@dyyz1993/pi-coding-agent 0.70.5 → 0.74.4

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 (301) hide show
  1. package/CHANGELOG.md +266 -80
  2. package/README.md +48 -20
  3. package/dist/bun/cli.d.ts.map +1 -1
  4. package/dist/bun/cli.js +4 -2
  5. package/dist/bun/cli.js.map +1 -1
  6. package/dist/bun/restore-sandbox-env.d.ts +13 -0
  7. package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
  8. package/dist/bun/restore-sandbox-env.js +32 -0
  9. package/dist/bun/restore-sandbox-env.js.map +1 -0
  10. package/dist/cli/args.d.ts +2 -1
  11. package/dist/cli/args.d.ts.map +1 -1
  12. package/dist/cli/args.js +34 -22
  13. package/dist/cli/args.js.map +1 -1
  14. package/dist/cli/list-models.d.ts.map +1 -1
  15. package/dist/cli/list-models.js +2 -1
  16. package/dist/cli/list-models.js.map +1 -1
  17. package/dist/cli.d.ts.map +1 -1
  18. package/dist/cli.js +9 -4
  19. package/dist/cli.js.map +1 -1
  20. package/dist/config.d.ts +16 -8
  21. package/dist/config.d.ts.map +1 -1
  22. package/dist/config.js +238 -66
  23. package/dist/config.js.map +1 -1
  24. package/dist/core/agent-session-runtime.d.ts +10 -0
  25. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  26. package/dist/core/agent-session-runtime.js +14 -0
  27. package/dist/core/agent-session-runtime.js.map +1 -1
  28. package/dist/core/agent-session-services.d.ts +2 -1
  29. package/dist/core/agent-session-services.d.ts.map +1 -1
  30. package/dist/core/agent-session-services.js +1 -0
  31. package/dist/core/agent-session-services.js.map +1 -1
  32. package/dist/core/agent-session.d.ts +25 -26
  33. package/dist/core/agent-session.d.ts.map +1 -1
  34. package/dist/core/agent-session.js +1042 -1116
  35. package/dist/core/agent-session.js.map +1 -1
  36. package/dist/core/agent-types.d.ts +58 -0
  37. package/dist/core/agent-types.d.ts.map +1 -0
  38. package/dist/core/agent-types.js +203 -0
  39. package/dist/core/agent-types.js.map +1 -0
  40. package/dist/core/auth-guidance.d.ts +5 -0
  41. package/dist/core/auth-guidance.d.ts.map +1 -0
  42. package/dist/core/auth-guidance.js +21 -0
  43. package/dist/core/auth-guidance.js.map +1 -0
  44. package/dist/core/auth-storage.d.ts +9 -0
  45. package/dist/core/auth-storage.d.ts.map +1 -1
  46. package/dist/core/auth-storage.js +20 -1
  47. package/dist/core/auth-storage.js.map +1 -1
  48. package/dist/core/bash-executor.d.ts.map +1 -1
  49. package/dist/core/bash-executor.js +9 -6
  50. package/dist/core/bash-executor.js.map +1 -1
  51. package/dist/core/compaction/compaction.d.ts +0 -1
  52. package/dist/core/compaction/compaction.d.ts.map +1 -1
  53. package/dist/core/compaction/compaction.js.map +1 -1
  54. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  55. package/dist/core/export-html/ansi-to-html.js +1 -1
  56. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  57. package/dist/core/export-html/template.css +53 -4
  58. package/dist/core/export-html/template.js +84 -20
  59. package/dist/core/export-html/tool-renderer.d.ts +0 -6
  60. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  61. package/dist/core/export-html/tool-renderer.js +15 -2
  62. package/dist/core/export-html/tool-renderer.js.map +1 -1
  63. package/dist/core/extensions/channel-factory.d.ts +13 -0
  64. package/dist/core/extensions/channel-factory.d.ts.map +1 -0
  65. package/dist/core/extensions/channel-factory.js +19 -0
  66. package/dist/core/extensions/channel-factory.js.map +1 -0
  67. package/dist/core/extensions/channel-registry.d.ts +28 -0
  68. package/dist/core/extensions/channel-registry.d.ts.map +1 -0
  69. package/dist/core/extensions/channel-registry.js +12 -0
  70. package/dist/core/extensions/channel-registry.js.map +1 -0
  71. package/dist/core/extensions/index.d.ts +4 -1
  72. package/dist/core/extensions/index.d.ts.map +1 -1
  73. package/dist/core/extensions/index.js +1 -0
  74. package/dist/core/extensions/index.js.map +1 -1
  75. package/dist/core/extensions/loader.d.ts +0 -1
  76. package/dist/core/extensions/loader.d.ts.map +1 -1
  77. package/dist/core/extensions/loader.js +49 -137
  78. package/dist/core/extensions/loader.js.map +1 -1
  79. package/dist/core/extensions/runner.d.ts +24 -20
  80. package/dist/core/extensions/runner.d.ts.map +1 -1
  81. package/dist/core/extensions/runner.js +128 -253
  82. package/dist/core/extensions/runner.js.map +1 -1
  83. package/dist/core/extensions/server-channel.d.ts +8 -8
  84. package/dist/core/extensions/server-channel.d.ts.map +1 -1
  85. package/dist/core/extensions/server-channel.js.map +1 -1
  86. package/dist/core/extensions/types.d.ts +88 -60
  87. package/dist/core/extensions/types.d.ts.map +1 -1
  88. package/dist/core/extensions/types.js +10 -0
  89. package/dist/core/extensions/types.js.map +1 -1
  90. package/dist/core/file-store/file-snapshot-manager.d.ts +95 -0
  91. package/dist/core/file-store/file-snapshot-manager.d.ts.map +1 -0
  92. package/dist/core/file-store/file-snapshot-manager.js +508 -0
  93. package/dist/core/file-store/file-snapshot-manager.js.map +1 -0
  94. package/dist/core/file-store/index.d.ts +5 -0
  95. package/dist/core/file-store/index.d.ts.map +1 -0
  96. package/dist/core/file-store/index.js +3 -0
  97. package/dist/core/file-store/index.js.map +1 -0
  98. package/dist/core/messages.d.ts +10 -2
  99. package/dist/core/messages.d.ts.map +1 -1
  100. package/dist/core/messages.js +23 -6
  101. package/dist/core/messages.js.map +1 -1
  102. package/dist/core/model-registry.d.ts +19 -1
  103. package/dist/core/model-registry.d.ts.map +1 -1
  104. package/dist/core/model-registry.js +97 -16
  105. package/dist/core/model-registry.js.map +1 -1
  106. package/dist/core/model-resolver.d.ts.map +1 -1
  107. package/dist/core/model-resolver.js +24 -15
  108. package/dist/core/model-resolver.js.map +1 -1
  109. package/dist/core/package-manager.d.ts +1 -0
  110. package/dist/core/package-manager.d.ts.map +1 -1
  111. package/dist/core/package-manager.js +61 -35
  112. package/dist/core/package-manager.js.map +1 -1
  113. package/dist/core/provider-display-names.d.ts +2 -0
  114. package/dist/core/provider-display-names.d.ts.map +1 -0
  115. package/dist/core/provider-display-names.js +32 -0
  116. package/dist/core/provider-display-names.js.map +1 -0
  117. package/dist/core/resource-loader.d.ts.map +1 -1
  118. package/dist/core/resource-loader.js +9 -21
  119. package/dist/core/resource-loader.js.map +1 -1
  120. package/dist/core/sdk.d.ts +9 -1
  121. package/dist/core/sdk.d.ts.map +1 -1
  122. package/dist/core/sdk.js +39 -18
  123. package/dist/core/sdk.js.map +1 -1
  124. package/dist/core/session-manager.d.ts +27 -17
  125. package/dist/core/session-manager.d.ts.map +1 -1
  126. package/dist/core/session-manager.js +133 -47
  127. package/dist/core/session-manager.js.map +1 -1
  128. package/dist/core/settings-manager.d.ts +21 -3
  129. package/dist/core/settings-manager.d.ts.map +1 -1
  130. package/dist/core/settings-manager.js +51 -6
  131. package/dist/core/settings-manager.js.map +1 -1
  132. package/dist/core/skills.d.ts.map +1 -1
  133. package/dist/core/skills.js +3 -8
  134. package/dist/core/skills.js.map +1 -1
  135. package/dist/core/slash-commands.d.ts.map +1 -1
  136. package/dist/core/slash-commands.js +4 -3
  137. package/dist/core/slash-commands.js.map +1 -1
  138. package/dist/core/tools/bash.d.ts +0 -2
  139. package/dist/core/tools/bash.d.ts.map +1 -1
  140. package/dist/core/tools/bash.js +108 -154
  141. package/dist/core/tools/bash.js.map +1 -1
  142. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  143. package/dist/core/tools/edit-diff.js +3 -2
  144. package/dist/core/tools/edit-diff.js.map +1 -1
  145. package/dist/core/tools/edit.d.ts.map +1 -1
  146. package/dist/core/tools/edit.js +4 -3
  147. package/dist/core/tools/edit.js.map +1 -1
  148. package/dist/core/tools/find.d.ts.map +1 -1
  149. package/dist/core/tools/find.js +1 -1
  150. package/dist/core/tools/find.js.map +1 -1
  151. package/dist/core/tools/grep.d.ts.map +1 -1
  152. package/dist/core/tools/grep.js +1 -1
  153. package/dist/core/tools/grep.js.map +1 -1
  154. package/dist/core/tools/output-accumulator.d.ts +50 -0
  155. package/dist/core/tools/output-accumulator.d.ts.map +1 -0
  156. package/dist/core/tools/output-accumulator.js +178 -0
  157. package/dist/core/tools/output-accumulator.js.map +1 -0
  158. package/dist/core/tools/output-collector.d.ts +35 -0
  159. package/dist/core/tools/output-collector.d.ts.map +1 -0
  160. package/dist/core/tools/output-collector.js +79 -0
  161. package/dist/core/tools/output-collector.js.map +1 -0
  162. package/dist/core/tools/read.d.ts.map +1 -1
  163. package/dist/core/tools/read.js +70 -13
  164. package/dist/core/tools/read.js.map +1 -1
  165. package/dist/core/tools/spawn-managed.d.ts +18 -0
  166. package/dist/core/tools/spawn-managed.d.ts.map +1 -0
  167. package/dist/core/tools/spawn-managed.js +52 -0
  168. package/dist/core/tools/spawn-managed.js.map +1 -0
  169. package/dist/index.d.ts +7 -4
  170. package/dist/index.d.ts.map +1 -1
  171. package/dist/index.js +6 -2
  172. package/dist/index.js.map +1 -1
  173. package/dist/main.d.ts.map +1 -1
  174. package/dist/main.js +17 -39
  175. package/dist/main.js.map +1 -1
  176. package/dist/migrations.d.ts +1 -1
  177. package/dist/migrations.d.ts.map +1 -1
  178. package/dist/migrations.js +3 -3
  179. package/dist/migrations.js.map +1 -1
  180. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  181. package/dist/modes/interactive/components/config-selector.js +3 -1
  182. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  183. package/dist/modes/interactive/components/extension-selector.d.ts +1 -4
  184. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  185. package/dist/modes/interactive/components/extension-selector.js +14 -56
  186. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  187. package/dist/modes/interactive/components/login-dialog.d.ts +5 -1
  188. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  189. package/dist/modes/interactive/components/login-dialog.js +19 -4
  190. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  191. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  192. package/dist/modes/interactive/components/model-selector.js +1 -1
  193. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  194. package/dist/modes/interactive/components/oauth-selector.d.ts +18 -6
  195. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  196. package/dist/modes/interactive/components/oauth-selector.js +93 -25
  197. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  198. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  199. package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
  200. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  201. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  202. package/dist/modes/interactive/components/session-selector.js +3 -7
  203. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  204. package/dist/modes/interactive/components/settings-selector.d.ts +5 -0
  205. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  206. package/dist/modes/interactive/components/settings-selector.js +53 -1
  207. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  208. package/dist/modes/interactive/interactive-mode.d.ts +20 -4
  209. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  210. package/dist/modes/interactive/interactive-mode.js +423 -186
  211. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  212. package/dist/modes/interactive/theme/dark.json +1 -1
  213. package/dist/modes/interactive/theme/light.json +1 -1
  214. package/dist/modes/print-mode.d.ts +3 -0
  215. package/dist/modes/print-mode.d.ts.map +1 -1
  216. package/dist/modes/print-mode.js +62 -19
  217. package/dist/modes/print-mode.js.map +1 -1
  218. package/dist/modes/rpc/rpc-client.d.ts +80 -60
  219. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  220. package/dist/modes/rpc/rpc-client.js +108 -93
  221. package/dist/modes/rpc/rpc-client.js.map +1 -1
  222. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  223. package/dist/modes/rpc/rpc-mode.js +106 -0
  224. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  225. package/dist/modes/rpc/rpc-types.d.ts +115 -0
  226. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  227. package/dist/modes/rpc/rpc-types.js.map +1 -1
  228. package/dist/package-manager-cli.d.ts.map +1 -1
  229. package/dist/package-manager-cli.js +238 -12
  230. package/dist/package-manager-cli.js.map +1 -1
  231. package/dist/utils/child-process.d.ts +1 -0
  232. package/dist/utils/child-process.d.ts.map +1 -1
  233. package/dist/utils/child-process.js +8 -0
  234. package/dist/utils/child-process.js.map +1 -1
  235. package/dist/utils/clipboard-image.d.ts.map +1 -1
  236. package/dist/utils/clipboard-image.js +2 -2
  237. package/dist/utils/clipboard-image.js.map +1 -1
  238. package/dist/utils/clipboard.d.ts.map +1 -1
  239. package/dist/utils/clipboard.js +84 -45
  240. package/dist/utils/clipboard.js.map +1 -1
  241. package/dist/utils/paths.d.ts +9 -0
  242. package/dist/utils/paths.d.ts.map +1 -1
  243. package/dist/utils/paths.js +31 -0
  244. package/dist/utils/paths.js.map +1 -1
  245. package/dist/utils/pi-user-agent.d.ts +2 -0
  246. package/dist/utils/pi-user-agent.d.ts.map +1 -0
  247. package/dist/utils/pi-user-agent.js +5 -0
  248. package/dist/utils/pi-user-agent.js.map +1 -0
  249. package/dist/utils/structured-output.d.ts +10 -0
  250. package/dist/utils/structured-output.d.ts.map +1 -0
  251. package/dist/utils/structured-output.js +57 -0
  252. package/dist/utils/structured-output.js.map +1 -0
  253. package/dist/utils/tools-manager.d.ts.map +1 -1
  254. package/dist/utils/tools-manager.js +6 -2
  255. package/dist/utils/tools-manager.js.map +1 -1
  256. package/dist/utils/version-check.d.ts +14 -0
  257. package/dist/utils/version-check.d.ts.map +1 -0
  258. package/dist/utils/version-check.js +77 -0
  259. package/dist/utils/version-check.js.map +1 -0
  260. package/docs/compaction.md +14 -14
  261. package/docs/custom-provider.md +40 -31
  262. package/docs/development.md +1 -1
  263. package/docs/docs.json +148 -0
  264. package/docs/extensions.md +116 -56
  265. package/docs/index.md +70 -0
  266. package/docs/json.md +4 -4
  267. package/docs/models.md +150 -3
  268. package/docs/packages.md +10 -5
  269. package/docs/providers.md +62 -17
  270. package/docs/quickstart.md +142 -0
  271. package/docs/rollback-architecture.md +693 -0
  272. package/docs/rollback-test-cases.md +412 -0
  273. package/docs/rpc.md +1 -1
  274. package/docs/sdk.md +26 -26
  275. package/docs/{session.md → session-format.md} +6 -6
  276. package/docs/sessions.md +137 -0
  277. package/docs/settings.md +52 -9
  278. package/docs/termux.md +1 -1
  279. package/docs/themes.md +2 -2
  280. package/docs/tui.md +20 -20
  281. package/docs/usage.md +277 -0
  282. package/examples/extensions/README.md +2 -4
  283. package/examples/extensions/border-status-editor.ts +150 -0
  284. package/examples/extensions/commands.ts +2 -2
  285. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  286. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  287. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  288. package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
  289. package/examples/extensions/dynamic-resources/dynamic.json +1 -1
  290. package/examples/extensions/git-checkpoint.ts +1 -1
  291. package/examples/extensions/handoff.ts +49 -11
  292. package/examples/extensions/plan-mode/index.ts +1 -1
  293. package/examples/extensions/sandbox/package-lock.json +5 -5
  294. package/examples/extensions/sandbox/package.json +1 -1
  295. package/examples/extensions/subagent/agents.ts +126 -0
  296. package/examples/extensions/with-deps/package-lock.json +2 -2
  297. package/examples/extensions/with-deps/package.json +1 -1
  298. package/examples/sdk/README.md +2 -2
  299. package/package.json +7 -15
  300. package/docs/tree.md +0 -233
  301. package/examples/extensions/antigravity-image-gen.ts +0 -418
