Source inventory

August 20, 2026 ยท View on GitHub

This inventory freezes the migration baseline at Zig commit fc124be (0.0.3). The source contains 541 Zig modules, 674,840 lines, 8,251 in-source unit tests, and 871 root end-to-end tests across 58 files. Counts include large test fixtures and generated Unicode tables, so line count is a scope signal, not an architectural target for the Rust rewrite.

Runtime domains

DomainFilesLinesTestsProduct responsibilityRust boundary
agent4052,895746model loop, stream recovery, parallel tool batches, interruption, finalizationfx-core orchestration
app3564,633865native composition, lifecycle, input actions, worker/UI coordinationACP-reachable composition only
auth97,354104API keys, OAuth, login, secret storesfx-provider, fx-auth
background109,21984supervised persistent background processesACP-reachable process capability; internal diagnostics only otherwise
cli616,107200top-level parsing and typed text/JSON snapshotsinternal test/diagnostic harness only
config109,175148layered settings, capabilities, prompt policyfx-config
execution72,17023local/devbox routing and process effectsfx-process
gateway core53,01450provider ports, catalog metadata, failure diagnosticsfx-core contracts
gateway adapter78,216130HTTP streaming, usage, web search, JS host adaptersbuilt-in modules in fx-provider
hooks61,62116lifecycle/prompt/tool hook contractsfx-core plus host adapters
hosts112,68640native/WASM/keychain/URL host capabilitiesnative capabilities required by ACP only
images24,36887attachment validation, snapshots, commandsfx-media candidate
input278,758111editor state, Unicode navigation, undo, selection, pasteout of scope
MCP3647,986361stdio/HTTP/SSE, OAuth, schema, resources/prompts/tools, lifecyclefx-mcp
output67,180102typed snapshots, transcript projection, diffs, activityfx-core snapshots plus frontends
permissions1315,995231rules, grants, auto review, sandbox admissionfx-core policy plus fx-process sandbox
sessions3961,715576event log, projections, migration/recovery, usage, catalogsfx-store
shared1718,014179domain types, Unicode/display helpers, diagnosticssplit by owning crate
shell command32,68966lexical command classification and effectsfx-process policy
skills46,08292discovery, invocation, commands, trust boundariesfx-tools::skills
slash commands22,99580registry, help, completion, routingout of scope
subagents2153,372338durable child identity, authority, communication, managerfx-core plus fx-store
terminal host1636,209274terminal sessions, tmux/native backends, recoveryfx-terminal candidate
tooling3130,856397registry, validation, admission, MCP bridge, result limitsfx-core contracts
workspace1915,524246path authority, indexes, search, context, metricsfx-workspace, fx-tools, and future fx-context
UI85128,5601,790terminal rendering, footer surfaces, transcript, resizeout of scope
ACP89,777118JSON-RPC server and editor session projectionfx-acp
built-ins1316,281291composition catalogs for commands, tools, gateway, MCP, modesrelevant composition crates

Smaller domains cover GitHub publishing, notifications, modes, upgrades, feedback, tasks, and generic registries. They remain separate feature slices rather than becoming layers of fx-core.

Source behavior surface

The top-level CLI has help, ask, ACP, PR/issue, authentication, status, permissions, models, doctor, background, teams, session inspection/listing, resume, credits, usage, upgrade, replay, and workspace management. Interactive mode adds 42 registered slash-command entries, including nested background actions, MCP and skills management, model/appearance/security settings, images, compaction, diagnostics, and session lifecycle.

Built-in tool families are:

  • filesystem observation: read_file, list_files, glob_files, grep_files, file_info, semantic_search, open_file;
  • filesystem mutation: write_file, edit_file, delete_file, rename_file, copy_file, create_folder;
  • execution: terminal sessions and background processes;
  • agent: user questions, vision, and subagents;
  • web: search and fetch;
  • extensions/state: skills, skill installation, memory, and stored tool-result reads;
  • dynamic MCP tools, prompts, resources, and completion.

This inventory describes the source, not the Rust product boundary. The rewrite uses ACP as its sole agent protocol and ports other behavior only when ACP exposes or depends on it. The Rust TUI is an ACP client rather than a second composition root.

Cross-cutting invariants found in source and tests

  • The Zig main.zig is a composition root, not the owner of leaf behavior.
  • Fast CLI paths run before configuration, credentials, network, threads, or terminal initialization.
  • Text and JSON output are rendered from the same typed snapshots.
  • Explicit absolute, home-relative, or lexically escaping paths express external intent; workspace-relative paths may not escape through symlinks.
  • Permission denies precede session grants. Yolo bypasses fx policy and uses no effective sandbox without rewriting the configured sandbox.
  • Agent-owned model attempts cannot also be retried by the transport after possible delivery.
  • Provider-executed tool results are projected but never locally re-executed.
  • Current sessions use an append-only, sequenced event log with atomic state replacement; legacy schema 1 and 2 snapshots migrate into schema 3 storage.
  • Child agents are ordinary durable sessions. Parent/child authority and create operation identity survive interruption and resume.
  • MCP transport callbacks do not run while reader/state locks are held, and a final precommit guard closes authorization races.
  • TUI tests cover rendering as a state machine under resize, interruption, terminal takeover, and partial gateway streams; a widget-by-widget port is therefore insufficient.

Migration order

  1. Freeze domain contracts, config precedence, permission order, path intent, and the ACP product boundary.
  2. Port read-only and mutation tools behind the registry, including read-before- write freshness evidence.
  3. Add streaming gateway transport and the minimal noninteractive agent loop.
  4. Add event-log sessions and recovery before interactive resume or subagents.
  5. Add MCP and ACP as protocol adapters over the established core.
  6. Port the terminal and extension capabilities reachable through ACP; omit WASM, N-API, and standalone SDK surfaces.
  7. Add the TUI as an isolated ACP client after the protocol semantics stabilize.
  8. Qualify ACP interoperability, semantic E2E parity, cold start, binary size, and failure recovery.