AutoCode is organized around a local agent runtime that turns a user task into bounded repository context, model calls, tool execution, verification, and a persisted session record.
User task
-> CLI runtime
-> repository summary and retrieval
-> task-context assembly
-> model client
-> protocol parser
-> tool permission gate
-> tool execution
-> verification/report/session persistence
The runtime layer owns the command-line interface, terminal UI, permissions,
task execution, session persistence, reports, and verification state. The main
entry point is src/index.ts.
Important runtime areas:
runtime/cliTaskExecutor.ts: headless task execution wiring.runtime/tui/: interactive terminal UI.runtime/permissions.ts: approval-mode enforcement.runtime/sessionStore.ts: persisted run snapshots.runtime/taskRunReport.ts: text and Markdown report rendering.runtime/taskRunTypes.ts: task-run mode and result contracts.
The core layer owns prompt construction, the model-response protocol, parsing, recovery, and tool-call orchestration. It is intentionally explicit so that tool use and verification can be audited from session records.
Important core areas:
core/agent.ts: main agent loop and tool protocol handling.core/protocol.ts: structured response parsing and turn schema handling.core/structuredRetryTarget.ts: recovery targeting for malformed or failed responses.core/evidenceShapeMatrix.ts: evidence and recovery behavior checks.
The repository layer builds a lightweight model of the target workspace: files, projects, dependency edges, symbols, symbol references, and ignore rules. This repository model feeds retrieval, context assembly, and impact tools.
Important repository areas:
repo/repoSummaryBuilder.ts: workspace summary construction.repo/repositoryProjectDetection.ts: project-boundary detection.repo/repositorySymbolGraph.ts: symbol graph extraction.repo/repositorySymbolReferences.ts: reference discovery.repo/workspaceIgnore.ts: ignored-path handling.
The retrieval layer ranks files and neighbors for a user query. The context layer turns that retrieval output into compact task context, optionally with focused compaction settings for large repositories.
Important areas:
retrieval/: query terms, scoring, ranking, and graph-neighbor retrieval.context/: task context, memory loading, compaction, and prompt assembly.
Model access is isolated behind a small ModelClient interface. The default
runtime supports:
mock: deterministic local test provider.openai-compatible: configurable HTTP provider for compatible endpoints.
Configuration is resolved from shell environment variables and ignored local env files. Public examples should never contain real credentials.
Built-in tools cover repository inspection, file reads, search, patching, shell verification, dependency paths, symbol graphs, symbol references, and impact-oriented queries. Permission checks happen before tools that can write files or run commands.
AutoCode supports multiple task modes:
single: one agent loop handles the task.multi: sequential role-style orchestration.graph: fixed-stage graph runtime scaffold.
The multi-stage modes are useful for structured experiments, but the stable
baseline for ordinary local use is still single.