apex-code 0.0.1-alpha.7 → 0.0.1-alpha.8

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 (256) hide show
  1. package/CHANGELOG.md +146 -0
  2. package/README.md +5 -0
  3. package/dist/cli/args.d.ts +3 -1
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +15 -0
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/concurrent-session.d.ts +3 -0
  8. package/dist/cli/concurrent-session.d.ts.map +1 -0
  9. package/dist/cli/concurrent-session.js +13 -0
  10. package/dist/cli/concurrent-session.js.map +1 -0
  11. package/dist/cli.d.ts.map +1 -1
  12. package/dist/cli.js +1 -2
  13. package/dist/cli.js.map +1 -1
  14. package/dist/core/agent-session-services.d.ts.map +1 -1
  15. package/dist/core/agent-session-services.js +20 -0
  16. package/dist/core/agent-session-services.js.map +1 -1
  17. package/dist/core/agent-session.d.ts +15 -2
  18. package/dist/core/agent-session.d.ts.map +1 -1
  19. package/dist/core/agent-session.js +9 -6
  20. package/dist/core/agent-session.js.map +1 -1
  21. package/dist/core/auth-storage.d.ts +4 -1
  22. package/dist/core/auth-storage.d.ts.map +1 -1
  23. package/dist/core/auth-storage.js +6 -2
  24. package/dist/core/auth-storage.js.map +1 -1
  25. package/dist/core/bash-executor.d.ts.map +1 -1
  26. package/dist/core/bash-executor.js +10 -9
  27. package/dist/core/bash-executor.js.map +1 -1
  28. package/dist/core/experimental.d.ts +4 -0
  29. package/dist/core/experimental.d.ts.map +1 -1
  30. package/dist/core/experimental.js +4 -0
  31. package/dist/core/experimental.js.map +1 -1
  32. package/dist/core/extensions/types.d.ts +4 -0
  33. package/dist/core/extensions/types.d.ts.map +1 -1
  34. package/dist/core/extensions/types.js.map +1 -1
  35. package/dist/core/http-dispatcher.d.ts +1 -2
  36. package/dist/core/http-dispatcher.d.ts.map +1 -1
  37. package/dist/core/http-dispatcher.js +2 -17
  38. package/dist/core/http-dispatcher.js.map +1 -1
  39. package/dist/core/http-idle-timeout.d.ts +12 -0
  40. package/dist/core/http-idle-timeout.d.ts.map +1 -0
  41. package/dist/core/http-idle-timeout.js +27 -0
  42. package/dist/core/http-idle-timeout.js.map +1 -0
  43. package/dist/core/keybindings.d.ts +24 -0
  44. package/dist/core/keybindings.d.ts.map +1 -1
  45. package/dist/core/lsp/client.d.ts +2 -0
  46. package/dist/core/lsp/client.d.ts.map +1 -1
  47. package/dist/core/lsp/client.js +27 -2
  48. package/dist/core/lsp/client.js.map +1 -1
  49. package/dist/core/model-config.d.ts +5 -0
  50. package/dist/core/model-config.d.ts.map +1 -1
  51. package/dist/core/model-config.js +1 -0
  52. package/dist/core/model-config.js.map +1 -1
  53. package/dist/core/sandbox/child-entry.d.ts.map +1 -1
  54. package/dist/core/sandbox/child-entry.js +8 -1
  55. package/dist/core/sandbox/child-entry.js.map +1 -1
  56. package/dist/core/sandbox/cli-launch.d.ts +3 -0
  57. package/dist/core/sandbox/cli-launch.d.ts.map +1 -1
  58. package/dist/core/sandbox/cli-launch.js +25 -4
  59. package/dist/core/sandbox/cli-launch.js.map +1 -1
  60. package/dist/core/sandbox/cli-supervisor.d.ts.map +1 -1
  61. package/dist/core/sandbox/cli-supervisor.js +53 -13
  62. package/dist/core/sandbox/cli-supervisor.js.map +1 -1
  63. package/dist/core/sandbox/linux-backend.d.ts.map +1 -1
  64. package/dist/core/sandbox/linux-backend.js +15 -0
  65. package/dist/core/sandbox/linux-backend.js.map +1 -1
  66. package/dist/core/sandbox/macos-backend.d.ts.map +1 -1
  67. package/dist/core/sandbox/macos-backend.js +24 -1
  68. package/dist/core/sandbox/macos-backend.js.map +1 -1
  69. package/dist/core/sandbox/rpc/credential-client.d.ts +20 -0
  70. package/dist/core/sandbox/rpc/credential-client.d.ts.map +1 -0
  71. package/dist/core/sandbox/rpc/credential-client.js +170 -0
  72. package/dist/core/sandbox/rpc/credential-client.js.map +1 -0
  73. package/dist/core/sandbox/rpc/credential-proxy.d.ts +44 -0
  74. package/dist/core/sandbox/rpc/credential-proxy.d.ts.map +1 -0
  75. package/dist/core/sandbox/rpc/credential-proxy.js +381 -0
  76. package/dist/core/sandbox/rpc/credential-proxy.js.map +1 -0
  77. package/dist/core/sandbox/supervisor.d.ts +11 -0
  78. package/dist/core/sandbox/supervisor.d.ts.map +1 -1
  79. package/dist/core/sandbox/supervisor.js.map +1 -1
  80. package/dist/core/sandbox/terminal-size.d.ts +40 -0
  81. package/dist/core/sandbox/terminal-size.d.ts.map +1 -0
  82. package/dist/core/sandbox/terminal-size.js +105 -0
  83. package/dist/core/sandbox/terminal-size.js.map +1 -0
  84. package/dist/core/sdk.d.ts +6 -3
  85. package/dist/core/sdk.d.ts.map +1 -1
  86. package/dist/core/sdk.js +16 -4
  87. package/dist/core/sdk.js.map +1 -1
  88. package/dist/core/session-lease.d.ts +31 -0
  89. package/dist/core/session-lease.d.ts.map +1 -0
  90. package/dist/core/session-lease.js +138 -0
  91. package/dist/core/session-lease.js.map +1 -0
  92. package/dist/core/session-manager.d.ts +5 -0
  93. package/dist/core/session-manager.d.ts.map +1 -1
  94. package/dist/core/session-manager.js +3 -3
  95. package/dist/core/session-manager.js.map +1 -1
  96. package/dist/core/settings-manager.d.ts +26 -0
  97. package/dist/core/settings-manager.d.ts.map +1 -1
  98. package/dist/core/settings-manager.js +42 -3
  99. package/dist/core/settings-manager.js.map +1 -1
  100. package/dist/core/slash-commands.d.ts.map +1 -1
  101. package/dist/core/slash-commands.js +2 -0
  102. package/dist/core/slash-commands.js.map +1 -1
  103. package/dist/core/system-prompt.d.ts +2 -2
  104. package/dist/core/system-prompt.d.ts.map +1 -1
  105. package/dist/core/system-prompt.js +47 -62
  106. package/dist/core/system-prompt.js.map +1 -1
  107. package/dist/core/tools/bash.d.ts.map +1 -1
  108. package/dist/core/tools/bash.js +2 -0
  109. package/dist/core/tools/bash.js.map +1 -1
  110. package/dist/core/tools/delegate.d.ts.map +1 -1
  111. package/dist/core/tools/delegate.js +24 -0
  112. package/dist/core/tools/delegate.js.map +1 -1
  113. package/dist/core/tools/edit.d.ts.map +1 -1
  114. package/dist/core/tools/edit.js +2 -0
  115. package/dist/core/tools/edit.js.map +1 -1
  116. package/dist/core/tools/find.d.ts.map +1 -1
  117. package/dist/core/tools/find.js +1 -1
  118. package/dist/core/tools/find.js.map +1 -1
  119. package/dist/core/tools/grep.d.ts +2 -0
  120. package/dist/core/tools/grep.d.ts.map +1 -1
  121. package/dist/core/tools/grep.js +35 -10
  122. package/dist/core/tools/grep.js.map +1 -1
  123. package/dist/core/tools/ls.d.ts +2 -0
  124. package/dist/core/tools/ls.d.ts.map +1 -1
  125. package/dist/core/tools/ls.js +5 -1
  126. package/dist/core/tools/ls.js.map +1 -1
  127. package/dist/core/tools/read.d.ts.map +1 -1
  128. package/dist/core/tools/read.js +2 -0
  129. package/dist/core/tools/read.js.map +1 -1
  130. package/dist/core/tools/web-search-exa.d.ts +33 -0
  131. package/dist/core/tools/web-search-exa.d.ts.map +1 -0
  132. package/dist/core/tools/web-search-exa.js +128 -0
  133. package/dist/core/tools/web-search-exa.js.map +1 -0
  134. package/dist/core/tools/write.d.ts.map +1 -1
  135. package/dist/core/tools/write.js +2 -0
  136. package/dist/core/tools/write.js.map +1 -1
  137. package/dist/core/web-search-provider.d.ts +64 -0
  138. package/dist/core/web-search-provider.d.ts.map +1 -0
  139. package/dist/core/web-search-provider.js +149 -0
  140. package/dist/core/web-search-provider.js.map +1 -0
  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 +1 -0
  145. package/dist/main.d.ts.map +1 -1
  146. package/dist/main.js +20 -1
  147. package/dist/main.js.map +1 -1
  148. package/dist/modes/interactive/components/custom-editor.d.ts +23 -0
  149. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  150. package/dist/modes/interactive/components/custom-editor.js +105 -2
  151. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  152. package/dist/modes/interactive/components/dynamic-border.d.ts +7 -1
  153. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  154. package/dist/modes/interactive/components/dynamic-border.js +11 -2
  155. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  156. package/dist/modes/interactive/components/extension-selector.d.ts +4 -0
  157. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  158. package/dist/modes/interactive/components/extension-selector.js +24 -6
  159. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  160. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  161. package/dist/modes/interactive/components/first-time-setup.js +6 -3
  162. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  163. package/dist/modes/interactive/components/first-use-hints.d.ts +8 -0
  164. package/dist/modes/interactive/components/first-use-hints.d.ts.map +1 -0
  165. package/dist/modes/interactive/components/first-use-hints.js +22 -0
  166. package/dist/modes/interactive/components/first-use-hints.js.map +1 -0
  167. package/dist/modes/interactive/components/footer.d.ts +12 -0
  168. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  169. package/dist/modes/interactive/components/footer.js +128 -9
  170. package/dist/modes/interactive/components/footer.js.map +1 -1
  171. package/dist/modes/interactive/components/index.d.ts +1 -0
  172. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  173. package/dist/modes/interactive/components/index.js +1 -0
  174. package/dist/modes/interactive/components/index.js.map +1 -1
  175. package/dist/modes/interactive/components/model-selector.d.ts +2 -0
  176. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  177. package/dist/modes/interactive/components/model-selector.js +20 -5
  178. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  179. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  180. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  181. package/dist/modes/interactive/components/settings-selector.js +10 -0
  182. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  183. package/dist/modes/interactive/components/splash-header.d.ts +29 -4
  184. package/dist/modes/interactive/components/splash-header.d.ts.map +1 -1
  185. package/dist/modes/interactive/components/splash-header.js +58 -23
  186. package/dist/modes/interactive/components/splash-header.js.map +1 -1
  187. package/dist/modes/interactive/components/tool-execution.d.ts +14 -0
  188. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  189. package/dist/modes/interactive/components/tool-execution.js +113 -35
  190. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  191. package/dist/modes/interactive/components/tool-panel.d.ts +30 -0
  192. package/dist/modes/interactive/components/tool-panel.d.ts.map +1 -0
  193. package/dist/modes/interactive/components/tool-panel.js +130 -0
  194. package/dist/modes/interactive/components/tool-panel.js.map +1 -0
  195. package/dist/modes/interactive/interactive-mode.d.ts +44 -9
  196. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  197. package/dist/modes/interactive/interactive-mode.js +282 -70
  198. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  199. package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
  200. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
  201. package/dist/modes/interactive/model-catalog-refresh.js +34 -0
  202. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
  203. package/dist/modes/interactive/theme/apex.json +62 -63
  204. package/dist/modes/interactive/theme/dark.json +2 -0
  205. package/dist/modes/interactive/theme/light.json +2 -0
  206. package/dist/modes/interactive/theme/theme-controller.d.ts +10 -2
  207. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  208. package/dist/modes/interactive/theme/theme-controller.js +25 -11
  209. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  210. package/dist/modes/interactive/theme/theme-schema.json +9 -1
  211. package/dist/modes/interactive/theme/theme.d.ts +14 -3
  212. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  213. package/dist/modes/interactive/theme/theme.js +55 -6
  214. package/dist/modes/interactive/theme/theme.js.map +1 -1
  215. package/dist/modes/json-event.d.ts +4 -1
  216. package/dist/modes/json-event.d.ts.map +1 -1
  217. package/dist/modes/json-event.js +5 -2
  218. package/dist/modes/json-event.js.map +1 -1
  219. package/dist/server/create-harness.d.ts.map +1 -1
  220. package/dist/server/create-harness.js +2 -0
  221. package/dist/server/create-harness.js.map +1 -1
  222. package/dist/themes/apex-logo.d.ts +36 -16
  223. package/dist/themes/apex-logo.d.ts.map +1 -1
  224. package/dist/themes/apex-logo.js +32 -28
  225. package/dist/themes/apex-logo.js.map +1 -1
  226. package/dist/utils/tools-manager.d.ts +10 -1
  227. package/dist/utils/tools-manager.d.ts.map +1 -1
  228. package/dist/utils/tools-manager.js +15 -20
  229. package/dist/utils/tools-manager.js.map +1 -1
  230. package/docs/compaction.md +3 -3
  231. package/docs/custom-provider.md +1 -1
  232. package/docs/environment-variables.md +1 -0
  233. package/docs/extensions.md +4 -0
  234. package/docs/json.md +6 -4
  235. package/docs/keybindings.md +8 -2
  236. package/docs/rpc.md +15 -4
  237. package/docs/sdk.md +9 -0
  238. package/docs/settings.md +63 -0
  239. package/docs/terminal-setup.md +23 -2
  240. package/docs/themes.md +24 -3
  241. package/docs/tui.md +2 -2
  242. package/docs/usage.md +3 -2
  243. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  244. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  245. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  246. package/examples/extensions/gondolin/package-lock.json +2 -2
  247. package/examples/extensions/gondolin/package.json +1 -1
  248. package/examples/extensions/sandbox/package-lock.json +2 -2
  249. package/examples/extensions/sandbox/package.json +1 -1
  250. package/examples/extensions/subagent/README.md +2 -0
  251. package/examples/extensions/subagent/agents.ts +40 -9
  252. package/examples/extensions/subagent/index.ts +21 -3
  253. package/examples/extensions/with-deps/package-lock.json +2 -2
  254. package/examples/extensions/with-deps/package.json +1 -1
  255. package/npm-shrinkwrap.json +27 -78
  256. package/package.json +6 -6
