@earendil-works/pi-coding-agent 0.80.2 → 0.80.5

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 (211) hide show
  1. package/CHANGELOG.md +115 -1
  2. package/README.md +3 -2
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +2 -2
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/cli/config-selector.d.ts +4 -2
  7. package/dist/cli/config-selector.d.ts.map +1 -1
  8. package/dist/cli/config-selector.js +1 -1
  9. package/dist/cli/config-selector.js.map +1 -1
  10. package/dist/cli/file-processor.d.ts.map +1 -1
  11. package/dist/cli/file-processor.js +13 -25
  12. package/dist/cli/file-processor.js.map +1 -1
  13. package/dist/core/agent-session.d.ts +22 -5
  14. package/dist/core/agent-session.d.ts.map +1 -1
  15. package/dist/core/agent-session.js +133 -50
  16. package/dist/core/agent-session.js.map +1 -1
  17. package/dist/core/auth-storage.d.ts.map +1 -1
  18. package/dist/core/auth-storage.js +13 -5
  19. package/dist/core/auth-storage.js.map +1 -1
  20. package/dist/core/cache-stats.d.ts +49 -0
  21. package/dist/core/cache-stats.d.ts.map +1 -0
  22. package/dist/core/cache-stats.js +101 -0
  23. package/dist/core/cache-stats.js.map +1 -0
  24. package/dist/core/compaction/compaction.d.ts +1 -2
  25. package/dist/core/compaction/compaction.d.ts.map +1 -1
  26. package/dist/core/compaction/compaction.js +56 -81
  27. package/dist/core/compaction/compaction.js.map +1 -1
  28. package/dist/core/extensions/index.d.ts +1 -1
  29. package/dist/core/extensions/index.d.ts.map +1 -1
  30. package/dist/core/extensions/index.js.map +1 -1
  31. package/dist/core/extensions/loader.d.ts.map +1 -1
  32. package/dist/core/extensions/loader.js +10 -0
  33. package/dist/core/extensions/loader.js.map +1 -1
  34. package/dist/core/extensions/runner.d.ts +5 -3
  35. package/dist/core/extensions/runner.d.ts.map +1 -1
  36. package/dist/core/extensions/runner.js +38 -0
  37. package/dist/core/extensions/runner.js.map +1 -1
  38. package/dist/core/extensions/types.d.ts +39 -5
  39. package/dist/core/extensions/types.d.ts.map +1 -1
  40. package/dist/core/extensions/types.js.map +1 -1
  41. package/dist/core/http-dispatcher.d.ts.map +1 -1
  42. package/dist/core/http-dispatcher.js +28 -1
  43. package/dist/core/http-dispatcher.js.map +1 -1
  44. package/dist/core/index.d.ts +1 -1
  45. package/dist/core/index.d.ts.map +1 -1
  46. package/dist/core/index.js.map +1 -1
  47. package/dist/core/keybindings.d.ts.map +1 -1
  48. package/dist/core/keybindings.js +3 -6
  49. package/dist/core/keybindings.js.map +1 -1
  50. package/dist/core/model-registry.d.ts +3 -0
  51. package/dist/core/model-registry.d.ts.map +1 -1
  52. package/dist/core/model-registry.js +16 -2
  53. package/dist/core/model-registry.js.map +1 -1
  54. package/dist/core/model-resolver.d.ts +10 -0
  55. package/dist/core/model-resolver.d.ts.map +1 -1
  56. package/dist/core/model-resolver.js +15 -18
  57. package/dist/core/model-resolver.js.map +1 -1
  58. package/dist/core/package-manager.d.ts +4 -1
  59. package/dist/core/package-manager.d.ts.map +1 -1
  60. package/dist/core/package-manager.js +68 -26
  61. package/dist/core/package-manager.js.map +1 -1
  62. package/dist/core/provider-attribution.d.ts.map +1 -1
  63. package/dist/core/provider-attribution.js +0 -10
  64. package/dist/core/provider-attribution.js.map +1 -1
  65. package/dist/core/resource-loader.d.ts +2 -2
  66. package/dist/core/resource-loader.d.ts.map +1 -1
  67. package/dist/core/resource-loader.js +8 -7
  68. package/dist/core/resource-loader.js.map +1 -1
  69. package/dist/core/sdk.d.ts +1 -1
  70. package/dist/core/sdk.d.ts.map +1 -1
  71. package/dist/core/sdk.js +8 -1
  72. package/dist/core/sdk.js.map +1 -1
  73. package/dist/core/session-manager.d.ts +21 -2
  74. package/dist/core/session-manager.d.ts.map +1 -1
  75. package/dist/core/session-manager.js +104 -72
  76. package/dist/core/session-manager.js.map +1 -1
  77. package/dist/core/settings-manager.d.ts +10 -0
  78. package/dist/core/settings-manager.d.ts.map +1 -1
  79. package/dist/core/settings-manager.js +27 -0
  80. package/dist/core/settings-manager.js.map +1 -1
  81. package/dist/core/slash-commands.d.ts +1 -0
  82. package/dist/core/slash-commands.d.ts.map +1 -1
  83. package/dist/core/slash-commands.js +3 -3
  84. package/dist/core/slash-commands.js.map +1 -1
  85. package/dist/core/timings.d.ts +4 -2
  86. package/dist/core/timings.d.ts.map +1 -1
  87. package/dist/core/timings.js +24 -14
  88. package/dist/core/timings.js.map +1 -1
  89. package/dist/core/tools/bash.d.ts.map +1 -1
  90. package/dist/core/tools/bash.js +20 -5
  91. package/dist/core/tools/bash.js.map +1 -1
  92. package/dist/core/tools/edit.d.ts.map +1 -1
  93. package/dist/core/tools/edit.js +2 -2
  94. package/dist/core/tools/edit.js.map +1 -1
  95. package/dist/core/tools/read.d.ts.map +1 -1
  96. package/dist/core/tools/read.js +12 -25
  97. package/dist/core/tools/read.js.map +1 -1
  98. package/dist/index.d.ts +3 -2
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +2 -1
  101. package/dist/index.js.map +1 -1
  102. package/dist/main.d.ts +2 -2
  103. package/dist/main.d.ts.map +1 -1
  104. package/dist/main.js +17 -4
  105. package/dist/main.js.map +1 -1
  106. package/dist/modes/interactive/components/assistant-message.d.ts +3 -1
  107. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  108. package/dist/modes/interactive/components/assistant-message.js +23 -15
  109. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  110. package/dist/modes/interactive/components/config-selector.d.ts +34 -3
  111. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  112. package/dist/modes/interactive/components/config-selector.js +280 -25
  113. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  114. package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
  115. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
  116. package/dist/modes/interactive/components/custom-entry.js +52 -0
  117. package/dist/modes/interactive/components/custom-entry.js.map +1 -0
  118. package/dist/modes/interactive/components/extension-editor.d.ts +3 -1
  119. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  120. package/dist/modes/interactive/components/extension-editor.js +12 -3
  121. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  122. package/dist/modes/interactive/components/footer.d.ts +4 -0
  123. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  124. package/dist/modes/interactive/components/footer.js +1 -1
  125. package/dist/modes/interactive/components/footer.js.map +1 -1
  126. package/dist/modes/interactive/components/oauth-selector.d.ts +3 -1
  127. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  128. package/dist/modes/interactive/components/oauth-selector.js +17 -6
  129. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  130. package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
  131. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  132. package/dist/modes/interactive/components/settings-selector.js +23 -1
  133. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  134. package/dist/modes/interactive/components/status-indicator.d.ts +28 -0
  135. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
  136. package/dist/modes/interactive/components/status-indicator.js +60 -0
  137. package/dist/modes/interactive/components/status-indicator.js.map +1 -0
  138. package/dist/modes/interactive/components/user-message.d.ts +6 -2
  139. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  140. package/dist/modes/interactive/components/user-message.js +19 -6
  141. package/dist/modes/interactive/components/user-message.js.map +1 -1
  142. package/dist/modes/interactive/interactive-mode.d.ts +21 -10
  143. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  144. package/dist/modes/interactive/interactive-mode.js +417 -196
  145. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  146. package/dist/modes/print-mode.d.ts.map +1 -1
  147. package/dist/modes/print-mode.js +1 -1
  148. package/dist/modes/print-mode.js.map +1 -1
  149. package/dist/modes/rpc/rpc-client.d.ts +21 -6
  150. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  151. package/dist/modes/rpc/rpc-client.js +17 -3
  152. package/dist/modes/rpc/rpc-client.js.map +1 -1
  153. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  154. package/dist/modes/rpc/rpc-mode.js +20 -1
  155. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  156. package/dist/modes/rpc/rpc-types.d.ts +26 -0
  157. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  158. package/dist/modes/rpc/rpc-types.js.map +1 -1
  159. package/dist/package-manager-cli.d.ts +2 -2
  160. package/dist/package-manager-cli.d.ts.map +1 -1
  161. package/dist/package-manager-cli.js +71 -17
  162. package/dist/package-manager-cli.js.map +1 -1
  163. package/dist/rpc-entry.d.ts +3 -0
  164. package/dist/rpc-entry.d.ts.map +1 -0
  165. package/dist/rpc-entry.js +10 -0
  166. package/dist/rpc-entry.js.map +1 -0
  167. package/dist/utils/clipboard-image.d.ts.map +1 -1
  168. package/dist/utils/clipboard-image.js +1 -1
  169. package/dist/utils/clipboard-image.js.map +1 -1
  170. package/dist/utils/image-convert.d.ts +1 -0
  171. package/dist/utils/image-convert.d.ts.map +1 -1
  172. package/dist/utils/image-convert.js +21 -15
  173. package/dist/utils/image-convert.js.map +1 -1
  174. package/dist/utils/image-process.d.ts +18 -0
  175. package/dist/utils/image-process.d.ts.map +1 -0
  176. package/dist/utils/image-process.js +83 -0
  177. package/dist/utils/image-process.js.map +1 -0
  178. package/dist/utils/mime.d.ts.map +1 -1
  179. package/dist/utils/mime.js +41 -0
  180. package/dist/utils/mime.js.map +1 -1
  181. package/docs/extensions.md +88 -17
  182. package/docs/keybindings.md +1 -1
  183. package/docs/models.md +4 -4
  184. package/docs/packages.md +2 -2
  185. package/docs/providers.md +2 -1
  186. package/docs/rpc.md +71 -3
  187. package/docs/sdk.md +50 -0
  188. package/docs/session-format.md +18 -8
  189. package/docs/settings.md +11 -0
  190. package/docs/usage.md +3 -3
  191. package/examples/extensions/README.md +1 -0
  192. package/examples/extensions/custom-compaction.ts +1 -0
  193. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  194. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  195. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  196. package/examples/extensions/entry-renderer.ts +41 -0
  197. package/examples/extensions/gondolin/package-lock.json +2 -2
  198. package/examples/extensions/gondolin/package.json +1 -1
  199. package/examples/extensions/handoff.ts +1 -1
  200. package/examples/extensions/qna.ts +1 -1
  201. package/examples/extensions/question.ts +1 -0
  202. package/examples/extensions/reload-runtime.ts +2 -2
  203. package/examples/extensions/sandbox/package-lock.json +2 -2
  204. package/examples/extensions/sandbox/package.json +1 -1
  205. package/examples/extensions/summarize.ts +1 -0
  206. package/examples/extensions/with-deps/package-lock.json +2 -2
  207. package/examples/extensions/with-deps/package.json +1 -1
  208. package/examples/sdk/12-full-control.ts +1 -1
  209. package/examples/sdk/README.md +1 -1
  210. package/npm-shrinkwrap.json +12 -12
  211. package/package.json +8 -5
