# alexcas/archon-ai architecture

> Architecture diagram of the GitHub repository alexcas/archon-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexcas/archon-ai
- Repository: https://github.com/alexcas/archon-ai

## Overview

Archon is a Go CLI for setting up and maintaining an AI-assisted, spec-driven development harness in a project. The main user workflow is init → agent and skill setup → generated orchestrator/configuration, followed by TUI or CLI configuration and use of phase routing/state commands. The README also documents skill refresh, rollback, status, and model selection. The excerpts show init and workflow internals, but not all command handlers or map-generation code; those relationships are omitted where evidence is insufficient.

Main entry points: [`cmd/archon/main.go`](https://github.com/alexcas/archon-ai/blob/master/cmd/archon/main.go) (Archon commands), [`internal/initcmd/init.go`](https://github.com/alexcas/archon-ai/blob/master/internal/initcmd/init.go) (Initialize harness), [`internal/tui/model.go`](https://github.com/alexcas/archon-ai/blob/master/internal/tui/model.go) (Terminal interface), [`internal/route/resolve.go`](https://github.com/alexcas/archon-ai/blob/master/internal/route/resolve.go) (Phase router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and configuration"]
  node_commands["Archon commands<br/>[main.go]"]
  node_configcmd["Config commands<br/>[config.go]"]
  node_config[("Harness config<br/>[config.go]")]
  node_status["Harness status<br/>[display.go]"]
end

subgraph group_setup["Harness setup"]
  node_init["Initialize harness<br/>[init.go]"]
  node_agent["Agent detection<br/>[detect.go]"]
  node_skills["Embedded skills<br/>[embed.go]"]
  node_scaffold["Skill extraction<br/>[extract.go]"]
  node_templates["Orchestrator templates<br/>[templates.go]"]
  node_refresh["Skill refresh<br/>[update.go]"]
  node_rollback["Rollback tracking<br/>[rollback.go]"]
end

subgraph group_workflow["SDD workflow"]
  node_router["Phase router<br/>[resolve.go]"]
  node_discovery["Change discovery<br/>[discover.go]"]
  node_state[("Phase state machine<br/>[workflow.go]")]
  node_mapgen["Project map generation<br/>[mapgen.go]"]
end

subgraph group_interactive["Interactive configuration"]
  node_tui["Terminal interface<br/>[model.go]"]
  node_models["Model catalog<br/>[resolve.go]"]
  node_opencode["OpenCode catalog access<br/>[models.go]"]
end

node_user(("Project user"))

node_user -->|"runs"| node_commands
node_commands -->|"initializes"| node_init
node_init -->|"detects"| node_agent
node_init -->|"extracts skills"| node_scaffold
node_skills -->|"provides embedded files"| node_scaffold
node_init -->|"writes instructions"| node_templates
node_init -->|"creates config"| node_config
node_commands -->|"updates skills"| node_refresh
node_commands -->|"removes created files"| node_rollback
node_commands -->|"reports status"| node_status
node_commands -->|"manages settings"| node_configcmd
node_configcmd -->|"reads and writes"| node_config
node_user -->|"configures interactively"| node_tui
node_tui -->|"saves settings"| node_config
node_tui -->|"loads model choices"| node_models
node_models -->|"reads catalog"| node_opencode
node_user -->|"submits phase request"| node_router
node_commands -->|"routes requests"| node_router
node_router -.->|"uses change context"| node_discovery
node_commands -->|"reports phase status"| node_state
node_commands -.->|"offers map generation"| node_mapgen

click node_commands "https://github.com/alexcas/archon-ai/blob/master/cmd/archon/main.go"
click node_configcmd "https://github.com/alexcas/archon-ai/blob/master/cmd/archon/config.go"
click node_config "https://github.com/alexcas/archon-ai/blob/master/internal/config/config.go"
click node_init "https://github.com/alexcas/archon-ai/blob/master/internal/initcmd/init.go"
click node_agent "https://github.com/alexcas/archon-ai/blob/master/internal/agent/detect.go"
click node_skills "https://github.com/alexcas/archon-ai/blob/master/skills/embed.go"
click node_scaffold "https://github.com/alexcas/archon-ai/blob/master/internal/scaffold/extract.go"
click node_templates "https://github.com/alexcas/archon-ai/blob/master/internal/initcmd/templates.go"
click node_refresh "https://github.com/alexcas/archon-ai/blob/master/internal/initcmd/update.go"
click node_rollback "https://github.com/alexcas/archon-ai/blob/master/internal/config/rollback.go"
click node_status "https://github.com/alexcas/archon-ai/blob/master/internal/status/display.go"
click node_router "https://github.com/alexcas/archon-ai/blob/master/internal/route/resolve.go"
click node_discovery "https://github.com/alexcas/archon-ai/blob/master/internal/route/discover.go"
click node_state "https://github.com/alexcas/archon-ai/blob/master/internal/workflow/workflow.go"
click node_mapgen "https://github.com/alexcas/archon-ai/blob/master/internal/mapgen/mapgen.go"
click node_tui "https://github.com/alexcas/archon-ai/blob/master/internal/tui/model.go"
click node_models "https://github.com/alexcas/archon-ai/blob/master/internal/models/resolve.go"
click node_opencode "https://github.com/alexcas/archon-ai/blob/master/internal/opencode/models.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_commands,node_configcmd,node_config,node_status,node_user toneBlue
class node_init,node_agent,node_skills,node_scaffold,node_templates,node_refresh,node_rollback toneAmber
class node_router,node_discovery,node_state,node_mapgen toneMint
class node_tui,node_models,node_opencode toneRose
```

## Components

### CLI and configuration

- [Archon commands](https://github.com/alexcas/archon-ai/blob/master/cmd/archon/main.go): `cmd/archon/main.go`
- [Config commands](https://github.com/alexcas/archon-ai/blob/master/cmd/archon/config.go): `cmd/archon/config.go`
- [Harness config](https://github.com/alexcas/archon-ai/blob/master/internal/config/config.go): `internal/config/config.go`
- [Harness status](https://github.com/alexcas/archon-ai/blob/master/internal/status/display.go): `internal/status/display.go`

### Harness setup

- [Initialize harness](https://github.com/alexcas/archon-ai/blob/master/internal/initcmd/init.go): `internal/initcmd/init.go`
- [Agent detection](https://github.com/alexcas/archon-ai/blob/master/internal/agent/detect.go): `internal/agent/detect.go`
- [Embedded skills](https://github.com/alexcas/archon-ai/blob/master/skills/embed.go): `skills/embed.go`
- [Skill extraction](https://github.com/alexcas/archon-ai/blob/master/internal/scaffold/extract.go): `internal/scaffold/extract.go`
- [Orchestrator templates](https://github.com/alexcas/archon-ai/blob/master/internal/initcmd/templates.go): `internal/initcmd/templates.go`
- [Skill refresh](https://github.com/alexcas/archon-ai/blob/master/internal/initcmd/update.go): `internal/initcmd/update.go`
- [Rollback tracking](https://github.com/alexcas/archon-ai/blob/master/internal/config/rollback.go): `internal/config/rollback.go`

### SDD workflow

- [Phase router](https://github.com/alexcas/archon-ai/blob/master/internal/route/resolve.go): `internal/route/resolve.go`
- [Change discovery](https://github.com/alexcas/archon-ai/blob/master/internal/route/discover.go): `internal/route/discover.go`
- [Phase state machine](https://github.com/alexcas/archon-ai/blob/master/internal/workflow/workflow.go): `internal/workflow/workflow.go`
- [Project map generation](https://github.com/alexcas/archon-ai/blob/master/internal/mapgen/mapgen.go): `internal/mapgen/mapgen.go`

### Interactive configuration

- [Terminal interface](https://github.com/alexcas/archon-ai/blob/master/internal/tui/model.go): `internal/tui/model.go`
- [Model catalog](https://github.com/alexcas/archon-ai/blob/master/internal/models/resolve.go): `internal/models/resolve.go`
- [OpenCode catalog access](https://github.com/alexcas/archon-ai/blob/master/internal/opencode/models.go): `internal/opencode/models.go`

### Other components

- **Project user**

## Connections

- Project user → Archon commands: runs (evidence: `README.md`)
- Archon commands → Initialize harness: initializes (evidence: `README.md`)
- Initialize harness → Agent detection: detects (evidence: `internal/initcmd/init.go`)
- Initialize harness → Skill extraction: extracts skills (evidence: `internal/initcmd/init.go`)
- Embedded skills → Skill extraction: provides embedded files (evidence: `README.md`)
- Initialize harness → Orchestrator templates: writes instructions (evidence: `README.md`)
- Initialize harness → Harness config: creates config (evidence: `README.md`)
- Archon commands → Skill refresh: updates skills (evidence: `README.md`)
- Archon commands → Rollback tracking: removes created files (evidence: `README.md`)
- Archon commands → Harness status: reports status (evidence: `README.md`)
- Archon commands → Config commands: manages settings (evidence: `cmd/archon/main.go`)
- Config commands → Harness config: reads and writes (evidence: `cmd/archon/config.go`)
- Project user → Terminal interface: configures interactively (evidence: `README.md`)
- Terminal interface → Harness config: saves settings (evidence: `internal/tui/model.go`)
- Terminal interface → Model catalog: loads model choices (evidence: `internal/tui/model.go`)
- Model catalog → OpenCode catalog access: reads catalog (evidence: `internal/models/resolve.go`)
- Project user → Phase router: submits phase request (evidence: `README.md`)
- Archon commands → Phase router: routes requests (evidence: `cmd/archon/main.go`)
- Phase router → Change discovery: uses change context
- Archon commands → Phase state machine: reports phase status (evidence: `cmd/archon/main.go`)
- Archon commands → Project map generation: offers map generation