@@ -42,13 +42,13 @@ You can also trigger manually with `/compact [instructions]`, where optional ins
42
42
  2. **Extract messages**: Collect messages from the previous kept boundary (or session start) up to the cut point
43
43
  3. **Generate summary**: Call LLM to summarize with structured format, passing the previous summary as iterative context when present
44
44
  4. **Append entry**: Save `CompactionEntry` with summary and `firstKeptEntryId`
45
- 5. **Reload**: Session reloads, using summary + messages from `firstKeptEntryId` onwards
45
+ 5. **Rebuilds context**: Session rebuilds the context for the next request, using summary + messages from `firstKeptEntryId` onwards
46
46
 
47
47
  ```
48
48
  Before compaction:
49
49
 
50
50
  entry: 0 1 2 3 4 5 6 7 8 9
51
- ┌─────┬─────┬─────┬─────┬──────┬─────┬─────┬──────┬──────┬─────┐
51
+ ┌─────┬─────┬─────┬──────┬─────┬─────┬──────┬──────┬─────┬─────┐
52
52
  │ hdr │ usr │ ass │ tool │ usr │ ass │ tool │ tool │ ass │ tool│
53
53
  └─────┴─────┴─────┴──────┴─────┴─────┴──────┴──────┴─────┴─────┘
54
54
  └────────┬───────┘ └──────────────┬──────────────┘
@@ -59,7 +59,7 @@ Before compaction:
59
59
  After compaction (new entry appended):
60
60
 
61
61
  entry: 0 1 2 3 4 5 6 7 8 9 10
62
- ┌─────┬─────┬─────┬─────┬──────┬─────┬─────┬──────┬──────┬─────┬─────┐
62
+ ┌─────┬─────┬─────┬──────┬─────┬─────┬──────┬──────┬─────┬─────┬─────┐
63
63
  │ hdr │ usr │ ass │ tool │ usr │ ass │ tool │ tool │ ass │ tool│ cmp │
64
64
  └─────┴─────┴─────┴──────┴─────┴─────┴──────┴──────┴─────┴─────┴─────┘
65
65
  └──────────┬──────┘ └──────────────────────┬───────────────────┘
@@ -227,7 +227,7 @@ The `api` field determines which streaming implementation is used:
227
227
  | `openai-responses` | OpenAI Responses API |
228
228
  | `azure-openai-responses` | Azure OpenAI Responses API |
229
229
  | `openai-codex-responses` | OpenAI Codex Responses API |
230
- | `mistral-conversations` | Mistral SDK Conversations/Chat streaming |
230
+ | `mistral-conversations` | Native Mistral Chat Completions streaming |
231
231
  | `google-generative-ai` | Google Generative AI API |
232
232
  | `google-vertex` | Google Vertex AI API |
233
233
  | `bedrock-converse-stream` | Amazon Bedrock Converse API |
@@ -22,6 +22,7 @@ subprocess metadata. Provider API-key variables remain documented in
22
22
  | `APEX_CODE_SHARE_VIEWER_URL` | Optional base URL for preview links after `/share`; unset returns the GitHub Gist URL only |
23
23
  | `VISUAL`, `EDITOR` | External editor fallback |
24
24
  | `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
