πŸ—ΊοΈ Architecture

graph TD
  A[πŸ’» CLI] -->|createSession| B[🧠 sdk.ts]
  B --> C[βš™οΈ agent-loop.ts]
  C -->|LLM Turns & Tool Calls| D[πŸ”Œ pi-ai]
  D --> E[πŸ“š pi-catalog]
  E -.->|sqlite/env| F[πŸ› οΈ pi-utils]
  C -.->|Background Jobs| G[AsyncJobManager]

πŸ“¦ Packages

  • pi-coding-agent (Legacy v13.x): App/CLI, UI, Tools
  • pi-agent-core (Legacy v13.x): Turn Engine, EventStream
  • pi-ai (Modern v16.x): Multi-Provider Gateway
  • pi-catalog (Modern v16.x): Model DB & Caching
  • pi-utils (Modern v16.x): Env & Stream Parsing
  • pi-natives (Modern v16.x): Rust N-API bindings

πŸš€ Commands

  • bun run check: Type validation, Biome check
  • bun run fix: Auto-fix (biome β€”unsafe)
  • bun test: Monorepo tests (β€”parallel)
  • bun run generate-models: Rebuild models.json (pi-catalog)

βœ… Constraints

  • Runtime: Bun only (no Node.js)
  • Tooling: Biome strict (no ESLint/Prettier)
  • Concurrency: Shared (parallel) or exclusive (blocking) execution
  • State: Turns (EventStream) & Background (AsyncJobManager)
  • Resilience: Inject AgentToolResult with isError: true on failure; never crash the process
  • Testing: Use bun:test, mock via custom fetch injection, real temp dirs (no nock or filesystem mocks)
  • Security: Override Bun.env dynamically; use crypto.subtle (no hardcoded keys)