@earendil-works/pi-coding-agent 0.87.0 → 0.87.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +25 -711
  3. package/dist/bundle/chunks/{anthropic-messages-MYU5ZMRF.js → anthropic-messages-J5WXPPPC.js} +1 -1
  4. package/dist/bundle/chunks/{chunk-GV2E3GBU.js → chunk-65HAU2C5.js} +1 -1
  5. package/dist/bundle/chunks/{chunk-4DKZACXI.js → chunk-OJP47DM6.js} +13 -13
  6. package/dist/bundle/chunks/github-copilot.js +1 -1
  7. package/dist/bundle/chunks/{openai-completions-XHML6MTL.js → openai-completions-OBX42CLD.js} +1 -1
  8. package/dist/bundle/chunks/{virtual-modules-BNWPZYDH.js → virtual-modules-VHMJYYWQ.js} +1 -1
  9. package/dist/bundle/cli-runtime.js +1 -1
  10. package/dist/bundle/index.js +1 -1
  11. package/dist/bundle/rpc-entry.js +1 -1
  12. package/dist/cli/args.d.ts.map +1 -1
  13. package/dist/cli/args.js +14 -4
  14. package/dist/cli/args.js.map +1 -1
  15. package/dist/core/compaction/compaction.d.ts.map +1 -1
  16. package/dist/core/compaction/compaction.js +9 -9
  17. package/dist/core/compaction/compaction.js.map +1 -1
  18. package/dist/core/model-resolver.d.ts.map +1 -1
  19. package/dist/core/model-resolver.js +1 -1
  20. package/dist/core/model-resolver.js.map +1 -1
  21. package/docs/cli-integration.md +106 -0
  22. package/docs/cli.md +268 -0
  23. package/docs/compaction.md +22 -22
  24. package/docs/configuration.md +45 -0
  25. package/docs/containerization.md +109 -82
  26. package/docs/custom-provider.md +132 -784
  27. package/docs/docs.json +139 -99
  28. package/docs/environment-variables.md +3 -5
  29. package/docs/extensions.md +134 -3020
  30. package/docs/how-pi-works.md +49 -0
  31. package/docs/images/interactive-mode.png +0 -0
  32. package/docs/index.md +24 -69
  33. package/docs/json.md +193 -65
  34. package/docs/keybindings.md +57 -102
  35. package/docs/llama-cpp.md +3 -3
  36. package/docs/message-types.md +261 -0
  37. package/docs/models.md +55 -565
  38. package/docs/packages.md +66 -167
  39. package/docs/prompt-templates.md +31 -68
  40. package/docs/providers.md +102 -240
  41. package/docs/quickstart.md +61 -106
  42. package/docs/rpc-commands.md +854 -0
  43. package/docs/rpc-extension-ui.md +200 -0
  44. package/docs/rpc.md +129 -1556
  45. package/docs/sdk.md +76 -1171
  46. package/docs/security.md +70 -32
  47. package/docs/session-format.md +10 -214
  48. package/docs/sessions.md +35 -141
  49. package/docs/settings.md +109 -387
  50. package/docs/shell-aliases.md +85 -5
  51. package/docs/skills.md +51 -190
  52. package/docs/slash-commands.md +60 -0
  53. package/docs/terminal-setup.md +105 -78
  54. package/docs/termux.md +74 -83
  55. package/docs/themes.md +68 -280
  56. package/docs/tmux.md +31 -39
  57. package/docs/tui.md +69 -923
  58. package/docs/usage.md +54 -272
  59. package/docs/windows.md +43 -17
  60. package/examples/README.md +13 -2
  61. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  62. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  63. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  64. package/examples/extensions/gondolin/package-lock.json +2 -2
  65. package/examples/extensions/gondolin/package.json +1 -1
  66. package/examples/extensions/sandbox/package-lock.json +2 -2
  67. package/examples/extensions/sandbox/package.json +1 -1
  68. package/examples/extensions/with-deps/package-lock.json +2 -2
  69. package/examples/extensions/with-deps/package.json +1 -1
  70. package/examples/rpc-client.ts +35 -0
  71. package/examples/rpc-extension-ui.ts +25 -5
  72. package/examples/sdk/README.md +1 -1
  73. package/npm-shrinkwrap.json +20 -20
  74. package/package.json +8 -8
  75. package/docs/development.md +0 -90
package/README.md CHANGED
@@ -1,756 +1,70 @@
1
1
  <p align="center">
2
2
  <a href="https://pi.dev">
3
- <img alt="pi logo" src="https://pi.dev/logo-auto.svg" width="128">
3
+ <img alt="Pi logo" src="https://pi.dev/logo-auto.svg" width="128">
4
4
  </a>
5
5
  </p>
6
6
  <p align="center">
7
7
  <a href="https://discord.com/invite/3cU7Bz4UPx"><img alt="Discord" src="https://img.shields.io/badge/discord-community-5865F2?style=flat-square&logo=discord&logoColor=white" /></a>
8
- <a href="https://www.npmjs.com/package/@earendil-works/pi-coding-agent"><img alt="npm" src="https://img.shields.io/npm/v/@earendil-works/pi-coding-agent?style=flat-square" /></a>
8
+ <a href="https://www.npmjs.com/package/@earendil-works/pi-coding-agent"><img alt="npm" src="https://img.shields.io/npm/v/@earendil-works/pi-coding-agent?style=flat-square&logo=npm&logoColor=white" /></a>
9
9
  </p>
10
10
 
