Some checks failed
CI / build-check-test (push) Has been cancelled
- Remove unused .pi extensions and prompts - Update generated model files - Add context.md - Update pi-test.sh and package-lock.json
6.8 KiB
6.8 KiB
Code Context
Top-Level Structure
.sproutclaw/
├── .claude/ # Claude configuration
├── .github/ # Issue templates, workflows (issue-gate, pr-gate, approve-contributor)
├── .husky/ # Git hooks
├── .pi/ # pi/pi-mono agent configuration (AGENTS.md)
├── node_modules/
├── packages/ # 5 monorepo workspaces
│ ├── ai/ # @earendil-works/pi-ai v0.74.0
│ ├── agent/ # @earendil-works/pi-agent-core v0.74.0
│ ├── coding-agent/ # @earendil-works/pi-coding-agent v0.74.0
│ ├── tui/ # @earendil-works/pi-tui v0.74.0
│ └── web-ui/ # @earendil-works/pi-web-ui v0.74.0
├── scripts/ # CI/release/utility scripts
├── tmp/ # Temp files
├── pi-test.sh # Interactive TUI test script
├── README.md
├── CONTRIBUTING.md
├── AGENTS.md
├── biome.json # Linting/formatting config
├── tsconfig.base.json # Shared TS config
├── tsconfig.json # Root TS config
├── package.json # Workspace root (npm workspaces)
└── bun.lock / package-lock.json
Packages
1. packages/ai — @earendil-works/pi-ai
Unified LLM API — automatic model discovery, provider configuration, streaming.
src/index.ts— package entrysrc/types.ts— core types (Api,StreamOptions,Model,KnownProvider)src/stream.ts— main streaming implementationsrc/models.ts/src/models.generated.ts— model registry + auto-generatedsrc/providers/— individual provider implementations (Anthropic, Google, OpenAI, Mistral, etc.)src/cli.ts— CLI for model listing etc.src/env-api-keys.ts— credential detection from env varssrc/oauth.ts— OAuth supportsrc/api-registry.ts— API/stream provider registrationscripts/generate-models.ts— model list generation script- Subpath exports per provider (e.g.
./anthropic,./google, etc.)
2. packages/agent — @earendil-works/pi-agent-core
General-purpose agent — transport abstraction, state management, attachment support.
src/index.ts— package entrysrc/types.ts— core types (agent state, attachments, transports)src/agent.ts— agent implementationsrc/agent-loop.ts— agent main loopsrc/proxy.ts— proxy supportsrc/harness/— test harness utilities
3. packages/coding-agent — @earendil-works/pi-coding-agent
Coding agent CLI — the pi CLI binary with read, bash, edit, write tools and session management.
src/cli.ts/src/cli/— CLI argument parsing / entry pointsrc/main.ts— main agent runnersrc/index.ts— package entrysrc/config.ts— configuration managementsrc/core/— core logic (model resolution, hooks, tool execution, session management)src/modes/— operational modessrc/bun/— Bun-specific supportsrc/migrations.ts— data migration utilitiessrc/package-manager-cli.ts— package manager interactiondocs/— provider setup docsexamples/— extension examples (custom provider, sandbox)- Binary name:
pi
4. packages/tui — @earendil-works/pi-tui
Terminal UI library — differential rendering for text-based terminal applications.
src/index.ts— package entrysrc/tui.ts— core TUI rendering enginesrc/terminal.ts— low-level terminal I/Osrc/keys.ts/src/keybindings.ts— key input handlingsrc/components/— reusable UI componentssrc/editor-component.ts— text editor componentsrc/autocomplete.ts— autocomplete supportsrc/fuzzy.ts— fuzzy matchingsrc/terminal-image.ts— image rendering in terminalsrc/kill-ring.ts/src/undo-stack.ts— editing helperssrc/stdin-buffer.ts/src/utils.ts— utilities
5. packages/web-ui — @earendil-works/pi-web-ui
Reusable web UI components — AI chat interfaces powered by pi-ai.
src/index.ts— package entrysrc/app.css— Tailwind CSS stylesheetsrc/ChatPanel.ts— main chat panel componentsrc/components/— reusable React componentssrc/dialogs/— dialog componentssrc/prompts/— prompt templates/managementsrc/storage/— client-side storage abstractionsrc/tools/— tool integrationsrc/utils/— utilities- Build: TypeScript + Tailwind CSS
Root Scripts (scripts/)
release.mjs— automated release workflow (version + changelog + publish)sync-versions.js— lockstep version sync across all packagescost.ts/stats.ts— analytics/telemetry statstool-stats.ts/edit-tool-stats.mjs/read-tool-stats.mjs— tool usage statisticsprofile-coding-agent-node.mjs— Node.js profiling for coding agentbuild-binaries.sh— binary build scriptbrowser-smoke-entry.ts/check-browser-smoke.mjs— browser smoke testssession-transcripts.ts/session-context-stats.mjs— session logging
Architecture Summary
pi-tui (terminal UI) ─── pi-coding-agent (CLI + tools) ─── pi-agent-core (agent loop)
│
pi-web-ui (web UI) ────────────┤
│
pi-ai (LLM provider abstraction)
- pi-ai is the foundation layer providing unified LLM API access (Anthropic, Google, OpenAI, Azure, Mistral, Bedrock, etc.)
- pi-agent-core builds on pi-ai with agent loop, transport abstraction, and state management
- pi-coding-agent is the main product: a coding agent CLI (
picommand) with read/bash/edit/write tools and session management - pi-tui is a standalone TUI rendering library used by pi-coding-agent
- pi-web-ui provides reusable chat UI components (React) powered by pi-ai
Key Facts
- Lockstep versioning: all packages share the same version (currently 0.74.0)
- Release automation:
npm run release:patch/release:minorviascripts/release.mjs - TypeScript with tsgo: uses
tsgo(TypeScript native preview) for fast builds; web-ui usestsc - Linting: Biome (v2.3.5) for formatting and linting (
npm run check) - Testing: vitest for ai/agent/coding-agent; node --test for tui
- No
anytypes allowed, standard top-level imports only (no inlineimport()) - GitHub CI: issue-gate, pr-gate, approve-contributor workflows for contributor management
Start Here
Open package.json (root) for workspace structure and available scripts. For a specific package, start with its package.json then src/index.ts for the public API surface.