3code - developer docs

developer docs

Introduction

These are the developer docs: the internal API of 3code as extracted from the source by nim doc, every module, type, and proc with its doc comment. Where the manual shows you how to use the app and the reference lists every switch and config key, this half is for people embedding 3code in another program, writing a plugin, or changing 3code itself.

Start from the entry points:

Embedding

The headless frontend is threecode/library: it runs the same agent loop, tools, sandbox, and .3log sessions as the CLI, with the terminal replaced by return values and callbacks.

import threecode/library

let s = initAgentSession(AgentOptions(model: "deepinfra.deepseek-v3.2"))
echo s.prompt("what does this project do?")
s.close()

Module tour

The modules a host or contributor touches most, with their job in one line:

modulewhat lives there
turnsturn lifecycle orchestration
actionstool dispatch: model tool_call JSON into Actions, then execute
apiHTTP client and SSE parsing
sessionsession persistence in the .3log format
configconfig file parsing and provider/profile resolution
typesshared types and process-level globals
enginestateful terminal layout engine
minlinemultiline line editor
displaytranscript formatting: markdown, receipts, banners
webfetch and search helpers exposed as native tools

The root module's list also carries the newer surfaces (library for embedding, the plugin ABI, the sandbox and ACP frontends) and the long tail of wire translations, auth flows, and terminal internals.

Regenerating

These pages are generated, never hand edited. The doc comment in the source is the text; nimble devdocs rewrites docs/dev/ from src/:

nimble devdocs

Note: The API here is internal. It serves readers of the source and embedders who accept churn; nothing on these pages is a compatibility promise.