Welcome back to another GitHub deep dive! Today, we’re cracking open Pi Mono, a monorepo by Mario Zechner (the creator of libGDX) that takes a radically different philosophy to AI coding agents.
While tools like Claude Code, Cursor, and Aider bake in features like sub-agents, plan modes, and permission popups, Pi says: “Build it yourself.” It gives you the primitives—a unified LLM API, an agent runtime, a TUI framework, and a web UI library—and lets you compose the exact workflow you need using TypeScript extensions.
Let’s break it down using our Mental Model.
Part 1: Foundations (The Mental Model)
Think of most AI coding agents like a pre-built house. The floor plan is fixed, the walls are where they are, and if you want a skylight, you’re submitting a PR and hoping the maintainer agrees.
Pi is more like a construction toolkit. It gives you the steel beams (the LLM API), the electrical wiring (the agent runtime), the interior design tools (TUI & Web UI), and says: “Go build your house.”
The result? A coding agent that ships with 4 default tools (read, write, edit, bash) and is immediately useful—but also an agent you can fundamentally reshape without forking the codebase.
The Mental Model: Pi Mono = Unified LLM API + Stateful Agent Runtime + Terminal UI Framework + Web Components + Extension System = Your AI Agent, Your Way.
Part 2: The Investigation
Pi Mono is a TypeScript monorepo containing 7 packages, each solving a distinct problem in the AI agent stack. Here’s the architecture:
| |
The 7 Packages, Explained
| Package | What It Does |
|---|---|
| pi-ai | The foundation. A unified API that talks to OpenAI, Anthropic, Google, Bedrock, Mistral, xAI, Groq, Cerebras, and more. One stream() call, any provider. |
| pi-agent-core | The brain. A stateful agent with tool execution, event streaming, steering (interrupt mid-tool), and follow-up queues. |
| pi-coding-agent | The product. An interactive terminal agent with session branching, auto-compaction, file references via @, and a full extension API. |
| pi-tui | The screen. A terminal UI library with differential rendering, flicker-free output, and components like Editor, Markdown renderer, and inline Image display. |
| pi-web-ui | The browser. Web components for chat interfaces, JavaScript REPL, artifact rendering (HTML, SVG, Markdown), and IndexedDB storage. |
| pi-mom | The assistant. A Slack bot that self-manages its environment—installing tools, writing scripts, and building its own CLI skills autonomously. |
| pi-pods | The GPU manager. Deploy and manage LLMs on remote GPU pods with automatic vLLM configuration for agentic workloads. |
Part 3: The Diagnosis
This is where Pi gets genuinely interesting for developers.
1. The Extension System: Build Anything
Pi’s killer feature is its extension API. Extensions are TypeScript modules that can:
- Replace built-in tools entirely (swap
writefor a version that auto-commits to git) - Add custom UI components (status lines, headers, overlays—even Doom)
- Implement sub-agents and plan mode (Pi intentionally doesn’t ship these, so you build them to match your workflow)
- Gate permissions and protect paths
- Integrate MCP servers
- Build SSH and sandbox execution
| |
The philosophy is clear: features that other tools bake in can be built as extensions, keeping the core minimal and your agent shaped exactly how you work.
2. Cross-Provider Handoffs
Most LLM libraries lock you into one provider per session. Pi’s pi-ai package supports seamless mid-conversation handoffs between providers:
| |
Thinking blocks from Provider A are automatically converted to text with <thinking> tags for Provider B. Tool calls and results are preserved unchanged.
3. Session Branching & Compaction
Pi stores sessions as JSONL files with a tree structure. Each entry has an id and parentId, enabling in-place branching without creating new files:
/tree- Navigate the entire session history, jump to any point, and continue from there/fork- Create a new session from any branch point/compact- Summarize older messages to free context. The full history remains in the JSONL file
This is massively useful for exploration—try one approach, branch, try another, and switch between them without losing anything.
4. Pi Mom: The Self-Managing Bot
pi-mom is unlike any chatbot framework. It’s a Slack bot that:
- Installs its own tools (
apk add git jq curl) - Writes its own CLI skills (need a Gmail checker? Ask Mom, she writes the script)
- Manages its own credentials (ask for tokens, store them securely)
- Runs in a Docker sandbox with full bash access
- Schedules events (cron-based periodic tasks, one-shot reminders)
Each Slack channel gets its own workspace, conversation history, and memory files. Mom compacts context automatically and can grep infinite history from log.jsonl.
5. GPU Pod Management with pi-pods
For developers running their own models, pi-pods automates vLLM deployment:
| |
It automatically configures tool calling parsers for known models (Hermes for Qwen, GLM4 parser for GLM, Responses API for GPT-OSS) and manages multi-GPU assignments.
Part 4: The Resolution
Getting Started
| |
Pi gives you 4 tools by default: read, write, edit, bash. Start talking and the model will use them to fulfill your requests.
Extending Pi
Pi’s extension ecosystem is distributed via Pi Packages—bundles of extensions, skills, prompts, and themes shared via npm or git:
| |
Using as an SDK
Pi isn’t just a CLI. You can embed it in your own applications:
| |
For non-Node.js integrations, use RPC mode over stdin/stdout: pi --mode rpc.
Final Mental Model
| Aspect | Traditional AI Agents | Pi Mono |
|---|---|---|
| Features | Pre-built, take-it-or-leave-it | Extension-based, build what you need |
| Providers | Usually locked to 1-2 | 20+ providers, mid-session handoffs |
| Session Management | Linear history | Tree-structured branching with compaction |
| Sub-Agents | Built-in or nothing | Build your own via extensions |
| Core Philosophy | Opinionated | “Aggressively extensible” |
Pi Mono is for developers who see their AI coding agent as a tool that should adapt to their workflow, not the other way around. It trades a polished out-of-the-box experience for radical composability—and backs it up with a genuinely elegant set of primitives.
The monorepo is MIT-licensed, actively maintained, and backed by a growing Discord community. If you’ve ever wished your coding agent worked differently, Pi says: make it so.
