Repository navigation
development cookbook
github-actions[bot] edited this page Oct 18, 2026
·
53 revisions
Step-by-step recipes for common changes. Each lists files, order, tests, and docs. Testing detail: Testing. Package context: architecture portal.
- Implement handler in
internal/agent/commands/(new file or existing). - Register in
builtin_slash.go(Registryentry with names + help text). - Ensure
help.golists it (sorted catalogue for/help). - Wire callbacks on
commands.Depsif the command needs runtime state — set inslash_deps.go. - Optional: first-arg completion in
replcomplete/slash_args.go. - Test:
test/slash_dispatch_test.gousingtestDeps. - Docs: Usage and commands if user-facing.
Do not parse slash lines outside slash/dispatch.go.
- Implement tool in
internal/agent/tools/(handler func). - Register OpenAI schema in
params.gofor the rightMode(s). - Route execution in
exec.go(mode guards,switchon tool name). - If the tool needs env/context, extend
toolenv/env.go, wire fields inruntime/exec.gotoolEnv(), read from handler viatools.Envalias (tools/env.go). - Optional: plan/build dump strings in
dump_*.goif the tool should appear in system prompt listings. - Test: new or extended file in
test/witht.TempDir()for filesystem tools. - Docs: Native tools, Plan vs build if mode-specific.
MCP tools are separate — configure mcp.json, not this path (MCP integration).
- Stream loop:
internal/agent/runtime/turns.go. - Native vs legacy resolution:
legacy.go. - Terminal tool lines / legacy stream writer:
tool_print.go. - XML parse/stream:
internal/tooling/. - Test:
legacy_runtime_test.go,legacy_tools_test.go. - Docs: Agent turn pipeline.
Preserve: fail-closed stream integrity (llm/stream/completion.go), SIGINT cancel via WithCancelCause.
- Keys/buffer:
repl/editor/read.go. - Redraw:
repl/editor/refresh.go. - Loop dispatch:
repl/loop.go. - Completion:
replcomplete/+ wiringreplcomplete_runtime.go. - Add test exports in
editor/editorhistory.goif needed. - Test:
repl_editor_test.go,repl_complete_*_test.go. - Docs: Runtime — REPL input.
- Implement
search.Enginein new file underinternal/search/. - Register in
web_search.goand config keys. - Test: focused test with HTTP stub if the engine calls the network.
- Docs: Configuration — web search, Supporting packages.
- Job lifecycle and record snapshots:
internal/research/job.goandtypes.go. - Engine rounds, extraction, and report rendering:
internal/research/engine.goandhtml/. - Runtime/native/slash surfaces:
researchmanager.go,deep_research.go, andresearch.go. - Keep status reads independent from background mutations; test the runtime and web adapters through
test/web_surfaces_test.goand run the Linux-racecommand before committing. - Docs: Deep research, Usage —
/research, Configuration, and Data layout.
- Provider config:
internal/config/, wizardcommands/connect/. - Backend factory:
internal/llm/factory.go. - Protocol adapter:
openai_backend.gooranthropic_*.go. - OAuth (ChatGPT Sub):
internal/auth/openai/codex/,providersetup/. - Test:
httptest— seeapi_resilience_*_test.go,provider_auth_test.go. - Docs: Configuration, LLM layer.
- Go process/install:
internal/integrations/cursor/. - Node proxy:
integrations/cursor/src/— especiallylegacy.ts,chat.ts. - Runtime hooks:
cursor_sidecar.go,cursor_native_display.go. - Rebuild embed:
go run scripts/cursor_bundler.go build && bundle(ormake build). - Test: Go
stream_cursor_tool_test.go; TSmake cursor-proxy-test. - Docs: Cursor integration — update tool bridge table if aliases change.
- Update the architecture or user article for the behavior change.
- Add or link tests in the article if non-obvious.
- Run
make check-docs(markdown links, anchors, cited paths, package index).
Design rationale stays in architecture articles; there is no separate ADR folder.