@oh-my-pi/pi-coding-agent 17.2.4 → 17.2.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 (319) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/{CHANGELOG-bpmhv26t.md → CHANGELOG-q2w43aw3.md} +51 -0
  3. package/dist/cli.js +4148 -3717
  4. package/dist/{template-8vdv6xb4.js → template-c2hyaytt.js} +8 -26
  5. package/dist/types/cli/args.d.ts +4 -1
  6. package/dist/types/cli/browser-relay-cli.d.ts +15 -0
  7. package/dist/types/cli/command-help.d.ts +99 -0
  8. package/dist/types/cli/help-extra.d.ts +2 -0
  9. package/dist/types/cli/thinking-levels.d.ts +5 -0
  10. package/dist/types/cli/update-cli.d.ts +13 -0
  11. package/dist/types/commands/browser-relay.d.ts +38 -0
  12. package/dist/types/commands/commit.d.ts +3 -0
  13. package/dist/types/commands/complete.d.ts +1 -1
  14. package/dist/types/commands/completions.d.ts +6 -0
  15. package/dist/types/commands/grep.d.ts +3 -0
  16. package/dist/types/commands/join.d.ts +4 -0
  17. package/dist/types/commands/launch-help.d.ts +171 -0
  18. package/dist/types/commands/launch.d.ts +5 -1
  19. package/dist/types/commands/models.d.ts +3 -0
  20. package/dist/types/commands/say.d.ts +10 -0
  21. package/dist/types/commands/worktree.d.ts +3 -0
  22. package/dist/types/config/keybindings.d.ts +5 -0
  23. package/dist/types/config/model-discovery.d.ts +2 -2
  24. package/dist/types/config/models-config-schema-bundle.d.ts +3 -0
  25. package/dist/types/config/models-config-schema.d.ts +2 -0
  26. package/dist/types/config/models-config.d.ts +1 -0
  27. package/dist/types/config/service-tier.d.ts +2 -0
  28. package/dist/types/config/settings-schema.d.ts +69 -21
  29. package/dist/types/cursor-bridge-tools.d.ts +1 -1
  30. package/dist/types/cursor.d.ts +7 -4
  31. package/dist/types/edit/index.d.ts +3 -3
  32. package/dist/types/edit/modes/replace.d.ts +22 -15
  33. package/dist/types/edit/renderer.d.ts +1 -1
  34. package/dist/types/eval/py/kernel.d.ts +3 -1
  35. package/dist/types/eval/py/spawn-options.d.ts +12 -16
  36. package/dist/types/extensibility/legacy-pi-ai-shim.d.ts +8 -1
  37. package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +1 -1
  38. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +2 -0
  39. package/dist/types/launch/broker.d.ts +1 -1
  40. package/dist/types/launch/client.d.ts +6 -3
  41. package/dist/types/launch/ensure.d.ts +8 -0
  42. package/dist/types/launch/paths.d.ts +1 -1
  43. package/dist/types/launch/protocol.d.ts +2 -2
  44. package/dist/types/lsp/client.d.ts +2 -0
  45. package/dist/types/lsp/mux/daemon.d.ts +15 -0
  46. package/dist/types/lsp/mux/protocol.d.ts +57 -0
  47. package/dist/types/lsp/mux/server.d.ts +18 -0
  48. package/dist/types/lsp/types.d.ts +22 -2
  49. package/dist/types/main.d.ts +2 -0
  50. package/dist/types/mnemopi/embed-client.d.ts +1 -1
  51. package/dist/types/mnemopi/state.d.ts +0 -23
  52. package/dist/types/modes/components/assistant-message.d.ts +2 -0
  53. package/dist/types/modes/components/custom-editor.d.ts +2 -1
  54. package/dist/types/modes/components/read-tool-group.d.ts +2 -0
  55. package/dist/types/modes/components/stripped-tool-calls-placeholder.d.ts +12 -0
  56. package/dist/types/modes/components/tool-execution.d.ts +2 -0
  57. package/dist/types/modes/controllers/input-controller.d.ts +1 -0
  58. package/dist/types/modes/interactive-mode.d.ts +1 -0
  59. package/dist/types/modes/types.d.ts +1 -0
  60. package/dist/types/modes/workflow.d.ts +2 -1
  61. package/dist/types/sdk.d.ts +3 -1
  62. package/dist/types/secrets/index.d.ts +1 -1
  63. package/dist/types/session/agent-session-types.d.ts +3 -1
  64. package/dist/types/session/indexed-session-storage.d.ts +1 -0
  65. package/dist/types/session/session-advisors.d.ts +1 -1
  66. package/dist/types/session/session-context.d.ts +2 -1
  67. package/dist/types/session/session-maintenance.d.ts +1 -0
  68. package/dist/types/session/session-manager.d.ts +16 -11
  69. package/dist/types/session/session-stats.d.ts +10 -0
  70. package/dist/types/session/session-storage.d.ts +15 -3
  71. package/dist/types/system-prompt.d.ts +4 -1
  72. package/dist/types/task/index.d.ts +2 -1
  73. package/dist/types/task/spawn-policy.d.ts +5 -0
  74. package/dist/types/thinking.d.ts +1 -7
  75. package/dist/types/tools/ast-grep.d.ts +1 -1
  76. package/dist/types/tools/browser/registry.d.ts +2 -1
  77. package/dist/types/tools/browser/relay/bridge.d.ts +35 -0
  78. package/dist/types/tools/browser/relay/daemon.d.ts +16 -0
  79. package/dist/types/tools/browser/relay/kind.d.ts +19 -0
  80. package/dist/types/tools/browser/relay/protocol.d.ts +97 -0
  81. package/dist/types/tools/browser/relay/server.d.ts +35 -0
  82. package/dist/types/tools/browser/render.d.ts +1 -0
  83. package/dist/types/tools/browser.d.ts +3 -0
  84. package/dist/types/tools/computer/exposure.d.ts +9 -7
  85. package/dist/types/tools/computer/protocol.d.ts +70 -17
  86. package/dist/types/tools/computer/supervisor.d.ts +23 -10
  87. package/dist/types/tools/computer/worker-entry.d.ts +1 -0
  88. package/dist/types/tools/computer/worker.d.ts +42 -7
  89. package/dist/types/tools/computer-renderer.d.ts +7 -5
  90. package/dist/types/tools/computer.d.ts +25 -44
  91. package/dist/types/tools/context.d.ts +3 -0
  92. package/dist/types/tools/glob.d.ts +1 -1
  93. package/dist/types/tools/grep.d.ts +1 -1
  94. package/dist/types/tools/render-utils.d.ts +2 -0
  95. package/dist/types/tools/{browser/run-cancellation.d.ts → run-scope.d.ts} +8 -8
  96. package/dist/types/tools/tool-timeouts.d.ts +5 -0
  97. package/dist/types/tools/xdev.d.ts +8 -0
  98. package/dist/types/utils/clipboard.d.ts +2 -2
  99. package/dist/types/web/kagi.d.ts +1 -0
  100. package/dist/types/web/search/index.d.ts +1 -1
  101. package/dist/types/web/search/providers/anthropic.d.ts +1 -0
  102. package/dist/types/web/search/providers/base.d.ts +2 -0
  103. package/dist/types/web/search/providers/brave.d.ts +1 -0
  104. package/dist/types/web/search/providers/browser-page.d.ts +1 -0
  105. package/dist/types/web/search/providers/codex.d.ts +1 -0
  106. package/dist/types/web/search/providers/exa.d.ts +1 -0
  107. package/dist/types/web/search/providers/firecrawl.d.ts +1 -0
  108. package/dist/types/web/search/providers/gemini.d.ts +1 -0
  109. package/dist/types/web/search/providers/jina.d.ts +1 -0
  110. package/dist/types/web/search/providers/kagi.d.ts +1 -0
  111. package/dist/types/web/search/providers/kimi.d.ts +1 -0
  112. package/dist/types/web/search/providers/parallel.d.ts +1 -0
  113. package/dist/types/web/search/providers/perplexity.d.ts +1 -0
  114. package/dist/types/web/search/providers/searxng.d.ts +1 -0
  115. package/dist/types/web/search/providers/tavily.d.ts +1 -0
  116. package/dist/types/web/search/providers/tinyfish.d.ts +1 -0
  117. package/dist/types/web/search/providers/utils.d.ts +6 -9
  118. package/dist/types/web/search/providers/zai.d.ts +1 -0
  119. package/dist/types/web/search/types.d.ts +4 -0
  120. package/package.json +12 -12
  121. package/src/cli/args.ts +7 -87
  122. package/src/cli/browser-relay-cli.ts +119 -0
  123. package/src/cli/command-help.ts +103 -0
  124. package/src/cli/completion-gen.ts +5 -5
  125. package/src/cli/flag-tables.ts +9 -0
  126. package/src/cli/help-extra.ts +89 -0
  127. package/src/cli/setup-cli.ts +13 -21
  128. package/src/cli/thinking-levels.ts +7 -0
  129. package/src/cli/update-cli.ts +26 -7
  130. package/src/cli-commands.ts +170 -33
  131. package/src/cli.ts +17 -5
  132. package/src/commands/acp.ts +3 -1
  133. package/src/commands/agents.ts +3 -2
  134. package/src/commands/auth-broker.ts +3 -2
  135. package/src/commands/auth-gateway.ts +3 -2
  136. package/src/commands/bench.ts +2 -3
  137. package/src/commands/browser-relay.ts +53 -0
  138. package/src/commands/cleanse.ts +2 -2
  139. package/src/commands/commit.ts +3 -2
  140. package/src/commands/complete.ts +2 -1
  141. package/src/commands/completions.ts +3 -2
  142. package/src/commands/config.ts +3 -2
  143. package/src/commands/dry-balance.ts +2 -2
  144. package/src/commands/gallery.ts +3 -2
  145. package/src/commands/gc.ts +3 -2
  146. package/src/commands/grep.ts +3 -2
  147. package/src/commands/grievances.ts +3 -2
  148. package/src/commands/install.ts +2 -2
  149. package/src/commands/join.ts +3 -2
  150. package/src/commands/launch-help.ts +116 -0
  151. package/src/commands/launch.ts +7 -191
  152. package/src/commands/models.ts +3 -2
  153. package/src/commands/plugin.ts +3 -2
  154. package/src/commands/read.ts +3 -2
  155. package/src/commands/say.ts +3 -2
  156. package/src/commands/setup.ts +3 -2
  157. package/src/commands/shell.ts +3 -2
  158. package/src/commands/ssh.ts +3 -2
  159. package/src/commands/stats.ts +3 -2
  160. package/src/commands/tiny-models.ts +2 -2
  161. package/src/commands/token.ts +2 -2
  162. package/src/commands/ttsr.ts +2 -2
  163. package/src/commands/update.ts +3 -2
  164. package/src/commands/usage.ts +3 -2
  165. package/src/commands/web-search.ts +3 -2
  166. package/src/commands/worktree.ts +3 -2
  167. package/src/config/keybindings.ts +5 -0
  168. package/src/config/model-discovery.ts +30 -13
  169. package/src/config/model-registry.ts +9 -5
  170. package/src/config/models-config-schema-bundle.ts +9 -0
  171. package/src/config/resolve-config-value.ts +2 -1
  172. package/src/config/service-tier.ts +5 -0
  173. package/src/config/settings-schema.ts +72 -20
  174. package/src/cursor-bridge-tools.ts +1 -1
  175. package/src/cursor.ts +10 -14
  176. package/src/edit/diff.ts +17 -8
  177. package/src/edit/index.ts +20 -7
  178. package/src/edit/modes/replace.ts +93 -40
  179. package/src/edit/renderer.ts +1 -1
  180. package/src/edit/streaming.ts +14 -17
  181. package/src/eval/py/kernel.ts +2 -1
  182. package/src/eval/py/spawn-options.ts +24 -29
  183. package/src/export/html/template.js +8 -26
  184. package/src/extensibility/extensions/wrapper.ts +1 -0
  185. package/src/extensibility/legacy-pi-ai-shim.ts +22 -1
  186. package/src/extensibility/legacy-pi-coding-agent-shim.ts +7 -6
  187. package/src/extensibility/plugins/legacy-pi-compat.ts +124 -57
  188. package/src/extensibility/skills.ts +11 -0
  189. package/src/extensibility/utils.ts +10 -2
  190. package/src/launch/broker.ts +1 -1
  191. package/src/launch/client.ts +32 -13
  192. package/src/launch/ensure.ts +73 -0
  193. package/src/launch/paths.ts +1 -1
  194. package/src/launch/protocol.ts +2 -2
  195. package/src/lsp/client.ts +23 -2
  196. package/src/lsp/index.ts +8 -0
  197. package/src/lsp/mux/daemon.ts +348 -0
  198. package/src/lsp/mux/protocol.ts +96 -0
  199. package/src/lsp/mux/server.ts +797 -0
  200. package/src/lsp/types.ts +28 -2
  201. package/src/main.ts +7 -2
  202. package/src/mcp/oauth-flow.ts +11 -1
  203. package/src/mnemopi/embed-client.ts +49 -2
  204. package/src/mnemopi/state.ts +57 -23
  205. package/src/modes/components/assistant-message.ts +11 -0
  206. package/src/modes/components/chat-transcript-builder.ts +4 -0
  207. package/src/modes/components/custom-editor.ts +9 -0
  208. package/src/modes/components/read-tool-group.ts +10 -0
  209. package/src/modes/components/status-line/component.ts +1 -1
  210. package/src/modes/components/stripped-tool-calls-placeholder.ts +35 -0
  211. package/src/modes/components/tool-execution.ts +8 -0
  212. package/src/modes/components/tree-selector.ts +46 -48
  213. package/src/modes/controllers/event-controller.ts +17 -0
  214. package/src/modes/controllers/input-controller.ts +39 -1
  215. package/src/modes/controllers/mcp-command-controller.ts +11 -5
  216. package/src/modes/controllers/selector-controller.ts +20 -0
  217. package/src/modes/interactive-mode.ts +2 -0
  218. package/src/modes/types.ts +1 -0
  219. package/src/modes/utils/hotkeys-markdown.ts +1 -0
  220. package/src/modes/utils/interactive-context-helpers.ts +1 -0
  221. package/src/modes/utils/ui-helpers.ts +6 -10
  222. package/src/modes/workflow.ts +8 -2
  223. package/src/prompts/agents/init.md +1 -1
  224. package/src/prompts/system/plan-mode-active.md +2 -2
  225. package/src/prompts/system/system-prompt.md +26 -52
  226. package/src/prompts/system/workflow-notice.md +3 -3
  227. package/src/prompts/tools/ast-grep.md +1 -1
  228. package/src/prompts/tools/bash.md +1 -1
  229. package/src/prompts/tools/browser.md +1 -0
  230. package/src/prompts/tools/computer.md +21 -21
  231. package/src/prompts/tools/glob.md +1 -1
  232. package/src/prompts/tools/grep.md +1 -1
  233. package/src/prompts/tools/replace.md +5 -4
  234. package/src/prompts/tools/task.md +4 -4
  235. package/src/sdk.ts +34 -6
  236. package/src/secrets/index.ts +1 -1
  237. package/src/session/agent-session-types.ts +3 -1
  238. package/src/session/agent-session.ts +13 -1
  239. package/src/session/indexed-session-storage.ts +9 -0
  240. package/src/session/prewalk.ts +24 -2
  241. package/src/session/session-advisors.ts +2 -2
  242. package/src/session/session-context.ts +16 -12
  243. package/src/session/session-dump-format.ts +1 -1
  244. package/src/session/session-maintenance.ts +38 -4
  245. package/src/session/session-manager.ts +102 -67
  246. package/src/session/session-paths.ts +118 -55
  247. package/src/session/session-stats.ts +48 -3
  248. package/src/session/session-storage.ts +30 -22
  249. package/src/session/stream-guards.ts +1 -1
  250. package/src/slash-commands/builtin-registry.ts +27 -24
  251. package/src/system-prompt.ts +8 -3
  252. package/src/task/index.ts +23 -8
  253. package/src/task/spawn-policy.ts +14 -0
  254. package/src/thinking.ts +2 -8
  255. package/src/tools/ast-grep.ts +10 -4
  256. package/src/tools/browser/cmux/cmux-tab.ts +5 -10
  257. package/src/tools/browser/cmux/rpc.ts +2 -8
  258. package/src/tools/browser/registry.ts +53 -2
  259. package/src/tools/browser/relay/bridge.ts +945 -0
  260. package/src/tools/browser/relay/daemon.ts +117 -0
  261. package/src/tools/browser/relay/extension-assets/background.js.txt +242 -0
  262. package/src/tools/browser/relay/extension-assets/manifest.json.txt +14 -0
  263. package/src/tools/browser/relay/extension-assets/options.html.txt +53 -0
  264. package/src/tools/browser/relay/extension-assets/options.js.txt +23 -0
  265. package/src/tools/browser/relay/kind.ts +41 -0
  266. package/src/tools/browser/relay/protocol.ts +54 -0
  267. package/src/tools/browser/relay/server.ts +141 -0
  268. package/src/tools/browser/render.ts +4 -1
  269. package/src/tools/browser/shared-daemon.ts +7 -58
  270. package/src/tools/browser/tab-supervisor.ts +5 -4
  271. package/src/tools/browser/tab-worker.ts +33 -12
  272. package/src/tools/browser.ts +26 -1
  273. package/src/tools/computer/exposure.ts +11 -35
  274. package/src/tools/computer/protocol.ts +51 -10
  275. package/src/tools/computer/supervisor.ts +227 -124
  276. package/src/tools/computer/worker-entry.ts +11 -6
  277. package/src/tools/computer/worker.ts +695 -81
  278. package/src/tools/computer-renderer.ts +104 -65
  279. package/src/tools/computer.ts +134 -428
  280. package/src/tools/context.ts +3 -0
  281. package/src/tools/glob.ts +9 -2
  282. package/src/tools/grep.ts +12 -6
  283. package/src/tools/inspect-image.ts +32 -6
  284. package/src/tools/render-utils.ts +2 -0
  285. package/src/tools/{browser/run-cancellation.ts → run-scope.ts} +11 -11
  286. package/src/tools/tool-timeouts.ts +1 -0
  287. package/src/tools/xdev.ts +29 -2
  288. package/src/utils/clipboard.ts +40 -14
  289. package/src/utils/command-args.ts +26 -28
  290. package/src/utils/tool-choice.ts +0 -13
  291. package/src/web/kagi.ts +2 -1
  292. package/src/web/search/index.ts +18 -2
  293. package/src/web/search/providers/anthropic.ts +4 -1
  294. package/src/web/search/providers/base.ts +2 -0
  295. package/src/web/search/providers/brave.ts +3 -1
  296. package/src/web/search/providers/browser-page.ts +6 -4
  297. package/src/web/search/providers/codex.ts +4 -1
  298. package/src/web/search/providers/duckduckgo.ts +2 -1
  299. package/src/web/search/providers/ecosia.ts +2 -1
  300. package/src/web/search/providers/exa.ts +4 -2
  301. package/src/web/search/providers/firecrawl.ts +3 -1
  302. package/src/web/search/providers/gemini.ts +8 -2
  303. package/src/web/search/providers/google.ts +2 -1
  304. package/src/web/search/providers/jina.ts +12 -2
  305. package/src/web/search/providers/kagi.ts +3 -0
  306. package/src/web/search/providers/kimi.ts +5 -1
  307. package/src/web/search/providers/mojeek.ts +2 -1
  308. package/src/web/search/providers/parallel.ts +5 -1
  309. package/src/web/search/providers/perplexity.ts +6 -3
  310. package/src/web/search/providers/public.ts +1 -1
  311. package/src/web/search/providers/searxng.ts +11 -5
  312. package/src/web/search/providers/startpage.ts +10 -4
  313. package/src/web/search/providers/synthetic.ts +11 -5
  314. package/src/web/search/providers/tavily.ts +3 -1
  315. package/src/web/search/providers/tinyfish.ts +3 -1
  316. package/src/web/search/providers/utils.ts +12 -10
  317. package/src/web/search/providers/xai.ts +2 -2
  318. package/src/web/search/providers/zai.ts +18 -3
  319. package/src/web/search/types.ts +6 -0
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * Show provider usage limits for every authenticated account.
3
3
  */