@@ -294,6 +294,7 @@ user sends prompt ────────────────────
294
294
  │ │ │ │
295
295
  │ ├─► turn_start │ │
296
296
  │ ├─► context (can modify messages) │ │
297
+ │ ├─► before_provider_headers (can mutate headers) |
297
298
  │ ├─► before_provider_request (can inspect or replace payload)
298
299
  │ ├─► after_provider_response (status + headers, before stream consume)
299
300
  │ │ │ │
@@ -306,7 +307,8 @@ user sends prompt ────────────────────
306
307
  │ │ │ │
307
308
  │ └─► turn_end │ │
308
309
  │ │
309
- └─► agent_end │
310
+ ├─► agent_end │
311
+ └─► agent_settled (no retry/compaction/follow-up left) │
310
312
  │
311
313
  user sends another prompt ◄────────────────────────────────┘
312
314
 
@@ -322,6 +324,9 @@ user sends another prompt ◄─────────────────
322
324
  ├─► session_start { reason: "fork", previousSessionFile }
323
325
  └─► resources_discover { reason: "startup" }
324
326
 
327
+ /name or pi.setSessionName()
328
+ └─► session_info_changed
329
+
325
330
  /compact or auto-compaction
326
331
  ├─► session_before_compact (can cancel or customize)
