@bastani/atomic 0.9.2-alpha.1 → 0.9.3-alpha.1

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 (455) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +2 -2
  3. package/dist/builtin/cursor/CHANGELOG.md +6 -0
  4. package/dist/builtin/cursor/package.json +2 -2
  5. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  6. package/dist/builtin/intercom/package.json +1 -1
  7. package/dist/builtin/mcp/CHANGELOG.md +12 -0
  8. package/dist/builtin/mcp/direct-tools.ts +4 -2
  9. package/dist/builtin/mcp/package.json +1 -1
  10. package/dist/builtin/mcp/proxy-call.ts +3 -1
  11. package/dist/builtin/mcp/utils.ts +18 -7
  12. package/dist/builtin/subagents/CHANGELOG.md +17 -0
  13. package/dist/builtin/subagents/README.md +6 -6
  14. package/dist/builtin/subagents/agents/code-simplifier.md +7 -6
  15. package/dist/builtin/subagents/agents/codebase-analyzer.md +5 -4
  16. package/dist/builtin/subagents/agents/codebase-locator.md +3 -3
  17. package/dist/builtin/subagents/agents/codebase-online-researcher.md +10 -10
  18. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +4 -4
  19. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +3 -3
  20. package/dist/builtin/subagents/agents/codebase-research-locator.md +4 -4
  21. package/dist/builtin/subagents/agents/debugger.md +5 -5
  22. package/dist/builtin/subagents/agents/worker.md +56 -0
  23. package/dist/builtin/subagents/package.json +1 -1
  24. package/dist/builtin/subagents/skills/subagent/SKILL.md +11 -11
  25. package/dist/builtin/subagents/src/agents/agent-loaders.ts +3 -5
  26. package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +3 -3
  27. package/dist/builtin/subagents/src/extension/schemas.ts +2 -2
  28. package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -3
  29. package/dist/builtin/subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +1 -1
  30. package/dist/builtin/subagents/src/runs/shared/nested-render.ts +2 -2
  31. package/dist/builtin/subagents/src/runs/shared/pi-args.ts +2 -1
  32. package/dist/builtin/subagents/src/shared/types-depth.ts +5 -5
  33. package/dist/builtin/subagents/src/shared/types-runtime.ts +2 -1
  34. package/dist/builtin/subagents/src/tui/render-event-formatting.ts +2 -2
  35. package/dist/builtin/web-access/CHANGELOG.md +6 -0
  36. package/dist/builtin/web-access/package.json +1 -1
  37. package/dist/builtin/workflows/CHANGELOG.md +21 -0
  38. package/dist/builtin/workflows/README.md +2 -2
  39. package/dist/builtin/workflows/builtin/goal-artifacts.ts +11 -6
  40. package/dist/builtin/workflows/builtin/goal-ledger.ts +33 -1
  41. package/dist/builtin/workflows/builtin/goal-prompts.ts +23 -28
  42. package/dist/builtin/workflows/builtin/goal-reducer.ts +2 -2
  43. package/dist/builtin/workflows/builtin/goal-reports.ts +2 -5
  44. package/dist/builtin/workflows/builtin/goal-review.ts +1 -1
  45. package/dist/builtin/workflows/builtin/goal-runner.ts +10 -17
  46. package/dist/builtin/workflows/builtin/open-claude-design-feedback.ts +3 -3
  47. package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +1 -3
  48. package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +1 -1
  49. package/dist/builtin/workflows/builtin/ralph-core.ts +7 -17
  50. package/dist/builtin/workflows/builtin/ralph-runner.ts +11 -18
  51. package/dist/builtin/workflows/builtin/shared-prompts.ts +1 -1
  52. package/dist/builtin/workflows/package.json +1 -1
  53. package/dist/builtin/workflows/src/extension/config-loader.ts +35 -15
  54. package/dist/builtin/workflows/src/extension/discovery.ts +20 -8
  55. package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +1 -2
  56. package/dist/builtin/workflows/src/extension/wiring.ts +1 -1
  57. package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +11 -10
  58. package/dist/cli/args.d.ts.map +1 -1
  59. package/dist/cli/args.js +9 -9
  60. package/dist/cli/args.js.map +1 -1
  61. package/dist/config-self-update.d.ts.map +1 -1
  62. package/dist/config-self-update.js +3 -4
  63. package/dist/config-self-update.js.map +1 -1
  64. package/dist/config.d.ts.map +1 -1
  65. package/dist/config.js +4 -5
  66. package/dist/config.js.map +1 -1
  67. package/dist/core/agent-session-bash.d.ts +1 -0
  68. package/dist/core/agent-session-bash.d.ts.map +1 -1
  69. package/dist/core/agent-session-bash.js +1 -0
  70. package/dist/core/agent-session-bash.js.map +1 -1
  71. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  72. package/dist/core/agent-session-tool-registry.js +23 -0
  73. package/dist/core/agent-session-tool-registry.js.map +1 -1
  74. package/dist/core/bash-executor.d.ts +2 -0
  75. package/dist/core/bash-executor.d.ts.map +1 -1
  76. package/dist/core/bash-executor.js +1 -0
  77. package/dist/core/bash-executor.js.map +1 -1
  78. package/dist/core/compaction/compaction.d.ts +29 -0
  79. package/dist/core/compaction/compaction.d.ts.map +1 -1
  80. package/dist/core/compaction/compaction.js +36 -1
  81. package/dist/core/compaction/compaction.js.map +1 -1
  82. package/dist/core/compaction/context-compaction-metrics.d.ts +14 -2
  83. package/dist/core/compaction/context-compaction-metrics.d.ts.map +1 -1
  84. package/dist/core/compaction/context-compaction-metrics.js +50 -1
  85. package/dist/core/compaction/context-compaction-metrics.js.map +1 -1
  86. package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -1
  87. package/dist/core/compaction/context-compaction-prompt.js +2 -0
  88. package/dist/core/compaction/context-compaction-prompt.js.map +1 -1
  89. package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -1
  90. package/dist/core/compaction/context-compaction-runner.js +1 -1
  91. package/dist/core/compaction/context-compaction-runner.js.map +1 -1
  92. package/dist/core/compaction/context-deletion-application.d.ts.map +1 -1
  93. package/dist/core/compaction/context-deletion-application.js +5 -5
  94. package/dist/core/compaction/context-deletion-application.js.map +1 -1
  95. package/dist/core/compaction/context-deletion-targets.d.ts +2 -0
  96. package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -1
  97. package/dist/core/compaction/context-deletion-targets.js +23 -3
  98. package/dist/core/compaction/context-deletion-targets.js.map +1 -1
  99. package/dist/core/compaction/context-deletion-tool-definitions.d.ts +6 -0
  100. package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +1 -1
  101. package/dist/core/compaction/context-deletion-tool-definitions.js.map +1 -1
  102. package/dist/core/compaction/context-deletion-tools.d.ts.map +1 -1
  103. package/dist/core/compaction/context-deletion-tools.js +18 -10
  104. package/dist/core/compaction/context-deletion-tools.js.map +1 -1
  105. package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
  106. package/dist/core/compaction/context-transcript-analysis.js +2 -4
  107. package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
  108. package/dist/core/copilot-gemini-tool-arguments.d.ts.map +1 -1
  109. package/dist/core/copilot-gemini-tool-arguments.js +2 -60
  110. package/dist/core/copilot-gemini-tool-arguments.js.map +1 -1
  111. package/dist/core/extensions/context-types.d.ts +2 -0
  112. package/dist/core/extensions/context-types.d.ts.map +1 -1
  113. package/dist/core/extensions/context-types.js.map +1 -1
  114. package/dist/core/extensions/index.d.ts +2 -2
  115. package/dist/core/extensions/index.d.ts.map +1 -1
  116. package/dist/core/extensions/index.js +1 -1
  117. package/dist/core/extensions/index.js.map +1 -1
  118. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  119. package/dist/core/extensions/loader-virtual-modules.js +11 -3
  120. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  121. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  122. package/dist/core/extensions/runner-context.js +11 -0
  123. package/dist/core/extensions/runner-context.js.map +1 -1
  124. package/dist/core/extensions/tool-events.d.ts +13 -13
  125. package/dist/core/extensions/tool-events.d.ts.map +1 -1
  126. package/dist/core/extensions/tool-events.js +3 -3
  127. package/dist/core/extensions/tool-events.js.map +1 -1
  128. package/dist/core/extensions/types.d.ts +1 -1
  129. package/dist/core/extensions/types.d.ts.map +1 -1
  130. package/dist/core/extensions/types.js +1 -1
  131. package/dist/core/extensions/types.js.map +1 -1
  132. package/dist/core/flattened-tool-arguments.d.ts +18 -0
  133. package/dist/core/flattened-tool-arguments.d.ts.map +1 -1
  134. package/dist/core/flattened-tool-arguments.js +104 -0
  135. package/dist/core/flattened-tool-arguments.js.map +1 -1
  136. package/dist/core/sdk-exports.d.ts +1 -1
  137. package/dist/core/sdk-exports.d.ts.map +1 -1
  138. package/dist/core/sdk-exports.js +1 -1
  139. package/dist/core/sdk-exports.js.map +1 -1
  140. package/dist/core/sdk-types.d.ts +2 -2
  141. package/dist/core/sdk-types.d.ts.map +1 -1
  142. package/dist/core/sdk-types.js.map +1 -1
  143. package/dist/core/settings-manager-basic-accessors.d.ts +4 -0
  144. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  145. package/dist/core/settings-manager-basic-accessors.js +18 -0
  146. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  147. package/dist/core/settings-manager-resource-accessors.d.ts +4 -0
  148. package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
  149. package/dist/core/settings-manager-resource-accessors.js +15 -0
  150. package/dist/core/settings-manager-resource-accessors.js.map +1 -1
  151. package/dist/core/settings-types.d.ts +11 -0
  152. package/dist/core/settings-types.d.ts.map +1 -1
  153. package/dist/core/settings-types.js.map +1 -1
  154. package/dist/core/system-prompt.d.ts +1 -1
  155. package/dist/core/system-prompt.d.ts.map +1 -1
  156. package/dist/core/system-prompt.js +3 -2
  157. package/dist/core/system-prompt.js.map +1 -1
  158. package/dist/core/tools/artifact-protocol.d.ts +11 -0
  159. package/dist/core/tools/artifact-protocol.d.ts.map +1 -0
  160. package/dist/core/tools/artifact-protocol.js +76 -0
  161. package/dist/core/tools/artifact-protocol.js.map +1 -0
  162. package/dist/core/tools/artifacts.d.ts +18 -0
  163. package/dist/core/tools/artifacts.d.ts.map +1 -0
  164. package/dist/core/tools/artifacts.js +90 -0
  165. package/dist/core/tools/artifacts.js.map +1 -0
  166. package/dist/core/tools/bash-async-jobs.d.ts +20 -0
  167. package/dist/core/tools/bash-async-jobs.d.ts.map +1 -0
  168. package/dist/core/tools/bash-async-jobs.js +59 -0
  169. package/dist/core/tools/bash-async-jobs.js.map +1 -0
  170. package/dist/core/tools/bash-async-output.d.ts +10 -0
  171. package/dist/core/tools/bash-async-output.d.ts.map +1 -0
  172. package/dist/core/tools/bash-async-output.js +80 -0
  173. package/dist/core/tools/bash-async-output.js.map +1 -0
  174. package/dist/core/tools/bash-interceptor.d.ts +10 -0
  175. package/dist/core/tools/bash-interceptor.d.ts.map +1 -0
  176. package/dist/core/tools/bash-interceptor.js +39 -0
  177. package/dist/core/tools/bash-interceptor.js.map +1 -0
  178. package/dist/core/tools/bash-leading-cd.d.ts +7 -0
  179. package/dist/core/tools/bash-leading-cd.d.ts.map +1 -0
  180. package/dist/core/tools/bash-leading-cd.js +59 -0
  181. package/dist/core/tools/bash-leading-cd.js.map +1 -0
  182. package/dist/core/tools/bash-pty-native.d.ts +14 -0
  183. package/dist/core/tools/bash-pty-native.d.ts.map +1 -0
  184. package/dist/core/tools/bash-pty-native.js +71 -0
  185. package/dist/core/tools/bash-pty-native.js.map +1 -0
  186. package/dist/core/tools/bash.d.ts +28 -17
  187. package/dist/core/tools/bash.d.ts.map +1 -1
  188. package/dist/core/tools/bash.js +152 -35
  189. package/dist/core/tools/bash.js.map +1 -1
  190. package/dist/core/tools/block-resolver.d.ts +16 -0
  191. package/dist/core/tools/block-resolver.d.ts.map +1 -0
  192. package/dist/core/tools/block-resolver.js +74 -0
  193. package/dist/core/tools/block-resolver.js.map +1 -0
  194. package/dist/core/tools/conflict-registry.d.ts +16 -0
  195. package/dist/core/tools/conflict-registry.d.ts.map +1 -0
  196. package/dist/core/tools/conflict-registry.js +44 -0
  197. package/dist/core/tools/conflict-registry.js.map +1 -0
  198. package/dist/core/tools/directory-tree.d.ts +13 -0
  199. package/dist/core/tools/directory-tree.d.ts.map +1 -0
  200. package/dist/core/tools/directory-tree.js +81 -0
  201. package/dist/core/tools/directory-tree.js.map +1 -0
  202. package/dist/core/tools/edit.d.ts +4 -29
  203. package/dist/core/tools/edit.d.ts.map +1 -1
  204. package/dist/core/tools/edit.js +136 -228
  205. package/dist/core/tools/edit.js.map +1 -1
  206. package/dist/core/tools/fetch-url.d.ts +74 -0
  207. package/dist/core/tools/fetch-url.d.ts.map +1 -0
  208. package/dist/core/tools/fetch-url.js +518 -0
  209. package/dist/core/tools/fetch-url.js.map +1 -0
  210. package/dist/core/tools/find.d.ts +27 -9
  211. package/dist/core/tools/find.d.ts.map +1 -1
  212. package/dist/core/tools/find.js +400 -176
  213. package/dist/core/tools/find.js.map +1 -1
  214. package/dist/core/tools/glob-path-utils.d.ts +8 -0
  215. package/dist/core/tools/glob-path-utils.d.ts.map +1 -0
  216. package/dist/core/tools/glob-path-utils.js +26 -0
  217. package/dist/core/tools/glob-path-utils.js.map +1 -0
  218. package/dist/core/tools/grep.d.ts +12 -0
  219. package/dist/core/tools/grep.d.ts.map +1 -1
  220. package/dist/core/tools/grep.js +141 -17
  221. package/dist/core/tools/grep.js.map +1 -1
  222. package/dist/core/tools/hashline-engine/apply.d.ts +11 -0
  223. package/dist/core/tools/hashline-engine/apply.d.ts.map +1 -0
  224. package/dist/core/tools/hashline-engine/apply.js +752 -0
  225. package/dist/core/tools/hashline-engine/apply.js.map +1 -0
  226. package/dist/core/tools/hashline-engine/block.d.ts +40 -0
  227. package/dist/core/tools/hashline-engine/block.d.ts.map +1 -0
  228. package/dist/core/tools/hashline-engine/block.js +117 -0
  229. package/dist/core/tools/hashline-engine/block.js.map +1 -0
  230. package/dist/core/tools/hashline-engine/diff-preview.d.ts +15 -0
  231. package/dist/core/tools/hashline-engine/diff-preview.d.ts.map +1 -0
  232. package/dist/core/tools/hashline-engine/diff-preview.js +98 -0
  233. package/dist/core/tools/hashline-engine/diff-preview.js.map +1 -0
  234. package/dist/core/tools/hashline-engine/format.d.ts +71 -0
  235. package/dist/core/tools/hashline-engine/format.d.ts.map +1 -0
  236. package/dist/core/tools/hashline-engine/format.js +178 -0
  237. package/dist/core/tools/hashline-engine/format.js.map +1 -0
  238. package/dist/core/tools/hashline-engine/fs.d.ts +81 -0
  239. package/dist/core/tools/hashline-engine/fs.d.ts.map +1 -0
  240. package/dist/core/tools/hashline-engine/fs.js +143 -0
  241. package/dist/core/tools/hashline-engine/fs.js.map +1 -0
  242. package/dist/core/tools/hashline-engine/index.d.ts +18 -0
  243. package/dist/core/tools/hashline-engine/index.d.ts.map +1 -0
  244. package/dist/core/tools/hashline-engine/index.js +20 -0
  245. package/dist/core/tools/hashline-engine/index.js.map +1 -0
  246. package/dist/core/tools/hashline-engine/input.d.ts +101 -0
  247. package/dist/core/tools/hashline-engine/input.d.ts.map +1 -0
  248. package/dist/core/tools/hashline-engine/input.js +398 -0
  249. package/dist/core/tools/hashline-engine/input.js.map +1 -0
  250. package/dist/core/tools/hashline-engine/messages.d.ts +99 -0
  251. package/dist/core/tools/hashline-engine/messages.d.ts.map +1 -0
  252. package/dist/core/tools/hashline-engine/messages.js +144 -0
  253. package/dist/core/tools/hashline-engine/messages.js.map +1 -0
  254. package/dist/core/tools/hashline-engine/mismatch.d.ts +45 -0
  255. package/dist/core/tools/hashline-engine/mismatch.d.ts.map +1 -0
  256. package/dist/core/tools/hashline-engine/mismatch.js +90 -0
  257. package/dist/core/tools/hashline-engine/mismatch.js.map +1 -0
  258. package/dist/core/tools/hashline-engine/normalize.d.ts +21 -0
  259. package/dist/core/tools/hashline-engine/normalize.d.ts.map +1 -0
  260. package/dist/core/tools/hashline-engine/normalize.js +33 -0
  261. package/dist/core/tools/hashline-engine/normalize.js.map +1 -0
  262. package/dist/core/tools/hashline-engine/parser.d.ts +24 -0
  263. package/dist/core/tools/hashline-engine/parser.d.ts.map +1 -0
  264. package/dist/core/tools/hashline-engine/parser.js +381 -0
  265. package/dist/core/tools/hashline-engine/parser.js.map +1 -0
  266. package/dist/core/tools/hashline-engine/patcher.d.ts +118 -0
  267. package/dist/core/tools/hashline-engine/patcher.d.ts.map +1 -0
  268. package/dist/core/tools/hashline-engine/patcher.js +341 -0
  269. package/dist/core/tools/hashline-engine/patcher.js.map +1 -0
  270. package/dist/core/tools/hashline-engine/prefixes.d.ts +43 -0
  271. package/dist/core/tools/hashline-engine/prefixes.d.ts.map +1 -0
  272. package/dist/core/tools/hashline-engine/prefixes.js +135 -0
  273. package/dist/core/tools/hashline-engine/prefixes.js.map +1 -0
  274. package/dist/core/tools/hashline-engine/recovery.d.ts +41 -0
  275. package/dist/core/tools/hashline-engine/recovery.d.ts.map +1 -0
  276. package/dist/core/tools/hashline-engine/recovery.js +168 -0
  277. package/dist/core/tools/hashline-engine/recovery.js.map +1 -0
  278. package/dist/core/tools/hashline-engine/snapshots.d.ts +65 -0
  279. package/dist/core/tools/hashline-engine/snapshots.d.ts.map +1 -0
  280. package/dist/core/tools/hashline-engine/snapshots.js +108 -0
  281. package/dist/core/tools/hashline-engine/snapshots.js.map +1 -0
  282. package/dist/core/tools/hashline-engine/stream.d.ts +3 -0
  283. package/dist/core/tools/hashline-engine/stream.d.ts.map +1 -0
  284. package/dist/core/tools/hashline-engine/stream.js +111 -0
  285. package/dist/core/tools/hashline-engine/stream.js.map +1 -0
  286. package/dist/core/tools/hashline-engine/tokenizer.d.ts +69 -0
  287. package/dist/core/tools/hashline-engine/tokenizer.d.ts.map +1 -0
  288. package/dist/core/tools/hashline-engine/tokenizer.js +430 -0
  289. package/dist/core/tools/hashline-engine/tokenizer.js.map +1 -0
  290. package/dist/core/tools/hashline-engine/types.d.ts +166 -0
  291. package/dist/core/tools/hashline-engine/types.d.ts.map +1 -0
  292. package/dist/core/tools/hashline-engine/types.js +9 -0
  293. package/dist/core/tools/hashline-engine/types.js.map +1 -0
  294. package/dist/core/tools/hashline.d.ts +29 -0
  295. package/dist/core/tools/hashline.d.ts.map +1 -0
  296. package/dist/core/tools/hashline.js +110 -0
  297. package/dist/core/tools/hashline.js.map +1 -0
  298. package/dist/core/tools/index.d.ts +6 -4
  299. package/dist/core/tools/index.d.ts.map +1 -1
  300. package/dist/core/tools/index.js +52 -35
  301. package/dist/core/tools/index.js.map +1 -1
  302. package/dist/core/tools/notebook.d.ts +38 -0
  303. package/dist/core/tools/notebook.d.ts.map +1 -0
  304. package/dist/core/tools/notebook.js +125 -0
  305. package/dist/core/tools/notebook.js.map +1 -0
  306. package/dist/core/tools/read-document-extract.d.ts +9 -0
  307. package/dist/core/tools/read-document-extract.d.ts.map +1 -0
  308. package/dist/core/tools/read-document-extract.js +212 -0
  309. package/dist/core/tools/read-document-extract.js.map +1 -0
  310. package/dist/core/tools/read-selectors.d.ts +24 -0
  311. package/dist/core/tools/read-selectors.d.ts.map +1 -0
  312. package/dist/core/tools/read-selectors.js +277 -0
  313. package/dist/core/tools/read-selectors.js.map +1 -0
  314. package/dist/core/tools/read-url.d.ts +37 -0
  315. package/dist/core/tools/read-url.d.ts.map +1 -0
  316. package/dist/core/tools/read-url.js +39 -0
  317. package/dist/core/tools/read-url.js.map +1 -0
  318. package/dist/core/tools/read.d.ts +11 -11
  319. package/dist/core/tools/read.d.ts.map +1 -1
  320. package/dist/core/tools/read.js +224 -94
  321. package/dist/core/tools/read.js.map +1 -1
  322. package/dist/core/tools/resource-selectors.d.ts +44 -0
  323. package/dist/core/tools/resource-selectors.d.ts.map +1 -0
  324. package/dist/core/tools/resource-selectors.js +808 -0
  325. package/dist/core/tools/resource-selectors.js.map +1 -0
  326. package/dist/core/tools/search-details.d.ts +26 -0
  327. package/dist/core/tools/search-details.d.ts.map +1 -0
  328. package/dist/core/tools/search-details.js +24 -0
  329. package/dist/core/tools/search-details.js.map +1 -0
  330. package/dist/core/tools/search-line-ranges.d.ts +11 -0
  331. package/dist/core/tools/search-line-ranges.d.ts.map +1 -0
  332. package/dist/core/tools/search-line-ranges.js +65 -0
  333. package/dist/core/tools/search-line-ranges.js.map +1 -0
  334. package/dist/core/tools/search-native.d.ts +97 -0
  335. package/dist/core/tools/search-native.d.ts.map +1 -0
  336. package/dist/core/tools/search-native.js +27 -0
  337. package/dist/core/tools/search-native.js.map +1 -0
  338. package/dist/core/tools/search.d.ts +24 -0
  339. package/dist/core/tools/search.d.ts.map +1 -0
  340. package/dist/core/tools/search.js +573 -0
  341. package/dist/core/tools/search.js.map +1 -0
  342. package/dist/core/tools/truncate.d.ts +4 -4
  343. package/dist/core/tools/truncate.d.ts.map +1 -1
  344. package/dist/core/tools/truncate.js +3 -3
  345. package/dist/core/tools/truncate.js.map +1 -1
  346. package/dist/core/tools/url-ip-guards.d.ts +4 -0
  347. package/dist/core/tools/url-ip-guards.d.ts.map +1 -0
  348. package/dist/core/tools/url-ip-guards.js +126 -0
  349. package/dist/core/tools/url-ip-guards.js.map +1 -0
  350. package/dist/core/tools/write.d.ts +12 -2
  351. package/dist/core/tools/write.d.ts.map +1 -1
  352. package/dist/core/tools/write.js +166 -14
  353. package/dist/core/tools/write.js.map +1 -1
  354. package/dist/core/trust-manager.d.ts.map +1 -1
  355. package/dist/core/trust-manager.js +2 -3
  356. package/dist/core/trust-manager.js.map +1 -1
  357. package/dist/index-extensions.d.ts +2 -2
  358. package/dist/index-extensions.d.ts.map +1 -1
  359. package/dist/index-extensions.js +1 -1
  360. package/dist/index-extensions.js.map +1 -1
  361. package/dist/index.d.ts +3 -3
  362. package/dist/index.d.ts.map +1 -1
  363. package/dist/index.js +3 -3
  364. package/dist/index.js.map +1 -1
  365. package/dist/modes/interactive/components/custom-editor.d.ts +1 -0
  366. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  367. package/dist/modes/interactive/components/custom-editor.js +9 -2
  368. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  369. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  370. package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
  371. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  372. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  373. package/dist/modes/interactive/components/settings-selector-items.js +7 -0
  374. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  375. package/dist/modes/interactive/components/settings-selector-types.d.ts +2 -0
  376. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  377. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  378. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  379. package/dist/modes/interactive/components/tree-selector-content.js +0 -5
  380. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  381. package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -1
  382. package/dist/modes/interactive/interactive-auth-login.js +1 -0
  383. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  384. package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
  385. package/dist/modes/interactive/interactive-autocomplete.js +80 -2
  386. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  387. package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
  388. package/dist/modes/interactive/interactive-hotkeys-debug.js +3 -0
  389. package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
  390. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  391. package/dist/modes/interactive/interactive-input-handling.js +51 -0
  392. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  393. package/dist/modes/interactive/interactive-mode-base.d.ts +5 -0
  394. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  395. package/dist/modes/interactive/interactive-mode-base.js +5 -0
  396. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  397. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  398. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  399. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  400. package/dist/modes/interactive/interactive-mode-surface.d.ts +12 -0
  401. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  402. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  403. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  404. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  405. package/dist/modes/interactive/interactive-mode.js +1 -0
  406. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  407. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  408. package/dist/modes/interactive/interactive-model-routing.js +4 -1
  409. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  410. package/dist/modes/interactive/interactive-onboarding.d.ts +11 -0
  411. package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -0
  412. package/dist/modes/interactive/interactive-onboarding.js +220 -0
  413. package/dist/modes/interactive/interactive-onboarding.js.map +1 -0
  414. package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
  415. package/dist/modes/interactive/interactive-selectors.js +4 -0
  416. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  417. package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
  418. package/dist/modes/interactive/interactive-session-routing.js +6 -0
  419. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  420. package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -1
  421. package/dist/modes/interactive/interactive-slash-commands.js +9 -4
  422. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  423. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  424. package/dist/modes/interactive/interactive-startup.js +28 -0
  425. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  426. package/dist/utils/child-process.d.ts.map +1 -1
  427. package/dist/utils/child-process.js +21 -1
  428. package/dist/utils/child-process.js.map +1 -1
  429. package/dist/utils/markit.d.ts +8 -0
  430. package/dist/utils/markit.d.ts.map +1 -0
  431. package/dist/utils/markit.js +53 -0
  432. package/dist/utils/markit.js.map +1 -0
  433. package/dist/utils/paths.d.ts +2 -1
  434. package/dist/utils/paths.d.ts.map +1 -1
  435. package/dist/utils/paths.js +14 -1
  436. package/dist/utils/paths.js.map +1 -1
  437. package/docs/compaction.md +16 -1
  438. package/docs/containerization.md +1 -1
  439. package/docs/docs.json +1 -0
  440. package/docs/extensions.md +25 -36
  441. package/docs/quickstart.md +11 -6
  442. package/docs/sdk.md +5 -5
  443. package/docs/settings.md +7 -0
  444. package/docs/subagents.md +3 -2
  445. package/docs/tools.md +49 -0
  446. package/docs/usage.md +3 -3
  447. package/docs/workflows.md +7 -5
  448. package/examples/extensions/subagent/README.md +5 -5
  449. package/examples/extensions/subagent/agents/planner.md +1 -1
  450. package/examples/extensions/subagent/agents/reviewer.md +1 -1
  451. package/examples/extensions/subagent/agents/scout.md +2 -2
  452. package/examples/extensions/subagent/display.ts +3 -3
  453. package/examples/sdk/05-tools.ts +3 -3
  454. package/examples/sdk/README.md +1 -1
  455. package/package.json +3 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/input.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA+EjF,UAAU,UAAU;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACb;AA+CD;;;;GAIG;AACH,wBAAgB,sCAAsC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAK7E;AAyED;;;;;GAKG;AACH,qBAAa,YAAY;;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAGtB,YAAY,GAAG,EAAE,UAAU,EAI1B;IAED;;;;OAIG;IACH,KAAK,IAAI;QAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAGtD;IAED,qCAAqC;IACrC,IAAI,KAAK,IAAI,SAAS,IAAI,EAAE,CAE3B;IAED,uDAAuD;IACvD,IAAI,QAAQ,IAAI,SAAS,MAAM,EAAE,CAEhC;IAED;;;;OAIG;IACH,IAAI,mBAAmB,IAAI,OAAO,CAOjC;IAED,+EAA+E;IAC/E,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAgBtC;IAED;;;;;;;;;OASG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,aAAa,GAAG,WAAW,CAchE;IAED;;;;;;;;;;OAUG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,aAAa,GAAG,WAAW,CAYvE;CACD;AAED;;;;;;GAMG;AACH,qBAAa,KAAK;IACjB,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IAE3C,OAAO,eAEN;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,KAAK,CAG7D;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,YAAY,CAK1E;CACD","sourcesContent":["// @generated vendored verbatim from oh-my-pi packages/hashline @ 15b5c1397fc -- DO NOT EDIT.\n// Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).\n/**\n * Top-level patch parser. Splits an authored hashline input into a list of\n * {@link PatchSection}s, each rooted at a `[PATH#HASH]` header, then exposes\n * a {@link Patch} class that gives lazy access to the parsed edits per\n * section.\n *\n * The splitter is purely lexical — it doesn't know whether a section's path\n * actually exists. That's the patcher's job.\n */\nimport * as path from \"node:path\";\nimport { applyEdits } from \"./apply.js\";\nimport { resolveBlockEdits } from \"./block.js\";\nimport { HL_FILE_HASH_EXAMPLES, HL_FILE_HASH_LENGTH, HL_FILE_HASH_SEP, HL_FILE_PREFIX, HL_FILE_SUFFIX } from \"./format.js\";\nimport { parsePatch, parsePatchStreaming } from \"./parser.js\";\nimport { Tokenizer } from \"./tokenizer.js\";\nimport type { ApplyResult, BlockResolver, Edit, SplitOptions } from \"./types.js\";\n\n// Pure classification — single shared tokenizer is safe.\nconst TOKENIZER = new Tokenizer();\n\nfunction unquoteHashlinePath(pathText: string): string {\n\tif (pathText.length < 2) return pathText;\n\tconst first = pathText[0];\n\tconst last = pathText[pathText.length - 1];\n\tif ((first === '\"' || first === \"'\") && first === last) return pathText.slice(1, -1);\n\treturn pathText;\n}\n\n/**\n * Strip apply_patch-style noise that models reflexively prepend to the\n * path. Examples observed in benchmark traces:\n *\n * `Update File:foo.ts`, `Update:foo.ts`, `UpdateFile:foo.ts`,\n * `Update/File:foo.ts`, `Update-file:foo.ts`, `Update(File):foo.ts`,\n * `Update<File:foo.ts`, `Add File:foo.ts`, `Delete File:foo.ts`,\n * `Move to:foo.ts`, `***foo.ts`, `***Update File:foo.ts`.\n *\n * We strip a leading `***` (the model duplicating the header sigil) and a\n * leading `(Update|Add|Delete|Move)[<separator>]*(File|to)?[<separator>]*:`\n * keyword block, case-insensitive. The remaining text is the real path.\n */\nconst APPLY_PATCH_PATH_NOISE_RE =\n\t/^\\*{0,3}\\s*(?:(?:update|add|delete|move)[^A-Za-z0-9]*(?:file|to)?[^A-Za-z0-9]*:)?\\s*\\*{0,3}\\s*/i;\n\nfunction stripApplyPatchPathNoise(pathText: string): string {\n\treturn pathText.replace(APPLY_PATCH_PATH_NOISE_RE, \"\");\n}\n\n/**\n * Best-effort recovery for bracketed header lines the strict tokenizer\n * rejects. Strips apply_patch keyword noise (`Update File:`, `Update:`,\n * etc.) and an extra leading `***` (some models emit a hybrid\n * `[***foo.ts#HASH]` shape), then expects `PATH(#HASH)?`.\n * Returns `null` when no clean path can be salvaged.\n */\nfunction tryParseRecoveryHeader(line: string, cwd?: string): RawSection | null {\n\tif (!line.startsWith(HL_FILE_PREFIX) || !line.endsWith(HL_FILE_SUFFIX)) return null;\n\tconst body = stripApplyPatchPathNoise(line.slice(HL_FILE_PREFIX.length, line.length - HL_FILE_SUFFIX.length).trim());\n\tif (body.length === 0) return null;\n\n\t// Trailing `#XXXX` is the tag; everything before it is the path. The\n\t// path may contain whitespace (Windows OneDrive folders, Program Files,\n\t// etc.), so we anchor the tag at end-of-body rather than scanning\n\t// forward and stopping at the first space.\n\tconst trailing = new RegExp(`#([0-9A-Fa-f]{${HL_FILE_HASH_LENGTH}})\\\\s*$`).exec(body);\n\tlet pathText: string;\n\tlet fileHash: string | undefined;\n\tif (trailing !== null) {\n\t\tpathText = body.slice(0, trailing.index);\n\t\tfileHash = trailing[1].toUpperCase();\n\t} else {\n\t\tpathText = body.replace(/\\s+$/, \"\");\n\t}\n\n\t// Same rule as the strict tokenizer: the hashline header grammar uses\n\t// `#` as the path/tag separator and does not allow `#` inside\n\t// filenames. Anything `#` left in the path body — short tags, non-hex\n\t// tags, over-long tags, stale-tag copy-paste, line-suffixed tags —\n\t// means the header is malformed, not a path with an embedded hash.\n\tif (pathText.includes(\"#\")) return null;\n\n\tconst path = normalizeHashlinePath(pathText, cwd);\n\tif (path.length === 0) return null;\n\treturn fileHash !== undefined ? { path, fileHash, diff: \"\" } : { path, diff: \"\" };\n}\n\nfunction normalizeHashlinePath(rawPath: string, cwd?: string): string {\n\tconst unquoted = stripApplyPatchPathNoise(unquoteHashlinePath(rawPath.trim()));\n\tif (!cwd || !path.isAbsolute(unquoted)) return unquoted;\n\tconst relative = path.relative(path.resolve(cwd), path.resolve(unquoted));\n\tconst isWithinCwd = relative === \"\" || (!relative.startsWith(\"..\") && !path.isAbsolute(relative));\n\treturn isWithinCwd ? relative || \".\" : unquoted;\n}\n\ninterface RawSection {\n\tpath: string;\n\tfileHash?: string;\n\tdiff: string;\n}\n\n/**\n * Parse a `[PATH]` or `[PATH#hash]` header line. Returns `null` for lines that do\n * not start with `[`. Throws the strict \"Input header must be …\" error\n * when a bracketed line fails the strict shape (so malformed paths\n * surface immediately instead of being silently re-classified as payload).\n */\nfunction parseHashlineHeaderLine(line: string, cwd?: string): RawSection | null {\n\tconst trimmed = line.trimEnd();\n\tif (!trimmed.startsWith(HL_FILE_PREFIX)) return null;\n\n\tconst token = TOKENIZER.tokenize(trimmed);\n\tif (token.kind !== \"header\") {\n\t\t// Recovery: try to extract a path from the raw line after stripping\n\t\t// apply_patch noise. This handles `[*** Update File:foo.ts#CB5A]` and\n\t\t// the half-dozen variants models actually emit.\n\t\tconst recovered = tryParseRecoveryHeader(trimmed, cwd);\n\t\tif (recovered !== null) return recovered;\n\t\tthrow new Error(\n\t\t\t`Input header must be ${HL_FILE_PREFIX}PATH${HL_FILE_SUFFIX} or ${HL_FILE_PREFIX}PATH${HL_FILE_HASH_SEP}TAG${HL_FILE_SUFFIX} with a ${HL_FILE_HASH_LENGTH}-hex content-hash tag; got ${JSON.stringify(trimmed)}.`,\n\t\t);\n\t}\n\n\tconst parsedPath = normalizeHashlinePath(token.path, cwd);\n\tif (parsedPath.length === 0) {\n\t\tthrow new Error(`Input header \"${HL_FILE_PREFIX}${HL_FILE_SUFFIX}\" is empty; provide a file path.`);\n\t}\n\treturn token.fileHash !== undefined\n\t\t? { path: parsedPath, fileHash: token.fileHash, diff: \"\" }\n\t\t: { path: parsedPath, diff: \"\" };\n}\n\nfunction stripLeadingBlankLines(input: string): string {\n\tconst stripped = input.startsWith(\"\\uFEFF\") ? input.slice(1) : input;\n\tconst lines = stripped.split(\"\\n\");\n\twhile (lines.length > 0) {\n\t\tconst head = lines[0].replace(/\\r$/, \"\");\n\t\tif (head.trim().length === 0 || TOKENIZER.tokenize(head).kind === \"envelope-begin\") {\n\t\t\tlines.shift();\n\t\t\tcontinue;\n\t\t}\n\t\tbreak;\n\t}\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Returns true when the input contains at least one line that the tokenizer\n * recognizes as a hashline op. Used by streaming previews to decide whether\n * the partial input is worth treating as a hashline patch yet.\n */\nexport function containsRecognizableHashlineOperations(input: string): boolean {\n\tfor (const line of input.split(/\\r?\\n/)) {\n\t\tif (TOKENIZER.isOp(line)) return true;\n\t}\n\treturn false;\n}\n\nfunction normalizeFallbackInput(input: string, options: SplitOptions): string {\n\tconst stripped = input.startsWith(\"\\uFEFF\") ? input.slice(1) : input;\n\tconst hasExplicitHeader = stripped\n\t\t.split(/\\r?\\n/)\n\t\t.some(rawLine => parseHashlineHeaderLine(rawLine, options.cwd) !== null);\n\tif (hasExplicitHeader) return input;\n\n\tif (!options.path || !containsRecognizableHashlineOperations(input)) return input;\n\tconst fallbackPath = normalizeHashlinePath(options.path, options.cwd);\n\tif (fallbackPath.length === 0) return input;\n\treturn `${HL_FILE_PREFIX}${fallbackPath}${HL_FILE_SUFFIX}\\n${input}`;\n}\n\nfunction splitRawSections(input: string, options: SplitOptions = {}): RawSection[] {\n\tconst stripped = stripLeadingBlankLines(normalizeFallbackInput(input, options));\n\tconst lines = stripped.split(/\\r?\\n/);\n\tconst firstLine = lines[0] ?? \"\";\n\n\tif (parseHashlineHeaderLine(firstLine, options.cwd) === null) {\n\t\t// Catch unified-diff hunk-header contamination on the first line so\n\t\t// the model sees a focused error.\n\t\tconst firstTrimmed = firstLine.trimEnd();\n\t\tif (/^@@\\s+[-+]?\\d+,\\d+\\s+[-+]?\\d+,\\d+\\s+@@/.test(firstTrimmed)) {\n\t\t\tthrow new Error(\n\t\t\t\t\"unified-diff hunk header (`@@ -N,M +N,M @@`) is not valid in hashline. \" +\n\t\t\t\t\t`File sections start with \\`${HL_FILE_PREFIX}path${HL_FILE_HASH_SEP}HASH${HL_FILE_SUFFIX}\\`; use \\`replace\\`, \\`delete\\`, or \\`insert\\` ops.`,\n\t\t\t);\n\t\t}\n\t\tconst preview = JSON.stringify(firstLine.slice(0, 120));\n\t\tthrow new Error(\n\t\t\t`input must begin with \"${HL_FILE_PREFIX}PATH${HL_FILE_HASH_SEP}HASH${HL_FILE_SUFFIX}\" on the first non-blank line for anchored edits; got: ${preview}. ` +\n\t\t\t\t`Example: \"${HL_FILE_PREFIX}src/foo.ts${HL_FILE_HASH_SEP}${HL_FILE_HASH_EXAMPLES[0]}${HL_FILE_SUFFIX}\" then edit ops.`,\n\t\t);\n\t}\n\n\tconst sections: RawSection[] = [];\n\tlet current: RawSection | undefined;\n\tlet currentLines: string[] = [];\n\n\tconst flush = () => {\n\t\tif (!current) return;\n\t\tconst hasOps = currentLines.some(line => line.trim().length > 0);\n\t\tif (hasOps) sections.push({ ...current, diff: currentLines.join(\"\\n\") });\n\t\tcurrentLines = [];\n\t};\n\n\tfor (const line of lines) {\n\t\tconst trimmed = line.trimEnd();\n\t\tconst token = TOKENIZER.tokenize(line);\n\t\tif (token.kind === \"envelope-end\" || token.kind === \"abort\") break;\n\t\tif (token.kind === \"envelope-begin\") continue;\n\n\t\t// Route every bracket-prefixed line through parseHashlineHeaderLine so\n\t\t// malformed headers still raise the strict \"Input header must be …\"\n\t\t// diagnostic (the tokenizer alone would silently classify them as\n\t\t// payload).\n\t\tif (trimmed.startsWith(HL_FILE_PREFIX)) {\n\t\t\tconst header = parseHashlineHeaderLine(line, options.cwd);\n\t\t\tif (header !== null) {\n\t\t\t\tflush();\n\t\t\t\tcurrent = header;\n\t\t\t\tcurrentLines = [];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tcurrentLines.push(line);\n\t}\n\tflush();\n\treturn sections;\n}\n\n/**\n * Snapshot of one section in a parsed {@link Patch}: a target file plus the\n * lazily-parsed list of edits that should land on it. Constructed by\n * {@link Patch.parse}; consumers usually iterate `patch.sections` rather\n * than build these directly.\n */\nexport class PatchSection {\n\treadonly path: string;\n\treadonly fileHash: string | undefined;\n\treadonly diff: string;\n\t#parsed: { edits: Edit[]; warnings: string[] } | undefined;\n\n\tconstructor(raw: RawSection) {\n\t\tthis.path = raw.path;\n\t\tthis.fileHash = raw.fileHash;\n\t\tthis.diff = raw.diff;\n\t}\n\n\t/**\n\t * Parse this section's diff body. Cached: subsequent calls return the\n\t * same `{ edits, warnings }` object so callers can safely call this from\n\t * multiple paths (preflight, apply, diff-preview).\n\t */\n\tparse(): { edits: Edit[]; warnings: readonly string[] } {\n\t\tthis.#parsed ??= parsePatch(this.diff);\n\t\treturn this.#parsed;\n\t}\n\n\t/** Parsed edits for this section. */\n\tget edits(): readonly Edit[] {\n\t\treturn this.parse().edits;\n\t}\n\n\t/** Warnings emitted during parsing of this section. */\n\tget warnings(): readonly string[] {\n\t\treturn this.parse().warnings;\n\t}\n\n\t/**\n\t * True when at least one edit anchors to concrete file content. Pure\n\t * `insert head:` / `insert tail:` literal inserts do not count: those are\n\t * safe to apply to files that don't yet exist.\n\t */\n\tget hasAnchorScopedEdit(): boolean {\n\t\treturn this.edits.some(edit => {\n\t\t\tif (edit.kind === \"delete\") return true;\n\t\t\t// A `replace block N:` edit is anchored to concrete content on line N.\n\t\t\tif (edit.kind === \"block\") return true;\n\t\t\treturn edit.cursor.kind === \"before_anchor\" || edit.cursor.kind === \"after_anchor\";\n\t\t});\n\t}\n\n\t/** Anchor lines touched by this section, sorted ascending and deduplicated. */\n\tcollectAnchorLines(): readonly number[] {\n\t\tconst lines = new Set<number>();\n\t\tfor (const edit of this.edits) {\n\t\t\tif (edit.kind === \"delete\") {\n\t\t\t\tlines.add(edit.anchor.line);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (edit.kind === \"block\") {\n\t\t\t\tlines.add(edit.anchor.line);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (edit.cursor.kind === \"before_anchor\" || edit.cursor.kind === \"after_anchor\") {\n\t\t\t\tlines.add(edit.cursor.anchor.line);\n\t\t\t}\n\t\t}\n\t\treturn [...lines].sort((a, b) => a - b);\n\t}\n\n\t/**\n\t * Apply this section's edits to `text` and return the post-edit result.\n\t * Pure: does no I/O, does not validate the section snapshot tag. The\n\t * {@link Patcher} owns tag validation and recovery; reach for this\n\t * method directly when you've already validated the file content and\n\t * just want the result.\n\t *\n\t * `blockResolver` resolves any `replace block N:` edits against `text`; an\n\t * unresolvable block throws (this is the final, authoritative preview path).\n\t */\n\tapplyTo(text: string, blockResolver?: BlockResolver): ApplyResult {\n\t\tconst { edits, warnings } = this.parse();\n\t\tconst resolveWarnings: string[] = [];\n\t\tconst resolved = resolveBlockEdits(edits, text, this.path, blockResolver, {\n\t\t\tonUnresolved: \"throw\",\n\t\t\tonWarning: warning => resolveWarnings.push(warning),\n\t\t});\n\t\tconst result = applyEdits(text, resolved);\n\t\t// Preserve parse warnings so consumers don't need to call `parse()`\n\t\t// separately.\n\t\tconst merged = [...warnings, ...resolveWarnings, ...(result.warnings ?? [])];\n\t\treturn merged.length > 0\n\t\t\t? { ...result, warnings: merged }\n\t\t\t: { text: result.text, firstChangedLine: result.firstChangedLine };\n\t}\n\n\t/**\n\t * Streaming-tolerant counterpart to {@link applyTo}. Uses\n\t * {@link parsePatchStreaming} so a trailing in-flight op (no payload yet,\n\t * or a per-token parse error mid-stream) does not throw or emit a phantom\n\t * empty-payload edit. Intended for incremental diff previews; the writer\n\t * path should always use {@link applyTo}.\n\t *\n\t * `blockResolver` resolves any `replace block N:` edits against `text`; an\n\t * unresolvable block is silently dropped so a half-written file does not\n\t * throw mid-stream.\n\t */\n\tapplyPartialTo(text: string, blockResolver?: BlockResolver): ApplyResult {\n\t\tconst { edits, warnings } = parsePatchStreaming(this.diff);\n\t\tconst resolveWarnings: string[] = [];\n\t\tconst resolved = resolveBlockEdits(edits, text, this.path, blockResolver, {\n\t\t\tonUnresolved: \"drop\",\n\t\t\tonWarning: warning => resolveWarnings.push(warning),\n\t\t});\n\t\tconst result = applyEdits(text, resolved);\n\t\tconst merged = [...warnings, ...resolveWarnings, ...(result.warnings ?? [])];\n\t\treturn merged.length > 0\n\t\t\t? { ...result, warnings: merged }\n\t\t\t: { text: result.text, firstChangedLine: result.firstChangedLine };\n\t}\n}\n\n/**\n * A parsed hashline patch — zero or more {@link PatchSection}s, each rooted\n * at a `[PATH#HASH]` header. Construct via {@link Patch.parse}.\n *\n * `Patch` is pure data: parsing is line-anchored and does not look at the\n * filesystem. To apply a patch, hand it to {@link Patcher.apply}.\n */\nexport class Patch {\n\treadonly sections: readonly PatchSection[];\n\n\tprivate constructor(sections: PatchSection[]) {\n\t\tthis.sections = sections;\n\t}\n\n\t/**\n\t * Parse `input` into a {@link Patch}. `options.cwd` resolves absolute\n\t * paths inside headers to cwd-relative form; `options.path` provides a\n\t * fallback when the input lacks a header but contains hashline ops\n\t * (useful for streaming previews).\n\t *\n\t * Consecutive sections targeting the same path are merged into a single\n\t * section with concatenated diff bodies. Anchors authored against the\n\t * same file snapshot must be applied as one batch; otherwise the first\n\t * sub-edit shifts line numbers out from under the second's anchors and\n\t * validation fails.\n\t */\n\tstatic parse(input: string, options: SplitOptions = {}): Patch {\n\t\tconst raw = mergeSamePathSections(splitRawSections(input, options));\n\t\treturn new Patch(raw.map(section => new PatchSection(section)));\n\t}\n\n\t/**\n\t * Parse `input` and return only the first section. Throws if the input\n\t * has zero sections. Convenience for the single-section case where the\n\t * caller already knows the patch is one hunk.\n\t */\n\tstatic parseSingle(input: string, options: SplitOptions = {}): PatchSection {\n\t\tconst patch = Patch.parse(input, options);\n\t\tconst first = patch.sections[0];\n\t\tif (!first) throw new Error(\"Patch input did not produce any sections.\");\n\t\treturn first;\n\t}\n}\n\n/**\n * Collapse consecutive or interleaved sections targeting the same path into a\n * single section with concatenated diffs. Anchors authored against the same\n * file snapshot must be applied as one batch; otherwise the first sub-edit\n * shifts line numbers out from under the second's anchors and validation\n * fails. Path order is preserved by first occurrence.\n */\nfunction mergeSamePathSections(sections: RawSection[]): RawSection[] {\n\tconst byPath = new Map<string, { fileHash?: string; diffs: string[] }>();\n\tfor (const section of sections) {\n\t\tconst existing = byPath.get(section.path);\n\t\tif (existing) {\n\t\t\tif (\n\t\t\t\texisting.fileHash !== undefined &&\n\t\t\t\tsection.fileHash !== undefined &&\n\t\t\t\texisting.fileHash !== section.fileHash\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Conflicting hashline snapshot tags for ${section.path}: #${existing.fileHash} and #${section.fileHash}. Re-read the file and retry with one current header.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (existing.fileHash === undefined && section.fileHash !== undefined) existing.fileHash = section.fileHash;\n\t\t\texisting.diffs.push(section.diff);\n\t\t\tcontinue;\n\t\t}\n\t\tbyPath.set(section.path, {\n\t\t\t...(section.fileHash !== undefined ? { fileHash: section.fileHash } : {}),\n\t\t\tdiffs: [section.diff],\n\t\t});\n\t}\n\treturn Array.from(byPath, ([sectionPath, entry]) => ({\n\t\tpath: sectionPath,\n\t\t...(entry.fileHash !== undefined ? { fileHash: entry.fileHash } : {}),\n\t\tdiff: entry.diffs.join(\"\\n\"),\n\t}));\n}\n"]}