4
+
4
5
  import { Args, Command, Flags } from "@oh-my-pi/pi-utils/cli";
6
+ import { usageHelp as commandHelp } from "../cli/command-help";
5
7
  import { runUsageCommand } from "../cli/usage-cli";
6
8
 
7
9
  export default class Usage extends Command {
8
- static description = "Show provider usage limits for every authenticated account";
9
-
10
+ static description = commandHelp.description;
10
11
  static args = {
11
12
  action: Args.string({
12
13
  description: "Optional subcommand to execute",
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Test web search providers.
3
3
  */
4
+
4
5
  import { Args, Command, Flags } from "@oh-my-pi/pi-utils/cli";
6
+ import { searchHelp as commandHelp } from "../cli/command-help";
5
7
  import { runSearchCommand, type SearchCommandArgs } from "../cli/web-search-cli";
6
8
  import { SEARCH_PROVIDER_ORDER } from "../web/search/provider";
7
9
 
@@ -10,8 +12,7 @@ const PROVIDERS: Array<string> = ["auto", ...SEARCH_PROVIDER_ORDER];
10
12
  const RECENCY: NonNullable<SearchCommandArgs["recency"]>[] = ["day", "week", "month", "year"];
11
13
 
12
14
  export default class Search extends Command {
13
- static description = "Test web search providers";
14
-
15
+ static description = commandHelp.description;
15
16
  static aliases = ["q"];
16
17
 
17
18
  static args = {
@@ -1,14 +1,15 @@
1
1
  /**
2
2
  * List and clean up agent-managed git worktrees under `~/.omp/wt`.
3
3
  */
4
+
4
5
  import { getProjectDir } from "@oh-my-pi/pi-utils";
5
6
  import { Args, Command, Flags } from "@oh-my-pi/pi-utils/cli";
7
+ import { worktreeHelp as commandHelp } from "../cli/command-help";
6
8
  import { clearWorktrees, listWorktrees } from "../cli/worktree-cli";
7
9
  import { Settings } from "../config/settings";
8
10
 
9
11
  export default class Worktree extends Command {
10
- static description = "List or clear agent-managed git worktrees (~/.omp/wt)";
11
-
12
+ static description = commandHelp.description;
12
13
  static aliases = ["wt"];
13
14
 
14
15
  static args = {
@@ -29,6 +29,7 @@ interface AppKeybindings {
29
29
  "app.model.select": true;
30
30
  "app.model.selectTemporary": true;
31
31
  "app.tools.expand": true;
32
+ "app.tools.toggleVisibility": true;
32
33
  "app.editor.external": true;
33
34
  "app.message.followUp": true;
34
35
  "app.retry": true;
@@ -124,6 +125,10 @@ export const KEYBINDINGS = {
124
125
  defaultKeys: "ctrl+o",
125
126
  description: "Expand tools",
126
127
  },
128
+ "app.tools.toggleVisibility": {
129
+ defaultKeys: "ctrl+shift+o",
130
+ description: "Show or hide tool activity",
131
+ },
127
132
  "app.editor.external": {
128
133
  defaultKeys: "ctrl+g",
129
134
  description: "Open external editor",
@@ -76,7 +76,10 @@ const REMOTE_DISCOVERY_TIMEOUT_MS = 10_000;
76
76
  * empty (issue #7087). Anything that is not strictly loopback therefore gets
77
77
  * {@link REMOTE_DISCOVERY_TIMEOUT_MS}.
78
78
  */
79
- export function discoveryProbeTimeoutMs(baseUrl: string, loopbackMs: number): number {
79
+ export function discoveryProbeTimeoutMs(baseUrl: string, loopbackMs: number, customTimeoutMs?: number): number {
80
+ if (typeof customTimeoutMs === "number" && customTimeoutMs > 0 && Number.isFinite(customTimeoutMs)) {
81
+ return customTimeoutMs;
82
+ }
80
83
  let hostname: string;
81
84
  try {
82
85
  hostname = new URL(baseUrl).hostname;
@@ -415,10 +418,11 @@ async function discoverOllamaModelMetadata(
415
418
  endpoint: string,
416
419
  modelId: string,
417
420
  headers: Record<string, string> | undefined,
421
+ customTimeoutMs?: number,
418
422
  ): Promise<OllamaDiscoveredModelMetadata | null> {
419
423
  const showUrl = `${endpoint}/api/show`;
420
424
  try {
421
- const payload = await withTimeoutSignal(discoveryProbeTimeoutMs(endpoint, 150), async signal => {
425
+ const payload = await withTimeoutSignal(discoveryProbeTimeoutMs(endpoint, 150, customTimeoutMs), async signal => {
422
426
  const response = await ctx.fetch(showUrl, {
423
427
  method: "POST",
424
428
  headers: { ...(headers ?? {}), "Content-Type": "application/json" },
@@ -471,7 +475,8 @@ export async function discoverOllamaModels(
471
475
  const endpoint = normalizeOllamaBaseUrl(providerConfig.baseUrl);
472
476
  const tagsUrl = `${endpoint}/api/tags`;
473
477
  const headers = { ...(providerConfig.headers ?? {}) };
474
- const payload = await withTimeoutSignal(discoveryProbeTimeoutMs(endpoint, 250), async signal => {
478
+ const customTimeoutMs = providerConfig.discovery.timeoutMs;
479
+ const payload = await withTimeoutSignal(discoveryProbeTimeoutMs(endpoint, 250, customTimeoutMs), async signal => {
475
480
  const response = await ctx.fetch(tagsUrl, {
476
481
  headers,
477
482
  signal,
@@ -488,7 +493,11 @@ export async function discoverOllamaModels(
488
493
  const metadataById = new Map(
489
494
  await Promise.all(
490
495
  entries.map(
491
- async entry => [entry.id, await discoverOllamaModelMetadata(ctx, endpoint, entry.id, headers)] as const,
496
+ async entry =>
497
+ [
498
+ entry.id,
499
+ await discoverOllamaModelMetadata(ctx, endpoint, entry.id, headers, customTimeoutMs),
500
+ ] as const,
492
501
  ),
493
502
  ),
494
503
  );
@@ -515,10 +524,11 @@ async function discoverLlamaCppServerMetadata(
515
524
  ctx: DiscoveryContext,
516
525
  baseUrl: string,
517
526
  headers: Record<string, string> | undefined,
527
+ customTimeoutMs?: number,
518
528
  ): Promise<LlamaCppDiscoveredServerMetadata | null> {
519
529
  const propsUrl = `${toLlamaCppNativeBaseUrl(baseUrl)}/props`;
520
530
  try {
521
- const payload = await withTimeoutSignal(discoveryProbeTimeoutMs(baseUrl, 150), async signal => {
531
+ const payload = await withTimeoutSignal(discoveryProbeTimeoutMs(baseUrl, 150, customTimeoutMs), async signal => {
522
532
  const response = await ctx.fetch(propsUrl, {
523
533
  headers,
524
534
  signal,
@@ -592,9 +602,10 @@ export async function discoverLlamaCppModels(
592
602
 
593
603
  const baseHeaders: Record<string, string> = { ...(providerConfig.headers ?? {}) };
594
604
  let headers = baseHeaders;
605
+ const customTimeoutMs = providerConfig.discovery.timeoutMs;
595
606
  const attempt = async (h: Record<string, string>) => {
596
607
  const [payload, metadata] = await Promise.all([
597
- withTimeoutSignal(discoveryProbeTimeoutMs(baseUrl, 250), async signal => {
608
+ withTimeoutSignal(discoveryProbeTimeoutMs(baseUrl, 250, customTimeoutMs), async signal => {
598
609
  const response = await ctx.fetch(modelsUrl, {
599
610
  headers: h,
600
611
  signal,
@@ -605,7 +616,7 @@ export async function discoverLlamaCppModels(
605
616
  headers = h;
606
617
  return (await response.json()) as unknown;
607
618
  }),
608
- discoverLlamaCppServerMetadata(ctx, baseUrl, h),
619
+ discoverLlamaCppServerMetadata(ctx, baseUrl, h, customTimeoutMs),
609
620
  ]);
610
621
  return [payload, metadata] as const;
611
622
  };
@@ -657,6 +668,7 @@ export async function discoverLlamaCppModels(
657
668
  export async function discoverLlamaCppModelRuntimeMetadata(
658
669
  model: Pick<Model<Api>, "provider" | "id" | "baseUrl" | "headers">,
659
670
  ctx: DiscoveryContext,
671
+ customTimeoutMs?: number,
660
672
  ): Promise<LlamaCppDiscoveredModelRuntimeMetadata | undefined> {
661
673
  const baseUrl = normalizeLlamaCppBaseUrl(model.baseUrl);
662
674
  // Probe the native `/models` endpoint (not the OpenAI-compatible `/v1/models`)
@@ -668,7 +680,7 @@ export async function discoverLlamaCppModelRuntimeMetadata(
668
680
  const baseHeaders: Record<string, string> = { ...(model.headers ?? {}) };
669
681
  const attempt = async (headers: Record<string, string>) => {
670
682
  const [entries, serverMetadata] = await Promise.all([
671
- withTimeoutSignal(discoveryProbeTimeoutMs(nativeBaseUrl, 250), async signal => {
683
+ withTimeoutSignal(discoveryProbeTimeoutMs(nativeBaseUrl, 250, customTimeoutMs), async signal => {
672
684
  const response = await ctx.fetch(modelsUrl, {
673
685
  headers,
674
686
  signal,
@@ -678,7 +690,7 @@ export async function discoverLlamaCppModelRuntimeMetadata(
678
690
  }
679
691
  return parseLlamaCppModelList(await response.json());
680
692
  }),
681
- discoverLlamaCppServerMetadata(ctx, nativeBaseUrl, headers),
693
+ discoverLlamaCppServerMetadata(ctx, nativeBaseUrl, headers, customTimeoutMs),
682
694
  ]);
683
695
  if (!entries) {
684
696
  return undefined;
@@ -721,13 +733,16 @@ export async function discoverOpenAIModelsList(
721
733
 
722
734
  const baseHeaders: Record<string, string> = { ...(providerConfig.headers ?? {}) };
723
735
  let headers = baseHeaders;
736
+ const timeoutMs = providerConfig.discovery.timeoutMs ?? 10_000;
724
737
  const attempt = async (h: Record<string, string>) => {
725
738
  const nativeMetadataPromise =
726
739
  providerConfig.discovery.type === "lm-studio"
727
- ? fetchLmStudioNativeModelMetadata(baseUrl, ctx.fetch, { headers: h })
740
+ ? withTimeoutSignal(timeoutMs, signal =>
741
+ fetchLmStudioNativeModelMetadata(baseUrl, ctx.fetch, { headers: h, signal }),
742
+ )
728
743
  : Promise.resolve(null);
729
744
  const [payload, nativeMetadata] = await Promise.all([
730
- withTimeoutSignal(10_000, async signal => {
745
+ withTimeoutSignal(timeoutMs, async signal => {
731
746
  const res = await ctx.fetch(modelsUrl, {
732
747
  headers: h,
733
748
  signal,
@@ -819,6 +834,7 @@ export async function discoverLiteLLMModels(
819
834
  const resolveReference = (id: string) => resolveModelReference(id, references) as ModelSpec<Api> | undefined;
820
835
  const baseHeaders: Record<string, string> = { ...(providerConfig.headers ?? {}) };
821
836
  let headers = baseHeaders;
837
+ const timeoutMs = providerConfig.discovery.timeoutMs ?? 10_000;
822
838
  const attempt = async (h: Record<string, string>) => {
823
839
  headers = h;
824
840
  let authError: (Error & { status: number }) | undefined;
@@ -830,7 +846,7 @@ export async function discoverLiteLLMModels(
830
846
  }
831
847
  return response;
832
848
  };
833
- const models = await withTimeoutSignal(10_000, signal =>
849
+ const models = await withTimeoutSignal(timeoutMs, signal =>
834
850
  fetchLiteLLMRichModels({
835
851
  api: providerConfig.api,
836
852
  provider: providerConfig.provider,
@@ -889,8 +905,9 @@ export async function discoverProxyModels(
889
905
 
890
906
  const baseHeaders: Record<string, string> = { ...(providerConfig.headers ?? {}) };
891
907
  let headers = baseHeaders;
908
+ const timeoutMs = providerConfig.discovery.timeoutMs ?? 10_000;
892
909
  const attempt = async (h: Record<string, string>) =>
893
- withTimeoutSignal(10_000, async signal => {
910
+ withTimeoutSignal(timeoutMs, async signal => {
894
911
  const res = await ctx.fetch(modelsUrl, {
895
912
  headers: h,
896
913
  signal,
@@ -73,7 +73,7 @@ import {
73
73
  inheritReferenceThinking,
74
74
  resolveModelReference,
75
75
  } from "@oh-my-pi/pi-catalog/identity";
76
- import { isBunTestRuntime, isRecord, logger, wrapFetchForExtraCa } from "@oh-my-pi/pi-utils";
76
+ import { $envExact, isBunTestRuntime, isRecord, logger, wrapFetchForExtraCa } from "@oh-my-pi/pi-utils";
77
77
  import { parseModelString, resolveProviderModelReference } from "../config/model-resolver";
78
78
  import { generateCodexAttestation } from "../live/attestation";
79
79
  import type { AuthStorage, OAuthCredential } from "../session/auth-storage";
@@ -329,7 +329,7 @@ interface CommandApiKeyResolution {
329
329
  */
330
330
  function resolveConfigValue(valueConfig: string): string | undefined {
331
331
  if (valueConfig.startsWith("!")) return resolveCommandConfig(valueConfig.slice(1).trim());
332
- const envValue = Bun.env[valueConfig];
332
+ const envValue = $envExact(valueConfig);
333
333
  if (envValue) return envValue;
334
334
  return valueConfig;
335
335
  }
@@ -972,14 +972,18 @@ export class ModelRegistry {
972
972
  * Refresh dynamic metadata that can appear only after a local model loads.
973
973
  */
974
974
  async refreshSelectedModelMetadata(model: Model<Api>): Promise<Model<Api>> {
975
- const isLlamaCppDiscovery = this.#discoverableProviders.some(
975
+ const llamaCppDiscoveryConfig = this.#discoverableProviders.find(
976
976
  providerConfig => providerConfig.provider === model.provider && providerConfig.discovery.type === "llama.cpp",
977
977
  );
978
- if (!isLlamaCppDiscovery) {
978
+ if (!llamaCppDiscoveryConfig) {
979
979
  return model;
980
980
  }
981
981
  this.#ensureFullSnapshot();
982
- const runtimeMetadata = await discoverLlamaCppModelRuntimeMetadata(model, this.#nonResolvingDiscoveryContext());
982
+ const runtimeMetadata = await discoverLlamaCppModelRuntimeMetadata(
983
+ model,
984
+ this.#nonResolvingDiscoveryContext(),
985
+ llamaCppDiscoveryConfig.discovery.timeoutMs,
986
+ );
983
987
  if (runtimeMetadata === undefined) {
984
988
  return this.find(model.provider, model.id) ?? model;
985
989
  }
@@ -262,6 +262,15 @@ export const getModelsConfigSchemaBundle = once(() => {
262
262
 
263
263
  const ProviderDiscoverySchema = type({
264
264
  type: '"ollama" | "llama.cpp" | "lm-studio" | "openai-models-list" | "proxy" | "litellm"',
265
+ "timeoutMs?": "number",
266
+ }).narrow((value, ctx) => {
267
+ if (
268
+ value.timeoutMs !== undefined &&
269
+ (typeof value.timeoutMs !== "number" || value.timeoutMs <= 0 || !Number.isFinite(value.timeoutMs))
270
+ ) {
271
+ return ctx.mustBe("timeoutMs a positive finite number");
272
+ }
273
+ return true;
265
274
  });
266
275
 
267
276
  const ProviderAuthSchema = type('"apiKey" | "none" | "oauth"');
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import { executeShell } from "@oh-my-pi/pi-natives";
8
+ import { $envExact } from "@oh-my-pi/pi-utils";
8
9
 
9
10
  /** Cache for successful shell command results (persists for process lifetime). */
10
11
  const commandResultCache = new Map<string, string>();
@@ -21,7 +22,7 @@ export async function resolveConfigValue(config: string): Promise<string | undef
21
22
  if (config.startsWith("!")) {
22
23
  return await executeCommand(config);
23
24
  }
24
- const envValue = process.env[config];
25
+ const envValue = $envExact(config);
25
26
  return envValue || config;
26
27
  }
27
28
 
@@ -16,6 +16,11 @@ export type ServiceTierOpenAISettingValue = (typeof SERVICE_TIER_OPENAI_VALUES)[
16
16
  export type ServiceTierAnthropicSettingValue = (typeof SERVICE_TIER_ANTHROPIC_VALUES)[number];
17
17
  export type ServiceTierGoogleSettingValue = (typeof SERVICE_TIER_GOOGLE_VALUES)[number];
18
18
 
19
+ /** Whether a runtime value is a supported OpenAI service-tier setting. */
20
+ export function isServiceTierOpenAISettingValue(value: string): value is ServiceTierOpenAISettingValue {
21
+ return SERVICE_TIER_OPENAI_VALUES.some(tier => tier === value);
22
+ }
23
+
19
24
  /** Whether a runtime value names a provider family with an independent service-tier knob. */
20
25
  export function isServiceTierFamily(value: unknown): value is ServiceTierFamily {
21
26
  return value === "openai" || value === "anthropic" || value === "google";
@@ -37,7 +37,12 @@ import {
37
37
  TTS_LOCAL_VOICE_VALUES,
38
38
  } from "../tts/models";
39
39
  import { EDIT_MODES } from "../utils/edit-mode";
40
- import { SEARCH_PROVIDER_CHOICES, type SearchProviderId } from "../web/search/types";
40
+ import {
41
+ DEFAULT_WEB_SEARCH_TIMEOUT_SECONDS,
42
+ MAX_WEB_SEARCH_TIMEOUT_SECONDS,
43
+ SEARCH_PROVIDER_CHOICES,
44
+ type SearchProviderId,
45
+ } from "../web/search/types";
41
46
  import {
42
47
  SERVICE_TIER_ANTHROPIC_OPTIONS,
43
48
  SERVICE_TIER_ANTHROPIC_VALUES,
@@ -1013,6 +1018,17 @@ export const SETTINGS_SCHEMA = {
1013
1018
  },
1014
1019
  },
1015
1020
 
1021
+ "display.hideToolActivity": {
1022
+ type: "boolean",
1023
+ default: false,
1024
+ ui: {
1025
+ tab: "appearance",
1026
+ group: "Display",
1027
+ label: "Hide Tool Activity",
1028
+ description: "Hide model-initiated tool calls and results from the transcript",
1029
+ },
1030
+ },
1031
+
1016
1032
  "display.showTokenUsage": {
1017
1033
  type: "boolean",
1018
1034
  default: false,
@@ -3382,6 +3398,18 @@ export const SETTINGS_SCHEMA = {
3382
3398
  },
3383
3399
  },
3384
3400
 
3401
+ "lsp.shared": {
3402
+ type: "boolean",
3403
+ default: true,
3404
+ ui: {
3405
+ tab: "files",
3406
+ group: "LSP",
3407
+ label: "Shared Language Servers",
3408
+ description:
3409
+ "Share one language server per project across omp instances via the daemon broker (falls back to private servers when unavailable)",
3410
+ },
3411
+ },
3412
+
3385
3413
  "lsp.formatOnWrite": {
3386
3414
  type: "boolean",
3387
3415
  default: false,
@@ -3897,23 +3925,7 @@ export const SETTINGS_SCHEMA = {
3897
3925
  tab: "tools",
3898
3926
  group: "Available Tools",
3899
3927
  label: "Computer",
3900
- description: "Enable native host-desktop screenshots and input for OpenAI computer use",
3901
- },
3902
- },
3903
-
3904
- "computer.backend": {
3905
- type: "enum",
3906
- values: ["auto", "native"] as const,
3907
- default: "auto",
3908
- ui: {
3909
- tab: "tools",
3910
- group: "Computer",
3911
- label: "Computer Backend",
3912
- description: "Select automatic or explicit platform-native desktop capture and input",
3913
- options: [
3914
- { value: "auto", label: "Auto" },
3915
- { value: "native", label: "Native" },
3916
- ],
3928
+ description: "Enable the scriptable host-desktop control tool (screenshots, input, accessibility)",
3917
3929
  },
3918
3930
  },
3919
3931
 
@@ -3930,7 +3942,7 @@ export const SETTINGS_SCHEMA = {
3930
3942
 
3931
3943
  "computer.maxWidth": {
3932
3944
  type: "number",
3933
- default: 1920,
3945
+ default: 3840,
3934
3946
  ui: {
3935
3947
  tab: "tools",
3936
3948
  group: "Computer",
@@ -3941,7 +3953,7 @@ export const SETTINGS_SCHEMA = {
3941
3953
 
3942
3954
  "computer.maxHeight": {
3943
3955
  type: "number",
3944
- default: 1200,
3956
+ default: 2400,
3945
3957
  ui: {
3946
3958
  tab: "tools",
3947
3959
  group: "Computer",
@@ -4108,6 +4120,29 @@ export const SETTINGS_SCHEMA = {
4108
4120
  },
4109
4121
  },
4110
4122
 
4123
+ "browser.relay": {
4124
+ type: "boolean",
4125
+ default: false,
4126
+ ui: {
4127
+ tab: "tools",
4128
+ group: "Grep & Browser",
4129
+ label: "Browser Relay",
4130
+ description:
4131
+ "Drive your own Chrome tabs through the omp browser relay. Install the extension once (`omp browser-relay install`); the relay server auto-starts when the browser tool needs it. Takes precedence over Browser CDP URL; set PI_BROWSER_RELAY=0 or PI_BROWSER_RELAY=1 to override.",
4132
+ },
4133
+ },
4134
+
4135
+ "browser.relayUrl": {
4136
+ type: "string",
4137
+ default: undefined,
4138
+ ui: {
4139
+ tab: "tools",
4140
+ group: "Grep & Browser",
4141
+ label: "Browser Relay URL",
4142
+ description: "omp browser relay endpoint (default http://127.0.0.1:9224).",
4143
+ },
4144
+ },
4145
+
4111
4146
  "browser.headless": {
4112
4147
  type: "boolean",
4113
4148
  default: true,
@@ -4869,6 +4904,23 @@ export const SETTINGS_SCHEMA = {
4869
4904
  options: SEARCH_PROVIDER_CHOICES,
4870
4905
  },
4871
4906
  },
4907
+ "providers.webSearchTimeoutSeconds": {
4908
+ type: "number",
4909
+ default: DEFAULT_WEB_SEARCH_TIMEOUT_SECONDS,
4910
+ ui: {
4911
+ tab: "providers",
4912
+ group: "Services",
4913
+ label: "Web Search Timeout",
4914
+ description: `Hard timeout for each provider's search transport before web_search advances to the next fallback, in seconds (maximum ${MAX_WEB_SEARCH_TIMEOUT_SECONDS})`,
4915
+ options: [
4916
+ { value: "30", label: "30 seconds" },
4917
+ { value: "60", label: "1 minute" },
4918
+ { value: "120", label: "2 minutes" },
4919
+ { value: "180", label: "3 minutes" },
4920
+ { value: "300", label: "5 minutes" },
4921
+ ],
4922
+ },
4923
+ },
4872
4924
  "providers.webSearchGeminiModel": {
4873
4925
  type: "string",
4874
4926
  default: undefined,
@@ -39,7 +39,7 @@ export function createBridgeGrepFactory(
39
39
  /**
40
40
  * Build the `replace`-mode `edit` the bridge answers `pi_edit` with.
41
41
  *
42
- * `PiEditExecArgs` carries `old_text`/`new_text` pairs, which is exactly
42
+ * `PiEditExecArgs` carries `old_string`/`new_string` replacements, which is exactly
43
43
  * `replace`'s schema and nothing else's. The session's own instance follows the
44
44
  * configured `edit.mode` — `hashline` by default, whose schema is a single
45
45
  * `input` string — so a frame handed that instance fails validation instead of
package/src/cursor.ts CHANGED
@@ -69,7 +69,7 @@ interface CursorExecBridgeOptions {
69
69
  *
70
70
  * `PiEditExecArgs` is that mode's schema verbatim, and the session's own
71
71
  * `edit` may be in any mode — `hashline` by default — whose schema rejects
72
- * `old_text`/`new_text` outright. {@link tools} therefore cannot be trusted
72
+ * `old_string`/`new_string` outright. {@link tools} therefore cannot be trusted
73
73
  * for this one frame: a session that starts on another provider keeps its
74
74
  * configured instance in the map (only Cursor sessions move `edit` out), and
75
75
  * switching to Cursor later does not rebuild the roster.
@@ -641,25 +641,21 @@ export class CursorExecHandlers implements ICursorExecHandlers {
641
641
  }
642
642
 
643
643
  /**
644
- * `PiEditExecArgs` is the local `edit` tool's replace mode verbatim: a path
645
- * plus `old_text`/`new_text` pairs. The tool's schema is snake_case, so the
646
- * proto's camelCase accessors are mapped back on the way in.
644
+ * `PiEditExecArgs` carries a path plus `oldText`/`newText` replacement
645
+ * pairs. A single replacement maps onto the model-facing single-edit
646
+ * `replace` schema verbatim; a multi-replacement frame still runs as ONE
647
+ * tool lifecycle (one start/end event pair, one aggregate diff), so it is
648
+ * sent in the tool's internal `edits` batch form (`ReplaceBatchParams`),
649
+ * which only this bridge produces.
647
650
  *
648
651
  * The replace-mode instance is requested explicitly rather than resolved
649
652
  * from {@link CursorExecBridgeOptions.tools}: the registry's `edit` is in
650
653
  * the session's configured mode, whose schema rejects these arguments.
651
654
  */
652
655
  async piEdit(call: Parameters<NonNullable<ICursorExecHandlers["piEdit"]>>[0]) {
653
- return await executeTool(
654
- this.options,
655
- "edit",
656
- call.toolCallId,
657
- {
658
- path: call.args.path,
659
- edits: call.args.edits.map(edit => ({ old_text: edit.oldText, new_text: edit.newText })),
660
- },
661
- this.options.getEditReplaceTool?.(),
662
- );
656
+ const edits = call.args.edits.map(edit => ({ old_string: edit.oldText, new_string: edit.newText }));
657
+ const args = edits.length === 1 ? { path: call.args.path, ...edits[0] } : { path: call.args.path, edits };
658
+ return await executeTool(this.options, "edit", call.toolCallId, args, this.options.getEditReplaceTool?.());
663
659
  }
664
660
 
665
661
  async piWrite(call: Parameters<NonNullable<ICursorExecHandlers["piWrite"]>>[0]) {
package/src/edit/diff.ts CHANGED
@@ -855,7 +855,6 @@ export function replaceText(content: string, oldText: string, newText: string, o
855
855
  let normalizedContent = normalizeToLF(content);
856
856
  const normalizedOldText = normalizeToLF(oldText);
857
857
  const normalizedNewText = normalizeToLF(newText);
858
- let count = 0;
859
858
 
860
859
  if (options.all) {
861
860
  // Check for exact matches first
@@ -867,11 +866,13 @@ export function replaceText(content: string, oldText: string, newText: string, o
867
866
  };
868
867
  }
869
868
 
870
- // No exact matches - try fuzzy matching iteratively
869
+ // Match against the immutable source so inserted replacement text cannot become a later candidate.
870
+ const replacements: Array<{ startIndex: number; endIndex: number; text: string }> = [];
871
871
  while (true) {
872
872
  const matchOutcome = findMatch(normalizedContent, normalizedOldText, {
873
873
  allowFuzzy: options.fuzzy,
874
874
  threshold,
875
+ excludedRanges: replacements,
875
876
  });
876
877
 
877
878
  const shouldUseClosest =
@@ -888,14 +889,22 @@ export function replaceText(content: string, oldText: string, newText: string, o
888
889
  if (adjustedNewText === match.actualText) {
889
890
  break;
890
891
  }
891
- normalizedContent =
892
- normalizedContent.substring(0, match.startIndex) +
893
- adjustedNewText +
894
- normalizedContent.substring(match.startIndex + match.actualText.length);
895
- count++;
892
+ replacements.push({
893
+ startIndex: match.startIndex,
894
+ endIndex: match.startIndex + Math.max(match.actualText.length, 1),
895
+ text: adjustedNewText,
896
+ });
896
897
  }
897
898
 
898
- return { content: normalizedContent, count };
899
+ replacements.sort((a, b) => a.startIndex - b.startIndex);
900
+ const parts: string[] = [];
901
+ let sourceIndex = 0;
902
+ for (const replacement of replacements) {
903
+ parts.push(normalizedContent.substring(sourceIndex, replacement.startIndex), replacement.text);
904
+ sourceIndex = replacement.endIndex;
905
+ }
906
+ parts.push(normalizedContent.substring(sourceIndex));
907
+ return { content: parts.join(""), count: replacements.length };
899
908
  }
900
909
 
901
910
  // Single replacement mode
package/src/edit/index.ts CHANGED
@@ -19,7 +19,7 @@ import { executeHashlineSingle, hashlineEditParamsSchema } from "./hashline";
19
19
  import { type ApplyPatchParams, applyPatchSchema, expandApplyPatchToEntries } from "./modes/apply-patch";
20
20
  import applyPatchGrammar from "./modes/apply-patch.lark" with { type: "text" };
21
21
  import { executePatchSingle, type PatchEditEntry, type PatchParams, patchEditSchema } from "./modes/patch";
22
- import { executeReplaceSingle, type ReplaceEditEntry, type ReplaceParams, replaceEditSchema } from "./modes/replace";
22
+ import { executeReplace, type ReplaceBatchParams, type ReplaceParams, replaceEditSchema } from "./modes/replace";
23
23
  import { type EditToolDetails, type EditToolPerFileResult, getLspBatchRequest, type LspBatchRequest } from "./renderer";
24
24
  import { pruneOversizedEditSnapshots } from "./snapshot-details";
25
25
  import { EDIT_MODE_STRATEGIES } from "./streaming";
@@ -46,7 +46,7 @@ type TInput =
46
46
 
47
47
  type HashlineParams = typeof hashlineEditParamsSchema.infer;
48
48
 
49
- type EditParams = ReplaceParams | PatchParams | HashlineParams | ApplyPatchParams;
49
+ type EditParams = ReplaceParams | ReplaceBatchParams | PatchParams | HashlineParams | ApplyPatchParams;
50
50
 
51
51
  type EditModeDefinition = {
52
52
  description: (session: ToolSession) => string;
@@ -402,7 +402,7 @@ export class EditTool implements AgentTool<TInput> {
402
402
  /**
403
403
  * `mode` pins the edit variant for this instance, for callers whose protocol
404
404
  * fixes the shape of an edit. The Cursor `pi_edit` frame carries
405
- * `old_text`/`new_text` pairs, which only `replace` accepts — under the
405
+ * `old_string`/`new_string` args, which only `replace` accepts — under the
406
406
  * default `hashline` mode those args do not match the schema at all. Left
407
407
  * unset, the env/settings resolution applies as before.
408
408
  */
@@ -662,11 +662,24 @@ export class EditTool implements AgentTool<TInput> {
662
662
  batchRequest: LspBatchRequest | undefined,
663
663
  onUpdate?: (partialResult: AgentToolResult<EditToolDetails, TInput>) => void,
664
664
  ) => {
665
- const { edits, path } = params as ReplaceParams;
666
- const targetPath = await resolveEditPath(tool.session, path, { mustExist: true, signal });
667
- const runs = (edits as ReplaceEditEntry[]).map(
665
+ // `edits` is the internal `ReplaceBatchParams` form only the Cursor
666
+ // exec bridge produces (multi-replacement `pi_edit` frames run as one
667
+ // lifecycle); model calls always arrive in the single-edit schema shape.
668
+ const replaceParams = params as ReplaceParams | ReplaceBatchParams;
669
+ const entries =
670
+ "edits" in replaceParams
671
+ ? replaceParams.edits
672
+ : [
673
+ {
674
+ old_string: replaceParams.old_string,
675
+ new_string: replaceParams.new_string,
676
+ replace_all: replaceParams.replace_all,
677
+ },
678
+ ];
679
+ const targetPath = await resolveEditPath(tool.session, replaceParams.path, { mustExist: true, signal });
680
+ const runs = entries.map(
668
681
  entry => (br: LspBatchRequest | undefined) =>
669
- executeReplaceSingle({
682
+ executeReplace({
670
683
  session: tool.session,
671
684
  path: targetPath,
672
685
  params: entry,