package/docs/models.md CHANGED
@@ -11,7 +11,9 @@ Add custom providers and models (Ollama, vLLM, LM Studio, proxies) via `~/.pi/ag
11
11
  - [Model Configuration](#model-configuration)
12
12
  - [Overriding Built-in Providers](#overriding-built-in-providers)
13
13
  - [Per-model Overrides](#per-model-overrides)
14
+ - [Anthropic Messages Compatibility](#anthropic-messages-compatibility)
14
15
  - [OpenAI Compatibility](#openai-compatibility)
16
+ - [Model Tier Aliases](#model-tier-aliases)
15
17
 
16
18
  ## Minimal Example
17
19
 
@@ -191,16 +193,59 @@ If your command is slow, expensive, rate-limited, or should keep using a previou
191
193
  | `name` | No | `id` | Human-readable model label. Used for matching (`--model` patterns) and shown in model details/status text. |
192
194
  | `api` | No | provider's `api` | Override provider's API for this model |
193
195
  | `reasoning` | No | `false` | Supports extended thinking |
196
+ | `thinkingLevelMap` | No | omitted | Maps pi thinking levels to provider values and marks unsupported levels (see below) |
194
197
  | `input` | No | `["text"]` | Input types: `["text"]` or `["text", "image"]` |
195
198
  | `contextWindow` | No | `128000` | Context window size in tokens |
196
199
  | `maxTokens` | No | `16384` | Maximum output tokens |
197
200
  | `cost` | No | all zeros | `{"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0}` (per million tokens) |
198
- | `compat` | No | provider `compat` | OpenAI compatibility overrides. Merged with provider-level `compat` when both are set. |
201
+ | `compat` | No | provider `compat` | Provider compatibility overrides. Merged with provider-level `compat` when both are set. |
199
202
 
200
203
  Current behavior:
201
204
  - `/model` and `--list-models` list entries by model `id`.
202
205
  - The configured `name` is used for model matching and detail/status text.
203
206
 
207
+ ### Thinking Level Map
208
+
209
+ Use `thinkingLevelMap` on a model to describe model-specific thinking controls. Keys are pi thinking levels: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`.
210
+
211
+ Values are tristate:
212
+
213
+ | Value | Meaning |
214
+ |-------|---------|
215
+ | omitted | Level is supported and uses the provider's default mapping |
216
+ | string | Level is supported and this value is sent to the provider |
217
+ | `null` | Level is unsupported and hidden/skipped/clamped away |
218
+
219
+ Example for a model that only supports off, high, and max reasoning:
220
+
221
+ ```json
222
+ {
223
+ "id": "deepseek-v4-pro",
224
+ "reasoning": true,
225
+ "thinkingLevelMap": {
226
+ "minimal": null,
227
+ "low": null,
228
+ "medium": null,
229
+ "high": "high",
230
+ "xhigh": "max"
231
+ }
232
+ }
233
+ ```
234
+
235
+ Example for a model where thinking cannot be disabled:
236
+
237
+ ```json
238
+ {
239
+ "id": "always-thinking-model",
240
+ "reasoning": true,
241
+ "thinkingLevelMap": {
242
+ "off": null
243
+ }
244
+ }
245
+ ```
246
+
247
+ Migration: older configs that used `compat.reasoningEffortMap` should move that mapping to model-level `thinkingLevelMap`. Use `null` for levels that should not appear in the UI.
248
+
204
249
  ## Overriding Built-in Providers
205
250
 
206
251
  Route a built-in provider through a proxy without redefining models:
@@ -269,6 +314,40 @@ Behavior notes:
269
314
  - You can combine provider-level `baseUrl`/`headers` with `modelOverrides`.
270
315
  - If `models` is also defined for a provider, custom models are merged after built-in overrides. A custom model with the same `id` replaces the overridden built-in model entry.
271
316
 
317
+ ## Anthropic Messages Compatibility
318
+
319
+ For providers or proxies using `api: "anthropic-messages"`, use `compat.supportsEagerToolInputStreaming` to control Anthropic fine-grained tool streaming compatibility.
320
+
321
+ By default pi sends per-tool `eager_input_streaming: true`. If a proxy or Anthropic-compatible backend rejects that field, set `supportsEagerToolInputStreaming` to `false`. Pi will omit `tools[].eager_input_streaming` and send the legacy `fine-grained-tool-streaming-2025-05-14` beta header for tool-enabled requests instead.
322
+
323
+ ```json
324
+ {
325
+ "providers": {
326
+ "anthropic-proxy": {
327
+ "baseUrl": "https://proxy.example.com",
328
+ "api": "anthropic-messages",
329
+ "apiKey": "ANTHROPIC_PROXY_KEY",
330
+ "compat": {
331
+ "supportsEagerToolInputStreaming": false,
332
+ "supportsLongCacheRetention": true
333
+ },
334
+ "models": [
335
+ {
336
+ "id": "claude-opus-4-7",
337
+ "reasoning": true,
338
+ "input": ["text", "image"]
339
+ }
340
+ ]
341
+ }
342
+ }
343
+ }
344
+ ```
345
+
346
+ | Field | Description |
347
+ |-------|-------------|
348
+ | `supportsEagerToolInputStreaming` | Whether the provider accepts per-tool `eager_input_streaming`. Default: `true`. Set to `false` to omit that field and use the legacy fine-grained tool streaming beta header on tool-enabled requests. |
349
+ | `supportsLongCacheRetention` | Whether the provider accepts Anthropic long cache retention (`cache_control.ttl: "1h"`) when cache retention is `long`. Default: `true`. |
350
+
272
351
  ## OpenAI Compatibility
273
352
 
274
353
  For providers with partial OpenAI compatibility, use the `compat` field.
@@ -297,15 +376,16 @@ For providers with partial OpenAI compatibility, use the `compat` field.
297
376
  | `supportsStore` | Provider supports `store` field |
298
377
  | `supportsDeveloperRole` | Use `developer` vs `system` role |
299
378
  | `supportsReasoningEffort` | Support for `reasoning_effort` parameter |
300
- | `reasoningEffortMap` | Map pi thinking levels to provider-specific `reasoning_effort` values |
301
379
  | `supportsUsageInStreaming` | Supports `stream_options: { include_usage: true }` (default: `true`) |
302
380
  | `maxTokensField` | Use `max_completion_tokens` or `max_tokens` |
303
381
  | `requiresToolResultName` | Include `name` on tool result messages |
304
382
  | `requiresAssistantAfterToolResult` | Insert an assistant message before a user message after tool results |
305
383
  | `requiresThinkingAsText` | Convert thinking blocks to plain text |
306
- | `thinkingFormat` | Use `reasoning_effort`, `zai`, `qwen`, or `qwen-chat-template` thinking parameters |
384
+ | `requiresReasoningContentOnAssistantMessages` | Include empty `reasoning_content` on all replayed assistant messages when reasoning is enabled |
385
+ | `thinkingFormat` | Use `reasoning_effort`, `deepseek`, `zai`, `qwen`, or `qwen-chat-template` thinking parameters |
307
386
  | `cacheControlFormat` | Use Anthropic-style `cache_control` markers on the system prompt, last tool definition, and last user/assistant text content. Currently only `anthropic` is supported. |
308
387
  | `supportsStrictMode` | Include the `strict` field in tool definitions |
388
+ | `supportsLongCacheRetention` | Whether the provider accepts long cache retention when cache retention is `long`: `prompt_cache_retention: "24h"` for OpenAI prompt caching, or `cache_control.ttl: "1h"` when `cacheControlFormat` is `anthropic`. Default: `true`. |
309
389
  | `openRouterRouting` | OpenRouter provider routing preferences. This object is sent as-is in the `provider` field of the [OpenRouter API request](https://openrouter.ai/docs/guides/routing/provider-selection). |
310
390
  | `vercelGatewayRouting` | Vercel AI Gateway routing config for provider selection (`only`, `order`) |
311
391
 
@@ -393,3 +473,70 @@ Vercel AI Gateway example:
393
473
  }
394
474
  }
395
475
  ```
476
+
477
+ ## Model Tier Aliases
478
+
479
+ Pi provides built-in model aliases that work as shorthand for specific models:
480
+
481
+ | Alias | Default Model | Use Case |
482
+ |-------|--------------|----------|
483
+ | `fast` | `anthropic/claude-haiku-4` | Quick tasks: summaries, titles, classification |
484
+ | `pro` | `anthropic/claude-sonnet-4-20250514` | Day-to-day coding: write code, fix bugs, answer questions |
485
+ | `max` | `anthropic/claude-opus-4-6` | Deep reasoning: architecture design, code review, complex analysis |
486
+
487
+ ### Where Aliases Work
488
+
489
+ Aliases are accepted everywhere a model can be specified:
490
+
491
+ - **CLI**: `pi --model fast`
492
+ - **CLI scoped models**: `pi --models "fast,pro,max"`
493
+ - **Settings**: `"defaultModel": "pro"`, `"enabledModels": ["fast", "pro", "max"]`
494
+ - **Interactive**: `/model fast`
495
+ - **Agent configs**: `model: max` in `.pi/agents/*.md`
496
+ - **Extension API**: `pi.callLLM({ model: "fast", ... })`, `pi.forkAgent("task", { model: "max" })`
497
+ - **RPC**: `{ type: "set_model", provider: "...", modelId: "fast" }`
498
+
499
+ ### Resolution Order
500
+
501
+ When an alias is used, it resolves through this chain:
502
+
503
+ 1. **Session-level** `tierModels` override (set via `pi.setTierModels()`)
504
+ 2. **Global** `tierModels` from `settings.json`
505
+ 3. **Hardcoded defaults** (`fast` → haiku, `pro` → sonnet, `max` → opus)
506
+ 4. **Current session model** (if alias can't be resolved)
507
+
508
+ ### Customizing Aliases
509
+
510
+ Override in `~/.pi/settings.json` (global) or `.pi/settings.json` (per-project):
511
+
512
+ ```json
513
+ {
514
+ "tierModels": {
515
+ "fast": "openai/gpt-4o-mini",
516
+ "pro": "google/gemini-2.5-pro",
517
+ "max": "anthropic/claude-opus-4-6"
518
+ }
519
+ }
520
+ ```
521
+
522
+ You only need to override the aliases you want to change. Unspecified aliases keep their defaults.
523
+
524
+ ### Using in Extensions
525
+
526
+ ```typescript
527
+ // Quick task with fast model
528
+ const summary = await pi.callLLM({
529
+ model: "fast",
530
+ messages: [{ role: "user", content: "Summarize..." }],
531
+ });
532
+
533
+ // Background review with max model
534
+ pi.background(async (signal) => {
535
+ const result = await pi.forkAgent("Review this code", {
536
+ model: "max",
537
+ shareContext: false,
538
+ maxTurns: 5,
539
+ signal,
540
+ });
541
+ });
542
+ ```
package/docs/packages.md CHANGED
@@ -27,8 +27,13 @@ pi install /absolute/path/to/package
27
27
  pi install ./relative/path/to/package
28
28
 
29
29
  pi remove npm:@foo/bar
30
- pi list # show installed packages from settings
31
- pi update # update all non-pinned packages
30
+ pi list # show installed packages from settings
31
+ pi update # update pi and all non-pinned packages
32
+ pi update --extensions # update all non-pinned packages only
33
+ pi update --self # update pi only
34
+ pi update --self --force # reinstall pi even if current
35
+ pi update npm:@foo/bar # update one package
36
+ pi update --extension npm:@foo/bar
32
37
  ```
33
38
 
34
39
  By default, `install` and `remove` write to global settings (`~/.pi/agent/settings.json`). Use `-l` to write to project settings (`.pi/settings.json`) instead. Project settings can be shared with your team, and pi installs any missing packages automatically on startup.
@@ -51,7 +56,7 @@ npm:@scope/pkg@1.2.3
51
56
  npm:pkg
52
57
  ```
53
58
 
54
- - Versioned specs are pinned and skipped by `pi update`.
59
+ - Versioned specs are pinned and skipped by package updates (`pi update`, `pi update --extensions`).
55
60
  - Global installs use `npm install -g`.
56
61
  - Project installs go under `.pi/npm/`.
57
62
  - Set `npmCommand` in `settings.json` to pin npm package lookup and install operations to a specific wrapper command such as `mise` or `asdf`.
@@ -78,7 +83,7 @@ ssh://git@github.com/user/repo@v1
78
83
  - HTTPS and SSH URLs are both supported.
79
84
  - SSH URLs use your configured SSH keys automatically (respects `~/.ssh/config`).
80
85
  - For non-interactive runs (for example CI), you can set `GIT_TERMINAL_PROMPT=0` to disable credential prompts and set `GIT_SSH_COMMAND` (for example `ssh -o BatchMode=yes -o ConnectTimeout=5`) to fail fast.
81
- - Refs pin the package and skip `pi update`.
86
+ - Refs pin the package and skip package updates (`pi update`, `pi update --extensions`).
82
87
  - Cloned to `~/.pi/agent/git/<host>/<path>` (global) or `.pi/git/<host>/<path>` (project).
83
88
  - Runs `npm install` after clone or pull if `package.json` exists.
84
89
 
@@ -158,7 +163,7 @@ If no `pi` manifest is present, pi auto-discovers resources from these directori
158
163
 
159
164
  Third party runtime dependencies belong in `dependencies` in `package.json`. Dependencies that do not register extensions, skills, prompt templates, or themes also belong in `dependencies`. When pi installs a package from npm or git, it runs `npm install`, so those dependencies are installed automatically.
160
165
 
161
- Pi bundles core packages for extensions and skills. If you import any of these, list them in `peerDependencies` with a `"*"` range and do not bundle them: `@mariozechner/pi-ai`, `@mariozechner/pi-agent-core`, `@mariozechner/pi-coding-agent`, `@mariozechner/pi-tui`, `typebox`.
166
+ Pi bundles core packages for extensions and skills. If you import any of these, list them in `peerDependencies` with a `"*"` range and do not bundle them: `@dyyz1993/pi-ai`, `@dyyz1993/pi-agent-core`, `@dyyz1993/pi-coding-agent`, `@dyyz1993/pi-tui`, `typebox`.
162
167
 
163
168
  Other pi packages must be bundled in your tarball. Add them to `dependencies` and `bundledDependencies`, then reference their resources through `node_modules/` paths. Pi loads packages with separate module roots, so separate installs do not collide or share modules.
164
169
 
package/docs/providers.md CHANGED
@@ -15,36 +15,31 @@ Pi supports subscription-based providers via OAuth and API key providers via env
15
15
 
16
16
  Use `/login` in interactive mode, then select a provider:
17
17
 
18
- - Claude Pro/Max
19
18
  - ChatGPT Plus/Pro (Codex)
19
+ - Claude Pro/Max
20
20
  - GitHub Copilot
21
- - Google Gemini CLI
22
- - Google Antigravity
23
21
 
24
22
  Use `/logout` to clear credentials. Tokens are stored in `~/.pi/agent/auth.json` and auto-refresh when expired.
25
23
 
26
- ### GitHub Copilot
24
+ ### OpenAI Codex
27
25
 
28
- - Press Enter for github.com, or enter your GitHub Enterprise Server domain
29
- - If you get "model not supported", enable it in VS Code: Copilot Chat → model selector → select model → "Enable"
26
+ - Requires ChatGPT Plus or Pro subscription
27
+ - Officially endorsed by OpenAI: [Codex for OSS](https://developers.openai.com/community/codex-for-oss)
30
28
 
31
- ### Google Providers
29
+ ### Claude Pro/Max
32
30
 
33
- - **Gemini CLI**: Standard Gemini models via Cloud Code Assist
34
- - **Antigravity**: Sandbox with Gemini 3, Claude, and GPT-OSS models
35
- - Both free with any Google account, subject to rate limits
36
- - For paid Cloud Code Assist: set `GOOGLE_CLOUD_PROJECT` env var
31
+ Anthropic subscription auth is active for Claude Pro/Max accounts. Third-party harness usage draws from [extra usage](https://claude.ai/settings/usage) and is billed per token, not against Claude plan limits.
37
32
 
38
- ### OpenAI Codex
33
+ ### GitHub Copilot
39
34
 
40
- - Requires ChatGPT Plus or Pro subscription
41
- - Personal use only; for production, use the OpenAI Platform API
35
+ - Press Enter for github.com, or enter your GitHub Enterprise Server domain
36
+ - If you get "model not supported", enable it in VS Code: Copilot Chat → model selector → select model → "Enable"
42
37
 
43
38
  ## API Keys
44
39
 
45
40
  ### Environment Variables or Auth File
46
41
 
47
- Set via environment variable:
42
+ Use `/login` in interactive mode and select a provider to store an API key in `auth.json`, or set credentials via environment variable:
48
43
 
49
44
  ```bash
50
45
  export ANTHROPIC_API_KEY=sk-ant-...
@@ -56,10 +51,13 @@ pi
56
51
  | Anthropic | `ANTHROPIC_API_KEY` | `anthropic` |
57
52
  | Azure OpenAI Responses | `AZURE_OPENAI_API_KEY` | `azure-openai-responses` |
58
53
  | OpenAI | `OPENAI_API_KEY` | `openai` |
54
+ | DeepSeek | `DEEPSEEK_API_KEY` | `deepseek` |
59
55
  | Google Gemini | `GEMINI_API_KEY` | `google` |
60
56
  | Mistral | `MISTRAL_API_KEY` | `mistral` |
61
57
  | Groq | `GROQ_API_KEY` | `groq` |
62
58
  | Cerebras | `CEREBRAS_API_KEY` | `cerebras` |
59
+ | Cloudflare AI Gateway | `CLOUDFLARE_API_KEY` (+ `CLOUDFLARE_ACCOUNT_ID`, `CLOUDFLARE_GATEWAY_ID`) | `cloudflare-ai-gateway` |
60
+ | Cloudflare Workers AI | `CLOUDFLARE_API_KEY` (+ `CLOUDFLARE_ACCOUNT_ID`) | `cloudflare-workers-ai` |
63
61
  | xAI | `XAI_API_KEY` | `xai` |
64
62
  | OpenRouter | `OPENROUTER_API_KEY` | `openrouter` |
65
63
  | Vercel AI Gateway | `AI_GATEWAY_API_KEY` | `vercel-ai-gateway` |
@@ -71,8 +69,12 @@ pi
71
69
  | Kimi For Coding | `KIMI_API_KEY` | `kimi-coding` |
72
70
  | MiniMax | `MINIMAX_API_KEY` | `minimax` |
73
71
  | MiniMax (China) | `MINIMAX_CN_API_KEY` | `minimax-cn` |
72
+ | Xiaomi MiMo | `XIAOMI_API_KEY` | `xiaomi` |
73
+ | Xiaomi MiMo Token Plan (China) | `XIAOMI_TOKEN_PLAN_CN_API_KEY` | `xiaomi-token-plan-cn` |
74
+ | Xiaomi MiMo Token Plan (Amsterdam) | `XIAOMI_TOKEN_PLAN_AMS_API_KEY` | `xiaomi-token-plan-ams` |
75
+ | Xiaomi MiMo Token Plan (Singapore) | `XIAOMI_TOKEN_PLAN_SGP_API_KEY` | `xiaomi-token-plan-sgp` |
74
76
 
75
- Reference for environment variables and `auth.json` keys: [`const envMap`](https://github.com/badlogic/pi-mono/blob/main/packages/ai/src/env-api-keys.ts) in [`packages/ai/src/env-api-keys.ts`](https://github.com/badlogic/pi-mono/blob/main/packages/ai/src/env-api-keys.ts).
77
+ Reference for environment variables and `auth.json` keys: [`const envMap`](https://github.com/dyyz1993/pi-mono/blob/main/packages/ai/src/env-api-keys.ts) in [`packages/ai/src/env-api-keys.ts`](https://github.com/dyyz1993/pi-mono/blob/main/packages/ai/src/env-api-keys.ts).
76
78
 
77
79
  #### Auth File
78
80
 
@@ -82,9 +84,14 @@ Store credentials in `~/.pi/agent/auth.json`:
82
84
  {
83
85
  "anthropic": { "type": "api_key", "key": "sk-ant-..." },
84
86
  "openai": { "type": "api_key", "key": "sk-..." },
87
+ "deepseek": { "type": "api_key", "key": "sk-..." },
85
88
  "google": { "type": "api_key", "key": "..." },
86
89
  "opencode": { "type": "api_key", "key": "..." },
87
- "opencode-go": { "type": "api_key", "key": "..." }
90
+ "opencode-go": { "type": "api_key", "key": "..." },
91
+ "xiaomi": { "type": "api_key", "key": "..." },
92
+ "xiaomi-token-plan-cn": { "type": "api_key", "key": "..." },
93
+ "xiaomi-token-plan-ams": { "type": "api_key", "key": "..." },
94
+ "xiaomi-token-plan-sgp": { "type": "api_key", "key": "..." }
88
95
  }
89
96
  ```
90
97
 
@@ -117,6 +124,8 @@ OAuth credentials are also stored here after `/login` and managed automatically.
117
124
  ```bash
118
125
  export AZURE_OPENAI_API_KEY=...
119
126
  export AZURE_OPENAI_BASE_URL=https://your-resource.openai.azure.com
127
+ # also supported: https://your-resource.cognitiveservices.azure.com
128
+ # root endpoints are auto-normalized to /openai/v1
120
129
  # or use resource name instead of base URL
121
130
  export AZURE_OPENAI_RESOURCE_NAME=your-resource
122
131
 
@@ -168,6 +177,42 @@ export AWS_BEDROCK_SKIP_AUTH=1
168
177
  export AWS_BEDROCK_FORCE_HTTP1=1
169
178
  ```
170
179
 
180
+ ### Cloudflare AI Gateway
181
+
182
+ `CLOUDFLARE_API_KEY` can be set via `/login`. The account ID and gateway slug must be set as environment variables.
183
+
184
+ ```bash
185
+ export CLOUDFLARE_API_KEY=... # or use /login
186
+ export CLOUDFLARE_ACCOUNT_ID=...
187
+ export CLOUDFLARE_GATEWAY_ID=... # create at dash.cloudflare.com → AI → AI Gateway
188
+ pi --provider cloudflare-ai-gateway --model "claude-sonnet-4-5"
189
+ ```
190
+
191
+ Routes to OpenAI, Anthropic, and Workers AI through Cloudflare AI Gateway. Workers AI uses the Unified API (`/compat`) and prefixed model IDs (`workers-ai/@cf/...`). OpenAI uses the OpenAI passthrough route (`/openai`) with native OpenAI model IDs such as `gpt-5.1`. Anthropic uses the Anthropic passthrough route (`/anthropic`) with native Anthropic model IDs such as `claude-sonnet-4-5`.
192
+
193
+ AI Gateway authentication uses `CLOUDFLARE_API_KEY` as `cf-aig-authorization`. Upstream authentication can be one of:
194
+
195
+ | Mode | Request auth | Upstream auth |
196
+ |------|--------------|---------------|
197
+ | Workers AI | Cloudflare token only | Cloudflare-native |
198
+ | Unified billing | Cloudflare token only | Cloudflare handles upstream auth and deducts credits |
199
+ | Stored BYOK | Cloudflare token only | Cloudflare injects provider keys stored in the AI Gateway dashboard |
200
+ | Inline BYOK | Cloudflare token plus upstream `Authorization` header | The request supplies the upstream provider key |
201
+
202
+ For normal pi usage, prefer unified billing or stored BYOK. Inline BYOK requires configuring an additional upstream `Authorization` header for the Cloudflare AI Gateway provider, for example via a `models.json` provider/model override.
203
+
204
+ ### Cloudflare Workers AI
205
+
206
+ `CLOUDFLARE_API_KEY` can be set via `/login`. `CLOUDFLARE_ACCOUNT_ID` must be set as an environment variable.
207
+
208
+ ```bash
209
+ export CLOUDFLARE_API_KEY=... # or use /login
210
+ export CLOUDFLARE_ACCOUNT_ID=...
211
+ pi --provider cloudflare-workers-ai --model "@cf/moonshotai/kimi-k2.6"
212
+ ```
213
+
214
+ Pi automatically sets `x-session-affinity` for [prefix caching](https://developers.cloudflare.com/workers-ai/features/prompt-caching/) discounts.
215
+
171
216
  ### Google Vertex AI
172
217
 
173
218
  Uses Application Default Credentials:
@@ -0,0 +1,142 @@
1
+ # Quickstart
2
+
3
+ This page gets you from install to a useful first pi session.
4
+
5
+ ## Install
6
+
7
+ Pi is distributed as an npm package:
8
+
9
+ ```bash
10
+ npm install -g @dyyz1993/pi-coding-agent
11
+ ```
12
+
13
+ Then start pi in the project directory you want it to work on:
14
+
15
+ ```bash
16
+ cd /path/to/project
17
+ pi
18
+ ```
19
+
20
+ ## Authenticate
21
+
22
+ Pi can use subscription providers through `/login`, or API-key providers through environment variables or the auth file.
23
+
24
+ ### Option 1: subscription login
25
+
26
+ Start pi and run:
27
+
28
+ ```text
29
+ /login
30
+ ```
31
+
32
+ Then select a provider. Built-in subscription logins include Claude Pro/Max, ChatGPT Plus/Pro (Codex), and GitHub Copilot.
33
+
34
+ ### Option 2: API key
35
+
36
+ Set an API key before launching pi:
37
+
38
+ ```bash
39
+ export ANTHROPIC_API_KEY=sk-ant-...
40
+ pi
41
+ ```
42
+
43
+ You can also run `/login` and select an API-key provider to store the key in `~/.pi/agent/auth.json`.
44
+
45
+ See [Providers](providers.md) for all supported providers, environment variables, and cloud-provider setup.
46
+
47
+ ## First session
48
+
49
+ Once pi starts, type a request and press Enter:
50
+
51
+ ```text
52
+ Summarize this repository and tell me how to run its checks.
53
+ ```
54
+
55
+ By default, pi gives the model four tools:
56
+
57
+ - `read` - read files
58
+ - `write` - create or overwrite files
59
+ - `edit` - patch files
60
+ - `bash` - run shell commands
61
+
62
+ Additional built-in read-only tools (`grep`, `find`, `ls`) are available through tool options. Pi runs in your current working directory and can modify files there. Use git or another checkpointing workflow if you want easy rollback.
63
+
64
+ ## Give pi project instructions
65
+
66
+ Pi loads context files at startup. Add an `AGENTS.md` file to tell it how to work in a project:
67
+
68
+ ```markdown
69
+ # Project Instructions
70
+
71
+ - Run `npm run check` after code changes.
72
+ - Do not run production migrations locally.
73
+ - Keep responses concise.
74
+ ```
75
+
76
+ Pi loads:
77
+
78
+ - `~/.pi/agent/AGENTS.md` for global instructions
79
+ - `AGENTS.md` or `CLAUDE.md` from parent directories and the current directory
80
+
81
+ Restart pi, or run `/reload`, after changing context files.
82
+
83
+ ## Common things to try
84
+
85
+ ### Reference files
86
+
87
+ Type `@` in the editor to fuzzy-search files, or pass files on the command line:
88
+
89
+ ```bash
90
+ pi @README.md "Summarize this"
91
+ pi @src/app.ts @src/app.test.ts "Review these together"
92
+ ```
93
+
94
+ Images can be pasted with Ctrl+V (Alt+V on Windows) or dragged into supported terminals.
95
+
96
+ ### Run shell commands
97
+
98
+ In interactive mode:
99
+
100
+ ```text
101
+ !npm run lint
102
+ ```
103
+
104
+ The command output is sent to the model. Use `!!command` to run a command without adding its output to the model context.
105
+
106
+ ### Switch models
107
+
108
+ Use `/model` or Ctrl+L to choose a model. Use Shift+Tab to cycle thinking level. Use Ctrl+P / Shift+Ctrl+P to cycle through scoped models.
109
+
110
+ ### Continue later
111
+
112
+ Sessions are saved automatically:
113
+
114
+ ```bash
115
+ pi -c # Continue most recent session
116
+ pi -r # Browse previous sessions
117
+ pi --session <path|id> # Open a specific session
118
+ ```
119
+
120
+ Inside pi, use `/resume`, `/new`, `/tree`, `/fork`, and `/clone` to manage sessions.
121
+
122
+ ### Non-interactive mode
123
+
124
+ For one-shot prompts:
125
+
126
+ ```bash
127
+ pi -p "Summarize this codebase"
128
+ cat README.md | pi -p "Summarize this text"
129
+ pi -p @screenshot.png "What's in this image?"
130
+ ```
131
+
132
+ Use `--mode json` for JSON event output or `--mode rpc` for process integration.
133
+
134
+ ## Next steps
135
+
136
+ - [Using Pi](usage.md) - interactive mode, slash commands, sessions, context files, and CLI reference.
137
+ - [Providers](providers.md) - authentication and model setup.
138
+ - [Settings](settings.md) - global and project configuration.
139
+ - [Keybindings](keybindings.md) - shortcuts and customization.
140
+ - [Pi Packages](packages.md) - install shared extensions, skills, prompts, and themes.
141
+
142
+ Platform notes: [Windows](windows.md), [Termux](termux.md), [tmux](tmux.md), [Terminal setup](terminal-setup.md), [Shell aliases](shell-aliases.md).