327
332
  └─► session_compact
@@ -395,6 +400,17 @@ pi.on("session_start", async (event, ctx) => {
395
400
  });
396
401
  ```
397
402
 
403
+ #### session_info_changed
404
+
405
+ Fired when the current session display name is set via `/name`, RPC, or `pi.setSessionName()`.
406
+
407
+ ```typescript
408
+ pi.on("session_info_changed", async (event, ctx) => {
409
+ // event.name - current normalized name, or undefined if cleared
410
+ ctx.ui.notify(`Session renamed: ${event.name ?? "(none)"}`, "info");
411
+ });
412
+ ```
413
+
398
414
  #### session_before_switch
399
415
 
400
416
  Fired before starting a new session (`/new`) or switching sessions (`/resume`).
@@ -531,15 +547,19 @@ The `systemPromptOptions` field gives extensions access to the same structured d
531
547
 
532
548
  Inside `before_agent_start`, `event.systemPrompt` and `ctx.getSystemPrompt()` both reflect the chained system prompt as of the current handler. Later `before_agent_start` handlers can still modify it again.
533
549
 
534
- #### agent_start / agent_end
550
+ #### agent_start / agent_end / agent_settled
535
551
 
536
- Fired once per user prompt.
552
+ `agent_start` fires when a low-level agent run begins. `agent_end` fires when that run ends, but Pi may still auto-retry, auto-compact and retry, or continue with queued follow-up messages. Use `agent_settled` for status integrations that need to know Pi will not continue running automatically.
537
553
 
538
554
  ```typescript
539
555
  pi.on("agent_start", async (_event, ctx) => {});
540
556
 
541
557
  pi.on("agent_end", async (event, ctx) => {
542
- // event.messages - messages from this prompt
558
+ // event.messages - messages from this low-level run
559
+ });
560
+
561
+ pi.on("agent_settled", async (_event, ctx) => {
562
+ // ctx.isIdle() is true here unless another extension started a new run.
543
563
  });
544
564
  ```
545
565
 
@@ -629,6 +649,24 @@ pi.on("context", async (event, ctx) => {
629
649
  });
630
650
  ```
631
651
 
652
+ #### before_provider_headers
653
+
654
+ Fired after the outgoing HTTP headers are assembled. Use it to add, override, or remove request headers.
655
+
656
+ Handlers mutate `event.headers` in place. Set a key to a string to add or override it, or to `null` to delete it.
657
+
658
+ ```typescript
659
+ pi.on("before_provider_headers", (event, ctx) => {
660
+ // Add or override — e.g. a session id for gateway tracing/attribution
661
+ event.headers["x-session-id"] = ctx.sessionManager.getSessionId();
662
+
663
+ // Drop a tracking header pi adds for this call
664
+ event.headers["X-OpenRouter-Title"] = null;
665
+ });
666
+ ```
667
+
668
+ Runs once per provider request; retries reuse the same headers rather than re-firing the hook.
669
+
632
670
  #### before_provider_request
633
671
 
634
672
  Fired after the provider-specific payload is built, right before the request is sent. Handlers run in extension load order. Returning `undefined` keeps the payload unchanged. Returning any other value replaces the payload for later handlers and for the actual request.
@@ -930,9 +968,10 @@ Read-only access to session state. See [Session Format](session-format.md) for t
930
968
  For `tool_call`, this state is synchronized through the current assistant message before handlers run. In parallel tool execution mode it is still not guaranteed to include sibling tool results from the same assistant message.
931
969
 
932
970
  ```typescript
933
- ctx.sessionManager.getEntries() // All entries
934
- ctx.sessionManager.getBranch() // Current branch
935
- ctx.sessionManager.getLeafId() // Current leaf entry ID
971
+ ctx.sessionManager.getEntries() // All entries
972
+ ctx.sessionManager.getBranch() // Current branch
973
+ ctx.sessionManager.buildContextEntries() // Active branch entries with compaction applied
974
+ ctx.sessionManager.getLeafId() // Current leaf entry ID
936
975
  ```
937
976
 
938
977
  ### ctx.modelRegistry / ctx.model
