# dealignai/mythos-router architecture

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

- Interactive diagram: https://gitdiagram.com/dealignai/mythos-router
- Repository: https://github.com/dealignai/mythos-router

## Overview

mythos-router is a local CLI for AI-assisted coding with Claude, filesystem write verification, and persistent project memory. The main workflow starts at `chat`: it sends conversation turns to Claude, checks claimed file actions against filesystem snapshots, and records results in memory; session budgets constrain the interaction. Separate `verify` and `dream` commands scan for memory drift and compress older logs. The SDK also exposes the verification engine and memory/client APIs. Some command internals were only partially sampled, so unsupported call links are omitted.

Main entry points: [`src/commands/chat.ts`](https://github.com/dealignai/mythos-router/blob/main/src/commands/chat.ts) (Chat Command), [`src/client.ts`](https://github.com/dealignai/mythos-router/blob/main/src/client.ts) (Model Client), [`src/memory.ts`](https://github.com/dealignai/mythos-router/blob/main/src/memory.ts) (Memory Manager), [`src/cli.ts`](https://github.com/dealignai/mythos-router/blob/main/src/cli.ts) (CLI Router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and SDK"]
  node_cli["CLI Router<br/>[cli.ts]"]
  node_sdk["SDK Exports<br/>[index.ts]"]
  node_terminal_utils["Terminal Utilities<br/>[utils.ts]"]
end

subgraph group_chat["Chat Session"]
  node_chat_command["Chat Command<br/>[chat.ts]"]
  node_model_client["Model Client<br/>[client.ts]"]
  node_configuration["Model Config<br/>[config.ts]"]
  node_budget["Session Budget<br/>[budget.ts]"]
end

subgraph group_integrity["Verification"]
  node_swd["Write Discipline<br/>[swd.ts]"]
  node_verify_command["Drift Scanner<br/>[verify.ts]"]
end

subgraph group_memory["Project Memory"]
  node_dream_command["Memory Dream<br/>[dream.ts]"]
  node_memory_manager["Memory Manager<br/>[memory.ts]"]
  node_memory_file["MEMORY.md"]
end

node_developer(("Developer"))
node_anthropic["Anthropic API"]
node_filesystem["Project Files"]

node_developer -->|"runs command"| node_cli
node_cli -->|"dispatches chat"| node_chat_command
node_cli -->|"dispatches verify"| node_verify_command
node_cli -->|"dispatches dream"| node_dream_command
node_chat_command -->|"streams turns"| node_model_client
node_model_client -->|"requests responses"| node_anthropic
node_model_client -->|"validates key"| node_configuration
node_chat_command -->|"checks file actions"| node_swd
node_swd -->|"snapshots and verifies"| node_filesystem
node_chat_command -->|"logs session results"| node_memory_manager
node_memory_manager -->|"reads and writes"| node_memory_file
node_verify_command -->|"reads and logs"| node_memory_manager
node_verify_command -->|"scans project"| node_filesystem
node_dream_command -->|"compresses entries"| node_memory_manager
node_dream_command -->|"requests summary"| node_model_client
node_chat_command -.->|"tracks session limits"| node_budget
node_developer -->|"uses programmatic API"| node_sdk
node_sdk -->|"exports engine"| node_swd
node_sdk -->|"exports client"| node_model_client
node_sdk -->|"exports memory API"| node_memory_manager

click node_cli "https://github.com/dealignai/mythos-router/blob/main/src/cli.ts"
click node_chat_command "https://github.com/dealignai/mythos-router/blob/main/src/commands/chat.ts"
click node_sdk "https://github.com/dealignai/mythos-router/blob/main/src/index.ts"
click node_model_client "https://github.com/dealignai/mythos-router/blob/main/src/client.ts"
click node_configuration "https://github.com/dealignai/mythos-router/blob/main/src/config.ts"
click node_budget "https://github.com/dealignai/mythos-router/blob/main/src/budget.ts"
click node_swd "https://github.com/dealignai/mythos-router/blob/main/src/swd.ts"
click node_verify_command "https://github.com/dealignai/mythos-router/blob/main/src/commands/verify.ts"
click node_dream_command "https://github.com/dealignai/mythos-router/blob/main/src/commands/dream.ts"
click node_memory_manager "https://github.com/dealignai/mythos-router/blob/main/src/memory.ts"
click node_terminal_utils "https://github.com/dealignai/mythos-router/blob/main/src/utils.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_cli,node_sdk,node_terminal_utils toneBlue
class node_chat_command,node_model_client,node_configuration,node_budget toneAmber
class node_swd,node_verify_command,node_anthropic toneMint
class node_dream_command,node_memory_manager,node_memory_file toneRose
class node_developer,node_filesystem toneIndigo
```

## Components

### CLI and SDK

- [CLI Router](https://github.com/dealignai/mythos-router/blob/main/src/cli.ts): `src/cli.ts`
- [SDK Exports](https://github.com/dealignai/mythos-router/blob/main/src/index.ts): `src/index.ts`
- [Terminal Utilities](https://github.com/dealignai/mythos-router/blob/main/src/utils.ts): `src/utils.ts`

### Chat Session

- [Chat Command](https://github.com/dealignai/mythos-router/blob/main/src/commands/chat.ts): `src/commands/chat.ts`
- [Model Client](https://github.com/dealignai/mythos-router/blob/main/src/client.ts): `src/client.ts`
- [Model Config](https://github.com/dealignai/mythos-router/blob/main/src/config.ts): `src/config.ts`
- [Session Budget](https://github.com/dealignai/mythos-router/blob/main/src/budget.ts): `src/budget.ts`

### Verification

- [Write Discipline](https://github.com/dealignai/mythos-router/blob/main/src/swd.ts): `src/swd.ts`
- [Drift Scanner](https://github.com/dealignai/mythos-router/blob/main/src/commands/verify.ts): `src/commands/verify.ts`

### Project Memory

- [Memory Dream](https://github.com/dealignai/mythos-router/blob/main/src/commands/dream.ts): `src/commands/dream.ts`
- [Memory Manager](https://github.com/dealignai/mythos-router/blob/main/src/memory.ts): `src/memory.ts`
- **MEMORY.md**

### Other components

- **Developer**
- **Anthropic API**
- **Project Files**

## Connections

- Developer → CLI Router: runs command (evidence: `README.md`)
- CLI Router → Chat Command: dispatches chat (evidence: `src/cli.ts`)
- CLI Router → Drift Scanner: dispatches verify (evidence: `src/cli.ts`)
- CLI Router → Memory Dream: dispatches dream (evidence: `src/cli.ts`)
- Chat Command → Model Client: streams turns (evidence: `src/commands/chat.ts`)
- Model Client → Anthropic API: requests responses (evidence: `src/client.ts`)
- Model Client → Model Config: validates key (evidence: `src/client.ts`)
- Chat Command → Write Discipline: checks file actions (evidence: `src/commands/chat.ts`)
- Write Discipline → Project Files: snapshots and verifies (evidence: `src/swd.ts`)
- Chat Command → Memory Manager: logs session results (evidence: `src/commands/chat.ts`)
- Memory Manager → MEMORY.md: reads and writes (evidence: `src/memory.ts`)
- Drift Scanner → Memory Manager: reads and logs (evidence: `src/commands/verify.ts`)
- Drift Scanner → Project Files: scans project (evidence: `README.md`)
- Memory Dream → Memory Manager: compresses entries (evidence: `src/commands/dream.ts`)
- Memory Dream → Model Client: requests summary (evidence: `src/commands/dream.ts`)
- Chat Command → Session Budget: tracks session limits (evidence: `src/commands/chat.ts`)
- Developer → SDK Exports: uses programmatic API (evidence: `README.md`)
- SDK Exports → Write Discipline: exports engine (evidence: `src/index.ts`)
- SDK Exports → Model Client: exports client (evidence: `src/index.ts`)
- SDK Exports → Memory Manager: exports memory API (evidence: `src/index.ts`)
