Imported from dbowm91/codegg (
AGENTS.md). Install upstream withnpx skills add dbowm91/codegg. Copyright stays with the author.
AGENTS.md
Quick start
Rust 1.89+, edition 2021.
scripts/verify.sh quick # canonical sanity: fmt, agent schema, core-boundary, sandbox,
# execution-ownership, tui-authority, http-route-disposition,
# audit-coverage, scheduler-bypass guards, cargo check workspace
scripts/verify.sh full # quick + clippy (-D warnings) + workspace tests +
# cargo test -p codegg --features server,plugins,lsp-test-support
cargo fmt # rustfmt: max_width 100, 4-space; non-Rust files use 2-space
Both verify modes cap resources (CARGO_BUILD_JOBS=1, --test-threads=1). dbg!/println!
are allowed in tests (clippy.toml).
Layout
- Root crate
codegg(src/): TUI, agent loop, tools, scheduler, server, auth.src/lib.rsre-exportscodegg_protocol as protocol,codegg_providers as provider, andcodegg_config as config— there is nosrc/protocol/,src/provider/, orsrc/config/implementation directory. crates/: 9 crates (+ root = 10 workspace members inCargo.toml) —codegg-core(domain types: bus, jobs, session, storage, workspace; must stay UI/server/plugin/auth-free, enforced byscripts/check-core-boundary.sh),codegg-config,codegg-protocol,codegg-providers,codegg-git(typed git ops + risk),egglsp(authoritative LSP;src/lsp/is a thin shim),egggit(read-only git facts),eggsentry(security scanning),eggcontext(tokens).crates/egglsp-test-server/is NOT a member; it builds thecodegg-lsp-test-serverbinary behindlsp-test-support.- Workspace ownership: root
Cargo.toml[workspace.package]/[workspace.dependencies]own shared versions/default policy; members use*.workspace = trueplus only their local features (minimal baseline — member manifests add only what they need;serdekeeps no workspace features). Single-consumer deps stay local.[workspace.lints] unsafe_code = "deny"is inherited via[lints] workspace = true(e.g.codegg-core); the root package intentionally does NOT inherit it becausesrc/bin/codegg-sandbox-helper.rshas deliberate reviewedunsafe— the lib enforces#![deny(unsafe_code)]insrc/lib.rsinstead. - Aliases (
.cargo/config.toml):cargo ck(workspace check),ckroot ckcore ckprotocol ckconfig ckproviders ckgit cksplit. - Features:
server(axum HTTP/WS),plugins(wasmtime),image,lsp-test-support(fake-LSP harness),lsp-real-server-tests(needs installed servers — never in default sweeps),arboard(default). Never--all-featuresfor workspace sweeps; it drags in real-server tests.verify.sh fulluses--features server,plugins,lsp-test-supportinstead.
Testing
Prefer the narrowest target covering the change; run verify.sh quick first.
cargo test -p codegg-core # single crate
cargo test --test tui_render # single integration test
cargo test -p egglsp --features lsp-test-support --test scenario_engine # LSP (needs feature)
CARGO_BUILD_JOBS=1 cargo test --workspace --locked -- --test-threads=1 # capped full suite
- New
#[tokio::test]s default tocurrent_thread; useflavor = "multi_thread", worker_threads = 2only for real concurrency/subprocesses. - Storage tests:
isolated_pool()(migrations run inside; never add extramigrate()). - Test profile strips debuginfo; restore backtraces with
RUSTFLAGS=-C debuginfo=2 cargo test …. - Plugin SDKs test separately:
examples/plugins/sdk-rust(cargo),examples/plugins/sdk-python(python3 -m unittest discover). - Full taxonomy, pool strategy, nextest profiles:
architecture/testing.md.
Change-triggered guards
verify.sh quick runs the routine subset. CI (.github/workflows/ci.yml) is one bounded
verify job: agent schema, core-boundary, sandbox, execution-ownership, tui-authority,
http-route-disposition, audit-coverage, scheduler-bypass, fmt, clippy, workspace tests.
Everything else is change-triggered (ls scripts/check_*
for the full list):
codegg-coreor workspace deps →bash scripts/check-core-boundary.sh- Process spawning / execution surfaces →
python3 scripts/check_execution_ownership.pyand keepdocs/execution-ownership.tomlin sync; scheduler changes also needcheck_scheduler_bypass.py; daemon path handling needscheck_daemon_cwd_usage.py(nostd::env::current_dir()in workspace-bound daemon code — threadExecutionContext) assets/agents/*.tomlorassets/prompts/→python3 scripts/generate_builtin_agents.pyto regeneratesrc/agent/builtins/generated.rs(never edit it);--checkin CI- Git risk/policy →
check_git_forbidden_patterns.py; storage layout →check_project_catalog_invariants.py(STORAGE_LAYOUT_VERSIONmust track the highest migration insession/schema.rs); projection transport →check_projection_*.py+check_websocket_bounds.py; provider lifecycle →check_provider_connections_*.sh
Gotchas
PermissionRegistry/QuestionRegistryare sync (register/respond/answer_questionarefn, notasync); register the responder BEFORE publishing the Pending event.ToolBrokeris the only production tool-call boundary. Heavy work (tests, managed processes, subagent dispatch, tool programs) goesJobSubmissionService→JobScheduler, never direct executor calls.egggitnever mutates; mutations live insrc/git_mutations.rs(+ network/config policy insrc/git_network_policy.rs).- Daemon is a user-scoped singleton (
flockondaemon.lock;CODEGG_DAEMON_HOMEoverrides). Plaincodeggconnects-or-starts (src/core/instance.rs);--standaloneis in-process core; theserverrequires--standalone-core. - Command intent defaults to
Observe(classify only); kill switchCODEGG_ROUTING_DISABLE=1. - Human
!cmdis hidden from the model;!!cmdpromotes (bounded/redacted) output. - Slow TUI handlers use
spawn_tui_task+finish(request_id)/fail(request_id, err)guard with a stale-completion test (seesrc/tui/async_cmd.rs). - Auth:
ExternalCommandis unsupported; never log secrets; adding any config-defined provider disables all env-var auto-registration. - New web-search providers belong in the external
eggsearchproject, notsrc/search/(legacy fallback). New deterministic validators go in theeggsactcrate first. New LSP servers go incrates/egglsp/src/server.rs+ config. - Semantic model routing is opt-in through exact
virtual:<name>aliases only; concrete models bypass it. It never changes durable session/provider-connection selection, only picks a compatible model through the already-selected connection. No local affinity cache (sticky/affinity_ttl_sare shared policy fields only). See README +architecture/config.mdfor the full contract.
Pointers
architecture/overview.mdis the module map; one doc per module underarchitecture/.plans/registry.mdis the authoritative milestone/roadmap status — check it before assuming any roadmap state..opencode/skills/*/SKILL.mdare on-demand module guides (load via the skill tool;ls .opencode/skills/for the list). Canonical location is.opencode/skills/;.skillsand.agents/skillsare symlinks to it. When a module contract changes, update the skill and itsarchitecture/doc together.docs/:execution-ownership.md(+.tomlmanifest),security-semantics.md,LSP.md/MCP.md/PLUGINS.md(user integration notes;architecture/is authoritative),TROUBLESHOOTING.md,dependency-maintenance.md,themes.md,validation/(historical closure records).