mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 19:05:11 +00:00
- README-NEW.md: add Quick Start, Interactive Mode, Sessions sections - session.md: add Message Types section, complete SessionManager API, fix source links to GitHub URLs - compaction.md: rename hooks to extensions, fix source links to GitHub URLs - keybindings.md: new file documenting all keyboard shortcuts
387 lines
13 KiB
Markdown
387 lines
13 KiB
Markdown
<p align="center">
|
|
<a href="https://shittycodingagent.ai">
|
|
<img src="https://shittycodingagent.ai/logo.svg" alt="pi logo" width="128">
|
|
</a>
|
|
</p>
|
|
<p align="center">
|
|
<a href="https://discord.com/invite/nKXTsAcmbT"><img alt="Discord" src="https://img.shields.io/badge/discord-community-5865F2?style=flat-square&logo=discord&logoColor=white" /></a>
|
|
<a href="https://www.npmjs.com/package/@mariozechner/pi-coding-agent"><img alt="npm" src="https://img.shields.io/npm/v/@mariozechner/pi-coding-agent?style=flat-square" /></a>
|
|
<a href="https://github.com/badlogic/pi-mono/actions/workflows/ci.yml"><img alt="Build status" src="https://img.shields.io/github/actions/workflow/status/badlogic/pi-mono/ci.yml?style=flat-square&branch=main" /></a>
|
|
</p>
|
|
|
|
Pi is a minimal terminal coding harness. Adapt pi to your workflows, not the other way around, without having to fork and modify pi internals. Extend it with TypeScript [Extensions](#extensions), [Skills](#skills), [Prompt Templates](#prompt-templates), and [Themes](#themes). Put your extensions, skills, prompt templates, and themes in [Pi Packages](#pi-packages) and share them with others via npm or git.
|
|
|
|
Pi ships with powerful defaults but skips features like sub agents and plan mode. Instead, you can ask pi to build what you want or install a third party pi package that matches your workflow.
|
|
|
|
Pi runs in four modes: interactive, print or JSON, RPC for process integration, and an SDK for embedding in your own apps. See [clawdbot/clawdbot](https://github.com/clawdbot/clawdbot) for a real-world SDK integration.
|
|
|
|
## Table of Contents
|
|
|
|
- [Quick Start](#quick-start)
|
|
- [Providers & Models](#providers--models)
|
|
- [Interactive Mode](#interactive-mode)
|
|
- [Sessions](#sessions)
|
|
- [Configuration](#configuration)
|
|
- [Customization](#customization)
|
|
- [CLI Reference](#cli-reference)
|
|
- [Programmatic Usage](#programmatic-usage)
|
|
- [Philosophy](#philosophy)
|
|
|
|
---
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
npm install -g @mariozechner/pi-coding-agent
|
|
```
|
|
|
|
Authenticate with an API key:
|
|
|
|
```bash
|
|
export ANTHROPIC_API_KEY=sk-ant-...
|
|
pi
|
|
```
|
|
|
|
Or use your existing subscription:
|
|
|
|
```bash
|
|
pi
|
|
/login # Then select provider
|
|
```
|
|
|
|
Then just talk to pi. By default, pi gives the model four tools: `read`, `write`, `edit`, and `bash`. The model uses these to fulfill your requests. Add capabilities via [skills](#skills), [prompt templates](#prompt-templates), [extensions](#extensions), or [pi packages](#pi-packages).
|
|
|
|
**Platform notes:** [Windows](docs/windows.md) | [Terminal setup](docs/terminal-setup.md) | [Shell aliases](docs/shell-aliases.md)
|
|
|
|
---
|
|
|
|
## Providers & Models
|
|
|
|
For each built-in provider, pi maintains a list of tool-capable models, updated with every release. Authenticate via subscription (`/login`) or API key, then select any model from that provider via `/model` (or Ctrl+L).
|
|
|
|
**Subscriptions:**
|
|
- Anthropic Claude Pro/Max
|
|
- OpenAI ChatGPT Plus/Pro (Codex)
|
|
- GitHub Copilot
|
|
- Google Gemini CLI
|
|
- Google Antigravity
|
|
|
|
**API keys:**
|
|
- Anthropic
|
|
- OpenAI
|
|
- Azure OpenAI
|
|
- Google Gemini
|
|
- Google Vertex
|
|
- Amazon Bedrock
|
|
- Mistral
|
|
- Groq
|
|
- Cerebras
|
|
- xAI
|
|
- OpenRouter
|
|
- Vercel AI Gateway
|
|
- ZAI
|
|
- OpenCode Zen
|
|
- MiniMax
|
|
|
|
See [docs/providers.md](docs/providers.md) for detailed setup instructions.
|
|
|
|
**Custom providers & models:** Add providers via `~/.pi/agent/models.json` if they speak a supported API (OpenAI, Anthropic, Google). For custom APIs or OAuth, use extensions. See [docs/models.md](docs/models.md) and [docs/custom-provider.md](docs/custom-provider.md).
|
|
|
|
---
|
|
|
|
## Interactive Mode
|
|
|
|
<img src="docs/images/interactive-mode.png" alt="Interactive Mode" width="600">
|
|
|
|
The interface from top to bottom:
|
|
|
|
- **Startup header** - Shows shortcuts (`/hotkeys` for all), loaded AGENTS.md files, prompt templates, skills, and extensions
|
|
- **Messages** - Your messages, assistant responses, tool calls and results, notifications, errors, and extension UI
|
|
- **Editor** - Where you type; border color indicates thinking level
|
|
- **Footer** - Working directory, session name, total token/cache usage, cost, context usage, current model
|
|
|
|
The editor can be temporarily replaced by other UI, like built-in `/settings` or custom UI from extensions (e.g., a Q&A tool that lets the user answer model questions in a structured format). [Extensions](#extensions) can also replace the editor, add widgets above/below it, a status line, custom footer, or overlays.
|
|
|
|
### Editor
|
|
|
|
| Feature | How |
|
|
|---------|-----|
|
|
| File reference | Type `@` to fuzzy-search project files |
|
|
| Path completion | Tab to complete paths |
|
|
| Multi-line | Shift+Enter (or Ctrl+Enter on Windows Terminal) |
|
|
| Images | Ctrl+V to paste, or drag onto terminal |
|
|
| Bash commands | `!command` runs and sends output to LLM, `!!command` runs without sending |
|
|
|
|
Standard editing keybindings for delete word, undo, etc. See [docs/keybindings.md](docs/keybindings.md).
|
|
|
|
### Commands
|
|
|
|
Type `/` in the editor to trigger commands. [Extensions](#extensions) can register custom commands, [skills](#skills) are available as `/skill:name`, and [prompt templates](#prompt-templates) expand via `/templatename`.
|
|
|
|
| Command | Description |
|
|
|---------|-------------|
|
|
| `/login`, `/logout` | OAuth authentication |
|
|
| `/model` | Switch models |
|
|
| `/scoped-models` | Enable/disable models for Ctrl+P cycling |
|
|
| `/settings` | Thinking level, theme, message delivery |
|
|
| `/resume` | Pick from previous sessions |
|
|
| `/new` | Start a new session |
|
|
| `/name <name>` | Set session display name |
|
|
| `/session` | Show session info (path, tokens, cost) |
|
|
| `/tree` | Jump to any point in the session and continue from there |
|
|
| `/fork` | Create a new session from the current branch |
|
|
| `/compact [prompt]` | Manually compact context, optional custom instructions |
|
|
| `/copy` | Copy last assistant message to clipboard |
|
|
| `/export [file]` | Export session to HTML file |
|
|
| `/share` | Upload as private GitHub gist with shareable HTML link |
|
|
| `/reload` | Reload extensions, skills, prompts, themes |
|
|
| `/hotkeys` | Show all keyboard shortcuts |
|
|
| `/changelog` | Display version history |
|
|
| `/quit`, `/exit` | Quit pi |
|
|
|
|
### Keyboard Shortcuts
|
|
|
|
See `/hotkeys` for the full list. Customize via `~/.pi/agent/keybindings.json`. See [docs/keybindings.md](docs/keybindings.md).
|
|
|
|
**Commonly used:**
|
|
|
|
| Key | Action |
|
|
|-----|--------|
|
|
| Ctrl+C | Clear editor |
|
|
| Ctrl+C twice | Quit |
|
|
| Escape | Cancel/abort |
|
|
| Escape twice | Open `/tree` |
|
|
| Ctrl+L | Open model selector |
|
|
| Ctrl+P / Shift+Ctrl+P | Cycle scoped models forward/backward |
|
|
| Shift+Tab | Cycle thinking level |
|
|
| Ctrl+O | Collapse/expand tool output |
|
|
| Ctrl+T | Collapse/expand thinking blocks |
|
|
|
|
---
|
|
|
|
## Sessions
|
|
|
|
Sessions are stored as JSONL files with a tree structure. Each entry has an `id` and `parentId`, enabling in-place branching without creating new files.
|
|
|
|
### Management
|
|
|
|
Sessions auto-save to `~/.pi/agent/sessions/` organized by working directory.
|
|
|
|
```bash
|
|
pi -c # Continue most recent session
|
|
pi -r # Browse and select from past sessions
|
|
pi --no-session # Ephemeral mode (don't save)
|
|
pi --session <path> # Use specific session file or ID
|
|
```
|
|
|
|
### Branching
|
|
|
|
**`/tree`** - Navigate the session tree in-place. Select any previous point, continue from there, and switch between branches. All history preserved in a single file.
|
|
|
|
- Search by typing, page with ←/→
|
|
- Filter modes (Ctrl+O): default → no-tools → user-only → labeled-only → all
|
|
- Press `l` to label entries as bookmarks
|
|
|
|
**`/fork`** - Create a new session file from the current branch. Opens a selector, copies history up to the selected point, and places that message in the editor for modification.
|
|
|
|
### Compaction
|
|
|
|
Long sessions can exhaust context windows. Compaction summarizes older messages while keeping recent ones.
|
|
|
|
**Manual:** `/compact` or `/compact <custom instructions>`
|
|
|
|
**Automatic:** Enabled by default. Triggers on context overflow (recovers and retries) or when approaching the limit (proactive). Configure via `/settings` or `settings.json`.
|
|
|
|
Compaction is lossy. The full history remains in the JSONL file; use `/tree` to revisit. Customize compaction behavior via [extensions](#extensions).
|
|
|
|
See [docs/session.md](docs/session.md) for file format and [docs/compaction.md](docs/compaction.md) for internals.
|
|
|
|
---
|
|
|
|
## Configuration
|
|
|
|
### Context Files
|
|
|
|
Pi loads `AGENTS.md` files at startup (global `~/.pi/agent/AGENTS.md`, parent directories, current directory). Use for project instructions, conventions, common commands.
|
|
|
|
### System Prompt
|
|
|
|
Replace the default system prompt with `.pi/SYSTEM.md` (project) or `~/.pi/agent/SYSTEM.md` (global). Append without replacing via `APPEND_SYSTEM.md`.
|
|
|
|
### Custom Models
|
|
|
|
Add Ollama, vLLM, LM Studio, or proxy endpoints via `~/.pi/agent/models.json`:
|
|
|
|
```json
|
|
{
|
|
"providers": {
|
|
"ollama": {
|
|
"baseUrl": "http://localhost:11434/v1",
|
|
"api": "openai-completions",
|
|
"models": [{ "id": "llama-3.1-8b", "name": "Llama 3.1 8B", ... }]
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
See [docs/models.md](docs/models.md) for full schema and examples.
|
|
|
|
### Settings
|
|
|
|
Global settings in `~/.pi/agent/settings.json`, project overrides in `.pi/settings.json`.
|
|
|
|
See [docs/settings.md](docs/settings.md) for all options.
|
|
|
|
---
|
|
|
|
## Customization
|
|
|
|
### Themes
|
|
|
|
Built-in: `dark`, `light`. Create custom themes in `~/.pi/agent/themes/*.json` with live reload.
|
|
|
|
See [docs/themes.md](docs/themes.md).
|
|
|
|
### Prompt Templates
|
|
|
|
Reusable prompts as Markdown files in `~/.pi/agent/prompts/` or `.pi/prompts/`. Type `/name` to expand.
|
|
|
|
See [docs/prompt-templates.md](docs/prompt-templates.md).
|
|
|
|
### Skills
|
|
|
|
On-demand capability packages following the [Agent Skills standard](https://agentskills.io). Place in `~/.pi/agent/skills/` or `.pi/skills/`. Invoke via `/skill:name` or let the agent load them automatically.
|
|
|
|
See [docs/skills.md](docs/skills.md).
|
|
|
|
### Extensions
|
|
|
|
TypeScript modules for custom tools, commands, event interception, and UI.
|
|
|
|
```typescript
|
|
export default function (pi: ExtensionAPI) {
|
|
pi.registerTool({ name: "deploy", ... });
|
|
pi.registerCommand("stats", { ... });
|
|
pi.on("tool_call", async (event, ctx) => { ... });
|
|
}
|
|
```
|
|
|
|
Place in `~/.pi/agent/extensions/` or `.pi/extensions/`.
|
|
|
|
See [docs/extensions.md](docs/extensions.md) and [examples/extensions/](examples/extensions/).
|
|
|
|
### Pi Packages
|
|
|
|
Bundle and share extensions, skills, prompts, and themes via npm or git:
|
|
|
|
```bash
|
|
pi install npm:@foo/pi-tools
|
|
pi install git:github.com/user/repo
|
|
pi list
|
|
pi update
|
|
```
|
|
|
|
See [docs/packages.md](docs/packages.md).
|
|
|
|
---
|
|
|
|
## CLI Reference
|
|
|
|
```bash
|
|
pi [options] [@files...] [messages...]
|
|
```
|
|
|
|
### Modes
|
|
|
|
| Flag | Description |
|
|
|------|-------------|
|
|
| (default) | Interactive mode |
|
|
| `-p`, `--print` | Print response and exit |
|
|
| `--mode json` | JSON event stream |
|
|
| `--mode rpc` | RPC mode for process integration |
|
|
|
|
### Common Options
|
|
|
|
| Option | Description |
|
|
|--------|-------------|
|
|
| `--provider`, `--model` | Select provider and model |
|
|
| `--thinking <level>` | `off`, `minimal`, `low`, `medium`, `high` |
|
|
| `--models <patterns>` | Patterns for Ctrl+P cycling |
|
|
| `-c`, `--continue` | Continue most recent session |
|
|
| `-r`, `--resume` | Browse and select session |
|
|
| `--tools <list>` | Limit tools (default: `read,bash,edit,write`) |
|
|
|
|
### File Arguments
|
|
|
|
```bash
|
|
pi @prompt.md "Answer this"
|
|
pi @screenshot.png "What's in this image?"
|
|
```
|
|
|
|
See `pi --help` for all options.
|
|
|
|
---
|
|
|
|
## Programmatic Usage
|
|
|
|
### SDK
|
|
|
|
```typescript
|
|
import { AuthStorage, createAgentSession, ModelRegistry, SessionManager } from "@mariozechner/pi-coding-agent";
|
|
|
|
const { session } = await createAgentSession({
|
|
sessionManager: SessionManager.inMemory(),
|
|
authStorage: new AuthStorage(),
|
|
modelRegistry: new ModelRegistry(authStorage),
|
|
});
|
|
|
|
await session.prompt("What files are in the current directory?");
|
|
```
|
|
|
|
See [docs/sdk.md](docs/sdk.md) and [examples/sdk/](examples/sdk/).
|
|
|
|
### RPC Mode
|
|
|
|
```bash
|
|
pi --mode rpc --no-session
|
|
```
|
|
|
|
See [docs/rpc.md](docs/rpc.md) for the protocol.
|
|
|
|
### HTML Export
|
|
|
|
```bash
|
|
pi --export session.jsonl output.html
|
|
```
|
|
|
|
---
|
|
|
|
## Philosophy
|
|
|
|
**No MCP.** Build CLI tools with READMEs (see [Skills](#skills)). [Why?](https://mariozechner.at/posts/2025-11-02-what-if-you-dont-need-mcp/)
|
|
|
|
**No sub-agents.** Spawn pi instances via tmux, or build your own with [Extensions](#extensions).
|
|
|
|
**No permission popups.** Run in a container or build your own confirmation flow.
|
|
|
|
**No plan mode.** Write plans to files, start fresh for implementation.
|
|
|
|
Read the [blog post](https://mariozechner.at/posts/2025-11-30-pi-coding-agent/) for the full rationale.
|
|
|
|
---
|
|
|
|
## Development
|
|
|
|
See [docs/development.md](docs/development.md) for forking, rebranding, and debugging.
|
|
|
|
---
|
|
|
|
## License
|
|
|
|
MIT
|
|
|
|
## See Also
|
|
|
|
- [@mariozechner/pi-ai](https://www.npmjs.com/package/@mariozechner/pi-ai): Core LLM toolkit
|
|
- [@mariozechner/pi-agent](https://www.npmjs.com/package/@mariozechner/pi-agent): Agent framework
|
|
- [@mariozechner/pi-tui](https://www.npmjs.com/package/@mariozechner/pi-tui): Terminal UI components
|