# mzpatrick0529-mzyh/claw-code architecture

> Architecture diagram of the GitHub repository mzpatrick0529-mzyh/claw-code, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mzpatrick0529-mzyh/claw-code
- Repository: https://github.com/mzpatrick0529-mzyh/claw-code

## Overview

This is a Python porting-workspace CLI, not yet a full agent-harness runtime. Its main user workflow is to invoke a CLI command and receive a workspace summary, manifest, or mirrored command/tool inventory; additional commands expose limited runtime simulations and parity reporting. The sampled sources support the summary, session, and several dispatch relationships. Other runtime details are inferred only from documented command surfaces, so uncertain internal wiring is omitted.

Main entry points: [`src/main.py`](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/main.py) (CLI dispatcher), [`src/query_engine.py`](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/query_engine.py) (Summary engine), [`src/port_manifest.py`](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/port_manifest.py) (Workspace manifest), [`src/commands.py`](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/commands.py) (Command inventory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_main["CLI dispatcher<br/>[main.py]"]
  node_query["Summary engine<br/>[query_engine.py]"]
  node_output["CLI output"]
end

subgraph group_inventory["Port inventory"]
  node_manifest["Workspace manifest<br/>[port_manifest.py]"]
  node_models["Port models<br/>[models.py]"]
  node_commands["Command inventory<br/>[commands.py]"]
  node_tools["Tool inventory<br/>[tools.py]"]
  node_parity["Parity audit<br/>[parity_audit.py]"]
end

subgraph group_session["Session state"]
  node_sessionstore[("Session persistence<br/>[session_store.py]")]
  node_transcript["Transcript state<br/>[transcript.py]"]
end

subgraph group_runtime["Runtime views"]
  node_runtime["Prompt runtime<br/>[runtime.py]"]
  node_pool["Tool pool<br/>[tool_pool.py]"]
  node_bootstrap["Bootstrap graph<br/>[bootstrap_graph.py]"]
end

node_user(("CLI user"))

node_user -->|"invokes"| node_main
node_main -->|"builds manifest"| node_manifest
node_main -->|"renders summary"| node_query
node_query -->|"reads workspace"| node_manifest
node_query -->|"builds backlog"| node_commands
node_query -->|"builds backlog"| node_tools
node_query -->|"loads and saves"| node_sessionstore
node_query -->|"updates transcript"| node_transcript
node_main -->|"runs audit"| node_parity
node_main -->|"lists or executes"| node_commands
node_main -->|"lists or executes"| node_tools
node_main -->|"runs turn loop"| node_runtime
node_main -->|"assembles pool"| node_pool
node_main -->|"builds graph"| node_bootstrap
node_query -->|"returns summary"| node_output
node_main -->|"prints result"| node_output

click node_main "https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/main.py"
click node_query "https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/query_engine.py"
click node_manifest "https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/port_manifest.py"
click node_models "https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/models.py"
click node_commands "https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/commands.py"
click node_tools "https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/tools.py"
click node_parity "https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/parity_audit.py"
click node_runtime "https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/runtime.py"
click node_pool "https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/tool_pool.py"
click node_bootstrap "https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/bootstrap_graph.py"
click node_sessionstore "https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/session_store.py"
click node_transcript "https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/transcript.py"

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_main,node_query,node_output,node_user toneBlue
class node_manifest,node_models,node_commands,node_tools,node_parity toneAmber
class node_sessionstore,node_transcript toneMint
class node_runtime,node_pool,node_bootstrap toneRose
```

## Components

### CLI workflow

- [CLI dispatcher](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/main.py): `src/main.py`
- [Summary engine](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/query_engine.py): `src/query_engine.py`
- **CLI output**

### Port inventory

- [Workspace manifest](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/port_manifest.py): `src/port_manifest.py`
- [Port models](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/models.py): `src/models.py`
- [Command inventory](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/commands.py): `src/commands.py`
- [Tool inventory](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/tools.py): `src/tools.py`
- [Parity audit](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/parity_audit.py): `src/parity_audit.py`

### Session state

- [Session persistence](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/session_store.py): `src/session_store.py`
- [Transcript state](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/transcript.py): `src/transcript.py`

### Runtime views

- [Prompt runtime](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/runtime.py): `src/runtime.py`
- [Tool pool](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/tool_pool.py): `src/tool_pool.py`
- [Bootstrap graph](https://github.com/mzpatrick0529-mzyh/claw-code/blob/main/src/bootstrap_graph.py): `src/bootstrap_graph.py`

### Other components

- **CLI user**

## Connections

- CLI user → CLI dispatcher: invokes
- CLI dispatcher → Workspace manifest: builds manifest
- CLI dispatcher → Summary engine: renders summary
- Summary engine → Workspace manifest: reads workspace
- Summary engine → Command inventory: builds backlog
- Summary engine → Tool inventory: builds backlog
- Summary engine → Session persistence: loads and saves
- Summary engine → Transcript state: updates transcript
- CLI dispatcher → Parity audit: runs audit
- CLI dispatcher → Command inventory: lists or executes
- CLI dispatcher → Tool inventory: lists or executes
- CLI dispatcher → Prompt runtime: runs turn loop
- CLI dispatcher → Tool pool: assembles pool
- CLI dispatcher → Bootstrap graph: builds graph
- Summary engine → CLI output: returns summary
- CLI dispatcher → CLI output: prints result
