@@ -58,6 +58,139 @@ please contact the repository owner for immediate removal.
5858
5959---
6060
61+ ## Directory Reference
62+
63+ ```
64+ src/
65+ ├── main.tsx # REPL bootstrap, 4,683 lines
66+ ├── QueryEngine.ts # SDK/headless query lifecycle engine
67+ ├── query.ts # Main agent loop (785KB, largest file)
68+ ├── Tool.ts # Tool interface + buildTool factory
69+ ├── Task.ts # Task types, IDs, state base
70+ ├── tools.ts # Tool registry, presets, filtering
71+ ├── commands.ts # Slash command definitions
72+ ├── context.ts # User input context
73+ ├── cost-tracker.ts # API cost accumulation
74+ ├── setup.ts # First-run setup flow
75+ │
76+ ├── bridge/ # Claude Desktop / remote bridge
77+ │ ├── bridgeMain.ts # Session lifecycle manager
78+ │ ├── bridgeApi.ts # HTTP client
79+ │ ├── bridgeConfig.ts # Connection config
80+ │ ├── bridgeMessaging.ts # Message relay
81+ │ ├── sessionRunner.ts # Process spawning
82+ │ ├── jwtUtils.ts # JWT refresh
83+ │ ├── workSecret.ts # Auth tokens
84+ │ └── capacityWake.ts # Capacity-based wakeup
85+ │
86+ ├── cli/ # CLI infrastructure
87+ │ ├── handlers/ # Command handlers
88+ │ └── transports/ # I/O transports (stdio, structured)
89+ │
90+ ├── commands/ # ~80 slash commands
91+ │ ├── agents/ # Agent management
92+ │ ├── compact/ # Context compaction
93+ │ ├── config/ # Settings management
94+ │ ├── help/ # Help display
95+ │ ├── login/ # Authentication
96+ │ ├── mcp/ # MCP server management
97+ │ ├── memory/ # Memory system
98+ │ ├── plan/ # Plan mode
99+ │ ├── resume/ # Session resume
100+ │ ├── review/ # Code review
101+ │ └── ... # 70+ more commands
102+ │
103+ ├── components/ # React/Ink terminal UI
104+ │ ├── design-system/ # Reusable UI primitives
105+ │ ├── messages/ # Message rendering
106+ │ ├── permissions/ # Permission dialogs
107+ │ ├── PromptInput/ # Input field + suggestions
108+ │ ├── LogoV2/ # Branding + welcome screen
109+ │ ├── Settings/ # Settings panels
110+ │ ├── Spinner.tsx # Loading indicators
111+ │ └── ... # 40+ component groups
112+ │
113+ ├── entrypoints/ # Application entry points
114+ │ ├── cli.tsx # CLI main (version, help, daemon)
115+ │ ├── sdk/ # Agent SDK (types, sessions)
116+ │ └── mcp.ts # MCP server entry
117+ │
118+ ├── hooks/ # React hooks
119+ │ ├── useCanUseTool.tsx # Permission checking
120+ │ ├── useReplBridge.tsx # Bridge connection
121+ │ ├── notifs/ # Notification hooks
122+ │ └── toolPermission/ # Tool permission handlers
123+ │
124+ ├── services/ # Business logic layer
125+ │ ├── api/ # Claude API client
126+ │ │ ├── claude.ts # Streaming API calls
127+ │ │ ├── errors.ts # Error categorization
128+ │ │ └── withRetry.ts # Retry logic
129+ │ ├── analytics/ # Telemetry + GrowthBook
130+ │ ├── compact/ # Context compression
131+ │ ├── mcp/ # MCP connection management
132+ │ ├── tools/ # Tool execution engine
133+ │ │ ├── StreamingToolExecutor.ts # Parallel tool runner
134+ │ │ └── toolOrchestration.ts # Batch orchestration
135+ │ ├── plugins/ # Plugin loader
136+ │ └── settingsSync/ # Cross-device settings
137+ │
138+ ├── state/ # Application state
139+ │ ├── AppStateStore.ts # Store definition
140+ │ └── AppState.tsx # React provider + hooks
141+ │
142+ ├── tasks/ # Task implementations
143+ │ ├── LocalShellTask/ # Bash command execution
144+ │ ├── LocalAgentTask/ # Sub-agent execution
145+ │ ├── RemoteAgentTask/ # Remote agent via bridge
146+ │ ├── InProcessTeammateTask/ # In-process teammate
147+ │ └── DreamTask/ # Background thinking
148+ │
149+ ├── tools/ # 40+ tool implementations
150+ │ ├── AgentTool/ # Sub-agent spawning + fork
151+ │ ├── BashTool/ # Shell command execution
152+ │ ├── FileReadTool/ # File reading (PDF, image, etc)
153+ │ ├── FileEditTool/ # String-replace editing
154+ │ ├── FileWriteTool/ # Full file creation
155+ │ ├── GlobTool/ # File pattern search
156+ │ ├── GrepTool/ # Content search (ripgrep)
157+ │ ├── WebFetchTool/ # HTTP fetching
158+ │ ├── WebSearchTool/ # Web search
159+ │ ├── MCPTool/ # MCP tool wrapper
160+ │ ├── SkillTool/ # Skill invocation
161+ │ ├── AskUserQuestionTool/ # User interaction
162+ │ └── ... # 30+ more tools
163+ │
164+ ├── types/ # Type definitions
165+ │ ├── message.ts # Message discriminated unions
166+ │ ├── permissions.ts # Permission types
167+ │ ├── tools.ts # Tool progress types
168+ │ └── ids.ts # Branded ID types
169+ │
170+ ├── utils/ # Utilities (largest directory)
171+ │ ├── permissions/ # Permission rule engine
172+ │ ├── messages/ # Message formatting
173+ │ ├── model/ # Model selection logic
174+ │ ├── settings/ # Settings management
175+ │ ├── sandbox/ # Sandbox runtime adapter
176+ │ ├── hooks/ # Hook execution
177+ │ ├── memory/ # Memory system utils
178+ │ ├── git/ # Git operations
179+ │ ├── github/ # GitHub API
180+ │ ├── bash/ # Bash execution helpers
181+ │ ├── swarm/ # Multi-agent swarm
182+ │ ├── telemetry/ # Telemetry reporting
183+ │ └── ... # 30+ more util groups
184+ │
185+ └── vendor/ # Native module source stubs
186+ ├── audio-capture-src/ # Audio input
187+ ├── image-processor-src/ # Image processing
188+ ├── modifiers-napi-src/ # Native modifiers
189+ └── url-handler-src/ # URL handling
190+ ```
191+
192+ ---
193+
61194## Architecture Overview
62195
63196```
@@ -601,139 +734,6 @@ This source code demonstrates 12 layered mechanisms that a production AI agent h
601734
602735---
603736
604- ## Directory Reference
605-
606- ```
607- src/
608- ├── main.tsx # REPL bootstrap, 4,683 lines
609- ├── QueryEngine.ts # SDK/headless query lifecycle engine
610- ├── query.ts # Main agent loop (785KB, largest file)
611- ├── Tool.ts # Tool interface + buildTool factory
612- ├── Task.ts # Task types, IDs, state base
613- ├── tools.ts # Tool registry, presets, filtering
614- ├── commands.ts # Slash command definitions
615- ├── context.ts # User input context
616- ├── cost-tracker.ts # API cost accumulation
617- ├── setup.ts # First-run setup flow
618- │
619- ├── bridge/ # Claude Desktop / remote bridge
620- │ ├── bridgeMain.ts # Session lifecycle manager
621- │ ├── bridgeApi.ts # HTTP client
622- │ ├── bridgeConfig.ts # Connection config
623- │ ├── bridgeMessaging.ts # Message relay
624- │ ├── sessionRunner.ts # Process spawning
625- │ ├── jwtUtils.ts # JWT refresh
626- │ ├── workSecret.ts # Auth tokens
627- │ └── capacityWake.ts # Capacity-based wakeup
628- │
629- ├── cli/ # CLI infrastructure
630- │ ├── handlers/ # Command handlers
631- │ └── transports/ # I/O transports (stdio, structured)
632- │
633- ├── commands/ # ~80 slash commands
634- │ ├── agents/ # Agent management
635- │ ├── compact/ # Context compaction
636- │ ├── config/ # Settings management
637- │ ├── help/ # Help display
638- │ ├── login/ # Authentication
639- │ ├── mcp/ # MCP server management
640- │ ├── memory/ # Memory system
641- │ ├── plan/ # Plan mode
642- │ ├── resume/ # Session resume
643- │ ├── review/ # Code review
644- │ └── ... # 70+ more commands
645- │
646- ├── components/ # React/Ink terminal UI
647- │ ├── design-system/ # Reusable UI primitives
648- │ ├── messages/ # Message rendering
649- │ ├── permissions/ # Permission dialogs
650- │ ├── PromptInput/ # Input field + suggestions
651- │ ├── LogoV2/ # Branding + welcome screen
652- │ ├── Settings/ # Settings panels
653- │ ├── Spinner.tsx # Loading indicators
654- │ └── ... # 40+ component groups
655- │
656- ├── entrypoints/ # Application entry points
657- │ ├── cli.tsx # CLI main (version, help, daemon)
658- │ ├── sdk/ # Agent SDK (types, sessions)
659- │ └── mcp.ts # MCP server entry
660- │
661- ├── hooks/ # React hooks
662- │ ├── useCanUseTool.tsx # Permission checking
663- │ ├── useReplBridge.tsx # Bridge connection
664- │ ├── notifs/ # Notification hooks
665- │ └── toolPermission/ # Tool permission handlers
666- │
667- ├── services/ # Business logic layer
668- │ ├── api/ # Claude API client
669- │ │ ├── claude.ts # Streaming API calls
670- │ │ ├── errors.ts # Error categorization
671- │ │ └── withRetry.ts # Retry logic
672- │ ├── analytics/ # Telemetry + GrowthBook
673- │ ├── compact/ # Context compression
674- │ ├── mcp/ # MCP connection management
675- │ ├── tools/ # Tool execution engine
676- │ │ ├── StreamingToolExecutor.ts # Parallel tool runner
677- │ │ └── toolOrchestration.ts # Batch orchestration
678- │ ├── plugins/ # Plugin loader
679- │ └── settingsSync/ # Cross-device settings
680- │
681- ├── state/ # Application state
682- │ ├── AppStateStore.ts # Store definition
683- │ └── AppState.tsx # React provider + hooks
684- │
685- ├── tasks/ # Task implementations
686- │ ├── LocalShellTask/ # Bash command execution
687- │ ├── LocalAgentTask/ # Sub-agent execution
688- │ ├── RemoteAgentTask/ # Remote agent via bridge
689- │ ├── InProcessTeammateTask/ # In-process teammate
690- │ └── DreamTask/ # Background thinking
691- │
692- ├── tools/ # 40+ tool implementations
693- │ ├── AgentTool/ # Sub-agent spawning + fork
694- │ ├── BashTool/ # Shell command execution
695- │ ├── FileReadTool/ # File reading (PDF, image, etc)
696- │ ├── FileEditTool/ # String-replace editing
697- │ ├── FileWriteTool/ # Full file creation
698- │ ├── GlobTool/ # File pattern search
699- │ ├── GrepTool/ # Content search (ripgrep)
700- │ ├── WebFetchTool/ # HTTP fetching
701- │ ├── WebSearchTool/ # Web search
702- │ ├── MCPTool/ # MCP tool wrapper
703- │ ├── SkillTool/ # Skill invocation
704- │ ├── AskUserQuestionTool/ # User interaction
705- │ └── ... # 30+ more tools
706- │
707- ├── types/ # Type definitions
708- │ ├── message.ts # Message discriminated unions
709- │ ├── permissions.ts # Permission types
710- │ ├── tools.ts # Tool progress types
711- │ └── ids.ts # Branded ID types
712- │
713- ├── utils/ # Utilities (largest directory)
714- │ ├── permissions/ # Permission rule engine
715- │ ├── messages/ # Message formatting
716- │ ├── model/ # Model selection logic
717- │ ├── settings/ # Settings management
718- │ ├── sandbox/ # Sandbox runtime adapter
719- │ ├── hooks/ # Hook execution
720- │ ├── memory/ # Memory system utils
721- │ ├── git/ # Git operations
722- │ ├── github/ # GitHub API
723- │ ├── bash/ # Bash execution helpers
724- │ ├── swarm/ # Multi-agent swarm
725- │ ├── telemetry/ # Telemetry reporting
726- │ └── ... # 30+ more util groups
727- │
728- └── vendor/ # Native module source stubs
729- ├── audio-capture-src/ # Audio input
730- ├── image-processor-src/ # Image processing
731- ├── modifiers-napi-src/ # Native modifiers
732- └── url-handler-src/ # URL handling
733- ```
734-
735- ---
736-
737737## Build Notes
738738
739739This source is ** not directly compilable** from this repo alone:
0 commit comments