@astralyn/pi 0.81.1-1 → 0.82.0

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 (185) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +690 -677
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +1 -0
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/cli/config-selector.d.ts.map +1 -1
  7. package/dist/cli/config-selector.js +1 -1
  8. package/dist/cli/config-selector.js.map +1 -1
  9. package/dist/cli/startup-ui.d.ts.map +1 -1
  10. package/dist/cli/startup-ui.js +1 -1
  11. package/dist/cli/startup-ui.js.map +1 -1
  12. package/dist/cli.js +0 -0
  13. package/dist/core/agent-session.d.ts +11 -0
  14. package/dist/core/agent-session.d.ts.map +1 -1
  15. package/dist/core/agent-session.js +7 -8
  16. package/dist/core/agent-session.js.map +1 -1
  17. package/dist/core/compaction/compaction.d.ts.map +1 -1
  18. package/dist/core/compaction/compaction.js +11 -3
  19. package/dist/core/compaction/compaction.js.map +1 -1
  20. package/dist/core/extensions/runner.d.ts.map +1 -1
  21. package/dist/core/extensions/runner.js +4 -0
  22. package/dist/core/extensions/runner.js.map +1 -1
  23. package/dist/core/extensions/types.d.ts +9 -1
  24. package/dist/core/extensions/types.d.ts.map +1 -1
  25. package/dist/core/extensions/types.js.map +1 -1
  26. package/dist/core/model-config.d.ts +30 -0
  27. package/dist/core/model-config.d.ts.map +1 -1
  28. package/dist/core/model-config.js +6 -0
  29. package/dist/core/model-config.js.map +1 -1
  30. package/dist/core/model-registry.d.ts.map +1 -1
  31. package/dist/core/model-registry.js +2 -2
  32. package/dist/core/model-registry.js.map +1 -1
  33. package/dist/core/model-resolver.d.ts.map +1 -1
  34. package/dist/core/model-resolver.js +7 -0
  35. package/dist/core/model-resolver.js.map +1 -1
  36. package/dist/core/model-runtime.d.ts +0 -1
  37. package/dist/core/model-runtime.d.ts.map +1 -1
  38. package/dist/core/model-runtime.js +3 -5
  39. package/dist/core/model-runtime.js.map +1 -1
  40. package/dist/core/remote-catalog-provider.d.ts +1 -1
  41. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  42. package/dist/core/remote-catalog-provider.js +5 -10
  43. package/dist/core/remote-catalog-provider.js.map +1 -1
  44. package/dist/core/settings-manager.d.ts +1 -1
  45. package/dist/core/settings-manager.d.ts.map +1 -1
  46. package/dist/core/settings-manager.js.map +1 -1
  47. package/dist/core/system-prompt.d.ts.map +1 -1
  48. package/dist/core/system-prompt.js +1 -1
  49. package/dist/core/system-prompt.js.map +1 -1
  50. package/dist/core/tools/bash.d.ts +2 -1
  51. package/dist/core/tools/bash.d.ts.map +1 -1
  52. package/dist/core/tools/bash.js +114 -24
  53. package/dist/core/tools/bash.js.map +1 -1
  54. package/dist/core/tools/find.d.ts.map +1 -1
  55. package/dist/core/tools/find.js +1 -0
  56. package/dist/core/tools/find.js.map +1 -1
  57. package/dist/core/tools/read.d.ts.map +1 -1
  58. package/dist/core/tools/read.js +4 -3
  59. package/dist/core/tools/read.js.map +1 -1
  60. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  61. package/dist/core/tools/tool-definition-wrapper.js +5 -1
  62. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  63. package/dist/extensions/index.d.ts.map +1 -1
  64. package/dist/extensions/index.js +2 -0
  65. package/dist/extensions/index.js.map +1 -1
  66. package/dist/extensions/llama/provider.d.ts.map +1 -1
  67. package/dist/extensions/llama/provider.js +1 -2
  68. package/dist/extensions/llama/provider.js.map +1 -1
  69. package/dist/extensions/subagent/activity.d.ts +16 -0
  70. package/dist/extensions/subagent/activity.d.ts.map +1 -0
  71. package/dist/extensions/subagent/activity.js +150 -0
  72. package/dist/extensions/subagent/activity.js.map +1 -0
  73. package/dist/extensions/subagent/agents.d.ts +7 -0
  74. package/dist/extensions/subagent/agents.d.ts.map +1 -0
  75. package/dist/extensions/subagent/agents.js +218 -0
  76. package/dist/extensions/subagent/agents.js.map +1 -0
  77. package/dist/extensions/subagent/constants.d.ts +22 -0
  78. package/dist/extensions/subagent/constants.d.ts.map +1 -0
  79. package/dist/extensions/subagent/constants.js +32 -0
  80. package/dist/extensions/subagent/constants.js.map +1 -0
  81. package/dist/extensions/subagent/index.d.ts +3 -0
  82. package/dist/extensions/subagent/index.d.ts.map +1 -0
  83. package/dist/extensions/subagent/index.js +249 -0
  84. package/dist/extensions/subagent/index.js.map +1 -0
  85. package/dist/extensions/subagent/picker.d.ts +31 -0
  86. package/dist/extensions/subagent/picker.d.ts.map +1 -0
  87. package/dist/extensions/subagent/picker.js +116 -0
  88. package/dist/extensions/subagent/picker.js.map +1 -0
  89. package/dist/extensions/subagent/render.d.ts +8 -0
  90. package/dist/extensions/subagent/render.d.ts.map +1 -0
  91. package/dist/extensions/subagent/render.js +322 -0
  92. package/dist/extensions/subagent/render.js.map +1 -0
  93. package/dist/extensions/subagent/resolve.d.ts +16 -0
  94. package/dist/extensions/subagent/resolve.d.ts.map +1 -0
  95. package/dist/extensions/subagent/resolve.js +103 -0
  96. package/dist/extensions/subagent/resolve.js.map +1 -0
  97. package/dist/extensions/subagent/runner.d.ts +30 -0
  98. package/dist/extensions/subagent/runner.d.ts.map +1 -0
  99. package/dist/extensions/subagent/runner.js +355 -0
  100. package/dist/extensions/subagent/runner.js.map +1 -0
  101. package/dist/extensions/subagent/schema.d.ts +28 -0
  102. package/dist/extensions/subagent/schema.d.ts.map +1 -0
  103. package/dist/extensions/subagent/schema.js +33 -0
  104. package/dist/extensions/subagent/schema.js.map +1 -0
  105. package/dist/extensions/subagent/sdk-runner.d.ts +14 -0
  106. package/dist/extensions/subagent/sdk-runner.d.ts.map +1 -0
  107. package/dist/extensions/subagent/sdk-runner.js +210 -0
  108. package/dist/extensions/subagent/sdk-runner.js.map +1 -0
  109. package/dist/extensions/subagent/settings.d.ts +9 -0
  110. package/dist/extensions/subagent/settings.d.ts.map +1 -0
  111. package/dist/extensions/subagent/settings.js +131 -0
  112. package/dist/extensions/subagent/settings.js.map +1 -0
  113. package/dist/extensions/subagent/types.d.ts +99 -0
  114. package/dist/extensions/subagent/types.d.ts.map +1 -0
  115. package/dist/extensions/subagent/types.js +2 -0
  116. package/dist/extensions/subagent/types.js.map +1 -0
  117. package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
  118. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  119. package/dist/modes/interactive/components/extension-editor.js +16 -46
  120. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  121. package/dist/modes/interactive/components/index.d.ts +1 -0
  122. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  123. package/dist/modes/interactive/components/index.js +1 -0
  124. package/dist/modes/interactive/components/index.js.map +1 -1
  125. package/dist/modes/interactive/components/tool-execution.d.ts +2 -0
  126. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  127. package/dist/modes/interactive/components/tool-execution.js +25 -4
  128. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  129. package/dist/modes/interactive/components/tool-group.d.ts +16 -0
  130. package/dist/modes/interactive/components/tool-group.d.ts.map +1 -0
  131. package/dist/modes/interactive/components/tool-group.js +64 -0
  132. package/dist/modes/interactive/components/tool-group.js.map +1 -0
  133. package/dist/modes/interactive/external-editor.d.ts +12 -0
  134. package/dist/modes/interactive/external-editor.d.ts.map +1 -0
  135. package/dist/modes/interactive/external-editor.js +37 -0
  136. package/dist/modes/interactive/external-editor.js.map +1 -0
  137. package/dist/modes/interactive/interactive-mode.d.ts +3 -1
  138. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  139. package/dist/modes/interactive/interactive-mode.js +61 -62
  140. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  141. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  142. package/dist/modes/rpc/rpc-mode.js +1 -0
  143. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  144. package/dist/rpc-entry.js +0 -0
  145. package/dist/utils/clipboard.d.ts.map +1 -1
  146. package/dist/utils/clipboard.js +19 -8
  147. package/dist/utils/clipboard.js.map +1 -1
  148. package/dist/utils/version-check.d.ts.map +1 -1
  149. package/dist/utils/version-check.js +3 -1
  150. package/dist/utils/version-check.js.map +1 -1
  151. package/docs/compaction.md +401 -401
  152. package/docs/containerization.md +111 -111
  153. package/docs/custom-provider.md +766 -763
  154. package/docs/environment-variables.md +88 -0
  155. package/docs/extensions.md +2961 -2953
  156. package/docs/index.md +80 -77
  157. package/docs/models.md +6 -2
  158. package/docs/packages.md +228 -228
  159. package/docs/providers.md +8 -1
  160. package/docs/quickstart.md +165 -165
  161. package/docs/rpc.md +1576 -1559
  162. package/docs/sdk.md +1186 -1186
  163. package/docs/session-format.md +436 -436
  164. package/docs/settings.md +1 -1
  165. package/docs/termux.md +127 -127
  166. package/docs/tui.md +942 -942
  167. package/docs/usage.md +0 -13
  168. package/examples/extensions/README.md +213 -213
  169. package/examples/extensions/custom-compaction.ts +3 -0
  170. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  171. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  172. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  173. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  174. package/examples/extensions/doom-overlay/doom/build.sh +0 -0
  175. package/examples/extensions/gondolin/package-lock.json +2 -2
  176. package/examples/extensions/gondolin/package.json +1 -1
  177. package/examples/extensions/handoff.ts +9 -1
  178. package/examples/extensions/sandbox/package-lock.json +2 -2
  179. package/examples/extensions/sandbox/package.json +1 -1
  180. package/examples/extensions/summarize.ts +3 -0
  181. package/examples/extensions/with-deps/package-lock.json +2 -2
  182. package/examples/extensions/with-deps/package.json +1 -1
  183. package/examples/sdk/README.md +140 -140
  184. package/npm-shrinkwrap.json +16 -15
  185. package/package.json +10 -4
