@earendil-works/pi-coding-agent 0.99.1 → 1.0.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 (221) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/dist/bundle/chunks/anthropic-messages-UID2PALB.js +6 -0
  3. package/dist/bundle/chunks/anthropic.js +2 -2
  4. package/dist/bundle/chunks/{azure-openai-responses-EN5WOBET.js → azure-openai-responses-AFMVM6NP.js} +1 -1
  5. package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
  6. package/dist/bundle/chunks/{chunk-AXPY26X7.js → chunk-2KTBZM5G.js} +14 -28
  7. package/dist/bundle/chunks/{chunk-LRS5S6EK.js → chunk-2VNGUWBO.js} +2 -2
  8. package/dist/bundle/chunks/chunk-33XOIQ5N.js +1204 -0
  9. package/dist/bundle/chunks/{chunk-W2DOMZSC.js → chunk-3LH3ZQKY.js} +1 -1
  10. package/dist/bundle/chunks/chunk-4KU537KD.js +2 -0
  11. package/dist/bundle/chunks/chunk-6D7LHLKG.js +2 -0
  12. package/dist/bundle/chunks/chunk-7FH3BDRG.js +82 -0
  13. package/dist/bundle/chunks/{chunk-LLMKQWZS.js → chunk-IBCPYVFK.js} +7 -9
  14. package/dist/bundle/chunks/chunk-KDN6RCEQ.js +4 -0
  15. package/dist/bundle/chunks/chunk-LD2P6SFZ.js +2 -0
  16. package/dist/bundle/chunks/{chunk-PEHWOV5U.js → chunk-LTXEMVMA.js} +18 -78
  17. package/dist/bundle/chunks/{chunk-J4CWPC4N.js → chunk-OSKPX3Z5.js} +1 -1
  18. package/dist/bundle/chunks/chunk-PRD6WYBT.js +16 -0
  19. package/dist/bundle/chunks/chunk-VIV3CWXG.js +2 -0
  20. package/dist/bundle/chunks/{cli-AZXNGIZH.js → cli-QOMC26IJ.js} +8 -6
  21. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-XJQQYGGU.js → cloudflare-workers-ai-system-one-NPQN263E.js} +1 -1
  22. package/dist/bundle/chunks/codemode-worker.js +67 -8
  23. package/dist/bundle/chunks/execute-GVRSEGHL.js +367 -0
  24. package/dist/bundle/chunks/github-copilot.js +1 -1
  25. package/dist/bundle/chunks/{google-generative-ai-CQAKKJTA.js → google-generative-ai-APTPZOQL.js} +1 -1
  26. package/dist/bundle/chunks/{google-vertex-AE36YXJU.js → google-vertex-MXCOSOY3.js} +1 -1
  27. package/dist/bundle/chunks/{llama-cpp-classify-PJJYKPLD.js → llama-cpp-classify-XT44PI3C.js} +1 -1
  28. package/dist/bundle/chunks/{mistral-conversations-KEYTXJM7.js → mistral-conversations-DKVFNQL6.js} +1 -1
  29. package/dist/bundle/chunks/openai-chatgpt.js +1 -1
  30. package/dist/bundle/chunks/{openai-codex-responses-JQTCOVEG.js → openai-codex-responses-GK67DQQJ.js} +1 -1
  31. package/dist/bundle/chunks/openai-codex.js +1 -1
  32. package/dist/bundle/chunks/{openai-completions-XW2Q5HVC.js → openai-completions-JXDDPZ23.js} +1 -1
  33. package/dist/bundle/chunks/{openai-responses-6AXWFL75.js → openai-responses-CQDDLDQF.js} +1 -1
  34. package/dist/bundle/chunks/{openrouter-images-TPQ4V6OR.js → openrouter-images-ZVXWCSIM.js} +1 -1
  35. package/dist/bundle/chunks/openrouter.js +1 -1
  36. package/dist/bundle/chunks/pi-logo-animation-MPKZE4EK.js +2 -0
  37. package/dist/bundle/chunks/radius.js +1 -1
  38. package/dist/bundle/chunks/runtime-2SO2JDWM.js +2 -0
  39. package/dist/bundle/chunks/{typesafe-system-one-E7A4HNJI.js → typesafe-system-one-A4CZTQWZ.js} +1 -1
  40. package/dist/bundle/chunks/virtual-modules-6ZMK7GDO.js +2 -0
  41. package/dist/bundle/cli-runtime.js +1 -1
  42. package/dist/bundle/index.js +1 -1
  43. package/dist/bundle/rpc-entry.js +1 -1
  44. package/dist/cli/args.js +2 -2
  45. package/dist/cli/args.js.map +1 -1
  46. package/dist/config.d.ts +5 -8
  47. package/dist/config.d.ts.map +1 -1
  48. package/dist/config.js +16 -13
  49. package/dist/config.js.map +1 -1
  50. package/dist/core/agent-session.d.ts +15 -1
  51. package/dist/core/agent-session.d.ts.map +1 -1
  52. package/dist/core/agent-session.js +51 -10
  53. package/dist/core/agent-session.js.map +1 -1
  54. package/dist/core/extensions/loader.d.ts.map +1 -1
  55. package/dist/core/extensions/loader.js +13 -1
  56. package/dist/core/extensions/loader.js.map +1 -1
  57. package/dist/core/extensions/types.d.ts +6 -1
  58. package/dist/core/extensions/types.d.ts.map +1 -1
  59. package/dist/core/extensions/types.js.map +1 -1
  60. package/dist/core/mcp-servers.d.ts +34 -7
  61. package/dist/core/mcp-servers.d.ts.map +1 -1
  62. package/dist/core/mcp-servers.js +52 -11
  63. package/dist/core/mcp-servers.js.map +1 -1
  64. package/dist/core/model-registry.d.ts +3 -1
  65. package/dist/core/model-registry.d.ts.map +1 -1
  66. package/dist/core/model-registry.js +4 -0
  67. package/dist/core/model-registry.js.map +1 -1
  68. package/dist/core/model-runtime.d.ts +6 -0
  69. package/dist/core/model-runtime.d.ts.map +1 -1
  70. package/dist/core/model-runtime.js +22 -18
  71. package/dist/core/model-runtime.js.map +1 -1
  72. package/dist/core/radius.d.ts +2 -0
  73. package/dist/core/radius.d.ts.map +1 -1
  74. package/dist/core/radius.js +2 -0
  75. package/dist/core/radius.js.map +1 -1
  76. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  77. package/dist/core/remote-catalog-provider.js +4 -9
  78. package/dist/core/remote-catalog-provider.js.map +1 -1
  79. package/dist/core/sdk.d.ts.map +1 -1
  80. package/dist/core/sdk.js +1 -0
  81. package/dist/core/sdk.js.map +1 -1
  82. package/dist/core/settings-manager.d.ts +7 -5
  83. package/dist/core/settings-manager.d.ts.map +1 -1
  84. package/dist/core/settings-manager.js +3 -2
  85. package/dist/core/settings-manager.js.map +1 -1
  86. package/dist/core/system-prompt.js +1 -1
  87. package/dist/core/system-prompt.js.map +1 -1
  88. package/dist/core/tools/bash.d.ts.map +1 -1
  89. package/dist/core/tools/bash.js +3 -5
  90. package/dist/core/tools/bash.js.map +1 -1
  91. package/dist/core/tools/renderers/bash.d.ts.map +1 -1
  92. package/dist/core/tools/renderers/bash.js +11 -31
  93. package/dist/core/tools/renderers/bash.js.map +1 -1
  94. package/dist/core/virtual-models.d.ts +2 -0
  95. package/dist/core/virtual-models.d.ts.map +1 -1
  96. package/dist/core/virtual-models.js +19 -12
  97. package/dist/core/virtual-models.js.map +1 -1
  98. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  99. package/dist/extensions/codemode/execute.js +197 -51
  100. package/dist/extensions/codemode/execute.js.map +1 -1
  101. package/dist/extensions/codemode/renderer.d.ts.map +1 -1
  102. package/dist/extensions/codemode/renderer.js +43 -25
  103. package/dist/extensions/codemode/renderer.js.map +1 -1
  104. package/dist/extensions/codemode/tool.d.ts +12 -11
  105. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  106. package/dist/extensions/codemode/tool.js +73 -129
  107. package/dist/extensions/codemode/tool.js.map +1 -1
  108. package/dist/extensions/codemode/worker.d.ts +1 -1
  109. package/dist/extensions/codemode/worker.js +1 -1
  110. package/dist/extensions/codemode/worker.js.map +1 -1
  111. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  112. package/dist/extensions/mcp/cli.js +20 -5
  113. package/dist/extensions/mcp/cli.js.map +1 -1
  114. package/dist/extensions/mcp/config.d.ts +4 -2
  115. package/dist/extensions/mcp/config.d.ts.map +1 -1
  116. package/dist/extensions/mcp/config.js +14 -2
  117. package/dist/extensions/mcp/config.js.map +1 -1
  118. package/dist/extensions/mcp/index.d.ts +32 -8
  119. package/dist/extensions/mcp/index.d.ts.map +1 -1
  120. package/dist/extensions/mcp/index.js +220 -56
  121. package/dist/extensions/mcp/index.js.map +1 -1
  122. package/dist/extensions/mcp/oauth.d.ts +10 -7
  123. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  124. package/dist/extensions/mcp/oauth.js +56 -31
  125. package/dist/extensions/mcp/oauth.js.map +1 -1
  126. package/dist/extensions/mcp/runtime.d.ts +2 -0
  127. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  128. package/dist/extensions/mcp/runtime.js +16 -9
  129. package/dist/extensions/mcp/runtime.js.map +1 -1
  130. package/dist/extensions/mcp/tools.d.ts +5 -4
  131. package/dist/extensions/mcp/tools.d.ts.map +1 -1
  132. package/dist/extensions/mcp/tools.js +33 -15
  133. package/dist/extensions/mcp/tools.js.map +1 -1
  134. package/dist/extensions/mcp/ui.d.ts.map +1 -1
  135. package/dist/extensions/mcp/ui.js +4 -2
  136. package/dist/extensions/mcp/ui.js.map +1 -1
  137. package/dist/extensions/tool-search/tool.d.ts +5 -4
  138. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  139. package/dist/extensions/tool-search/tool.js +7 -28
  140. package/dist/extensions/tool-search/tool.js.map +1 -1
  141. package/dist/index.d.ts +1 -1
  142. package/dist/index.d.ts.map +1 -1
  143. package/dist/index.js.map +1 -1
  144. package/dist/main.d.ts.map +1 -1
  145. package/dist/main.js +6 -0
  146. package/dist/main.js.map +1 -1
  147. package/dist/modes/interactive/components/oauth-selector.d.ts +8 -2
  148. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  149. package/dist/modes/interactive/components/oauth-selector.js +24 -21
  150. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  151. package/dist/modes/interactive/components/pi-logo-animation.d.ts +68 -0
  152. package/dist/modes/interactive/components/pi-logo-animation.d.ts.map +1 -0
  153. package/dist/modes/interactive/components/pi-logo-animation.js +1086 -0
  154. package/dist/modes/interactive/components/pi-logo-animation.js.map +1 -0
  155. package/dist/modes/interactive/components/pi-logo-animation.lazy.d.ts +7 -0
  156. package/dist/modes/interactive/components/pi-logo-animation.lazy.d.ts.map +1 -0
  157. package/dist/modes/interactive/components/pi-logo-animation.lazy.js +12 -0
  158. package/dist/modes/interactive/components/pi-logo-animation.lazy.js.map +1 -0
  159. package/dist/modes/interactive/components/pi-logo.d.ts +7 -0
  160. package/dist/modes/interactive/components/pi-logo.d.ts.map +1 -1
  161. package/dist/modes/interactive/components/pi-logo.js +13 -1
  162. package/dist/modes/interactive/components/pi-logo.js.map +1 -1
  163. package/dist/modes/interactive/components/radius-login-selector.d.ts +15 -0
  164. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -0
  165. package/dist/modes/interactive/components/radius-login-selector.js +85 -0
  166. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -0
  167. package/dist/modes/interactive/components/settings-selector.d.ts +3 -3
  168. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  169. package/dist/modes/interactive/components/settings-selector.js +5 -5
  170. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  171. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  172. package/dist/modes/interactive/components/user-message.js +5 -4
  173. package/dist/modes/interactive/components/user-message.js.map +1 -1
  174. package/dist/modes/interactive/components/visual-truncate.d.ts +27 -3
  175. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  176. package/dist/modes/interactive/components/visual-truncate.js +39 -6
  177. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  178. package/dist/modes/interactive/interactive-mode.d.ts +10 -0
  179. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  180. package/dist/modes/interactive/interactive-mode.js +153 -40
  181. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  182. package/dist/modes/interactive/theme/system-theme.d.ts +2 -1
  183. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
  184. package/dist/modes/interactive/theme/system-theme.js +16 -5
  185. package/dist/modes/interactive/theme/system-theme.js.map +1 -1
  186. package/docs/cli.md +8 -18
  187. package/docs/codemode.md +207 -0
  188. package/docs/docs.json +5 -1
  189. package/docs/environment-variables.md +2 -2
  190. package/docs/extensions.md +3 -3
  191. package/docs/index.md +1 -1
  192. package/docs/mcp.md +142 -82
  193. package/docs/models.md +22 -1
  194. package/docs/providers.md +18 -6
  195. package/docs/sdk.md +2 -2
  196. package/docs/settings.md +5 -3
  197. package/docs/usage.md +1 -1
  198. package/examples/extensions/built-in-tool-renderer.ts +16 -40
  199. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  200. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  201. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  202. package/examples/extensions/gondolin/package-lock.json +2 -2
  203. package/examples/extensions/gondolin/package.json +1 -1
  204. package/examples/extensions/minimal-mode.ts +24 -96
  205. package/examples/extensions/sandbox/package-lock.json +2 -2
  206. package/examples/extensions/sandbox/package.json +1 -1
  207. package/examples/extensions/with-deps/package-lock.json +2 -2
  208. package/examples/extensions/with-deps/package.json +1 -1
  209. package/examples/sdk/14-codemode-mcp.ts +2 -2
  210. package/npm-shrinkwrap.json +25 -30
  211. package/package.json +10 -10
  212. package/dist/bundle/chunks/anthropic-messages-A6EXUBG6.js +0 -6
  213. package/dist/bundle/chunks/chunk-GOPCREV2.js +0 -4
  214. package/dist/bundle/chunks/chunk-GUORCHFS.js +0 -1435
  215. package/dist/bundle/chunks/chunk-HSPCVFST.js +0 -2
  216. package/dist/bundle/chunks/chunk-IMTXZUO7.js +0 -82
  217. package/dist/bundle/chunks/chunk-SLDA2X2H.js +0 -2
  218. package/dist/bundle/chunks/chunk-XNGRGP62.js +0 -2
  219. package/dist/bundle/chunks/execute-7XXPZAWW.js +0 -308
  220. package/dist/bundle/chunks/runtime-G5WJPRBM.js +0 -2
  221. package/dist/bundle/chunks/virtual-modules-CSWRO37N.js +0 -2