@@ -966,7 +1005,7 @@ pi.on("tool_result", async (event, ctx) => {
966
1005
 
967
1006
  ### ctx.isIdle() / ctx.abort() / ctx.hasPendingMessages()
968
1007
 
969
- Control flow helpers.
1008
+ Control flow helpers. `ctx.isIdle()` is false while Pi is processing an agent run, automatic retry, auto-compaction retry, or queued continuation.
970
1009
 
971
1010
  ### ctx.shutdown()
972
1011
 
@@ -1048,7 +1087,7 @@ This reports the current base prompt inputs. It does not include per-turn `befor
1048
1087
 
1049
1088
  ### ctx.waitForIdle()
1050
1089
 
1051
- Wait for the agent to finish streaming:
1090
+ Wait for the agent to fully settle, including automatic retries, auto-compaction retries, and queued continuations:
1052
1091
 
1053
1092
  ```typescript
1054
1093
  pi.registerCommand("my-cmd", {
@@ -1229,7 +1268,7 @@ Run the same reload flow as `/reload`.
1229
1268
 
1230
1269
  ```typescript
1231
1270
  pi.registerCommand("reload-runtime", {
1232
- description: "Reload extensions, skills, prompts, and themes",
1271
+ description: "Reload extensions, skills, prompts, themes, and context files",
1233
1272
  handler: async (_args, ctx) => {
1234
1273
  await ctx.reload();
1235
1274
  return;
@@ -1257,7 +1296,7 @@ import { Type } from "typebox";
1257
1296
 
1258
1297
  export default function (pi: ExtensionAPI) {
1259
1298
  pi.registerCommand("reload-runtime", {
1260
- description: "Reload extensions, skills, prompts, and themes",
1299
+ description: "Reload extensions, skills, prompts, themes, and context files",
1261
1300
  handler: async (_args, ctx) => {
1262
1301
  await ctx.reload();
1263
1302
  return;
@@ -1267,7 +1306,7 @@ export default function (pi: ExtensionAPI) {
1267
1306
  pi.registerTool({
1268
1307
  name: "reload_runtime",
1269
1308
  label: "Reload Runtime",
1270
- description: "Reload extensions, skills, prompts, and themes",
1309
+ description: "Reload extensions, skills, prompts, themes, and context files",
1271
1310
  parameters: Type.Object({}),
1272
1311
  async execute() {
1273
1312
  pi.sendUserMessage("/reload-runtime", { deliverAs: "followUp" });
@@ -1338,7 +1377,7 @@ pi.registerTool({
1338
1377
 
1339
1378
  ### pi.sendMessage(message, options?)
1340
1379
 
1341
- Inject a custom message into the session.
1380
+ Inject a custom message into the session. Custom messages participate in LLM context. For durable TUI-only content that should not be sent to the LLM, use [`pi.appendEntry()`](#piappendentrycustomtype-data) with [`pi.registerEntryRenderer()`](#piregisterentryrenderercustomtype-renderer).
1342
1381
 
1343
1382
  ```typescript
1344
1383
  pi.sendMessage({
@@ -1389,10 +1428,11 @@ See [send-user-message.ts](../examples/extensions/send-user-message.ts) for a co
1389
1428
 
1390
1429
  ### pi.appendEntry(customType, data?)
1391
1430
 
1392
- Persist extension state (does NOT participate in LLM context).
1431
+ Persist extension data. Custom entries do NOT participate in LLM context. In interactive mode, they can also render inside the chat transcript when paired with `pi.registerEntryRenderer()`.
1393
1432
 
1394
1433
  ```typescript
1395
1434
  pi.appendEntry("my-state", { count: 42 });
1435
+ pi.appendEntry("status-card", { title: "Indexed files", count: 17 });
1396
1436
 
1397
1437
  // Restore on reload
1398
1438
  pi.on("session_start", async (_event, ctx) => {
@@ -1510,7 +1550,27 @@ mode and would not execute if sent via `prompt`.
1510
1550
 
1511
1551
  ### pi.registerMessageRenderer(customType, renderer)
1512
1552
 
1513
- Register a custom TUI renderer for messages with your `customType`. See [Custom UI](#custom-ui).
1553
+ Register a custom TUI renderer for custom messages with your `customType`. Custom messages are created with `pi.sendMessage()` and participate in LLM context. See [Custom UI](#custom-ui).
1554
+
1555
+ ### pi.registerEntryRenderer(customType, renderer)
1556
+
1557
+ Register a custom TUI renderer for custom entries with your `customType`. Custom entries are created with `pi.appendEntry()` and do not participate in LLM context.
1558
+
1559
+ ```typescript
1560
+ import { Box, Text } from "@earendil-works/pi-tui";
1561
+
1562
+ pi.registerEntryRenderer("status-card", (entry, { expanded }, theme) => {
1563
+ const data = entry.data as { title: string; count: number };
1564
+ const box = new Box(1, 1, (text) => theme.bg("customMessageBg", text));
1565
+ box.addChild(new Text(`${theme.bold(data.title)}: ${data.count}`));
1566
+ if (expanded) {
1567
+ box.addChild(new Text(theme.fg("dim", JSON.stringify(data, null, 2))));
1568
+ }
1569
+ return box;
1570
+ });
1571
+
1572
+ pi.appendEntry("status-card", { title: "Indexed files", count: 17 });
1573
+ ```
1514
1574
 
1515
1575
  ### pi.registerShortcut(shortcut, options)
1516
1576
 
@@ -2514,9 +2574,9 @@ ctx.ui.setEditorComponent((tui, theme, keybindings) =>
2514
2574
 
2515
2575
  See [tui.md](tui.md) Pattern 7 for a complete example with mode indicator.
2516
2576
 
2517
- ### Message Rendering
2577
+ ### Message and Entry Rendering
2518
2578
 
2519
- Register a custom renderer for messages with your `customType`:
2579
+ Register a custom renderer for messages with your `customType`. Use message renderers for content that should participate in LLM context:
2520
2580
 
2521
2581
  ```typescript
2522
2582
  import { Text } from "@earendil-works/pi-tui";
@@ -2545,6 +2605,16 @@ pi.sendMessage({
2545
2605
  });
2546
2606
  ```
2547
2607
 
2608
+ For TUI-only content that should not be sent to the LLM, render custom entries instead:
2609
+
2610
+ ```typescript
2611
+ pi.registerEntryRenderer("my-card", (entry, options, theme) => {
2612
+ return new Text(theme.fg("accent", JSON.stringify(entry.data)));
2613
+ });
2614
+
2615
+ pi.appendEntry("my-card", { status: "done" });
2616
+ ```
2617
+
2548
2618
  ### Theme Colors
2549
2619
 
2550
2620
  All render functions receive a `theme` object. See [themes.md](themes.md) for creating custom themes and the full color palette.
@@ -2671,6 +2741,7 @@ All examples in [examples/extensions/](../examples/extensions/).
2671
2741
  | `custom-provider-gitlab-duo/` | GitLab Duo integration | `registerProvider` with OAuth |
2672
2742
  | **Messages & Communication** |||
2673
2743
  | `message-renderer.ts` | Custom message rendering | `registerMessageRenderer`, `sendMessage` |
2744
+ | `entry-renderer.ts` | TUI-only custom entry rendering | `registerEntryRenderer`, `appendEntry` |
2674
2745
  | `event-bus.ts` | Inter-extension events | `pi.events` |
2675
2746
  | **Session Metadata** |||
2676
2747
  | `session-name.ts` | Name sessions for selector | `setSessionName`, `getSessionName` |
@@ -86,7 +86,7 @@ Modifier combinations: `ctrl+shift+x`, `alt+ctrl+x`, `ctrl+shift+alt+x`, `ctrl+1
86
86
  | `app.clear` | `ctrl+c` | Clear editor |
87
87
  | `app.exit` | `ctrl+d` | Exit (when editor empty) |
88
88
  | `app.suspend` | `ctrl+z` (none on Windows) | Suspend to background |
89
- | `app.editor.external` | `ctrl+g` | Open in external editor (`$VISUAL` or `$EDITOR`) |
89
+ | `app.editor.external` | `ctrl+g` | Open in external editor (`externalEditor`, `$VISUAL`, `$EDITOR`, Notepad on Windows, or `nano` elsewhere) |
90
90
  | `app.clipboard.pasteImage` | `ctrl+v` (`alt+v` on Windows) | Paste image from clipboard |
91
91
 
92
92
  ### Sessions
package/docs/models.md CHANGED
@@ -139,7 +139,7 @@ Set `api` at provider level (default for all models) or model level (override pe
139
139
  | `headers` | Custom headers (see value resolution below) |
140
140
  | `authHeader` | Set `true` to add `Authorization: Bearer <apiKey>` automatically |
141
141
  | `models` | Array of model configurations |
142
- | `modelOverrides` | Per-model overrides for built-in models on this provider |
142
+ | `modelOverrides` | Per-model overrides for built-in or extension-registered models on this provider |
143
143
 
144
144
  For providers with `models`, non-built-in provider configs need `baseUrl` and an `api` value at either provider or model level. `apiKey` is not required to load the file: models become available when auth is configured through `/login`/`auth.json`, CLI `--api-key`, or provider `apiKey`. If no auth is configured, the models load but stay unavailable in `/model` and `--list-models`.
145
145
 
@@ -293,7 +293,7 @@ Merge semantics:
293
293
 
294
294
  ## Per-model Overrides
295
295
 
296
- Use `modelOverrides` to customize specific built-in models without replacing the provider's full model list.
296
+ Use `modelOverrides` to customize built-in models and matching extension-registered models without replacing the provider's full model list.
297
297
 
298
298
  ```json
299
299
  {
@@ -314,10 +314,10 @@ Use `modelOverrides` to customize specific built-in models without replacing the
314
314
  }
315
315
  ```
316
316
 
317
- `modelOverrides` supports these fields per model: `name`, `reasoning`, `input`, `cost` (partial), `contextWindow`, `maxTokens`, `headers`, `compat`.
317
+ `modelOverrides` supports these fields per model: `name`, `reasoning`, `thinkingLevelMap`, `input`, `cost` (partial), `contextWindow`, `maxTokens`, `headers`, `compat`.
318
318
 
319
319
  Behavior notes:
320
- - `modelOverrides` are applied to built-in provider models.
320
+ - `modelOverrides` are applied to built-in provider models and matching extension-registered provider models.
321
321
  - Unknown model IDs are ignored.
322
322
  - You can combine provider-level `baseUrl`/`headers` with `modelOverrides`.
323
323
  - Overriding `name` changes model matching and secondary detail text only; the footer and primary model lists continue to show the model `id`.
package/docs/packages.md CHANGED
@@ -216,11 +216,11 @@ Filter what a package loads using the object form in settings:
216
216
 
217
217
  ## Enable and Disable Resources
218
218
 
219
- Use `pi config` to enable or disable extensions, skills, prompt templates, and themes from installed packages and local directories. Works for both global (`~/.pi/agent`) and project (`.pi/`) scopes.
219
+ Use `pi config` to enable or disable extensions, skills, prompt templates, and themes from installed packages and local directories. `pi config` starts in global settings (`~/.pi/agent/settings.json`); press Tab to switch between global and project-local modes. Use `pi config -l` to start in project overrides (`.pi/settings.json`) with inherited global resources dimmed.
220
220
 
221
221
  ## Scope and Deduplication
222
222
 
223
- Packages can appear in both global and project settings. If the same package appears in both, the project entry wins. Identity is determined by:
223
+ Packages can appear in both global and project settings. If the same package appears in both, the project entry wins unless the project entry has `autoload: false`, in which case it is applied as a delta over the global entry. Identity is determined by:
224
224
 
225
225
  - npm: package name
226
226
  - git: repository URL without ref
package/docs/providers.md CHANGED
@@ -156,8 +156,9 @@ OAuth credentials are also stored here after `/login` and managed automatically.
156
156
 
157
157
  ```bash
158
158
  export AZURE_OPENAI_API_KEY=...
159
- export AZURE_OPENAI_BASE_URL=https://your-resource.openai.azure.com
159
+ export AZURE_OPENAI_BASE_URL=https://your-resource.ai.azure.com
160
160
  # also supported: https://your-resource.cognitiveservices.azure.com
161
+ # also supported: https://your-resource.openai.azure.com
161
162
  # root endpoints are auto-normalized to /openai/v1
162
163
  # or use resource name instead of base URL
163
164
  export AZURE_OPENAI_RESOURCE_NAME=your-resource
package/docs/rpc.md CHANGED
@@ -661,6 +661,64 @@ Response:
661
661
  }
662
662
  ```
663
663
 
664
+ #### get_entries
665
+
666
+ Get all session entries in append order (excluding the session header). The session is an append-only tree of entries with stable ids, so an entry id works as a durable cursor: pass the last entry id you have seen as `since` to get only entries strictly after it, even across client restarts. Unlike `get_messages`, this includes pre-compaction history and abandoned branches.
667
+
668
+ ```json
669
+ {"type": "get_entries"}
670
+ ```
671
+
672
+ With a cursor:
673
+ ```json
674
+ {"type": "get_entries", "since": "abc123"}
675
+ ```
676
+
677
+ Response:
678
+ ```json
679
+ {
680
+ "type": "response",
681
+ "command": "get_entries",
682
+ "success": true,
683
+ "data": {
684
+ "entries": [
685
+ {"type": "message", "id": "def456", "parentId": "abc123", "timestamp": "...", "message": {"role": "user", "...": "..."}}
686
+ ],
687
+ "leafId": "def456"
688
+ }
689
+ }
690
+ ```
691
+
692
+ `leafId` is the id of the current leaf entry (`null` for an empty session), so a client can tell in one round trip whether the active branch moved. If `since` does not match any entry id, the response is `success: false`.
693
+
694
+ #### get_tree
695
+
696
+ Get the session as a tree of entries. Each node is `{entry, children, label?, labelTimestamp?}`. A well-formed session has a single root; orphaned entries (broken parent chain) also appear as roots.
697
+
698
+ ```json
699
+ {"type": "get_tree"}
700
+ ```
701
+
702
+ Response:
703
+ ```json
704
+ {
705
+ "type": "response",
706
+ "command": "get_tree",
707
+ "success": true,
708
+ "data": {
709
+ "tree": [
710
+ {
711
+ "entry": {"type": "message", "id": "abc123", "parentId": null, "...": "..."},
712
+ "children": [
713
+ {"entry": {"type": "message", "id": "def456", "parentId": "abc123", "...": "..."}, "children": []}
714
+ ]
715
+ }
716
+ ],
717
+ "leafId": "def456"
718
+ }
719
+ }
720
+ ```
721
+
664
722
  #### get_last_assistant_text
665
723
 
666
724
  Get the text content of the last assistant message.
@@ -750,7 +808,8 @@ Events are streamed to stdout as JSON lines during agent operation. Events do NO
750
808
  | Event | Description |
751
809
  |-------|-------------|
752
810
  | `agent_start` | Agent begins processing |
753
- | `agent_end` | Agent completes (includes all generated messages) |
811
+ | `agent_end` | One low-level agent run completes (may still be followed by retry, compaction, or queued continuations) |
812
+ | `agent_settled` | Agent run is fully settled; no automatic retry, compaction retry, or queued continuation remains |
754
813
  | `turn_start` | New turn begins |
755
814
  | `turn_end` | Turn completes (includes assistant message and tool results) |
756
815
  | `message_start` | Message begins |
@@ -776,15 +835,24 @@ Emitted when the agent begins processing a prompt.
776
835
 
777
836
  ### agent_end
778
837
 
779
- Emitted when the agent completes. Contains all messages generated during this run.
838
+ Emitted when one low-level agent run completes. Contains all messages generated during this run. If `willRetry` is true, an automatic retry will follow.
780
839
 
781
840
  ```json
782
841
  {
783
842
  "type": "agent_end",
784
- "messages": [...]
843
+ "messages": [...],
844
+ "willRetry": false
785
845
  }
786
846
  ```
787
847
 
848
+ ### agent_settled
849
+
850
+ Emitted after the full session-level run settles. At this point Pi will not continue automatically through retry, compaction retry, or queued follow-up messages.
851
+
852
+ ```json
853
+ {"type": "agent_settled"}
854
+ ```
855
+
788
856
  ### turn_start / turn_end
789
857
 
790
858
  A turn consists of one assistant response plus any resulting tool calls and results.
package/docs/sdk.md CHANGED
@@ -405,6 +405,32 @@ If no model is provided:
405
405
  2. Uses default from settings
406
406
  3. Falls back to first available model
407
407
 
408
+ To match CLI model parsing, use the exported resolver helpers:
409
+
410
+ ```typescript
411
+ import {
412
+ resolveCliModel,
413
+ resolveModelScopeWithDiagnostics,
414
+ } from "@earendil-works/pi-coding-agent";
415
+
416
+ const cliModel = resolveCliModel({
417
+ cliModel: "anthropic/claude-opus-4-5:high",
418
+ modelRegistry,
419
+ });
420
+ if (cliModel.error) throw new Error(cliModel.error);
421
+ if (cliModel.warning) console.warn(cliModel.warning);
422
+
423
+ const { scopedModels, diagnostics } = await resolveModelScopeWithDiagnostics(
424
+ ["anthropic/*:high", "gpt-5"],
425
+ modelRegistry,
426
+ );
427
+ for (const diagnostic of diagnostics) {
428
+ console.warn(diagnostic.message);
429
+ }
430
+ ```
431
+
432
+ `resolveCliModel()` uses all registered models so `--api-key` style first-time setup can resolve a model before stored auth exists. `resolveModelScopeWithDiagnostics()` matches `--models` and `enabledModels` semantics while returning warnings instead of printing them.
433
+
408
434
  > See [examples/sdk/02-custom-model.ts](../examples/sdk/02-custom-model.ts)
409
435
 
410
436
  ### API Keys and OAuth
@@ -578,6 +604,27 @@ const { session } = await createAgentSession({ resourceLoader: loader });
578
604
 
579
605
  Extensions can register tools, subscribe to events, add commands, and more. See [extensions.md](extensions.md) for the full API.
580
606
 
607
+ **Named inline extensions:** By default, inline factories display as `<inline:1>`, `<inline:2>`, etc. in the startup Extensions list. To show a descriptive name instead, wrap the factory:
608
+
609
+ ```typescript
610
+ import type { InlineExtension } from "@earendil-works/pi-coding-agent";
611
+
612
+ const myProvider: InlineExtension = {
613
+ name: "my-provider",
614
+ factory: (pi) => {
615
+ pi.on("agent_start", () => {
616
+ console.log("[my-provider] Agent starting");
617
+ });
618
+ },
619
+ };
620
+
621
+ const loader = new DefaultResourceLoader({
622
+ extensionFactories: [myProvider],
623
+ });
624
+ ```
625
+
626
+ This displays as `<inline:my-provider>` instead of `<inline:1>`. Bare factory functions are still accepted for backward compatibility.
627
+
581
628
  **Event Bus:** Extensions can communicate via `pi.events`. Pass a shared `eventBus` to `DefaultResourceLoader` if you need to emit or listen from outside:
582
629
 
583
630
  ```typescript
@@ -1104,6 +1151,8 @@ AgentSessionRuntime
1104
1151
  // Auth and Models
1105
1152
  AuthStorage
1106
1153
  ModelRegistry
1154
+ resolveCliModel
1155
+ resolveModelScopeWithDiagnostics
1107
1156
 
1108
1157
  // Resource loading
1109
1158
  DefaultResourceLoader
@@ -1133,6 +1182,7 @@ createGrepTool, createFindTool, createLsTool
1133
1182
  type CreateAgentSessionOptions
1134
1183
  type CreateAgentSessionResult
1135
1184
  type ExtensionFactory
1185
+ type InlineExtension
1136
1186
  type ExtensionAPI
1137
1187
  type ToolDefinition
1138
1188
  type Skill
@@ -255,7 +255,7 @@ Extension state persistence. Does NOT participate in LLM context.
255
255
  {"type":"custom","id":"h8i9j0k1","parentId":"g7h8i9j0","timestamp":"2024-12-03T14:20:00.000Z","customType":"my-extension","data":{"count":42}}
256
256
  ```
257
257
 
258
- Use `customType` to identify your extension's entries on reload.
258
+ Use `customType` to identify your extension's entries on reload. Interactive mode can render custom entries via `pi.registerEntryRenderer(customType, renderer)`, but they still do not participate in LLM context.
259
259
 
260
260
  ### CustomMessageEntry
261
261
 
@@ -306,15 +306,24 @@ Entries form a tree:
306
306
 
307
307
  ## Context Building
308
308
 
309
- `buildSessionContext()` walks from the current leaf to the root, producing the message list for the LLM:
309
+ `buildContextEntries()` walks from the current leaf to the root, producing the active entry list while honoring compaction:
310
310
 
311
311
  1. Collects all entries on the path
312
- 2. Extracts current model and thinking level settings
313
- 3. If a `CompactionEntry` is on the path:
314
- - Emits the summary first
315
- - Then messages from `firstKeptEntryId` to compaction
316
- - Then messages after compaction
317
- 4. Converts `BranchSummaryEntry` and `CustomMessageEntry` to appropriate message formats
312
+ 2. If a `CompactionEntry` is on the path:
313
+ - Includes the compaction entry first
314
+ - Then entries from `firstKeptEntryId` to compaction
315
+ - Then entries after compaction
316
+ 3. Preserves non-message entries in the selected range so interactive mode can render them
317
+
318
+ `buildSessionContext()` builds on that entry list to produce the message list for the LLM:
319
+
320
+ 1. Extracts current model and thinking level settings from the full path
321
+ 2. Converts selected entries to messages:
322
+ - `message` -> stored `AgentMessage`
323
+ - `compaction` -> `compactionSummary`
324
+ - `branch_summary` -> `branchSummary`
325
+ - `custom_message` -> `CustomMessage`
326
+ - `custom` -> no context message
318
327
 
319
328
  ## Parsing Example
320
329
 
@@ -401,6 +410,7 @@ Key methods for working with sessions programmatically.
401
410
  - `branchWithSummary(entryId, summary, details?, fromHook?)` - Branch with context summary
402
411
 
403
412
  ### Instance Methods - Context & Info
413
+ - `buildContextEntries()` - Get active branch entries with compaction applied
404
414
  - `buildSessionContext()` - Get messages, thinkingLevel, and model for LLM
405
415
  - `getEntries()` - All entries (excluding header)
406
416
  - `getHeader()` - Session header metadata
package/docs/settings.md CHANGED
@@ -31,6 +31,7 @@ Use `/trust` in interactive mode to save a project trust decision for future ses
31
31
  | `defaultModel` | string | - | Default model ID |
32
32
  | `defaultThinkingLevel` | string | - | `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"` |
33
33
  | `hideThinkingBlock` | boolean | `false` | Hide thinking blocks in output |
34
+ | `showCacheMissNotices` | boolean | `false` | Show transcript notices for significant prompt-cache misses |
34
35
  | `thinkingBudgets` | object | - | Custom token budgets per thinking level |
35
36
 
36
37
  #### thinkingBudgets
@@ -51,6 +52,7 @@ Use `/trust` in interactive mode to save a project trust decision for future ses
51
52
  | Setting | Type | Default | Description |
52
53
  |---------|------|---------|-------------|
53
54
  | `theme` | string | `"dark"` | Theme name (`"dark"`, `"light"`, or custom) |
55
+ | `externalEditor` | string | `$VISUAL`, then `$EDITOR`, then Notepad on Windows or `nano` elsewhere | Command for Ctrl+G external editor; takes precedence over environment variables |
54
56
  | `quietStartup` | boolean | `false` | Hide startup header |
55
57
  | `defaultProjectTrust` | string | `"ask"` | Fallback project trust behavior: `"ask"`, `"always"`, or `"never"`. Global setting only |
56
58
  | `collapseChangelog` | boolean | `false` | Show condensed changelog after updates |
@@ -60,9 +62,18 @@ Use `/trust` in interactive mode to save a project trust decision for future ses
60
62
  | `doubleEscapeAction` | string | `"tree"` | Action for double-escape: `"tree"`, `"fork"`, or `"none"` |
61
63
  | `treeFilterMode` | string | `"default"` | Default filter for `/tree`: `"default"`, `"no-tools"`, `"user-only"`, `"labeled-only"`, `"all"` |
62
64
  | `editorPaddingX` | number | `0` | Horizontal padding for input editor (0-3) |
65
+ | `outputPad` | number | `1` | Horizontal padding for user messages, assistant messages, and thinking (0 or 1) |
63
66
  | `autocompleteMaxVisible` | number | `5` | Max visible items in autocomplete dropdown (3-20) |
64
67
  | `showHardwareCursor` | boolean | `false` | Show the terminal cursor while TUI positions it for IME support |
65
68
 
69
+ For VS Code, include `--wait` so pi resumes after the editor exits:
70
+
71
+ ```json
72
+ {
73
+ "externalEditor": "code --wait"
74
+ }
75
+ ```
76
+
66
77
  ### Telemetry and update checks
67
78
 
68
79
  `enableInstallTelemetry` only controls the anonymous install/update ping to `https://pi.dev/api/report-install`. Opting out of telemetry does not disable update checks; Pi can still fetch `https://pi.dev/api/latest-version` to look for the latest version.
package/docs/usage.md CHANGED
@@ -25,7 +25,7 @@ The editor can be replaced temporarily by built-in UI such as `/settings` or by
25
25
  | Images | Paste with Ctrl+V, Alt+V on Windows, or drag into the terminal |
26
26
  | Shell command | `!command` runs and sends output to the model |
27
27
  | Hidden shell command | `!!command` runs without sending output to the model |
28
- | External editor | Ctrl+G opens `$VISUAL` or `$EDITOR` |
28
+ | External editor | Ctrl+G opens `externalEditor`, `$VISUAL`, `$EDITOR`, Notepad on Windows, or `nano` elsewhere |
29
29
 
30
30
  See [Keybindings](keybindings.md) for all shortcuts and customization.
31
31
 
@@ -52,7 +52,7 @@ Type `/` in the editor to open command completion. Extensions can register custo
52
52
  | `/export [file]` | Export session to HTML or JSONL |
53
53
  | `/import <file>` | Import and resume a session from a JSONL file |
54
54
  | `/share` | Upload as private GitHub gist with shareable HTML link |
55
- | `/reload` | Reload keybindings, extensions, skills, prompts, and context files |
55
+ | `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |
56
56
  | `/hotkeys` | Show all keyboard shortcuts |
57
57
  | `/changelog` | Display version history |
58
58
  | `/quit` | Quit pi |
@@ -297,7 +297,7 @@ pi --exclude-tools ask_question
297
297
  | `PI_SKIP_VERSION_CHECK` | Skip the Pi version update check at startup. This prevents the `pi.dev` latest-version request |
298
298
  | `PI_TELEMETRY` | Override install/update telemetry and provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no`. This does not disable update checks |
299
299
  | `PI_CACHE_RETENTION` | Set to `long` for extended prompt cache where supported |
300
- | `VISUAL`, `EDITOR` | External editor for Ctrl+G |
300
+ | `VISUAL`, `EDITOR` | Fallback external editor for Ctrl+G when `externalEditor` is unset; defaults to Notepad on Windows and `nano` elsewhere |
301
301
 
302
302
  ## Design Principles
303
303
 
@@ -112,6 +112,7 @@ cp permission-gate.ts ~/.pi/agent/extensions/
112
112
  | Extension | Description |
113
113
  |-----------|-------------|
114
114
  | `message-renderer.ts` | Custom message rendering with colors and expandable details via `registerMessageRenderer` |
115
+ | `entry-renderer.ts` | TUI-only session entry rendering via `appendEntry` and `registerEntryRenderer` |
115
116
  | `event-bus.ts` | Inter-extension communication via `pi.events` |
116
117
 
117
118
  ### Session Metadata
@@ -93,6 +93,7 @@ ${conversationText}
93
93
  {
94
94
  apiKey: auth.apiKey,
95
95
  headers: auth.headers,
96
+ env: auth.env,
96
97
  maxTokens: 8192,
97
98
  signal,
98
99
  },
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "0.80.2",
3
+ "version": "0.80.5",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "0.80.2",
9
+ "version": "0.80.5",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.52.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-anthropic",
3
3
  "private": true,
4
- "version": "0.80.2",
4
+ "version": "0.80.5",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "0.80.2",
4
+ "version": "0.80.5",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",