11
- > New issues and PRs from new contributors are auto-closed by default. Maintainers review auto-closed issues daily. See [CONTRIBUTING.md](../../CONTRIBUTING.md).
11
+ > New issues and PRs from new contributors are closed automatically. Maintainers review closed submissions daily. See [CONTRIBUTING.md](https://github.com/earendil-works/pi/blob/main/CONTRIBUTING.md).
12
12
 
13
- ---
13
+ # Pi
14
14
 
15
- 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.
15
+ Pi is a minimal, extensible AI agent for the terminal. Adapt Pi to your workflow, not the other way around.
16
16
 
17
- 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.
17
+ Ask Pi to create the prompt templates, skills, extensions, and themes you need, or install a Pi package. Use Pi directly, automate it in print, JSON, or RPC mode, or build applications with the TypeScript SDK.
18
18
 
19
- Pi runs in four modes: interactive, print or JSON, RPC for process integration, and an SDK for embedding in your own apps.
19
+ ## Getting started
20
20
 
21
- ## Share your OSS coding agent sessions
22
-
23
- If you use pi for open source work, please share your coding agent sessions.
24
-
25
- Public OSS session data helps improve models, prompts, tools, and evaluations using real development workflows.
26
-
27
- For the full explanation, see [this post on X](https://x.com/badlogicgames/status/2037811643774652911).
28
-
29
- To publish sessions, use [`badlogic/pi-share-hf`](https://github.com/badlogic/pi-share-hf). Read its README.md for setup instructions. All you need is a Hugging Face account, the Hugging Face CLI, and `pi-share-hf`.
30
-
31
- You can also watch [this video](https://x.com/badlogicgames/status/2041151967695634619), where I show how I publish my `pi-mono` sessions.
32
-
33
- I regularly publish my own `pi-mono` work sessions here:
34
-
35
- - [badlogicgames/pi-mono on Hugging Face](https://huggingface.co/datasets/badlogicgames/pi-mono)
36
-
37
- ## Table of Contents
38
-
39
- - [Quick Start](#quick-start)
40
- - [Providers & Models](#providers--models)
41
- - [Interactive Mode](#interactive-mode)
42
- - [Editor](#editor)
43
- - [Commands](#commands)
44
- - [Keyboard Shortcuts](#keyboard-shortcuts)
45
- - [Message Queue](#message-queue)
46
- - [Sessions](#sessions)
47
- - [Branching](#branching)
48
- - [Compaction](#compaction)
49
- - [Settings](#settings)
50
- - [Context Files](#context-files)
51
- - [Customization](#customization)
52
- - [Prompt Templates](#prompt-templates)
53
- - [Skills](#skills)
54
- - [Extensions](#extensions)
55
- - [Themes](#themes)
56
- - [Pi Packages](#pi-packages)
57
- - [Programmatic Usage](#programmatic-usage)
58
- - [Philosophy](#philosophy)
59
- - [CLI Reference](#cli-reference)
60
-
61
- ---
62
-
63
- ## Quick Start
21
+ Install the command-line interface with npm:
64
22
 
65
23
  ```bash
66
24
  npm install -g --ignore-scripts @earendil-works/pi-coding-agent
67
25
  ```
68
26
 
69
- `--ignore-scripts` disables dependency lifecycle scripts during install. Pi does not require install scripts for normal npm installs.
27
+ This requires Node.js 22.19 or newer. Pi does not require dependency lifecycle scripts for a normal npm installation.
70
28
 
71
- Installer alternative:
29
+ On macOS or Linux, you can instead use the installer:
72
30
 
73
31
  ```bash
74
32
  curl -fsSL https://pi.dev/install.sh | sh
75
33
  ```
76
34
 
77
- Authenticate with an API key:
35
+ Start Pi in the directory where you want it to work:
78
36
 
79
37
  ```bash
80
- export ANTHROPIC_API_KEY=sk-ant-...
38
+ cd /path/to/project
81
39
  pi
82
40
  ```
83
41
 
84
- Or use your existing subscription:
85
-
86
- ```bash
87
- pi
88
- /login # Then select provider
89
- ```
90
-
91
- 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).
92
-
93
- **Platform notes:** [Windows](docs/windows.md) | [Termux (Android)](docs/termux.md) | [tmux](docs/tmux.md) | [Terminal setup](docs/terminal-setup.md) | [Shell aliases](docs/shell-aliases.md)
94
-
95
- ---
96
-
97
- ## Providers & Models
98
-
99
- For each built-in provider, pi maintains a list of tool-capable models. Configured provider catalogs refresh automatically; run `pi update --models` to force an immediate refresh. Authenticate via subscription (`/login`) or API key, then select any model from that provider via `/model` (or Ctrl+L). Press Ctrl+S in the model picker to save the highlighted model as the startup default.
100
-
101
- **Subscriptions:**
102
- - Anthropic Claude Pro/Max
103
- - OpenAI ChatGPT Plus/Pro (Codex)
104
- - GitHub Copilot
105
-
106
- **API keys:**
107
- - Anthropic
108
- - Ant Ling
109
- - OpenAI
110
- - Azure OpenAI
111
- - DeepSeek
112
- - NVIDIA NIM
113
- - Google Gemini
114
- - Google Vertex
115
- - Amazon Bedrock
116
- - Mistral
117
- - Groq
118
- - Cerebras
119
- - Cloudflare AI Gateway
120
- - Cloudflare Workers AI
121
- - xAI
122
- - OpenRouter
123
- - Vercel AI Gateway
124
- - ZAI Coding Plan (Global)
125
- - ZAI Coding Plan (China)
126
- - OpenCode Zen
127
- - OpenCode Go
128
- - Hugging Face
129
- - Fireworks
130
- - Together AI
131
- - Baseten
132
- - Kimi For Coding
133
- - Meta
134
- - MiniMax
135
- - Xiaomi MiMo
136
- - Xiaomi MiMo Token Plan (China)
137
- - Xiaomi MiMo Token Plan (Amsterdam)
138
- - Xiaomi MiMo Token Plan (Singapore)
139
-
140
- Pi also supports the llama.cpp router server. Configure it with `/login llama.cpp`, manage downloads and loaded models with `/llama`, then select a loaded model with `/model`. See [docs/llama-cpp.md](docs/llama-cpp.md) for setup and usage.
141
-
142
- See [docs/providers.md](docs/providers.md) for other provider setup instructions.
143
-
144
- **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).
145
-
146
- ---
147
-
148
- ## Interactive Mode
42
+ For a built-in AI provider, run `/login` inside Pi to connect a subscription or API key. Then give Pi a task.
149
43
 
150
- <p align="center"><img src="docs/images/interactive-mode.png" alt="Interactive Mode" width="600"></p>
44
+ See the [documentation](docs/index.md) for full setup and usage instructions.
151
45
 
152
- The interface from top to bottom:
46
+ ## Development
153
47
 
154
- - **Startup header** - Shows shortcuts (`/hotkeys` for all), loaded AGENTS.md files, prompt templates, skills, and extensions
155
- - **Messages** - Your messages, assistant responses, tool calls and results, notifications, errors, and extension UI
156
- - **Editor** - Where you type; border color indicates thinking level and the border shows the streaming working indicator
157
- - **Footer** - Working directory, session name, total token/cache usage (`↑` input, `↓` output, `R` cache read, `W` cache write, `CH` latest cache hit rate), cost, context usage, current model. Totals include assistant responses, usage reported by tools, and summary generation.
158
-
159
- 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.
160
-
161
- ### Editor
162
-
163
- | Feature | How |
164
- |---------|-----|
165
- | File reference | Type `@` to fuzzy-search project files |
166
- | Path completion | Tab to complete paths |
167
- | Multi-line | Shift+Enter (or Ctrl+Enter on Windows Terminal) |
168
- | External editor | Ctrl+G opens `externalEditor`, `$VISUAL`, `$EDITOR`, Notepad on Windows, or `nano` elsewhere |
169
- | Clipboard | Ctrl+V to paste an image or text (Alt+V on Windows), or drag images onto terminal |
170
- | Bash commands | `!command` runs and sends output to LLM, `!!command` runs without sending |
171
-
172
- Standard editing keybindings for delete word, undo, etc. See [docs/keybindings.md](docs/keybindings.md).
173
-
174
- ### Commands
175
-
176
- 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`.
177
-
178
- | Command | Description |
179
- |---------|-------------|
180
- | `/login`, `/logout` | Manage provider credentials |
181
- | [`/llama`](docs/llama-cpp.md) | Download, load, and unload llama.cpp router models |
182
- | `/model` | Switch models; Ctrl+S in the picker saves the startup default |
183
- | `/thinking` | Switch thinking level; Ctrl+S in the picker saves the startup default |
184
- | `/scoped-models` | Enable/disable models for Ctrl+P cycling |
185
- | `/settings` | Theme, message delivery, transport, and other preferences |
186
- | `/resume` | Pick from previous sessions |
187
- | `/new` | Start a new session |
188
- | `/name <name>` | Set session display name |
189
- | `/session` | Show session info (file, ID, messages, tokens, cost) |
190
- | `/tree` | Jump to any point in the session and continue from there |
191
- | `/trust` | Save project trust decision for future sessions (restart required) |
192
- | `/fork` | Create a new session from a previous user message |
193
- | `/clone` | Duplicate the current active branch into a new session |
194
- | `/compact [prompt]` | Manually compact context, optional custom instructions |
195
- | `/copy` | Copy last assistant message to clipboard |
196
- | `/export [file]` | Export session to HTML or JSONL file |
197
- | `/import <file>` | Import and resume a session from a JSONL file |
198
- | `/share` | Upload as private GitHub gist with shareable HTML link |
199
- | `/bug [description]` | Report a bug to the Pi developers; see [Sessions](docs/sessions.md#reporting-bugs) |
200
- | `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |
201
- | `/hotkeys` | Show all keyboard shortcuts |
202
- | `/changelog` | Display version history |
203
- | `/quit` | Quit pi |
204
-
205
- ### Keyboard Shortcuts
206
-
207
- See `/hotkeys` for the full list. Customize via `~/.pi/agent/keybindings.json`. See [docs/keybindings.md](docs/keybindings.md).
208
-
209
- **Commonly used:**
210
-
211
- | Key | Action |
212
- |-----|--------|
213
- | Ctrl+C | Clear editor |
214
- | Ctrl+C twice | Quit |
215
- | Escape | Cancel/abort |
216
- | Escape twice | Open `/tree` |
217
- | Ctrl+L | Open model selector |
218
- | Ctrl+P / Shift+Ctrl+P | Cycle scoped models forward/backward |
219
- | Shift+Tab | Cycle thinking level |
220
- | Ctrl+O | Collapse/expand tool output |
221
- | Ctrl+T | Collapse/expand thinking blocks |
222
- | Ctrl+X | Copy the last assistant message; with fullscreen copy-on-select disabled, copy the active text selection |
223
-
224
- ### Message Queue
225
-
226
- Submit messages while the agent is working:
227
-
228
- - **Enter** queues a *steering* message, delivered after the current assistant turn finishes executing its tool calls
229
- - **Alt+Enter** queues a *follow-up* message, delivered only after the agent finishes all work
230
- - **Escape** aborts and restores queued messages to editor
231
- - **Alt+Up** retrieves queued messages back to editor
232
-
233
- On Windows Terminal, `Alt+Enter` is fullscreen by default. Remap it in [docs/terminal-setup.md](docs/terminal-setup.md) so pi can receive the follow-up shortcut.
234
-
235
- Configure delivery in [settings](docs/settings.md): `steeringMode` and `followUpMode` can be `"one-at-a-time"` (default, waits for response) or `"all"` (delivers all queued at once). `transport` selects provider transport preference (`"sse"`, `"websocket"`, or `"auto"`) for providers that support multiple transports.
236
-
237
- ---
238
-
239
- ## Sessions
240
-
241
- 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. See [docs/session-format.md](docs/session-format.md) for file format.
242
-
243
- ### Management
244
-
245
- Sessions auto-save to `~/.pi/agent/sessions/` organized by working directory.
48
+ Clone the repository, install its dependencies, and run Pi from source:
246
49
 
247
50
  ```bash
248
- pi -c # Continue most recent session
249
- pi -r # Browse and select from past sessions
250
- pi --no-session # Ephemeral mode (don't save)
251
- pi --name "my task" # Set session display name at startup
252
- pi --session <path|id> # Use specific session file or ID
253
- pi --fork <path|id> # Fork specific session file or ID into a new session
254
- ```
255
-
256
- Use `/session` in interactive mode to see the current session ID before reusing it with `--session <id>` or `--fork <id>`.
257
-
258
- ### Branching
259
-
260
- **`/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. Selecting a point while the model is responding cancels that response. Navigation cannot proceed while compaction or another tree navigation is still running; wait for it to finish and retry.
261
-
262
- <p align="center"><img src="docs/images/tree-view.png" alt="Tree View" width="600"></p>
263
-
264
- - Search by typing, fold/unfold and jump between branches with Ctrl+←/Ctrl+→ or Alt+←/Alt+→, page with ←/→
265
- - Filter modes (Ctrl+O): default → no-tools → user-only → labeled-only → all
266
- - Press Ctrl+X to copy the selected message
267
- - Press Shift+L to label entries as bookmarks and Shift+T to toggle label timestamps
268
-
269
- **`/fork`** - Create a new session file from a previous user message on the active branch. Opens a selector, copies the active path up to that point, and places the selected prompt in the editor for modification.
270
-
271
- **`/clone`** - Duplicate the current active branch into a new session file at the current position. The new session keeps the full active-path history and opens with an empty editor.
272
-
273
- **`--fork <path|id>`** - Fork an existing session file or partial session UUID directly from the CLI. This copies the full source session into a new session file in the current project.
274
-
275
- ### Compaction
276
-
277
- Long sessions can exhaust context windows. Compaction summarizes older messages while keeping recent ones.
278
-
279
- **Manual:** `/compact` or `/compact <custom instructions>`
280
-
281
- **Automatic:** Enabled by default. Triggers on context overflow (recovers and retries) or when approaching the limit (proactive). Configure via `/settings` or `settings.json`.
282
-
283
- Compaction is lossy. The full history remains in the JSONL file; use `/tree` to revisit. Customize compaction behavior via [extensions](#extensions). See [docs/compaction.md](docs/compaction.md) for internals.
284
-
285
- Session model context is projected from append-only history. Extensions can append a `context_edit` to omit or replace an earlier message only for future model requests; raw history and usage remain unchanged:
286
-
287
- ```typescript
288
- const assistantId = sessionManager.appendMessage(partialAssistant);
289
- sessionManager.appendContextEdit(assistantId, null); // Hidden from model context, retained in JSONL.
51
+ git clone https://github.com/earendil-works/pi
52
+ cd pi
53
+ npm install --ignore-scripts
54
+ ./pi-test.sh
290
55
  ```
291
56
 
292
- A retain-none compaction uses `appendCompaction(summary, null, tokensBefore)` to make the exact summary the new context root while preserving prior raw entries.
293
-
294
- ---
295
-
296
- ## Settings
297
-
298
- Use `/settings` to modify common options, or edit JSON files directly:
299
-
300
- | Location | Scope |
301
- |----------|-------|
302
- | `~/.pi/agent/settings.json` | Global (all projects) |
303
- | `.pi/settings.json` | Project (overrides global) |
304
-
305
- See [docs/settings.md](docs/settings.md) for all options.
306
-
307
- ### Project Trust
308
-
309
- On interactive startup, pi asks before trusting a project folder that contains project-local settings, resources, or project `.agents/skills` and has no saved decision for the folder or a parent folder in `~/.pi/agent/trust.json`. Trusting a project allows pi to load `.pi/settings.json` and `.pi` resources, install missing project packages, and execute project extensions.
310
-
311
- Before the trust decision, pi loads only context files, user/global extensions, and CLI `-e` extensions so they can handle the `project_trust` event. Project-local extensions, project package-managed extensions, and project settings are loaded only after the project is trusted. This split also applies when switching to a session from a different cwd whose trust has not been resolved in the current process.
312
-
313
- Non-interactive modes (`-p`, `--mode json`, and `--mode rpc`) do not show a trust prompt. Without an applicable saved trust decision, they use `defaultProjectTrust` from global settings: `ask` (default) and `never` ignore those project resources, while `always` trusts them. Pass `--approve`/`-a` or `--no-approve`/`-na` to override project trust for one run.
314
-
315
- If no extension or saved decision applies, `defaultProjectTrust` controls the fallback behavior. Set it to `"ask"`, `"always"`, or `"never"` in `~/.pi/agent/settings.json`, or change it with `/settings`.
316
-
317
- `pi config` and package commands use the same project trust flow, except `pi update` never prompts. Pass `--approve` to trust project-local settings for one command or `--no-approve` to ignore them.
318
-
319
- Use `/trust` in interactive mode to save a project trust decision for future sessions, including trust for the immediate parent folder. It writes `~/.pi/agent/trust.json` only; the current session is not reloaded, so restart pi for changes to take effect.
320
-
321
- ### Telemetry and update checks
322
-
323
- Pi has two separate startup features:
324
-
325
- - **Update check:** fetches `https://pi.dev/api/latest-version` to check whether a newer Pi version exists. Disable it with `PI_SKIP_VERSION_CHECK=1`. Disabling update checks only turns off this check.
326
- - **Install/update telemetry:** after first install or a changelog-detected update, sends an anonymous version ping to `https://pi.dev/api/report-install`. This setting also controls optional provider attribution headers for OpenRouter, Cloudflare, and direct NVIDIA NIM requests. Opt out by setting `enableInstallTelemetry` to `false` in `settings.json`, or by setting `PI_TELEMETRY=0`. This does not disable update checks; Pi may still contact `pi.dev` for the latest version unless update checks are disabled or offline mode is enabled.
327
-
328
- Use `--offline` or `PI_OFFLINE=1` to disable all startup network operations described here, including update checks, package update checks, and install/update telemetry.
329
-
330
- ---
331
-
332
- ## Context Files
333
-
334
- Pi loads `AGENTS.md` (or `CLAUDE.md`) at startup from:
335
- - `~/.pi/agent/AGENTS.md` (global)
336
- - Parent directories (walking up from cwd)
337
- - Current directory
338
-
339
- If a directory contains `AGENTS.override.md`, Pi loads it instead of `AGENTS.md` or `CLAUDE.md` from that directory. Context files from other directories are still concatenated.
340
-
341
- Use for project instructions (`AGENTS.md`/`CLAUDE.md`), conventions, common commands. All matching files are concatenated.
342
-
343
- Disable context file loading with `--no-context-files` (or `-nc`).
344
-
345
- ### System Prompt
346
-
347
- Replace the default system prompt with `.pi/SYSTEM.md` (project) or `~/.pi/agent/SYSTEM.md` (global). Append without replacing via `APPEND_SYSTEM.md`.
348
-
349
- ---
350
-
351
- ## Customization
352
-
353
- ### Prompt Templates
354
-
355
- Reusable prompts as Markdown files. Type `/name` to expand.
356
-
357
- ```markdown
358
- <!-- ~/.pi/agent/prompts/review.md -->
359
- Review this code for bugs, security issues, and performance problems.
360
- Focus on: {{focus}}
361
- ```
362
-
363
- Place in `~/.pi/agent/prompts/`, `.pi/prompts/`, or a [pi package](#pi-packages) to share with others. See [docs/prompt-templates.md](docs/prompt-templates.md).
364
-
365
- ### Skills
366
-
367
- On-demand capability packages following the [Agent Skills standard](https://agentskills.io). Invoke via `/skill:name` or let the agent load them automatically.
368
-
369
- ```markdown
370
- <!-- ~/.pi/agent/skills/my-skill/SKILL.md -->
371
- # My Skill
372
- Use this skill when the user asks about X.
373
-
374
- ## Steps
375
- 1. Do this
376
- 2. Then that
377
- ```
378
-
379
- Place in `~/.pi/agent/skills/`, `~/.agents/skills/`, `.pi/skills/`, or `.agents/skills/` (from `cwd` up through parent directories) or a [pi package](#pi-packages) to share with others. See [docs/skills.md](docs/skills.md).
380
-
381
- ### Extensions
382
-
383
- <p align="center"><img src="docs/images/doom-extension.png" alt="Doom Extension" width="600"></p>
384
-
385
- TypeScript modules that extend pi with custom tools, commands, keyboard shortcuts, event handlers, and UI components.
386
-
387
- ```typescript
388
- export default function (pi: ExtensionAPI) {
389
- pi.registerTool({ name: "deploy", ... });
390
- pi.registerCommand("stats", { ... });
391
- pi.on("tool_call", async (event, ctx) => { ... });
392
- }
393
- ```
57
+ `pi-test.sh` can be called from any directory and preserves the caller's working directory.
394
58
 
395
- `turn_end` and `agent_before_settle` are actionable persistence boundaries. Handlers can append structural entries and request one continuation. Later handlers see earlier proposals:
396
-
397
- ```typescript
398
- let replacedResponse = false;
399
- pi.on("turn_end", (event) => {
400
- if (replacedResponse || event.outcome !== "completed" || event.toolResults.length > 0) return;
401
- replacedResponse = true;
402
- return {
403
- entries: [
404
- ...event.entries,
405
- { type: "context_edit", targetId: event.messageEntryId, replacement: null },
406
- {
407
- type: "custom_message",
408
- customType: "replacement-instruction",
409
- content: "Answer again using the persisted user request.",
410
- display: false,
411
- },
412
- ],
413
- continue: true,
414
- };
415
- });
416
- ```
417
-
418
- Continuation is one-shot per boundary result, not per registered handler. It ensures one next provider request: tool-result, steering, or follow-up scheduling can satisfy that request without adding another one; otherwise Pi makes one context-only request. Guard handlers like the example above because an unconditional `continue: true` is evaluated again after the next response and can loop indefinitely. Error and aborted responses remain hard exits.
419
-
420
- Use `agent_before_settle` for final actions after retries, compaction, and queued input are exhausted. See [docs/extensions.md](docs/extensions.md#agent_start--agent_end--agent_before_settle--agent_settled).
421
-
422
- The default export can also be `async`. pi waits for async extension factories before startup continues, which is useful for one-time initialization such as fetching remote model lists before calling `pi.registerProvider()`.
423
-
424
- **What's possible:**
425
- - Custom tools (or replace built-in tools entirely)
426
- - Sub-agents and plan mode
427
- - Custom compaction and summarization
428
- - Permission gates and path protection
429
- - Custom editors and UI components
430
- - Status lines, headers, footers
431
- - Git checkpointing and auto-commit
432
- - SSH and sandbox execution
433
- - MCP server integration
434
- - Make pi look like Claude Code
435
- - Games while waiting (yes, Doom runs)
436
- - ...anything you can dream up
437
-
438
- Place in `~/.pi/agent/extensions/`, `.pi/extensions/`, or a [pi package](#pi-packages) to share with others. See [docs/extensions.md](docs/extensions.md) and [examples/extensions/](examples/extensions/).
439
-
440
- ### Themes
441
-
442
- Built-in: `dark`, `light`. Themes hot-reload: modify the active theme file and pi immediately applies changes.
443
-
444
- Place in `~/.pi/agent/themes/`, `.pi/themes/`, or a [pi package](#pi-packages) to share with others. See [docs/themes.md](docs/themes.md).
445
-
446
- ### Pi Packages
447
-
448
- Bundle and share extensions, skills, prompts, and themes via npm or git. Find packages on [npmjs.com](https://www.npmjs.com/search?q=keywords%3Api-package) or [Discord](https://discord.com/channels/1456806362351669492/1457744485428629628).
449
-
450
- > **Security:** Pi packages run with full system access. Extensions execute arbitrary code, and skills can instruct the model to perform any action including running executables. Review source code before installing third-party packages.
59
+ Before submitting changes, run:
451
60
 
452
61
  ```bash
453
- pi install npm:@foo/pi-tools
454
- pi install npm:@foo/pi-tools@1.2.3 # pinned version
455
- pi install git:github.com/user/repo
456
- pi install git:github.com/user/repo@v1 # tag or commit
457
- pi install git:git@github.com:user/repo
458
- pi install git:git@github.com:user/repo@v1 # tag or commit
459
- pi install https://github.com/user/repo
460
- pi install https://github.com/user/repo@v1 # tag or commit
461
- pi install ssh://git@github.com/user/repo
462
- pi install ssh://git@github.com/user/repo@v1 # tag or commit
463
- pi remove npm:@foo/pi-tools
464
- pi uninstall npm:@foo/pi-tools # alias for remove
465
- pi list
466
- pi update # update pi only
467
- pi update --all # update pi and packages
468
- pi update --extensions # update packages only
469
- pi update --models # refresh model catalogs only
470
- pi update --self # update pi only
471
- pi update --self --force # reinstall pi even if current
472
- pi update npm:@foo/pi-tools # update one package
473
- pi config # enable/disable extensions, skills, prompts, themes
62
+ npm run check
63
+ ./test.sh
474
64
  ```
475
65
 
476
- Packages install to `~/.pi/agent/git/` (git) or `~/.pi/agent/npm/` (npm). Use `-l` for project-local installs (`.pi/git/`, `.pi/npm/`). Git `@ref` values are pinned tags or commits; pinned packages are skipped by `pi update --extensions` and `pi update --all`, so use `pi install git:host/user/repo@new-ref` to move an existing package to a new ref. Git packages install dependencies with `npm install --omit=dev` by default, so runtime deps must be listed under `dependencies`; when `npmCommand` is configured, git packages use plain `install` for compatibility with wrappers. If you use a Node version manager and want package installs to reuse a stable npm context, set `npmCommand` in `settings.json`, for example `["mise", "exec", "node@20", "--", "npm"]`.
477
-
478
- Create a package by adding a `pi` key to `package.json`:
479
-
480
- ```json
481
- {
482
- "name": "my-pi-package",
483
- "keywords": ["pi-package"],
484
- "pi": {
485
- "extensions": ["./extensions"],
486
- "skills": ["./skills"],
487
- "prompts": ["./prompts"],
488
- "themes": ["./themes"]
489
- }
490
- }
491
- ```
492
-
493
- Without a `pi` manifest, pi auto-discovers from conventional directories (`extensions/`, `skills/`, `prompts/`, `themes/`).
494
-
495
- See [docs/packages.md](docs/packages.md).
496
-
497
- ---
498
-
499
- ## Programmatic Usage
500
-
501
- ### SDK
502
-
503
- ```typescript
504
- import { createAgentSession, ModelRuntime, SessionManager } from "@earendil-works/pi-coding-agent";
505
-
506
- const modelRuntime = await ModelRuntime.create();
507
- const { session } = await createAgentSession({
508
- sessionManager: SessionManager.inMemory(),
509
- modelRuntime,
510
- });
511
-
512
- await session.prompt("What files are in the current directory?");
513
- ```
514
-
515
- For advanced multi-session runtime replacement, use `createAgentSessionRuntime()` and `AgentSessionRuntime`.
516
-
517
- See [docs/sdk.md](docs/sdk.md) and [examples/sdk/](examples/sdk/).
518
-
519
- ### RPC Mode
520
-
521
- For non-Node.js integrations, use RPC mode over stdin/stdout:
522
-
523
- ```bash
524
- pi --mode rpc
525
- ```
526
-
527
- RPC mode uses strict LF-delimited JSONL framing. Clients must split records on `\n` only. Do not use generic line readers like Node `readline`, which also split on Unicode separators inside JSON payloads.
528
-
529
- See [docs/rpc.md](docs/rpc.md) for the protocol.
530
-
531
- ---
532
-
533
- ## Philosophy
534
-
535
- Pi is aggressively extensible so it doesn't have to dictate your workflow. Features that other tools bake in can be built with [extensions](#extensions), [skills](#skills), or installed from third-party [pi packages](#pi-packages). This keeps the core minimal while letting you shape pi to fit how you work.
536
-
537
- **No MCP.** Build CLI tools with READMEs (see [Skills](#skills)), or build an extension that adds MCP support. [Why?](https://mariozechner.at/posts/2025-11-02-what-if-you-dont-need-mcp/)
538
-
539
- **No sub-agents.** There's many ways to do this. Spawn pi instances via tmux, or build your own with [extensions](#extensions), or install a package that does it your way.
540
-
541
- **No permission popups.** Run in a container, or build your own confirmation flow with [extensions](#extensions) inline with your environment and security requirements.
542
-
543
- **No plan mode.** Write plans to files, or build it with [extensions](#extensions), or install a package.
544
-
545
- **No built-in to-dos.** They confuse models. Use a TODO.md file, or build your own with [extensions](#extensions).
546
-
547
- **No background bash.** Use tmux. Full observability, direct interaction.
548
-
549
- Read the [blog post](https://mariozechner.at/posts/2025-11-30-pi-coding-agent/) for the full rationale.
550
-
551
- ---
552
-
553
- ## CLI Reference
554
-
555
- ```bash
556
- pi [options] [--] [@files...] [messages...]
557
- ```
558
-
559
- ### Package Commands
560
-
561
- ```bash
562
- pi install <source> [-l] # Install package, -l for project-local
563
- pi remove <source> [-l] # Remove package
564
- pi uninstall <source> [-l] # Alias for remove
565
- pi update [source|self|pi] # Update pi only, or one package source
566
- pi update --all # Update pi and packages
567
- pi update --extensions # Update packages only
568
- pi update --models # Refresh model catalogs only
569
- pi update --self # Update pi only
570
- pi update --self --force # Reinstall pi even if current
571
- pi update --extension <src> # Update one package
572
- pi list # List installed packages
573
- pi config # Enable/disable package resources
574
- ```
575
-
576
- `pi config` and project package commands accept `--approve`/`--no-approve` to trust or ignore project-local settings for one command. `pi update` never prompts for project trust.
577
-
578
- ### Modes
579
-
580
- | Flag | Description |
581
- |------|-------------|
582
- | (default) | Interactive mode |
583
- | `-p`, `--print` | Print response and exit |
584
- | `--mode json` | Output all events as JSON lines (see [docs/json.md](docs/json.md)) |
585
- | `--mode rpc` | RPC mode for process integration (see [docs/rpc.md](docs/rpc.md)) |
586
- | `--export <in> [out]` | Export session to HTML |
587
-
588
- In print mode, pi also reads piped stdin and merges it into the initial prompt:
589
-
590
- ```bash
591
- cat README.md | pi -p "Summarize this text"
592
- ```
593
-
594
- ### Model Options
595
-
596
- | Option | Description |
597
- |--------|-------------|
598
- | `--provider <name>` | Provider (anthropic, openai, google, etc.) |
599
- | `--model <pattern>` | Model pattern or ID (supports `provider/id` and optional `:<thinking>`) |
600
- | `--api-key <key>` | API key (overrides env vars) |
601
- | `--thinking <level>` | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` |
602
- | `--models <patterns>` | Comma-separated patterns for Ctrl+P cycling |
603
- | `--list-models [search]` | List available models |
604
-
605
- ### Session Options
606
-
607
- | Option | Description |
608
- |--------|-------------|
609
- | `-c`, `--continue` | Continue most recent session |
610
- | `-r`, `--resume` | Browse and select session |
611
- | `--session <path\|id>` | Use specific session file or partial UUID |
612
- | `--fork <path\|id>` | Fork specific session file or partial UUID into a new session |
613
- | `--session-dir <dir>` | Custom session storage directory |
614
- | `--no-session` | Ephemeral mode (don't save) |
615
- | `--name <name>`, `-n <name>` | Set session display name at startup |
616
-
617
- ### Tool Options
618
-
619
- | Option | Description |
620
- |--------|-------------|
621
- | `--tools <list>`, `-t <list>` | Allowlist specific tool names across built-in, extension, and custom tools |
622
- | `--exclude-tools <list>`, `-xt <list>` | Disable specific tool names across built-in, extension, and custom tools |
623
- | `--no-builtin-tools`, `-nbt` | Disable built-in tools by default but keep extension/custom tools enabled |
624
- | `--no-tools`, `-nt` | Disable all tools by default |
625
-
626
- Available built-in tools: `read`, `bash`, `powershell` (Windows), `edit`, `write`, `grep`, `find`, `ls`
627
-
628
- ### Resource Options
629
-
630
- | Option | Description |
631
- |--------|-------------|
632
- | `-e`, `--extension <source>` | Load extension from path, npm, or git (repeatable) |
633
- | `--no-extensions` | Disable extension discovery |
634
- | `--skill <path>` | Load skill (repeatable) |
635
- | `--no-skills` | Disable skill discovery |
636
- | `--prompt-template <path>` | Load prompt template (repeatable) |
637
- | `--no-prompt-templates` | Disable prompt template discovery |
638
- | `--theme <path>` | Load theme (repeatable) |
639
- | `--no-themes` | Disable theme discovery |
640
- | `--no-context-files`, `-nc` | Disable AGENTS.md and CLAUDE.md context file discovery |
641
-
642
- Combine `--no-*` with explicit flags to load exactly what you need, ignoring settings.json (e.g., `--no-extensions -e ./my-ext.ts`).
643
-
644
- ### Other Options
645
-
646
- | Option | Description |
647
- |--------|-------------|
648
- | `--system-prompt <text>` | Replace default prompt (context files and skills still appended) |
649
- | `--append-system-prompt <text>` | Append to system prompt |
650
- | `--tui-mode <mode>` | TUI mode: `regular` (default) or experimental `fullscreen` |
651
- | `--use-theme <name[/name]>` | Set the initial interactive theme for this run without changing settings |
652
- | `--verbose` | Force verbose startup |
653
- | `-a`, `--approve` | Trust project-local files for this run |
654
- | `-na`, `--no-approve` | Ignore project-local files for this run |
655
- | `--` | Stop option parsing; remaining arguments are prompts or `@file` inputs |
656
- | `-h`, `--help` | Show help |
657
- | `-v`, `--version` | Show version |
658
-
659
- ### File Arguments
660
-
661
- Prefix files with `@` to include in the message:
662
-
663
- ```bash
664
- pi @prompt.md "Answer this"
665
- pi -p @screenshot.png "What's in this image?"
666
- pi @code.ts @test.ts "Review these files"
667
- ```
668
-
669
- ### Examples
670
-
671
- ```bash
672
- # Interactive with initial prompt
673
- pi "List all .ts files in src/"
674
-
675
- # Non-interactive
676
- pi -p "Summarize this codebase"
677
-
678
- # Prompt beginning with a dash
679
- pi -p -- "- Summarize these points"
680
-
681
- # Non-interactive with piped stdin
682
- cat README.md | pi -p "Summarize this text"
683
-
684
- # Named one-shot session
685
- pi --name "release audit" -p "Audit this repository"
686
-
687
- # Different model
688
- pi --provider openai --model gpt-4o "Help me refactor"
689
-
690
- # Model with provider prefix (no --provider needed)
691
- pi --model openai/gpt-4o "Help me refactor"
692
-
693
- # Model with thinking level shorthand
694
- pi --model sonnet:high "Solve this complex problem"
695
-
696
- # Limit model cycling
697
- pi --models "claude-*,gpt-4o"
698
-
699
- # Read-only mode
700
- pi --tools read,grep,find,ls -p "Review the code"
701
-
702
- # Disable one extension or built-in tool while keeping the rest available
703
- pi --exclude-tools ask_question
704
-
705
- # High thinking level
706
- pi --thinking high "Solve this complex problem"
707
- ```
708
-
709
- ### Environment Variables
710
-
711
- | Variable | Description |
712
- |----------|-------------|
713
- | `AI_AGENT` | Set to `pi` by the CLI and RPC entry points so generic tooling can attribute child processes to Pi |
714
- | `PI_CODING_AGENT` | Set to `true` by the CLI and RPC entry points so child processes can detect that they run inside Pi |
715
- | `PI_CODING_AGENT_DIR` | Override config directory (default: `~/.pi/agent`) |
716
- | `PI_CODING_AGENT_SESSION_DIR` | Override session storage directory (overridden by `--session-dir`) |
717
- | `PI_PACKAGE_DIR` | Override package directory (useful for Nix/Guix where store paths tokenize poorly) |
718
- | `PI_OFFLINE` | Disable startup network operations, including update checks, package update checks, and install/update telemetry |
719
- | `PI_SKIP_VERSION_CHECK` | Skip the Pi version update check at startup. This prevents the `pi.dev` latest-version request |
720
- | `PI_TELEMETRY` | Override install/update telemetry and provider attribution headers. Use `1`/`true`/`yes` to enable or `0`/`false`/`no` to disable. This does not disable update checks |
721
- | `PI_CACHE_RETENTION` | Set to `long` for extended prompt cache (Anthropic: 1h, OpenAI: 24h) |
722
- | `VISUAL`, `EDITOR` | Fallback external editor for Ctrl+G when `externalEditor` is unset; defaults to Notepad on Windows and `nano` elsewhere |
723
-
724
- Commands run by the LLM-callable `bash` and `powershell` tools also receive current session metadata:
725
-
726
- | Variable | Description |
727
- |----------|-------------|
728
- | `PI_SESSION_ID` | Current session ID |
729
- | `PI_SESSION_FILE` | Absolute session JSONL path; unset for ephemeral sessions |
730
- | `PI_PROVIDER` | Currently selected model provider |
731
- | `PI_MODEL` | Currently selected model ID |
732
- | `PI_REASONING_LEVEL` | Current effective reasoning level |
733
-
734
- These values are resolved when each command starts. See [Environment Variables](docs/environment-variables.md#shell-tool-session-environment) for semantics, examples, and custom-tool opt-out.
735
-
736
- ---
737
-
738
- ## Contributing & Development
739
-
740
- See [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines and [docs/development.md](docs/development.md) for setup, forking, and debugging.
66
+ Read [CONTRIBUTING.md](https://github.com/earendil-works/pi/blob/main/CONTRIBUTING.md) before opening an issue or pull request. It defines the contribution gate, issue quality bar, and required checks. Read [AGENTS.md](https://github.com/earendil-works/pi/blob/main/AGENTS.md) for repository-specific implementation, testing, dependency, and release rules.
741
67
 
742
68
  ## License
743
69
 
744
70
  MIT
745
-
746
- ## See Also
747
-
748
- - [@earendil-works/pi-ai](https://www.npmjs.com/package/@earendil-works/pi-ai): Core LLM toolkit
749
- - [@earendil-works/pi-agent-core](https://www.npmjs.com/package/@earendil-works/pi-agent-core): Agent framework
750
- - [@earendil-works/pi-tui](https://www.npmjs.com/package/@earendil-works/pi-tui): Terminal UI components
751
-
752
- <p align="center">
753
- <a href="https://pi.dev">pi.dev</a> domain graciously donated by
754
- <br /><br />
755
- <a href="https://exe.dev"><img src="docs/images/exy.png" alt="Exy mascot" width="48" /><br />exe.dev</a>
756
- </p>