Open source · MIT · 4921+ commits

Pi — the AI coding agent that extends itself

A unified agent toolkit that cleanly separates the "unstable outside world" (models, tools, UIs, extensions) from a "stable core loop". From a unified LLM API to an interactive coding CLI — everything is open source and self-hostable.

🚀 Quick Start ⭐ GitHub 📖 Docs

Pi is a set of open-source agent building blocks for developers who want to own their tooling. Instead of a single monolithic assistant, it gives you a stable core loop plus a collection of swappable peripherals — models, tools, UIs and extensions. You write the tools and the prompt; Pi drives the loop, calls the model, runs your tools, and records everything in a transparent session tree you can replay and audit. The result is an agent you can read, modify, extend and self-host without asking anyone for permission.

Install Pi

Clone, install safely, and run the coding agent locally in about five minutes.

Quick start git clone https://github.com/earendil-works/pi.git && cd pi
Terminal
# 1. Get the source
git clone https://github.com/earendil-works/pi.git
cd pi

# 2. Install deps safely (pinned, scripts disabled)
npm install --ignore-scripts

# 3. Build all packages
npm run build

# 4. Launch the interactive coding agent
./pi-test.sh
Requirements: Node.js 18+ and npm. To actually call a model, configure an API key in pi-ai — see Model providers.

Want the full steps and a minimal agent loop example? Head to Quick Start.

Why Pi

Not another black-box assistant, but an agent runtime you can read, modify and extend.

Most "AI assistants" hide their internals and lock you into a vendor. Pi inverts that: the loop is small and stable, and everything around it is a replaceable part. That is why a single codebase can power a terminal tool, an SDK and a remote agent at once.

🧩

Stable core, mutable peripherals

Models, tools, UIs change — but the agent loop is stable: prepare context → call model → handle tools → write back → continue or stop. You upgrade the outside without rewriting the inside.

🔌

Unified multi-vendor LLM

pi-ai hides the differences between OpenAI / Anthropic / Google / Bedrock / Vertex / Copilot. Switch vendors with one line and keep your tooling unchanged.

🛠

Tools + state management

pi-agent-core ships tool calling and a session state machine, with a JSONL session tree, branches and resumable runs you can pick up later.

⌨️

Interactive coding CLI

pi-coding-agent is a pair-programmer in your terminal: read the repo, edit files, run commands, self-correct, and show you a diff before writing.

🖥

Differential-render terminal UI

pi-tui only repaints what changed, staying smooth even in very long sessions where a naive terminal would stutter.

🔒

Supply-chain hardening

Pinned dependencies, lockfile as source of truth, isolated testing, and runs with the launching user's permissions by default — plus --ignore-scripts installs.

Four core packages

An npm workspaces monorepo — use one package or install the whole thing.

🧠

@earendil-works/pi-ai

A unified multi-vendor LLM API with streaming, tool calling and a provider factory. One interface covers OpenAI, Anthropic, Google, Bedrock, Vertex and Copilot, so swapping providers never touches your business code.

Unified LLM
⚙️

@earendil-works/pi-agent-core

The agent runtime with tool calling and state management — the heart of Pi. It owns the session, the tool dispatch and the resumable run loop that everything else builds on.

Agent runtime
⌨️

@earendil-works/pi-coding-agent

An interactive coding-agent command line tool for developers. Point it at a repo and it reads, edits, runs commands and self-corrects like a pair programmer in your terminal.

Coding CLI
🖥

@earendil-works/pi-tui

A terminal UI library with differential rendering that stays fluid on long output. It repaints only what changed, keeping the interface responsive through very long sessions.

Terminal UI

How a request flows

Clear layer boundaries, so each layer can be replaced and tested independently.

Layer 1 · Interaction
TUI / RPC / SDK

A user or external system submits a prompt through the terminal UI, remote call or SDK.

Layer 2 · Runtime
AgentSession → Agent

Expands skills and templates, checks model and auth, hands messages to the Agent Loop, and streams events back to the UI.

Layer 3 · Core loop
Agent Loop → pi-ai → tools → session store

The stable loop: call the model, run tools, write back results, until a final answer or stop.

Key design: keep the "unstable outside world" apart from the "stable core loop". Vendors, tools, UIs and extensions are swappable; the core loop stays put.

Who is Pi for

Pi fits teams that care about control, cost and longevity.

Up and running in five minutes

Clone, install, launch — details in Quick Start.

微信群二维码

扫码加入
Pi Agent 微信交流群

💬