@bastani/atomic 0.9.18-alpha.4 → 0.9.18-alpha.6

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 (409) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +3 -3
  3. package/dist/builtin/intercom/CHANGELOG.md +41 -0
  4. package/dist/builtin/intercom/README.md +18 -3
  5. package/dist/builtin/intercom/broker/broker.ts +670 -127
  6. package/dist/builtin/intercom/broker/client.ts +149 -35
  7. package/dist/builtin/intercom/broker/delivered-message-cache.ts +497 -37
  8. package/dist/builtin/intercom/broker/framing.ts +4 -2
  9. package/dist/builtin/intercom/broker/paths.ts +10 -0
  10. package/dist/builtin/intercom/broker/pending-send-registry.ts +1 -2
  11. package/dist/builtin/intercom/broker/send-handler.ts +311 -52
  12. package/dist/builtin/intercom/broker/send-signature.ts +4 -2
  13. package/dist/builtin/intercom/broker/socket-writes.ts +103 -0
  14. package/dist/builtin/intercom/broker/spawn.ts +9 -4
  15. package/dist/builtin/intercom/index.bundle.mjs +1419 -213
  16. package/dist/builtin/intercom/package.json +2 -2
  17. package/dist/builtin/intercom/recoverable-disconnect.ts +52 -0
  18. package/dist/builtin/intercom/retry-policy.ts +8 -0
  19. package/dist/builtin/intercom/skills/intercom/SKILL.md +17 -9
  20. package/dist/builtin/intercom/types.ts +25 -8
  21. package/dist/builtin/intercom/workflow-stage-path-matching.ts +90 -0
  22. package/dist/builtin/intercom/workflow-stage-target.ts +57 -0
  23. package/dist/builtin/mcp/index.bundle.mjs +427 -126
  24. package/dist/builtin/mcp/package.json +2 -2
  25. package/dist/builtin/subagents/CHANGELOG.md +19 -0
  26. package/dist/builtin/subagents/README.md +3 -3
  27. package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
  28. package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
  29. package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
  30. package/dist/builtin/subagents/agents/codebase-online-researcher.md +11 -11
  31. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
  32. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
  33. package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
  34. package/dist/builtin/subagents/agents/debugger.md +3 -3
  35. package/dist/builtin/subagents/agents/worker.md +2 -2
  36. package/dist/builtin/subagents/package.json +3 -3
  37. package/dist/builtin/subagents/skills/qlty/SKILL.md +29 -101
  38. package/dist/builtin/subagents/skills/qlty/references/manual-configuration.md +52 -0
  39. package/dist/builtin/subagents/skills/subagent/SKILL.md +11 -11
  40. package/dist/builtin/subagents/src/extension/index.bundle.mjs +49 -132
  41. package/dist/builtin/web-access/package.json +2 -2
  42. package/dist/builtin/workflows/CHANGELOG.md +44 -0
  43. package/dist/builtin/workflows/README.md +7 -7
  44. package/dist/builtin/workflows/builtin/adversarial-verification.js +2 -2
  45. package/dist/builtin/workflows/builtin/{chunk-szz1ajz9.js → chunk-42s7sw0b.js} +9 -2
  46. package/dist/builtin/workflows/builtin/{chunk-2dqb5s2q.js → chunk-79fjkcvh.js} +1 -1
  47. package/dist/builtin/workflows/builtin/{chunk-n58a7v26.js → chunk-b0v2xab1.js} +181 -10
  48. package/dist/builtin/workflows/builtin/{chunk-fghhy2a5.js → chunk-ed4jfn5t.js} +23 -5
  49. package/dist/builtin/workflows/builtin/{chunk-h3r2vkzc.js → chunk-hqpe2cyx.js} +60 -21
  50. package/dist/builtin/workflows/builtin/{chunk-hzzn6adg.js → chunk-k3w87x8y.js} +1 -1
  51. package/dist/builtin/workflows/builtin/{chunk-82ha8p41.js → chunk-n8h4yyew.js} +1 -1
  52. package/dist/builtin/workflows/builtin/{chunk-qwzvgxnq.js → chunk-reqr3sr3.js} +1 -1
  53. package/dist/builtin/workflows/builtin/{chunk-c53y8bdh.js → chunk-wgccch41.js} +1 -1
  54. package/dist/builtin/workflows/builtin/{chunk-0x6e303p.js → chunk-zbekjqew.js} +20 -7
  55. package/dist/builtin/workflows/builtin/{chunk-29wrp38a.js → chunk-ze5x3d1r.js} +1 -1
  56. package/dist/builtin/workflows/builtin/classify-and-act.js +2 -2
  57. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +2 -2
  58. package/dist/builtin/workflows/builtin/generate-and-filter.js +2 -2
  59. package/dist/builtin/workflows/builtin/goal.js +3 -3
  60. package/dist/builtin/workflows/builtin/index.js +11 -11
  61. package/dist/builtin/workflows/builtin/loop-until-done.js +2 -2
  62. package/dist/builtin/workflows/builtin/open-claude-design.js +2 -2
  63. package/dist/builtin/workflows/builtin/ralph.js +3 -3
  64. package/dist/builtin/workflows/builtin/steering-context.js +1 -1
  65. package/dist/builtin/workflows/builtin/tournament.js +2 -2
  66. package/dist/builtin/workflows/package.json +2 -2
  67. package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +39 -52
  68. package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +9 -37
  69. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +49 -0
  70. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +57 -0
  71. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +57 -0
  72. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +47 -0
  73. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +57 -0
  74. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +60 -0
  75. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +58 -0
  76. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_astra.md +58 -0
  77. package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +18 -4
  78. package/dist/builtin/workflows/src/extension/index.bundle.mjs +3194 -737
  79. package/dist/builtin/workflows/src/index.js +899 -436
  80. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +0 -10
  81. package/dist/cli/list-models.d.ts.map +1 -1
  82. package/dist/cli/list-models.js +4 -0
  83. package/dist/cli/list-models.js.map +1 -1
  84. package/dist/client/index.d.ts +1 -2
  85. package/dist/client/index.d.ts.map +1 -1
  86. package/dist/client/index.js +1 -2
  87. package/dist/client/index.js.map +1 -1
  88. package/dist/config.d.ts +0 -9
  89. package/dist/config.d.ts.map +1 -1
  90. package/dist/config.js +0 -45
  91. package/dist/config.js.map +1 -1
  92. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  93. package/dist/core/agent-session-compaction.js +8 -6
  94. package/dist/core/agent-session-compaction.js.map +1 -1
  95. package/dist/core/agent-session-methods.d.ts +1 -0
  96. package/dist/core/agent-session-methods.d.ts.map +1 -1
  97. package/dist/core/agent-session-methods.js.map +1 -1
  98. package/dist/core/agent-session-models.d.ts.map +1 -1
  99. package/dist/core/agent-session-models.js +3 -4
  100. package/dist/core/agent-session-models.js.map +1 -1
  101. package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
  102. package/dist/core/agent-session-queue-pause.js +6 -0
  103. package/dist/core/agent-session-queue-pause.js.map +1 -1
  104. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  105. package/dist/core/agent-session-runtime.js +15 -7
  106. package/dist/core/agent-session-runtime.js.map +1 -1
  107. package/dist/core/agent-session-tool-hooks.js +1 -1
  108. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  109. package/dist/core/agent-session-tree.d.ts.map +1 -1
  110. package/dist/core/agent-session-tree.js +8 -0
  111. package/dist/core/agent-session-tree.js.map +1 -1
  112. package/dist/core/agent-session.d.ts +2 -0
  113. package/dist/core/agent-session.d.ts.map +1 -1
  114. package/dist/core/agent-session.js +2 -0
  115. package/dist/core/agent-session.js.map +1 -1
  116. package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
  117. package/dist/core/anthropic-thinking-guard.js +71 -5
  118. package/dist/core/anthropic-thinking-guard.js.map +1 -1
  119. package/dist/core/compaction/branch-summarization.d.ts +2 -2
  120. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  121. package/dist/core/compaction/branch-summarization.js +4 -4
  122. package/dist/core/compaction/branch-summarization.js.map +1 -1
  123. package/dist/core/extensions/api-types.d.ts +8 -2
  124. package/dist/core/extensions/api-types.d.ts.map +1 -1
  125. package/dist/core/extensions/api-types.js.map +1 -1
  126. package/dist/core/extensions/context-types.d.ts +12 -0
  127. package/dist/core/extensions/context-types.d.ts.map +1 -1
  128. package/dist/core/extensions/context-types.js.map +1 -1
  129. package/dist/core/extensions/provider-types.d.ts +2 -2
  130. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  131. package/dist/core/extensions/provider-types.js.map +1 -1
  132. package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
  133. package/dist/core/extensions/runner-shortcuts.js +0 -1
  134. package/dist/core/extensions/runner-shortcuts.js.map +1 -1
  135. package/dist/core/fast-model-routing-transport.d.ts +12 -0
  136. package/dist/core/fast-model-routing-transport.d.ts.map +1 -0
  137. package/dist/core/{codex-fast-mode-transport.js → fast-model-routing-transport.js} +29 -29
  138. package/dist/core/fast-model-routing-transport.js.map +1 -0
  139. package/dist/core/fast-model-routing.d.ts +57 -0
  140. package/dist/core/fast-model-routing.d.ts.map +1 -0
  141. package/dist/core/fast-model-routing.js +201 -0
  142. package/dist/core/fast-model-routing.js.map +1 -0
  143. package/dist/core/fast-model-variants.d.ts +98 -0
  144. package/dist/core/fast-model-variants.d.ts.map +1 -0
  145. package/dist/core/fast-model-variants.js +148 -0
  146. package/dist/core/fast-model-variants.js.map +1 -0
  147. package/dist/core/http-dispatcher.d.ts.map +1 -1
  148. package/dist/core/http-dispatcher.js +4 -2
  149. package/dist/core/http-dispatcher.js.map +1 -1
  150. package/dist/core/keybindings.d.ts +0 -10
  151. package/dist/core/keybindings.d.ts.map +1 -1
  152. package/dist/core/keybindings.js +0 -8
  153. package/dist/core/keybindings.js.map +1 -1
  154. package/dist/core/messages.d.ts +1 -1
  155. package/dist/core/messages.d.ts.map +1 -1
  156. package/dist/core/messages.js.map +1 -1
  157. package/dist/core/model-config.d.ts +24 -4
  158. package/dist/core/model-config.d.ts.map +1 -1
  159. package/dist/core/model-config.js +6 -2
  160. package/dist/core/model-config.js.map +1 -1
  161. package/dist/core/model-resolver-initial.js +1 -1
  162. package/dist/core/model-resolver-initial.js.map +1 -1
  163. package/dist/core/model-runtime-streaming.d.ts +14 -1
  164. package/dist/core/model-runtime-streaming.d.ts.map +1 -1
  165. package/dist/core/model-runtime-streaming.js +25 -3
  166. package/dist/core/model-runtime-streaming.js.map +1 -1
  167. package/dist/core/model-runtime.d.ts +39 -2
  168. package/dist/core/model-runtime.d.ts.map +1 -1
  169. package/dist/core/model-runtime.js +91 -7
  170. package/dist/core/model-runtime.js.map +1 -1
  171. package/dist/core/provider-composer-internal.d.ts +1 -1
  172. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  173. package/dist/core/provider-composer-internal.js +8 -2
  174. package/dist/core/provider-composer-internal.js.map +1 -1
  175. package/dist/core/sdk.d.ts.map +1 -1
  176. package/dist/core/sdk.js +21 -18
  177. package/dist/core/sdk.js.map +1 -1
  178. package/dist/core/session-manager-archive.d.ts.map +1 -1
  179. package/dist/core/session-manager-archive.js +25 -2
  180. package/dist/core/session-manager-archive.js.map +1 -1
  181. package/dist/core/settings-manager-core.d.ts +0 -2
  182. package/dist/core/settings-manager-core.d.ts.map +1 -1
  183. package/dist/core/settings-manager-core.js +2 -9
  184. package/dist/core/settings-manager-core.js.map +1 -1
  185. package/dist/core/settings-manager-internals.d.ts +0 -1
  186. package/dist/core/settings-manager-internals.d.ts.map +1 -1
  187. package/dist/core/settings-manager-internals.js.map +1 -1
  188. package/dist/core/settings-manager-ui-accessors.d.ts +0 -8
  189. package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
  190. package/dist/core/settings-manager-ui-accessors.js +0 -53
  191. package/dist/core/settings-manager-ui-accessors.js.map +1 -1
  192. package/dist/core/settings-manager.d.ts +1 -1
  193. package/dist/core/settings-manager.d.ts.map +1 -1
  194. package/dist/core/settings-manager.js.map +1 -1
  195. package/dist/core/settings-types.d.ts +0 -5
  196. package/dist/core/settings-types.d.ts.map +1 -1
  197. package/dist/core/settings-types.js.map +1 -1
  198. package/dist/core/skills.d.ts +1 -1
  199. package/dist/core/skills.d.ts.map +1 -1
  200. package/dist/core/skills.js +4 -2
  201. package/dist/core/skills.js.map +1 -1
  202. package/dist/core/slash-commands.d.ts.map +1 -1
  203. package/dist/core/slash-commands.js +0 -1
  204. package/dist/core/slash-commands.js.map +1 -1
  205. package/dist/core/system-prompt.js +7 -7
  206. package/dist/core/system-prompt.js.map +1 -1
  207. package/dist/core/tools/bash.d.ts.map +1 -1
  208. package/dist/core/tools/bash.js +10 -7
  209. package/dist/core/tools/bash.js.map +1 -1
  210. package/dist/core/tools/edit.d.ts +1 -1
  211. package/dist/core/tools/edit.d.ts.map +1 -1
  212. package/dist/core/tools/edit.js +153 -8
  213. package/dist/core/tools/edit.js.map +1 -1
  214. package/dist/core/tools/find.d.ts.map +1 -1
  215. package/dist/core/tools/find.js +9 -8
  216. package/dist/core/tools/find.js.map +1 -1
  217. package/dist/core/tools/grep.d.ts.map +1 -1
  218. package/dist/core/tools/grep.js +4 -3
  219. package/dist/core/tools/grep.js.map +1 -1
  220. package/dist/core/tools/hashline.d.ts +2 -2
  221. package/dist/core/tools/hashline.d.ts.map +1 -1
  222. package/dist/core/tools/hashline.js +40 -10
  223. package/dist/core/tools/hashline.js.map +1 -1
  224. package/dist/core/tools/ls.d.ts.map +1 -1
  225. package/dist/core/tools/ls.js +2 -2
  226. package/dist/core/tools/ls.js.map +1 -1
  227. package/dist/core/tools/read.d.ts.map +1 -1
  228. package/dist/core/tools/read.js +12 -11
  229. package/dist/core/tools/read.js.map +1 -1
  230. package/dist/core/tools/search.d.ts.map +1 -1
  231. package/dist/core/tools/search.js +20 -19
  232. package/dist/core/tools/search.js.map +1 -1
  233. package/dist/core/tools/write.d.ts.map +1 -1
  234. package/dist/core/tools/write.js +22 -21
  235. package/dist/core/tools/write.js.map +1 -1
  236. package/dist/core/workflow-stage-admission.d.ts +6 -0
  237. package/dist/core/workflow-stage-admission.d.ts.map +1 -1
  238. package/dist/core/workflow-stage-admission.js +14 -0
  239. package/dist/core/workflow-stage-admission.js.map +1 -1
  240. package/dist/index-extensions.d.ts +1 -1
  241. package/dist/index-extensions.d.ts.map +1 -1
  242. package/dist/index-extensions.js.map +1 -1
  243. package/dist/index.d.ts +5 -5
  244. package/dist/index.d.ts.map +1 -1
  245. package/dist/index.js +4 -5
  246. package/dist/index.js.map +1 -1
  247. package/dist/modes/interactive/components/atomic-working-status.d.ts +4 -0
  248. package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -1
  249. package/dist/modes/interactive/components/atomic-working-status.js +26 -1
  250. package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
  251. package/dist/modes/interactive/components/custom-editor.d.ts +7 -0
  252. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  253. package/dist/modes/interactive/components/custom-editor.js +43 -0
  254. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  255. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  256. package/dist/modes/interactive/components/footer.js +0 -6
  257. package/dist/modes/interactive/components/footer.js.map +1 -1
  258. package/dist/modes/interactive/components/index.d.ts +1 -2
  259. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  260. package/dist/modes/interactive/components/index.js +0 -1
  261. package/dist/modes/interactive/components/index.js.map +1 -1
  262. package/dist/modes/interactive/components/model-selector.d.ts +1 -1
  263. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  264. package/dist/modes/interactive/components/model-selector.js +12 -25
  265. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  266. package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -5
  267. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  268. package/dist/modes/interactive/components/scoped-models-selector.js +16 -34
  269. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  270. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  271. package/dist/modes/interactive/components/settings-selector-items.js +10 -5
  272. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  273. package/dist/modes/interactive/components/settings-selector-submenus.d.ts +1 -1
  274. package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
  275. package/dist/modes/interactive/components/settings-selector-submenus.js +10 -7
  276. package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
  277. package/dist/modes/interactive/components/thinking-selector.d.ts +1 -2
  278. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  279. package/dist/modes/interactive/components/thinking-selector.js +6 -13
  280. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  281. package/dist/modes/interactive/components/transcript-follow-indicator.js +3 -3
  282. package/dist/modes/interactive/components/transcript-follow-indicator.js.map +1 -1
  283. package/dist/modes/interactive/components/trust-selector.js +2 -2
  284. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  285. package/dist/modes/interactive/interactive-agent-events.js +8 -8
  286. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  287. package/dist/modes/interactive/interactive-autocomplete.js +5 -16
  288. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  289. package/dist/modes/interactive/interactive-bash-compact.js +2 -9
  290. package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
  291. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  292. package/dist/modes/interactive/interactive-deferred-startup.js +3 -0
  293. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  294. package/dist/modes/interactive/interactive-editor-actions.js +2 -2
  295. package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
  296. package/dist/modes/interactive/interactive-extension-custom-ui.js +1 -0
  297. package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
  298. package/dist/modes/interactive/interactive-extension-dialogs.js +7 -0
  299. package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
  300. package/dist/modes/interactive/interactive-extension-runtime.js +20 -10
  301. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  302. package/dist/modes/interactive/interactive-hotkeys-debug.js +1 -5
  303. package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
  304. package/dist/modes/interactive/interactive-initial-session-binding.d.ts.map +1 -1
  305. package/dist/modes/interactive/interactive-initial-session-binding.js +3 -0
  306. package/dist/modes/interactive/interactive-initial-session-binding.js.map +1 -1
  307. package/dist/modes/interactive/interactive-input-handling.js +0 -8
  308. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  309. package/dist/modes/interactive/interactive-mode-base.d.ts +5 -1
  310. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  311. package/dist/modes/interactive/interactive-mode-base.js +15 -9
  312. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  313. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -3
  314. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  315. package/dist/modes/interactive/interactive-mode-deps.js +1 -3
  316. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  317. package/dist/modes/interactive/interactive-mode-surface.d.ts +9 -12
  318. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  319. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  320. package/dist/modes/interactive/interactive-model-routing.js +10 -13
  321. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  322. package/dist/modes/interactive/interactive-render-chat.js +29 -0
  323. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  324. package/dist/modes/interactive/interactive-selectors.js +2 -32
  325. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  326. package/dist/modes/interactive/interactive-session-routing.js +1 -5
  327. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  328. package/dist/modes/interactive/interactive-session-runtime.js +1 -5
  329. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  330. package/dist/modes/interactive/interactive-slash-commands.js +6 -13
  331. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  332. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  333. package/dist/modes/interactive/interactive-startup.js +19 -13
  334. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  335. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  336. package/dist/modes/interactive/interactive-tui.js +27 -3
  337. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  338. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  339. package/dist/modes/interactive-engine/engine-custom-ui.js +1 -0
  340. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  341. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  342. package/dist/modes/interactive-engine/isolated-runtime.js +4 -1
  343. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  344. package/dist/utils/child-process.d.ts.map +1 -1
  345. package/dist/utils/child-process.js +13 -6
  346. package/dist/utils/child-process.js.map +1 -1
  347. package/dist/utils/exif-orientation.d.ts.map +1 -1
  348. package/dist/utils/exif-orientation.js +2 -3
  349. package/dist/utils/exif-orientation.js.map +1 -1
  350. package/dist/utils/tools-manager.d.ts +1 -0
  351. package/dist/utils/tools-manager.d.ts.map +1 -1
  352. package/dist/utils/tools-manager.js +33 -18
  353. package/dist/utils/tools-manager.js.map +1 -1
  354. package/docs/compaction.md +2 -0
  355. package/docs/custom-provider.md +4 -1
  356. package/docs/docs.json +14 -2
  357. package/docs/extensions.md +11 -4
  358. package/docs/intercom.md +33 -8
  359. package/docs/keybindings.md +8 -6
  360. package/docs/models/evals.md +394 -0
  361. package/docs/models/model-selection.md +60 -25
  362. package/docs/models/pareto-efficiency.md +33 -15
  363. package/docs/models.md +80 -1
  364. package/docs/packages.md +2 -2
  365. package/docs/providers.md +44 -20
  366. package/docs/quickstart.md +8 -6
  367. package/docs/rpc.md +3 -3
  368. package/docs/sdk.md +2 -16
  369. package/docs/settings.md +19 -22
  370. package/docs/skills.md +4 -2
  371. package/docs/subagents.md +9 -3
  372. package/docs/terminal-setup.md +15 -0
  373. package/docs/tools/edit.md +373 -0
  374. package/docs/tools.md +3 -7
  375. package/docs/tui.md +2 -1
  376. package/docs/usage.md +3 -5
  377. package/docs/workflows/api-reference.md +1395 -0
  378. package/docs/workflows/authoring.md +678 -0
  379. package/docs/workflows/builtins.md +245 -0
  380. package/docs/workflows/operations.md +811 -0
  381. package/docs/workflows/reliable-design.md +2099 -0
  382. package/docs/workflows/verification.md +62 -0
  383. package/docs/workflows.md +15 -5183
  384. package/npm-shrinkwrap.json +584 -69
  385. package/package.json +7 -7
  386. package/dist/client/remote-session.d.ts +0 -64
  387. package/dist/client/remote-session.d.ts.map +0 -1
  388. package/dist/client/remote-session.js +0 -351
  389. package/dist/client/remote-session.js.map +0 -1
  390. package/dist/client/transcript.d.ts +0 -12
  391. package/dist/client/transcript.d.ts.map +0 -1
  392. package/dist/client/transcript.js +0 -98
  393. package/dist/client/transcript.js.map +0 -1
  394. package/dist/core/codex-fast-mode-transport.d.ts +0 -12
  395. package/dist/core/codex-fast-mode-transport.d.ts.map +0 -1
  396. package/dist/core/codex-fast-mode-transport.js.map +0 -1
  397. package/dist/core/codex-fast-mode.d.ts +0 -53
  398. package/dist/core/codex-fast-mode.d.ts.map +0 -1
  399. package/dist/core/codex-fast-mode.js +0 -249
  400. package/dist/core/codex-fast-mode.js.map +0 -1
  401. package/dist/modes/interactive/components/fast-mode-selector.d.ts +0 -27
  402. package/dist/modes/interactive/components/fast-mode-selector.d.ts.map +0 -1
  403. package/dist/modes/interactive/components/fast-mode-selector.js +0 -107
  404. package/dist/modes/interactive/components/fast-mode-selector.js.map +0 -1
  405. package/dist/server/create-harness.d.ts +0 -53
  406. package/dist/server/create-harness.d.ts.map +0 -1
  407. package/dist/server/create-harness.js +0 -360
  408. package/dist/server/create-harness.js.map +0 -1
  409. package/docs/models/artificial-analysis-index.md +0 -83
