# jackliu1376/ai-agent-plan architecture

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

- Interactive diagram: https://gitdiagram.com/jackliu1376/ai-agent-plan
- Repository: https://github.com/jackliu1376/ai-agent-plan

## Overview

Cairn turns a natural-language task into an evidence-backed, dependency-validated plan; it plans but does not execute the actions. The main workflow is task submission, model-led tool research, optional clarification, plan validation, and Markdown/JSON presentation. The web product adds streamed progress, resumable sessions, and plan revisions. Tool-specific capabilities are represented as distinct branches because the README documents them, but their internal implementations were not sampled. Relationships are limited to source-index references, shown calls, or README documentation.

Main entry points: [`task-planner/mcp_server/tools/base.py`](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/base.py) (Tool registry), [`task-planner/agent/loop.py`](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/loop.py) (Planning loop), [`task-planner/web/app.py`](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/web/app.py) (HTTP and SSE API), [`task-planner/frontend/src/App.tsx`](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/frontend/src/App.tsx) (Planning interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["Planning agent"]
  node_cli["CLI entry<br/>[cli.py]"]
  node_orchestrator["Planning loop<br/>[loop.py]"]
  node_llm["LLM client<br/>[llm_client.py]"]
  node_config["Runtime settings<br/>[config.py]"]
  node_events["Run events<br/>[events.py]"]
  node_toolrunner["Tool runner<br/>[tool_runner.py]"]
  node_plan_schema["Plan schema<br/>[schema.py]"]
  node_runlog["Run trace<br/>[run_log.py]"]
end

subgraph group_tools["Research tools"]
  node_tool_registry["Tool registry<br/>[base.py]"]
  node_attractions["Attraction lookup<br/>[attractions.py]"]
  node_live_attractions["Live attraction checks<br/>[attraction_live.py]"]
  node_weather["Weather lookup<br/>[weather.py]"]
  node_route["Route estimates<br/>[route.py]"]
  node_transit["Transit lookup<br/>[transit.py]"]
  node_budget["Budget parsing<br/>[budget.py]"]
  node_currency["Currency conversion<br/>[currency.py]"]
  node_web_search["Web retrieval<br/>[web.py]"]
  node_clarify_tool["Clarification tool<br/>[clarify.py]"]
  node_save_tool["Save plan<br/>[storage.py]"]
  node_mcp_server["MCP interface<br/>[server.py]"]
end

subgraph group_web["Web service"]
  node_web_app["HTTP and SSE API<br/>[app.py]"]
end

subgraph group_frontend["Web interface"]
  node_frontend_app["Planning interface<br/>[App.tsx]"]
  node_session_hook["Session state hook"]
  node_api_client["HTTP client<br/>[client.ts]"]
  node_plan_view["Plan and evidence views<br/>[PlanView.tsx]"]
end

subgraph group_state["Session state"]
  node_sessions["Session manager<br/>[session.py]"]
  node_session_db[("Session database<br/>[session_db.py]")]
end

node_user(("Task author"))

node_user -->|"submits task"| node_cli
node_cli -.->|"starts planning"| node_orchestrator
node_user -->|"enters task"| node_frontend_app
node_frontend_app -->|"uses session state"| node_session_hook
node_session_hook -->|"requests sessions"| node_api_client
node_api_client -.->|"calls HTTP API"| node_web_app
node_web_app -->|"runs planning"| node_orchestrator
node_web_app -->|"manages sessions"| node_sessions
node_sessions -->|"loads and saves"| node_session_db
node_sessions -->|"hosts clarification"| node_orchestrator
node_orchestrator -->|"requests decisions"| node_llm
node_orchestrator -->|"executes calls"| node_toolrunner
node_orchestrator -->|"emits progress"| node_events
node_orchestrator -->|"validates plan"| node_plan_schema
node_orchestrator -.->|"records trace"| node_runlog
node_llm -->|"loads settings"| node_config
node_toolrunner -->|"dispatches tools"| node_tool_registry
node_mcp_server -->|"serves tool schemas"| node_tool_registry
node_tool_registry -->|"registers"| node_attractions
node_tool_registry -->|"registers"| node_live_attractions
node_tool_registry -->|"registers"| node_weather
node_tool_registry -->|"registers"| node_route
node_tool_registry -->|"registers"| node_transit
node_tool_registry -->|"registers"| node_budget
node_tool_registry -->|"registers"| node_currency
node_tool_registry -->|"registers"| node_web_search
node_tool_registry -->|"registers"| node_clarify_tool
node_tool_registry -->|"registers"| node_save_tool
node_frontend_app -->|"renders plan"| node_plan_view

click node_cli "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/cli.py"
click node_orchestrator "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/loop.py"
click node_llm "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/llm_client.py"
click node_config "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/config.py"
click node_events "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/events.py"
click node_toolrunner "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/tool_runner.py"
click node_plan_schema "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/schema.py"
click node_runlog "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/run_log.py"
click node_tool_registry "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/base.py"
click node_attractions "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/attractions.py"
click node_live_attractions "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/attraction_live.py"
click node_weather "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/weather.py"
click node_route "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/route.py"
click node_transit "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/transit.py"
click node_budget "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/budget.py"
click node_currency "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/currency.py"
click node_web_search "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/web.py"
click node_clarify_tool "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/clarify.py"
click node_save_tool "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/storage.py"
click node_mcp_server "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/server.py"
click node_web_app "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/web/app.py"
click node_sessions "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/web/session.py"
click node_session_db "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/web/session_db.py"
click node_frontend_app "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/frontend/src/App.tsx"
click node_session_hook "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/frontend/src/hooks/usePlanningSession.ts"
click node_api_client "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/frontend/src/api/client.ts"
click node_plan_view "https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/frontend/src/components/PlanView.tsx"

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_orchestrator,node_llm,node_config,node_events,node_toolrunner,node_plan_schema,node_runlog toneBlue
class node_tool_registry,node_attractions,node_live_attractions,node_weather,node_route,node_transit,node_budget,node_currency,node_web_search,node_clarify_tool,node_save_tool,node_mcp_server toneAmber
class node_web_app toneMint
class node_frontend_app,node_session_hook,node_api_client,node_plan_view,node_user toneRose
class node_sessions,node_session_db toneIndigo
```

## Components

### Planning agent

- [CLI entry](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/cli.py): `task-planner/agent/cli.py`
- [Planning loop](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/loop.py): `task-planner/agent/loop.py`
- [LLM client](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/llm_client.py): `task-planner/agent/llm_client.py`
- [Runtime settings](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/config.py): `task-planner/agent/config.py`
- [Run events](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/events.py): `task-planner/agent/events.py`
- [Tool runner](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/tool_runner.py): `task-planner/agent/tool_runner.py`
- [Plan schema](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/schema.py): `task-planner/agent/schema.py`
- [Run trace](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/agent/run_log.py): `task-planner/agent/run_log.py`

### Research tools

- [Tool registry](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/base.py): `task-planner/mcp_server/tools/base.py`
- [Attraction lookup](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/attractions.py): `task-planner/mcp_server/tools/attractions.py`
- [Live attraction checks](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/attraction_live.py): `task-planner/mcp_server/tools/attraction_live.py`
- [Weather lookup](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/weather.py): `task-planner/mcp_server/tools/weather.py`
- [Route estimates](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/route.py): `task-planner/mcp_server/tools/route.py`
- [Transit lookup](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/transit.py): `task-planner/mcp_server/tools/transit.py`
- [Budget parsing](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/budget.py): `task-planner/mcp_server/tools/budget.py`
- [Currency conversion](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/currency.py): `task-planner/mcp_server/tools/currency.py`
- [Web retrieval](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/web.py): `task-planner/mcp_server/tools/web.py`
- [Clarification tool](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/clarify.py): `task-planner/mcp_server/tools/clarify.py`
- [Save plan](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/tools/storage.py): `task-planner/mcp_server/tools/storage.py`
- [MCP interface](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/mcp_server/server.py): `task-planner/mcp_server/server.py`

### Web service

- [HTTP and SSE API](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/web/app.py): `task-planner/web/app.py`

### Web interface

- [Planning interface](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/frontend/src/App.tsx): `task-planner/frontend/src/App.tsx`
- [Session state hook](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/frontend/src/hooks/usePlanningSession.ts): `task-planner/frontend/src/hooks/usePlanningSession.ts`
- [HTTP client](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/frontend/src/api/client.ts): `task-planner/frontend/src/api/client.ts`
- [Plan and evidence views](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/frontend/src/components/PlanView.tsx): `task-planner/frontend/src/components/PlanView.tsx`

### Session state

- [Session manager](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/web/session.py): `task-planner/web/session.py`
- [Session database](https://github.com/jackliu1376/ai-agent-plan/blob/main/task-planner/web/session_db.py): `task-planner/web/session_db.py`

### Other components

- **Task author**

## Connections

- Task author → CLI entry: submits task (evidence: `README.md`)
- CLI entry → Planning loop: starts planning
- Task author → Planning interface: enters task (evidence: `README.md`)
- Planning interface → Session state hook: uses session state (evidence: `task-planner/frontend/src/App.tsx`)
- Session state hook → HTTP client: requests sessions (evidence: `task-planner/frontend/src/hooks/usePlanningSession.ts`)
- HTTP client → HTTP and SSE API: calls HTTP API
- HTTP and SSE API → Planning loop: runs planning (evidence: `task-planner/web/app.py`)
- HTTP and SSE API → Session manager: manages sessions (evidence: `task-planner/web/app.py`)
- Session manager → Session database: loads and saves (evidence: `task-planner/web/session.py`)
- Session manager → Planning loop: hosts clarification (evidence: `task-planner/web/session.py`)
- Planning loop → LLM client: requests decisions (evidence: `task-planner/agent/loop.py`)
- Planning loop → Tool runner: executes calls (evidence: `task-planner/agent/loop.py`)
- Planning loop → Run events: emits progress (evidence: `task-planner/agent/loop.py`)
- Planning loop → Plan schema: validates plan (evidence: `task-planner/agent/loop.py`)
- Planning loop → Run trace: records trace (evidence: `task-planner/agent/run_log.py`)
- LLM client → Runtime settings: loads settings (evidence: `task-planner/agent/llm_client.py`)
- Tool runner → Tool registry: dispatches tools (evidence: `task-planner/agent/tool_runner.py`)
- MCP interface → Tool registry: serves tool schemas (evidence: `task-planner/mcp_server/server.py`)
- Tool registry → Attraction lookup: registers (evidence: `task-planner/mcp_server/tools/base.py`)
- Tool registry → Live attraction checks: registers (evidence: `task-planner/mcp_server/tools/base.py`)
- Tool registry → Weather lookup: registers (evidence: `task-planner/mcp_server/tools/base.py`)
- Tool registry → Route estimates: registers (evidence: `task-planner/mcp_server/tools/base.py`)
- Tool registry → Transit lookup: registers (evidence: `task-planner/mcp_server/tools/base.py`)
- Tool registry → Budget parsing: registers (evidence: `task-planner/mcp_server/tools/base.py`)
- Tool registry → Currency conversion: registers (evidence: `task-planner/mcp_server/tools/base.py`)
- Tool registry → Web retrieval: registers (evidence: `task-planner/mcp_server/tools/base.py`)
- Tool registry → Clarification tool: registers (evidence: `task-planner/mcp_server/tools/base.py`)
- Tool registry → Save plan: registers (evidence: `task-planner/mcp_server/tools/base.py`)
- Planning interface → Plan and evidence views: renders plan (evidence: `task-planner/frontend/src/App.tsx`)
