Azycode is a dependency-free Node.js CLI. The main process owns:
| Module | Responsibility |
|---|---|
src/cli.js |
Command routing, help topics, interactive prompts |
src/agent.js |
Coding harness loop, tool dispatch, session events |
src/llm.js |
OpenAI-compatible fetch, timeout, retry, streaming |
src/providers.js |
Provider presets, capability registry, diagnostics |
src/config.js |
Persisted config/state, validation, caching |
src/tools.js |
Filesystem, search, patch, shell, git tools |
src/permissions.js |
Permission profiles and per-tool policy resolution |
src/path-guard.js |
Protected path checks for write tools |
src/shell-risk.js |
Shell command risk classification |
src/guard.js |
Git branch guard (main/master protection) |
src/execution-policy.js |
Execution policy abstraction |
src/sandbox.js |
Optional Docker/Podman/local sandbox backends |
src/exec.js |
Cancellable subprocess execution with byte limits |
src/context.js |
Layered context retrieval and context packs |
src/compaction.js |
Conversation trimming and deterministic/LLM compaction |
src/missions.js |
Mission load/plan/run, schema validation, dry-run |
src/subagents.js |
Subagent registry, parallel runs, worktree isolation |
src/skills.js |
Global and project skills, activation rules, import/export |
src/commands.js |
Markdown custom commands with frontmatter |
src/mcp.js |
Stdio MCP clients, tool policy, probe/inspect |
src/local-review.js |
Local git-diff security heuristics |
src/security-review.js |
Security review orchestration and test recommendations |
src/patch-validation.js |
Isolated worktree patch validation |
src/memory.js |
Long-lived local notes |
src/hooks.js |
Configurable lifecycle hooks |
src/bench.js |
Internal benchmark harness |
src/tui.js / src/ui.js |
Interactive terminal UI |
src/harness.js |
Progress formatting, runtime snapshots, abort handling |
src/logger.js |
Leveled logging (AZYCODE_LOG_LEVEL, AZYCODE_DEBUG) |
The CLI entrypoint is bin/azycode.js. All runtime behavior lives under this repository's src/ directory — it is not a wrapper around another harness.
Default config directory is ~/.azycode; set AZYCODE_HOME to isolate a project, test run, or CI environment.
The CLI stores keys with 0600 file permissions. It does not hardcode user keys and can also read provider-specific environment variables.
Config, state, and todos are loaded with an in-memory cache keyed on file mtime. Config values are validated on load: unknown modes, reasoning levels, permission profiles, sandbox modes, and tool policies are normalized to safe defaults.
Notable config keys:
permissionProfile—normal,read-only,plan-only,safe-write,trusted-workspace,full-autogitGuard— enabled by default; blocks writes onmain/masterpathGuard— protects.git,.env, lockfiles, CI workflowsshellPolicy— destructive/network/secret-risk command handlingsandbox—mode,network, mounts, env allowlistmcpServers— stdio MCP server definitions with tool policysubagentIsolation—same-workspaceorworktree
The loop sends:
- mode-specific system prompt
- applied skills (explicit or activation-matched)
- project instructions (
AGENTS.md,.azycode/rules.md) - relevant memory and active todos
- optional context pack
- user task
- OpenAI tool schemas
- structured tool results until the model returns a final assistant message
Risky tools ask for approval unless alwaysApprove is enabled or policy is changed. Git guard and path guard are separate from approval and still apply.
Agent runs emit progress events, persist recent tool execution records, and expose formatted transcripts. Optional context packs use layered retrieval with per-section byte budgets and untrusted-data wrapping.
Missions (src/missions.js):
- Load
.json,.yml, or.yamlmission files validateMissionchecks modes, agents, maxSteps, dependencies, and cyclesbuildMissionDryRunexposes ordered steps, parallel groups, risk, and permission metadatarunMissionexecutes steps sequentially or in parallel groups, passing context between dependent steps
Subagents (src/subagents.js):
- Built-in profiles: planner, reviewer, implementer, explorer
runSubagentsParallelbatches tasks with depth limits- Optional
subagentIsolation: worktreecreates isolated git worktrees under.azycode/worktrees/ - Results include duration, changed files, verification hints, and confidence
Skills — global entries in config; project entries in .azycode/skills/*.md. Skills support activation keyword rules and JSON import/export.
Custom commands — markdown files in ~/.azycode/commands/ and .azycode/commands/. Frontmatter supports name, description, scope, and args. Prompts can use {{args}}.
MCP — stdio JSON-RPC clients with startup/request timeouts, env allowlists, tool allow/deny policy, collision detection, and CLI probe/inspect/resources/prompts commands.
Hooks — configured shell commands on agent lifecycle events.
Local review (local-review.js) scans git diffs for secrets, injection patterns, SSRF, weak crypto, CI workflow changes, package script risks, and more.
Security review (security-review.js) combines local findings with test recommendations and an optional model-backed security prompt via azycode review --security.
Patch validation (patch-validation.js) applies patches in an isolated git worktree, runs optional verification commands, and never mutates the main workspace.
The model client supports:
- OpenAI Chat Completions for OpenAI-compatible providers
- OpenAI Responses API when
api-modeisresponses - Anthropic Messages normalization for OpenCode Go models that use
/messages - Model-based routing for OpenCode Go, because its documented endpoints differ by model family
- Capability registry and
status/health --jsondiagnostics
npm test runs the Node.js built-in test runner (node --test). Tests cover CLI flows, agent behavior, permissions, sandbox command builders, MCP fake server fixtures, mission validation, subagent isolation, security review, and patch validation.