@@ -20,14 +20,139 @@ const editSchema = Type.Object({
20
20
  description: "One or more hashline file sections. Must start with [PATH#TAG]; tag comes from the latest read, search, write, or successful edit output.",
21
21
  }),
22
22
  }, { additionalProperties: false });
23
+ // Hashline prompt origin: can1357/oh-my-pi packages/hashline/src/prompt.md @ 15b5c1397fc (MIT).
24
+ // This file carries Atomic-maintained local modifications; see ./hashline-engine/PROVENANCE.md and ./hashline-engine/LICENSE.upstream.
23
25
  export const editToolSystemPromptContribution = Object.freeze({
24
26
  snippet: "Apply source edits with hashline patch input",
25
27
  guidelines: Object.freeze([
26
- "hashline edit format: a header ending in ':' is followed by '+'TEXT body rows; 'delete' has no body. Every section starts with [PATH#TAG]; TAG is REQUIRED (the 4-hex snapshot tag from your latest read/search) — there is no hashless form. Use the write tool to create new files.",
27
- "Ops: 'replace N..M:' replaces original lines N..M (INCLUSIVE — line M is consumed); 'replace block N:' replaces the whole syntactic block that BEGINS on line N (Atomic resolves the closing line with a brace/indent heuristic; point N at the opener); 'delete N..M' / 'delete block N' delete (no body); 'insert before N:' / 'insert after N:' insert relative to a line; 'insert after block N:' inserts after the END of the block beginning on N; 'insert head:' / 'insert tail:' insert at file start/end. Single line: 'replace N..N:' / 'delete N'. The range is the ORIGINAL lines you touch; body length is irrelevant.",
28
- "Body rows appear only under a ':' header. Every row is '+TEXT' (adds a literal line, leading whitespace kept; '+' alone adds a blank line). There is NO other body row kind — never write '-old' or a bare/context line. To keep a line, leave it out of every range. For a literal line starting with '-' or '+', prefix it: '+-x', '++x'.",
28
+ "hashline edit format: a header ending in ':' is followed by '+TEXT' body rows; 'delete' has no body. Every section starts with [PATH#TAG]; TAG is REQUIRED (the 4-hex snapshot tag from your latest read/search) — there is no hashless form. Use the write tool to create new files.",
29
+ "Ops: 'replace N..M:' replaces original lines N..M (INCLUSIVE — line M is consumed); 'delete N..M' / 'delete block N' delete (no body); 'insert before N:' / 'insert after N:' insert relative to a line; 'insert head:' / 'insert tail:' insert at file start/end. Block ops ('replace block N:', 'delete block N', 'insert after block N:') resolve the exact syntactic node BEGINNING on N through the native Rust tree-sitter `blockRangeAt` primitive in `@bastani/atomic-natives`; the brace/indent heuristic is the fallback only when the native binding is unavailable. Single line: 'replace N..N:' / 'delete N'. The range is the ORIGINAL lines you touch; body length is irrelevant.",
30
+ "Body rows appear only under a ':' header and start on the NEXT line. Every row is '+TEXT' (adds a literal line, leading whitespace kept; '+' alone adds a blank line). There is NO other body row kind — never write '-old' or a bare/context line. To keep a line, leave it out of every range. For a literal line starting with '-' or '+', prefix it: '+-x', '++x'.",
31
+ "Block anchors: 'replace block N' resolves the outermost node BEGINNING on N. Where a language folds a decorator/annotation into its construct (Python folds `@dec` and `def` into one node; TypeScript/Java annotations also fold), anchoring at the first decorator sweeps both. Rust `#[attr]` and doc- or line-comments resolve alone; replacing there with a construct body duplicates the construct, so use explicit 'replace N..M:' to take both. Confirm the result echo: 'replace block N → resolved lines A-B (K lines)'. 'insert after block N:' takes the opener, never the closer; insert-after echoes '; body lands after line B'. Resolution fails for an unsupported language, blank/closer line, no node beginning on N, or an unparsable block; use 'replace N..M:' or 'insert after M:' instead.",
29
32
  "Numbers refer to the ORIGINAL file and do not shift as hunks apply; they die with the call — every applied edit mints a fresh #TAG and renumbers, so anchor the next edit on the edit response or a fresh read. Parallel edit calls that share a [path#TAG] are applied as one snapshot batch. Ranges are TIGHT: cover ONLY lines whose content changes; a stale wide range shreds everything it spans. Pure additions use 'insert', never a widened 'replace'. Whole construct → 'replace block N'; lines inside it → 'replace N..M'.",
30
33
  "On a stale-tag rejection or any surprising result: STOP and re-read before further edits. Never start or end a range mid-expression/mid-block, and never span a hunk across an elided ('…') region — read it first. Never use edit to reformat/restyle code; run the project formatter instead.",
34
+ [
35
+ "Worked examples. Original (the exact shape `read` returns):",
36
+ "```text",
37
+ "[greet.py#A1B2]",
38
+ "1:@cache",
39
+ "2:def greet(name):",
40
+ '3: msg = "Hello, " + name',
41
+ "4: print(msg)",
42
+ '5:greet("world")',
43
+ "```",
44
+ "Replace one original line with one line:",
45
+ "```text",
46
+ "[greet.py#A1B2]",
47
+ "replace 3..3:",
48
+ '+ msg = f"Hi, {name}"',
49
+ "```",
50
+ "Replace the decorated Python block (Python folds `@cache` and `def` into one node; anchoring at line 2 would keep/orphan line 1). For a Rust attribute or doc- or line-comment, use explicit `replace N..M:` to take both it and the construct:",
51
+ "```text",
52
+ "[greet.py#A1B2]",
53
+ "replace block 1:",
54
+ "+@cache",
55
+ "+def greet(name):",
56
+ '+ print(f"Hello, {name}")',
57
+ "```",
58
+ "Delete one line (no colon/body):",
59
+ "```text",
60
+ "[greet.py#A1B2]",
61
+ "delete 4",
62
+ "```",
63
+ "Delete a range (no colon/body):",
64
+ "```text",
65
+ "[greet.py#A1B2]",
66
+ "delete 3..4",
67
+ "```",
68
+ "Delete a whole block (no colon/body):",
69
+ "```text",
70
+ "[greet.py#A1B2]",
71
+ "delete block 2",
72
+ "```",
73
+ "Insert before a line:",
74
+ "```text",
75
+ "[greet.py#A1B2]",
76
+ "insert before 5:",
77
+ "+log()",
78
+ "```",
79
+ "Insert after a line:",
80
+ "```text",
81
+ "[greet.py#A1B2]",
82
+ "insert after 3:",
83
+ "+ print(msg)",
84
+ "```",
85
+ "Insert after the block whose opener is line 2:",
86
+ "```text",
87
+ "[greet.py#A1B2]",
88
+ "insert after block 2:",
89
+ "+audit()",
90
+ "```",
91
+ "Insert at both file ends:",
92
+ "```text",
93
+ "[greet.py#A1B2]",
94
+ "insert head:",
95
+ "+# generated",
96
+ "insert tail:",
97
+ '+greet("everyone")',
98
+ "```",
99
+ "Multi-file input:",
100
+ "```text",
101
+ "[src/a.ts#0A3B]",
102
+ "replace 1..1:",
103
+ "+export const enabled = true;",
104
+ "[src/b.ts#1F7C]",
105
+ "delete 20",
106
+ "```",
107
+ ].join("\n"),
108
+ [
109
+ "Anti-patterns:",
110
+ "```text",
111
+ "# WRONG — `-` rows are rejected; bare context rows are auto-prefixed and inserted as literal content: `-` rows are not valid; the range already names the lines being changed. For a literal `-` line, write `+-…`.",
112
+ "replace 3..3:",
113
+ ' msg = "Hello"',
114
+ "- print(msg)",
115
+ "+ return msg",
116
+ "# RIGHT",
117
+ "replace 3..3:",
118
+ "+ return msg",
119
+ "",
120
+ "# WRONG — body glued to its header: payload line has no preceding hunk header; body starts on the NEXT line.",
121
+ "replace block 238:+export const value = 1;",
122
+ "# RIGHT",
123
+ "replace block 238:",
124
+ "+export const value = 1;",
125
+ "",
126
+ "# WRONG — `delete N..M` has no colon and no body.",
127
+ "delete 2..3:",
128
+ "+replacement",
129
+ "# RIGHT: delete 2..3",
130
+ "",
131
+ "# WRONG — empty `insert` / `replace`: `insert` needs at least one `+TEXT` body row. A bodyless concrete `replace` silently deletes the range.",
132
+ "insert after 2:",
133
+ "replace 4..4:",
134
+ "# RIGHT — give `replace` a body; if deletion is intended, write `delete 4`.",
135
+ "",
136
+ "# WRONG — widened replace for a pure insertion can drop retyped keepers.",
137
+ "replace 2..4:",
138
+ "+kept()",
139
+ "+added()",
140
+ "# RIGHT: insert after 2:",
141
+ "+added()",
142
+ "",
143
+ "# WRONG — block anchor is a closer/last visible line.",
144
+ "insert after block 3:",
145
+ "+after()",
146
+ "# RIGHT: insert after 3:",
147
+ "+after()",
148
+ "```",
149
+ ].join("\n"),
150
+ [
151
+ "If you remember nothing else:",
152
+ "1. RE-GROUND AFTER EVERY EDIT. Every apply mints a fresh #TAG and renumbers; use the edit response or a fresh read. Stale tag or surprise? STOP and re-read.",
153
+ "2. RANGES ARE TIGHT. Cover only lines that change; a stale wide range shreds everything it spans. Whole construct → replace block N.",
154
+ "3. THE BODY IS THE FINAL CONTENT. Only +TEXT rows; never -old/context lines. The range does the deleting.",
155
+ ].join("\n"),
31
156
  ]),
32
157
  });