package/docs/docs.json CHANGED
@@ -136,6 +136,10 @@
136
136
  "title": "CLI",
137
137
  "path": "cli.md"
138
138
  },
139
+ {
140
+ "title": "Codemode",
141
+ "path": "codemode.md"
142
+ },
139
143
  {
140
144
  "title": "Slash Commands",
141
145
  "path": "slash-commands.md"
@@ -153,7 +157,7 @@
153
157
  "path": "keybindings.md"
154
158
  },
155
159
  {
156
- "title": "Provider Authentication",
160
+ "title": "Providers",
157
161
  "path": "providers.md"
158
162
  },
159
163
  {
@@ -6,7 +6,7 @@ Pi uses environment variables in three ways:
6
6
  - Pi sets process markers so child processes can identify Pi as the launching agent.
7
7
  - Commands run by the LLM-callable shell tools receive `PI_*` variables describing the current session.
8
8
 
9
- Provider API-key variables are documented separately in [Provider Authentication](providers.md#use-an-api-key-from-the-environment).
9
+ Provider API-key variables are documented separately in [Providers](providers.md#use-an-api-key-from-the-environment).
10
10
 
11
11
  ## Process Marker
12
12
 
@@ -95,4 +95,4 @@ These variables are read by Pi itself:
95
95
  | `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
96
96
  | `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
97
97
 
98
- Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and cloud-provider configuration are listed in [Provider Authentication](providers.md#use-an-api-key-from-the-environment).
98
+ Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and provider-specific configuration are listed in [Providers](providers.md#use-an-api-key-from-the-environment).
@@ -159,7 +159,7 @@ See [`hello.ts`](../examples/extensions/hello.ts), [`todo.ts`](../examples/exten
159
159
  - `deferred`: like `codemode`, but codemode tools do not list it; `tool_search` can find and activate it.
160
160
  - `hidden`: registered but unreachable. Re-register a tool with `exposure: "hidden"` to withdraw it, since tools cannot be unregistered.
161
161
 
162
- `namespace: { name, description }` groups related tools, as MCP servers do. Codemode tools list a namespace under one heading.
162
+ `namespace: { name, description, instructions }` groups related tools, as MCP servers do. Codemode tools list a namespace under one heading with its `description`. `instructions` holds longer usage guidance; it is not listed, and codemode scripts read it with `describeNamespace(name)`.
163
163
 
164
164
  Registering a `direct` or `model-only` tool activates it; the other exposures are not activated on registration. The active set (`pi.getActiveTools()`, `pi.setActiveTools()`) is the set of tools declared to the model. `pi.getAllTools()` reports each tool's `exposure`, `namespace`, and `annotations`.
165
165
 
@@ -177,7 +177,7 @@ pi.on("tool_call", async (event, ctx) => {
177
177
  });
178
178
  ```
179
179
 
180
- A tool that orchestrates other tools can adjust what the model sees while it is active with `prepareLoadout(loadout)`. It runs whenever the active tools change and receives the declared tools, the callable tools, and every registered tool with its exposure and namespace. It returns replacement `descriptions` for declared tools (including its own) and `hiddenDeclarations`: active tools whose declarations requests leave out while they stay active and callable. `codemode` and `tool_search` use only this hook, `exposure`, and `ctx.executeTool()`, so another tool can implement the same behavior under a different name.
180
+ A tool that orchestrates other tools can adjust what the model sees while it is active with `prepareLoadout(loadout)`. It runs whenever the active tools change and receives the declared tools, the callable tools, and every registered tool with its exposure and namespace. It returns replacement `descriptions` for declared tools (including its own) and `hiddenDeclarations`: active tools whose declarations requests leave out while they stay active and callable. `codemode` uses only this hook, `exposure`, and `ctx.executeTool()`, so another tool can implement the same behavior under a different name.
181
181
 
182
182
  ### Activate tools dynamically
183
183
 
@@ -187,7 +187,7 @@ Pi records the initial prompt and tool set in the transcript's first system mess
187
187
 
188
188
  ### MCP servers
189
189
 
190
- `pi.registerMcpServer(name, config)` adds an MCP server for the current session. `config` has the shape of an `mcpServers` entry in [`mcp.json`](mcp.md): `command`, `args`, `env`, and `cwd` for stdio servers, `url`, `headers`, and `oauth` for HTTP servers, plus `exposure`, `toolExposure`, `enabled`, and `timeout`.
190
+ `pi.registerMcpServer(name, config)` adds an MCP server for the current session. `config` has the shape of an `mcpServers` entry in [`mcp.json`](mcp.md): `command`, `args`, `env`, and `cwd` for stdio servers, `url`, `headers`, and `oauth` for HTTP servers, plus `exposure`, `toolExposure`, `description`, `enabled`, and `timeout`.
191
191
 
192
192
  ```typescript
193
193
  pi.registerMcpServer("jira", { url: "https://mcp.example.com/jira", exposure: "codemode" });
package/docs/index.md CHANGED
@@ -30,7 +30,7 @@ Use the [Quickstart customization chooser](quickstart.md#choose-how-to-customize
30
30
 
31
31
  ## Find reference and setup information
32
32
 
33
- Use the reference pages to look up [CLI options](cli.md), [settings](settings.md), [provider authentication](providers.md), [keybindings](keybindings.md), and [environment variables](environment-variables.md).
33
+ Use the reference pages to look up [CLI options](cli.md), [settings](settings.md), [providers](providers.md), [keybindings](keybindings.md), and [environment variables](environment-variables.md).
34
34
 
35
35
  For platform-specific help, see [Terminal Setup](terminal-setup.md), [Windows](windows.md), [tmux](tmux.md), [Termux on Android](termux.md), or [Containerization](containerization.md).
36
36
 
package/docs/mcp.md CHANGED
@@ -1,10 +1,37 @@
1
1
  # MCP Servers
2
2
 
3
- Pi connects to [Model Context Protocol](https://modelcontextprotocol.io) servers over stdio or streamable HTTP and makes their tools available to the model.
3
+ Pi connects to [Model Context Protocol](https://modelcontextprotocol.io) servers over stdio or streamable HTTP and makes their tools and resources available to the model.
4
+
5
+ ## Quick setup
6
+
7
+ Add a local stdio server, check the connection, then start Pi:
8
+
9
+ ```bash
10
+ pi mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem .
11
+ pi mcp list
12
+ pi
13
+ ```
14
+
15
+ For a remote server:
16
+
17
+ ```bash
18
+ pi mcp add docs --url https://example.com/mcp --bearer-token-env-var DOCS_TOKEN
19
+ pi mcp list
20
+ ```
21
+
22
+ These commands add user-level servers by default. Add `--local` or `-l` to write the project configuration instead:
23
+
24
+ ```bash
25
+ pi mcp add -l tools --env API_KEY='${TOOLS_KEY}' -- uvx tools-mcp
26
+ ```
27
+
28
+ Use `/mcp` inside an interactive session to inspect connections, sign in, reconnect, change exposure, or enable and disable servers. Run `/reload` after adding, removing, or changing a server outside the session.
4
29
 
5
30
  ## Configure servers
6
31
 
7
- Add servers to `~/.pi/agent/mcp.json`, or to `.pi/mcp.json` in a project. The format matches other MCP clients, so existing `mcpServers` entries can be copied over:
32
+ Pi reads user-level servers from `~/.pi/agent/mcp.json` and project servers from `.pi/mcp.json`. Project configuration is read only after [project trust](security.md#understand-project-trust) is granted. A project entry replaces a user-level entry with the same name.
33
+
34
+ The format matches other MCP clients:
8
35
 
9
36
  ```json
10
37
  {
@@ -16,77 +43,66 @@ Add servers to `~/.pi/agent/mcp.json`, or to `.pi/mcp.json` in a project. The fo
16
43
  "docs": {
17
44
  "url": "https://example.com/mcp",
18
45
  "headers": { "Authorization": "Bearer ${DOCS_TOKEN}" },
19
- "exposure": "direct"
46
+ "description": "Search and read the product documentation"
20
47
  }
21
48
  }
22
49
  }
23
50
  ```
24
51
 
25
- - stdio servers take `command`, `args`, `env`, and `cwd`. Relative `cwd` resolves against the session directory. A leading `~/` in `command`, an argument, or `cwd` names the home directory.
26
- - HTTP servers take `url`, `headers`, and `oauth` (see [Sign in with OAuth](#sign-in-with-oauth)). The legacy SSE transport is not supported.
27
- - `env` and `headers` values can reference environment variables (`${NAME}`) or commands (`!command`), like provider API keys.
28
- - `timeout` sets the per-request timeout in seconds (default 60). Progress notifications from the server reset it.
29
- - `enabled: false` keeps an entry without connecting to it.
52
+ Stdio servers use `command`, `args`, `env`, and `cwd`. Relative `cwd` values resolve against the session directory. A leading `~/` in `command`, an argument, or `cwd` names the home directory.
30
53
 
31
- Project entries replace global entries with the same name. A project `mcp.json` is only read after the project is trusted, because stdio servers run commands.
54
+ HTTP servers use `url`, `headers`, and `oauth` (see [Authenticate with OAuth](#authenticate-with-oauth)). The legacy SSE transport is not supported.
32
55
 
33
- `pi mcp add` and `pi mcp remove` edit the file from a shell (see [MCP commands](cli.md#mcp-commands)):
56
+ Both server types support:
34
57
 
35
- ```bash
36
- pi mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem .
37
- pi mcp add docs --url https://example.com/mcp --bearer-token-env-var DOCS_TOKEN --exposure direct
38
- pi mcp add -l tools --env API_KEY='${TOOLS_KEY}' -- uvx tools-mcp
39
- pi mcp remove docs
40
- ```
58
+ - `timeout`: per-request timeout in seconds (default 60). Progress notifications reset it.
59
+ - `enabled: false`: keep the entry without connecting to it.
60
+ - `exposure` and `toolExposure`: control how tools reach the model (see [Control tool exposure](#control-tool-exposure)).
61
+ - `description`: what the server offers, in a sentence. It lists the server in the system prompt (see [Control tool exposure](#control-tool-exposure)), tool search ranks the server's tools by it, and codemode's `describeNamespace()` returns it. Without it, the first line of the server instructions is used once the server connects.
62
+
63
+ Keep personal servers and servers with credentials in the user-level file. Use the project file only for servers the project requires, and only in trusted projects.
41
64
 
42
- Rules that are easy to get wrong:
65
+ ### Configuration rules
43
66
 
44
- - Server names may only contain letters, digits, `_`, and `-`. Tools are named `mcp__<server>__<tool>`.
45
- - `type` is optional: a `command` makes a stdio server and a `url` a streamable HTTP server. When present, it must be `stdio`, `http`, or `streamable-http`. `sse` is rejected; most servers that document an SSE endpoint also serve streamable HTTP, often at `/mcp` instead of `/sse`.
46
- - `command` is a single executable and `args` its arguments, not one shell string.
47
- - Keep secrets out of the file: use `${NAME}` for environment variables, as in `"Authorization": "Bearer ${GITHUB_TOKEN}"`, or `!command` to run a command. A command must make up the whole value, so it has to print the header value itself: `"Authorization": "!echo Bearer $(gh auth token)"`.
48
- - Invalid entries are skipped and reported; the other servers still connect.
67
+ - Server names may contain only letters, digits, `_`, and `-`. Tools are named `mcp__<server>__<tool>`, with every character other than letters, digits, and `_` replaced by `_`; tools of a server whose names then collide all get a hash suffix. Server names that differ only in `-` and `_` count as the same server: a second one is rejected, and a `mcp.json` server overrides a registered one.
68
+ - `type` is optional. A `command` selects stdio and a `url` selects streamable HTTP. When present, `type` must be `stdio`, `http`, or `streamable-http`.
69
+ - `sse` is rejected. Servers that document an SSE endpoint often also provide streamable HTTP, commonly at `/mcp` instead of `/sse`.
70
+ - `command` is one executable and `args` contains its arguments. It is not a shell command string.
71
+ - `env` and `headers` values can use environment variables such as `${GITHUB_TOKEN}`. They can also run a command with `!command`, but the command must make up the whole value, for example `"Authorization": "!echo Bearer $(gh auth token)"`.
72
+ - Invalid entries are reported and skipped without preventing other servers from connecting.
49
73
 
50
- ## Set up servers
74
+ `pi mcp add` and `pi mcp remove` cover common changes from a shell. See [MCP commands](cli.md#mcp-commands) for their options.
51
75
 
52
- When asked to add an MCP server, the agent should:
76
+ ### Inspect or change a server
53
77
 
54
- 1. Add simple servers with `pi mcp add` (add `-l` for the project file), or edit `mcp.json` directly for settings the command does not cover. Put personal servers and servers with credentials in `~/.pi/agent/mcp.json`. Use the project `.pi/mcp.json` only for servers the project itself needs, and only in trusted projects.
55
- 2. Convert entries written for other clients:
56
- - Claude Desktop, Claude Code, and Cursor use the same `mcpServers` shape; copy the entry.
57
- - VS Code uses a top-level `servers` object and `inputs` prompts; move the entry under `mcpServers` and replace `${input:...}` with `${NAME}` environment variables.
58
- - Codex uses TOML (`[mcp_servers.<name>]` with `command`, `args`, `env`, or `url`); write the same fields as JSON.
59
- - opencode uses `"type": "local"` with `command` as an array (split it into `command` and `args`), `"type": "remote"` for URLs, `environment` for `env`, and `{env:NAME}` for `${NAME}`.
60
- 3. Run `pi mcp list` to check the entry. It connects to every enabled server and prints the state, the tools, and errors such as the stderr of a stdio server that failed to start. It exits with 1 while anything is wrong.
61
- 4. For a server that needs a sign-in, run `pi mcp login <server>`. It opens the authorization page in the user's browser and waits until the user approves access; tell the user to approve it. A running session uses the new credentials on its next turn.
62
- 5. Tell the user to run `/reload` (or start a new session) so the running session connects to added or changed servers.
78
+ `/mcp` lists configured servers with their state, tool count, exposure, and configuration source. Servers that need attention appear first. Select a server to inspect its tools and connection details, reconnect, sign in or out, change exposure, or enable and disable it.
63
79
 
64
- Pi connects when a session starts. The first prompt waits up to 10 seconds for startup connections; the tools of servers that take longer become available once they connect. HTTP connections that fail with a network error or a transient status (408, 429, 5xx) are retried twice. A server that drops its connection shows as disconnected and is reconnected on the next call. When a server announces that its tool list changed, new tools are added and withdrawn tools become unreachable until the server offers them again.
80
+ Exposure and enabled-state changes are saved to the file that defines the server without replacing unrelated content. Disabled servers remain listed. Outside the interactive TUI, `/mcp` prints server status; `/mcp login <server>`, `/mcp logout <server>`, and `/mcp reconnect <server>` perform those actions directly.
65
81
 
66
- Config errors, servers that failed to connect, and servers that need a sign-in are reported once after startup.
82
+ Shell commands work without a session: `pi mcp add`, `pi mcp remove`, `pi mcp list`, `pi mcp login`, and `pi mcp logout`. Shell commands do not load extensions.
67
83
 
68
- Log messages servers send with MCP logging notifications are appended to `~/.pi/agent/mcp.log` as `<time> [<server>] <level> <logger>: <message>`. The file is moved to `mcp.log.1` when it grows past 5 MB.
84
+ ### Diagnose connection problems
69
85
 
70
- ## Manage servers
86
+ Run `pi mcp list` to connect to every enabled server and print its state, tools, and errors. It exits with status 1 when an entry is invalid or an enabled server is not connected. `/mcp` shows the full connection error and the tail of stderr from a failed stdio server.
71
87
 
72
- `/mcp` opens the server manager. It lists every configured server with its state, tool count, exposure, and whether it comes from the global or the project `mcp.json`; servers that need attention come first. Select a server to:
88
+ Pi reports configuration errors, failed connections, and required sign-ins once after startup. Server logging notifications are appended to `~/.pi/agent/mcp.log` as `<time> [<server>] <level> <logger>: <message>`. The file moves to `mcp.log.1` after it grows past 5 MB.
73
89
 
74
- - sign in, for OAuth servers that need it (see [Sign in with OAuth](#sign-in-with-oauth))
75
- - see its tools, its command or URL, and the full connection error, including the tail of a stdio server's stderr
76
- - reconnect
77
- - sign out, which deletes the stored OAuth credentials
78
- - change its exposure (see [Exposure](#exposure))
79
- - disable or enable it
90
+ Pi connects every enabled server in the background when a session starts. A server's tools appear once it connects; the `codemode` description does not list them, so it does not change when servers connect. The first prompt waits up to 10 seconds only for servers with `direct` tools, which must be declared in its request. Other servers are waited for when they are needed: a codemode script waits for the servers it names (`mcp__<server>`) and, when it calls `searchTools()` or reads `ALL_TOOLS`, for all of them; `tool_search` and the resource tools also wait for all of them. HTTP network errors and transient statuses (408, 429, and 5xx) are retried twice. A dropped connection is shown as disconnected and reconnects on the next call. When a server announces a changed tool list, new tools are added and withdrawn tools become unreachable.
80
91
 
81
- Exposure changes and enabling or disabling are saved to the `mcp.json` that defines the server; other content of the file is kept. Disabled servers stay listed so they can be enabled again.
92
+ Stopping a stdio server closes its stdin, sends SIGTERM, then sends SIGKILL to its process group. This also stops servers launched through wrappers such as `npx` or `uvx`.
82
93
 
83
- Outside the interactive TUI, `/mcp` prints the server status. `/mcp login <server>`, `/mcp logout <server>`, and `/mcp reconnect <server>` run those actions directly.
94
+ ## Migrate configuration from another client
84
95
 
85
- From a shell, `pi mcp add`, `pi mcp remove`, `pi mcp list`, `pi mcp login <server>`, and `pi mcp logout <server>` manage servers without a session (see [MCP commands](cli.md#mcp-commands)).
96
+ Move the converted entry under `mcpServers` in `mcp.json`, then run `pi mcp list` to validate it.
86
97
 
87
- Stopping a stdio server closes its stdin, then sends SIGTERM and finally SIGKILL to its whole process group, so servers started through wrappers such as `npx` or `uvx` do not linger.
98
+ | Client | Conversion |
99
+ |---|---|
100
+ | Claude Desktop, Claude Code, or Cursor | Copy the existing `mcpServers` entry. |
101
+ | VS Code | Move an entry from the top-level `servers` object and replace `${input:...}` prompts with `${NAME}` environment variables. |
102
+ | Codex | Convert `[mcp_servers.<name>]` TOML fields such as `command`, `args`, `env`, and `url` to JSON. |
103
+ | OpenCode | Convert `"type": "local"` to a stdio entry, split its `command` array into `command` and `args`, rename `environment` to `env`, and replace `{env:NAME}` with `${NAME}`. Convert `"type": "remote"` to a URL entry. |
88
104
 
89
- ## Sign in with OAuth
105
+ ## Authenticate with OAuth
90
106
 
91
107
  Remote servers that use OAuth, such as Sentry, need no credentials in `mcp.json`:
92
108
 
@@ -98,11 +114,13 @@ Remote servers that use OAuth, such as Sentry, need no credentials in `mcp.json`
98
114
  }
99
115
  ```
100
116
 
101
- When such a server rejects the connection, `/mcp` shows it as needing sign-in. Select it and choose "Sign in" (or run `/mcp login sentry`, or `pi mcp login sentry` in a shell) to open the authorization page in your browser. After you approve access, the browser redirects to a temporary server on `127.0.0.1` and pi connects. If the browser runs on another machine, for example over SSH, paste the URL it was redirected to into the sign-in screen instead.
117
+ When the server rejects an unauthenticated connection, `/mcp` shows that it needs sign-in. Select "Sign in", run `/mcp login sentry`, or run `pi mcp login sentry`. Pi opens the authorization page and waits for approval. If the browser runs on another machine, such as over SSH, paste its redirected URL into the sign-in screen. A running session uses the new credentials on its next turn.
118
+
119
+ Pi registers itself with the authorization server, stores tokens in `~/.pi/agent/mcp-auth.json`, and refreshes access tokens when they expire or the server rejects them. If a server later requests additional scope, Pi asks for sign-in again. Signing out deletes the stored credentials.
102
120
 
103
- Pi registers itself with the authorization server (dynamic client registration), stores tokens in `~/.pi/agent/mcp-auth.json`, and refreshes access tokens automatically when they expire or the server rejects them. If the server later asks for more scope than was granted, it shows as needing sign-in again, and signing in requests the new scope. "Sign out" in `/mcp` (or `/mcp logout sentry`) deletes the stored credentials.
121
+ Credentials belong to a server name and URL. Servers with the same URL under different names, such as one per account, sign in separately; servers with the same name and URL in different `mcp.json` files share one sign-in.
104
122
 
105
- OAuth applies to HTTP servers without an `Authorization` header. For authorization servers that do not support dynamic client registration, configure a pre-registered client:
123
+ OAuth applies to HTTP servers without an `Authorization` header. For a server that does not support dynamic client registration, configure a registered client:
106
124
 
107
125
  ```json
108
126
  {
@@ -115,21 +133,55 @@ OAuth applies to HTTP servers without an `Authorization` header. For authorizati
115
133
  }
116
134
  ```
117
135
 
118
- The redirect URI must match the one registered for the client. `callbackPort` fixes it to `http://127.0.0.1:<port>/callback`. For another redirect URI, set `callbackUrl`, for example `"callbackUrl": "http://localhost:8080/oauth/callback"`. It must be an `http` URI on `localhost`, `127.0.0.1`, or `[::1]`, and is sent exactly as written. Without a port in `callbackUrl`, pi listens on `callbackPort`, or on a free port, and adds it to the URI; authorization servers accept any port for loopback redirects (RFC 8252). `clientSecret` is optional and can reference environment variables or commands.
136
+ The redirect URI must match the registered URI. `callbackPort` uses `http://127.0.0.1:<port>/callback`. To use another URI, set `callbackUrl`; it must use HTTP on `localhost`, `127.0.0.1`, or `[::1]`. Pi sends it exactly as written. When `callbackUrl` omits a port, Pi uses `callbackPort` or a free port and adds it to the URI, as allowed for loopback redirects by RFC 8252. `clientSecret` is optional and can use an environment variable or command.
119
137
 
120
- `scope` sets the scopes to request, separated by spaces, for servers that do not advertise the ones they need. Without it, pi requests the scopes the server advertises. When a server later asks for more scope, pi requests those on top of `scope`.
138
+ Set `scope` to a space-separated list for servers that do not advertise their required scopes. Otherwise, Pi requests the advertised scopes. Later scope requests are added to the configured value.
121
139
 
122
- ## Exposure
140
+ Pi registers as `pi`. Some servers only accept registrations from known clients. Set `clientName` to send another name:
123
141
 
124
- Each server's tools are registered as `mcp__<server>__<tool>`. The `exposure` setting controls how the model reaches them:
142
+ ```json
143
+ {
144
+ "mcpServers": {
145
+ "figma": { "url": "https://mcp.figma.com/mcp", "oauth": { "clientName": "Claude Code" } }
146
+ }
147
+ }
148
+ ```
125
149
 
126
- - `codemode` (default): the tools are callable from [`codemode`](cli.md#tools) scripts and listed in the `codemode` tool's description, but are not declared to the model. Large MCP tool lists stay out of the model's tool declarations, and scripts can call several MCP tools, in parallel if needed, while returning only the part of the result the model needs. Pi activates the `codemode` tool when such a server connects. Large servers do not fill the description: declarations share a token budget, and scripts find the remaining tools with `searchTools()` (see [`codemode`](cli.md#tools)).
127
- - `codemode-deferred`: like `codemode`, but the tools are not listed in the `codemode` tool's description either; it only names the server and its tool count. Scripts call them by name and find them with `searchTools()` or in `ALL_TOOLS`. Use it for large servers that codemode scripts use rarely.
128
- - `deferred`: the tools are not declared to the model until the [`tool_search`](cli.md#tools) tool loads them. The model searches, and the matches are declared from its next call on and called directly, without codemode. Pi activates the `tool_search` tool when such a server connects. Use it for large servers without codemode.
129
- - `direct`: the tools are declared to the model like built-in tools, and are also callable from codemode.
130
- - `hidden`: the tools are registered but cannot be called.
150
+ The name is only sent when Pi registers a client. To register again under a new name, sign out first.
131
151
 
132
- `toolExposure` sets the exposure of single tools and overrides `exposure` for them. Keys are tool names as the server offers them, or patterns where `*` matches any characters. An exact name wins over patterns; among patterns, the first match in the object wins. With `hidden` as the server's exposure, only the listed tools are reachable:
152
+ Pi finds the authorization server through the server's protected resource metadata (RFC 9728) and checks that the authorization server's metadata names the expected issuer (RFC 8414). Some servers advertise the wrong authorization server or none, so sign-in opens a page that does not exist. Set `authServerMetadataUrl` to the metadata document of the right authorization server:
153
+
154
+ ```json
155
+ {
156
+ "mcpServers": {
157
+ "example": {
158
+ "url": "https://mcp.example.com/mcp",
159
+ "oauth": { "authServerMetadataUrl": "https://example.okta.com/.well-known/openid-configuration" }
160
+ }
161
+ }
162
+ }
163
+ ```
164
+
165
+ Pi uses that document instead of discovery and trusts it as configured, so only point it at a document you trust. The URL must use HTTPS, except on `localhost`, `127.0.0.1`, or `[::1]`.
166
+
167
+ ## Control tool exposure
168
+
169
+ Each server tool is registered as `mcp__<server>__<tool>`. The server's `exposure` determines how the model reaches it:
170
+
171
+ | Exposure | Behavior | Typical use |
172
+ |---|---|---|
173
+ | `codemode` (default) | Callable from [`codemode`](cli.md#tools) scripts, but neither declared to the model nor listed in the codemode description. Scripts find tools with `searchTools()`, `describeTool()`, or `ALL_TOOLS`. | General MCP servers, especially when scripts should combine or filter calls. |
174
+ | `deferred` | Not declared until [`tool_search`](cli.md#tools) loads a match for the next model call. | Large servers whose tools should be called directly after discovery. |
175
+ | `direct` | Declared to the model like a built-in tool and also callable from codemode. | Small, frequently used tool sets. |
176
+ | `hidden` | Registered but unreachable. | Servers or tools that should remain unavailable. |
177
+
178
+ `codemode-deferred` is accepted as an alias for `codemode`.
179
+
180
+ Servers with `codemode` or `deferred` tools are listed in the `mcp_servers` section of the system prompt, with how their tools are reached and one line from the configured `description` or, once connected, from the server instructions. Pi updates the section when a prompt starts, after waiting for servers with `direct` tools. When it changed, for example because a server connected and its summary became available, Pi appends the new section to the conversation instead of changing tool declarations, so earlier messages stay cached. `describeNamespace()` and the `namespace` option of `searchTools()` accept `mcp__dev-radius`, `mcp__dev_radius`, `dev-radius`, or `dev_radius`.
181
+
182
+ Pi activates `codemode` when a server with `codemode` exposure connects. It activates `tool_search` for a server with `deferred` exposure. To make the model see a tool without searching, give it `direct` exposure with `toolExposure`.
183
+
184
+ `toolExposure` overrides the server exposure for individual tools. Keys are exact server tool names or patterns where `*` matches any characters. Exact names win over patterns; among patterns, the first match wins. A server with `hidden` exposure can expose only selected tools:
133
185
 
134
186
  ```json
135
187
  {
@@ -147,42 +199,50 @@ Each server's tools are registered as `mcp__<server>__<tool>`. The `exposure` se
147
199
  }
148
200
  ```
149
201
 
150
- `pi mcp list` marks tools whose exposure differs from the server's, and the Tools view in `/mcp` shows it too.
202
+ `pi mcp list` marks tools whose exposure differs from their server. The Tools view in `/mcp` also shows the effective exposure.
151
203
 
152
- Tools that are not declared (`codemode`, `codemode-deferred`, and `deferred` exposure) are reachable through either tool: codemode scripts can call all of them, and `tool_search` can load any of them. For example, with `codemode` active, scripts can call the tools of a `deferred` server, and with `tool_search` active, the model can load the tools of a `codemode` server.
204
+ Tools with `codemode` or `deferred` exposure can be reached through either indirect mechanism: codemode scripts can call them, and `tool_search` can load them. Codemode calls do not depend on the active tool set, so they remain available after `/tree`, resume, and fork. Tools loaded by `tool_search` are recorded in the transcript and remain declared on that branch.
153
205
 
154
- Tools called from codemode scripts do not depend on the active tool set, so they stay callable after `/tree`, resume, and fork. Tools loaded by `tool_search` are recorded in the transcript like any other tool change and stay declared on that branch. To keep `codemode` active without MCP servers too, add `"defaultTools": ["+codemode"]` to [settings](settings.md#tools). To keep pi from activating the `codemode` tool, set `"autoEnableCodemode": false` at the top level of `mcp.json`, next to `mcpServers`. A project `mcp.json` value overrides the global one. Pi warns once when neither `codemode` nor `tool_search` is active, since the tools then cannot be called.
206
+ To keep `codemode` active without MCP servers, add `"defaultTools": ["+codemode"]` to [settings](settings.md#tools). To prevent automatic codemode activation, set `"autoEnableCodemode": false` beside `mcpServers`. A project value overrides the user-level value. Pi warns once when neither `codemode` nor `tool_search` is active and non-direct tools cannot be called.
155
207
 
156
- Text results over 20KB reach the model with the middle cut out, in the format Codex uses: the start and end of the text around a `…N chars truncated…` marker. The full text is saved to a temp file whose path the result names. Codemode scripts always receive the whole result, so a script can filter a large result down to what the model needs.
208
+ Text results over 20 KB reach the model with their middle removed around a `…N chars truncated…` marker. The full text is saved to a temporary file named in the result. Codemode scripts receive the complete result and can reduce it before returning output to the model.
157
209
 
158
- Codemode scripts receive an MCP tool's whole `CallToolResult` (`content` blocks as sent by the server, `structuredContent`, and `isError`), and the `codemode` description declares it as `CallToolResult<T>`. A result with `isError` resolves in scripts and is reported to the model as an error for direct calls. `image(result.content[0])` forwards an image block to the model. The server's `instructions` describe its tools in the `codemode` description.
210
+ Codemode scripts receive the complete MCP `CallToolResult`, including `content`, `structuredContent`, and `isError`. A result with `isError` resolves inside scripts but is reported as an error for direct calls. `image(result.content[0])` forwards an image block. Server instructions are not part of any tool description; scripts read them with `describeNamespace("mcp__<server>")`, which also returns the server's tool names.
159
211
 
160
- ## Resources
212
+ ## Use resources
161
213
 
162
- When a connected server offers [resources](https://modelcontextprotocol.io/specification/2025-11-25/server/resources), pi adds the resource tools Codex and opencode use:
214
+ When a connected server offers [resources](https://modelcontextprotocol.io/specification/2025-11-25/server/resources), Pi adds the resource tools used by Codex and OpenCode:
163
215
 
164
- - `list_mcp_resources` lists resources as JSON: `{ server?, resources: [{ server, uri, name, ... }], nextCursor? }`. With `server`, it lists one page of that server, and `cursor` continues with the next one. Without, it lists every resource of every server.
165
- - `list_mcp_resource_templates` lists URI templates for resources the servers do not list, in the same way.
166
- - `read_mcp_resource` reads a resource given `server` and `uri`. Text resources reach the model as text and images as images; other binary resources are saved to temp files, and the model sees the file path. Scripts receive `{ server, uri, contents }`.
216
+ - `list_mcp_resources` lists resources as JSON: `{ server?, resources: [{ server, uri, name, ... }], nextCursor? }`. With `server`, it lists one page; `cursor` continues with the next page. Without `server`, it lists every resource from every server.
217
+ - `list_mcp_resource_templates` lists URI templates for resources the servers do not list directly.
218
+ - `read_mcp_resource` reads a resource by `server` and `uri`. Text reaches the model as text and images as images. Other binary resources are saved to temporary files, and the model receives the path. Scripts receive `{ server, uri, contents }`.
167
219
 
168
- The tools reach every enabled server with resources whose exposure is not `hidden`, and take the widest exposure among them: `direct` if one of the servers is direct, else `codemode`, else `codemode-deferred`, else `deferred`. Resource links in tool results name `read_mcp_resource` and the server.
220
+ These tools reach every enabled, non-hidden server with resources. Their exposure is the widest exposure among those servers: `direct`, then `codemode` or `deferred`. Resource links in tool results identify `read_mcp_resource` and the server.
169
221
 
170
- Resources for MCP Apps (`ui://` URIs or `text/html;profile=mcp-app`) are left out of the listings, since pi does not render them, and so are resource icons.
222
+ Resources for MCP Apps, identified by `ui://` URIs or `text/html;profile=mcp-app`, are omitted because Pi does not render them. Resource icons are also omitted.
171
223
 
172
- Reading and listing resources is retried once after a transient HTTP error (408, 429, 5xx). Tool calls are not retried, since the server may have run them.
224
+ Reading and listing resources is retried once after a transient HTTP error (408, 429, or 5xx). Tool calls are not retried because the server may already have performed them.
173
225
 
174
226
  ## Permissions
175
227
 
176
- Every MCP call goes through pi's tool pipeline, so `tool_call` and `tool_result` extension handlers, including permission gates, apply to MCP tools. Calls made from codemode scripts carry the `codemode` call's id as `parentToolCallId`. `pi.getAllTools()` reports the tool annotations servers declare (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`), so a permission extension can confirm only calls that change something (see [Extensions](extensions.md#tool-exposure)). The resource tools are marked read-only.
228
+ Every MCP call passes through Pi's tool pipeline. Extension `tool_call` and `tool_result` handlers, including permission gates, therefore apply to MCP tools. Calls made from codemode scripts carry the codemode call ID as `parentToolCallId`.
229
+
230
+ `pi.getAllTools()` reports the annotations declared by each server: `readOnlyHint`, `destructiveHint`, `idempotentHint`, and `openWorldHint`. Permission extensions can use these hints to decide which calls require confirmation (see [Tool exposure](extensions.md#tool-exposure)). Resource tools are marked read-only.
231
+
232
+ ## Extensions and SDK
233
+
234
+ ### Add servers from extensions
235
+
236
+ Extensions can add servers for the current session with `pi.registerMcpServer(name, config)`, using the same shape as an `mcpServers` entry (see [MCP servers in extensions](extensions.md#mcp-servers)). Registered servers connect like configured servers and appear in `/mcp` with the extension as their source.
177
237
 
178
- ## Servers from extensions
238
+ Changes to enabled state or exposure apply only to the current session. A file-configured server with the same name takes precedence, and `/mcp` lists the overridden registration. `pi mcp` shell commands do not load extensions and only see file-configured servers.
179
239
 
180
- Extensions can add servers for the current session with `pi.registerMcpServer(name, config)`, using the same config shape as `mcp.json` (see [Extensions](extensions.md#mcp-servers)). They connect like configured servers and appear in `/mcp` with the extension as their source. Enabling, disabling, and exposure changes for them apply to the current session only. A server in `mcp.json` with the same name takes precedence; `/mcp` lists the overridden registration. `pi mcp` shell commands do not load extensions and only see `mcp.json` servers.
240
+ ### Replace the built-in MCP support
181
241
 
182
- ## Other MCP extensions
242
+ An installed extension that registers `/mcp`, such as `pi-mcp-adapter`, replaces the built-in MCP support for sessions. Pi then does not read `mcp.json` or connect its servers in a session, and `/mcp` belongs to the extension. Remove the extension to restore the built-in behavior. To disable built-in MCP support without a replacement, disable `mcp` under Built-in in `pi config`, or set `"extensions": ["-builtin:mcp"]` in [settings](settings.md#resources).
183
243
 
184
- An installed extension that registers the `/mcp` command, such as `pi-mcp-adapter`, replaces the built-in MCP support: pi then neither reads `mcp.json` in sessions nor connects servers, and `/mcp` belongs to that extension. Remove the extension to use the built-in support. To turn off the built-in support without installing another extension, disable `mcp` under Built-in in `pi config`, or set `"extensions": ["-builtin:mcp"]` in [settings](settings.md#resources); `pi mcp` shell commands still work. Likewise, an extension that registers a tool named `codemode` or `tool_search` replaces the built-in tool of that name. `pi mcp` shell commands always use the built-in support.
244
+ An extension that registers `codemode` or `tool_search` similarly replaces the built-in tool with that name. Shell-level `pi mcp` commands always use the built-in implementation.
185
245
 
186
- ## SDK
246
+ ### Use MCP from the SDK
187
247
 
188
- SDK sessions do not load the built-in extensions. Add the MCP extension, the codemode extension for `codemode` and `codemode-deferred` servers, and the tool search extension for `deferred` servers to the resource loader. See [SDK](sdk.md#codemode-mcp).
248
+ SDK sessions do not load built-in extensions. Add the MCP extension, the codemode extension for `codemode` servers, and the tool-search extension for `deferred` servers to the resource loader. See [Codemode and MCP](sdk.md#codemode-mcp).
package/docs/models.md CHANGED
@@ -18,7 +18,7 @@ Browse the [model catalog](https://pi.dev/models) for current providers, model I
18
18
 
19
19
  Run `/login` and select a provider. Pi stores credentials in [`auth.json`](configuration.md#agent-directory). Run `/logout` to remove stored credentials for a provider.
20
20
 
21
- You can instead provide an API key through the provider's environment variable. This is useful in CI and other environments where Pi should not write credentials. [Provider Authentication](providers.md) lists the variables and cloud-provider setup.
21
+ You can instead provide an API key through the provider's environment variable. This is useful in CI and other environments where Pi should not write credentials. [Providers](providers.md) lists the variables and provider-specific setup.
22
22
 
23
23
  When several credential sources are configured, Pi uses a runtime `--api-key` first, then a stored `auth.json` credential, an `apiKey` from `models.json`, and finally the provider's environment variables or ambient cloud credentials. Provider extensions can define their own authentication behavior.
24
24
 
@@ -131,10 +131,31 @@ const result = await models.classify(jev, {
131
131
  return result.answers;
132
132
  ```
133
133
 
134
+ [Codemode](codemode.md#classify) describes the question and answer types.
135
+
134
136
  When the service reports token counts, as all System One services do, `result.usage` carries them with their cost. Pi adds the usage of a script's classifier calls to the `codemode` tool result, so it counts toward the session cost in the footer and `/session`. The cost uses the model's catalog price; models without one, such as TypeSafe's direct `jev-latest`, report tokens at no cost.
135
137
 
136
138
  Extensions call classifiers through `ctx.modelRegistry.classify()`, without codemode. [Virtual models](virtual-models.md#route-requests) can use them to route requests; see the `jev-router.ts` example.
137
139
 
140
+ ## Use image models
141
+
142
+ Image models generate images from a prompt and optional input images. Pi lists OpenRouter's image models, such as `google/gemini-2.5-flash-image` and `black-forest-labs/flux.2-pro`, under the `openrouter` provider; they use the same `OPENROUTER_API_KEY` or `/login` credential as its chat models.
143
+
144
+ Like classifier models, image models do not appear in `/model`; the model reaches them through the [`codemode`](cli.md#enable-codemode) tool. Scripts list them with `models.getAvailableOfType("image")` and call `models.generateImages(model, { input })`. The result's `output` holds base64 image blocks, which `image()` attaches to the `codemode` result so the model sees them:
145
+
146
+ ```js
147
+ const painter = await models.getModelOfType("image", "openrouter", "google/gemini-2.5-flash-image");
148
+ const result = await models.generateImages(painter, {
149
+ input: [{ type: "text", text: "A red fox in the snow, watercolor" }],
150
+ });
151
+ if (result.stopReason !== "stop") return result.errorMessage;
152
+ for (const block of result.output) if (block.type === "image") image(block);
153
+ ```
154
+
155
+ `input` can also contain `{ type: "image", data, mimeType }` blocks to edit or use as references. Pi adds the usage of a script's image calls to the `codemode` tool result, like classifier calls. Generated images are not saved to disk. [Codemode](codemode.md#generate-images) describes the full API.
156
+
157
+ Extensions generate images through `ctx.modelRegistry.generateImages()`, without codemode.
158
+
138
159
  ## Add a custom provider
139
160
 
140
161
  Use an extension when the provider needs custom streaming, model discovery, or authentication behavior. See [Custom Providers](custom-provider.md) for the extension workflow.
package/docs/providers.md CHANGED
@@ -1,4 +1,4 @@
1
- # Provider Authentication
1
+ # Providers
2
2
 
3
3
  Most hosted providers support one or both of these authentication methods:
4
4
 
@@ -17,8 +17,6 @@ Run `/logout` and select a provider to remove its stored credential. This does n
17
17
 
18
18
  `auth.json` can contain API keys and OAuth tokens. Keep it private and do not commit it.
19
19
 
20
- Radius authentication uses its gateway catalog and caches refreshed model metadata for later offline startup. A custom Radius gateway configured in `models.json` uses its own catalog rather than inheriting the public `radius.pi.dev` catalog.
21
-
22
20
  ## Use an API key from the environment
23
21
 
24
22
  Environment variables are useful in CI and anywhere Pi should not store the key. Set the variable before starting Pi:
@@ -28,7 +26,7 @@ export ANTHROPIC_API_KEY=sk-ant-...
28
26
  pi
29
27
  ```
30
28
 
31
- This table covers providers with a single primary API-key variable. Providers that need additional configuration or support ambient credentials are covered under [Cloud providers](#cloud-providers).
29
+ This table covers providers with a single primary API-key variable. Providers that need additional configuration or support ambient credentials are covered under [Provider Specific Config](#provider-specific-config).
32
30
 
33
31
  | Provider | Environment variable |
34
32
  |---|---|
@@ -68,6 +66,8 @@ This table covers providers with a single primary API-key variable. Providers th
68
66
 
69
67
  Anthropic also recognizes `ANTHROPIC_OAUTH_TOKEN` as an API credential and `ANTHROPIC_AUTH_TOKEN` as bearer authentication.
70
68
 
69
+ With no key or token set, Anthropic uses workload identity federation when `ANTHROPIC_FEDERATION_RULE_ID`, `ANTHROPIC_ORGANIZATION_ID` and `ANTHROPIC_IDENTITY_TOKEN_FILE` are set: the Anthropic SDK exchanges the identity token for a short-lived access token and refreshes it itself (re-reading the identity token file, so keep that file fresh for long sessions). `ANTHROPIC_SERVICE_ACCOUNT_ID` and `ANTHROPIC_WORKSPACE_ID` are passed through when set.
70
+
71
71
  ## Load an API key from a command
72
72
 
73
73
  To use a secret manager without writing the resolved key to disk, set a provider's `key` in `auth.json` to a command prefixed with `!`:
@@ -83,9 +83,9 @@ To use a secret manager without writing the resolved key to disk, set a provider
83
83
 
84
84
  Pi runs the command when the key is first needed and caches its standard output for the process lifetime. Empty output, a timeout, or a nonzero exit leaves the key unresolved until Pi restarts.
85
85
 
86
- ## Cloud Providers
86
+ ## Provider Specific Config
87
87
 
88
- The providers below need additional settings or can use credentials supplied by their cloud platform.
88
+ The providers below have additional setup, need additional settings, or can use credentials supplied by their platform.
89
89
 
90
90
  A stored API-key credential can include an `env` object. Its values take priority over the process environment for that provider:
91
91
 
@@ -101,6 +101,18 @@ A stored API-key credential can include an `env` object. Its values take priorit
101
101
  }
102
102
  ```
103
103
 
104
+ ### Radius
105
+
106
+ Radius is a service crafted for Pi by the builders of Pi, Earendil Works. It provides a customizable AI gateway with organization-level controls and analytics built in, and artifacts for sharing what you create with Pi.
107
+
108
+ To get started, run `/login radius` in Pi. This adds Radius as a provider, and its models appear in `/model` like any other provider's.
109
+
110
+ Radius also has an MCP server, so Pi can manage Radius for you.
111
+
112
+ Radius is currently in early alpha and evolving quickly. See [radius.earendil.com](https://radius.earendil.com) for more.
113
+
114
+ Radius authentication uses its gateway catalog and caches refreshed model metadata for later offline startup. A custom Radius gateway configured in `models.json` uses its own catalog rather than inheriting the public `radius.pi.dev` catalog.
115
+
104
116
  ### Azure OpenAI
105
117
 
106
118
  Set an API key plus either a base URL or resource name:
package/docs/sdk.md CHANGED
@@ -113,7 +113,7 @@ Inline extension factories can be supplied through `DefaultResourceLoader`. Give
113
113
 
114
114
  <a id="codemode-mcp"></a>
115
115
 
116
- The CLI loads `codemode`, `tool_search`, and MCP as built-in extensions. SDK sessions do not; add `createCodemodeExtension()`, `createToolSearchExtension()`, and `createMcpExtension()` to the `extensionFactories` of `DefaultResourceLoader`. `codemode` and `tool_search` are registered inactive: enable them through the `defaultTools` setting (`["+codemode", "+tool_search"]` keeps the other default tools), or let the MCP extension activate them: `codemode` for servers with `codemode` or `codemode-deferred` exposure, `tool_search` for servers with `deferred` exposure. The MCP extension connects its servers on `session_start`, so call `session.bindExtensions()`. See [Codemode and MCP](../examples/sdk/14-codemode-mcp.ts).
116
+ The CLI loads `codemode`, `tool_search`, and MCP as built-in extensions. SDK sessions do not; add `createCodemodeExtension()`, `createToolSearchExtension()`, and `createMcpExtension()` to the `extensionFactories` of `DefaultResourceLoader`. `codemode` and `tool_search` are registered inactive: enable them through the `defaultTools` setting (`["+codemode", "+tool_search"]` keeps the other default tools), or let the MCP extension activate them: `codemode` for servers with `codemode` exposure, `tool_search` for servers with `deferred` exposure. The MCP extension connects its servers on `session_start`, so call `session.bindExtensions()`. See [Codemode and MCP](../examples/sdk/14-codemode-mcp.ts).
117
117
 
118
118
  See the focused examples for [models](../examples/sdk/02-custom-model.ts), [tools](../examples/sdk/05-tools.ts), [extensions](../examples/sdk/06-extensions.ts), and [full control](../examples/sdk/12-full-control.ts).
119
119
 
@@ -140,7 +140,7 @@ See the focused examples for [models](../examples/sdk/02-custom-model.ts), [tool
140
140
 
141
141
  ## Resources
142
142
 
143
- - [Choose a Model](models.md) covers model selection and compatible endpoints; [Provider Authentication](providers.md) covers credentials and cloud-provider setup.
143
+ - [Choose a Model](models.md) covers model selection and compatible endpoints; [Providers](providers.md) covers credentials and provider-specific setup.
144
144
  - [Configuration](configuration.md) explains normal discovery and settings; [Settings](settings.md) lists every setting.
145
145
  - [Sessions and Context](sessions.md) explains session behavior; [Session Format](session-format.md) defines persisted entries; [Message Types](message-types.md) defines shared transcript values.
146
146
  - [Extensions](extensions.md), [Skills](skills.md), and [Prompt Templates](prompt-templates.md) document resources supplied through a `ResourceLoader`.
package/docs/settings.md CHANGED
@@ -38,7 +38,7 @@ See [Choose a Model](models.md) for model selection and thinking controls.
38
38
  | Setting | Type | Default | Description |
39
39
  |---|---|---|---|
40
40
  | `defaultTools` | `string[]` | `read`, `bash`, `edit`, `write` | Tools enabled at startup. Plain names replace the defaults; `+name` adds a tool and `-name` removes one. An empty array disables all built-in tools but not extension or SDK tools. |
41
- | `codemode.mode` | `"on"` \| `"only"` | `"on"` | How the `codemode` tool presents tools while it is active. `on`: declared tools get their `codemode` declaration appended to their description, and `codemode` lists only tools that are not declared (MCP `codemode` exposure). `only`: `codemode` lists every tool scripts can call, and active built-in and extension tools are hidden from the model, so it reaches them through `codemode`. |
41
+ | `codemode.mode` | `"on"` \| `"only"` | `"on"` | How the `codemode` tool presents tools while it is active. `on`: declared tools get a note on calling them from scripts appended to their description, and `codemode` lists only tools that are not declared. `only`: `codemode` lists every tool scripts can call, and active built-in and extension tools are hidden from the model, so it reaches them through `codemode`. |
42
42
  | `codemode.inlineBudget` | number | `3000` | Estimated tokens (characters / 4) the `codemode` tool's description may spend on tool declarations. Tools that do not fit are left out and found with `searchTools()`. `0` lists only namespaces. |
43
43
 
44
44
  Available built-in tools are `read`, `bash`, `powershell`, `edit`, `write`, `grep`, `find`, and `ls`. `defaultTools` can also name `codemode` and `tool_search`, which built-in extensions register inactive, and other extension tools registered inactive.
@@ -53,6 +53,8 @@ A list of only `+name` and `-name` entries changes the inherited selection inste
53
53
 
54
54
  This replaces `bash` with `powershell` and enables `grep`: `["-bash", "+powershell", "+grep"]`. Project settings apply on top of user settings: a project list with only `+name` and `-name` entries changes the user's selection, and a project list with a plain name replaces it. In one list, plain names form the selection, and `+name` and `-name` then apply in order.
55
55
 
56
+ `/reload` enables tools newly added to `defaultTools`. It does not disable tools removed from it or re-enable unchanged tools you turned off. `--tools`, `--no-tools`, and `--no-builtin-tools` override `defaultTools`, also on reload.
57
+
56
58
  CLI tool options override this setting for one invocation; `--tools` does not accept `+name` or `-name`. See [Command Line](cli.md#tools).
57
59
 
58
60
  ## Sessions and context
@@ -88,8 +90,8 @@ See [Compaction Reference](compaction.md) for trigger, summarization, and valida
88
90
  | Setting | Type | Default | Description |
89
91
  |---|---|---|---|
90
92
  | `theme` | string | `"system"` | Built-in or custom theme name. `system` derives colors from the terminal theme. |
91
- | `quietStartup` | boolean | `false` | Hide the startup header. |
92
- | `tuiMode` | `"regular" \| "fullscreen"` | `"regular"` | Interactive terminal UI mode. |
93
+ | `quietStartup` | boolean \| `"header"` | `false` | `true` hides the startup header and loaded-resource listing. `"header"` keeps the header (version and key hints) but hides the model scope line and loaded-resource listing. |
94
+ | `tuiMode` | `"regular" \| "fullscreen"` | `"fullscreen"` | Interactive terminal UI mode. |
93
95
  | `fullscreenExitOutput` | `"transcript" \| "resume-hint"` | `"transcript"` | Output printed when fullscreen mode exits. |
94
96
  | `fullscreenScrollbar` | `"auto" \| "always" \| "hidden"` | `"auto"` | Fullscreen transcript scrollbar behavior. |
95
97
  | `fullscreenCopyOnSelect` | boolean | `true` | Copy selected text automatically in fullscreen mode. |
package/docs/usage.md CHANGED
@@ -83,7 +83,7 @@ Use `/share` to upload the session and get a viewer link. With Radius authentica
83
83
 
84
84
  ## Adjust the terminal
85
85
 
86
- Regular mode uses the terminal's normal scrollback. Fullscreen mode keeps the editor and status area fixed while the transcript scrolls within the terminal window. Choose a mode through `/settings` or `--tui-mode`.
86
+ Fullscreen mode, the default, keeps the editor and status area fixed while the transcript scrolls within the terminal window. Regular mode uses the terminal's normal scrollback. Choose a mode through `/settings` or `--tui-mode`.
87
87
 
88
88
  Terminal support for mouse input, keyboard shortcuts, and inline images varies. See [Terminal Setup](terminal-setup.md) for platform-specific configuration and [Keybindings](keybindings.md) for every configurable shortcut. Run `/hotkeys` to inspect the shortcuts active in your current session.
89
89