package/README.md CHANGED
@@ -1,677 +1,690 @@
1
- # Pi coding agent
2
-
3
- > This package is the `@astralyn/pi` distribution maintained in this repository. It is based on [earendil-works/pi](https://github.com/earendil-works/pi) but is not an upstream release. Fork-specific architecture and bundled feature documentation live in the repository root `docs/` directory.
4
-
5
- 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.
6
-
7
- 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.
8
-
9
- Pi runs in four modes: interactive, print or JSON, RPC for process integration, and an SDK for embedding in your own apps. See [openclaw/openclaw](https://github.com/openclaw/openclaw) for a real-world SDK integration.
10
-
11
- ## Share your OSS coding agent sessions
12
-
13
- If you use pi for open source work, please share your coding agent sessions.
14
-
15
- Public OSS session data helps improve models, prompts, tools, and evaluations using real development workflows.
16
-
17
- For the full explanation, see [this post on X](https://x.com/badlogicgames/status/2037811643774652911).
18
-
19
- 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`.
20
-
21
- You can also watch [this video](https://x.com/badlogicgames/status/2041151967695634619), where I show how I publish my `pi-mono` sessions.
22
-
23
- I regularly publish my own `pi-mono` work sessions here:
24
-
25
- - [badlogicgames/pi-mono on Hugging Face](https://huggingface.co/datasets/badlogicgames/pi-mono)
26
-
27
- ## Table of Contents
28
-
29
- - [Quick Start](#quick-start)
30
- - [Providers & Models](#providers--models)
31
- - [Interactive Mode](#interactive-mode)
32
- - [Editor](#editor)
33
- - [Commands](#commands)
34
- - [Keyboard Shortcuts](#keyboard-shortcuts)
35
- - [Message Queue](#message-queue)
36
- - [Sessions](#sessions)
37
- - [Branching](#branching)
38
- - [Compaction](#compaction)
39
- - [Settings](#settings)
40
- - [Context Files](#context-files)
41
- - [Customization](#customization)
42
- - [Prompt Templates](#prompt-templates)
43
- - [Skills](#skills)
44
- - [Extensions](#extensions)
45
- - [Themes](#themes)
46
- - [Pi Packages](#pi-packages)
47
- - [Programmatic Usage](#programmatic-usage)
48
- - [Philosophy](#philosophy)
49
- - [CLI Reference](#cli-reference)
50
-
51
- ---
52
-
53
- ## Quick Start
54
-
55
- ```bash
56
- npm install -g --ignore-scripts @astralyn/pi
57
- ```
58
-
59
- `--ignore-scripts` disables dependency lifecycle scripts during install. Pi does not require install scripts for normal npm installs.
60
-
61
- Authenticate with an API key:
62
-
63
- ```bash
64
- export ANTHROPIC_API_KEY=sk-ant-...
65
- pi
66
- ```
67
-
68
- Or use your existing subscription:
69
-
70
- ```bash
71
- pi
72
- /login # Then select provider
73
- ```
74
-
75
- 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).
76
-
77
- **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)
78
-
79
- ---
80
-
81
- ## Providers & Models
82
-
83
- 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).
84
-
85
- **Subscriptions:**
86
- - Anthropic Claude Pro/Max
87
- - OpenAI ChatGPT Plus/Pro (Codex)
88
- - GitHub Copilot
89
-
90
- **API keys:**
91
- - Anthropic
92
- - Ant Ling
93
- - OpenAI
94
- - Azure OpenAI
95
- - DeepSeek
96
- - NVIDIA NIM
97
- - Google Gemini
98
- - Google Vertex
99
- - Amazon Bedrock
100
- - Mistral
101
- - Groq
102
- - Cerebras
103
- - Cloudflare AI Gateway
104
- - Cloudflare Workers AI
105
- - xAI
106
- - OpenRouter
107
- - Vercel AI Gateway
108
- - ZAI Coding Plan (Global)
109
- - ZAI Coding Plan (China)
110
- - OpenCode Zen
111
- - OpenCode Go
112
- - Hugging Face
113
- - Fireworks
114
- - Together AI
115
- - Kimi For Coding
116
- - MiniMax
117
- - Xiaomi MiMo
118
- - Xiaomi MiMo Token Plan (China)
119
- - Xiaomi MiMo Token Plan (Amsterdam)
120
- - Xiaomi MiMo Token Plan (Singapore)
121
-
122
- 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.
123
-
124
- See [docs/providers.md](docs/providers.md) for other provider setup instructions.
125
-
126
- **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).
127
-
128
- ---
129
-
130
- ## Interactive Mode
131
-
132
- <p align="center"><img src="docs/images/interactive-mode.png" alt="Interactive Mode" width="600"></p>
133
-
134
- The interface from top to bottom:
135
-
136
- - **Startup header** - Shows shortcuts (`/hotkeys` for all), loaded AGENTS.md files, prompt templates, skills, and extensions
137
- - **Messages** - Your messages, assistant responses, tool calls and results, notifications, errors, and extension UI
138
- - **Editor** - Where you type; border color indicates thinking level
139
- - **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.
140
-
141
- 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.
142
-
143
- ### Editor
144
-
145
- | Feature | How |
146
- |---------|-----|
147
- | File reference | Type `@` to fuzzy-search project files |
148
- | Path completion | Tab to complete paths |
149
- | Multi-line | Shift+Enter (or Ctrl+Enter on Windows Terminal) |
150
- | External editor | Ctrl+G opens `externalEditor`, `$VISUAL`, `$EDITOR`, Notepad on Windows, or `nano` elsewhere |
151
- | Clipboard | Ctrl+V to paste an image or text (Alt+V on Windows), or drag images onto terminal |
152
- | Bash commands | `!command` runs and sends output to LLM, `!!command` runs without sending |
153
-
154
- Standard editing keybindings for delete word, undo, etc. See [docs/keybindings.md](docs/keybindings.md).
155
-
156
- ### Commands
157
-
158
- 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`.
159
-
160
- | Command | Description |
161
- |---------|-------------|
162
- | `/login`, `/logout` | Manage provider credentials |
163
- | [`/llama`](docs/llama-cpp.md) | Download, load, and unload llama.cpp router models |
164
- | `/model` | Switch models |
165
- | `/scoped-models` | Enable/disable models for Ctrl+P cycling |
166
- | `/settings` | Thinking level, theme, message delivery, transport |
167
- | `/resume` | Pick from previous sessions |
168
- | `/new` | Start a new session |
169
- | `/name <name>` | Set session display name |
170
- | `/session` | Show session info (file, ID, messages, tokens, cost) |
171
- | `/tree` | Jump to any point in the session and continue from there |
172
- | `/trust` | Save project trust decision for future sessions (restart required) |
173
- | `/fork` | Create a new session from a previous user message |
174
- | `/clone` | Duplicate the current active branch into a new session |
175
- | `/compact [prompt]` | Manually compact context, optional custom instructions |
176
- | `/copy` | Copy last assistant message to clipboard |
177
- | `/export [file]` | Export session to HTML or JSONL file |
178
- | `/import <file>` | Import and resume a session from a JSONL file |
179
- | `/share` | Upload as private GitHub gist with shareable HTML link |
180
- | `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |
181
- | `/hotkeys` | Show all keyboard shortcuts |
182
- | `/changelog` | Display version history |
183
- | `/quit` | Quit pi |
184
-
185
- ### Keyboard Shortcuts
186
-
187
- See `/hotkeys` for the full list. Customize via `~/.pi/agent/keybindings.json`. See [docs/keybindings.md](docs/keybindings.md).
188
-
189
- **Commonly used:**
190
-
191
- | Key | Action |
192
- |-----|--------|
193
- | Ctrl+C | Clear editor |
194
- | Ctrl+C twice | Quit |
195
- | Escape | Cancel/abort |
196
- | Escape twice | Open `/tree` |
197
- | Ctrl+L | Open model selector |
198
- | Ctrl+P / Shift+Ctrl+P | Cycle scoped models forward/backward |
199
- | Shift+Tab | Cycle thinking level |
200
- | Ctrl+O | Collapse/expand tool output |
201
- | Ctrl+T | Collapse/expand thinking blocks |
202
- | Ctrl+X | Copy the last assistant message |
203
-
204
- ### Message Queue
205
-
206
- Submit messages while the agent is working:
207
-
208
- - **Enter** queues a *steering* message, delivered after the current assistant turn finishes executing its tool calls
209
- - **Alt+Enter** queues a *follow-up* message, delivered only after the agent finishes all work
210
- - **Escape** aborts and restores queued messages to editor
211
- - **Alt+Up** retrieves queued messages back to editor
212
-
213
- 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.
214
-
215
- 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.
216
-
217
- ---
218
-
219
- ## Sessions
220
-
221
- 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.
222
-
223
- ### Management
224
-
225
- Sessions auto-save to `~/.pi/agent/sessions/` organized by working directory.
226
-
227
- ```bash
228
- pi -c # Continue most recent session
229
- pi -r # Browse and select from past sessions
230
- pi --no-session # Ephemeral mode (don't save)
231
- pi --name "my task" # Set session display name at startup
232
- pi --session <path|id> # Use specific session file or ID
233
- pi --fork <path|id> # Fork specific session file or ID into a new session
234
- ```
235
-
236
- Use `/session` in interactive mode to see the current session ID before reusing it with `--session <id>` or `--fork <id>`.
237
-
238
- ### Branching
239
-
240
- **`/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.
241
-
242
- <p align="center"><img src="docs/images/tree-view.png" alt="Tree View" width="600"></p>
243
-
244
- - Search by typing, fold/unfold and jump between branches with Ctrl+←/Ctrl+→ or Alt+←/Alt+→, page with ←/→
245
- - Filter modes (Ctrl+O): default → no-tools → user-only → labeled-only → all
246
- - Press Ctrl+X to copy the selected message
247
- - Press Shift+L to label entries as bookmarks and Shift+T to toggle label timestamps
248
-
249
- **`/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.
250
-
251
- **`/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.
252
-
253
- **`--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.
254
-
255
- ### Compaction
256
-
257
- Long sessions can exhaust context windows. Compaction summarizes older messages while keeping recent ones.
258
-
259
- **Manual:** `/compact` or `/compact <custom instructions>`
260
-
261
- **Automatic:** Enabled by default. Triggers on context overflow (recovers and retries) or when approaching the limit (proactive). Configure via `/settings` or `settings.json`.
262
-
263
- 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.
264
-
265
- ---
266
-
267
- ## Settings
268
-
269
- Use `/settings` to modify common options, or edit JSON files directly:
270
-
271
- | Location | Scope |
272
- |----------|-------|
273
- | `~/.pi/agent/settings.json` | Global (all projects) |
274
- | `.pi/settings.json` | Project (overrides global) |
275
-
276
- See [docs/settings.md](docs/settings.md) for all options.
277
-
278
- ### Project Trust
279
-
280
- 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.
281
-
282
- 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.
283
-
284
- 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.
285
-
286
- 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`.
287
-
288
- `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.
289
-
290
- 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.
291
-
292
- ### Provider attribution and update checks
293
-
294
- This distribution checks the npm registry for the latest `@astralyn/pi` version. Disable the startup check with `PI_SKIP_VERSION_CHECK=1`.
295
-
296
- The `enableInstallTelemetry` setting name is retained for configuration compatibility, but it now controls only optional provider attribution headers for supported OpenRouter, Cloudflare, and NVIDIA NIM requests. The Fork does not send install or update pings to `pi.dev`. Set it to `false` in `settings.json`, or set `PI_TELEMETRY=0`, to disable those headers.
297
-
298
- Use `--offline` or `PI_OFFLINE=1` to disable startup network operations, including the npm version check, model refresh, and package update checks.
299
-
300
- ---
301
-
302
- ## Context Files
303
-
304
- Pi loads `AGENTS.md` (or `CLAUDE.md`) at startup from:
305
- - `~/.pi/agent/AGENTS.md` (global)
306
- - Parent directories (walking up from cwd)
307
- - Current directory
308
-
309
- Use for project instructions (`AGENTS.md`/`CLAUDE.md`), conventions, common commands. All matching files are concatenated.
310
-
311
- Disable context file loading with `--no-context-files` (or `-nc`).
312
-
313
- ### System Prompt
314
-
315
- Replace the default system prompt with `.pi/SYSTEM.md` (project) or `~/.pi/agent/SYSTEM.md` (global). Append without replacing via `APPEND_SYSTEM.md`.
316
-
317
- ---
318
-
319
- ## Customization
320
-
321
- ### Prompt Templates
322
-
323
- Reusable prompts as Markdown files. Type `/name` to expand.
324
-
325
- ```markdown
326
- <!-- ~/.pi/agent/prompts/review.md -->
327
- Review this code for bugs, security issues, and performance problems.
328
- Focus on: {{focus}}
329
- ```
330
-
331
- 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).
332
-
333
- ### Skills
334
-
335
- On-demand capability packages following the [Agent Skills standard](https://agentskills.io). Invoke via `/skill:name` or let the agent load them automatically.
336
-
337
- ```markdown
338
- <!-- ~/.pi/agent/skills/my-skill/SKILL.md -->
339
- # My Skill
340
- Use this skill when the user asks about X.
341
-
342
- ## Steps
343
- 1. Do this
344
- 2. Then that
345
- ```
346
-
347
- 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).
348
-
349
- ### Extensions
350
-
351
- <p align="center"><img src="docs/images/doom-extension.png" alt="Doom Extension" width="600"></p>
352
-
353
- TypeScript modules that extend pi with custom tools, commands, keyboard shortcuts, event handlers, and UI components.
354
-
355
- ```typescript
356
- export default function (pi: ExtensionAPI) {
357
- pi.registerTool({ name: "deploy", ... });
358
- pi.registerCommand("stats", { ... });
359
- pi.on("tool_call", async (event, ctx) => { ... });
360
- }
361
- ```
362
-
363
- 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()`.
364
-
365
- **What's possible:**
366
- - Custom tools (or replace built-in tools entirely)
367
- - Sub-agents and plan mode
368
- - Custom compaction and summarization
369
- - Permission gates and path protection
370
- - Custom editors and UI components
371
- - Status lines, headers, footers
372
- - Git checkpointing and auto-commit
373
- - SSH and sandbox execution
374
- - MCP server integration
375
- - Make pi look like Claude Code
376
- - Games while waiting (yes, Doom runs)
377
- - ...anything you can dream up
378
-
379
- 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/).
380
-
381
- ### Themes
382
-
383
- Built-in: `dark`, `light`. Themes hot-reload: modify the active theme file and pi immediately applies changes.
384
-
385
- Place in `~/.pi/agent/themes/`, `.pi/themes/`, or a [pi package](#pi-packages) to share with others. See [docs/themes.md](docs/themes.md).
386
-
387
- ### Pi Packages
388
-
389
- 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).
390
-
391
- > **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.
392
-
393
- ```bash
394
- pi install npm:@foo/pi-tools
395
- pi install npm:@foo/pi-tools@1.2.3 # pinned version
396
- pi install git:github.com/user/repo
397
- pi install git:github.com/user/repo@v1 # tag or commit
398
- pi install git:git@github.com:user/repo
399
- pi install git:git@github.com:user/repo@v1 # tag or commit
400
- pi install https://github.com/user/repo
401
- pi install https://github.com/user/repo@v1 # tag or commit
402
- pi install ssh://git@github.com/user/repo
403
- pi install ssh://git@github.com/user/repo@v1 # tag or commit
404
- pi remove npm:@foo/pi-tools
405
- pi uninstall npm:@foo/pi-tools # alias for remove
406
- pi list
407
- pi update # update pi only
408
- pi update --all # update pi and packages
409
- pi update --extensions # update packages only
410
- pi update --models # refresh model catalogs only
411
- pi update --self # update pi only
412
- pi update --self --force # reinstall pi even if current
413
- pi update npm:@foo/pi-tools # update one package
414
- pi config # enable/disable extensions, skills, prompts, themes
415
- ```
416
-
417
- 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"]`.
418
-
419
- Create a package by adding a `pi` key to `package.json`:
420
-
421
- ```json
422
- {
423
- "name": "my-pi-package",
424
- "keywords": ["pi-package"],
425
- "pi": {
426
- "extensions": ["./extensions"],
427
- "skills": ["./skills"],
428
- "prompts": ["./prompts"],
429
- "themes": ["./themes"]
430
- }
431
- }
432
- ```
433
-
434
- Without a `pi` manifest, pi auto-discovers from conventional directories (`extensions/`, `skills/`, `prompts/`, `themes/`).
435
-
436
- See [docs/packages.md](docs/packages.md).
437
-
438
- ---
439
-
440
- ## Programmatic Usage
441
-
442
- ### SDK
443
-
444
- ```typescript
445
- import { createAgentSession, ModelRuntime, SessionManager } from "@astralyn/pi";
446
-
447
- const modelRuntime = await ModelRuntime.create();
448
- const { session } = await createAgentSession({
449
- sessionManager: SessionManager.inMemory(),
450
- modelRuntime,
451
- });
452
-
453
- await session.prompt("What files are in the current directory?");
454
- ```
455
-
456
- For advanced multi-session runtime replacement, use `createAgentSessionRuntime()` and `AgentSessionRuntime`.
457
-
458
- See [docs/sdk.md](docs/sdk.md) and [examples/sdk/](examples/sdk/).
459
-
460
- ### RPC Mode
461
-
462
- For non-Node.js integrations, use RPC mode over stdin/stdout:
463
-
464
- ```bash
465
- pi --mode rpc
466
- ```
467
-
468
- 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.
469
-
470
- See [docs/rpc.md](docs/rpc.md) for the protocol.
471
-
472
- ---
473
-
474
- ## Philosophy
475
-
476
- 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.
477
-
478
- **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/)
479
-
480
- **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.
481
-
482
- **No permission popups.** Run in a container, or build your own confirmation flow with [extensions](#extensions) inline with your environment and security requirements.
483
-
484
- **No plan mode.** Write plans to files, or build it with [extensions](#extensions), or install a package.
485
-
486
- **No built-in to-dos.** They confuse models. Use a TODO.md file, or build your own with [extensions](#extensions).
487
-
488
- **No background bash.** Use tmux. Full observability, direct interaction.
489
-
490
- Read the [blog post](https://mariozechner.at/posts/2025-11-30-pi-coding-agent/) for the full rationale.
491
-
492
- ---
493
-
494
- ## CLI Reference
495
-
496
- ```bash
497
- pi [options] [@files...] [messages...]
498
- ```
499
-
500
- ### Package Commands
501
-
502
- ```bash
503
- pi install <source> [-l] # Install package, -l for project-local
504
- pi remove <source> [-l] # Remove package
505
- pi uninstall <source> [-l] # Alias for remove
506
- pi update [source|self|pi] # Update pi only, or one package source
507
- pi update --all # Update pi and packages
508
- pi update --extensions # Update packages only
509
- pi update --models # Refresh model catalogs only
510
- pi update --self # Update pi only
511
- pi update --self --force # Reinstall pi even if current
512
- pi update --extension <src> # Update one package
513
- pi list # List installed packages
514
- pi config # Enable/disable package resources
515
- ```
516
-
517
- `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.
518
-
519
- ### Modes
520
-
521
- | Flag | Description |
522
- |------|-------------|
523
- | (default) | Interactive mode |
524
- | `-p`, `--print` | Print response and exit |
525
- | `--mode json` | Output all events as JSON lines (see [docs/json.md](docs/json.md)) |
526
- | `--mode rpc` | RPC mode for process integration (see [docs/rpc.md](docs/rpc.md)) |
527
- | `--export <in> [out]` | Export session to HTML |
528
-
529
- In print mode, pi also reads piped stdin and merges it into the initial prompt:
530
-
531
- ```bash
532
- cat README.md | pi -p "Summarize this text"
533
- ```
534
-
535
- ### Model Options
536
-
537
- | Option | Description |
538
- |--------|-------------|
539
- | `--provider <name>` | Provider (anthropic, openai, google, etc.) |
540
- | `--model <pattern>` | Model pattern or ID (supports `provider/id` and optional `:<thinking>`) |
541
- | `--api-key <key>` | API key (overrides env vars) |
542
- | `--thinking <level>` | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` |
543
- | `--models <patterns>` | Comma-separated patterns for Ctrl+P cycling |
544
- | `--list-models [search]` | List available models |
545
-
546
- ### Session Options
547
-
548
- | Option | Description |
549
- |--------|-------------|
550
- | `-c`, `--continue` | Continue most recent session |
551
- | `-r`, `--resume` | Browse and select session |
552
- | `--session <path\|id>` | Use specific session file or partial UUID |
553
- | `--fork <path\|id>` | Fork specific session file or partial UUID into a new session |
554
- | `--session-dir <dir>` | Custom session storage directory |
555
- | `--no-session` | Ephemeral mode (don't save) |
556
- | `--name <name>`, `-n <name>` | Set session display name at startup |
557
-
558
- ### Tool Options
559
-
560
- | Option | Description |
561
- |--------|-------------|
562
- | `--tools <list>`, `-t <list>` | Allowlist specific tool names across built-in, extension, and custom tools |
563
- | `--exclude-tools <list>`, `-xt <list>` | Disable specific tool names across built-in, extension, and custom tools |
564
- | `--no-builtin-tools`, `-nbt` | Disable built-in tools by default but keep extension/custom tools enabled |
565
- | `--no-tools`, `-nt` | Disable all tools by default |
566
-
567
- Available built-in tools: `read`, `bash`, `edit`, `write`, `grep`, `find`, `ls`
568
-
569
- ### Resource Options
570
-
571
- | Option | Description |
572
- |--------|-------------|
573
- | `-e`, `--extension <source>` | Load extension from path, npm, or git (repeatable) |
574
- | `--no-extensions` | Disable extension discovery |
575
- | `--skill <path>` | Load skill (repeatable) |
576
- | `--no-skills` | Disable skill discovery |
577
- | `--prompt-template <path>` | Load prompt template (repeatable) |
578
- | `--no-prompt-templates` | Disable prompt template discovery |
579
- | `--theme <path>` | Load theme (repeatable) |
580
- | `--no-themes` | Disable theme discovery |
581
- | `--no-context-files`, `-nc` | Disable AGENTS.md and CLAUDE.md context file discovery |
582
-
583
- Combine `--no-*` with explicit flags to load exactly what you need, ignoring settings.json (e.g., `--no-extensions -e ./my-ext.ts`).
584
-
585
- ### Other Options
586
-
587
- | Option | Description |
588
- |--------|-------------|
589
- | `--system-prompt <text>` | Replace default prompt (context files and skills still appended) |
590
- | `--append-system-prompt <text>` | Append to system prompt |
591
- | `--verbose` | Force verbose startup |
592
- | `-a`, `--approve` | Trust project-local files for this run |
593
- | `-na`, `--no-approve` | Ignore project-local files for this run |
594
- | `-h`, `--help` | Show help |
595
- | `-v`, `--version` | Show version |
596
-
597
- ### File Arguments
598
-
599
- Prefix files with `@` to include in the message:
600
-
601
- ```bash
602
- pi @prompt.md "Answer this"
603
- pi -p @screenshot.png "What's in this image?"
604
- pi @code.ts @test.ts "Review these files"
605
- ```
606
-
607
- ### Examples
608
-
609
- ```bash
610
- # Interactive with initial prompt
611
- pi "List all .ts files in src/"
612
-
613
- # Non-interactive
614
- pi -p "Summarize this codebase"
615
-
616
- # Non-interactive with piped stdin
617
- cat README.md | pi -p "Summarize this text"
618
-
619
- # Named one-shot session
620
- pi --name "release audit" -p "Audit this repository"
621
-
622
- # Different model
623
- pi --provider openai --model gpt-4o "Help me refactor"
624
-
625
- # Model with provider prefix (no --provider needed)
626
- pi --model openai/gpt-4o "Help me refactor"
627
-
628
- # Model with thinking level shorthand
629
- pi --model sonnet:high "Solve this complex problem"
630
-
631
- # Limit model cycling
632
- pi --models "claude-*,gpt-4o"
633
-
634
- # Read-only mode
635
- pi --tools read,grep,find,ls -p "Review the code"
636
-
637
- # Disable one extension or built-in tool while keeping the rest available
638
- pi --exclude-tools ask_question
639
-
640
- # High thinking level
641
- pi --thinking high "Solve this complex problem"
642
- ```
643
-
644
- ### Environment Variables
645
-
646
- | Variable | Description |
647
- |----------|-------------|
648
- | `PI_CODING_AGENT_DIR` | Override config directory (default: `~/.pi/agent`) |
649
- | `PI_CODING_AGENT_SESSION_DIR` | Override session storage directory (overridden by `--session-dir`) |
650
- | `PI_PACKAGE_DIR` | Override package directory (useful for Nix/Guix where store paths tokenize poorly) |
651
- | `PI_OFFLINE` | Disable startup network operations, including npm version checks, package update checks, and model refresh |
652
- | `PI_SKIP_VERSION_CHECK` | Skip the Pi version update check at startup. This prevents the npm registry latest-version request |
653
- | `PI_TELEMETRY` | Override optional provider attribution headers. Use `1`/`true`/`yes` to enable or `0`/`false`/`no` to disable. This does not disable version checks |
654
- | `PI_CACHE_RETENTION` | Set to `long` for extended prompt cache (Anthropic: 1h, OpenAI: 24h) |
655
- | `VISUAL`, `EDITOR` | Fallback external editor for Ctrl+G when `externalEditor` is unset; defaults to Notepad on Windows and `nano` elsewhere |
656
-
657
- ---
658
-
659
- ## Development
660
-
661
- This repository is developed privately by its owner and invited Contributors. See [docs/development.md](docs/development.md) for upstream-compatible setup and debugging notes. Fork-specific development rules are in the repository root [AGENTS.md](../../AGENTS.md).
662
-
663
- ## License
664
-
665
- MIT
666
-
667
- ## See Also
668
-
669
- - [@earendil-works/pi-ai](https://www.npmjs.com/package/@earendil-works/pi-ai): Core LLM toolkit
670
- - [@earendil-works/pi-agent-core](https://www.npmjs.com/package/@earendil-works/pi-agent-core): Agent framework
671
- - [@earendil-works/pi-tui](https://www.npmjs.com/package/@earendil-works/pi-tui): Terminal UI components
672
-
673
- <p align="center">
674
- <a href="https://pi.dev">pi.dev</a> domain graciously donated by
675
- <br /><br />
676
- <a href="https://exe.dev"><img src="docs/images/exy.png" alt="Exy mascot" width="48" /><br />exe.dev</a>
677
- </p>
1
+ # Pi coding agent
2
+
3
+ > This package is the `@astralyn/pi` distribution maintained in this repository. It is based on [earendil-works/pi](https://github.com/earendil-works/pi) but is not an upstream release. Product usage and public APIs are indexed in [`docs/index.md`](docs/index.md); Fork architecture, bundled behavior, maintenance, and publishing live in the repository root [Fork documentation](../../docs/README.md).
4
+
5
+ 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.
6
+
7
+ 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.
8
+
9
+ Pi runs in four modes: interactive, print or JSON, RPC for process integration, and an SDK for embedding in your own apps. See [openclaw/openclaw](https://github.com/openclaw/openclaw) for a real-world SDK integration.
10
+
11
+ ## Share your OSS coding agent sessions
12
+
13
+ If you use pi for open source work, please share your coding agent sessions.
14
+
15
+ Public OSS session data helps improve models, prompts, tools, and evaluations using real development workflows.
16
+
17
+ For the full explanation, see [this post on X](https://x.com/badlogicgames/status/2037811643774652911).
18
+
19
+ 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`.
20
+
21
+ You can also watch [this video](https://x.com/badlogicgames/status/2041151967695634619), where I show how I publish my `pi-mono` sessions.
22
+
23
+ I regularly publish my own `pi-mono` work sessions here:
24
+
25
+ - [badlogicgames/pi-mono on Hugging Face](https://huggingface.co/datasets/badlogicgames/pi-mono)
26
+
27
+ ## Table of Contents
28
+
29
+ - [Quick Start](#quick-start)
30
+ - [Providers & Models](#providers--models)
31
+ - [Interactive Mode](#interactive-mode)
32
+ - [Editor](#editor)
33
+ - [Commands](#commands)
34
+ - [Keyboard Shortcuts](#keyboard-shortcuts)
35
+ - [Message Queue](#message-queue)
36
+ - [Sessions](#sessions)
37
+ - [Branching](#branching)
38
+ - [Compaction](#compaction)
39
+ - [Settings](#settings)
40
+ - [Context Files](#context-files)
41
+ - [Customization](#customization)
42
+ - [Prompt Templates](#prompt-templates)
43
+ - [Skills](#skills)
44
+ - [Extensions](#extensions)
45
+ - [Themes](#themes)
46
+ - [Pi Packages](#pi-packages)
47
+ - [Programmatic Usage](#programmatic-usage)
48
+ - [Philosophy](#philosophy)
49
+ - [CLI Reference](#cli-reference)
50
+
51
+ ---
52
+
53
+ ## Quick Start
54
+
55
+ ```bash
56
+ npm install -g --ignore-scripts @astralyn/pi
57
+ ```
58
+
59
+ `--ignore-scripts` disables dependency lifecycle scripts during install. Pi does not require install scripts for normal npm installs.
60
+
61
+ Authenticate with an API key:
62
+
63
+ ```bash
64
+ export ANTHROPIC_API_KEY=sk-ant-...
65
+ pi
66
+ ```
67
+
68
+ Or use your existing subscription:
69
+
70
+ ```bash
71
+ pi
72
+ /login # Then select provider
73
+ ```
74
+
75
+ 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).
76
+
77
+ **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)
78
+
79
+ ---
80
+
81
+ ## Providers & Models
82
+
83
+ 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).
84
+
85
+ **Subscriptions:**
86
+ - Anthropic Claude Pro/Max
87
+ - OpenAI ChatGPT Plus/Pro (Codex)
88
+ - GitHub Copilot
89
+
90
+ **API keys:**
91
+ - Anthropic
92
+ - Ant Ling
93
+ - OpenAI
94
+ - Azure OpenAI
95
+ - DeepSeek
96
+ - NVIDIA NIM
97
+ - Google Gemini
98
+ - Google Vertex
99
+ - Amazon Bedrock
100
+ - Mistral
101
+ - Groq
102
+ - Cerebras
103
+ - Cloudflare AI Gateway
104
+ - Cloudflare Workers AI
105
+ - xAI
106
+ - OpenRouter
107
+ - Vercel AI Gateway
108
+ - ZAI Coding Plan (Global)
109
+ - ZAI Coding Plan (China)
110
+ - OpenCode Zen
111
+ - OpenCode Go
112
+ - Hugging Face
113
+ - Fireworks
114
+ - Together AI
115
+ - Kimi For Coding
116
+ - MiniMax
117
+ - Xiaomi MiMo
118
+ - Xiaomi MiMo Token Plan (China)
119
+ - Xiaomi MiMo Token Plan (Amsterdam)
120
+ - Xiaomi MiMo Token Plan (Singapore)
121
+
122
+ 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.
123
+
124
+ See [docs/providers.md](docs/providers.md) for other provider setup instructions.
125
+
126
+ **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).
127
+
128
+ ---
129
+
130
+ ## Interactive Mode
131
+
132
+ <p align="center"><img src="docs/images/interactive-mode.png" alt="Interactive Mode" width="600"></p>
133
+
134
+ The interface from top to bottom:
135
+
136
+ - **Startup header** - Shows shortcuts (`/hotkeys` for all), loaded AGENTS.md files, prompt templates, skills, and extensions
137
+ - **Messages** - Your messages, assistant responses, tool calls and results, notifications, errors, and extension UI
138
+ - **Editor** - Where you type; border color indicates thinking level
139
+ - **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.
140
+
141
+ 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.
142
+
143
+ ### Editor
144
+
145
+ | Feature | How |
146
+ |---------|-----|
147
+ | File reference | Type `@` to fuzzy-search project files |
148
+ | Path completion | Tab to complete paths |
149
+ | Multi-line | Shift+Enter (or Ctrl+Enter on Windows Terminal) |
150
+ | External editor | Ctrl+G opens `externalEditor`, `$VISUAL`, `$EDITOR`, Notepad on Windows, or `nano` elsewhere |
151
+ | Clipboard | Ctrl+V to paste an image or text (Alt+V on Windows), or drag images onto terminal |
152
+ | Bash commands | `!command` runs and sends output to LLM, `!!command` runs without sending |
153
+
154
+ Standard editing keybindings for delete word, undo, etc. See [docs/keybindings.md](docs/keybindings.md).
155
+
156
+ ### Commands
157
+
158
+ 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`.
159
+
160
+ | Command | Description |
161
+ |---------|-------------|
162
+ | `/login`, `/logout` | Manage provider credentials |
163
+ | [`/llama`](docs/llama-cpp.md) | Download, load, and unload llama.cpp router models |
164
+ | `/model` | Switch models |
165
+ | `/scoped-models` | Enable/disable models for Ctrl+P cycling |
166
+ | `/settings` | Thinking level, theme, message delivery, transport |
167
+ | `/resume` | Pick from previous sessions |
168
+ | `/new` | Start a new session |
169
+ | `/name <name>` | Set session display name |
170
+ | `/session` | Show session info (file, ID, messages, tokens, cost) |
171
+ | `/tree` | Jump to any point in the session and continue from there |
172
+ | `/trust` | Save project trust decision for future sessions (restart required) |
173
+ | `/fork` | Create a new session from a previous user message |
174
+ | `/clone` | Duplicate the current active branch into a new session |
175
+ | `/compact [prompt]` | Manually compact context, optional custom instructions |
176
+ | `/copy` | Copy last assistant message to clipboard |
177
+ | `/export [file]` | Export session to HTML or JSONL file |
178
+ | `/import <file>` | Import and resume a session from a JSONL file |
179
+ | `/share` | Upload as private GitHub gist with shareable HTML link |
180
+ | `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |
181
+ | `/hotkeys` | Show all keyboard shortcuts |
182
+ | `/changelog` | Display version history |
183
+ | `/quit` | Quit pi |
184
+
185
+ ### Keyboard Shortcuts
186
+
187
+ See `/hotkeys` for the full list. Customize via `~/.pi/agent/keybindings.json`. See [docs/keybindings.md](docs/keybindings.md).
188
+
189
+ **Commonly used:**
190
+
191
+ | Key | Action |
192
+ |-----|--------|
193
+ | Ctrl+C | Clear editor |
194
+ | Ctrl+C twice | Quit |
195
+ | Escape | Cancel/abort |
196
+ | Escape twice | Open `/tree` |
197
+ | Ctrl+L | Open model selector |
198
+ | Ctrl+P / Shift+Ctrl+P | Cycle scoped models forward/backward |
199
+ | Shift+Tab | Cycle thinking level |
200
+ | Ctrl+O | Collapse/expand tool output |
201
+ | Ctrl+T | Collapse/expand thinking blocks |
202
+ | Ctrl+X | Copy the last assistant message |
203
+
204
+ ### Message Queue
205
+
206
+ Submit messages while the agent is working:
207
+
208
+ - **Enter** queues a *steering* message, delivered after the current assistant turn finishes executing its tool calls
209
+ - **Alt+Enter** queues a *follow-up* message, delivered only after the agent finishes all work
210
+ - **Escape** aborts and restores queued messages to editor
211
+ - **Alt+Up** retrieves queued messages back to editor
212
+
213
+ 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.
214
+
215
+ 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.
216
+
217
+ ---
218
+
219
+ ## Sessions
220
+
221
+ 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.
222
+
223
+ ### Management
224
+
225
+ Sessions auto-save to `~/.pi/agent/sessions/` organized by working directory.
226
+
227
+ ```bash
228
+ pi -c # Continue most recent session
229
+ pi -r # Browse and select from past sessions
230
+ pi --no-session # Ephemeral mode (don't save)
231
+ pi --name "my task" # Set session display name at startup
232
+ pi --session <path|id> # Use specific session file or ID
233
+ pi --fork <path|id> # Fork specific session file or ID into a new session
234
+ ```
235
+
236
+ Use `/session` in interactive mode to see the current session ID before reusing it with `--session <id>` or `--fork <id>`.
237
+
238
+ ### Branching
239
+
240
+ **`/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.
241
+
242
+ <p align="center"><img src="docs/images/tree-view.png" alt="Tree View" width="600"></p>
243
+
244
+ - Search by typing, fold/unfold and jump between branches with Ctrl+←/Ctrl+→ or Alt+←/Alt+→, page with ←/→
245
+ - Filter modes (Ctrl+O): default → no-tools → user-only → labeled-only → all
246
+ - Press Ctrl+X to copy the selected message
247
+ - Press Shift+L to label entries as bookmarks and Shift+T to toggle label timestamps
248
+
249
+ **`/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.
250
+
251
+ **`/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.
252
+
253
+ **`--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.
254
+
255
+ ### Compaction
256
+
257
+ Long sessions can exhaust context windows. Compaction summarizes older messages while keeping recent ones.
258
+
259
+ **Manual:** `/compact` or `/compact <custom instructions>`
260
+
261
+ **Automatic:** Enabled by default. Triggers on context overflow (recovers and retries) or when approaching the limit (proactive). Configure via `/settings` or `settings.json`.
262
+
263
+ 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.
264
+
265
+ ---
266
+
267
+ ## Settings
268
+
269
+ Use `/settings` to modify common options, or edit JSON files directly:
270
+
271
+ | Location | Scope |
272
+ |----------|-------|
273
+ | `~/.pi/agent/settings.json` | Global (all projects) |
274
+ | `.pi/settings.json` | Project (overrides global) |
275
+
276
+ See [docs/settings.md](docs/settings.md) for all options.
277
+
278
+ ### Project Trust
279
+
280
+ 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.
281
+
282
+ 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.
283
+
284
+ 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.
285
+
286
+ 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`.
287
+
288
+ `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.
289
+
290
+ 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.
291
+
292
+ ### Provider attribution and update checks
293
+
294
+ This distribution checks the npm registry for the latest `@astralyn/pi` version. Disable the startup check with `PI_SKIP_VERSION_CHECK=1`.
295
+
296
+ The `enableInstallTelemetry` setting name is retained for configuration compatibility, but it now controls only optional provider attribution headers for supported OpenRouter, Cloudflare, and NVIDIA NIM requests. The Fork does not send install or update pings to `pi.dev`. Set it to `false` in `settings.json`, or set `PI_TELEMETRY=0`, to disable those headers.
297
+
298
+ Use `--offline` or `PI_OFFLINE=1` to disable startup network operations, including the npm version check, model refresh, and package update checks.
299
+
300
+ ---
301
+
302
+ ## Context Files
303
+
304
+ Pi loads `AGENTS.md` (or `CLAUDE.md`) at startup from:
305
+ - `~/.pi/agent/AGENTS.md` (global)
306
+ - Parent directories (walking up from cwd)
307
+ - Current directory
308
+
309
+ Use for project instructions (`AGENTS.md`/`CLAUDE.md`), conventions, common commands. All matching files are concatenated.
310
+
311
+ Disable context file loading with `--no-context-files` (or `-nc`).
312
+
313
+ ### System Prompt
314
+
315
+ Replace the default system prompt with `.pi/SYSTEM.md` (project) or `~/.pi/agent/SYSTEM.md` (global). Append without replacing via `APPEND_SYSTEM.md`.
316
+
317
+ ---
318
+
319
+ ## Customization
320
+
321
+ ### Prompt Templates
322
+
323
+ Reusable prompts as Markdown files. Type `/name` to expand.
324
+
325
+ ```markdown
326
+ <!-- ~/.pi/agent/prompts/review.md -->
327
+ Review this code for bugs, security issues, and performance problems.
328
+ Focus on: {{focus}}
329
+ ```
330
+
331
+ 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).
332
+
333
+ ### Skills
334
+
335
+ On-demand capability packages following the [Agent Skills standard](https://agentskills.io). Invoke via `/skill:name` or let the agent load them automatically.
336
+
337
+ ```markdown
338
+ <!-- ~/.pi/agent/skills/my-skill/SKILL.md -->
339
+ # My Skill
340
+ Use this skill when the user asks about X.
341
+
342
+ ## Steps
343
+ 1. Do this
344
+ 2. Then that
345
+ ```
346
+
347
+ 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).
348
+
349
+ ### Extensions
350
+
351
+ <p align="center"><img src="docs/images/doom-extension.png" alt="Doom Extension" width="600"></p>
352
+
353
+ TypeScript modules that extend pi with custom tools, commands, keyboard shortcuts, event handlers, and UI components.
354
+
355
+ ```typescript
356
+ export default function (pi: ExtensionAPI) {
357
+ pi.registerTool({ name: "deploy", ... });
358
+ pi.registerCommand("stats", { ... });
359
+ pi.on("tool_call", async (event, ctx) => { ... });
360
+ }
361
+ ```
362
+
363
+ 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()`.
364
+
365
+ **What's possible:**
366
+ - Custom tools (or replace built-in tools entirely)
367
+ - Sub-agents and plan mode
368
+ - Custom compaction and summarization
369
+ - Permission gates and path protection
370
+ - Custom editors and UI components
371
+ - Status lines, headers, footers
372
+ - Git checkpointing and auto-commit
373
+ - SSH and sandbox execution
374
+ - MCP server integration
375
+ - Make pi look like Claude Code
376
+ - Games while waiting (yes, Doom runs)
377
+ - ...anything you can dream up
378
+
379
+ 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/).
380
+
381
+ ### Themes
382
+
383
+ Built-in: `dark`, `light`. Themes hot-reload: modify the active theme file and pi immediately applies changes.
384
+
385
+ Place in `~/.pi/agent/themes/`, `.pi/themes/`, or a [pi package](#pi-packages) to share with others. See [docs/themes.md](docs/themes.md).
386
+
387
+ ### Pi Packages
388
+
389
+ 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).
390
+
391
+ > **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.
392
+
393
+ ```bash
394
+ pi install npm:@foo/pi-tools
395
+ pi install npm:@foo/pi-tools@1.2.3 # pinned version
396
+ pi install git:github.com/user/repo
397
+ pi install git:github.com/user/repo@v1 # tag or commit
398
+ pi install git:git@github.com:user/repo
399
+ pi install git:git@github.com:user/repo@v1 # tag or commit
400
+ pi install https://github.com/user/repo
401
+ pi install https://github.com/user/repo@v1 # tag or commit
402
+ pi install ssh://git@github.com/user/repo
403
+ pi install ssh://git@github.com/user/repo@v1 # tag or commit
404
+ pi remove npm:@foo/pi-tools
405
+ pi uninstall npm:@foo/pi-tools # alias for remove
406
+ pi list
407
+ pi update # update pi only
408
+ pi update --all # update pi and packages
409
+ pi update --extensions # update packages only
410
+ pi update --models # refresh model catalogs only
411
+ pi update --self # update pi only
412
+ pi update --self --force # reinstall pi even if current
413
+ pi update npm:@foo/pi-tools # update one package
414
+ pi config # enable/disable extensions, skills, prompts, themes
415
+ ```
416
+
417
+ 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"]`.
418
+
419
+ Create a package by adding a `pi` key to `package.json`:
420
+
421
+ ```json
422
+ {
423
+ "name": "my-pi-package",
424
+ "keywords": ["pi-package"],
425
+ "pi": {
426
+ "extensions": ["./extensions"],
427
+ "skills": ["./skills"],
428
+ "prompts": ["./prompts"],
429
+ "themes": ["./themes"]
430
+ }
431
+ }
432
+ ```
433
+
434
+ Without a `pi` manifest, pi auto-discovers from conventional directories (`extensions/`, `skills/`, `prompts/`, `themes/`).
435
+
436
+ See [docs/packages.md](docs/packages.md).
437
+
438
+ ---
439
+
440
+ ## Programmatic Usage
441
+
442
+ ### SDK
443
+
444
+ ```typescript
445
+ import { createAgentSession, ModelRuntime, SessionManager } from "@astralyn/pi";
446
+
447
+ const modelRuntime = await ModelRuntime.create();
448
+ const { session } = await createAgentSession({
449
+ sessionManager: SessionManager.inMemory(),
450
+ modelRuntime,
451
+ });
452
+
453
+ await session.prompt("What files are in the current directory?");
454
+ ```
455
+
456
+ For advanced multi-session runtime replacement, use `createAgentSessionRuntime()` and `AgentSessionRuntime`.
457
+
458
+ See [docs/sdk.md](docs/sdk.md) and [examples/sdk/](examples/sdk/).
459
+
460
+ ### RPC Mode
461
+
462
+ For non-Node.js integrations, use RPC mode over stdin/stdout:
463
+
464
+ ```bash
465
+ pi --mode rpc
466
+ ```
467
+
468
+ 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.
469
+
470
+ See [docs/rpc.md](docs/rpc.md) for the protocol.
471
+
472
+ ---
473
+
474
+ ## Philosophy
475
+
476
+ 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.
477
+
478
+ **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/)
479
+
480
+ **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.
481
+
482
+ **No permission popups.** Run in a container, or build your own confirmation flow with [extensions](#extensions) inline with your environment and security requirements.
483
+
484
+ **No plan mode.** Write plans to files, or build it with [extensions](#extensions), or install a package.
485
+
486
+ **No built-in to-dos.** They confuse models. Use a TODO.md file, or build your own with [extensions](#extensions).
487
+
488
+ **No background bash.** Use tmux. Full observability, direct interaction.
489
+
490
+ Read the [blog post](https://mariozechner.at/posts/2025-11-30-pi-coding-agent/) for the full rationale.
491
+
492
+ ---
493
+
494
+ ## CLI Reference
495
+
496
+ ```bash
497
+ pi [options] [@files...] [messages...]
498
+ ```
499
+
500
+ ### Package Commands
501
+
502
+ ```bash
503
+ pi install <source> [-l] # Install package, -l for project-local
504
+ pi remove <source> [-l] # Remove package
505
+ pi uninstall <source> [-l] # Alias for remove
506
+ pi update [source|self|pi] # Update pi only, or one package source
507
+ pi update --all # Update pi and packages
508
+ pi update --extensions # Update packages only
509
+ pi update --models # Refresh model catalogs only
510
+ pi update --self # Update pi only
511
+ pi update --self --force # Reinstall pi even if current
512
+ pi update --extension <src> # Update one package
513
+ pi list # List installed packages
514
+ pi config # Enable/disable package resources
515
+ ```
516
+
517
+ `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.
518
+
519
+ ### Modes
520
+
521
+ | Flag | Description |
522
+ |------|-------------|
523
+ | (default) | Interactive mode |
524
+ | `-p`, `--print` | Print response and exit |
525
+ | `--mode json` | Output all events as JSON lines (see [docs/json.md](docs/json.md)) |
526
+ | `--mode rpc` | RPC mode for process integration (see [docs/rpc.md](docs/rpc.md)) |
527
+ | `--export <in> [out]` | Export session to HTML |
528
+
529
+ In print mode, pi also reads piped stdin and merges it into the initial prompt:
530
+
531
+ ```bash
532
+ cat README.md | pi -p "Summarize this text"
533
+ ```
534
+
535
+ ### Model Options
536
+
537
+ | Option | Description |
538
+ |--------|-------------|
539
+ | `--provider <name>` | Provider (anthropic, openai, google, etc.) |
540
+ | `--model <pattern>` | Model pattern or ID (supports `provider/id` and optional `:<thinking>`) |
541
+ | `--api-key <key>` | API key (overrides env vars) |
542
+ | `--thinking <level>` | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` |
543
+ | `--models <patterns>` | Comma-separated patterns for Ctrl+P cycling |
544
+ | `--list-models [search]` | List available models |
545
+
546
+ ### Session Options
547
+
548
+ | Option | Description |
549
+ |--------|-------------|
550
+ | `-c`, `--continue` | Continue most recent session |
551
+ | `-r`, `--resume` | Browse and select session |
552
+ | `--session <path\|id>` | Use specific session file or partial UUID |
553
+ | `--fork <path\|id>` | Fork specific session file or partial UUID into a new session |
554
+ | `--session-dir <dir>` | Custom session storage directory |
555
+ | `--no-session` | Ephemeral mode (don't save) |
556
+ | `--name <name>`, `-n <name>` | Set session display name at startup |
557
+
558
+ ### Tool Options
559
+
560
+ | Option | Description |
561
+ |--------|-------------|
562
+ | `--tools <list>`, `-t <list>` | Allowlist specific tool names across built-in, extension, and custom tools |
563
+ | `--exclude-tools <list>`, `-xt <list>` | Disable specific tool names across built-in, extension, and custom tools |
564
+ | `--no-builtin-tools`, `-nbt` | Disable built-in tools by default but keep extension/custom tools enabled |
565
+ | `--no-tools`, `-nt` | Disable all tools by default |
566
+
567
+ Available built-in tools: `read`, `bash`, `edit`, `write`, `grep`, `find`, `ls`
568
+
569
+ ### Resource Options
570
+
571
+ | Option | Description |
572
+ |--------|-------------|
573
+ | `-e`, `--extension <source>` | Load extension from path, npm, or git (repeatable) |
574
+ | `--no-extensions` | Disable extension discovery |
575
+ | `--skill <path>` | Load skill (repeatable) |
576
+ | `--no-skills` | Disable skill discovery |
577
+ | `--prompt-template <path>` | Load prompt template (repeatable) |
578
+ | `--no-prompt-templates` | Disable prompt template discovery |
579
+ | `--theme <path>` | Load theme (repeatable) |
580
+ | `--no-themes` | Disable theme discovery |
581
+ | `--no-context-files`, `-nc` | Disable AGENTS.md and CLAUDE.md context file discovery |
582
+
583
+ Combine `--no-*` with explicit flags to load exactly what you need, ignoring settings.json (e.g., `--no-extensions -e ./my-ext.ts`).
584
+
585
+ ### Other Options
586
+
587
+ | Option | Description |
588
+ |--------|-------------|
589
+ | `--system-prompt <text>` | Replace default prompt (context files and skills still appended) |
590
+ | `--append-system-prompt <text>` | Append to system prompt |
591
+ | `--verbose` | Force verbose startup |
592
+ | `-a`, `--approve` | Trust project-local files for this run |
593
+ | `-na`, `--no-approve` | Ignore project-local files for this run |
594
+ | `-h`, `--help` | Show help |
595
+ | `-v`, `--version` | Show version |
596
+
597
+ ### File Arguments
598
+
599
+ Prefix files with `@` to include in the message:
600
+
601
+ ```bash
602
+ pi @prompt.md "Answer this"
603
+ pi -p @screenshot.png "What's in this image?"
604
+ pi @code.ts @test.ts "Review these files"
605
+ ```
606
+
607
+ ### Examples
608
+
609
+ ```bash
610
+ # Interactive with initial prompt
611
+ pi "List all .ts files in src/"
612
+
613
+ # Non-interactive
614
+ pi -p "Summarize this codebase"
615
+
616
+ # Non-interactive with piped stdin
617
+ cat README.md | pi -p "Summarize this text"
618
+
619
+ # Named one-shot session
620
+ pi --name "release audit" -p "Audit this repository"
621
+
622
+ # Different model
623
+ pi --provider openai --model gpt-4o "Help me refactor"
624
+
625
+ # Model with provider prefix (no --provider needed)
626
+ pi --model openai/gpt-4o "Help me refactor"
627
+
628
+ # Model with thinking level shorthand
629
+ pi --model sonnet:high "Solve this complex problem"
630
+
631
+ # Limit model cycling
632
+ pi --models "claude-*,gpt-4o"
633
+
634
+ # Read-only mode
635
+ pi --tools read,grep,find,ls -p "Review the code"
636
+
637
+ # Disable one extension or built-in tool while keeping the rest available
638
+ pi --exclude-tools ask_question
639
+
640
+ # High thinking level
641
+ pi --thinking high "Solve this complex problem"
642
+ ```
643
+
644
+ ### Environment Variables
645
+
646
+ | Variable | Description |
647
+ |----------|-------------|
648
+ | `PI_CODING_AGENT` | Set to `true` by the CLI and RPC entry points so child processes can detect that they run inside Pi |
649
+ | `PI_CODING_AGENT_DIR` | Override config directory (default: `~/.pi/agent`) |
650
+ | `PI_CODING_AGENT_SESSION_DIR` | Override session storage directory (overridden by `--session-dir`) |
651
+ | `PI_PACKAGE_DIR` | Override package directory (useful for Nix/Guix where store paths tokenize poorly) |
652
+ | `PI_OFFLINE` | Disable startup network operations, including npm version checks, package update checks, and model refresh |
653
+ | `PI_SKIP_VERSION_CHECK` | Skip the Pi version update check at startup. This prevents the npm registry latest-version request |
654
+ | `PI_TELEMETRY` | Override optional provider attribution headers. Use `1`/`true`/`yes` to enable or `0`/`false`/`no` to disable. This does not disable version checks |
655
+ | `PI_CACHE_RETENTION` | Set to `long` for extended prompt cache (Anthropic: 1h, OpenAI: 24h) |
656
+ | `VISUAL`, `EDITOR` | Fallback external editor for Ctrl+G when `externalEditor` is unset; defaults to Notepad on Windows and `nano` elsewhere |
657
+
658
+ Commands run by the LLM-callable bash tool also receive current session metadata:
659
+
660
+ | Variable | Description |
661
+ |----------|-------------|
662
+ | `PI_SESSION_ID` | Current session ID |
663
+ | `PI_SESSION_FILE` | Absolute session JSONL path; unset for ephemeral sessions |
664
+ | `PI_PROVIDER` | Currently selected model provider |
665
+ | `PI_MODEL` | Currently selected model ID |
666
+ | `PI_REASONING_LEVEL` | Current effective reasoning level |
667
+
668
+ These values are resolved when each command starts. See [Environment Variables](docs/environment-variables.md#bash-tool-session-environment) for semantics, examples, and custom-tool opt-out.
669
+
670
+ ---
671
+
672
+ ## Development
673
+
674
+ This repository is developed privately by its owner and invited Contributors. See [docs/development.md](docs/development.md) for upstream-compatible setup and debugging notes. Fork-specific development rules are in the repository root [AGENTS.md](../../AGENTS.md).
675
+
676
+ ## License
677
+
678
+ MIT
679
+
680
+ ## See Also
681
+
682
+ - [@earendil-works/pi-ai](https://www.npmjs.com/package/@earendil-works/pi-ai): Core LLM toolkit
683
+ - [@earendil-works/pi-agent-core](https://www.npmjs.com/package/@earendil-works/pi-agent-core): Agent framework
684
+ - [@earendil-works/pi-tui](https://www.npmjs.com/package/@earendil-works/pi-tui): Terminal UI components
685
+
686
+ <p align="center">
687
+ <a href="https://pi.dev">pi.dev</a> domain graciously donated by
688
+ <br /><br />
689
+ <a href="https://exe.dev"><img src="docs/images/exy.png" alt="Exy mascot" width="48" /><br />exe.dev</a>
690
+ </p>