# aestheticsuraj234/chaicodeclaw-build architecture

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

- Interactive diagram: https://gitdiagram.com/aestheticsuraj234/chaicodeclaw-build
- Repository: https://github.com/aestheticsuraj234/chaicodeclaw-build

## Overview

This is a Telegram-oriented coding assistant with CLI modes for asking questions, carrying out agent tasks, and planning multi-step work. Users submit a prompt, the selected workflow uses an AI model and tools to inspect files or research the web, then stages proposed changes for review before applying them. Telegram adds chat commands, plan-step selection, and inline approval; the CLI provides interactive equivalents. The README only says “hello from telegram,” so the broader capabilities and several connections below are supported by sampled source and the SOURCE INDEX, not by product documentation.

Main entry points: [`modes/plan/orchestrator.ts`](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/plan/orchestrator.ts) (Plan workflow), [`modes/agent/tool-executor.ts`](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/tool-executor.ts) (Tool executor), [`modes/ask/orchestrator.ts`](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/ask/orchestrator.ts) (Ask workflow), [`modes/agent/orchestrator.ts`](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/orchestrator.ts) (Agent workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["CLI mode router<br/>[cli.ts]"]
  node_wake["Startup and wakeup<br/>[wakeup.ts]"]
  node_handlers["Telegram handlers<br/>[handlers.ts]"]
  node_agentrun["Telegram run coordinator<br/>[agent-run.ts]"]
end

subgraph group_workflows["Assistant workflows"]
  node_ask["Ask workflow<br/>[orchestrator.ts]"]
  node_agent["Agent workflow<br/>[orchestrator.ts]"]
  node_planflow["Plan workflow<br/>[orchestrator.ts]"]
  node_planner["Plan generation<br/>[planner.ts]"]
  node_selection["Plan selection<br/>[selection.ts]"]
  node_plansession["Telegram plan session<br/>[plan-session.ts]"]
end

subgraph group_runtime["Agent runtime"]
  node_toolrunner["Tool executor<br/>[tool-executor.ts]"]
  node_agenttools["Agent tools<br/>[agent-tools.ts]"]
  node_tracker["Action tracker<br/>[action-tracker.ts]"]
  node_approval["CLI approval flow<br/>[approval.ts]"]
  node_diff["Change diff view<br/>[diff-view.ts]"]
  node_tgapproval["Telegram approval session"]
end

subgraph group_integrations["Models and research"]
  node_webtools["Web research tools<br/>[web-tools.ts]"]
  node_modelconfig["Model configuration<br/>[ai.config.ts]"]
  node_terminalmd["Terminal Markdown<br/>[terminal-md.ts]"]
end

node_user(("User"))
node_telegram(("Telegram bot"))
node_modelservice["OpenRouter model"]
node_firecrawl["Firecrawl service"]

node_user -->|"chooses mode"| node_cli
node_user -->|"sends commands"| node_telegram
node_wake -->|"starts"| node_cli
node_wake -->|"starts"| node_telegram
node_telegram -->|"dispatches updates"| node_handlers
node_cli -->|"routes ask"| node_ask
node_cli -->|"routes agent"| node_agent
node_cli -->|"routes plan"| node_planflow
node_handlers -->|"starts runs"| node_agentrun
node_handlers -->|"generates plan"| node_planner
node_handlers -->|"updates selection"| node_plansession
node_handlers -->|"handles approval"| node_tgapproval
node_agentrun -->|"executes tools"| node_toolrunner
node_agentrun -->|"uses research"| node_webtools
node_agentrun -->|"requests review"| node_tgapproval
node_ask -->|"runs file tools"| node_toolrunner
node_ask -->|"adds research tools"| node_webtools
node_ask -->|"gets model"| node_modelconfig
node_ask -->|"renders answer"| node_terminalmd
node_ask -->|"requests review"| node_approval
node_agent -->|"creates tools"| node_agenttools
node_agent -->|"executes tools"| node_toolrunner
node_agent -->|"gets model"| node_modelconfig
node_agent -->|"requests review"| node_approval
node_agent -->|"renders answer"| node_terminalmd
node_planflow -->|"generates plan"| node_planner
node_planflow -->|"selects steps"| node_selection
node_planflow -->|"creates tools"| node_agenttools
node_planflow -->|"executes tools"| node_toolrunner
node_planflow -->|"adds research tools"| node_webtools
node_planflow -->|"gets model"| node_modelconfig
node_planflow -->|"requests review"| node_approval
node_planflow -->|"renders output"| node_terminalmd
node_toolrunner -->|"logs actions"| node_tracker
node_agenttools -->|"delegates tools"| node_toolrunner
node_approval -->|"reads pending changes"| node_tracker
node_approval -->|"applies approved changes"| node_toolrunner
node_approval -->|"formats changes"| node_diff
node_tgapproval -->|"reads and updates"| node_tracker
node_tgapproval -->|"formats changes"| node_diff
node_modelconfig -->|"configures model"| node_modelservice
node_webtools -->|"searches and scrapes"| node_firecrawl

click node_cli "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/cli.ts"
click node_wake "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/tui/wakeup.ts"
click node_handlers "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/telegram/handlers.ts"
click node_agentrun "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/telegram/agent-run.ts"
click node_ask "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/ask/orchestrator.ts"
click node_agent "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/orchestrator.ts"
click node_planflow "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/plan/orchestrator.ts"
click node_planner "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/plan/planner.ts"
click node_selection "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/plan/selection.ts"
click node_plansession "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/telegram/plan-session.ts"
click node_toolrunner "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/tool-executor.ts"
click node_agenttools "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/agent-tools.ts"
click node_tracker "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/action-tracker.ts"
click node_approval "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/approval.ts"
click node_diff "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/diff-view.ts"
click node_tgapproval "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/telegram/approval-session.ts"
click node_webtools "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/plan/web-tools.ts"
click node_modelconfig "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/ai/ai.config.ts"
click node_terminalmd "https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/tui/terminal-md.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_wake,node_handlers,node_agentrun,node_user toneBlue
class node_ask,node_agent,node_planflow,node_planner,node_selection,node_plansession toneAmber
class node_toolrunner,node_agenttools,node_tracker,node_approval,node_diff,node_tgapproval,node_modelservice toneMint
class node_webtools,node_modelconfig,node_terminalmd toneRose
class node_telegram,node_firecrawl toneIndigo
```

## Components

### Entry points

- [CLI mode router](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/cli.ts): `modes/cli.ts`
- [Startup and wakeup](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/tui/wakeup.ts): `tui/wakeup.ts`
- [Telegram handlers](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/telegram/handlers.ts): `modes/telegram/handlers.ts`
- [Telegram run coordinator](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/telegram/agent-run.ts): `modes/telegram/agent-run.ts`

### Assistant workflows

- [Ask workflow](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/ask/orchestrator.ts): `modes/ask/orchestrator.ts`
- [Agent workflow](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/orchestrator.ts): `modes/agent/orchestrator.ts`
- [Plan workflow](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/plan/orchestrator.ts): `modes/plan/orchestrator.ts`
- [Plan generation](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/plan/planner.ts): `modes/plan/planner.ts`
- [Plan selection](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/plan/selection.ts): `modes/plan/selection.ts`
- [Telegram plan session](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/telegram/plan-session.ts): `modes/telegram/plan-session.ts`

### Agent runtime

- [Tool executor](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/tool-executor.ts): `modes/agent/tool-executor.ts`
- [Agent tools](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/agent-tools.ts): `modes/agent/agent-tools.ts`
- [Action tracker](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/action-tracker.ts): `modes/agent/action-tracker.ts`
- [CLI approval flow](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/approval.ts): `modes/agent/approval.ts`
- [Change diff view](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/agent/diff-view.ts): `modes/agent/diff-view.ts`
- [Telegram approval session](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/telegram/approval-session.ts): `modes/telegram/approval-session.ts`

### Models and research

- [Web research tools](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/modes/plan/web-tools.ts): `modes/plan/web-tools.ts`
- [Model configuration](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/ai/ai.config.ts): `ai/ai.config.ts`
- [Terminal Markdown](https://github.com/aestheticsuraj234/chaicodeclaw-build/blob/main/tui/terminal-md.ts): `tui/terminal-md.ts`

### Other components

- **User**
- **Telegram bot**
- **OpenRouter model**
- **Firecrawl service**

## Connections

- User → CLI mode router: chooses mode (evidence: `modes/cli.ts`)
- User → Telegram bot: sends commands (evidence: `README.md`)
- Startup and wakeup → CLI mode router: starts (evidence: `tui/wakeup.ts`)
- Startup and wakeup → Telegram bot: starts (evidence: `tui/wakeup.ts`)
- Telegram bot → Telegram handlers: dispatches updates
- CLI mode router → Ask workflow: routes ask (evidence: `modes/cli.ts`)
- CLI mode router → Agent workflow: routes agent (evidence: `modes/cli.ts`)
- CLI mode router → Plan workflow: routes plan (evidence: `modes/cli.ts`)
- Telegram handlers → Telegram run coordinator: starts runs (evidence: `modes/telegram/handlers.ts`)
- Telegram handlers → Plan generation: generates plan (evidence: `modes/telegram/handlers.ts`)
- Telegram handlers → Telegram plan session: updates selection (evidence: `modes/telegram/handlers.ts`)
- Telegram handlers → Telegram approval session: handles approval (evidence: `modes/telegram/handlers.ts`)
- Telegram run coordinator → Tool executor: executes tools (evidence: `modes/telegram/agent-run.ts`)
- Telegram run coordinator → Web research tools: uses research (evidence: `modes/telegram/agent-run.ts`)
- Telegram run coordinator → Telegram approval session: requests review (evidence: `modes/telegram/agent-run.ts`)
- Ask workflow → Tool executor: runs file tools (evidence: `modes/ask/orchestrator.ts`)
- Ask workflow → Web research tools: adds research tools (evidence: `modes/ask/orchestrator.ts`)
- Ask workflow → Model configuration: gets model (evidence: `modes/ask/orchestrator.ts`)
- Ask workflow → Terminal Markdown: renders answer (evidence: `modes/ask/orchestrator.ts`)
- Ask workflow → CLI approval flow: requests review (evidence: `modes/ask/orchestrator.ts`)
- Agent workflow → Agent tools: creates tools (evidence: `modes/agent/orchestrator.ts`)
- Agent workflow → Tool executor: executes tools (evidence: `modes/agent/orchestrator.ts`)
- Agent workflow → Model configuration: gets model (evidence: `modes/agent/orchestrator.ts`)
- Agent workflow → CLI approval flow: requests review (evidence: `modes/agent/orchestrator.ts`)
- Agent workflow → Terminal Markdown: renders answer (evidence: `modes/agent/orchestrator.ts`)
- Plan workflow → Plan generation: generates plan (evidence: `modes/plan/orchestrator.ts`)
- Plan workflow → Plan selection: selects steps (evidence: `modes/plan/orchestrator.ts`)
- Plan workflow → Agent tools: creates tools (evidence: `modes/plan/orchestrator.ts`)
- Plan workflow → Tool executor: executes tools (evidence: `modes/plan/orchestrator.ts`)
- Plan workflow → Web research tools: adds research tools (evidence: `modes/plan/orchestrator.ts`)
- Plan workflow → Model configuration: gets model (evidence: `modes/plan/orchestrator.ts`)
- Plan workflow → CLI approval flow: requests review (evidence: `modes/plan/orchestrator.ts`)
- Plan workflow → Terminal Markdown: renders output (evidence: `modes/plan/orchestrator.ts`)
- Tool executor → Action tracker: logs actions (evidence: `modes/agent/tool-executor.ts`)
- Agent tools → Tool executor: delegates tools (evidence: `modes/agent/agent-tools.ts`)
- CLI approval flow → Action tracker: reads pending changes (evidence: `modes/agent/approval.ts`)
- CLI approval flow → Tool executor: applies approved changes (evidence: `modes/agent/approval.ts`)
- CLI approval flow → Change diff view: formats changes (evidence: `modes/agent/approval.ts`)
- Telegram approval session → Action tracker: reads and updates (evidence: `modes/telegram/approval-session.ts`)
- Telegram approval session → Change diff view: formats changes (evidence: `modes/telegram/approval-session.ts`)
- Model configuration → OpenRouter model: configures model (evidence: `ai/ai.config.ts`)
- Web research tools → Firecrawl service: searches and scrapes (evidence: `modes/plan/web-tools.ts`)