25
+ | `EXA_API_KEY` | Key for the `web_search` tool's Exa backend; unset leaves `web_search` unconfigured |
25
26
 
26
27
  The CLI and RPC entry points set `APEX_CODE_CODING_AGENT=true`. Commands run through
27
28
  the built-in bash tool receive `APEX_CODE_SESSION_ID`, `APEX_CODE_SESSION_FILE`,
@@ -1426,12 +1426,16 @@ pi.sendUserMessage([
1426
1426
  // During streaming - must specify delivery mode
1427
1427
  pi.sendUserMessage("Focus on error handling", { deliverAs: "steer" });
1428
1428
  pi.sendUserMessage("And then summarize", { deliverAs: "followUp" });
1429
+
1430
+ // Opt in to extension command dispatch and skill/prompt template expansion
1431
+ pi.sendUserMessage("/review src/index.ts", { expandPromptTemplates: true });
1429
1432
  ```
1430
1433
 
1431
1434
  **Options:**
1432
1435
  - `deliverAs` - Required when agent is streaming:
1433
1436
  - `"steer"` - Queues the message for delivery after the current assistant turn finishes executing its tool calls
1434
1437
  - `"followUp"` - Waits for agent to finish all tools
1438
+ - `expandPromptTemplates` - Dispatch extension commands and expand skill commands and prompt templates. Defaults to `false`.
1435
1439
 
1436
1440
  When not streaming, the message is sent immediately and triggers a new turn. When streaming without `deliverAs`, throws an error.
1437
1441
 
package/docs/json.md CHANGED
@@ -19,6 +19,7 @@ type JsonAgentSessionEvent =
19
19
  | Exclude<AgentSessionEvent, { type: "message_update" }>
20
20
  | {
21
21
  type: "message_update";
22
+ usage: Usage;
22
23
  assistantMessageEvent: WithoutPartial<AssistantMessageEvent>;
23
24
  };
24
25
  ```
@@ -73,16 +74,17 @@ Followed by events as they occur:
73
74
  {"type":"agent_start"}
74
75
  {"type":"turn_start"}
75
76
  {"type":"message_start","message":{"role":"assistant","content":[],...}}
76
- {"type":"message_update","assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":"Hello"}}
77
+ {"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":"Hello"}}
77
78
  {"type":"message_end","message":{...}}
