Architecture

System Design & Core Internals

4-Layer Architecture

Entry Layer

CLI parsing, bootstrap, env initialization

Query Engine

LLM orchestration, streaming, tool loop

Tool & Service Layer

39 tools + 36 service modules

UI Layer

React/Ink terminal UI, 111 components

Bootstrap Flow

1

main.tsx entry

2

Parallel: MDM prefetch + Keychain prefetch

3

Parse CLI args (Commander.js)

4

Load config, OAuth, policy limits

5

Initialize MCP connections

6

Launch React/Ink UI + QueryEngine

Key Files by Size

FileSizePurpose
main.tsx4,683 linesCLI entry + React bootstrap
query.ts1,729 linesQuery pipeline
QueryEngine.ts1,295 linesLLM orchestration
Tool.ts792 linesTool framework base
commands.ts754 linesCommand registry