Architecture Overview
How Cdoing Agent is structured as a modular monorepo and how all the pieces connect.
Project Structure
Package Dependency Graph
The dependency graph is strictly layered. Core has no internal dependencies. AI depends only on core. Both CLI and VS Code extension depend on AI and core. Dashed lines show direct core imports (for OAuth, tools, etc.).
Full System Map
Every module, tool, and external dependency — and how they connect. Solid lines are runtime calls, dashed lines are shared imports.
Build System
The project uses Turbo for build orchestration across the Yarn workspace monorepo. Key build commands:
| Command | Description |
|---|---|
| yarn build | Build all packages via Turbo (respects dependency order) |
| yarn dev | Watch mode for all packages (persistent, no cache) |
| yarn start | Build core + ai, then run CLI |
| yarn clean | Remove all dist/ directories |
Each package compiles TypeScript to CommonJS (ES2022 target) with declaration files. Build outputs go to dist/ in each package. The VS Code extension uses esbuild to bundle everything (including core) into a single dist/extension.js.
Data Flow: The Agentic Loop
The core runtime is an agentic loop that continuously cycles between the LLM and tool execution until the task is complete:
Key Architectural Decisions
1. Shared OAuth in Core
All OAuth logic (PKCE, credential storage, token refresh) lives in @cdoing/core. Both CLI and VS Code extension import from core — zero duplication. Tokens are stored in the OS credential manager and shared between all consumers.
2. Raw JSON Schema for Tool Binding
Tools are bound to the LLM using raw JSON Schema definitions rather than Zod or other schema libraries. This keeps the core package dependency-free from validation libraries and ensures maximum compatibility across providers.
3. SQLite for Indexing (No External DB)
The codebase indexer uses SQLite with FTS5 for full-text search and stores vector embeddings as JSON. No external vector database needed.
4. LangChain for Provider Abstraction
The AI package uses @langchain/core as a thin abstraction layer over multiple LLM providers.
5. Permissions as a First-Class Concern
Every tool execution passes through the permission engine before running. The 3-tier deny/ask/allow rule system ensures security without sacrificing usability.
Technology Stack
| Layer | Technology |
|---|---|
| Language | TypeScript (ES2022, CommonJS output) |
| Monorepo | Yarn Workspaces + Turbo |
| LLM Abstraction | LangChain (@langchain/core, @langchain/anthropic, etc.) |
| Database | SQLite (better-sqlite3) with FTS5 |
| CLI Framework | Commander + Ink (React for terminals) |
| VS Code UI | React + esbuild (webview) |
| Auth | OAuth 2.0 PKCE (shared via @cdoing/core) |
| Diagrams | React Flow + avoid-nodes-edge |