78
79
  {"type":"turn_end","message":{...},"toolResults":[]}
79
80
  {"type":"agent_end","messages":[...]}
80
81
  ```
81
82
 
82
83
  `message_update` records are delta-only. They omit both the cumulative `message` field and
83
- `assistantMessageEvent.partial` to keep stream size linear. Use `contentIndex` and `delta`
84
- to assemble live text, thinking, or tool-call arguments if needed. `message_end` contains
85
- the final authoritative message.
84
+ `assistantMessageEvent.partial` to keep stream size linear. The top-level `usage` field contains
85
+ the latest cumulative provider-reported usage and may remain zero when a provider only reports
86
+ usage at completion. Use `contentIndex` and `delta` to assemble live text, thinking, or tool-call
87
+ arguments if needed. `message_end` contains the final authoritative message.
86
88
 
87
89
  ## Example
88
90
 
@@ -86,7 +86,7 @@ The dedicated history actions always change history entries, regardless of the c
86
86
 
87
87
  ### TUI Fullscreen Viewport
88
88
 
89
- These actions apply when interactive mode uses `--tui-mode fullscreen` and target the primary transcript scroll region. Two-finger trackpad and mouse-wheel input scroll the region under the pointer, falling back to the transcript over the fixed editor/status/footer dock. Clicking an OSC 8 hyperlink opens it in the default handler. Dragging with the primary mouse button selects text and copies it to the clipboard; holding at the transcript's top or bottom edge auto-scrolls into off-screen content.
89
+ These actions apply when interactive mode uses `--tui-mode fullscreen` and target the primary transcript scroll region. Two-finger trackpad and mouse-wheel input scroll the region under the pointer, falling back to the transcript over the fixed editor/status/footer dock. Clicking an OSC 8 hyperlink opens it in the default handler. Dragging with the primary mouse button selects text and copies it to the clipboard; holding at the transcript's top or bottom edge auto-scrolls into off-screen content. See [Terminal setup](terminal-setup.md) for terminal-specific mouse and trackpad behavior.
90
90
 
91
91
  Fullscreen transcript bindings take precedence over editor bindings. The default unmodified navigation keys therefore control the transcript in fullscreen mode, while their `ctrl` variants continue to control the editor. Outside fullscreen mode, both variants control the editor.
92
92
 
@@ -97,7 +97,7 @@ Fullscreen transcript bindings take precedence over editor bindings. The default
97
97
  | `pageUp`, `pageDown` | Editor | Transcript |
98
98
  | `ctrl+pageUp`, `ctrl+pageDown` | Editor | Editor |
99
99
 
100
- This routing remains configurable through the ordinary action bindings. For example, `"tui.altScreen.pageUp": "ctrl+pageUp"` makes `pageUp` control the editor and `ctrl+pageUp` control the transcript in fullscreen mode. Bind `tui.altScreen.halfPageUp` and `tui.altScreen.halfPageDown` for smaller transcript steps while keeping the full-page bindings. Setting `"tui.altScreen.pageUp": []` disables that transcript shortcut entirely. User bindings replace the defaults for that action.
100
+ This routing remains configurable through the ordinary action bindings. For example, `"tui.altScreen.pageUp": "ctrl+pageUp"` makes `pageUp` control the editor and `ctrl+pageUp` control the transcript in fullscreen mode. Bind `tui.altScreen.halfPageUp` and `tui.altScreen.halfPageDown` for half-page steps, or bind `tui.altScreen.lineUp` and `tui.altScreen.lineDown` for single-line steps. Setting `"tui.altScreen.pageUp": []` disables that transcript shortcut entirely. User bindings replace the defaults for that action.
101
101
 
102
102
  | Keybinding id | Default | Description |
103
103
  |--------|---------|-------------|
@@ -105,8 +105,14 @@ This routing remains configurable through the ordinary action bindings. For exam
105
105
  | `tui.altScreen.pageDown` | `pageDown` | Scroll the transcript down by one page |
106
106
  | `tui.altScreen.halfPageUp` | *(none)* | Scroll the transcript up by half a page |
107
107
  | `tui.altScreen.halfPageDown` | *(none)* | Scroll the transcript down by half a page |
108
+ | `tui.altScreen.lineUp` | *(none)* | Scroll the transcript up by one line |
109
+ | `tui.altScreen.lineDown` | *(none)* | Scroll the transcript down by one line |
108
110
  | `tui.altScreen.previousPrompt` | `ctrl+shift+up` | Jump to the previous marked message |
109
111
  | `tui.altScreen.nextPrompt` | `ctrl+shift+down` | Jump to the next marked message |
112
+ | `tui.altScreen.search` | `ctrl+shift+f` | Search the rendered transcript |
113
+ | `tui.altScreen.searchNext` | `enter`, `ctrl+g` | Select the next search match while searching |
114
+ | `tui.altScreen.searchPrevious` | `shift+enter`, `ctrl+shift+g` | Select the previous search match while searching |
115
+ | `tui.altScreen.searchClose` | `escape` | Close transcript search |
110
116
  | `tui.altScreen.top` | `home` | Scroll to the beginning of the transcript |
111
117
  | `tui.altScreen.bottom` | `end` | Scroll to the transcript end and follow new output |
112
118
 
package/docs/rpc.md CHANGED
@@ -919,6 +919,14 @@ Emitted during streaming of assistant messages. Contains a delta event without a
919
919
  ```json
