πΊοΈ 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)