Pi
Self-extensible AI coding agent CLI with a terminal UI, tool calling, and session management
Repository Health
Technical Analysis
Pi is an open-source, self-extensible coding agent you run from the terminal — an interactive CLI that reads, edits, and writes files, executes shell commands, and manages multi-turn sessions, all rendered through a custom differential-rendering TUI. It ships as @earendil-works/pi-coding-agent, the flagship package of a four-package monorepo that also exposes its underlying pieces (pi-agent-core for the agent runtime, pi-ai for a unified multi-provider LLM API, and pi-tui for the terminal UI layer) as independently usable libraries.
Pi deliberately ships without a built-in permission system, running with the same access as the user who launched it; the project instead documents three containerization patterns (a Gondolin micro-VM extension, plain Docker, or OpenShell) for teams that need stronger sandboxing. It has an unusually mature supply-chain-hardening posture for a young project — pinned direct dependencies, npm audit signatures in CI, and a generated shrinkwrap bundled into every published release.
What You Get
- An interactive terminal coding agent (
pi) with file read/edit/write, bash execution, and persistent session management - A custom differential-rendering TUI (
pi-tui) instead of a generic terminal-output loop - A reusable agent runtime (
pi-agent-core) handling tool calling and state management independently of the CLI - A unified LLM API (
pi-ai) abstracting OpenAI, Anthropic, Google, and other providers behind one interface - RPC and print modes (
src/modes/rpc,src/modes/print-mode.ts) for scripting and non-interactive automation - Documented containerization patterns (Gondolin micro-VM, Docker, OpenShell) for sandboxing agent execution
- Supply-chain hardening: pinned direct dependencies, generated npm shrinkwrap, and CI-enforced
npm audit signatures
Common Use Cases
- Running an interactive AI coding session in a terminal to read, edit, and test code across a real repository
- Automating coding-agent workflows non-interactively via RPC/print mode from scripts or CI
- Building a custom coding agent or internal tool on top of the reusable
pi-agent-coreruntime andpi-aiLLM abstraction - Sandboxing untrusted or high-autonomy agent runs inside a micro-VM, Docker container, or OpenShell policy sandbox
- Switching between LLM providers (OpenAI, Anthropic, Google) for the same coding-agent workflow without rewriting integration code
Under The Hood
Architecture: The coding agent (packages/coding-agent) is the top-level consumer of a layered monorepo: main.ts dispatches to one of three modes — modes/interactive (the full TUI), modes/print-mode.ts (single-shot output), and modes/rpc (structured automation) — all driven by an AgentSession (core/agent-session.ts, agent-session-runtime.ts, agent-session-services.ts) that wraps the lower-level pi-agent-core tool-calling loop; session state, auth storage, bash execution, and an internal event bus are each isolated into their own core modules (bash-executor.ts, auth-storage.ts, event-bus.ts), and extensions live under core/extensions for user-defined tool/behavior additions. Tech Stack: TypeScript throughout (~93% of the codebase, 54,600+ lines in the coding-agent package alone), built with tsgo, optionally compiled to a standalone binary via Bun (build:binary), with undici dispatcher configuration for HTTP, @silvia-odwyer/photon-node for image resizing, and a custom TUI renderer (pi-tui) rather than an off-the-shelf terminal-UI library. Code Quality: The coding-agent package alone has 176+ .test.ts files run via Vitest, and the monorepo’s npm run check chains lint, format, and type-checking; the README documents an explicit, unusually detailed supply-chain-hardening policy — exact-pinned direct dependencies, min-release-age=2 in .npmrc, pre-commit lockfile-change blocking, and a generated shrinkwrap bundled into the published CLI package — treating dependency bumps as reviewed code changes. API Design: The CLI surfaces three distinct entry modes (interactive TUI, single-shot print, scriptable RPC) behind one binary, letting the same agent be driven by a human in a terminal or by another program over structured RPC without a separate integration, while the underlying pi-agent-core/pi-ai packages are published separately so the agent runtime and LLM abstraction can be reused outside the CLI entirely.
Used by 5 apps in this directory
agenta
Developer Tools · Devops · AI Development
The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.
Cate
AI Code Assistants
A desktop IDE built on an infinite canvas — spread code editors, terminals, browsers, docs, and AI agents across freeform space instead of stacking windows and tabs, with layouts restored automatically.
herdr
AI Agents · Developer Tools
A terminal-native agent multiplexer that runs Claude, Codex, Gemini, and other coding agents side by side in real, persistent panes you can detach from and reattach to from anywhere.
NemoClaw
AI Agents · AI Development
Run AI coding agents like OpenClaw and Hermes securely inside NVIDIA OpenShell sandboxes with a hardened blueprint, routed inference, and lifecycle management through a single CLI.
Pi
AI Agents
An open-source, self-extensible agent harness and coding agent CLI — a modular runtime (agent core, unified multi-provider LLM API, TUI) with no built-in permission system by default, documented containerization patterns for sandboxing instead.