33
158
  const defaultEditOperations = {
@@ -138,9 +263,7 @@ function assertUniquePreparedPaths(prepared) {
138
263
  seen.set(entry.canonicalPath, entry.section.path);
139
264
  }
140
265
  }
141
- export function createEditToolDefinition(cwd, options) {
142
- const ops = options?.operations ?? defaultEditOperations;
143
- const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
266
+ function createEditCwdScope(cwd, ops, hashlineStore) {
144
267
  const fs = new EditFilesystem(cwd, ops);
145
268
  const patcher = new Patcher({ fs, snapshots: hashlineStore.snapshots, blockResolver: nativeBlockResolver });
146
269
  const noopCounts = new Map();
@@ -207,6 +330,26 @@ export function createEditToolDefinition(cwd, options) {
207
330
  details: { diff: combinedDiff, patch: combinedPatch, firstChangedLine },
208
331
  };
209
332
  }
333
+ return { fs, batcher, applySiblingEdits };
334
+ }
335
+ export function createEditToolDefinition(cwd, options) {
336
+ const ops = options?.operations ?? defaultEditOperations;
337
+ const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
338
+ // Atomic adaptation of upstream #8627 ("use ctx.cwd for cwd-sensitive tools"). Upstream's edit
339
+ // tool is a stateless text replacer, so it could resolve `ctx?.cwd || cwd` inline. Atomic's
340
+ // hashline patcher instead carries per-tool state — the `EditFilesystem`, the `Patcher`, the
341
+ // repeated-no-op counters, and the parallel-edit batcher — that is all keyed to one cwd.
342
+ // Mutating a shared cwd field would corrupt concurrent tool calls, so each distinct execution
343
+ // cwd gets its own scope. Callers that pass no ctx keep the factory cwd's scope unchanged.
344
+ const scopes = new Map();
345
+ const scopeFor = (executionCwd) => {
346
+ const existing = scopes.get(executionCwd);
347
+ if (existing)
348
+ return existing;
349
+ const scope = createEditCwdScope(executionCwd, ops, hashlineStore);
350
+ scopes.set(executionCwd, scope);
351
+ return scope;
352
+ };
210
353
  return {
211
354
  name: "edit",
212
355
  label: "edit",
@@ -215,10 +358,12 @@ export function createEditToolDefinition(cwd, options) {
215
358
  promptGuidelines: [...editToolSystemPromptContribution.guidelines],
216
359
  ...experimentalToolSamplingProperty(),
217
360
  parameters: editSchema,
218
- async execute(_toolCallId, input, signal) {
361
+ async execute(_toolCallId, input, signal, _onUpdate, ctx) {
219
362
  if (typeof input.input !== "string" || input.input.trim() === "")
220
363
  throw new Error("edit input must be a non-empty hashline script with [PATH#TAG] sections.");
221
- const patch = Patch.parse(input.input, { cwd });
364
+ const executionCwd = ctx?.cwd || cwd;
365
+ const { fs, batcher, applySiblingEdits } = scopeFor(executionCwd);
366
+ const patch = Patch.parse(input.input, { cwd: executionCwd });
222
367
  const paths = new Map();
223
368
  for (const section of patch.sections) {
224
369
  if (section.fileHash === undefined)
@@ -1 +1 @@
1
- {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAExE,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,2BAA2B,EAC3B,+BAA+B,EAE/B,sBAAsB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,UAAU,EACV,yBAAyB,EACzB,KAAK,EACL,OAAO,GAIP,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC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OAAO,CAAC,aAAuC,IAAI,IAAI,SAAS,EAAE,CAAC;YACtF,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM;gBAAE,OAAO,SAAS,CAAC;YAC9B,SAAS,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC3C,OAAO,SAAS,CAAC;QAClB,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile, writeFile as fsWriteFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { renderDiff } from \"../../modes/interactive/components/diff.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { experimentalToolSamplingProperty } from \"../experimental.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { nativeBlockResolver } from \"./block-resolver.ts\";\nimport { EditBatchCoordinator, parallelEditBatchWarning } from \"./edit-batch.ts\";\nimport { generateDiffString, generateUnifiedPatch, normalizeToLF, stripBom } from \"./edit-diff.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport {\n\tcreateHashlineSnapshotStore,\n\tformatCompactHashlineEditResult,\n\ttype HashlineSnapshotStore,\n\trecordHashlineSnapshot,\n} from \"./hashline.ts\";\nimport {\n\tFilesystem,\n\tmissingSnapshotTagMessage,\n\tPatch,\n\tPatcher,\n\ttype PatchSectionResult,\n\ttype PreparedSection,\n\ttype WriteResult,\n} from \"./hashline-engine/index.ts\";\nimport { isNotebookPath, readEditableNotebookText, serializeEditedNotebookText } from \"./notebook.ts\";\nimport { resolveReadPath } from \"./path-utils.ts\";\nimport { renderToolPath } from \"./render-utils.ts\";\nimport { invalidateNativeSearchCache } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst editSchema = Type.Object(\n\t{\n\t\tinput: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"One or more hashline file sections. Must start with [PATH#TAG]; tag comes from the latest read, search, write, or successful edit output.\",\n\t\t}),\n\t},\n\t{ additionalProperties: false },\n);\nexport const editToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Apply source edits with hashline patch input\",\n\tguidelines: Object.freeze([\n\t\t\"hashline edit format: a header ending in ':' is followed by '+'TEXT body rows; 'delete' has no body. Every section starts with [PATH#TAG]; TAG is REQUIRED (the 4-hex snapshot tag from your latest read/search) — there is no hashless form. Use the write tool to create new files.\",\n\t\t\"Ops: 'replace N..M:' replaces original lines N..M (INCLUSIVE — line M is consumed); 'replace block N:' replaces the whole syntactic block that BEGINS on line N (Atomic resolves the closing line with a brace/indent heuristic; point N at the opener); 'delete N..M' / 'delete block N' delete (no body); 'insert before N:' / 'insert after N:' insert relative to a line; 'insert after block N:' inserts after the END of the block beginning on N; 'insert head:' / 'insert tail:' insert at file start/end. Single line: 'replace N..N:' / 'delete N'. The range is the ORIGINAL lines you touch; body length is irrelevant.\",\n\t\t\"Body rows appear only under a ':' header. Every row is '+TEXT' (adds a literal line, leading whitespace kept; '+' alone adds a blank line). There is NO other body row kind — never write '-old' or a bare/context line. To keep a line, leave it out of every range. For a literal line starting with '-' or '+', prefix it: '+-x', '++x'.\",\n\t\t\"Numbers refer to the ORIGINAL file and do not shift as hunks apply; they die with the call — every applied edit mints a fresh #TAG and renumbers, so anchor the next edit on the edit response or a fresh read. Parallel edit calls that share a [path#TAG] are applied as one snapshot batch. Ranges are TIGHT: cover ONLY lines whose content changes; a stale wide range shreds everything it spans. Pure additions use 'insert', never a widened 'replace'. Whole construct → 'replace block N'; lines inside it → 'replace N..M'.\",\n\t\t\"On a stale-tag rejection or any surprising result: STOP and re-read before further edits. Never start or end a range mid-expression/mid-block, and never span a hunk across an elided ('…') region — read it first. Never use edit to reformat/restyle code; run the project formatter instead.\",\n\t] as const),\n} as const);\n\nexport type EditToolInput = Static<typeof editSchema>;\n\nexport interface EditToolDetails {\n\tdiff: string;\n\tpatch: string;\n\tfirstChangedLine?: number;\n}\n\nexport interface EditOperations {\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\twriteFile: (absolutePath: string, content: string) => Promise<void>;\n\taccess: (absolutePath: string) => Promise<void>;\n}\n\nconst defaultEditOperations: EditOperations = {\n\treadFile: (path) => fsReadFile(path),\n\twriteFile: (path, content) => fsWriteFile(path, content, \"utf-8\"),\n\taccess: (path) => fsAccess(path, constants.R_OK | constants.W_OK),\n};\n\nexport interface EditToolOptions {\n\toperations?: EditOperations;\n\thashlineStore?: HashlineSnapshotStore;\n}\n\ntype EditToolResultLike = {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: EditToolDetails | undefined;\n};\n\nclass EditFilesystem extends Filesystem {\n\tprivate readonly cwd: string;\n\tprivate readonly operations: EditOperations;\n\tconstructor(cwd: string, operations: EditOperations) {\n\t\tsuper();\n\t\tthis.cwd = cwd;\n\t\tthis.operations = operations;\n\t}\n\n\tcanonicalPath(path: string): string {\n\t\treturn resolveReadPath(path, this.cwd);\n\t}\n\n\tasync preflightWrite(path: string): Promise<void> {\n\t\tconst absolutePath = this.canonicalPath(path);\n\t\ttry {\n\t\t\tawait this.operations.access(absolutePath);\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error && \"code\" in error ? `Error code: ${error.code}` : String(error);\n\t\t\tthrow new Error(`Could not edit file: ${path}. ${message}.`);\n\t\t}\n\t}\n\n\tasync readText(path: string): Promise<string> {\n\t\tconst absolutePath = this.canonicalPath(path);\n\t\treturn isNotebookPath(absolutePath)\n\t\t\t? readEditableNotebookText(absolutePath, path)\n\t\t\t: (await this.operations.readFile(absolutePath)).toString(\"utf-8\");\n\t}\n\n\tasync writeText(path: string, content: string): Promise<WriteResult> {\n\t\tconst absolutePath = this.canonicalPath(path);\n\t\tconst persisted = isNotebookPath(absolutePath)\n\t\t\t? serializeEditedNotebookText(absolutePath, path, normalizeToLF(stripBom(content).text))\n\t\t\t: content;\n\t\tawait this.operations.writeFile(absolutePath, persisted);\n\t\treturn { text: persisted };\n\t}\n}\n\nfunction isFourDigitHexTag(value: string): boolean {\n\treturn (\n\t\tvalue.length === 4 &&\n\t\t[...value].every(\n\t\t\t(char) => (char >= \"0\" && char <= \"9\") || (char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\"),\n\t\t)\n\t);\n}\n\nfunction extractFirstHeaderPath(input: string | undefined): string | undefined {\n\tif (!input) return undefined;\n\tfor (const line of input.split(\"\\n\")) {\n\t\tconst trimmed = line.trimStart();\n\t\tif (!trimmed.startsWith(\"[\")) continue;\n\t\tconst hashIndex = trimmed.indexOf(\"#\", 1);\n\t\tconst closeIndex = hashIndex >= 0 ? trimmed.indexOf(\"]\", hashIndex + 1) : -1;\n\t\tif (hashIndex <= 1 || closeIndex !== hashIndex + 5) continue;\n\t\tconst tag = trimmed.slice(hashIndex + 1, closeIndex);\n\t\tif (isFourDigitHexTag(tag)) return trimmed.slice(1, hashIndex);\n\t}\n\treturn undefined;\n}\n\nfunction formatEditCall(args: unknown, theme: Theme, cwd: string): string {\n\tconst input = args && typeof args === \"object\" && \"input\" in args ? (args as { input?: unknown }).input : undefined;\n\tconst pathDisplay = renderToolPath(\n\t\textractFirstHeaderPath(typeof input === \"string\" ? input : undefined) ?? null,\n\t\ttheme,\n\t\tcwd,\n\t);\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"edit\"))} ${pathDisplay}`;\n}\n\nfunction formatEditResult(result: EditToolResultLike, theme: Theme, isError: boolean): string | undefined {\n\tif (isError) {\n\t\tconst errorText = result.content\n\t\t\t.filter((c) => c.type === \"text\")\n\t\t\t.map((c) => c.text || \"\")\n\t\t\t.join(\"\\n\");\n\t\treturn errorText ? theme.fg(\"error\", errorText) : undefined;\n\t}\n\treturn result.details?.diff ? renderDiff(result.details.diff) : undefined;\n}\n\nasync function withFileMutationQueues<T>(filePaths: readonly string[], fn: () => Promise<T>): Promise<T> {\n\tconst sorted = [...new Set(filePaths)].sort();\n\tconst run = (index: number): Promise<T> => {\n\t\tconst filePath = sorted[index];\n\t\treturn filePath ? withFileMutationQueue(filePath, () => run(index + 1)) : fn();\n\t};\n\treturn run(0);\n}\n\nfunction throwIfAborted(signal?: AbortSignal): void {\n\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n}\n\nfunction formatNoopMessage(path: string, count: number): string {\n\treturn `Edits to ${path} parsed and applied cleanly, but produced no change: your body row(s) are byte-identical to the file at the targeted lines. The bug is somewhere else — re-read the file before issuing another edit. Do NOT widen the payload or add lines; verify the anchor first.${count > 1 ? `\\nNo-op count for this identical payload: ${count}.` : \"\"}`;\n}\n\nfunction blockMessages(item: PreparedSection | PatchSectionResult): string[] {\n\tconst warnings =\n\t\t\"parseWarnings\" in item ? [...item.parseWarnings, ...(item.applyResult.warnings ?? [])] : item.warnings;\n\tconst resolutions =\n\t\t(\"applyResult\" in item ? item.applyResult.blockResolutions : item.blockResolutions)?.map((resolution) => {\n\t\t\tconst verb = resolution.op === \"insert_after\" ? \"insert after block\" : `${resolution.op} block`;\n\t\t\tconst lands = resolution.op === \"insert_after\" ? `; body lands after line ${resolution.end}` : \"\";\n\t\t\treturn `${verb} ${resolution.anchorLine} → resolved lines ${resolution.start}-${resolution.end} (${resolution.end - resolution.start + 1} lines)${lands}`;\n\t\t}) ?? [];\n\treturn [...warnings, ...resolutions];\n}\n\nfunction assertUniquePreparedPaths(prepared: readonly PreparedSection[]): void {\n\tconst seen = new Map<string, string>();\n\tfor (const entry of prepared) {\n\t\tconst previous = seen.get(entry.canonicalPath);\n\t\tif (previous)\n\t\t\tthrow new Error(\n\t\t\t\t`Multiple hashline sections resolve to the same file (${previous} and ${entry.section.path}). Merge their ops under one header before applying.`,\n\t\t\t);\n\t\tseen.set(entry.canonicalPath, entry.section.path);\n\t}\n}\n\nexport function createEditToolDefinition(\n\tcwd: string,\n\toptions?: EditToolOptions,\n): ToolDefinition<typeof editSchema, EditToolDetails | undefined> {\n\tconst ops = options?.operations ?? defaultEditOperations;\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst fs = new EditFilesystem(cwd, ops);\n\tconst patcher = new Patcher({ fs, snapshots: hashlineStore.snapshots, blockResolver: nativeBlockResolver });\n\tconst noopCounts = new Map<string, number>();\n\tconst batcher = new EditBatchCoordinator<EditToolResultLike>();\n\tasync function applySiblingEdits(\n\t\tsiblings: readonly { input: string }[],\n\t\tapplySignal?: AbortSignal,\n\t): Promise<EditToolResultLike> {\n\t\tconst merged =\n\t\t\tsiblings.length === 1\n\t\t\t\t? Patch.parse(siblings[0]!.input, { cwd })\n\t\t\t\t: Patch.parse(siblings.map((sibling) => sibling.input).join(\"\\n\"), { cwd });\n\t\tconst prepared: PreparedSection[] = [];\n\t\tfor (const section of merged.sections) {\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tprepared.push(await patcher.prepare(section));\n\t\t}\n\t\tassertUniquePreparedPaths(prepared);\n\t\tconst noops = prepared.filter((item) => item.isNoop);\n\t\tif (noops.length > 0) {\n\t\t\tif (noops.length !== prepared.length)\n\t\t\t\tthrow new Error(`Hashline edit for ${noops[0]!.section.path} did not change the file.`);\n\t\t\tconst key = prepared.map((item) => `${item.canonicalPath}\\0${item.applyResult.text}`).join(\"\\0\\0\");\n\t\t\tconst count = (noopCounts.get(key) ?? 0) + 1;\n\t\t\tnoopCounts.set(key, count);\n\t\t\tif (count >= 3) throw new Error(`STOP. ${formatNoopMessage(prepared[0]!.section.path, count)}`);\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: formatNoopMessage(prepared[0]!.section.path, count) }],\n\t\t\t\tdetails: { diff: \"\", patch: \"\" },\n\t\t\t};\n\t\t}\n\t\tfor (const item of prepared) {\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tif (normalizeToLF(stripBom(await fs.readText(item.section.path)).text) !== item.normalized)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Stale hashline tag for ${item.section.path}: file content changed before write. Re-read before editing.`,\n\t\t\t\t);\n\t\t}\n\t\tconst outputs: string[] = [];\n\t\tlet combinedDiff = \"\",\n\t\t\tcombinedPatch = \"\";\n\t\tlet firstChangedLine: number | undefined;\n\t\tconst batchNote = siblings.length > 1 ? [parallelEditBatchWarning(siblings.length)] : [];\n\t\tfor (let index = 0; index < prepared.length; index++) {\n\t\t\tconst item = prepared[index]!;\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tlet result: PatchSectionResult;\n\t\t\ttry {\n\t\t\t\tresult = await patcher.commit(item);\n\t\t\t} catch (error) {\n\t\t\t\tconst written = prepared.slice(0, index).map((entry) => entry.section.path);\n\t\t\t\tconst notWritten = prepared.slice(index + 1).map((entry) => entry.section.path);\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to write ${item.section.path}: ${message}` +\n\t\t\t\t\t\t(written.length > 0 ? ` Sections already written: ${written.join(\", \")}.` : \"\") +\n\t\t\t\t\t\t(notWritten.length > 0 ? ` Sections not written: ${notWritten.join(\", \")}.` : \"\"),\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tinvalidateNativeSearchCache(result.canonicalPath);\n\t\t\tconst snapshot = recordHashlineSnapshot(result.canonicalPath, cwd, result.after, hashlineStore);\n\t\t\tconst diffResult = generateDiffString(result.before, result.after);\n\t\t\tcombinedDiff += `${combinedDiff ? \"\\n\" : \"\"}${diffResult.diff}`;\n\t\t\tcombinedPatch += `${combinedPatch ? \"\\n\" : \"\"}${generateUnifiedPatch(result.path, result.before, result.after)}`;\n\t\t\tfirstChangedLine ??= diffResult.firstChangedLine;\n\t\t\toutputs.push(formatCompactHashlineEditResult(snapshot, diffResult, [...batchNote, ...blockMessages(result)]));\n\t\t}\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: outputs.join(\"\\n\\n\") }],\n\t\t\tdetails: { diff: combinedDiff, patch: combinedPatch, firstChangedLine },\n\t\t};\n\t}\n\treturn {\n\t\tname: \"edit\",\n\t\tlabel: \"edit\",\n\t\tdescription:\n\t\t\t\"Edit existing files with the hashline patch language: each section starts with [PATH#TAG] (TAG is the 4-hex snapshot tag from your latest read/search), then hunk headers (replace N..M:, replace block N:, delete N..M, delete block N, insert before|after N:, insert after block N:, insert head:, insert tail:) followed by +TEXT body rows. Numbers refer to the original file. Use the write tool to create new files.\",\n\t\tpromptSnippet: editToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...editToolSystemPromptContribution.guidelines],\n\t\t...experimentalToolSamplingProperty(),\n\t\tparameters: editSchema,\n\t\tasync execute(_toolCallId, input: EditToolInput, signal?: AbortSignal) {\n\t\t\tif (typeof input.input !== \"string\" || input.input.trim() === \"\")\n\t\t\t\tthrow new Error(\"edit input must be a non-empty hashline script with [PATH#TAG] sections.\");\n\t\t\tconst patch = Patch.parse(input.input, { cwd });\n\t\t\tconst paths = new Map<string, string>();\n\t\t\tfor (const section of patch.sections) {\n\t\t\t\tif (section.fileHash === undefined) throw new Error(missingSnapshotTagMessage(section.path));\n\t\t\t\tpaths.set(section.path, section.fileHash);\n\t\t\t}\n\t\t\tconst entry = batcher.announce(input.input, paths, signal);\n\t\t\ttry {\n\t\t\t\treturn await withFileMutationQueues(\n\t\t\t\t\t[...paths.keys()].map((sectionPath) => fs.canonicalPath(sectionPath)),\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tif (entry.settled) return await entry.promise;\n\t\t\t\t\t\tthrowIfAborted(signal);\n\t\t\t\t\t\tconst siblings = batcher.takeCompatible(entry);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await applySiblingEdits(siblings, signal);\n\t\t\t\t\t\t\tfor (const sibling of siblings) sibling.resolve(result);\n\t\t\t\t\t\t\treturn result;\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tfor (const sibling of siblings) sibling.reject(error);\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (entry.settled) return await entry.promise;\n\t\t\t\tentry.reject(error);\n\t\t\t\tthrow error;\n\t\t\t} finally {\n\t\t\t\tbatcher.drop(entry);\n\t\t\t}\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatEditCall(args, theme, context.cwd));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst output = formatEditResult(result as EditToolResultLike, theme, context.isError);\n\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\tcomponent.clear();\n\t\t\tif (!output) return component;\n\t\t\tcomponent.addChild(new Spacer(1));\n\t\t\tcomponent.addChild(new Text(output, 1, 0));\n\t\t\treturn component;\n\t\t},\n\t};\n}\n\nexport function createEditTool(cwd: string, options?: EditToolOptions): AgentTool<typeof editSchema> {\n\treturn wrapToolDefinition(createEditToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,IAAI,WAAW,E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CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile, writeFile as fsWriteFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { renderDiff } from \"../../modes/interactive/components/diff.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { experimentalToolSamplingProperty } from \"../experimental.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport { nativeBlockResolver } from \"./block-resolver.ts\";\nimport { EditBatchCoordinator, parallelEditBatchWarning } from \"./edit-batch.ts\";\nimport { generateDiffString, generateUnifiedPatch, normalizeToLF, stripBom } from \"./edit-diff.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport {\n\tcreateHashlineSnapshotStore,\n\tformatCompactHashlineEditResult,\n\ttype HashlineSnapshotStore,\n\trecordHashlineSnapshot,\n} from \"./hashline.ts\";\nimport {\n\tFilesystem,\n\tmissingSnapshotTagMessage,\n\tPatch,\n\tPatcher,\n\ttype PatchSectionResult,\n\ttype PreparedSection,\n\ttype WriteResult,\n} from \"./hashline-engine/index.ts\";\nimport { isNotebookPath, readEditableNotebookText, serializeEditedNotebookText } from \"./notebook.ts\";\nimport { resolveReadPath } from \"./path-utils.ts\";\nimport { renderToolPath } from \"./render-utils.ts\";\nimport { invalidateNativeSearchCache } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst editSchema = Type.Object(\n\t{\n\t\tinput: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"One or more hashline file sections. Must start with [PATH#TAG]; tag comes from the latest read, search, write, or successful edit output.\",\n\t\t}),\n\t},\n\t{ additionalProperties: false },\n);\n// Hashline prompt origin: can1357/oh-my-pi packages/hashline/src/prompt.md @ 15b5c1397fc (MIT).\n// This file carries Atomic-maintained local modifications; see ./hashline-engine/PROVENANCE.md and ./hashline-engine/LICENSE.upstream.\nexport const editToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Apply source edits with hashline patch input\",\n\tguidelines: Object.freeze([\n\t\t\"hashline edit format: a header ending in ':' is followed by '+TEXT' body rows; 'delete' has no body. Every section starts with [PATH#TAG]; TAG is REQUIRED (the 4-hex snapshot tag from your latest read/search) — there is no hashless form. Use the write tool to create new files.\",\n\t\t\"Ops: 'replace N..M:' replaces original lines N..M (INCLUSIVE — line M is consumed); 'delete N..M' / 'delete block N' delete (no body); 'insert before N:' / 'insert after N:' insert relative to a line; 'insert head:' / 'insert tail:' insert at file start/end. Block ops ('replace block N:', 'delete block N', 'insert after block N:') resolve the exact syntactic node BEGINNING on N through the native Rust tree-sitter `blockRangeAt` primitive in `@bastani/atomic-natives`; the brace/indent heuristic is the fallback only when the native binding is unavailable. Single line: 'replace N..N:' / 'delete N'. The range is the ORIGINAL lines you touch; body length is irrelevant.\",\n\t\t\"Body rows appear only under a ':' header and start on the NEXT line. Every row is '+TEXT' (adds a literal line, leading whitespace kept; '+' alone adds a blank line). There is NO other body row kind — never write '-old' or a bare/context line. To keep a line, leave it out of every range. For a literal line starting with '-' or '+', prefix it: '+-x', '++x'.\",\n\t\t\"Block anchors: 'replace block N' resolves the outermost node BEGINNING on N. Where a language folds a decorator/annotation into its construct (Python folds `@dec` and `def` into one node; TypeScript/Java annotations also fold), anchoring at the first decorator sweeps both. Rust `#[attr]` and doc- or line-comments resolve alone; replacing there with a construct body duplicates the construct, so use explicit 'replace N..M:' to take both. Confirm the result echo: 'replace block N → resolved lines A-B (K lines)'. 'insert after block N:' takes the opener, never the closer; insert-after echoes '; body lands after line B'. Resolution fails for an unsupported language, blank/closer line, no node beginning on N, or an unparsable block; use 'replace N..M:' or 'insert after M:' instead.\",\n\t\t\"Numbers refer to the ORIGINAL file and do not shift as hunks apply; they die with the call — every applied edit mints a fresh #TAG and renumbers, so anchor the next edit on the edit response or a fresh read. Parallel edit calls that share a [path#TAG] are applied as one snapshot batch. Ranges are TIGHT: cover ONLY lines whose content changes; a stale wide range shreds everything it spans. Pure additions use 'insert', never a widened 'replace'. Whole construct → 'replace block N'; lines inside it → 'replace N..M'.\",\n\t\t\"On a stale-tag rejection or any surprising result: STOP and re-read before further edits. Never start or end a range mid-expression/mid-block, and never span a hunk across an elided ('…') region — read it first. Never use edit to reformat/restyle code; run the project formatter instead.\",\n\t\t[\n\t\t\t\"Worked examples. Original (the exact shape `read` returns):\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"1:@cache\",\n\t\t\t\"2:def greet(name):\",\n\t\t\t'3: msg = \"Hello, \" + name',\n\t\t\t\"4: print(msg)\",\n\t\t\t'5:greet(\"world\")',\n\t\t\t\"```\",\n\t\t\t\"Replace one original line with one line:\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"replace 3..3:\",\n\t\t\t'+ msg = f\"Hi, {name}\"',\n\t\t\t\"```\",\n\t\t\t\"Replace the decorated Python block (Python folds `@cache` and `def` into one node; anchoring at line 2 would keep/orphan line 1). For a Rust attribute or doc- or line-comment, use explicit `replace N..M:` to take both it and the construct:\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"replace block 1:\",\n\t\t\t\"+@cache\",\n\t\t\t\"+def greet(name):\",\n\t\t\t'+ print(f\"Hello, {name}\")',\n\t\t\t\"```\",\n\t\t\t\"Delete one line (no colon/body):\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"delete 4\",\n\t\t\t\"```\",\n\t\t\t\"Delete a range (no colon/body):\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"delete 3..4\",\n\t\t\t\"```\",\n\t\t\t\"Delete a whole block (no colon/body):\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"delete block 2\",\n\t\t\t\"```\",\n\t\t\t\"Insert before a line:\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"insert before 5:\",\n\t\t\t\"+log()\",\n\t\t\t\"```\",\n\t\t\t\"Insert after a line:\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"insert after 3:\",\n\t\t\t\"+ print(msg)\",\n\t\t\t\"```\",\n\t\t\t\"Insert after the block whose opener is line 2:\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"insert after block 2:\",\n\t\t\t\"+audit()\",\n\t\t\t\"```\",\n\t\t\t\"Insert at both file ends:\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"insert head:\",\n\t\t\t\"+# generated\",\n\t\t\t\"insert tail:\",\n\t\t\t'+greet(\"everyone\")',\n\t\t\t\"```\",\n\t\t\t\"Multi-file input:\",\n\t\t\t\"```text\",\n\t\t\t\"[src/a.ts#0A3B]\",\n\t\t\t\"replace 1..1:\",\n\t\t\t\"+export const enabled = true;\",\n\t\t\t\"[src/b.ts#1F7C]\",\n\t\t\t\"delete 20\",\n\t\t\t\"```\",\n\t\t].join(\"\\n\"),\n\t\t[\n\t\t\t\"Anti-patterns:\",\n\t\t\t\"```text\",\n\t\t\t\"# WRONG — `-` rows are rejected; bare context rows are auto-prefixed and inserted as literal content: `-` rows are not valid; the range already names the lines being changed. For a literal `-` line, write `+-…`.\",\n\t\t\t\"replace 3..3:\",\n\t\t\t' msg = \"Hello\"',\n\t\t\t\"- print(msg)\",\n\t\t\t\"+ return msg\",\n\t\t\t\"# RIGHT\",\n\t\t\t\"replace 3..3:\",\n\t\t\t\"+ return msg\",\n\t\t\t\"\",\n\t\t\t\"# WRONG — body glued to its header: payload line has no preceding hunk header; body starts on the NEXT line.\",\n\t\t\t\"replace block 238:+export const value = 1;\",\n\t\t\t\"# RIGHT\",\n\t\t\t\"replace block 238:\",\n\t\t\t\"+export const value = 1;\",\n\t\t\t\"\",\n\t\t\t\"# WRONG — `delete N..M` has no colon and no body.\",\n\t\t\t\"delete 2..3:\",\n\t\t\t\"+replacement\",\n\t\t\t\"# RIGHT: delete 2..3\",\n\t\t\t\"\",\n\t\t\t\"# WRONG — empty `insert` / `replace`: `insert` needs at least one `+TEXT` body row. A bodyless concrete `replace` silently deletes the range.\",\n\t\t\t\"insert after 2:\",\n\t\t\t\"replace 4..4:\",\n\t\t\t\"# RIGHT — give `replace` a body; if deletion is intended, write `delete 4`.\",\n\t\t\t\"\",\n\t\t\t\"# WRONG — widened replace for a pure insertion can drop retyped keepers.\",\n\t\t\t\"replace 2..4:\",\n\t\t\t\"+kept()\",\n\t\t\t\"+added()\",\n\t\t\t\"# RIGHT: insert after 2:\",\n\t\t\t\"+added()\",\n\t\t\t\"\",\n\t\t\t\"# WRONG — block anchor is a closer/last visible line.\",\n\t\t\t\"insert after block 3:\",\n\t\t\t\"+after()\",\n\t\t\t\"# RIGHT: insert after 3:\",\n\t\t\t\"+after()\",\n\t\t\t\"```\",\n\t\t].join(\"\\n\"),\n\t\t[\n\t\t\t\"If you remember nothing else:\",\n\t\t\t\"1. RE-GROUND AFTER EVERY EDIT. Every apply mints a fresh #TAG and renumbers; use the edit response or a fresh read. Stale tag or surprise? STOP and re-read.\",\n\t\t\t\"2. RANGES ARE TIGHT. Cover only lines that change; a stale wide range shreds everything it spans. Whole construct → replace block N.\",\n\t\t\t\"3. THE BODY IS THE FINAL CONTENT. Only +TEXT rows; never -old/context lines. The range does the deleting.\",\n\t\t].join(\"\\n\"),\n\t] as const),\n} as const);\n\nexport type EditToolInput = Static<typeof editSchema>;\n\nexport interface EditToolDetails {\n\tdiff: string;\n\tpatch: string;\n\tfirstChangedLine?: number;\n}\n\nexport interface EditOperations {\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\twriteFile: (absolutePath: string, content: string) => Promise<void>;\n\taccess: (absolutePath: string) => Promise<void>;\n}\n\nconst defaultEditOperations: EditOperations = {\n\treadFile: (path) => fsReadFile(path),\n\twriteFile: (path, content) => fsWriteFile(path, content, \"utf-8\"),\n\taccess: (path) => fsAccess(path, constants.R_OK | constants.W_OK),\n};\n\nexport interface EditToolOptions {\n\toperations?: EditOperations;\n\thashlineStore?: HashlineSnapshotStore;\n}\n\ntype EditToolResultLike = {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: EditToolDetails | undefined;\n};\n\nclass EditFilesystem extends Filesystem {\n\tprivate readonly cwd: string;\n\tprivate readonly operations: EditOperations;\n\tconstructor(cwd: string, operations: EditOperations) {\n\t\tsuper();\n\t\tthis.cwd = cwd;\n\t\tthis.operations = operations;\n\t}\n\n\tcanonicalPath(path: string): string {\n\t\treturn resolveReadPath(path, this.cwd);\n\t}\n\n\tasync preflightWrite(path: string): Promise<void> {\n\t\tconst absolutePath = this.canonicalPath(path);\n\t\ttry {\n\t\t\tawait this.operations.access(absolutePath);\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error && \"code\" in error ? `Error code: ${error.code}` : String(error);\n\t\t\tthrow new Error(`Could not edit file: ${path}. ${message}.`);\n\t\t}\n\t}\n\n\tasync readText(path: string): Promise<string> {\n\t\tconst absolutePath = this.canonicalPath(path);\n\t\treturn isNotebookPath(absolutePath)\n\t\t\t? readEditableNotebookText(absolutePath, path)\n\t\t\t: (await this.operations.readFile(absolutePath)).toString(\"utf-8\");\n\t}\n\n\tasync writeText(path: string, content: string): Promise<WriteResult> {\n\t\tconst absolutePath = this.canonicalPath(path);\n\t\tconst persisted = isNotebookPath(absolutePath)\n\t\t\t? serializeEditedNotebookText(absolutePath, path, normalizeToLF(stripBom(content).text))\n\t\t\t: content;\n\t\tawait this.operations.writeFile(absolutePath, persisted);\n\t\treturn { text: persisted };\n\t}\n}\n\nfunction isFourDigitHexTag(value: string): boolean {\n\treturn (\n\t\tvalue.length === 4 &&\n\t\t[...value].every(\n\t\t\t(char) => (char >= \"0\" && char <= \"9\") || (char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\"),\n\t\t)\n\t);\n}\n\nfunction extractFirstHeaderPath(input: string | undefined): string | undefined {\n\tif (!input) return undefined;\n\tfor (const line of input.split(\"\\n\")) {\n\t\tconst trimmed = line.trimStart();\n\t\tif (!trimmed.startsWith(\"[\")) continue;\n\t\tconst hashIndex = trimmed.indexOf(\"#\", 1);\n\t\tconst closeIndex = hashIndex >= 0 ? trimmed.indexOf(\"]\", hashIndex + 1) : -1;\n\t\tif (hashIndex <= 1 || closeIndex !== hashIndex + 5) continue;\n\t\tconst tag = trimmed.slice(hashIndex + 1, closeIndex);\n\t\tif (isFourDigitHexTag(tag)) return trimmed.slice(1, hashIndex);\n\t}\n\treturn undefined;\n}\n\nfunction formatEditCall(args: unknown, theme: Theme, cwd: string): string {\n\tconst input = args && typeof args === \"object\" && \"input\" in args ? (args as { input?: unknown }).input : undefined;\n\tconst pathDisplay = renderToolPath(\n\t\textractFirstHeaderPath(typeof input === \"string\" ? input : undefined) ?? null,\n\t\ttheme,\n\t\tcwd,\n\t);\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"edit\"))} ${pathDisplay}`;\n}\n\nfunction formatEditResult(result: EditToolResultLike, theme: Theme, isError: boolean): string | undefined {\n\tif (isError) {\n\t\tconst errorText = result.content\n\t\t\t.filter((c) => c.type === \"text\")\n\t\t\t.map((c) => c.text || \"\")\n\t\t\t.join(\"\\n\");\n\t\treturn errorText ? theme.fg(\"error\", errorText) : undefined;\n\t}\n\treturn result.details?.diff ? renderDiff(result.details.diff) : undefined;\n}\n\nasync function withFileMutationQueues<T>(filePaths: readonly string[], fn: () => Promise<T>): Promise<T> {\n\tconst sorted = [...new Set(filePaths)].sort();\n\tconst run = (index: number): Promise<T> => {\n\t\tconst filePath = sorted[index];\n\t\treturn filePath ? withFileMutationQueue(filePath, () => run(index + 1)) : fn();\n\t};\n\treturn run(0);\n}\n\nfunction throwIfAborted(signal?: AbortSignal): void {\n\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n}\n\nfunction formatNoopMessage(path: string, count: number): string {\n\treturn `Edits to ${path} parsed and applied cleanly, but produced no change: your body row(s) are byte-identical to the file at the targeted lines. The bug is somewhere else — re-read the file before issuing another edit. Do NOT widen the payload or add lines; verify the anchor first.${count > 1 ? `\\nNo-op count for this identical payload: ${count}.` : \"\"}`;\n}\n\nfunction blockMessages(item: PreparedSection | PatchSectionResult): string[] {\n\tconst warnings =\n\t\t\"parseWarnings\" in item ? [...item.parseWarnings, ...(item.applyResult.warnings ?? [])] : item.warnings;\n\tconst resolutions =\n\t\t(\"applyResult\" in item ? item.applyResult.blockResolutions : item.blockResolutions)?.map((resolution) => {\n\t\t\tconst verb = resolution.op === \"insert_after\" ? \"insert after block\" : `${resolution.op} block`;\n\t\t\tconst lands = resolution.op === \"insert_after\" ? `; body lands after line ${resolution.end}` : \"\";\n\t\t\treturn `${verb} ${resolution.anchorLine} → resolved lines ${resolution.start}-${resolution.end} (${resolution.end - resolution.start + 1} lines)${lands}`;\n\t\t}) ?? [];\n\treturn [...warnings, ...resolutions];\n}\n\nfunction assertUniquePreparedPaths(prepared: readonly PreparedSection[]): void {\n\tconst seen = new Map<string, string>();\n\tfor (const entry of prepared) {\n\t\tconst previous = seen.get(entry.canonicalPath);\n\t\tif (previous)\n\t\t\tthrow new Error(\n\t\t\t\t`Multiple hashline sections resolve to the same file (${previous} and ${entry.section.path}). Merge their ops under one header before applying.`,\n\t\t\t);\n\t\tseen.set(entry.canonicalPath, entry.section.path);\n\t}\n}\n\ninterface EditCwdScope {\n\treadonly fs: EditFilesystem;\n\treadonly batcher: EditBatchCoordinator<EditToolResultLike>;\n\tapplySiblingEdits(siblings: readonly { input: string }[], applySignal?: AbortSignal): Promise<EditToolResultLike>;\n}\n\nfunction createEditCwdScope(cwd: string, ops: EditOperations, hashlineStore: HashlineSnapshotStore): EditCwdScope {\n\tconst fs = new EditFilesystem(cwd, ops);\n\tconst patcher = new Patcher({ fs, snapshots: hashlineStore.snapshots, blockResolver: nativeBlockResolver });\n\tconst noopCounts = new Map<string, number>();\n\tconst batcher = new EditBatchCoordinator<EditToolResultLike>();\n\tasync function applySiblingEdits(\n\t\tsiblings: readonly { input: string }[],\n\t\tapplySignal?: AbortSignal,\n\t): Promise<EditToolResultLike> {\n\t\tconst merged =\n\t\t\tsiblings.length === 1\n\t\t\t\t? Patch.parse(siblings[0]!.input, { cwd })\n\t\t\t\t: Patch.parse(siblings.map((sibling) => sibling.input).join(\"\\n\"), { cwd });\n\t\tconst prepared: PreparedSection[] = [];\n\t\tfor (const section of merged.sections) {\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tprepared.push(await patcher.prepare(section));\n\t\t}\n\t\tassertUniquePreparedPaths(prepared);\n\t\tconst noops = prepared.filter((item) => item.isNoop);\n\t\tif (noops.length > 0) {\n\t\t\tif (noops.length !== prepared.length)\n\t\t\t\tthrow new Error(`Hashline edit for ${noops[0]!.section.path} did not change the file.`);\n\t\t\tconst key = prepared.map((item) => `${item.canonicalPath}\\0${item.applyResult.text}`).join(\"\\0\\0\");\n\t\t\tconst count = (noopCounts.get(key) ?? 0) + 1;\n\t\t\tnoopCounts.set(key, count);\n\t\t\tif (count >= 3) throw new Error(`STOP. ${formatNoopMessage(prepared[0]!.section.path, count)}`);\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: formatNoopMessage(prepared[0]!.section.path, count) }],\n\t\t\t\tdetails: { diff: \"\", patch: \"\" },\n\t\t\t};\n\t\t}\n\t\tfor (const item of prepared) {\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tif (normalizeToLF(stripBom(await fs.readText(item.section.path)).text) !== item.normalized)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Stale hashline tag for ${item.section.path}: file content changed before write. Re-read before editing.`,\n\t\t\t\t);\n\t\t}\n\t\tconst outputs: string[] = [];\n\t\tlet combinedDiff = \"\",\n\t\t\tcombinedPatch = \"\";\n\t\tlet firstChangedLine: number | undefined;\n\t\tconst batchNote = siblings.length > 1 ? [parallelEditBatchWarning(siblings.length)] : [];\n\t\tfor (let index = 0; index < prepared.length; index++) {\n\t\t\tconst item = prepared[index]!;\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tlet result: PatchSectionResult;\n\t\t\ttry {\n\t\t\t\tresult = await patcher.commit(item);\n\t\t\t} catch (error) {\n\t\t\t\tconst written = prepared.slice(0, index).map((entry) => entry.section.path);\n\t\t\t\tconst notWritten = prepared.slice(index + 1).map((entry) => entry.section.path);\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to write ${item.section.path}: ${message}` +\n\t\t\t\t\t\t(written.length > 0 ? ` Sections already written: ${written.join(\", \")}.` : \"\") +\n\t\t\t\t\t\t(notWritten.length > 0 ? ` Sections not written: ${notWritten.join(\", \")}.` : \"\"),\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tinvalidateNativeSearchCache(result.canonicalPath);\n\t\t\tconst snapshot = recordHashlineSnapshot(result.canonicalPath, cwd, result.after, hashlineStore);\n\t\t\tconst diffResult = generateDiffString(result.before, result.after);\n\t\t\tcombinedDiff += `${combinedDiff ? \"\\n\" : \"\"}${diffResult.diff}`;\n\t\t\tcombinedPatch += `${combinedPatch ? \"\\n\" : \"\"}${generateUnifiedPatch(result.path, result.before, result.after)}`;\n\t\t\tfirstChangedLine ??= diffResult.firstChangedLine;\n\t\t\toutputs.push(formatCompactHashlineEditResult(snapshot, diffResult, [...batchNote, ...blockMessages(result)]));\n\t\t}\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: outputs.join(\"\\n\\n\") }],\n\t\t\tdetails: { diff: combinedDiff, patch: combinedPatch, firstChangedLine },\n\t\t};\n\t}\n\treturn { fs, batcher, applySiblingEdits };\n}\n\nexport function createEditToolDefinition(\n\tcwd: string,\n\toptions?: EditToolOptions,\n): ToolDefinition<typeof editSchema, EditToolDetails | undefined> {\n\tconst ops = options?.operations ?? defaultEditOperations;\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\t// Atomic adaptation of upstream #8627 (\"use ctx.cwd for cwd-sensitive tools\"). Upstream's edit\n\t// tool is a stateless text replacer, so it could resolve `ctx?.cwd || cwd` inline. Atomic's\n\t// hashline patcher instead carries per-tool state — the `EditFilesystem`, the `Patcher`, the\n\t// repeated-no-op counters, and the parallel-edit batcher — that is all keyed to one cwd.\n\t// Mutating a shared cwd field would corrupt concurrent tool calls, so each distinct execution\n\t// cwd gets its own scope. Callers that pass no ctx keep the factory cwd's scope unchanged.\n\tconst scopes = new Map<string, EditCwdScope>();\n\tconst scopeFor = (executionCwd: string): EditCwdScope => {\n\t\tconst existing = scopes.get(executionCwd);\n\t\tif (existing) return existing;\n\t\tconst scope = createEditCwdScope(executionCwd, ops, hashlineStore);\n\t\tscopes.set(executionCwd, scope);\n\t\treturn scope;\n\t};\n\treturn {\n\t\tname: \"edit\",\n\t\tlabel: \"edit\",\n\t\tdescription:\n\t\t\t\"Edit existing files with the hashline patch language: each section starts with [PATH#TAG] (TAG is the 4-hex snapshot tag from your latest read/search), then hunk headers (replace N..M:, replace block N:, delete N..M, delete block N, insert before|after N:, insert after block N:, insert head:, insert tail:) followed by +TEXT body rows. Numbers refer to the original file. Use the write tool to create new files.\",\n\t\tpromptSnippet: editToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...editToolSystemPromptContribution.guidelines],\n\t\t...experimentalToolSamplingProperty(),\n\t\tparameters: editSchema,\n\t\tasync execute(_toolCallId, input: EditToolInput, signal?: AbortSignal, _onUpdate?, ctx?: ExtensionContext) {\n\t\t\tif (typeof input.input !== \"string\" || input.input.trim() === \"\")\n\t\t\t\tthrow new Error(\"edit input must be a non-empty hashline script with [PATH#TAG] sections.\");\n\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\tconst { fs, batcher, applySiblingEdits } = scopeFor(executionCwd);\n\t\t\tconst patch = Patch.parse(input.input, { cwd: executionCwd });\n\t\t\tconst paths = new Map<string, string>();\n\t\t\tfor (const section of patch.sections) {\n\t\t\t\tif (section.fileHash === undefined) throw new Error(missingSnapshotTagMessage(section.path));\n\t\t\t\tpaths.set(section.path, section.fileHash);\n\t\t\t}\n\t\t\tconst entry = batcher.announce(input.input, paths, signal);\n\t\t\ttry {\n\t\t\t\treturn await withFileMutationQueues(\n\t\t\t\t\t[...paths.keys()].map((sectionPath) => fs.canonicalPath(sectionPath)),\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tif (entry.settled) return await entry.promise;\n\t\t\t\t\t\tthrowIfAborted(signal);\n\t\t\t\t\t\tconst siblings = batcher.takeCompatible(entry);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await applySiblingEdits(siblings, signal);\n\t\t\t\t\t\t\tfor (const sibling of siblings) sibling.resolve(result);\n\t\t\t\t\t\t\treturn result;\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tfor (const sibling of siblings) sibling.reject(error);\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (entry.settled) return await entry.promise;\n\t\t\t\tentry.reject(error);\n\t\t\t\tthrow error;\n\t\t\t} finally {\n\t\t\t\tbatcher.drop(entry);\n\t\t\t}\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatEditCall(args, theme, context.cwd));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst output = formatEditResult(result as EditToolResultLike, theme, context.isError);\n\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\tcomponent.clear();\n\t\t\tif (!output) return component;\n\t\t\tcomponent.addChild(new Spacer(1));\n\t\t\tcomponent.addChild(new Text(output, 1, 0));\n\t\t\treturn component;\n\t\t},\n\t};\n}\n\nexport function createEditTool(cwd: string, options?: EditToolOptions): AgentTool<typeof editSchema> {\n\treturn wrapToolDefinition(createEditToolDefinition(cwd, options));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/core/tools/find.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AAOtF,OAAO,EAAiC,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAGnG,QAAA,MAAM,UAAU;;;;;;EAgBf,CAAC;AACF,eAAO,MAAM,gCAAgC;sBACnC,gCAAgC;;EAE/B,CAAC;AACZ,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AA6HtD,6FAA6F;AAC7F,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,UAAU,GAAE,IAAI,CAAC,YAAmB,GAClC,MAAM,CAMR;AAiED,MAAM,WAAW,eAAe;IAC/B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE;QA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AE,GAAG,SAAS,CAAC,GAC9D;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,GACzC,SAAS,CAAC;IACb,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACrD,IAAI,EAAE,CACL,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,KACzD,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;CAClC;AAKD,MAAM,WAAW,eAAe;IAC/B,oEAAoE;IACpE,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AAsDD,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,eAAe,GACvB,cAAc,CAAC,OAAO,UAAU,EAAE,eAAe,GAAG,SAAS,CAAC,CA2ZhE;AACD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAEnG"}
@@ -297,7 +297,7 @@ export function createFindToolDefinition(cwd, options) {
297
297
  promptSnippet: findToolSystemPromptContribution.snippet,
298
298
  ...experimentalToolSamplingProperty(),
299
299
  parameters: findSchema,
300
- async execute(_toolCallId, params, signal, _onUpdate, _ctx) {
300
+ async execute(_toolCallId, params, signal, _onUpdate, ctx) {
301
301
  return new Promise((resolve, reject) => {
302
302
  if (signal?.aborted) {
303
303
  reject(new Error("Operation aborted"));
@@ -320,11 +320,12 @@ export function createFindToolDefinition(cwd, options) {
320
320
  signal?.addEventListener("abort", onAbort, { once: true });
321
321
  const { limit, hidden, gitignore, timeout } = params;
322
322
  const paths = params.paths;
323
- const resourceCtx = _ctx;
323
+ const resourceCtx = ctx;
324
+ const executionCwd = ctx?.cwd || cwd;
324
325
  (async () => {
325
326
  try {
326
327
  const ops = customOps ?? defaultFindOperations;
327
- const targets = normalizeFindTargets(cwd, await expandDelimitedFindPaths(paths, cwd, ops, resourceCtx, !!customOps), !!customOps);
328
+ const targets = normalizeFindTargets(executionCwd, await expandDelimitedFindPaths(paths, executionCwd, ops, resourceCtx, !!customOps), !!customOps);
328
329
  const searchPaths = targets.map((target) => target.searchPath);
329
330
  const effectiveLimit = normalizeLimit(limit);
330
331
  const timeoutMs = normalizeTimeoutMs(timeout);
@@ -349,7 +350,7 @@ export function createFindToolDefinition(cwd, options) {
349
350
  if (target.exactPathInput) {
350
351
  const isFile = typeof stat?.isFile === "function" ? stat.isFile() : stat?.isFile;
351
352
  if (isFile) {
352
- exactFileResults.push(formatExactFoundPath(target.searchPath, cwd));
353
+ exactFileResults.push(formatExactFoundPath(target.searchPath, executionCwd));
353
354
  continue;
354
355
  }
355
356
  }
@@ -424,7 +425,7 @@ export function createFindToolDefinition(cwd, options) {
424
425
  if (target.exactPathInput && results.length === 0) {
425
426
  const stat = await customOps.stat?.(target.searchPath);
426
427
  if (!stat?.isDirectory)
427
- relativized.push(formatExactFoundPath(target.searchPath, cwd));
428
+ relativized.push(formatExactFoundPath(target.searchPath, executionCwd));
428
429
  continue;
429
430
  }
430
431
  if (signal?.aborted) {
@@ -436,7 +437,7 @@ export function createFindToolDefinition(cwd, options) {
436
437
  customLimitReached = true;
437
438
  relativized.push(...visible
438
439
  .slice(0, remaining)
439
- .map((p) => formatFoundPath(p, target.searchPath, searchPaths, cwd)));
440
+ .map((p) => formatFoundPath(p, target.searchPath, searchPaths, executionCwd)));
440
441
  emitUpdate(relativized);
441
442
  if (customLimitReached)
442
443
  break;
@@ -483,7 +484,7 @@ export function createFindToolDefinition(cwd, options) {
483
484
  !match.path.endsWith("/");
484
485
  const matchPath = isDir ? `${match.path}/` : match.path;
485
486
  return {
486
- path: formatFoundPath(matchPath, target.searchPath, searchPaths, cwd),
487
+ path: formatFoundPath(matchPath, target.searchPath, searchPaths, executionCwd),
487
488
  mtime: match.mtime ?? 0,
488
489
  };
489
490
  }));
@@ -601,7 +602,7 @@ export function createFindToolDefinition(cwd, options) {
601
602
  })?.isDirectory() && !line.endsWith("/")
602
603
  ? `${line}/`
603
604
  : line;
604
- relativized.push(formatFoundPath(found, target.searchPath, searchPaths, cwd));
605
+ relativized.push(formatFoundPath(found, target.searchPath, searchPaths, executionCwd));
605
606
  }
606
607
  }
607
608
  emitUpdate(relativized);