@@ -0,0 +1,398 @@
1
+ // @generated vendored verbatim from oh-my-pi packages/hashline @ 15b5c1397fc -- DO NOT EDIT.
2
+ // Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).
3
+ /**
4
+ * Top-level patch parser. Splits an authored hashline input into a list of
5
+ * {@link PatchSection}s, each rooted at a `[PATH#HASH]` header, then exposes
6
+ * a {@link Patch} class that gives lazy access to the parsed edits per
7
+ * section.
8
+ *
9
+ * The splitter is purely lexical — it doesn't know whether a section's path
10
+ * actually exists. That's the patcher's job.
11
+ */
12
+ import * as path from "node:path";
13
+ import { applyEdits } from "./apply.js";
14
+ import { resolveBlockEdits } from "./block.js";
15
+ import { HL_FILE_HASH_EXAMPLES, HL_FILE_HASH_LENGTH, HL_FILE_HASH_SEP, HL_FILE_PREFIX, HL_FILE_SUFFIX } from "./format.js";
16
+ import { parsePatch, parsePatchStreaming } from "./parser.js";
17
+ import { Tokenizer } from "./tokenizer.js";
18
+ // Pure classification — single shared tokenizer is safe.
19
+ const TOKENIZER = new Tokenizer();
20
+ function unquoteHashlinePath(pathText) {
21
+ if (pathText.length < 2)
22
+ return pathText;
23
+ const first = pathText[0];
24
+ const last = pathText[pathText.length - 1];
25
+ if ((first === '"' || first === "'") && first === last)
26
+ return pathText.slice(1, -1);
27
+ return pathText;
28
+ }
29
+ /**
30
+ * Strip apply_patch-style noise that models reflexively prepend to the
31
+ * path. Examples observed in benchmark traces:
32
+ *
33
+ * `Update File:foo.ts`, `Update:foo.ts`, `UpdateFile:foo.ts`,
34
+ * `Update/File:foo.ts`, `Update-file:foo.ts`, `Update(File):foo.ts`,
35
+ * `Update<File:foo.ts`, `Add File:foo.ts`, `Delete File:foo.ts`,
36
+ * `Move to:foo.ts`, `***foo.ts`, `***Update File:foo.ts`.
37
+ *
38
+ * We strip a leading `***` (the model duplicating the header sigil) and a
39
+ * leading `(Update|Add|Delete|Move)[<separator>]*(File|to)?[<separator>]*:`
40
+ * keyword block, case-insensitive. The remaining text is the real path.
41
+ */
42
+ const APPLY_PATCH_PATH_NOISE_RE = /^\*{0,3}\s*(?:(?:update|add|delete|move)[^A-Za-z0-9]*(?:file|to)?[^A-Za-z0-9]*:)?\s*\*{0,3}\s*/i;
43
+ function stripApplyPatchPathNoise(pathText) {
44
+ return pathText.replace(APPLY_PATCH_PATH_NOISE_RE, "");
45
+ }
46
+ /**
47
+ * Best-effort recovery for bracketed header lines the strict tokenizer
48
+ * rejects. Strips apply_patch keyword noise (`Update File:`, `Update:`,
49
+ * etc.) and an extra leading `***` (some models emit a hybrid
50
+ * `[***foo.ts#HASH]` shape), then expects `PATH(#HASH)?`.
51
+ * Returns `null` when no clean path can be salvaged.
52
+ */
53
+ function tryParseRecoveryHeader(line, cwd) {
54
+ if (!line.startsWith(HL_FILE_PREFIX) || !line.endsWith(HL_FILE_SUFFIX))
55
+ return null;
56
+ const body = stripApplyPatchPathNoise(line.slice(HL_FILE_PREFIX.length, line.length - HL_FILE_SUFFIX.length).trim());
57
+ if (body.length === 0)
58
+ return null;
59
+ // Trailing `#XXXX` is the tag; everything before it is the path. The
60
+ // path may contain whitespace (Windows OneDrive folders, Program Files,
61
+ // etc.), so we anchor the tag at end-of-body rather than scanning
62
+ // forward and stopping at the first space.
63
+ const trailing = new RegExp(`#([0-9A-Fa-f]{${HL_FILE_HASH_LENGTH}})\\s*$`).exec(body);
64
+ let pathText;
65
+ let fileHash;
66
+ if (trailing !== null) {
67
+ pathText = body.slice(0, trailing.index);
68
+ fileHash = trailing[1].toUpperCase();
69
+ }
70
+ else {
71
+ pathText = body.replace(/\s+$/, "");
72
+ }
73
+ // Same rule as the strict tokenizer: the hashline header grammar uses
74
+ // `#` as the path/tag separator and does not allow `#` inside
75
+ // filenames. Anything `#` left in the path body — short tags, non-hex
76
+ // tags, over-long tags, stale-tag copy-paste, line-suffixed tags —
77
+ // means the header is malformed, not a path with an embedded hash.
78
+ if (pathText.includes("#"))
79
+ return null;
80
+ const path = normalizeHashlinePath(pathText, cwd);
81
+ if (path.length === 0)
82
+ return null;
83
+ return fileHash !== undefined ? { path, fileHash, diff: "" } : { path, diff: "" };
84
+ }
85
+ function normalizeHashlinePath(rawPath, cwd) {
86
+ const unquoted = stripApplyPatchPathNoise(unquoteHashlinePath(rawPath.trim()));
87
+ if (!cwd || !path.isAbsolute(unquoted))
88
+ return unquoted;
89
+ const relative = path.relative(path.resolve(cwd), path.resolve(unquoted));
90
+ const isWithinCwd = relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
91
+ return isWithinCwd ? relative || "." : unquoted;
92
+ }
93
+ /**
94
+ * Parse a `[PATH]` or `[PATH#hash]` header line. Returns `null` for lines that do
95
+ * not start with `[`. Throws the strict "Input header must be …" error
96
+ * when a bracketed line fails the strict shape (so malformed paths
97
+ * surface immediately instead of being silently re-classified as payload).
98
+ */
99
+ function parseHashlineHeaderLine(line, cwd) {
100
+ const trimmed = line.trimEnd();
101
+ if (!trimmed.startsWith(HL_FILE_PREFIX))
102
+ return null;
103
+ const token = TOKENIZER.tokenize(trimmed);
104
+ if (token.kind !== "header") {
105
+ // Recovery: try to extract a path from the raw line after stripping
106
+ // apply_patch noise. This handles `[*** Update File:foo.ts#CB5A]` and
107
+ // the half-dozen variants models actually emit.
108
+ const recovered = tryParseRecoveryHeader(trimmed, cwd);
109
+ if (recovered !== null)
110
+ return recovered;
111
+ throw new Error(`Input header must be ${HL_FILE_PREFIX}PATH${HL_FILE_SUFFIX} or ${HL_FILE_PREFIX}PATH${HL_FILE_HASH_SEP}TAG${HL_FILE_SUFFIX} with a ${HL_FILE_HASH_LENGTH}-hex content-hash tag; got ${JSON.stringify(trimmed)}.`);
112
+ }
113
+ const parsedPath = normalizeHashlinePath(token.path, cwd);
114
+ if (parsedPath.length === 0) {
115
+ throw new Error(`Input header "${HL_FILE_PREFIX}${HL_FILE_SUFFIX}" is empty; provide a file path.`);
116
+ }
117
+ return token.fileHash !== undefined
118
+ ? { path: parsedPath, fileHash: token.fileHash, diff: "" }
119
+ : { path: parsedPath, diff: "" };
120
+ }
121
+ function stripLeadingBlankLines(input) {
122
+ const stripped = input.startsWith("\uFEFF") ? input.slice(1) : input;
123
+ const lines = stripped.split("\n");
124
+ while (lines.length > 0) {
125
+ const head = lines[0].replace(/\r$/, "");
126
+ if (head.trim().length === 0 || TOKENIZER.tokenize(head).kind === "envelope-begin") {
127
+ lines.shift();
128
+ continue;
129
+ }
130
+ break;
131
+ }
132
+ return lines.join("\n");
133
+ }
134
+ /**
135
+ * Returns true when the input contains at least one line that the tokenizer
136
+ * recognizes as a hashline op. Used by streaming previews to decide whether
137
+ * the partial input is worth treating as a hashline patch yet.
138
+ */
139
+ export function containsRecognizableHashlineOperations(input) {
140
+ for (const line of input.split(/\r?\n/)) {
141
+ if (TOKENIZER.isOp(line))
142
+ return true;
143
+ }
144
+ return false;
145
+ }
146
+ function normalizeFallbackInput(input, options) {
147
+ const stripped = input.startsWith("\uFEFF") ? input.slice(1) : input;
148
+ const hasExplicitHeader = stripped
149
+ .split(/\r?\n/)
150
+ .some(rawLine => parseHashlineHeaderLine(rawLine, options.cwd) !== null);
151
+ if (hasExplicitHeader)
152
+ return input;
153
+ if (!options.path || !containsRecognizableHashlineOperations(input))
154
+ return input;
155
+ const fallbackPath = normalizeHashlinePath(options.path, options.cwd);
156
+ if (fallbackPath.length === 0)
157
+ return input;
158
+ return `${HL_FILE_PREFIX}${fallbackPath}${HL_FILE_SUFFIX}\n${input}`;
159
+ }
160
+ function splitRawSections(input, options = {}) {
161
+ const stripped = stripLeadingBlankLines(normalizeFallbackInput(input, options));
162
+ const lines = stripped.split(/\r?\n/);
163
+ const firstLine = lines[0] ?? "";
164
+ if (parseHashlineHeaderLine(firstLine, options.cwd) === null) {
165
+ // Catch unified-diff hunk-header contamination on the first line so
166
+ // the model sees a focused error.
167
+ const firstTrimmed = firstLine.trimEnd();
168
+ if (/^@@\s+[-+]?\d+,\d+\s+[-+]?\d+,\d+\s+@@/.test(firstTrimmed)) {
169
+ throw new Error("unified-diff hunk header (`@@ -N,M +N,M @@`) is not valid in hashline. " +
170
+ `File sections start with \`${HL_FILE_PREFIX}path${HL_FILE_HASH_SEP}HASH${HL_FILE_SUFFIX}\`; use \`replace\`, \`delete\`, or \`insert\` ops.`);
171
+ }
172
+ const preview = JSON.stringify(firstLine.slice(0, 120));
173
+ throw new Error(`input must begin with "${HL_FILE_PREFIX}PATH${HL_FILE_HASH_SEP}HASH${HL_FILE_SUFFIX}" on the first non-blank line for anchored edits; got: ${preview}. ` +
174
+ `Example: "${HL_FILE_PREFIX}src/foo.ts${HL_FILE_HASH_SEP}${HL_FILE_HASH_EXAMPLES[0]}${HL_FILE_SUFFIX}" then edit ops.`);
175
+ }
176
+ const sections = [];
177
+ let current;
178
+ let currentLines = [];
179
+ const flush = () => {
180
+ if (!current)
181
+ return;
182
+ const hasOps = currentLines.some(line => line.trim().length > 0);
183
+ if (hasOps)
184
+ sections.push({ ...current, diff: currentLines.join("\n") });
185
+ currentLines = [];
186
+ };
187
+ for (const line of lines) {
188
+ const trimmed = line.trimEnd();
189
+ const token = TOKENIZER.tokenize(line);
190
+ if (token.kind === "envelope-end" || token.kind === "abort")
191
+ break;
192
+ if (token.kind === "envelope-begin")
193
+ continue;
194
+ // Route every bracket-prefixed line through parseHashlineHeaderLine so
195
+ // malformed headers still raise the strict "Input header must be …"
196
+ // diagnostic (the tokenizer alone would silently classify them as
197
+ // payload).
198
+ if (trimmed.startsWith(HL_FILE_PREFIX)) {
199
+ const header = parseHashlineHeaderLine(line, options.cwd);
200
+ if (header !== null) {
201
+ flush();
202
+ current = header;
203
+ currentLines = [];
204
+ continue;
205
+ }
206
+ }
207
+ currentLines.push(line);
208
+ }
209
+ flush();
210
+ return sections;
211
+ }
212
+ /**
213
+ * Snapshot of one section in a parsed {@link Patch}: a target file plus the
214
+ * lazily-parsed list of edits that should land on it. Constructed by
215
+ * {@link Patch.parse}; consumers usually iterate `patch.sections` rather
216
+ * than build these directly.
217
+ */
218
+ export class PatchSection {
219
+ #parsed;
220
+ constructor(raw) {
221
+ this.path = raw.path;
222
+ this.fileHash = raw.fileHash;
223
+ this.diff = raw.diff;
224
+ }
225
+ /**
226
+ * Parse this section's diff body. Cached: subsequent calls return the
227
+ * same `{ edits, warnings }` object so callers can safely call this from
228
+ * multiple paths (preflight, apply, diff-preview).
229
+ */
230
+ parse() {
231
+ this.#parsed ??= parsePatch(this.diff);
232
+ return this.#parsed;
233
+ }
234
+ /** Parsed edits for this section. */
235
+ get edits() {
236
+ return this.parse().edits;
237
+ }
238
+ /** Warnings emitted during parsing of this section. */
239
+ get warnings() {
240
+ return this.parse().warnings;
241
+ }
242
+ /**
243
+ * True when at least one edit anchors to concrete file content. Pure
244
+ * `insert head:` / `insert tail:` literal inserts do not count: those are
245
+ * safe to apply to files that don't yet exist.
246
+ */
247
+ get hasAnchorScopedEdit() {
248
+ return this.edits.some(edit => {
249
+ if (edit.kind === "delete")
250
+ return true;
251
+ // A `replace block N:` edit is anchored to concrete content on line N.
252
+ if (edit.kind === "block")
253
+ return true;
254
+ return edit.cursor.kind === "before_anchor" || edit.cursor.kind === "after_anchor";
255
+ });
256
+ }
257
+ /** Anchor lines touched by this section, sorted ascending and deduplicated. */
258
+ collectAnchorLines() {
259
+ const lines = new Set();
260
+ for (const edit of this.edits) {
261
+ if (edit.kind === "delete") {
262
+ lines.add(edit.anchor.line);
263
+ continue;
264
+ }
265
+ if (edit.kind === "block") {
266
+ lines.add(edit.anchor.line);
267
+ continue;
268
+ }
269
+ if (edit.cursor.kind === "before_anchor" || edit.cursor.kind === "after_anchor") {
270
+ lines.add(edit.cursor.anchor.line);
271
+ }
272
+ }
273
+ return [...lines].sort((a, b) => a - b);
274
+ }
275
+ /**
276
+ * Apply this section's edits to `text` and return the post-edit result.
277
+ * Pure: does no I/O, does not validate the section snapshot tag. The
278
+ * {@link Patcher} owns tag validation and recovery; reach for this
279
+ * method directly when you've already validated the file content and
280
+ * just want the result.
281
+ *
282
+ * `blockResolver` resolves any `replace block N:` edits against `text`; an
283
+ * unresolvable block throws (this is the final, authoritative preview path).
284
+ */
285
+ applyTo(text, blockResolver) {
286
+ const { edits, warnings } = this.parse();
287
+ const resolveWarnings = [];
288
+ const resolved = resolveBlockEdits(edits, text, this.path, blockResolver, {
289
+ onUnresolved: "throw",
290
+ onWarning: warning => resolveWarnings.push(warning),
291
+ });
292
+ const result = applyEdits(text, resolved);
293
+ // Preserve parse warnings so consumers don't need to call `parse()`
294
+ // separately.
295
+ const merged = [...warnings, ...resolveWarnings, ...(result.warnings ?? [])];
296
+ return merged.length > 0
297
+ ? { ...result, warnings: merged }
298
+ : { text: result.text, firstChangedLine: result.firstChangedLine };
299
+ }
300
+ /**
301
+ * Streaming-tolerant counterpart to {@link applyTo}. Uses
302
+ * {@link parsePatchStreaming} so a trailing in-flight op (no payload yet,
303
+ * or a per-token parse error mid-stream) does not throw or emit a phantom
304
+ * empty-payload edit. Intended for incremental diff previews; the writer
305
+ * path should always use {@link applyTo}.
306
+ *
307
+ * `blockResolver` resolves any `replace block N:` edits against `text`; an
308
+ * unresolvable block is silently dropped so a half-written file does not
309
+ * throw mid-stream.
310
+ */
311
+ applyPartialTo(text, blockResolver) {
312
+ const { edits, warnings } = parsePatchStreaming(this.diff);
313
+ const resolveWarnings = [];
314
+ const resolved = resolveBlockEdits(edits, text, this.path, blockResolver, {
315
+ onUnresolved: "drop",
316
+ onWarning: warning => resolveWarnings.push(warning),
317
+ });
318
+ const result = applyEdits(text, resolved);
319
+ const merged = [...warnings, ...resolveWarnings, ...(result.warnings ?? [])];
320
+ return merged.length > 0
321
+ ? { ...result, warnings: merged }
322
+ : { text: result.text, firstChangedLine: result.firstChangedLine };
323
+ }
324
+ }
325
+ /**
326
+ * A parsed hashline patch — zero or more {@link PatchSection}s, each rooted
327
+ * at a `[PATH#HASH]` header. Construct via {@link Patch.parse}.
328
+ *
329
+ * `Patch` is pure data: parsing is line-anchored and does not look at the
330
+ * filesystem. To apply a patch, hand it to {@link Patcher.apply}.
331
+ */
332
+ export class Patch {
333
+ constructor(sections) {
334
+ this.sections = sections;
335
+ }
336
+ /**
337
+ * Parse `input` into a {@link Patch}. `options.cwd` resolves absolute
338
+ * paths inside headers to cwd-relative form; `options.path` provides a
339
+ * fallback when the input lacks a header but contains hashline ops
340
+ * (useful for streaming previews).
341
+ *
342
+ * Consecutive sections targeting the same path are merged into a single
343
+ * section with concatenated diff bodies. Anchors authored against the
344
+ * same file snapshot must be applied as one batch; otherwise the first
345
+ * sub-edit shifts line numbers out from under the second's anchors and
346
+ * validation fails.
347
+ */
348
+ static parse(input, options = {}) {
349
+ const raw = mergeSamePathSections(splitRawSections(input, options));
350
+ return new Patch(raw.map(section => new PatchSection(section)));
351
+ }
352
+ /**
353
+ * Parse `input` and return only the first section. Throws if the input
354
+ * has zero sections. Convenience for the single-section case where the
355
+ * caller already knows the patch is one hunk.
356
+ */
357
+ static parseSingle(input, options = {}) {
358
+ const patch = Patch.parse(input, options);
359
+ const first = patch.sections[0];
360
+ if (!first)
361
+ throw new Error("Patch input did not produce any sections.");
362
+ return first;
363
+ }
364
+ }
365
+ /**
366
+ * Collapse consecutive or interleaved sections targeting the same path into a
367
+ * single section with concatenated diffs. Anchors authored against the same
368
+ * file snapshot must be applied as one batch; otherwise the first sub-edit
369
+ * shifts line numbers out from under the second's anchors and validation
370
+ * fails. Path order is preserved by first occurrence.
371
+ */
372
+ function mergeSamePathSections(sections) {
373
+ const byPath = new Map();
374
+ for (const section of sections) {
375
+ const existing = byPath.get(section.path);
376
+ if (existing) {
377
+ if (existing.fileHash !== undefined &&
378
+ section.fileHash !== undefined &&
379
+ existing.fileHash !== section.fileHash) {
380
+ throw new Error(`Conflicting hashline snapshot tags for ${section.path}: #${existing.fileHash} and #${section.fileHash}. Re-read the file and retry with one current header.`);
381
+ }
382
+ if (existing.fileHash === undefined && section.fileHash !== undefined)
383
+ existing.fileHash = section.fileHash;
384
+ existing.diffs.push(section.diff);
385
+ continue;
386
+ }
387
+ byPath.set(section.path, {
388
+ ...(section.fileHash !== undefined ? { fileHash: section.fileHash } : {}),
389
+ diffs: [section.diff],
390
+ });
391
+ }
392
+ return Array.from(byPath, ([sectionPath, entry]) => ({
393
+ path: sectionPath,
394
+ ...(entry.fileHash !== undefined ? { fileHash: entry.fileHash } : {}),
395
+ diff: entry.diffs.join("\n"),
396
+ }));
397
+ }
398
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/input.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,iLAAiL;AACjL;;;;;;;;GAQG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3H,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,SAAS,EAA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5c1397fc -- DO NOT EDIT.\n// Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).\n/**\n * Top-level patch parser. Splits an authored hashline input into a list of\n * {@link PatchSection}s, each rooted at a `[PATH#HASH]` header, then exposes\n * a {@link Patch} class that gives lazy access to the parsed edits per\n * section.\n *\n * The splitter is purely lexical — it doesn't know whether a section's path\n * actually exists. That's the patcher's job.\n */\nimport * as path from \"node:path\";\nimport { applyEdits } from \"./apply.js\";\nimport { resolveBlockEdits } from \"./block.js\";\nimport { HL_FILE_HASH_EXAMPLES, HL_FILE_HASH_LENGTH, HL_FILE_HASH_SEP, HL_FILE_PREFIX, HL_FILE_SUFFIX } from \"./format.js\";\nimport { parsePatch, parsePatchStreaming } from \"./parser.js\";\nimport { Tokenizer } from \"./tokenizer.js\";\nimport type { ApplyResult, BlockResolver, Edit, SplitOptions } from \"./types.js\";\n\n// Pure classification — single shared tokenizer is safe.\nconst TOKENIZER = new Tokenizer();\n\nfunction unquoteHashlinePath(pathText: string): string {\n\tif (pathText.length < 2) return pathText;\n\tconst first = pathText[0];\n\tconst last = pathText[pathText.length - 1];\n\tif ((first === '\"' || first === \"'\") && first === last) return pathText.slice(1, -1);\n\treturn pathText;\n}\n\n/**\n * Strip apply_patch-style noise that models reflexively prepend to the\n * path. Examples observed in benchmark traces:\n *\n * `Update File:foo.ts`, `Update:foo.ts`, `UpdateFile:foo.ts`,\n * `Update/File:foo.ts`, `Update-file:foo.ts`, `Update(File):foo.ts`,\n * `Update<File:foo.ts`, `Add File:foo.ts`, `Delete File:foo.ts`,\n * `Move to:foo.ts`, `***foo.ts`, `***Update File:foo.ts`.\n *\n * We strip a leading `***` (the model duplicating the header sigil) and a\n * leading `(Update|Add|Delete|Move)[<separator>]*(File|to)?[<separator>]*:`\n * keyword block, case-insensitive. The remaining text is the real path.\n */\nconst APPLY_PATCH_PATH_NOISE_RE =\n\t/^\\*{0,3}\\s*(?:(?:update|add|delete|move)[^A-Za-z0-9]*(?:file|to)?[^A-Za-z0-9]*:)?\\s*\\*{0,3}\\s*/i;\n\nfunction stripApplyPatchPathNoise(pathText: string): string {\n\treturn pathText.replace(APPLY_PATCH_PATH_NOISE_RE, \"\");\n}\n\n/**\n * Best-effort recovery for bracketed header lines the strict tokenizer\n * rejects. Strips apply_patch keyword noise (`Update File:`, `Update:`,\n * etc.) and an extra leading `***` (some models emit a hybrid\n * `[***foo.ts#HASH]` shape), then expects `PATH(#HASH)?`.\n * Returns `null` when no clean path can be salvaged.\n */\nfunction tryParseRecoveryHeader(line: string, cwd?: string): RawSection | null {\n\tif (!line.startsWith(HL_FILE_PREFIX) || !line.endsWith(HL_FILE_SUFFIX)) return null;\n\tconst body = stripApplyPatchPathNoise(line.slice(HL_FILE_PREFIX.length, line.length - HL_FILE_SUFFIX.length).trim());\n\tif (body.length === 0) return null;\n\n\t// Trailing `#XXXX` is the tag; everything before it is the path. The\n\t// path may contain whitespace (Windows OneDrive folders, Program Files,\n\t// etc.), so we anchor the tag at end-of-body rather than scanning\n\t// forward and stopping at the first space.\n\tconst trailing = new RegExp(`#([0-9A-Fa-f]{${HL_FILE_HASH_LENGTH}})\\\\s*$`).exec(body);\n\tlet pathText: string;\n\tlet fileHash: string | undefined;\n\tif (trailing !== null) {\n\t\tpathText = body.slice(0, trailing.index);\n\t\tfileHash = trailing[1].toUpperCase();\n\t} else {\n\t\tpathText = body.replace(/\\s+$/, \"\");\n\t}\n\n\t// Same rule as the strict tokenizer: the hashline header grammar uses\n\t// `#` as the path/tag separator and does not allow `#` inside\n\t// filenames. Anything `#` left in the path body — short tags, non-hex\n\t// tags, over-long tags, stale-tag copy-paste, line-suffixed tags —\n\t// means the header is malformed, not a path with an embedded hash.\n\tif (pathText.includes(\"#\")) return null;\n\n\tconst path = normalizeHashlinePath(pathText, cwd);\n\tif (path.length === 0) return null;\n\treturn fileHash !== undefined ? { path, fileHash, diff: \"\" } : { path, diff: \"\" };\n}\n\nfunction normalizeHashlinePath(rawPath: string, cwd?: string): string {\n\tconst unquoted = stripApplyPatchPathNoise(unquoteHashlinePath(rawPath.trim()));\n\tif (!cwd || !path.isAbsolute(unquoted)) return unquoted;\n\tconst relative = path.relative(path.resolve(cwd), path.resolve(unquoted));\n\tconst isWithinCwd = relative === \"\" || (!relative.startsWith(\"..\") && !path.isAbsolute(relative));\n\treturn isWithinCwd ? relative || \".\" : unquoted;\n}\n\ninterface RawSection {\n\tpath: string;\n\tfileHash?: string;\n\tdiff: string;\n}\n\n/**\n * Parse a `[PATH]` or `[PATH#hash]` header line. Returns `null` for lines that do\n * not start with `[`. Throws the strict \"Input header must be …\" error\n * when a bracketed line fails the strict shape (so malformed paths\n * surface immediately instead of being silently re-classified as payload).\n */\nfunction parseHashlineHeaderLine(line: string, cwd?: string): RawSection | null {\n\tconst trimmed = line.trimEnd();\n\tif (!trimmed.startsWith(HL_FILE_PREFIX)) return null;\n\n\tconst token = TOKENIZER.tokenize(trimmed);\n\tif (token.kind !== \"header\") {\n\t\t// Recovery: try to extract a path from the raw line after stripping\n\t\t// apply_patch noise. This handles `[*** Update File:foo.ts#CB5A]` and\n\t\t// the half-dozen variants models actually emit.\n\t\tconst recovered = tryParseRecoveryHeader(trimmed, cwd);\n\t\tif (recovered !== null) return recovered;\n\t\tthrow new Error(\n\t\t\t`Input header must be ${HL_FILE_PREFIX}PATH${HL_FILE_SUFFIX} or ${HL_FILE_PREFIX}PATH${HL_FILE_HASH_SEP}TAG${HL_FILE_SUFFIX} with a ${HL_FILE_HASH_LENGTH}-hex content-hash tag; got ${JSON.stringify(trimmed)}.`,\n\t\t);\n\t}\n\n\tconst parsedPath = normalizeHashlinePath(token.path, cwd);\n\tif (parsedPath.length === 0) {\n\t\tthrow new Error(`Input header \"${HL_FILE_PREFIX}${HL_FILE_SUFFIX}\" is empty; provide a file path.`);\n\t}\n\treturn token.fileHash !== undefined\n\t\t? { path: parsedPath, fileHash: token.fileHash, diff: \"\" }\n\t\t: { path: parsedPath, diff: \"\" };\n}\n\nfunction stripLeadingBlankLines(input: string): string {\n\tconst stripped = input.startsWith(\"\\uFEFF\") ? input.slice(1) : input;\n\tconst lines = stripped.split(\"\\n\");\n\twhile (lines.length > 0) {\n\t\tconst head = lines[0].replace(/\\r$/, \"\");\n\t\tif (head.trim().length === 0 || TOKENIZER.tokenize(head).kind === \"envelope-begin\") {\n\t\t\tlines.shift();\n\t\t\tcontinue;\n\t\t}\n\t\tbreak;\n\t}\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Returns true when the input contains at least one line that the tokenizer\n * recognizes as a hashline op. Used by streaming previews to decide whether\n * the partial input is worth treating as a hashline patch yet.\n */\nexport function containsRecognizableHashlineOperations(input: string): boolean {\n\tfor (const line of input.split(/\\r?\\n/)) {\n\t\tif (TOKENIZER.isOp(line)) return true;\n\t}\n\treturn false;\n}\n\nfunction normalizeFallbackInput(input: string, options: SplitOptions): string {\n\tconst stripped = input.startsWith(\"\\uFEFF\") ? input.slice(1) : input;\n\tconst hasExplicitHeader = stripped\n\t\t.split(/\\r?\\n/)\n\t\t.some(rawLine => parseHashlineHeaderLine(rawLine, options.cwd) !== null);\n\tif (hasExplicitHeader) return input;\n\n\tif (!options.path || !containsRecognizableHashlineOperations(input)) return input;\n\tconst fallbackPath = normalizeHashlinePath(options.path, options.cwd);\n\tif (fallbackPath.length === 0) return input;\n\treturn `${HL_FILE_PREFIX}${fallbackPath}${HL_FILE_SUFFIX}\\n${input}`;\n}\n\nfunction splitRawSections(input: string, options: SplitOptions = {}): RawSection[] {\n\tconst stripped = stripLeadingBlankLines(normalizeFallbackInput(input, options));\n\tconst lines = stripped.split(/\\r?\\n/);\n\tconst firstLine = lines[0] ?? \"\";\n\n\tif (parseHashlineHeaderLine(firstLine, options.cwd) === null) {\n\t\t// Catch unified-diff hunk-header contamination on the first line so\n\t\t// the model sees a focused error.\n\t\tconst firstTrimmed = firstLine.trimEnd();\n\t\tif (/^@@\\s+[-+]?\\d+,\\d+\\s+[-+]?\\d+,\\d+\\s+@@/.test(firstTrimmed)) {\n\t\t\tthrow new Error(\n\t\t\t\t\"unified-diff hunk header (`@@ -N,M +N,M @@`) is not valid in hashline. \" +\n\t\t\t\t\t`File sections start with \\`${HL_FILE_PREFIX}path${HL_FILE_HASH_SEP}HASH${HL_FILE_SUFFIX}\\`; use \\`replace\\`, \\`delete\\`, or \\`insert\\` ops.`,\n\t\t\t);\n\t\t}\n\t\tconst preview = JSON.stringify(firstLine.slice(0, 120));\n\t\tthrow new Error(\n\t\t\t`input must begin with \"${HL_FILE_PREFIX}PATH${HL_FILE_HASH_SEP}HASH${HL_FILE_SUFFIX}\" on the first non-blank line for anchored edits; got: ${preview}. ` +\n\t\t\t\t`Example: \"${HL_FILE_PREFIX}src/foo.ts${HL_FILE_HASH_SEP}${HL_FILE_HASH_EXAMPLES[0]}${HL_FILE_SUFFIX}\" then edit ops.`,\n\t\t);\n\t}\n\n\tconst sections: RawSection[] = [];\n\tlet current: RawSection | undefined;\n\tlet currentLines: string[] = [];\n\n\tconst flush = () => {\n\t\tif (!current) return;\n\t\tconst hasOps = currentLines.some(line => line.trim().length > 0);\n\t\tif (hasOps) sections.push({ ...current, diff: currentLines.join(\"\\n\") });\n\t\tcurrentLines = [];\n\t};\n\n\tfor (const line of lines) {\n\t\tconst trimmed = line.trimEnd();\n\t\tconst token = TOKENIZER.tokenize(line);\n\t\tif (token.kind === \"envelope-end\" || token.kind === \"abort\") break;\n\t\tif (token.kind === \"envelope-begin\") continue;\n\n\t\t// Route every bracket-prefixed line through parseHashlineHeaderLine so\n\t\t// malformed headers still raise the strict \"Input header must be …\"\n\t\t// diagnostic (the tokenizer alone would silently classify them as\n\t\t// payload).\n\t\tif (trimmed.startsWith(HL_FILE_PREFIX)) {\n\t\t\tconst header = parseHashlineHeaderLine(line, options.cwd);\n\t\t\tif (header !== null) {\n\t\t\t\tflush();\n\t\t\t\tcurrent = header;\n\t\t\t\tcurrentLines = [];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tcurrentLines.push(line);\n\t}\n\tflush();\n\treturn sections;\n}\n\n/**\n * Snapshot of one section in a parsed {@link Patch}: a target file plus the\n * lazily-parsed list of edits that should land on it. Constructed by\n * {@link Patch.parse}; consumers usually iterate `patch.sections` rather\n * than build these directly.\n */\nexport class PatchSection {\n\treadonly path: string;\n\treadonly fileHash: string | undefined;\n\treadonly diff: string;\n\t#parsed: { edits: Edit[]; warnings: string[] } | undefined;\n\n\tconstructor(raw: RawSection) {\n\t\tthis.path = raw.path;\n\t\tthis.fileHash = raw.fileHash;\n\t\tthis.diff = raw.diff;\n\t}\n\n\t/**\n\t * Parse this section's diff body. Cached: subsequent calls return the\n\t * same `{ edits, warnings }` object so callers can safely call this from\n\t * multiple paths (preflight, apply, diff-preview).\n\t */\n\tparse(): { edits: Edit[]; warnings: readonly string[] } {\n\t\tthis.#parsed ??= parsePatch(this.diff);\n\t\treturn this.#parsed;\n\t}\n\n\t/** Parsed edits for this section. */\n\tget edits(): readonly Edit[] {\n\t\treturn this.parse().edits;\n\t}\n\n\t/** Warnings emitted during parsing of this section. */\n\tget warnings(): readonly string[] {\n\t\treturn this.parse().warnings;\n\t}\n\n\t/**\n\t * True when at least one edit anchors to concrete file content. Pure\n\t * `insert head:` / `insert tail:` literal inserts do not count: those are\n\t * safe to apply to files that don't yet exist.\n\t */\n\tget hasAnchorScopedEdit(): boolean {\n\t\treturn this.edits.some(edit => {\n\t\t\tif (edit.kind === \"delete\") return true;\n\t\t\t// A `replace block N:` edit is anchored to concrete content on line N.\n\t\t\tif (edit.kind === \"block\") return true;\n\t\t\treturn edit.cursor.kind === \"before_anchor\" || edit.cursor.kind === \"after_anchor\";\n\t\t});\n\t}\n\n\t/** Anchor lines touched by this section, sorted ascending and deduplicated. */\n\tcollectAnchorLines(): readonly number[] {\n\t\tconst lines = new Set<number>();\n\t\tfor (const edit of this.edits) {\n\t\t\tif (edit.kind === \"delete\") {\n\t\t\t\tlines.add(edit.anchor.line);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (edit.kind === \"block\") {\n\t\t\t\tlines.add(edit.anchor.line);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (edit.cursor.kind === \"before_anchor\" || edit.cursor.kind === \"after_anchor\") {\n\t\t\t\tlines.add(edit.cursor.anchor.line);\n\t\t\t}\n\t\t}\n\t\treturn [...lines].sort((a, b) => a - b);\n\t}\n\n\t/**\n\t * Apply this section's edits to `text` and return the post-edit result.\n\t * Pure: does no I/O, does not validate the section snapshot tag. The\n\t * {@link Patcher} owns tag validation and recovery; reach for this\n\t * method directly when you've already validated the file content and\n\t * just want the result.\n\t *\n\t * `blockResolver` resolves any `replace block N:` edits against `text`; an\n\t * unresolvable block throws (this is the final, authoritative preview path).\n\t */\n\tapplyTo(text: string, blockResolver?: BlockResolver): ApplyResult {\n\t\tconst { edits, warnings } = this.parse();\n\t\tconst resolveWarnings: string[] = [];\n\t\tconst resolved = resolveBlockEdits(edits, text, this.path, blockResolver, {\n\t\t\tonUnresolved: \"throw\",\n\t\t\tonWarning: warning => resolveWarnings.push(warning),\n\t\t});\n\t\tconst result = applyEdits(text, resolved);\n\t\t// Preserve parse warnings so consumers don't need to call `parse()`\n\t\t// separately.\n\t\tconst merged = [...warnings, ...resolveWarnings, ...(result.warnings ?? [])];\n\t\treturn merged.length > 0\n\t\t\t? { ...result, warnings: merged }\n\t\t\t: { text: result.text, firstChangedLine: result.firstChangedLine };\n\t}\n\n\t/**\n\t * Streaming-tolerant counterpart to {@link applyTo}. Uses\n\t * {@link parsePatchStreaming} so a trailing in-flight op (no payload yet,\n\t * or a per-token parse error mid-stream) does not throw or emit a phantom\n\t * empty-payload edit. Intended for incremental diff previews; the writer\n\t * path should always use {@link applyTo}.\n\t *\n\t * `blockResolver` resolves any `replace block N:` edits against `text`; an\n\t * unresolvable block is silently dropped so a half-written file does not\n\t * throw mid-stream.\n\t */\n\tapplyPartialTo(text: string, blockResolver?: BlockResolver): ApplyResult {\n\t\tconst { edits, warnings } = parsePatchStreaming(this.diff);\n\t\tconst resolveWarnings: string[] = [];\n\t\tconst resolved = resolveBlockEdits(edits, text, this.path, blockResolver, {\n\t\t\tonUnresolved: \"drop\",\n\t\t\tonWarning: warning => resolveWarnings.push(warning),\n\t\t});\n\t\tconst result = applyEdits(text, resolved);\n\t\tconst merged = [...warnings, ...resolveWarnings, ...(result.warnings ?? [])];\n\t\treturn merged.length > 0\n\t\t\t? { ...result, warnings: merged }\n\t\t\t: { text: result.text, firstChangedLine: result.firstChangedLine };\n\t}\n}\n\n/**\n * A parsed hashline patch — zero or more {@link PatchSection}s, each rooted\n * at a `[PATH#HASH]` header. Construct via {@link Patch.parse}.\n *\n * `Patch` is pure data: parsing is line-anchored and does not look at the\n * filesystem. To apply a patch, hand it to {@link Patcher.apply}.\n */\nexport class Patch {\n\treadonly sections: readonly PatchSection[];\n\n\tprivate constructor(sections: PatchSection[]) {\n\t\tthis.sections = sections;\n\t}\n\n\t/**\n\t * Parse `input` into a {@link Patch}. `options.cwd` resolves absolute\n\t * paths inside headers to cwd-relative form; `options.path` provides a\n\t * fallback when the input lacks a header but contains hashline ops\n\t * (useful for streaming previews).\n\t *\n\t * Consecutive sections targeting the same path are merged into a single\n\t * section with concatenated diff bodies. Anchors authored against the\n\t * same file snapshot must be applied as one batch; otherwise the first\n\t * sub-edit shifts line numbers out from under the second's anchors and\n\t * validation fails.\n\t */\n\tstatic parse(input: string, options: SplitOptions = {}): Patch {\n\t\tconst raw = mergeSamePathSections(splitRawSections(input, options));\n\t\treturn new Patch(raw.map(section => new PatchSection(section)));\n\t}\n\n\t/**\n\t * Parse `input` and return only the first section. Throws if the input\n\t * has zero sections. Convenience for the single-section case where the\n\t * caller already knows the patch is one hunk.\n\t */\n\tstatic parseSingle(input: string, options: SplitOptions = {}): PatchSection {\n\t\tconst patch = Patch.parse(input, options);\n\t\tconst first = patch.sections[0];\n\t\tif (!first) throw new Error(\"Patch input did not produce any sections.\");\n\t\treturn first;\n\t}\n}\n\n/**\n * Collapse consecutive or interleaved sections targeting the same path into a\n * single section with concatenated diffs. Anchors authored against the same\n * file snapshot must be applied as one batch; otherwise the first sub-edit\n * shifts line numbers out from under the second's anchors and validation\n * fails. Path order is preserved by first occurrence.\n */\nfunction mergeSamePathSections(sections: RawSection[]): RawSection[] {\n\tconst byPath = new Map<string, { fileHash?: string; diffs: string[] }>();\n\tfor (const section of sections) {\n\t\tconst existing = byPath.get(section.path);\n\t\tif (existing) {\n\t\t\tif (\n\t\t\t\texisting.fileHash !== undefined &&\n\t\t\t\tsection.fileHash !== undefined &&\n\t\t\t\texisting.fileHash !== section.fileHash\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Conflicting hashline snapshot tags for ${section.path}: #${existing.fileHash} and #${section.fileHash}. Re-read the file and retry with one current header.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (existing.fileHash === undefined && section.fileHash !== undefined) existing.fileHash = section.fileHash;\n\t\t\texisting.diffs.push(section.diff);\n\t\t\tcontinue;\n\t\t}\n\t\tbyPath.set(section.path, {\n\t\t\t...(section.fileHash !== undefined ? { fileHash: section.fileHash } : {}),\n\t\t\tdiffs: [section.diff],\n\t\t});\n\t}\n\treturn Array.from(byPath, ([sectionPath, entry]) => ({\n\t\tpath: sectionPath,\n\t\t...(entry.fileHash !== undefined ? { fileHash: entry.fileHash } : {}),\n\t\tdiff: entry.diffs.join(\"\\n\"),\n\t}));\n}\n"]}
@@ -0,0 +1,99 @@
1
+ /** Centralized error/warning text for the hashline parser, applier, and patcher. */
2
+ /** Lines of context shown either side of a hash mismatch. */
3
+ export declare const MISMATCH_CONTEXT = 2;
4
+ /**
5
+ * Numbered `LINE:TEXT` rows around `anchorLines` (±{@link MISMATCH_CONTEXT}),
6
+ * `*`-marking anchors, `...` between non-adjacent runs. Out-of-range anchors
7
+ * contribute no rows.
8
+ */
9
+ export declare function formatAnchoredContext(anchorLines: readonly number[], fileLines: readonly string[]): string[];
10
+ /** Optional patch envelope start marker; silently consumed. */
11
+ export declare const BEGIN_PATCH_MARKER = "*** Begin Patch";
12
+ /** Optional patch envelope end marker; terminates parsing. */
13
+ export declare const END_PATCH_MARKER = "*** End Patch";
14
+ /**
15
+ * Truncation sentinel emitted by an agent loop mid-call. Ends parsing like
16
+ * {@link END_PATCH_MARKER}, without a warning.
17
+ */
18
+ export declare const ABORT_MARKER = "*** Abort";
19
+ /** Two consecutive hunks targeted the exact same concrete range. */
20
+ export declare const REPLACE_PAIR_COALESCED_WARNING = "Two hunks targeted the same range; kept only the second. One `replace N..M:` hunk per range \u2014 the body is the final content, never old+new.";
21
+ /** Bare bodyless hunk followed by an overlapping concrete hunk. */
22
+ export declare const REPLACE_PAIR_COALESCED_OVERLAP_WARNING = "Dropped a bare hunk overlapped by the concrete hunk after it. One `replace N..M:` hunk per range \u2014 the body is the final content, never old+new.";
23
+ /** Bare body rows auto-converted to literal `+` rows. */
24
+ export declare const BARE_BODY_AUTO_PIPED_WARNING = "Auto-prefixed bare body row(s) with `+`. Body rows must be `+TEXT` literal lines.";
25
+ /** Unified-diff-style `-` row in a hunk body. */
26
+ export declare const MINUS_ROW_REJECTED = "`-` rows are not valid; the range already names the lines being changed. For a literal `-` line, write `+-\u2026`.";
27
+ /** Replace hunk with no body. */
28
+ export declare const EMPTY_REPLACE = "`replace N..M:` needs at least one `+TEXT` body row. To delete lines, use `delete N..M`.";
29
+ /** `replace block N:` hunk with no body. */
30
+ export declare const EMPTY_BLOCK = "`replace block N:` needs at least one `+TEXT` body row. To delete a block, use `delete block N`.";
31
+ /**
32
+ * Block-anchored replace/delete could not resolve to a syntactic block
33
+ * (unsupported language, blank/out-of-range line, no node beginning on N, or
34
+ * parse error). Appends a {@link formatAnchoredContext} preview when
35
+ * `fileLines` is given. `insert after block N:` never reaches this — it is
36
+ * lowered to plain `insert after N:` instead (see
37
+ * {@link insertAfterBlockUnresolvedLoweredWarning}).
38
+ */
39
+ export declare function blockUnresolvedMessage(line: number, op?: "replace" | "delete", fileLines?: readonly string[]): string;
40
+ /** Block-anchored edit reached a path with no {@link BlockResolver} wired in — a host-configuration bug. */
41
+ export declare const BLOCK_RESOLVER_UNAVAILABLE = "`replace block`/`delete block`/`insert after block` are not available here (no block resolver configured). Use a concrete line range.";
42
+ /**
43
+ * `insert after block N:` anchored on a closing-delimiter line, lowered to
44
+ * plain `insert after N:` — the closer ends a block, and inserting after it
45
+ * is exactly what the plain form does.
46
+ */
47
+ export declare function insertAfterBlockCloserLoweredWarning(line: number): string;
48
+ /**
49
+ * `insert after block N:` anchor unresolvable (unsupported language, blank
50
+ * line, parse error, or no resolver), lowered to plain `insert after N:` —
51
+ * applying with a warning beats failing the patch.
52
+ */
53
+ export declare function insertAfterBlockUnresolvedLoweredWarning(line: number): string;
54
+ /**
55
+ * Internal invariant: `applyEdits` received an unresolved `replace block N:`
56
+ * edit; `resolveBlockEdits` must run first. Wiring bug, not authored input.
57
+ */
58
+ export declare const UNRESOLVED_BLOCK_INTERNAL = "internal error: unresolved `replace block` edit reached the applier (resolveBlockEdits was not run).";
59
+ /** Delete hunk received a body row. */
60
+ export declare const DELETE_TAKES_NO_BODY = "`delete N..M` does not take body rows. Remove the body, or use `replace N..M:`.";
61
+ /** `delete block N` hunk received a body row. */
62
+ export declare const DELETE_BLOCK_TAKES_NO_BODY = "`delete block N` does not take body rows. Remove the body, or use `replace block N:`.";
63
+ /** Insert hunk with no body. */
64
+ export declare const EMPTY_INSERT = "`insert` needs at least one `+TEXT` body row.";
65
+ /**
66
+ * `insert after` body indented shallower than the anchor: the landing slid
67
+ * forward past trailing closer lines — the common "anchored on the last line
68
+ * I read instead of after the block" mistake.
69
+ */
70
+ export declare function afterInsertLandingShiftWarning(anchorLine: number, landingLine: number, crossed: number): string;
71
+ /**
72
+ * `insert after block N:` body indented deeper than the block's closer: the
73
+ * landing was pulled inside the block — a deeper body almost always means
74
+ * "append inside the block's body".
75
+ */
76
+ export declare function blockInsertLandingShiftWarning(blockStart: number, closerLine: number, landingLine: number): string;
77
+ /** `Recovery`: an external write matched a cached snapshot. */
78
+ export declare const RECOVERY_EXTERNAL_WARNING = "Recovered from a stale file hash using a previous read snapshot (file changed externally between read and edit).";
79
+ /** `Recovery`: a prior in-session edit advanced the hash. */
80
+ export declare const RECOVERY_SESSION_CHAIN_WARNING = "Recovered from a stale file hash using an earlier in-session snapshot (a prior edit in this session advanced the hash).";
81
+ /**
82
+ * `Recovery`: session-chain replay fast-path. Less certain than
83
+ * {@link RECOVERY_SESSION_CHAIN_WARNING} — the 3-way merge refused, the
84
+ * anchor-content gate passed, but a coincidental insert+delete earlier in
85
+ * the chain could still misplace an anchor — hence the verify hedge.
86
+ */
87
+ export declare const RECOVERY_SESSION_REPLAY_WARNING = "Recovered by replaying your edits onto the current file content (a prior in-session edit changed the lines you re-targeted with a stale hash). Verify the diff matches your intent.";
88
+ /**
89
+ * `insert head:`/`insert tail:` applied despite a stale snapshot tag.
90
+ * Head/tail position is content-independent, so drift is non-fatal: apply
91
+ * onto live content and warn instead of hard-failing.
92
+ */
93
+ export declare const HEADTAIL_DRIFT_WARNING = "Applied the `insert head:`/`insert tail:` edit despite a stale snapshot tag (file changed since your read) \u2014 head/tail position is content-independent. Re-read if the drift was unexpected.";
94
+ /**
95
+ * Section omitted the mandatory snapshot tag. Shared by the apply
96
+ * ({@link Patcher.prepare}) and preview/diff paths so both stay in lockstep.
97
+ */
98
+ export declare function missingSnapshotTagMessage(sectionPath: string): string;
99
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/messages.ts"],"names":[],"mappings":"AAEA,oFAAoF;AAIpF,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE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ED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAElH;AAED,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,qHAC6E,CAAC;AAEpH,6DAA6D;AAC7D,eAAO,MAAM,8BAA8B,4HAC+E,CAAC;AAE3H;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,wLAC0I,CAAC;AAEvL;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,sMAC4J,CAAC;AAEhM;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAErE","sourcesContent":["// @generated vendored verbatim from oh-my-pi packages/hashline @ 15b5c1397fc -- DO NOT EDIT.\n// Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).\n/** Centralized error/warning text for the hashline parser, applier, and patcher. */\n\nimport { formatNumberedLine, HL_FILE_HASH_SEP, HL_FILE_PREFIX, HL_FILE_SUFFIX } from \"./format.js\";\n\n/** Lines of context shown either side of a hash mismatch. */\nexport const MISMATCH_CONTEXT = 2;\n\n/**\n * Numbered `LINE:TEXT` rows around `anchorLines` (±{@link MISMATCH_CONTEXT}),\n * `*`-marking anchors, `...` between non-adjacent runs. Out-of-range anchors\n * contribute no rows.\n */\nexport function formatAnchoredContext(anchorLines: readonly number[], fileLines: readonly string[]): string[] {\n\tconst displayLines = new Set<number>();\n\tfor (const line of anchorLines) {\n\t\tif (line < 1 || line > fileLines.length) continue;\n\t\tconst lo = Math.max(1, line - MISMATCH_CONTEXT);\n\t\tconst hi = Math.min(fileLines.length, line + MISMATCH_CONTEXT);\n\t\tfor (let lineNum = lo; lineNum <= hi; lineNum++) displayLines.add(lineNum);\n\t}\n\tconst anchorSet = new Set(anchorLines);\n\tconst rows: string[] = [];\n\tlet previous = -1;\n\tfor (const lineNum of [...displayLines].sort((a, b) => a - b)) {\n\t\tif (previous !== -1 && lineNum > previous + 1) rows.push(\"...\");\n\t\tprevious = lineNum;\n\t\tconst marker = anchorSet.has(lineNum) ? \"*\" : \" \";\n\t\trows.push(`${marker}${formatNumberedLine(lineNum, fileLines[lineNum - 1] ?? \"\")}`);\n\t}\n\treturn rows;\n}\n\n/** Optional patch envelope start marker; silently consumed. */\nexport const BEGIN_PATCH_MARKER = \"*** Begin Patch\";\n\n/** Optional patch envelope end marker; terminates parsing. */\nexport const END_PATCH_MARKER = \"*** End Patch\";\n\n/**\n * Truncation sentinel emitted by an agent loop mid-call. Ends parsing like\n * {@link END_PATCH_MARKER}, without a warning.\n */\nexport const ABORT_MARKER = \"*** Abort\";\n\n/** Two consecutive hunks targeted the exact same concrete range. */\nexport const REPLACE_PAIR_COALESCED_WARNING =\n\t\"Two hunks targeted the same range; kept only the second. One `replace N..M:` hunk per range — the body is the final content, never old+new.\";\n\n/** Bare bodyless hunk followed by an overlapping concrete hunk. */\nexport const REPLACE_PAIR_COALESCED_OVERLAP_WARNING =\n\t\"Dropped a bare hunk overlapped by the concrete hunk after it. One `replace N..M:` hunk per range — the body is the final content, never old+new.\";\n\n/** Bare body rows auto-converted to literal `+` rows. */\nexport const BARE_BODY_AUTO_PIPED_WARNING =\n\t\"Auto-prefixed bare body row(s) with `+`. Body rows must be `+TEXT` literal lines.\";\n\n/** Unified-diff-style `-` row in a hunk body. */\nexport const MINUS_ROW_REJECTED =\n\t\"`-` rows are not valid; the range already names the lines being changed. For a literal `-` line, write `+-…`.\";\n\n/** Replace hunk with no body. */\nexport const EMPTY_REPLACE = \"`replace N..M:` needs at least one `+TEXT` body row. To delete lines, use `delete N..M`.\";\n\n/** `replace block N:` hunk with no body. */\nexport const EMPTY_BLOCK =\n\t\"`replace block N:` needs at least one `+TEXT` body row. To delete a block, use `delete block N`.\";\n\n/**\n * Block-anchored replace/delete could not resolve to a syntactic block\n * (unsupported language, blank/out-of-range line, no node beginning on N, or\n * parse error). Appends a {@link formatAnchoredContext} preview when\n * `fileLines` is given. `insert after block N:` never reaches this — it is\n * lowered to plain `insert after N:` instead (see\n * {@link insertAfterBlockUnresolvedLoweredWarning}).\n */\nexport function blockUnresolvedMessage(\n\tline: number,\n\top: \"replace\" | \"delete\" = \"replace\",\n\tfileLines?: readonly string[],\n): string {\n\tconst phrase = op === \"delete\" ? `delete block ${line}` : `replace block ${line}:`;\n\tconst fallback = op === \"delete\" ? `delete ${line}..M` : `replace ${line}..M:`;\n\tlet message =\n\t\t`\\`${phrase}\\` could not resolve a syntactic block beginning on line ${line} ` +\n\t\t`(unsupported language, blank/closer line, or parse error). Use \\`${fallback}\\` with explicit lines.`;\n\tif (fileLines) {\n\t\tconst context = formatAnchoredContext([line], fileLines);\n\t\tif (context.length > 0) message += `\\n\\n${context.join(\"\\n\")}`;\n\t}\n\treturn message;\n}\n\n/** Block-anchored edit reached a path with no {@link BlockResolver} wired in — a host-configuration bug. */\nexport const BLOCK_RESOLVER_UNAVAILABLE =\n\t\"`replace block`/`delete block`/`insert after block` are not available here (no block resolver configured). Use a concrete line range.\";\n\n/**\n * `insert after block N:` anchored on a closing-delimiter line, lowered to\n * plain `insert after N:` — the closer ends a block, and inserting after it\n * is exactly what the plain form does.\n */\nexport function insertAfterBlockCloserLoweredWarning(line: number): string {\n\treturn `\\`insert after block ${line}:\\` anchors on a closing delimiter, so it was applied as plain \\`insert after ${line}:\\`. Anchor on the line that OPENS the construct.`;\n}\n\n/**\n * `insert after block N:` anchor unresolvable (unsupported language, blank\n * line, parse error, or no resolver), lowered to plain `insert after N:` —\n * applying with a warning beats failing the patch.\n */\nexport function insertAfterBlockUnresolvedLoweredWarning(line: number): string {\n\treturn `\\`insert after block ${line}:\\` could not resolve a syntactic block on line ${line}, so it was applied as plain \\`insert after ${line}:\\`. Verify the landing line; anchor on a line that OPENS a construct.`;\n}\n\n/**\n * Internal invariant: `applyEdits` received an unresolved `replace block N:`\n * edit; `resolveBlockEdits` must run first. Wiring bug, not authored input.\n */\nexport const UNRESOLVED_BLOCK_INTERNAL =\n\t\"internal error: unresolved `replace block` edit reached the applier (resolveBlockEdits was not run).\";\n\n/** Delete hunk received a body row. */\nexport const DELETE_TAKES_NO_BODY = \"`delete N..M` does not take body rows. Remove the body, or use `replace N..M:`.\";\n\n/** `delete block N` hunk received a body row. */\nexport const DELETE_BLOCK_TAKES_NO_BODY =\n\t\"`delete block N` does not take body rows. Remove the body, or use `replace block N:`.\";\n\n/** Insert hunk with no body. */\nexport const EMPTY_INSERT = \"`insert` needs at least one `+TEXT` body row.\";\n\n/**\n * `insert after` body indented shallower than the anchor: the landing slid\n * forward past trailing closer lines — the common \"anchored on the last line\n * I read instead of after the block\" mistake.\n */\nexport function afterInsertLandingShiftWarning(anchorLine: number, landingLine: number, crossed: number): string {\n\treturn `insert after ${anchorLine}: body indented shallower than the anchor, so the landing moved past ${crossed} closing line${crossed === 1 ? \"\" : \"s\"} to after line ${landingLine}. For the deeper position inside the block, re-issue with the body indented to match.`;\n}\n\n/**\n * `insert after block N:` body indented deeper than the block's closer: the\n * landing was pulled inside the block — a deeper body almost always means\n * \"append inside the block's body\".\n */\nexport function blockInsertLandingShiftWarning(blockStart: number, closerLine: number, landingLine: number): string {\n\treturn `insert after block ${blockStart}: body indented deeper than closing line ${closerLine}, so it was placed inside the block, after line ${landingLine}. \\`insert after block\\` lands AFTER the block at sibling depth — if inside was intended, use plain \\`insert after ${closerLine}:\\`.`;\n}\n\n/** `Recovery`: an external write matched a cached snapshot. */\nexport const RECOVERY_EXTERNAL_WARNING =\n\t\"Recovered from a stale file hash using a previous read snapshot (file changed externally between read and edit).\";\n\n/** `Recovery`: a prior in-session edit advanced the hash. */\nexport const RECOVERY_SESSION_CHAIN_WARNING =\n\t\"Recovered from a stale file hash using an earlier in-session snapshot (a prior edit in this session advanced the hash).\";\n\n/**\n * `Recovery`: session-chain replay fast-path. Less certain than\n * {@link RECOVERY_SESSION_CHAIN_WARNING} — the 3-way merge refused, the\n * anchor-content gate passed, but a coincidental insert+delete earlier in\n * the chain could still misplace an anchor — hence the verify hedge.\n */\nexport const RECOVERY_SESSION_REPLAY_WARNING =\n\t\"Recovered by replaying your edits onto the current file content (a prior in-session edit changed the lines you re-targeted with a stale hash). Verify the diff matches your intent.\";\n\n/**\n * `insert head:`/`insert tail:` applied despite a stale snapshot tag.\n * Head/tail position is content-independent, so drift is non-fatal: apply\n * onto live content and warn instead of hard-failing.\n */\nexport const HEADTAIL_DRIFT_WARNING =\n\t\"Applied the `insert head:`/`insert tail:` edit despite a stale snapshot tag (file changed since your read) — head/tail position is content-independent. Re-read if the drift was unexpected.\";\n\n/**\n * Section omitted the mandatory snapshot tag. Shared by the apply\n * ({@link Patcher.prepare}) and preview/diff paths so both stay in lockstep.\n */\nexport function missingSnapshotTagMessage(sectionPath: string): string {\n\treturn `Missing hashline snapshot tag for ${sectionPath}; use \\`${HL_FILE_PREFIX}${sectionPath}${HL_FILE_HASH_SEP}tag${HL_FILE_SUFFIX}\\` from your latest read/search output. To create a new file, use the write tool.`;\n}\n"]}