# suge8/firecode architecture

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

- Interactive diagram: https://gitdiagram.com/suge8/firecode
- Repository: https://github.com/suge8/firecode

## Overview

FireCode is a Pi coding-agent extension for parallel sub-agents, adversarial multi-model review, and a streamlined terminal UI. A user request enters Pi’s agent workflow; the Master can delegate work, review can send findings back for repair and re-review, and delivery routes results into the session. Watcher advice is an independent, optional branch. The excerpts establish shared busy-state, delivery, and tool-rendering behavior; several domain internals are unsampled, so their documented capabilities are shown without inferred call chains.

Main entry points: [`index.ts`](https://github.com/suge8/firecode/blob/main/index.ts) (Extension registration), [`master/run.ts`](https://github.com/suge8/firecode/blob/main/master/run.ts) (Master coordinator), [`review/index.ts`](https://github.com/suge8/firecode/blob/main/review/index.ts) (Review loop), [`busy.ts`](https://github.com/suge8/firecode/blob/main/busy.ts) (Shared activity state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Extension setup"]
  node_entrypoint["Extension registration<br/>[index.ts]"]
  node_configuration["Configuration<br/>[config.ts]"]
end

subgraph group_delegation["Delegation"]
  node_master["Master coordinator<br/>[run.ts]"]
  node_mastertools["Master actions and tools<br/>[actions.ts]"]
  node_worker["Sub-agent sessions<br/>[spawn.ts]"]
  node_workerui["Worker activity and views<br/>[worker-view.ts]"]
end

subgraph group_review["Review and advice"]
  node_review["Review loop<br/>[index.ts]"]
  node_reviewstate["Review state machine<br/>[state.ts]"]
  node_reviewevidence["Review evidence<br/>[evidence.ts]"]
  node_watcher["Watcher observer<br/>[index.ts]"]
end

subgraph group_runtime["Session runtime"]
  node_providers["Model providers<br/>[claude-sub.ts]"]
  node_openai["OpenAI native provider<br/>[extension.ts]"]
  node_delivery["Message delivery<br/>[deliver.ts]"]
  node_busy["Shared activity state<br/>[busy.ts]"]
  node_rounds["Session round records<br/>[round.ts]"]
  node_toolruntime["Agent tools<br/>[index.ts]"]
end

subgraph group_interface["Terminal interface"]
  node_toolviews["Tool output projection<br/>[group-view.ts]"]
  node_statusbar["Status bar<br/>[index.ts]"]
  node_format["Text formatting<br/>[format.ts]"]
  node_flame["Activity indicator<br/>[flame.ts]"]
  node_settings["Preset and quota commands<br/>[presets.ts]"]
end

node_user(("User"))
node_pi["Pi agent host"]

node_user -->|"requests work"| node_pi
node_pi -->|"loads extension"| node_entrypoint
node_entrypoint -->|"loads settings"| node_configuration
node_entrypoint -->|"registers coordinator"| node_master
node_entrypoint -->|"registers review"| node_review
node_entrypoint -->|"registers watcher"| node_watcher
node_entrypoint -->|"registers provider"| node_providers
node_entrypoint -->|"registers provider"| node_openai
node_master -->|"dispatches actions"| node_mastertools
node_master -.->|"spawns agents"| node_worker
node_master -->|"publishes activity"| node_workerui
node_review -->|"reduces events"| node_reviewstate
node_review -->|"builds evidence"| node_reviewevidence
node_review -->|"delivers feedback"| node_delivery
node_watcher -->|"delivers advice"| node_delivery
node_watcher -->|"observes activity"| node_busy
node_master -->|"publishes activity"| node_busy
node_rounds -->|"tracks activity"| node_busy
node_delivery -->|"sends session messages"| node_pi
node_toolruntime -->|"executes host tools"| node_pi
node_toolruntime -->|"renders tool output"| node_toolviews
node_toolviews -->|"formats content"| node_format
node_statusbar -->|"reads activity"| node_busy
node_statusbar -->|"formats status"| node_format
node_statusbar -->|"renders activity"| node_flame
node_user -->|"switches presets"| node_settings

click node_entrypoint "https://github.com/suge8/firecode/blob/main/index.ts"
click node_configuration "https://github.com/suge8/firecode/blob/main/config.ts"
click node_master "https://github.com/suge8/firecode/blob/main/master/run.ts"
click node_mastertools "https://github.com/suge8/firecode/blob/main/master/actions.ts"
click node_worker "https://github.com/suge8/firecode/blob/main/spawn.ts"
click node_workerui "https://github.com/suge8/firecode/blob/main/master/worker-view.ts"
click node_review "https://github.com/suge8/firecode/blob/main/review/index.ts"
click node_reviewstate "https://github.com/suge8/firecode/blob/main/review/state.ts"
click node_reviewevidence "https://github.com/suge8/firecode/blob/main/review/evidence.ts"
click node_watcher "https://github.com/suge8/firecode/blob/main/watcher/index.ts"
click node_providers "https://github.com/suge8/firecode/blob/main/provider/claude-sub.ts"
click node_openai "https://github.com/suge8/firecode/blob/main/provider/openai-native/src/extension.ts"
click node_delivery "https://github.com/suge8/firecode/blob/main/deliver.ts"
click node_busy "https://github.com/suge8/firecode/blob/main/busy.ts"
click node_rounds "https://github.com/suge8/firecode/blob/main/round.ts"
click node_toolruntime "https://github.com/suge8/firecode/blob/main/tools/index.ts"
click node_toolviews "https://github.com/suge8/firecode/blob/main/tools/group-view.ts"
click node_statusbar "https://github.com/suge8/firecode/blob/main/statusbar/index.ts"
click node_format "https://github.com/suge8/firecode/blob/main/format.ts"
click node_flame "https://github.com/suge8/firecode/blob/main/flame.ts"
click node_settings "https://github.com/suge8/firecode/blob/main/session/presets.ts"

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_entrypoint,node_configuration,node_user toneBlue
class node_master,node_mastertools,node_worker,node_workerui toneAmber
class node_review,node_reviewstate,node_reviewevidence,node_watcher toneMint
class node_providers,node_openai,node_delivery,node_busy,node_rounds,node_toolruntime toneRose
class node_toolviews,node_statusbar,node_format,node_flame,node_settings,node_pi toneIndigo
```

## Components

### Extension setup

- [Extension registration](https://github.com/suge8/firecode/blob/main/index.ts): `index.ts`
- [Configuration](https://github.com/suge8/firecode/blob/main/config.ts): `config.ts`

### Delegation

- [Master coordinator](https://github.com/suge8/firecode/blob/main/master/run.ts): `master/run.ts`
- [Master actions and tools](https://github.com/suge8/firecode/blob/main/master/actions.ts): `master/actions.ts`
- [Sub-agent sessions](https://github.com/suge8/firecode/blob/main/spawn.ts): `spawn.ts`
- [Worker activity and views](https://github.com/suge8/firecode/blob/main/master/worker-view.ts): `master/worker-view.ts`

### Review and advice

- [Review loop](https://github.com/suge8/firecode/blob/main/review/index.ts): `review/index.ts`
- [Review state machine](https://github.com/suge8/firecode/blob/main/review/state.ts): `review/state.ts`
- [Review evidence](https://github.com/suge8/firecode/blob/main/review/evidence.ts): `review/evidence.ts`
- [Watcher observer](https://github.com/suge8/firecode/blob/main/watcher/index.ts): `watcher/index.ts`

### Session runtime

- [Model providers](https://github.com/suge8/firecode/blob/main/provider/claude-sub.ts): `provider/claude-sub.ts`
- [OpenAI native provider](https://github.com/suge8/firecode/blob/main/provider/openai-native/src/extension.ts): `provider/openai-native/src/extension.ts`
- [Message delivery](https://github.com/suge8/firecode/blob/main/deliver.ts): `deliver.ts`
- [Shared activity state](https://github.com/suge8/firecode/blob/main/busy.ts): `busy.ts`
- [Session round records](https://github.com/suge8/firecode/blob/main/round.ts): `round.ts`
- [Agent tools](https://github.com/suge8/firecode/blob/main/tools/index.ts): `tools/index.ts`

### Terminal interface

- [Tool output projection](https://github.com/suge8/firecode/blob/main/tools/group-view.ts): `tools/group-view.ts`
- [Status bar](https://github.com/suge8/firecode/blob/main/statusbar/index.ts): `statusbar/index.ts`
- [Text formatting](https://github.com/suge8/firecode/blob/main/format.ts): `format.ts`
- [Activity indicator](https://github.com/suge8/firecode/blob/main/flame.ts): `flame.ts`
- [Preset and quota commands](https://github.com/suge8/firecode/blob/main/session/presets.ts): `session/presets.ts`

### Other components

- **User**
- **Pi agent host**

## Connections

- User → Pi agent host: requests work (evidence: `README.md`)
- Pi agent host → Extension registration: loads extension (evidence: `index.ts`)
- Extension registration → Configuration: loads settings (evidence: `index.ts`)
- Extension registration → Master coordinator: registers coordinator (evidence: `index.ts`)
- Extension registration → Review loop: registers review (evidence: `index.ts`)
- Extension registration → Watcher observer: registers watcher (evidence: `index.ts`)
- Extension registration → Model providers: registers provider (evidence: `index.ts`)
- Extension registration → OpenAI native provider: registers provider (evidence: `index.ts`)
- Master coordinator → Master actions and tools: dispatches actions (evidence: `master/index.ts`)
- Master coordinator → Sub-agent sessions: spawns agents (evidence: `README.md`)
- Master coordinator → Worker activity and views: publishes activity
- Review loop → Review state machine: reduces events (evidence: `review/index.ts`)
- Review loop → Review evidence: builds evidence (evidence: `review/index.ts`)
- Review loop → Message delivery: delivers feedback (evidence: `review/index.ts`)
- Watcher observer → Message delivery: delivers advice (evidence: `watcher/index.ts`)
- Watcher observer → Shared activity state: observes activity (evidence: `watcher/index.ts`)
- Master coordinator → Shared activity state: publishes activity (evidence: `master/index.ts`)
- Session round records → Shared activity state: tracks activity (evidence: `round.ts`)
- Message delivery → Pi agent host: sends session messages (evidence: `deliver.ts`)
- Agent tools → Pi agent host: executes host tools (evidence: `tools/index.ts`)
- Agent tools → Tool output projection: renders tool output (evidence: `tools/index.ts`)
- Tool output projection → Text formatting: formats content (evidence: `tools/group-view.ts`)
- Status bar → Shared activity state: reads activity (evidence: `statusbar/index.ts`)
- Status bar → Text formatting: formats status (evidence: `statusbar/index.ts`)
- Status bar → Activity indicator: renders activity (evidence: `statusbar/index.ts`)
- User → Preset and quota commands: switches presets (evidence: `README.md`)
