# paperwave/claude-code-cli-leaked architecture

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

- Interactive diagram: https://gitdiagram.com/paperwave/claude-code-cli-leaked
- Repository: https://github.com/paperwave/claude-code-cli-leaked

## Overview

Claude Code is a terminal-based AI software-engineering assistant. The main user workflow is to submit a prompt, process it into model requests and tool activity, then present responses in the terminal; session data is also persisted. The tree also identifies command-driven configuration and MCP, remote bridge, agent, and task features. The README documents editing, shell, search, and git workflows, but their implementation files are absent from this tree. Source excerpts are partial, so uncertain internal wiring is omitted.

Main entry points: [`src/QueryEngine.ts`](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/QueryEngine.ts) (Query engine), [`src/utils/sessionStorage.ts`](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/utils/sessionStorage.ts) (Session storage), [`src/commands.ts`](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/commands.ts) (Commands), [`cli.js`](https://github.com/paperwave/claude-code-cli-leaked/blob/main/cli.js) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["CLI interaction"]
  node_cli["CLI entry<br/>[cli.js]"]
  node_app["Terminal interface<br/>[App.tsx]"]
  node_commands["Commands<br/>[commands.ts]"]
  node_input["Prompt input<br/>[PromptInput.tsx]"]
  node_messages["Message rendering<br/>[Messages.tsx]"]
end

subgraph group_runtime["Assistant runtime"]
  node_engine["Query engine<br/>[QueryEngine.ts]"]
  node_input_processing["Input processing"]
  node_query["Model query loop"]
  node_tool_contract["Tool contract<br/>[Tool.ts]"]
  node_permissions["Tool permissions"]
  node_tasks["Task tracking<br/>[useTasksV2.ts]"]
end

subgraph group_state["Session and state"]
  node_session_storage[("Session storage<br/>[sessionStorage.ts]")]
  node_portable_storage["Portable transcript access"]
  node_session_history["Session history<br/>[sessionHistory.ts]"]
end

subgraph group_extensions["Extensions and remote"]
  node_agents["Agent commands<br/>[agents.tsx]"]
  node_mcp["MCP management<br/>[mcp.tsx]"]
  node_mcp_ui["MCP interface<br/>[index.ts]"]
  node_bridge["Remote bridge<br/>[bridgeMain.ts]"]
end

node_user(("Terminal user"))
node_filesystem[("Local filesystem")]
node_model_service(("Model service"))

node_user -->|"invokes"| node_cli
node_cli -->|"starts interface"| node_app
node_user -->|"enters prompt"| node_input
node_input -->|"submits input"| node_engine
node_app -->|"dispatches commands"| node_commands
node_engine -->|"processes input"| node_input_processing
node_engine -->|"runs query"| node_query
node_engine -->|"flushes session"| node_session_storage
node_query -->|"requests completion"| node_model_service
node_query -->|"uses tool definitions"| node_tool_contract
node_engine -->|"yields results"| node_messages
node_permissions -->|"authorizes use"| node_tool_contract
node_session_storage -->|"reads transcripts"| node_portable_storage
node_session_history -->|"loads sessions"| node_session_storage
node_session_storage -->|"reads and writes"| node_filesystem
node_tasks -->|"watches task files"| node_filesystem
node_commands -->|"routes agent commands"| node_agents
node_commands -->|"routes MCP commands"| node_mcp
node_mcp -->|"renders management UI"| node_mcp_ui
node_bridge -.->|"accesses local state"| node_filesystem

click node_cli "https://github.com/paperwave/claude-code-cli-leaked/blob/main/cli.js"
click node_app "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/components/App.tsx"
click node_commands "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/commands.ts"
click node_input "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/components/PromptInput/PromptInput.tsx"
click node_engine "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/QueryEngine.ts"
click node_tool_contract "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/Tool.ts"
click node_messages "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/components/Messages.tsx"
click node_permissions "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/components/permissions/FilePermissionDialog/usePermissionHandler.ts"
click node_session_storage "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/utils/sessionStorage.ts"
click node_portable_storage "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/utils/sessionStoragePortable.ts"
click node_session_history "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/assistant/sessionHistory.ts"
click node_tasks "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/hooks/useTasksV2.ts"
click node_agents "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/commands/agents/agents.tsx"
click node_mcp "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/commands/mcp/mcp.tsx"
click node_mcp_ui "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/components/mcp/index.ts"
click node_bridge "https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/bridge/bridgeMain.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_app,node_commands,node_input,node_messages,node_user toneBlue
class node_engine,node_input_processing,node_query,node_tool_contract,node_permissions,node_tasks,node_filesystem toneAmber
class node_session_storage,node_portable_storage,node_session_history toneMint
class node_agents,node_mcp,node_mcp_ui,node_bridge toneRose
class node_model_service toneIndigo
```

## Components

### CLI interaction

- [CLI entry](https://github.com/paperwave/claude-code-cli-leaked/blob/main/cli.js): `cli.js`
- [Terminal interface](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/components/App.tsx): `src/components/App.tsx`
- [Commands](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/commands.ts): `src/commands.ts`
- [Prompt input](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/components/PromptInput/PromptInput.tsx): `src/components/PromptInput/PromptInput.tsx`
- [Message rendering](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/components/Messages.tsx): `src/components/Messages.tsx`

### Assistant runtime

- [Query engine](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/QueryEngine.ts): `src/QueryEngine.ts`
- **Input processing**
- **Model query loop**
- [Tool contract](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/Tool.ts): `src/Tool.ts`
- [Tool permissions](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/components/permissions/FilePermissionDialog/usePermissionHandler.ts): `src/components/permissions/FilePermissionDialog/usePermissionHandler.ts`
- [Task tracking](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/hooks/useTasksV2.ts): `src/hooks/useTasksV2.ts`

### Session and state

- [Session storage](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/utils/sessionStorage.ts): `src/utils/sessionStorage.ts`
- [Portable transcript access](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/utils/sessionStoragePortable.ts): `src/utils/sessionStoragePortable.ts`
- [Session history](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/assistant/sessionHistory.ts): `src/assistant/sessionHistory.ts`

### Extensions and remote

- [Agent commands](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/commands/agents/agents.tsx): `src/commands/agents/agents.tsx`
- [MCP management](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/commands/mcp/mcp.tsx): `src/commands/mcp/mcp.tsx`
- [MCP interface](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/components/mcp/index.ts): `src/components/mcp/index.ts`
- [Remote bridge](https://github.com/paperwave/claude-code-cli-leaked/blob/main/src/bridge/bridgeMain.ts): `src/bridge/bridgeMain.ts`

### Other components

- **Terminal user**
- **Local filesystem**
- **Model service**

## Connections

- Terminal user → CLI entry: invokes
- CLI entry → Terminal interface: starts interface
- Terminal user → Prompt input: enters prompt
- Prompt input → Query engine: submits input
- Terminal interface → Commands: dispatches commands
- Query engine → Input processing: processes input
- Query engine → Model query loop: runs query
- Query engine → Session storage: flushes session
- Model query loop → Model service: requests completion
- Model query loop → Tool contract: uses tool definitions
- Query engine → Message rendering: yields results
- Tool permissions → Tool contract: authorizes use
- Session storage → Portable transcript access: reads transcripts
- Session history → Session storage: loads sessions
- Session storage → Local filesystem: reads and writes
- Task tracking → Local filesystem: watches task files
- Commands → Agent commands: routes agent commands
- Commands → MCP management: routes MCP commands
- MCP management → MCP interface: renders management UI
- Remote bridge → Local filesystem: accesses local state