920
920
  {
921
921
  "type": "message_update",
922
+ "usage": {
923
+ "input": 100,
924
+ "output": 1,
925
+ "cacheRead": 0,
926
+ "cacheWrite": 0,
927
+ "totalTokens": 101,
928
+ "cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0, "total": 0}
929
+ },
922
930
  "assistantMessageEvent": {
923
931
  "type": "text_delta",
924
932
  "contentIndex": 0,
@@ -943,12 +951,15 @@ The `assistantMessageEvent` field contains one of these delta types:
943
951
 
944
952
  Example streaming a text response:
945
953
  ```json
946
- {"type":"message_update","assistantMessageEvent":{"type":"text_start","contentIndex":0}}
947
- {"type":"message_update","assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":"Hello"}}
948
- {"type":"message_update","assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":" world"}}
949
- {"type":"message_update","assistantMessageEvent":{"type":"text_end","contentIndex":0,"content":"Hello world"}}
954
+ {"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_start","contentIndex":0}}
955
+ {"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":"Hello"}}
956
+ {"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":" world"}}
957
+ {"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_end","contentIndex":0,"content":"Hello world"}}
950
958
  ```
951
959
 
960
+ The top-level `usage` field contains the latest cumulative provider-reported usage. It may remain
961
+ zero until completion when a provider does not report usage during streaming.
962
+
952
963
  `message_update` intentionally omits the former cumulative `message` field and
953
964
  `assistantMessageEvent.partial`. Clients that need a live partial message must assemble it
954
965
  from `message_start` and subsequent events using `contentIndex`. Treat `message_end.message`
package/docs/sdk.md CHANGED
@@ -372,6 +372,13 @@ import { ModelRuntime } from "apex-code";
372
372
 
373
373
  const modelRuntime = await ModelRuntime.create();
374
374
 
375
+ // create() restores cached catalogs but does not refresh them from pi.dev by default.
376
+ // Opt in to a create-time network refresh and bound how long it may take:
377
+ const refreshedRuntime = await ModelRuntime.create({
378
+ allowModelNetwork: true,
379
+ modelRefreshTimeoutMs: 15_000,
380
+ });
381
+
375
382
  // Find specific built-in model (doesn't check if API key exists)
376
383
  const opus = getModel("anthropic", "claude-opus-4-5");
377
384
  if (!opus) throw new Error("Model not found");
@@ -402,6 +409,8 @@ If no model is provided:
402
409
  2. Uses default from settings
403
410
  3. Falls back to first available model
404
411
 
412
+ Remote catalogs are persisted locally so later runtimes can restore them without a network request. The default file is `~/.pi/agent/models-store.json`; set `modelsStorePath` to choose another location, or inject `modelsStore` to control persistence. Network refreshes are throttled to once per provider every four hours unless forced. To force an immediate refresh, call `await modelRuntime.refresh({ allowNetwork: true, force: true, signal })`. Setting `PI_OFFLINE` disables model network access.
413
+
405
414
  To match CLI model parsing, use the exported resolver helpers:
406
415
 
407
416
  ```typescript
package/docs/settings.md CHANGED
@@ -63,6 +63,7 @@ Use `/trust` in interactive mode to save a project trust decision for future ses
63
63
  | `autocompleteMaxVisible` | number | `5` | Max visible items in autocomplete dropdown (3-20) |
64
64
  | `showHardwareCursor` | boolean | `false` | Show the terminal cursor while TUI positions it for IME support |
65
65
  | `tuiMode` | string | `"regular"` | Interactive TUI mode: `"regular"` or experimental `"fullscreen"`. Changes from `/settings` apply immediately; `--tui-mode` overrides this setting at startup |
66
+ | `fullscreenExitOutput` | string | `"transcript"` | Fullscreen exit output: `"transcript"` prints the final transcript and resume hint, while `"resume-hint"` restores the previous screen and prints only the resume hint. Has no effect in regular TUI mode |
66
67
  | `fullscreenScrollbar` | string | `"auto"` | Fullscreen transcript scrollbar: `"auto"` shows it temporarily while scrolling, `"always"` reserves the rightmost column and keeps it visible, and `"hidden"` hides it. Has no effect in regular TUI mode |
67
68
 
68
69
  For VS Code, include `--wait` so Apex Code resumes after the editor exits:
@@ -90,6 +91,38 @@ Set `APEX_CODE_SKIP_VERSION_CHECK=1` to disable the Apex Code version update che
90
91
  }
91
92
  ```
92
93
 
94
+ ### Web search
95
+
96
+ The `web_search` tool is registered in every session but has no backend until a
97
+ credential resolves. Setting `EXA_API_KEY` in your environment is enough; the settings
98
+ below only matter if you want to override a default.
99
+
100
+ | Setting | Type | Default | Description |
101
+ |---------|------|---------|-------------|
102
+ | `webSearch.provider` | string | `"exa"` | Search backend. `"exa"` is the only value today. |
103
+ | `webSearch.apiKey` | string | `"$EXA_API_KEY"` | Where to read the key from. Must be a reference: `$VAR`, `${VAR}`, or `!command`. A literal key is refused, because `<project>/.apex-code/settings.json` is versioned and shared with your team. |
104
+ | `webSearch.numResults` | number | `10` | Results requested per search (1-100). |
105
+ | `webSearch.snippetMaxCharacters` | number | `800` | Per-result snippet budget. Snippets come from query-relevant highlights, falling back to page text. Higher costs context on every search. |
106
+ | `webSearch.endpoint` | string | `https://api.exa.ai/search` | Override for an API-compatible endpoint. |
107
+
108
+ ```json
109
+ {
110
+ "webSearch": {
111
+ "apiKey": "!op read op://private/exa/api-key",
112
+ "numResults": 5
113
+ }
114
+ }
115
+ ```
116
+
117
+ A credential stored under `exa` in `auth.json` is also used, and takes precedence over
118
+ the environment variable. Note that nothing writes it for you today: every interactive
119
+ session runs inside the OS sandbox, which mounts the credential file read-only, so
120
+ `auth.json` can only be edited outside a running session. `EXA_API_KEY` is the
121
+ supported path.
122
+
123
+ The backend's host is added to the sandbox network allowlist automatically once a
124
+ credential is configured, so `network.allowedHosts` needs no entry for it.
125
+
93
126
  ### Warnings
94
127
 
95
128
  | Setting | Type | Default | Description |
@@ -187,6 +220,20 @@ Keep `retry.provider.maxRetries` at `0` unless provider-level retries are explic
187
220
  | `shellCommandPrefix` | string | - | Prefix for every bash command (e.g., `"shopt -s expand_aliases"`) |
188
221
  | `npmCommand` | string[] | - | Command argv used for npm package lookup/install operations (e.g., `["mise", "exec", "node@20", "--", "npm"]`) |
189
222
 
223
+ Windows paths in JSON must use forward slashes or escaped backslashes:
224
+
225
+ ```json
226
+ {
227
+ "shellPath": "C:/Program Files/Git/bin/bash.exe"
228
+ }
229
+ ```
230
+
231
+ ```json
232
+ {
233
+ "shellPath": "C:\\Program Files\\Git\\bin\\bash.exe"
234
+ }
235
+ ```
236
+
190
237
  ```json
191
238
  {
192
239
  "npmCommand": ["mise", "exec", "node@20", "--", "npm"]
@@ -195,6 +242,22 @@ Keep `retry.provider.maxRetries` at `0` unless provider-level retries are explic
195
242
 
196
243
  `npmCommand` is used for all npm package-manager operations, including installs, uninstalls, and dependency installs inside git packages. User-scoped npm packages install under `~/.apex-code/agent/npm/`; project-scoped npm packages install under `.apex-code/npm/`. Use argv-style entries exactly as the process should be launched. When `npmCommand` is configured, git package dependency installs use plain `install` to avoid npm-specific flags in wrappers or alternate package managers.
197
244
 
245
+ ### Tools
246
+
247
+ | Setting | Type | Default | Description |
248
+ |---------|------|---------|-------------|
249
+ | `defaultTools` | string[] | - | Built-in tools enabled initially. When omitted, Pi uses its standard defaults |
250
+
251
+ `defaultTools` selects the built-in tools enabled at startup. Extension and SDK custom tools remain enabled:
252
+
253
+ ```json
254
+ {
255
+ "defaultTools": ["bash", "edit", "write"]
256
+ }
257
+ ```
258
+
259
+ An empty array starts with no built-in tools while preserving extension and SDK custom tools. `--tools` replaces this behavior with a strict allowlist for all tools, `--no-tools` disables all tools, and `--no-builtin-tools` disables the built-in defaults. `--exclude-tools` filters the resulting list. A project `defaultTools` array replaces the global array.
260
+
198
261
  ### Sessions
199
262
 
200
263
  | Setting | Type | Default | Description |
@@ -2,9 +2,26 @@
2
2
 
3
3
  Apex Code uses the [Kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/) for reliable modifier key detection. Most modern terminals support this protocol, but some require configuration.
4
4
 
5
- ## Kitty, iTerm2
5
+ ## Kitty
6
6
 
7
- Work out of the box.
7
+ Works out of the box.
8
+
9
+ ## iTerm2
10
+
11
+ ### Regular TUI mode
12
+
13
+ Works out of the box.
14
+
15
+ ### Fullscreen TUI mode
16
+
17
+ Pi owns the viewport, so iTerm2 sends mouse-wheel reports instead of scrolling its native scrollback. With iTerm2's default fast-trackpad behavior, those reports can lose most of an accelerated wheel delta, making fullscreen scrolling much slower than regular scrolling.
18
+
19
+ If fast mouse-wheel gestures move only about one line at a time in fullscreen mode:
20
+
21
+ 1. Open **iTerm2 → Settings → Advanced**.
22
+ 2. Search for **Trackpad scrolls fast?** and set it to **No**.
23
+
24
+ This is an iTerm2-wide workaround and may also change native trackpad scrolling. The underlying behavior is tracked in [iTerm2 issue 9619](https://gitlab.com/gnachman/iterm2/-/work_items/9619).
8
25
 
9
26
  ## Apple Terminal
10
27
 
@@ -32,6 +49,10 @@ If Claude Code 2.x or newer is the only reason you added that mapping, you can r
32
49
 
33
50
  Apex Code binds `Ctrl+J` as a default newline alias, so `Shift+Enter` keeps working in tmux via that remap without extra apex-code configuration.
34
51
 
52
+ ### Fullscreen TUI mode
53
+
54
+ In fullscreen mode, links remain clickable, but Ghostty does not show its hover underline or lower-left URL preview while pi captures mouse input. Hold `Shift+Command` on macOS or `Shift+Ctrl` on Linux to use Ghostty's native link handling.
55
+
35
56
  ## WezTerm
36
57
 
37
58
  WezTerm usually works out of the box for `Shift+Enter` via xterm modifyOtherKeys. To use the Kitty keyboard protocol explicitly, create `~/.wezterm.lua`:
package/docs/themes.md CHANGED
@@ -39,6 +39,23 @@ Select a theme via `/settings` or in `settings.json`:
39
39
 
40
40
  On first run, Apex Code detects your terminal background and defaults to `dark` or `light`.
41
41
 
42
+ ### Initial Theme
43
+
44
+ Start an interactive run with a theme without changing the saved setting:
45
+
46
+ ```bash
47
+ pi --use-theme light
48
+ ```
49
+
50
+ To follow terminal appearance, use `lightTheme/darkTheme` syntax:
51
+
52
+ ```bash
53
+ pi --use-theme light/dark
54
+ ```
55
+
56
+ The CLI value is the initial theme for that run. Choosing another theme later in `/settings` applies it immediately
57
+ and saves it normally.
58
+
42
59
  ## Creating a Custom Theme
43
60
 
44
61
  1. Create a theme file:
@@ -72,6 +89,8 @@ vim ~/.apex-code/agent/themes/my-theme.json
72
89
  "thinkingText": "secondary",
73
90
  "selectedBg": "#2d2d30",
74
91
  "scrollbarThumb": "#555566",
92
+ "searchMatchBg": "#2d2d30",
93
+ "searchMatchText": "",
75
94
  "userMessageBg": "#2d2d30",
76
95
  "userMessageText": "",
77
96
  "customMessageBg": "#2d2d30",
@@ -141,13 +160,13 @@ vim ~/.apex-code/agent/themes/my-theme.json
141
160
 
142
161
  - `name` is required, must be unique, and must not contain `/`.
143
162
  - `vars` is optional. Define reusable colors here, then reference them in `colors`.
144
- - `colors` must define all 51 required tokens. `thinkingMax` is optional and falls back to `thinkingXhigh`; `scrollbarThumb` is optional and falls back to `selectedBg`.
163
+ - `colors` must define all 51 required tokens. `thinkingMax`, `scrollbarThumb`, and the two search highlight tokens are optional and use the fallbacks listed below.
145
164
 
146
165
  The `$schema` field enables editor auto-completion and validation.
147
166
 
148
167
  ## Color Tokens
149
168
 
150
- Every theme must define all 51 required color tokens. `thinkingMax` and `scrollbarThumb` are optional for compatibility with existing themes; when omitted, they use `thinkingXhigh` and `selectedBg`, respectively.
169
+ Every theme must define all 51 required color tokens. The optional tokens preserve compatibility with existing themes: `thinkingMax` falls back to `thinkingXhigh`, `scrollbarThumb` and `searchMatchBg` fall back to `selectedBg`, and `searchMatchText` falls back to `text`. Other search matches use `searchMatchText` on `searchMatchBg` with an underline; the current match reverses that foreground/background pair and uses bold text.
151
170
 
152
171
  ### Core UI (11 colors)
153
172
 
@@ -165,12 +184,14 @@ Every theme must define all 51 required color tokens. `thinkingMax` and `scrollb
165
184
  | `text` | Default text (usually `""`) |
166
185
  | `thinkingText` | Thinking block text |
167
186
 
168
- ### Backgrounds & Content (11 required, 1 optional)
187
+ ### Backgrounds & Content (11 required, 3 optional)
169
188
 
170
189
  | Token | Purpose |
171
190
  |-------|---------|
172
191
  | `selectedBg` | Selected line background |
173
192
  | `scrollbarThumb` | Fullscreen scrollbar thumb background; optional, falls back to `selectedBg` |
193
+ | `searchMatchBg` | Transcript search match background and current-match text; optional, falls back to `selectedBg` |
194
+ | `searchMatchText` | Transcript search match text and current-match background; optional, falls back to `text` |
174
195
  | `userMessageBg` | User message background |
175
196
  | `userMessageText` | User message text |
176
197
  | `customMessageBg` | Extension message background |
package/docs/tui.md CHANGED
@@ -431,7 +431,7 @@ renderResult(result, options, theme, context) {
431
431
 
432
432
  | Category | Colors |
433
433
  |----------|--------|
434
- | General | `text`, `accent`, `muted`, `dim` |
434
+ | General | `text`, `accent`, `muted`, `dim`, `searchMatchText` |
435
435
  | Status | `success`, `error`, `warning` |
436
436
  | Borders | `border`, `borderAccent`, `borderMuted` |
437
437
  | Messages | `userMessageText`, `customMessageText`, `customMessageLabel` |
@@ -444,7 +444,7 @@ renderResult(result, options, theme, context) {
444
444
 
445
445
  **Background colors** (`theme.bg(color, text)`):
446
446
 
447
- `selectedBg`, `userMessageBg`, `customMessageBg`, `toolPendingBg`, `toolSuccessBg`, `toolErrorBg`
447
+ `selectedBg`, `searchMatchBg`, `userMessageBg`, `customMessageBg`, `toolPendingBg`, `toolSuccessBg`, `toolErrorBg`
448
448
 
449
449
  **For Markdown**, use `getMarkdownTheme()`:
450
450
 
package/docs/usage.md CHANGED
@@ -244,15 +244,16 @@ apex-code --no-extensions -e ./my-extension.ts
244
244
  | `--system-prompt <text>` | Replace default prompt; context files and skills are still appended |
245
245
  | `--append-system-prompt <text>` | Append to system prompt |
246
246
  | `--tui-mode <mode>` | TUI mode: `regular` (default) or experimental `fullscreen` |
247
+ | `--use-theme <name[/name]>` | Set the initial interactive theme for this run without changing settings |
247
248
  | `--verbose` | Force verbose startup |
248
249
  | `-a`, `--approve` | Trust project-local files for this run |
249
250
  | `-na`, `--no-approve` | Ignore project-local files for this run |
250
251
  | `-h`, `--help` | Show help |
251
252
  | `-v`, `--version` | Show version |
252
253
 
253
- In `fullscreen` mode, the transcript scrolls inside the terminal viewport while queued messages, working status, extension widgets, editor, and footer remain fixed at the bottom. Mouse/trackpad input scrolls the region under the pointer; keyboard viewport actions always remain available. Inline images work in terminals that support the Kitty graphics protocol, including Kitty and Ghostty. In iTerm2 they render as text placeholders because its inline-image protocol cannot delete or crop placements during application-owned scrolling. In `regular` mode, Apex Code uses the main screen and terminal-owned scrollback, and iTerm2 inline images continue to render normally.
254
+ In `fullscreen` mode, the transcript scrolls inside the terminal viewport while queued messages, working status, extension widgets, editor, and footer remain fixed at the bottom. Mouse/trackpad input scrolls the region under the pointer; keyboard viewport actions always remain available. Inline images work in terminals that support the Kitty graphics protocol, including Kitty and Ghostty. In iTerm2 they render as text placeholders because its inline-image protocol cannot delete or crop placements during application-owned scrolling. In `regular` mode, Apex Code uses the main screen and terminal-owned scrollback, and iTerm2 inline images continue to render normally. See [Terminal setup](terminal-setup.md) for terminal-specific settings and workarounds.
254
255
 
255
- Set **TUI mode** in `/settings` to switch between `regular` and `fullscreen` immediately and choose the default for future sessions.
256
+ Set **TUI mode** in `/settings` to switch between `regular` and `fullscreen` immediately and choose the default for future sessions. **Fullscreen exit output** controls whether exiting fullscreen prints the final transcript or restores the previous screen and prints only the session resume hint.
256
257
 
257
258
  ### File Arguments
258
259
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "0.84.1",
3
+ "version": "0.84.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "0.84.1",
9
+ "version": "0.84.2",
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.84.1",
4
+ "version": "0.84.2",
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.84.1",
4
+ "version": "0.84.2",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-gondolin",
3
- "version": "0.84.1",
3
+ "version": "0.84.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-gondolin",
9
- "version": "0.84.1",
9
+ "version": "0.84.2",
10
10
  "dependencies": {
11
11
  "@earendil-works/gondolin": "0.12.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-gondolin",
3
3
  "private": true,
4
- "version": "0.84.1",
4
+ "version": "0.84.2",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
- "version": "1.14.1",
3
+ "version": "1.14.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-sandbox",
9
- "version": "1.14.1",
9
+ "version": "1.14.2",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sandbox-runtime": "^0.0.26"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
3
  "private": true,
4
- "version": "1.14.1",
4
+ "version": "1.14.2",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -137,6 +137,8 @@ model: claude-haiku-4-5
137
137
  System prompt for the agent goes here.
138
138
  ```
139
139
 
140
+ When `model` is omitted, the subagent inherits the dispatching session's active model and thinking level.
141
+
140
142
  **Locations:**
141
143
  - `~/.pi/agent/agents/*.md` - User-level (always loaded)
142
144
  - `.pi/agents/*.md` - Project-level (only with `agentScope: "project"` or `"both"`)
@@ -23,6 +23,42 @@ export interface AgentDiscoveryResult {
23
23
  projectAgentsDir: string | null;
24
24
  }
25
25
 
26
+ /**
27
+ * Raw agent frontmatter. Values are `unknown` because `parseFrontmatter` runs a
28
+ * real YAML parser, so any scalar or collection can appear here.
29
+ *
30
+ * A type alias rather than an interface: `parseFrontmatter` constrains its
31
+ * parameter to `Record<string, unknown>`, and only an alias picks up the
32
+ * implicit index signature that satisfies it.
33
+ */
34
+ type AgentFrontmatter = {
35
+ name?: unknown;
36
+ description?: unknown;
37
+ tools?: unknown;
38
+ model?: unknown;
39
+ };
40
+
41
+ /**
42
+ * Normalize a frontmatter `tools` value to a list of tool names.
43
+ *
44
+ * Both spellings are valid YAML and both are in use:
45
+ *
46
+ * tools: read, bash # string
47
+ * tools: [read, bash] # array
48
+ *
49
+ * so accept either. Anything else (a number, a map, a nested list) yields no
50
+ * tools rather than throwing: this runs inside agent discovery, where a single
51
+ * bad file must not take down every other agent in the same directory.
52
+ */
53
+ function parseToolList(value: unknown): string[] | undefined {
54
+ const raw = Array.isArray(value) ? value : typeof value === "string" ? value.split(",") : [];
55
+ const tools = raw
56
+ .filter((t): t is string => typeof t === "string")
57
+ .map((t) => t.trim())
58
+ .filter(Boolean);
59
+ return tools.length > 0 ? tools : undefined;
60
+ }
61
+
26
62
  function loadAgentsFromDir(dir: string, source: "user" | "project"): AgentConfig[] {
27
63
  const agents: AgentConfig[] = [];
28
64
 
@@ -49,22 +85,17 @@ function loadAgentsFromDir(dir: string, source: "user" | "project"): AgentConfig
49
85
  continue;
50
86
  }
51
87
 
52
- const { frontmatter, body } = parseFrontmatter<Record<string, string>>(content);
88
+ const { frontmatter, body } = parseFrontmatter<AgentFrontmatter>(content);
53
89
 
54
- if (!frontmatter.name || !frontmatter.description) {
90
+ if (typeof frontmatter.name !== "string" || typeof frontmatter.description !== "string") {
55
91
  continue;
56
92
  }
57
93
 
58
- const tools = frontmatter.tools
59
- ?.split(",")
60
- .map((t: string) => t.trim())
61
- .filter(Boolean);
62
-
63
94
  agents.push({
64
95
  name: frontmatter.name,
65
96
  description: frontmatter.description,
66
- tools: tools && tools.length > 0 ? tools : undefined,
67
- model: frontmatter.model,
97
+ tools: parseToolList(frontmatter.tools),
98
+ model: typeof frontmatter.model === "string" ? frontmatter.model : undefined,
68
99
  systemPrompt: body,
69
100
  source,
70
101
  filePath,