@bastani/atomic 0.9.2 → 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 (452) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +2 -2
  3. package/dist/builtin/cursor/package.json +2 -2
  4. package/dist/builtin/intercom/package.json +1 -1
  5. package/dist/builtin/mcp/CHANGELOG.md +6 -0
  6. package/dist/builtin/mcp/direct-tools.ts +4 -2
  7. package/dist/builtin/mcp/package.json +1 -1
  8. package/dist/builtin/mcp/proxy-call.ts +3 -1
  9. package/dist/builtin/mcp/utils.ts +18 -7
  10. package/dist/builtin/subagents/CHANGELOG.md +11 -0
  11. package/dist/builtin/subagents/README.md +6 -6
  12. package/dist/builtin/subagents/agents/code-simplifier.md +7 -6
  13. package/dist/builtin/subagents/agents/codebase-analyzer.md +5 -4
  14. package/dist/builtin/subagents/agents/codebase-locator.md +3 -3
  15. package/dist/builtin/subagents/agents/codebase-online-researcher.md +10 -10
  16. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +4 -4
  17. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +3 -3
  18. package/dist/builtin/subagents/agents/codebase-research-locator.md +4 -4
  19. package/dist/builtin/subagents/agents/debugger.md +5 -5
  20. package/dist/builtin/subagents/agents/worker.md +56 -0
  21. package/dist/builtin/subagents/package.json +1 -1
  22. package/dist/builtin/subagents/skills/subagent/SKILL.md +11 -11
  23. package/dist/builtin/subagents/src/agents/agent-loaders.ts +3 -5
  24. package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +3 -3
  25. package/dist/builtin/subagents/src/extension/schemas.ts +2 -2
  26. package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -3
  27. package/dist/builtin/subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +1 -1
  28. package/dist/builtin/subagents/src/runs/shared/nested-render.ts +2 -2
  29. package/dist/builtin/subagents/src/runs/shared/pi-args.ts +2 -1
  30. package/dist/builtin/subagents/src/shared/types-depth.ts +5 -5
  31. package/dist/builtin/subagents/src/shared/types-runtime.ts +2 -1
  32. package/dist/builtin/subagents/src/tui/render-event-formatting.ts +2 -2
  33. package/dist/builtin/web-access/package.json +1 -1
  34. package/dist/builtin/workflows/CHANGELOG.md +13 -0
  35. package/dist/builtin/workflows/README.md +2 -2
  36. package/dist/builtin/workflows/builtin/goal-artifacts.ts +11 -6
  37. package/dist/builtin/workflows/builtin/goal-ledger.ts +33 -1
  38. package/dist/builtin/workflows/builtin/goal-prompts.ts +23 -28
  39. package/dist/builtin/workflows/builtin/goal-reducer.ts +2 -2
  40. package/dist/builtin/workflows/builtin/goal-reports.ts +2 -5
  41. package/dist/builtin/workflows/builtin/goal-review.ts +1 -1
  42. package/dist/builtin/workflows/builtin/goal-runner.ts +10 -17
  43. package/dist/builtin/workflows/builtin/open-claude-design-feedback.ts +3 -3
  44. package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +1 -3
  45. package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +1 -1
  46. package/dist/builtin/workflows/builtin/ralph-core.ts +7 -17
  47. package/dist/builtin/workflows/builtin/ralph-runner.ts +11 -18
  48. package/dist/builtin/workflows/builtin/shared-prompts.ts +1 -1
  49. package/dist/builtin/workflows/package.json +1 -1
  50. package/dist/builtin/workflows/src/extension/config-loader.ts +35 -15
  51. package/dist/builtin/workflows/src/extension/discovery.ts +20 -8
  52. package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +1 -2
  53. package/dist/builtin/workflows/src/extension/wiring.ts +1 -1
  54. package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +11 -10
  55. package/dist/cli/args.d.ts.map +1 -1
  56. package/dist/cli/args.js +9 -9
  57. package/dist/cli/args.js.map +1 -1
  58. package/dist/config-self-update.d.ts.map +1 -1
  59. package/dist/config-self-update.js +3 -4
  60. package/dist/config-self-update.js.map +1 -1
  61. package/dist/config.d.ts.map +1 -1
  62. package/dist/config.js +4 -5
  63. package/dist/config.js.map +1 -1
  64. package/dist/core/agent-session-bash.d.ts +1 -0
  65. package/dist/core/agent-session-bash.d.ts.map +1 -1
  66. package/dist/core/agent-session-bash.js +1 -0
  67. package/dist/core/agent-session-bash.js.map +1 -1
  68. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  69. package/dist/core/agent-session-tool-registry.js +23 -0
  70. package/dist/core/agent-session-tool-registry.js.map +1 -1
  71. package/dist/core/bash-executor.d.ts +2 -0
  72. package/dist/core/bash-executor.d.ts.map +1 -1
  73. package/dist/core/bash-executor.js +1 -0
  74. package/dist/core/bash-executor.js.map +1 -1
  75. package/dist/core/compaction/compaction.d.ts +29 -0
  76. package/dist/core/compaction/compaction.d.ts.map +1 -1
  77. package/dist/core/compaction/compaction.js +36 -1
  78. package/dist/core/compaction/compaction.js.map +1 -1
  79. package/dist/core/compaction/context-compaction-metrics.d.ts +14 -2
  80. package/dist/core/compaction/context-compaction-metrics.d.ts.map +1 -1
  81. package/dist/core/compaction/context-compaction-metrics.js +50 -1
  82. package/dist/core/compaction/context-compaction-metrics.js.map +1 -1
  83. package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -1
  84. package/dist/core/compaction/context-compaction-prompt.js +2 -0
  85. package/dist/core/compaction/context-compaction-prompt.js.map +1 -1
  86. package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -1
  87. package/dist/core/compaction/context-compaction-runner.js +1 -1
  88. package/dist/core/compaction/context-compaction-runner.js.map +1 -1
  89. package/dist/core/compaction/context-deletion-application.d.ts.map +1 -1
  90. package/dist/core/compaction/context-deletion-application.js +5 -5
  91. package/dist/core/compaction/context-deletion-application.js.map +1 -1
  92. package/dist/core/compaction/context-deletion-targets.d.ts +2 -0
  93. package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -1
  94. package/dist/core/compaction/context-deletion-targets.js +23 -3
  95. package/dist/core/compaction/context-deletion-targets.js.map +1 -1
  96. package/dist/core/compaction/context-deletion-tool-definitions.d.ts +6 -0
  97. package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +1 -1
  98. package/dist/core/compaction/context-deletion-tool-definitions.js.map +1 -1
  99. package/dist/core/compaction/context-deletion-tools.d.ts.map +1 -1
  100. package/dist/core/compaction/context-deletion-tools.js +18 -10
  101. package/dist/core/compaction/context-deletion-tools.js.map +1 -1
  102. package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
  103. package/dist/core/compaction/context-transcript-analysis.js +2 -4
  104. package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
  105. package/dist/core/copilot-gemini-tool-arguments.d.ts.map +1 -1
  106. package/dist/core/copilot-gemini-tool-arguments.js +2 -60
  107. package/dist/core/copilot-gemini-tool-arguments.js.map +1 -1
  108. package/dist/core/extensions/context-types.d.ts +2 -0
  109. package/dist/core/extensions/context-types.d.ts.map +1 -1
  110. package/dist/core/extensions/context-types.js.map +1 -1
  111. package/dist/core/extensions/index.d.ts +2 -2
  112. package/dist/core/extensions/index.d.ts.map +1 -1
  113. package/dist/core/extensions/index.js +1 -1
  114. package/dist/core/extensions/index.js.map +1 -1
  115. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  116. package/dist/core/extensions/loader-virtual-modules.js +11 -3
  117. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  118. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  119. package/dist/core/extensions/runner-context.js +11 -0
  120. package/dist/core/extensions/runner-context.js.map +1 -1
  121. package/dist/core/extensions/tool-events.d.ts +13 -13
  122. package/dist/core/extensions/tool-events.d.ts.map +1 -1
  123. package/dist/core/extensions/tool-events.js +3 -3
  124. package/dist/core/extensions/tool-events.js.map +1 -1
  125. package/dist/core/extensions/types.d.ts +1 -1
  126. package/dist/core/extensions/types.d.ts.map +1 -1
  127. package/dist/core/extensions/types.js +1 -1
  128. package/dist/core/extensions/types.js.map +1 -1
  129. package/dist/core/flattened-tool-arguments.d.ts +18 -0
  130. package/dist/core/flattened-tool-arguments.d.ts.map +1 -1
  131. package/dist/core/flattened-tool-arguments.js +104 -0
  132. package/dist/core/flattened-tool-arguments.js.map +1 -1
  133. package/dist/core/sdk-exports.d.ts +1 -1
  134. package/dist/core/sdk-exports.d.ts.map +1 -1
  135. package/dist/core/sdk-exports.js +1 -1
  136. package/dist/core/sdk-exports.js.map +1 -1
  137. package/dist/core/sdk-types.d.ts +2 -2
  138. package/dist/core/sdk-types.d.ts.map +1 -1
  139. package/dist/core/sdk-types.js.map +1 -1
  140. package/dist/core/settings-manager-basic-accessors.d.ts +4 -0
  141. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  142. package/dist/core/settings-manager-basic-accessors.js +18 -0
  143. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  144. package/dist/core/settings-manager-resource-accessors.d.ts +4 -0
  145. package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
  146. package/dist/core/settings-manager-resource-accessors.js +15 -0
  147. package/dist/core/settings-manager-resource-accessors.js.map +1 -1
  148. package/dist/core/settings-types.d.ts +11 -0
  149. package/dist/core/settings-types.d.ts.map +1 -1
  150. package/dist/core/settings-types.js.map +1 -1
  151. package/dist/core/system-prompt.d.ts +1 -1
  152. package/dist/core/system-prompt.d.ts.map +1 -1
  153. package/dist/core/system-prompt.js +3 -2
  154. package/dist/core/system-prompt.js.map +1 -1
  155. package/dist/core/tools/artifact-protocol.d.ts +11 -0
  156. package/dist/core/tools/artifact-protocol.d.ts.map +1 -0
  157. package/dist/core/tools/artifact-protocol.js +76 -0
  158. package/dist/core/tools/artifact-protocol.js.map +1 -0
  159. package/dist/core/tools/artifacts.d.ts +18 -0
  160. package/dist/core/tools/artifacts.d.ts.map +1 -0
  161. package/dist/core/tools/artifacts.js +90 -0
  162. package/dist/core/tools/artifacts.js.map +1 -0
  163. package/dist/core/tools/bash-async-jobs.d.ts +20 -0
  164. package/dist/core/tools/bash-async-jobs.d.ts.map +1 -0
  165. package/dist/core/tools/bash-async-jobs.js +59 -0
  166. package/dist/core/tools/bash-async-jobs.js.map +1 -0
  167. package/dist/core/tools/bash-async-output.d.ts +10 -0
  168. package/dist/core/tools/bash-async-output.d.ts.map +1 -0
  169. package/dist/core/tools/bash-async-output.js +80 -0
  170. package/dist/core/tools/bash-async-output.js.map +1 -0
  171. package/dist/core/tools/bash-interceptor.d.ts +10 -0
  172. package/dist/core/tools/bash-interceptor.d.ts.map +1 -0
  173. package/dist/core/tools/bash-interceptor.js +39 -0
  174. package/dist/core/tools/bash-interceptor.js.map +1 -0
  175. package/dist/core/tools/bash-leading-cd.d.ts +7 -0
  176. package/dist/core/tools/bash-leading-cd.d.ts.map +1 -0
  177. package/dist/core/tools/bash-leading-cd.js +59 -0
  178. package/dist/core/tools/bash-leading-cd.js.map +1 -0
  179. package/dist/core/tools/bash-pty-native.d.ts +14 -0
  180. package/dist/core/tools/bash-pty-native.d.ts.map +1 -0
  181. package/dist/core/tools/bash-pty-native.js +71 -0
  182. package/dist/core/tools/bash-pty-native.js.map +1 -0
  183. package/dist/core/tools/bash.d.ts +28 -17
  184. package/dist/core/tools/bash.d.ts.map +1 -1
  185. package/dist/core/tools/bash.js +152 -35
  186. package/dist/core/tools/bash.js.map +1 -1
  187. package/dist/core/tools/block-resolver.d.ts +16 -0
  188. package/dist/core/tools/block-resolver.d.ts.map +1 -0
  189. package/dist/core/tools/block-resolver.js +74 -0
  190. package/dist/core/tools/block-resolver.js.map +1 -0
  191. package/dist/core/tools/conflict-registry.d.ts +16 -0
  192. package/dist/core/tools/conflict-registry.d.ts.map +1 -0
  193. package/dist/core/tools/conflict-registry.js +44 -0
  194. package/dist/core/tools/conflict-registry.js.map +1 -0
  195. package/dist/core/tools/directory-tree.d.ts +13 -0
  196. package/dist/core/tools/directory-tree.d.ts.map +1 -0
  197. package/dist/core/tools/directory-tree.js +81 -0
  198. package/dist/core/tools/directory-tree.js.map +1 -0
  199. package/dist/core/tools/edit.d.ts +4 -29
  200. package/dist/core/tools/edit.d.ts.map +1 -1
  201. package/dist/core/tools/edit.js +136 -228
  202. package/dist/core/tools/edit.js.map +1 -1
  203. package/dist/core/tools/fetch-url.d.ts +74 -0
  204. package/dist/core/tools/fetch-url.d.ts.map +1 -0
  205. package/dist/core/tools/fetch-url.js +518 -0
  206. package/dist/core/tools/fetch-url.js.map +1 -0
  207. package/dist/core/tools/find.d.ts +27 -9
  208. package/dist/core/tools/find.d.ts.map +1 -1
  209. package/dist/core/tools/find.js +400 -176
  210. package/dist/core/tools/find.js.map +1 -1
  211. package/dist/core/tools/glob-path-utils.d.ts +8 -0
  212. package/dist/core/tools/glob-path-utils.d.ts.map +1 -0
  213. package/dist/core/tools/glob-path-utils.js +26 -0
  214. package/dist/core/tools/glob-path-utils.js.map +1 -0
  215. package/dist/core/tools/grep.d.ts +12 -0
  216. package/dist/core/tools/grep.d.ts.map +1 -1
  217. package/dist/core/tools/grep.js +141 -17
  218. package/dist/core/tools/grep.js.map +1 -1
  219. package/dist/core/tools/hashline-engine/apply.d.ts +11 -0
  220. package/dist/core/tools/hashline-engine/apply.d.ts.map +1 -0
  221. package/dist/core/tools/hashline-engine/apply.js +752 -0
  222. package/dist/core/tools/hashline-engine/apply.js.map +1 -0
  223. package/dist/core/tools/hashline-engine/block.d.ts +40 -0
  224. package/dist/core/tools/hashline-engine/block.d.ts.map +1 -0
  225. package/dist/core/tools/hashline-engine/block.js +117 -0
  226. package/dist/core/tools/hashline-engine/block.js.map +1 -0
  227. package/dist/core/tools/hashline-engine/diff-preview.d.ts +15 -0
  228. package/dist/core/tools/hashline-engine/diff-preview.d.ts.map +1 -0
  229. package/dist/core/tools/hashline-engine/diff-preview.js +98 -0
  230. package/dist/core/tools/hashline-engine/diff-preview.js.map +1 -0
  231. package/dist/core/tools/hashline-engine/format.d.ts +71 -0
  232. package/dist/core/tools/hashline-engine/format.d.ts.map +1 -0
  233. package/dist/core/tools/hashline-engine/format.js +178 -0
  234. package/dist/core/tools/hashline-engine/format.js.map +1 -0
  235. package/dist/core/tools/hashline-engine/fs.d.ts +81 -0
  236. package/dist/core/tools/hashline-engine/fs.d.ts.map +1 -0
  237. package/dist/core/tools/hashline-engine/fs.js +143 -0
  238. package/dist/core/tools/hashline-engine/fs.js.map +1 -0
  239. package/dist/core/tools/hashline-engine/index.d.ts +18 -0
  240. package/dist/core/tools/hashline-engine/index.d.ts.map +1 -0
  241. package/dist/core/tools/hashline-engine/index.js +20 -0
  242. package/dist/core/tools/hashline-engine/index.js.map +1 -0
  243. package/dist/core/tools/hashline-engine/input.d.ts +101 -0
  244. package/dist/core/tools/hashline-engine/input.d.ts.map +1 -0
  245. package/dist/core/tools/hashline-engine/input.js +398 -0
  246. package/dist/core/tools/hashline-engine/input.js.map +1 -0
  247. package/dist/core/tools/hashline-engine/messages.d.ts +99 -0
  248. package/dist/core/tools/hashline-engine/messages.d.ts.map +1 -0
  249. package/dist/core/tools/hashline-engine/messages.js +144 -0
  250. package/dist/core/tools/hashline-engine/messages.js.map +1 -0
  251. package/dist/core/tools/hashline-engine/mismatch.d.ts +45 -0
  252. package/dist/core/tools/hashline-engine/mismatch.d.ts.map +1 -0
  253. package/dist/core/tools/hashline-engine/mismatch.js +90 -0
  254. package/dist/core/tools/hashline-engine/mismatch.js.map +1 -0
  255. package/dist/core/tools/hashline-engine/normalize.d.ts +21 -0
  256. package/dist/core/tools/hashline-engine/normalize.d.ts.map +1 -0
  257. package/dist/core/tools/hashline-engine/normalize.js +33 -0
  258. package/dist/core/tools/hashline-engine/normalize.js.map +1 -0
  259. package/dist/core/tools/hashline-engine/parser.d.ts +24 -0
  260. package/dist/core/tools/hashline-engine/parser.d.ts.map +1 -0
  261. package/dist/core/tools/hashline-engine/parser.js +381 -0
  262. package/dist/core/tools/hashline-engine/parser.js.map +1 -0
  263. package/dist/core/tools/hashline-engine/patcher.d.ts +118 -0
  264. package/dist/core/tools/hashline-engine/patcher.d.ts.map +1 -0
  265. package/dist/core/tools/hashline-engine/patcher.js +341 -0
  266. package/dist/core/tools/hashline-engine/patcher.js.map +1 -0
  267. package/dist/core/tools/hashline-engine/prefixes.d.ts +43 -0
  268. package/dist/core/tools/hashline-engine/prefixes.d.ts.map +1 -0
  269. package/dist/core/tools/hashline-engine/prefixes.js +135 -0
  270. package/dist/core/tools/hashline-engine/prefixes.js.map +1 -0
  271. package/dist/core/tools/hashline-engine/recovery.d.ts +41 -0
  272. package/dist/core/tools/hashline-engine/recovery.d.ts.map +1 -0
  273. package/dist/core/tools/hashline-engine/recovery.js +168 -0
  274. package/dist/core/tools/hashline-engine/recovery.js.map +1 -0
  275. package/dist/core/tools/hashline-engine/snapshots.d.ts +65 -0
  276. package/dist/core/tools/hashline-engine/snapshots.d.ts.map +1 -0
  277. package/dist/core/tools/hashline-engine/snapshots.js +108 -0
  278. package/dist/core/tools/hashline-engine/snapshots.js.map +1 -0
  279. package/dist/core/tools/hashline-engine/stream.d.ts +3 -0
  280. package/dist/core/tools/hashline-engine/stream.d.ts.map +1 -0
  281. package/dist/core/tools/hashline-engine/stream.js +111 -0
  282. package/dist/core/tools/hashline-engine/stream.js.map +1 -0
  283. package/dist/core/tools/hashline-engine/tokenizer.d.ts +69 -0
  284. package/dist/core/tools/hashline-engine/tokenizer.d.ts.map +1 -0
  285. package/dist/core/tools/hashline-engine/tokenizer.js +430 -0
  286. package/dist/core/tools/hashline-engine/tokenizer.js.map +1 -0
  287. package/dist/core/tools/hashline-engine/types.d.ts +166 -0
  288. package/dist/core/tools/hashline-engine/types.d.ts.map +1 -0
  289. package/dist/core/tools/hashline-engine/types.js +9 -0
  290. package/dist/core/tools/hashline-engine/types.js.map +1 -0
  291. package/dist/core/tools/hashline.d.ts +29 -0
  292. package/dist/core/tools/hashline.d.ts.map +1 -0
  293. package/dist/core/tools/hashline.js +110 -0
  294. package/dist/core/tools/hashline.js.map +1 -0
  295. package/dist/core/tools/index.d.ts +6 -4
  296. package/dist/core/tools/index.d.ts.map +1 -1
  297. package/dist/core/tools/index.js +52 -35
  298. package/dist/core/tools/index.js.map +1 -1
  299. package/dist/core/tools/notebook.d.ts +38 -0
  300. package/dist/core/tools/notebook.d.ts.map +1 -0
  301. package/dist/core/tools/notebook.js +125 -0
  302. package/dist/core/tools/notebook.js.map +1 -0
  303. package/dist/core/tools/read-document-extract.d.ts +9 -0
  304. package/dist/core/tools/read-document-extract.d.ts.map +1 -0
  305. package/dist/core/tools/read-document-extract.js +212 -0
  306. package/dist/core/tools/read-document-extract.js.map +1 -0
  307. package/dist/core/tools/read-selectors.d.ts +24 -0
  308. package/dist/core/tools/read-selectors.d.ts.map +1 -0
  309. package/dist/core/tools/read-selectors.js +277 -0
  310. package/dist/core/tools/read-selectors.js.map +1 -0
  311. package/dist/core/tools/read-url.d.ts +37 -0
  312. package/dist/core/tools/read-url.d.ts.map +1 -0
  313. package/dist/core/tools/read-url.js +39 -0
  314. package/dist/core/tools/read-url.js.map +1 -0
  315. package/dist/core/tools/read.d.ts +11 -11
  316. package/dist/core/tools/read.d.ts.map +1 -1
  317. package/dist/core/tools/read.js +224 -94
  318. package/dist/core/tools/read.js.map +1 -1
  319. package/dist/core/tools/resource-selectors.d.ts +44 -0
  320. package/dist/core/tools/resource-selectors.d.ts.map +1 -0
  321. package/dist/core/tools/resource-selectors.js +808 -0
  322. package/dist/core/tools/resource-selectors.js.map +1 -0
  323. package/dist/core/tools/search-details.d.ts +26 -0
  324. package/dist/core/tools/search-details.d.ts.map +1 -0
  325. package/dist/core/tools/search-details.js +24 -0
  326. package/dist/core/tools/search-details.js.map +1 -0
  327. package/dist/core/tools/search-line-ranges.d.ts +11 -0
  328. package/dist/core/tools/search-line-ranges.d.ts.map +1 -0
  329. package/dist/core/tools/search-line-ranges.js +65 -0
  330. package/dist/core/tools/search-line-ranges.js.map +1 -0
  331. package/dist/core/tools/search-native.d.ts +97 -0
  332. package/dist/core/tools/search-native.d.ts.map +1 -0
  333. package/dist/core/tools/search-native.js +27 -0
  334. package/dist/core/tools/search-native.js.map +1 -0
  335. package/dist/core/tools/search.d.ts +24 -0
  336. package/dist/core/tools/search.d.ts.map +1 -0
  337. package/dist/core/tools/search.js +573 -0
  338. package/dist/core/tools/search.js.map +1 -0
  339. package/dist/core/tools/truncate.d.ts +4 -4
  340. package/dist/core/tools/truncate.d.ts.map +1 -1
  341. package/dist/core/tools/truncate.js +3 -3
  342. package/dist/core/tools/truncate.js.map +1 -1
  343. package/dist/core/tools/url-ip-guards.d.ts +4 -0
  344. package/dist/core/tools/url-ip-guards.d.ts.map +1 -0
  345. package/dist/core/tools/url-ip-guards.js +126 -0
  346. package/dist/core/tools/url-ip-guards.js.map +1 -0
  347. package/dist/core/tools/write.d.ts +12 -2
  348. package/dist/core/tools/write.d.ts.map +1 -1
  349. package/dist/core/tools/write.js +166 -14
  350. package/dist/core/tools/write.js.map +1 -1
  351. package/dist/core/trust-manager.d.ts.map +1 -1
  352. package/dist/core/trust-manager.js +2 -3
  353. package/dist/core/trust-manager.js.map +1 -1
  354. package/dist/index-extensions.d.ts +2 -2
  355. package/dist/index-extensions.d.ts.map +1 -1
  356. package/dist/index-extensions.js +1 -1
  357. package/dist/index-extensions.js.map +1 -1
  358. package/dist/index.d.ts +3 -3
  359. package/dist/index.d.ts.map +1 -1
  360. package/dist/index.js +3 -3
  361. package/dist/index.js.map +1 -1
  362. package/dist/modes/interactive/components/custom-editor.d.ts +1 -0
  363. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  364. package/dist/modes/interactive/components/custom-editor.js +9 -2
  365. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  366. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  367. package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
  368. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  369. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  370. package/dist/modes/interactive/components/settings-selector-items.js +7 -0
  371. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  372. package/dist/modes/interactive/components/settings-selector-types.d.ts +2 -0
  373. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  374. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  375. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  376. package/dist/modes/interactive/components/tree-selector-content.js +0 -5
  377. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  378. package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -1
  379. package/dist/modes/interactive/interactive-auth-login.js +1 -0
  380. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  381. package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
  382. package/dist/modes/interactive/interactive-autocomplete.js +80 -2
  383. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  384. package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
  385. package/dist/modes/interactive/interactive-hotkeys-debug.js +3 -0
  386. package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
  387. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  388. package/dist/modes/interactive/interactive-input-handling.js +51 -0
  389. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  390. package/dist/modes/interactive/interactive-mode-base.d.ts +5 -0
  391. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  392. package/dist/modes/interactive/interactive-mode-base.js +5 -0
  393. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  394. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  395. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  396. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  397. package/dist/modes/interactive/interactive-mode-surface.d.ts +12 -0
  398. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  399. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  400. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  401. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  402. package/dist/modes/interactive/interactive-mode.js +1 -0
  403. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  404. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  405. package/dist/modes/interactive/interactive-model-routing.js +4 -1
  406. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  407. package/dist/modes/interactive/interactive-onboarding.d.ts +11 -0
  408. package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -0
  409. package/dist/modes/interactive/interactive-onboarding.js +220 -0
  410. package/dist/modes/interactive/interactive-onboarding.js.map +1 -0
  411. package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
  412. package/dist/modes/interactive/interactive-selectors.js +4 -0
  413. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  414. package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
  415. package/dist/modes/interactive/interactive-session-routing.js +6 -0
  416. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  417. package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -1
  418. package/dist/modes/interactive/interactive-slash-commands.js +9 -4
  419. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  420. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  421. package/dist/modes/interactive/interactive-startup.js +28 -0
  422. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  423. package/dist/utils/child-process.d.ts.map +1 -1
  424. package/dist/utils/child-process.js +21 -1
  425. package/dist/utils/child-process.js.map +1 -1
  426. package/dist/utils/markit.d.ts +8 -0
  427. package/dist/utils/markit.d.ts.map +1 -0
  428. package/dist/utils/markit.js +53 -0
  429. package/dist/utils/markit.js.map +1 -0
  430. package/dist/utils/paths.d.ts +2 -1
  431. package/dist/utils/paths.d.ts.map +1 -1
  432. package/dist/utils/paths.js +14 -1
  433. package/dist/utils/paths.js.map +1 -1
  434. package/docs/compaction.md +16 -1
  435. package/docs/containerization.md +1 -1
  436. package/docs/docs.json +1 -0
  437. package/docs/extensions.md +25 -36
  438. package/docs/quickstart.md +11 -6
  439. package/docs/sdk.md +5 -5
  440. package/docs/settings.md +7 -0
  441. package/docs/subagents.md +3 -2
  442. package/docs/tools.md +49 -0
  443. package/docs/usage.md +3 -3
  444. package/docs/workflows.md +7 -5
  445. package/examples/extensions/subagent/README.md +5 -5
  446. package/examples/extensions/subagent/agents/planner.md +1 -1
  447. package/examples/extensions/subagent/agents/reviewer.md +1 -1
  448. package/examples/extensions/subagent/agents/scout.md +2 -2
  449. package/examples/extensions/subagent/display.ts +3 -3
  450. package/examples/sdk/05-tools.ts +3 -3
  451. package/examples/sdk/README.md +1 -1
  452. package/package.json +3 -2
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Pure data types shared across the hashline parser, applier, and patcher.
3
+ * Nothing in this file references a filesystem, agent runtime, or schema
4
+ * library — keep it that way.
5
+ */
6
+ /** A line-number anchor (1-indexed). */
7
+ export interface Anchor {
8
+ line: number;
9
+ }
10
+ /** Where an `insert` edit should land relative to existing content. */
11
+ export type Cursor = {
12
+ kind: "bof";
13
+ } | {
14
+ kind: "eof";
15
+ } | {
16
+ kind: "before_anchor";
17
+ anchor: Anchor;
18
+ } | {
19
+ kind: "after_anchor";
20
+ anchor: Anchor;
21
+ };
22
+ /**
23
+ * A single low-level edit produced by the parser and consumed by the applier.
24
+ * Multi-line replacements decompose to one `insert` per replacement line plus
25
+ * one `delete` per consumed line. Replacement payloads are tagged so the
26
+ * applier can distinguish literal insertion from new content for a deleted
27
+ * line.
28
+ */
29
+ export type Edit = {
30
+ kind: "insert";
31
+ cursor: Cursor;
32
+ text: string;
33
+ lineNum: number;
34
+ index: number;
35
+ mode?: "replacement";
36
+ /**
37
+ * Present on inserts lowered from `insert after block N:`: the
38
+ * resolved block's first line. Lets the applier slide a body that
39
+ * claims a depth inside the block back across the block's trailing
40
+ * closer lines (never above this line).
41
+ */
42
+ blockStart?: number;
43
+ } | {
44
+ kind: "delete";
45
+ anchor: Anchor;
46
+ lineNum: number;
47
+ index: number;
48
+ oldAssertion?: string;
49
+ } | {
50
+ /**
51
+ * Deferred block edit (`replace block N:` / `delete block N` /
52
+ * `insert after block N:`). The exact line span is unknown at parse
53
+ * time — it is computed by {@link resolveBlockEdits} once file text +
54
+ * path (→ language) are available, then expanded into concrete edits:
55
+ * a non-empty `payloads` without `mode` (from `replace block`) becomes
56
+ * the same `replacement` inserts + deletes that `replace start..end:`
57
+ * produces; an empty `payloads` (from `delete block`) becomes a pure
58
+ * range deletion; `mode: "insert_after"` becomes plain `after_anchor`
59
+ * inserts at the block's last line. `applyEdits` never sees this
60
+ * variant.
61
+ */
62
+ kind: "block";
63
+ anchor: Anchor;
64
+ payloads: string[];
65
+ mode?: "insert_after";
66
+ lineNum: number;
67
+ index: number;
68
+ };
69
+ /** Result of applying a parsed set of edits to a text body. */
70
+ export interface ApplyResult {
71
+ /** Post-edit text body. */
72
+ text: string;
73
+ /** First line number (1-indexed) that changed, or `undefined` for a no-op apply. */
74
+ firstChangedLine?: number;
75
+ /** Diagnostic warnings collected by the parser, patcher, or recovery. */
76
+ warnings?: string[];
77
+ /**
78
+ * Resolved spans for each `replace block`/`delete block` op in this apply,
79
+ * in patch order. Present only when the apply matched the tagged content
80
+ * (the common no-drift path), so the line numbers line up with what the
81
+ * caller read. Absent when there were no block ops.
82
+ */
83
+ blockResolutions?: BlockResolution[];
84
+ }
85
+ /** A parsed `[A..B]` line range. */
86
+ export interface ParsedRange {
87
+ start: Anchor;
88
+ end: Anchor;
89
+ }
90
+ /** Optional hints for {@link splitPatchInput}. */
91
+ export interface SplitOptions {
92
+ /** Resolves absolute paths inside hashline headers to cwd-relative form. */
93
+ cwd?: string;
94
+ /**
95
+ * Fallback path used when the input lacks a `[PATH]` header but contains
96
+ * recognizable hashline operations. Lets streaming previews work before
97
+ * the model has written the header.
98
+ */
99
+ path?: string;
100
+ }
101
+ /** Streaming-formatter knobs for {@link streamHashLines}. */
102
+ export interface StreamOptions {
103
+ /** First line number to use when formatting (1-indexed, default 1). */
104
+ startLine?: number;
105
+ /** Maximum formatted lines per yielded chunk (default 200). */
106
+ maxChunkLines?: number;
107
+ /** Maximum UTF-8 bytes per yielded chunk (default 64 KiB). */
108
+ maxChunkBytes?: number;
109
+ }
110
+ /** Result of {@link buildCompactDiffPreview}. */
111
+ export interface CompactDiffPreview {
112
+ preview: string;
113
+ addedLines: number;
114
+ removedLines: number;
115
+ }
116
+ /** Optional knobs for {@link buildCompactDiffPreview}. */
117
+ export interface CompactDiffOptions {
118
+ /** Added lines kept on each side of a long added-run elision (default 2). */
119
+ maxAddedRunContext?: number;
120
+ /** Back-compat alias for {@link maxAddedRunContext}. */
121
+ maxUnchangedRun?: number;
122
+ }
123
+ /**
124
+ * Resolved 1-indexed inclusive line span of a `replace block N:` target.
125
+ */
126
+ export interface BlockSpan {
127
+ /** First line of the block (1-indexed, inclusive). */
128
+ start: number;
129
+ /** Last line of the block (1-indexed, inclusive). */
130
+ end: number;
131
+ }
132
+ /**
133
+ * One `replace block N:` / `delete block N` / `insert after block N:` anchor
134
+ * resolved to its concrete line span. Surfaced on {@link ApplyResult} so the
135
+ * host can echo "block N → lines start..end" and let the model catch a wrong
136
+ * opener — e.g. a decorator or doc-comment that sits in a separate node
137
+ * outside the resolved block.
138
+ */
139
+ export interface BlockResolution {
140
+ /** The 1-indexed line the block op was anchored on (the `N`). */
141
+ anchorLine: number;
142
+ /** First line of the resolved span (1-indexed, inclusive). */
143
+ start: number;
144
+ /** Last line of the resolved span (1-indexed, inclusive). */
145
+ end: number;
146
+ /** Which block op produced this resolution. */
147
+ op: "replace" | "delete" | "insert_after";
148
+ }
149
+ /** Request handed to a {@link BlockResolver} to resolve one `replace block N:` anchor. */
150
+ export interface BlockResolverRequest {
151
+ /** Target file path (used to infer language by extension). */
152
+ path: string;
153
+ /** Full text the block must be resolved against (the snapshot the tag names). */
154
+ text: string;
155
+ /** 1-indexed line the block must begin on. */
156
+ line: number;
157
+ }
158
+ /**
159
+ * Resolves a `replace block N:` anchor to the line span of the syntactic block
160
+ * that begins on line N. Returns `null` when no block can be resolved
161
+ * (unrecognized language, blank/out-of-range line, no node begins there, or the
162
+ * resolved subtree has a syntax error). Pure seam: the hashline core declares
163
+ * the contract; the host injects a tree-sitter-backed implementation.
164
+ */
165
+ export type BlockResolver = (request: BlockResolverRequest) => BlockSpan | null;
166
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/types.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,wCAAwC;AACxC,MAAM,WAAW,MAAM;IACtB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,uEAAuE;AACvE,MAAM,MAAM,MAAM,GACf;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GACf;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GACf;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,MAAM,IAAI,GACb;IACA,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACnB,GACD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GACzF;IACA;;;;;;;;;;;OAWG;IACH,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,cAAc,CAA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AW,eAAe;IAC/B,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,EAAE,EAAE,SAAS,GAAG,QAAQ,GAAG,cAAc,CAAC;CAC1C;AAED,0FAA0F;AAC1F,MAAM,WAAW,oBAAoB;IACpC,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,oBAAoB,KAAK,SAAS,GAAG,IAAI,CAAC","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 * Pure data types shared across the hashline parser, applier, and patcher.\n * Nothing in this file references a filesystem, agent runtime, or schema\n * library — keep it that way.\n */\n\n/** A line-number anchor (1-indexed). */\nexport interface Anchor {\n\tline: number;\n}\n\n/** Where an `insert` edit should land relative to existing content. */\nexport type Cursor =\n\t| { kind: \"bof\" }\n\t| { kind: \"eof\" }\n\t| { kind: \"before_anchor\"; anchor: Anchor }\n\t| { kind: \"after_anchor\"; anchor: Anchor };\n\n/**\n * A single low-level edit produced by the parser and consumed by the applier.\n * Multi-line replacements decompose to one `insert` per replacement line plus\n * one `delete` per consumed line. Replacement payloads are tagged so the\n * applier can distinguish literal insertion from new content for a deleted\n * line.\n */\nexport type Edit =\n\t| {\n\t\t\tkind: \"insert\";\n\t\t\tcursor: Cursor;\n\t\t\ttext: string;\n\t\t\tlineNum: number;\n\t\t\tindex: number;\n\t\t\tmode?: \"replacement\";\n\t\t\t/**\n\t\t\t * Present on inserts lowered from `insert after block N:`: the\n\t\t\t * resolved block's first line. Lets the applier slide a body that\n\t\t\t * claims a depth inside the block back across the block's trailing\n\t\t\t * closer lines (never above this line).\n\t\t\t */\n\t\t\tblockStart?: number;\n\t }\n\t| { kind: \"delete\"; anchor: Anchor; lineNum: number; index: number; oldAssertion?: string }\n\t| {\n\t\t\t/**\n\t\t\t * Deferred block edit (`replace block N:` / `delete block N` /\n\t\t\t * `insert after block N:`). The exact line span is unknown at parse\n\t\t\t * time — it is computed by {@link resolveBlockEdits} once file text +\n\t\t\t * path (→ language) are available, then expanded into concrete edits:\n\t\t\t * a non-empty `payloads` without `mode` (from `replace block`) becomes\n\t\t\t * the same `replacement` inserts + deletes that `replace start..end:`\n\t\t\t * produces; an empty `payloads` (from `delete block`) becomes a pure\n\t\t\t * range deletion; `mode: \"insert_after\"` becomes plain `after_anchor`\n\t\t\t * inserts at the block's last line. `applyEdits` never sees this\n\t\t\t * variant.\n\t\t\t */\n\t\t\tkind: \"block\";\n\t\t\tanchor: Anchor;\n\t\t\tpayloads: string[];\n\t\t\tmode?: \"insert_after\";\n\t\t\tlineNum: number;\n\t\t\tindex: number;\n\t };\n\n/** Result of applying a parsed set of edits to a text body. */\nexport interface ApplyResult {\n\t/** Post-edit text body. */\n\ttext: string;\n\t/** First line number (1-indexed) that changed, or `undefined` for a no-op apply. */\n\tfirstChangedLine?: number;\n\t/** Diagnostic warnings collected by the parser, patcher, or recovery. */\n\twarnings?: string[];\n\t/**\n\t * Resolved spans for each `replace block`/`delete block` op in this apply,\n\t * in patch order. Present only when the apply matched the tagged content\n\t * (the common no-drift path), so the line numbers line up with what the\n\t * caller read. Absent when there were no block ops.\n\t */\n\tblockResolutions?: BlockResolution[];\n}\n\n/** A parsed `[A..B]` line range. */\nexport interface ParsedRange {\n\tstart: Anchor;\n\tend: Anchor;\n}\n\n/** Optional hints for {@link splitPatchInput}. */\nexport interface SplitOptions {\n\t/** Resolves absolute paths inside hashline headers to cwd-relative form. */\n\tcwd?: string;\n\t/**\n\t * Fallback path used when the input lacks a `[PATH]` header but contains\n\t * recognizable hashline operations. Lets streaming previews work before\n\t * the model has written the header.\n\t */\n\tpath?: string;\n}\n\n/** Streaming-formatter knobs for {@link streamHashLines}. */\nexport interface StreamOptions {\n\t/** First line number to use when formatting (1-indexed, default 1). */\n\tstartLine?: number;\n\t/** Maximum formatted lines per yielded chunk (default 200). */\n\tmaxChunkLines?: number;\n\t/** Maximum UTF-8 bytes per yielded chunk (default 64 KiB). */\n\tmaxChunkBytes?: number;\n}\n\n/** Result of {@link buildCompactDiffPreview}. */\nexport interface CompactDiffPreview {\n\tpreview: string;\n\taddedLines: number;\n\tremovedLines: number;\n}\n\n/** Optional knobs for {@link buildCompactDiffPreview}. */\nexport interface CompactDiffOptions {\n\t/** Added lines kept on each side of a long added-run elision (default 2). */\n\tmaxAddedRunContext?: number;\n\t/** Back-compat alias for {@link maxAddedRunContext}. */\n\tmaxUnchangedRun?: number;\n}\n\n/**\n * Resolved 1-indexed inclusive line span of a `replace block N:` target.\n */\nexport interface BlockSpan {\n\t/** First line of the block (1-indexed, inclusive). */\n\tstart: number;\n\t/** Last line of the block (1-indexed, inclusive). */\n\tend: number;\n}\n\n/**\n * One `replace block N:` / `delete block N` / `insert after block N:` anchor\n * resolved to its concrete line span. Surfaced on {@link ApplyResult} so the\n * host can echo \"block N → lines start..end\" and let the model catch a wrong\n * opener — e.g. a decorator or doc-comment that sits in a separate node\n * outside the resolved block.\n */\nexport interface BlockResolution {\n\t/** The 1-indexed line the block op was anchored on (the `N`). */\n\tanchorLine: number;\n\t/** First line of the resolved span (1-indexed, inclusive). */\n\tstart: number;\n\t/** Last line of the resolved span (1-indexed, inclusive). */\n\tend: number;\n\t/** Which block op produced this resolution. */\n\top: \"replace\" | \"delete\" | \"insert_after\";\n}\n\n/** Request handed to a {@link BlockResolver} to resolve one `replace block N:` anchor. */\nexport interface BlockResolverRequest {\n\t/** Target file path (used to infer language by extension). */\n\tpath: string;\n\t/** Full text the block must be resolved against (the snapshot the tag names). */\n\ttext: string;\n\t/** 1-indexed line the block must begin on. */\n\tline: number;\n}\n\n/**\n * Resolves a `replace block N:` anchor to the line span of the syntactic block\n * that begins on line N. Returns `null` when no block can be resolved\n * (unrecognized language, blank/out-of-range line, no node begins there, or the\n * resolved subtree has a syntax error). Pure seam: the hashline core declares\n * the contract; the host injects a tree-sitter-backed implementation.\n */\nexport type BlockResolver = (request: BlockResolverRequest) => BlockSpan | null;\n"]}
@@ -0,0 +1,9 @@
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
+ * Pure data types shared across the hashline parser, applier, and patcher.
5
+ * Nothing in this file references a filesystem, agent runtime, or schema
6
+ * library — keep it that way.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/types.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,iLAAiL;AACjL;;;;GAIG","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 * Pure data types shared across the hashline parser, applier, and patcher.\n * Nothing in this file references a filesystem, agent runtime, or schema\n * library — keep it that way.\n */\n\n/** A line-number anchor (1-indexed). */\nexport interface Anchor {\n\tline: number;\n}\n\n/** Where an `insert` edit should land relative to existing content. */\nexport type Cursor =\n\t| { kind: \"bof\" }\n\t| { kind: \"eof\" }\n\t| { kind: \"before_anchor\"; anchor: Anchor }\n\t| { kind: \"after_anchor\"; anchor: Anchor };\n\n/**\n * A single low-level edit produced by the parser and consumed by the applier.\n * Multi-line replacements decompose to one `insert` per replacement line plus\n * one `delete` per consumed line. Replacement payloads are tagged so the\n * applier can distinguish literal insertion from new content for a deleted\n * line.\n */\nexport type Edit =\n\t| {\n\t\t\tkind: \"insert\";\n\t\t\tcursor: Cursor;\n\t\t\ttext: string;\n\t\t\tlineNum: number;\n\t\t\tindex: number;\n\t\t\tmode?: \"replacement\";\n\t\t\t/**\n\t\t\t * Present on inserts lowered from `insert after block N:`: the\n\t\t\t * resolved block's first line. Lets the applier slide a body that\n\t\t\t * claims a depth inside the block back across the block's trailing\n\t\t\t * closer lines (never above this line).\n\t\t\t */\n\t\t\tblockStart?: number;\n\t }\n\t| { kind: \"delete\"; anchor: Anchor; lineNum: number; index: number; oldAssertion?: string }\n\t| {\n\t\t\t/**\n\t\t\t * Deferred block edit (`replace block N:` / `delete block N` /\n\t\t\t * `insert after block N:`). The exact line span is unknown at parse\n\t\t\t * time — it is computed by {@link resolveBlockEdits} once file text +\n\t\t\t * path (→ language) are available, then expanded into concrete edits:\n\t\t\t * a non-empty `payloads` without `mode` (from `replace block`) becomes\n\t\t\t * the same `replacement` inserts + deletes that `replace start..end:`\n\t\t\t * produces; an empty `payloads` (from `delete block`) becomes a pure\n\t\t\t * range deletion; `mode: \"insert_after\"` becomes plain `after_anchor`\n\t\t\t * inserts at the block's last line. `applyEdits` never sees this\n\t\t\t * variant.\n\t\t\t */\n\t\t\tkind: \"block\";\n\t\t\tanchor: Anchor;\n\t\t\tpayloads: string[];\n\t\t\tmode?: \"insert_after\";\n\t\t\tlineNum: number;\n\t\t\tindex: number;\n\t };\n\n/** Result of applying a parsed set of edits to a text body. */\nexport interface ApplyResult {\n\t/** Post-edit text body. */\n\ttext: string;\n\t/** First line number (1-indexed) that changed, or `undefined` for a no-op apply. */\n\tfirstChangedLine?: number;\n\t/** Diagnostic warnings collected by the parser, patcher, or recovery. */\n\twarnings?: string[];\n\t/**\n\t * Resolved spans for each `replace block`/`delete block` op in this apply,\n\t * in patch order. Present only when the apply matched the tagged content\n\t * (the common no-drift path), so the line numbers line up with what the\n\t * caller read. Absent when there were no block ops.\n\t */\n\tblockResolutions?: BlockResolution[];\n}\n\n/** A parsed `[A..B]` line range. */\nexport interface ParsedRange {\n\tstart: Anchor;\n\tend: Anchor;\n}\n\n/** Optional hints for {@link splitPatchInput}. */\nexport interface SplitOptions {\n\t/** Resolves absolute paths inside hashline headers to cwd-relative form. */\n\tcwd?: string;\n\t/**\n\t * Fallback path used when the input lacks a `[PATH]` header but contains\n\t * recognizable hashline operations. Lets streaming previews work before\n\t * the model has written the header.\n\t */\n\tpath?: string;\n}\n\n/** Streaming-formatter knobs for {@link streamHashLines}. */\nexport interface StreamOptions {\n\t/** First line number to use when formatting (1-indexed, default 1). */\n\tstartLine?: number;\n\t/** Maximum formatted lines per yielded chunk (default 200). */\n\tmaxChunkLines?: number;\n\t/** Maximum UTF-8 bytes per yielded chunk (default 64 KiB). */\n\tmaxChunkBytes?: number;\n}\n\n/** Result of {@link buildCompactDiffPreview}. */\nexport interface CompactDiffPreview {\n\tpreview: string;\n\taddedLines: number;\n\tremovedLines: number;\n}\n\n/** Optional knobs for {@link buildCompactDiffPreview}. */\nexport interface CompactDiffOptions {\n\t/** Added lines kept on each side of a long added-run elision (default 2). */\n\tmaxAddedRunContext?: number;\n\t/** Back-compat alias for {@link maxAddedRunContext}. */\n\tmaxUnchangedRun?: number;\n}\n\n/**\n * Resolved 1-indexed inclusive line span of a `replace block N:` target.\n */\nexport interface BlockSpan {\n\t/** First line of the block (1-indexed, inclusive). */\n\tstart: number;\n\t/** Last line of the block (1-indexed, inclusive). */\n\tend: number;\n}\n\n/**\n * One `replace block N:` / `delete block N` / `insert after block N:` anchor\n * resolved to its concrete line span. Surfaced on {@link ApplyResult} so the\n * host can echo \"block N → lines start..end\" and let the model catch a wrong\n * opener — e.g. a decorator or doc-comment that sits in a separate node\n * outside the resolved block.\n */\nexport interface BlockResolution {\n\t/** The 1-indexed line the block op was anchored on (the `N`). */\n\tanchorLine: number;\n\t/** First line of the resolved span (1-indexed, inclusive). */\n\tstart: number;\n\t/** Last line of the resolved span (1-indexed, inclusive). */\n\tend: number;\n\t/** Which block op produced this resolution. */\n\top: \"replace\" | \"delete\" | \"insert_after\";\n}\n\n/** Request handed to a {@link BlockResolver} to resolve one `replace block N:` anchor. */\nexport interface BlockResolverRequest {\n\t/** Target file path (used to infer language by extension). */\n\tpath: string;\n\t/** Full text the block must be resolved against (the snapshot the tag names). */\n\ttext: string;\n\t/** 1-indexed line the block must begin on. */\n\tline: number;\n}\n\n/**\n * Resolves a `replace block N:` anchor to the line span of the syntactic block\n * that begins on line N. Returns `null` when no block can be resolved\n * (unrecognized language, blank/out-of-range line, no node begins there, or the\n * resolved subtree has a syntax error). Pure seam: the hashline core declares\n * the contract; the host injects a tree-sitter-backed implementation.\n */\nexport type BlockResolver = (request: BlockResolverRequest) => BlockSpan | null;\n"]}
@@ -0,0 +1,29 @@
1
+ import { type SnapshotStore } from "./hashline-engine/index.ts";
2
+ export interface HashlineSnapshot {
3
+ absolutePath: string;
4
+ displayPath: string;
5
+ tag: string;
6
+ content: string;
7
+ }
8
+ export interface HashlineSnapshotStore {
9
+ readonly snapshots: SnapshotStore;
10
+ record(absolutePath: string, cwd: string, content: string): HashlineSnapshot;
11
+ findByHeader(displayPath: string, tag: string): HashlineSnapshot | undefined;
12
+ }
13
+ export declare function hashlineDisplayPath(absolutePath: string, cwd: string): string;
14
+ export declare function normalizeHashlineContent(content: string): string;
15
+ export declare function computeHashlineTag(content: string): string;
16
+ export declare function createHashlineSnapshotStore(): HashlineSnapshotStore;
17
+ export declare function recordHashlineSnapshot(absolutePath: string, cwd: string, content: string, store: HashlineSnapshotStore): HashlineSnapshot;
18
+ export declare function formatHashlineContent(snapshot: HashlineSnapshot, content?: string, startLine?: number): string;
19
+ export interface StrippedHashlineContent {
20
+ content: string;
21
+ stripped: boolean;
22
+ }
23
+ export declare function stripKnownHashlineCopiedContentWithMeta(content: string, _absolutePath: string, _cwd: string, store: HashlineSnapshotStore): StrippedHashlineContent;
24
+ export declare function stripKnownHashlineCopiedContent(content: string, absolutePath: string, cwd: string, store: HashlineSnapshotStore): string;
25
+ export declare function formatCompactHashlineEditResult(snapshot: HashlineSnapshot, diff: {
26
+ diff?: string;
27
+ firstChangedLine?: number;
28
+ }, messages?: readonly string[]): string;
29
+ //# sourceMappingURL=hashline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashline.d.ts","sourceRoot":"","sources":["../../../src/core/tools/hashline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqF,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAGnJ,MAAM,WAAW,gBAAgB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAAC;IAC7E,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;CAC7E;AAMD,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAI7E;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,2BAA2B,IAAI,qBAAqB,CAkBnE;AAED,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,gBAAgB,CAEzI;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,SAAmB,EAAE,SAAS,SAAI,GAAG,MAAM,CAEnH;AAED,MAAM,WAAW,uBAAuB;IAAG,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE;AAE/E,wBAAgB,uCAAuC,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,uBAAuB,CAoDnK;AAED,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAExI;AAED,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,QAAQ,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAExK","sourcesContent":["import { computeFileHash, formatHashlineHeader, formatNumberedLines, InMemorySnapshotStore, type SnapshotStore } from \"./hashline-engine/index.ts\";\nimport { isAbsolute, normalize as normalizePath, relative, sep } from \"node:path\";\n\nexport interface HashlineSnapshot {\n\tabsolutePath: string;\n\tdisplayPath: string;\n\ttag: string;\n\tcontent: string;\n}\n\nexport interface HashlineSnapshotStore {\n\treadonly snapshots: SnapshotStore;\n\trecord(absolutePath: string, cwd: string, content: string): HashlineSnapshot;\n\tfindByHeader(displayPath: string, tag: string): HashlineSnapshot | undefined;\n}\n\nfunction toPosixPath(filePath: string): string {\n\treturn filePath.split(sep).join(\"/\");\n}\n\nexport function hashlineDisplayPath(absolutePath: string, cwd: string): string {\n\tconst relativePath = relative(cwd, absolutePath);\n\tif (relativePath && !relativePath.startsWith(\"..\") && !isAbsolute(relativePath)) return toPosixPath(relativePath);\n\treturn toPosixPath(absolutePath);\n}\n\nexport function normalizeHashlineContent(content: string): string {\n\treturn content.replace(/^\\uFEFF/, \"\").replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n}\n\nexport function computeHashlineTag(content: string): string {\n\treturn computeFileHash(normalizeHashlineContent(content));\n}\n\nexport function createHashlineSnapshotStore(): HashlineSnapshotStore {\n\tconst snapshots = new InMemorySnapshotStore();\n\tconst headers = new Map<string, HashlineSnapshot>();\n\treturn {\n\t\tsnapshots,\n\t\trecord(absolutePath: string, cwd: string, content: string): HashlineSnapshot {\n\t\t\tconst normalizedPath = normalizePath(absolutePath);\n\t\t\tconst normalized = normalizeHashlineContent(content);\n\t\t\tconst displayPath = hashlineDisplayPath(normalizedPath, cwd);\n\t\t\tconst tag = snapshots.record(normalizedPath, normalized);\n\t\t\tconst snapshot = { absolutePath: normalizedPath, displayPath, tag, content: normalized };\n\t\t\theaders.set(`${displayPath}\\0${tag}`, snapshot);\n\t\t\treturn snapshot;\n\t\t},\n\t\tfindByHeader(displayPath: string, tag: string): HashlineSnapshot | undefined {\n\t\t\treturn headers.get(`${displayPath}\\0${tag.toUpperCase()}`);\n\t\t},\n\t};\n}\n\nexport function recordHashlineSnapshot(absolutePath: string, cwd: string, content: string, store: HashlineSnapshotStore): HashlineSnapshot {\n\treturn store.record(absolutePath, cwd, content);\n}\n\nexport function formatHashlineContent(snapshot: HashlineSnapshot, content = snapshot.content, startLine = 1): string {\n\treturn [formatHashlineHeader(snapshot.displayPath, snapshot.tag), formatNumberedLines(normalizeHashlineContent(content), startLine)].join(\"\\n\");\n}\n\nexport interface StrippedHashlineContent { content: string; stripped: boolean }\n\nexport function stripKnownHashlineCopiedContentWithMeta(content: string, _absolutePath: string, _cwd: string, store: HashlineSnapshotStore): StrippedHashlineContent {\n\tconst normalized = normalizeHashlineContent(content);\n\tconst lines = normalized.split(\"\\n\");\n\tconst headerIndex = lines.findIndex((line, index) => /^\\[[^\\]\\n]+#[0-9A-Fa-f]{4}\\]$/.test(line) && lines.slice(0, index).every((prefix) => prefix.trim() === \"\" || /^#\\s+.+\\/?$/.test(prefix)));\n\tif (headerIndex < 0) return { content, stripped: false };\n\tconst header = (lines[headerIndex] ?? \"\").match(/^\\[([^\\]\\n]+)#([0-9A-Fa-f]{4})\\]$/);\n\tif (!header) return { content, stripped: false };\n\tconst snapshot = store.findByHeader(header[1] ?? \"\", header[2] ?? \"\");\n\tif (!snapshot) return { content, stripped: false };\n\tconst body = lines.slice(headerIndex + 1);\n\tif (body.length === 0) return { content: snapshot.content, stripped: true };\n\tconst stripped: string[] = [];\n\tconst snapshotLines = snapshot.content.split(\"\\n\");\n\tlet sawRow = false;\n\t// Trailing tool chrome a model is likely to copy along with the hashline\n\t// body: the read/search continuation footers, the write tool's own\n\t// `Successfully wrote N bytes to <path>` confirmation (and its stripped-\n\t// note), and `Resolved …` conflict footers. These never carry a line\n\t// number, so they mark the end of the numbered body — they must not abort\n\t// stripping the way an arbitrary non-row line would.\n\tconst isToolFooter = (line: string): boolean =>\n\t\tline.trim() === \"\"\n\t\t|| /^\\[\\d+ more lines in file\\./.test(line)\n\t\t|| /^\\[Showing lines /.test(line)\n\t\t|| /^Successfully wrote \\d+ bytes to /.test(line)\n\t\t|| /^Resolved \\d+ conflicts?/.test(line)\n\t\t|| /^Resolved conflict \\d+/.test(line)\n\t\t|| /^Note: stripped copied hashline/.test(line)\n\t\t|| /^\\[[^\\]\\n]+#[0-9A-Fa-f]{4}\\]$/.test(line);\n\tlet onlyFooter = true;\n\tfor (const line of body) {\n\t\tif (isToolFooter(line)) {\n\t\t\t// A footer after the numbered body ends the body; a footer before any\n\t\t\t// row (leading blanks / a copied snapshot header) is just skipped.\n\t\t\tif (sawRow) break;\n\t\t\tcontinue;\n\t\t}\n\t\tonlyFooter = false;\n\t\tconst match = line.match(/^[* ]?(\\d+):(.*)$/s);\n\t\tif (!match) return { content, stripped: false };\n\t\tsawRow = true;\n\t\tconst lineNumber = Number.parseInt(match[1] ?? \"0\", 10);\n\t\tconst strippedLine = match[2] ?? \"\";\n\t\tif (snapshotLines[lineNumber - 1] !== strippedLine) return { content, stripped: false };\n\t\tstripped.push(strippedLine);\n\t}\n\tif (sawRow) return { content: stripped.join(\"\\n\"), stripped: true };\n\t// Header + only tool chrome (e.g. a copied write confirmation\n\t// `Successfully wrote N bytes to <path>`) names a known snapshot with no\n\t// numbered body to recover — resolve to the snapshot's stored content.\n\tif (onlyFooter) return { content: snapshot.content, stripped: true };\n\treturn { content, stripped: false };\n}\n\nexport function stripKnownHashlineCopiedContent(content: string, absolutePath: string, cwd: string, store: HashlineSnapshotStore): string {\n\treturn stripKnownHashlineCopiedContentWithMeta(content, absolutePath, cwd, store).content;\n}\n\nexport function formatCompactHashlineEditResult(snapshot: HashlineSnapshot, diff: { diff?: string; firstChangedLine?: number }, messages: readonly string[] = []): string {\n\treturn [formatHashlineHeader(snapshot.displayPath, snapshot.tag), ...messages, diff.diff?.trim() || `First changed line: ${diff.firstChangedLine ?? 1}`].join(\"\\n\");\n}\n"]}
@@ -0,0 +1,110 @@
1
+ import { computeFileHash, formatHashlineHeader, formatNumberedLines, InMemorySnapshotStore } from "./hashline-engine/index.js";
2
+ import { isAbsolute, normalize as normalizePath, relative, sep } from "node:path";
3
+ function toPosixPath(filePath) {
4
+ return filePath.split(sep).join("/");
5
+ }
6
+ export function hashlineDisplayPath(absolutePath, cwd) {
7
+ const relativePath = relative(cwd, absolutePath);
8
+ if (relativePath && !relativePath.startsWith("..") && !isAbsolute(relativePath))
9
+ return toPosixPath(relativePath);
10
+ return toPosixPath(absolutePath);
11
+ }
12
+ export function normalizeHashlineContent(content) {
13
+ return content.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
14
+ }
15
+ export function computeHashlineTag(content) {
16
+ return computeFileHash(normalizeHashlineContent(content));
17
+ }
18
+ export function createHashlineSnapshotStore() {
19
+ const snapshots = new InMemorySnapshotStore();
20
+ const headers = new Map();
21
+ return {
22
+ snapshots,
23
+ record(absolutePath, cwd, content) {
24
+ const normalizedPath = normalizePath(absolutePath);
25
+ const normalized = normalizeHashlineContent(content);
26
+ const displayPath = hashlineDisplayPath(normalizedPath, cwd);
27
+ const tag = snapshots.record(normalizedPath, normalized);
28
+ const snapshot = { absolutePath: normalizedPath, displayPath, tag, content: normalized };
29
+ headers.set(`${displayPath}\0${tag}`, snapshot);
30
+ return snapshot;
31
+ },
32
+ findByHeader(displayPath, tag) {
33
+ return headers.get(`${displayPath}\0${tag.toUpperCase()}`);
34
+ },
35
+ };
36
+ }
37
+ export function recordHashlineSnapshot(absolutePath, cwd, content, store) {
38
+ return store.record(absolutePath, cwd, content);
39
+ }
40
+ export function formatHashlineContent(snapshot, content = snapshot.content, startLine = 1) {
41
+ return [formatHashlineHeader(snapshot.displayPath, snapshot.tag), formatNumberedLines(normalizeHashlineContent(content), startLine)].join("\n");
42
+ }
43
+ export function stripKnownHashlineCopiedContentWithMeta(content, _absolutePath, _cwd, store) {
44
+ const normalized = normalizeHashlineContent(content);
45
+ const lines = normalized.split("\n");
46
+ const headerIndex = lines.findIndex((line, index) => /^\[[^\]\n]+#[0-9A-Fa-f]{4}\]$/.test(line) && lines.slice(0, index).every((prefix) => prefix.trim() === "" || /^#\s+.+\/?$/.test(prefix)));
47
+ if (headerIndex < 0)
48
+ return { content, stripped: false };
49
+ const header = (lines[headerIndex] ?? "").match(/^\[([^\]\n]+)#([0-9A-Fa-f]{4})\]$/);
50
+ if (!header)
51
+ return { content, stripped: false };
52
+ const snapshot = store.findByHeader(header[1] ?? "", header[2] ?? "");
53
+ if (!snapshot)
54
+ return { content, stripped: false };
55
+ const body = lines.slice(headerIndex + 1);
56
+ if (body.length === 0)
57
+ return { content: snapshot.content, stripped: true };
58
+ const stripped = [];
59
+ const snapshotLines = snapshot.content.split("\n");
60
+ let sawRow = false;
61
+ // Trailing tool chrome a model is likely to copy along with the hashline
62
+ // body: the read/search continuation footers, the write tool's own
63
+ // `Successfully wrote N bytes to <path>` confirmation (and its stripped-
64
+ // note), and `Resolved …` conflict footers. These never carry a line
65
+ // number, so they mark the end of the numbered body — they must not abort
66
+ // stripping the way an arbitrary non-row line would.
67
+ const isToolFooter = (line) => line.trim() === ""
68
+ || /^\[\d+ more lines in file\./.test(line)
69
+ || /^\[Showing lines /.test(line)
70
+ || /^Successfully wrote \d+ bytes to /.test(line)
71
+ || /^Resolved \d+ conflicts?/.test(line)
72
+ || /^Resolved conflict \d+/.test(line)
73
+ || /^Note: stripped copied hashline/.test(line)
74
+ || /^\[[^\]\n]+#[0-9A-Fa-f]{4}\]$/.test(line);
75
+ let onlyFooter = true;
76
+ for (const line of body) {
77
+ if (isToolFooter(line)) {
78
+ // A footer after the numbered body ends the body; a footer before any
79
+ // row (leading blanks / a copied snapshot header) is just skipped.
80
+ if (sawRow)
81
+ break;
82
+ continue;
83
+ }
84
+ onlyFooter = false;
85
+ const match = line.match(/^[* ]?(\d+):(.*)$/s);
86
+ if (!match)
87
+ return { content, stripped: false };
88
+ sawRow = true;
89
+ const lineNumber = Number.parseInt(match[1] ?? "0", 10);
90
+ const strippedLine = match[2] ?? "";
91
+ if (snapshotLines[lineNumber - 1] !== strippedLine)
92
+ return { content, stripped: false };
93
+ stripped.push(strippedLine);
94
+ }
95
+ if (sawRow)
96
+ return { content: stripped.join("\n"), stripped: true };
97
+ // Header + only tool chrome (e.g. a copied write confirmation
98
+ // `Successfully wrote N bytes to <path>`) names a known snapshot with no
99
+ // numbered body to recover — resolve to the snapshot's stored content.
100
+ if (onlyFooter)
101
+ return { content: snapshot.content, stripped: true };
102
+ return { content, stripped: false };
103
+ }
104
+ export function stripKnownHashlineCopiedContent(content, absolutePath, cwd, store) {
105
+ return stripKnownHashlineCopiedContentWithMeta(content, absolutePath, cwd, store).content;
106
+ }
107
+ export function formatCompactHashlineEditResult(snapshot, diff, messages = []) {
108
+ return [formatHashlineHeader(snapshot.displayPath, snapshot.tag), ...messages, diff.diff?.trim() || `First changed line: ${diff.firstChangedLine ?? 1}`].join("\n");
109
+ }
110
+ //# sourceMappingURL=hashline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashline.js","sourceRoot":"","sources":["../../../src/core/tools/hashline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,qBAAqB,EAAsB,MAAM,4BAA4B,CAAC;AACnJ,OAAO,EAAE,UAAU,EAAE,SAAS,IAAI,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAelF,SAAS,WAAW,CAAC,QAAgB;IACpC,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,YAAoB,EAAE,GAAW;IACpE,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACjD,IAAI,YAAY,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,WAAW,CAAC,YAAY,CAAC,CAAC;IAClH,OAAO,WAAW,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAAe;IACvD,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACnF,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAe;IACjD,OAAO,eAAe,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,2BAA2B;IAC1C,MAAM,SAAS,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAC9C,MAAM,OAAO,GAAG,IAAI,GAAG,EAA4B,CAAC;IACpD,OAAO;QACN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C,IAAI,aAAa,CAAC,UAAU,GAAG,CAAC,CAAC,KAAK,YAAY;YAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACxF,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,MAAM;QAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACpE,8DAA8D;IAC9D,yEAAyE;IACzE,uEAAuE;IACvE,IAAI,UAAU;QAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACrE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,OAAe,EAAE,YAAoB,EAAE,GAAW,EAAE,KAA4B;IAC/H,OAAO,uCAAuC,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC;AAC3F,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,QAA0B,EAAE,IAAkD,EAAE,QAAQ,GAAsB,EAAE;IAC/J,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,uBAAuB,IAAI,CAAC,gBAAgB,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrK,CAAC","sourcesContent":["import { computeFileHash, formatHashlineHeader, formatNumberedLines, InMemorySnapshotStore, type SnapshotStore } from \"./hashline-engine/index.ts\";\nimport { isAbsolute, normalize as normalizePath, relative, sep } from \"node:path\";\n\nexport interface HashlineSnapshot {\n\tabsolutePath: string;\n\tdisplayPath: string;\n\ttag: string;\n\tcontent: string;\n}\n\nexport interface HashlineSnapshotStore {\n\treadonly snapshots: SnapshotStore;\n\trecord(absolutePath: string, cwd: string, content: string): HashlineSnapshot;\n\tfindByHeader(displayPath: string, tag: string): HashlineSnapshot | undefined;\n}\n\nfunction toPosixPath(filePath: string): string {\n\treturn filePath.split(sep).join(\"/\");\n}\n\nexport function hashlineDisplayPath(absolutePath: string, cwd: string): string {\n\tconst relativePath = relative(cwd, absolutePath);\n\tif (relativePath && !relativePath.startsWith(\"..\") && !isAbsolute(relativePath)) return toPosixPath(relativePath);\n\treturn toPosixPath(absolutePath);\n}\n\nexport function normalizeHashlineContent(content: string): string {\n\treturn content.replace(/^\\uFEFF/, \"\").replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n}\n\nexport function computeHashlineTag(content: string): string {\n\treturn computeFileHash(normalizeHashlineContent(content));\n}\n\nexport function createHashlineSnapshotStore(): HashlineSnapshotStore {\n\tconst snapshots = new InMemorySnapshotStore();\n\tconst headers = new Map<string, HashlineSnapshot>();\n\treturn {\n\t\tsnapshots,\n\t\trecord(absolutePath: string, cwd: string, content: string): HashlineSnapshot {\n\t\t\tconst normalizedPath = normalizePath(absolutePath);\n\t\t\tconst normalized = normalizeHashlineContent(content);\n\t\t\tconst displayPath = hashlineDisplayPath(normalizedPath, cwd);\n\t\t\tconst tag = snapshots.record(normalizedPath, normalized);\n\t\t\tconst snapshot = { absolutePath: normalizedPath, displayPath, tag, content: normalized };\n\t\t\theaders.set(`${displayPath}\\0${tag}`, snapshot);\n\t\t\treturn snapshot;\n\t\t},\n\t\tfindByHeader(displayPath: string, tag: string): HashlineSnapshot | undefined {\n\t\t\treturn headers.get(`${displayPath}\\0${tag.toUpperCase()}`);\n\t\t},\n\t};\n}\n\nexport function recordHashlineSnapshot(absolutePath: string, cwd: string, content: string, store: HashlineSnapshotStore): HashlineSnapshot {\n\treturn store.record(absolutePath, cwd, content);\n}\n\nexport function formatHashlineContent(snapshot: HashlineSnapshot, content = snapshot.content, startLine = 1): string {\n\treturn [formatHashlineHeader(snapshot.displayPath, snapshot.tag), formatNumberedLines(normalizeHashlineContent(content), startLine)].join(\"\\n\");\n}\n\nexport interface StrippedHashlineContent { content: string; stripped: boolean }\n\nexport function stripKnownHashlineCopiedContentWithMeta(content: string, _absolutePath: string, _cwd: string, store: HashlineSnapshotStore): StrippedHashlineContent {\n\tconst normalized = normalizeHashlineContent(content);\n\tconst lines = normalized.split(\"\\n\");\n\tconst headerIndex = lines.findIndex((line, index) => /^\\[[^\\]\\n]+#[0-9A-Fa-f]{4}\\]$/.test(line) && lines.slice(0, index).every((prefix) => prefix.trim() === \"\" || /^#\\s+.+\\/?$/.test(prefix)));\n\tif (headerIndex < 0) return { content, stripped: false };\n\tconst header = (lines[headerIndex] ?? \"\").match(/^\\[([^\\]\\n]+)#([0-9A-Fa-f]{4})\\]$/);\n\tif (!header) return { content, stripped: false };\n\tconst snapshot = store.findByHeader(header[1] ?? \"\", header[2] ?? \"\");\n\tif (!snapshot) return { content, stripped: false };\n\tconst body = lines.slice(headerIndex + 1);\n\tif (body.length === 0) return { content: snapshot.content, stripped: true };\n\tconst stripped: string[] = [];\n\tconst snapshotLines = snapshot.content.split(\"\\n\");\n\tlet sawRow = false;\n\t// Trailing tool chrome a model is likely to copy along with the hashline\n\t// body: the read/search continuation footers, the write tool's own\n\t// `Successfully wrote N bytes to <path>` confirmation (and its stripped-\n\t// note), and `Resolved …` conflict footers. These never carry a line\n\t// number, so they mark the end of the numbered body — they must not abort\n\t// stripping the way an arbitrary non-row line would.\n\tconst isToolFooter = (line: string): boolean =>\n\t\tline.trim() === \"\"\n\t\t|| /^\\[\\d+ more lines in file\\./.test(line)\n\t\t|| /^\\[Showing lines /.test(line)\n\t\t|| /^Successfully wrote \\d+ bytes to /.test(line)\n\t\t|| /^Resolved \\d+ conflicts?/.test(line)\n\t\t|| /^Resolved conflict \\d+/.test(line)\n\t\t|| /^Note: stripped copied hashline/.test(line)\n\t\t|| /^\\[[^\\]\\n]+#[0-9A-Fa-f]{4}\\]$/.test(line);\n\tlet onlyFooter = true;\n\tfor (const line of body) {\n\t\tif (isToolFooter(line)) {\n\t\t\t// A footer after the numbered body ends the body; a footer before any\n\t\t\t// row (leading blanks / a copied snapshot header) is just skipped.\n\t\t\tif (sawRow) break;\n\t\t\tcontinue;\n\t\t}\n\t\tonlyFooter = false;\n\t\tconst match = line.match(/^[* ]?(\\d+):(.*)$/s);\n\t\tif (!match) return { content, stripped: false };\n\t\tsawRow = true;\n\t\tconst lineNumber = Number.parseInt(match[1] ?? \"0\", 10);\n\t\tconst strippedLine = match[2] ?? \"\";\n\t\tif (snapshotLines[lineNumber - 1] !== strippedLine) return { content, stripped: false };\n\t\tstripped.push(strippedLine);\n\t}\n\tif (sawRow) return { content: stripped.join(\"\\n\"), stripped: true };\n\t// Header + only tool chrome (e.g. a copied write confirmation\n\t// `Successfully wrote N bytes to <path>`) names a known snapshot with no\n\t// numbered body to recover — resolve to the snapshot's stored content.\n\tif (onlyFooter) return { content: snapshot.content, stripped: true };\n\treturn { content, stripped: false };\n}\n\nexport function stripKnownHashlineCopiedContent(content: string, absolutePath: string, cwd: string, store: HashlineSnapshotStore): string {\n\treturn stripKnownHashlineCopiedContentWithMeta(content, absolutePath, cwd, store).content;\n}\n\nexport function formatCompactHashlineEditResult(snapshot: HashlineSnapshot, diff: { diff?: string; firstChangedLine?: number }, messages: readonly string[] = []): string {\n\treturn [formatHashlineHeader(snapshot.displayPath, snapshot.tag), ...messages, diff.diff?.trim() || `First changed line: ${diff.firstChangedLine ?? 1}`].join(\"\\n\");\n}\n"]}
@@ -2,7 +2,7 @@ export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type Ba
2
2
  export { createEditTool, createEditToolDefinition, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, } from "./edit.ts";
3
3
  export { withFileMutationQueue } from "./file-mutation-queue.ts";
4
4
  export { createFindTool, createFindToolDefinition, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, } from "./find.ts";
5
- export { createGrepTool, createGrepToolDefinition, type GrepOperations, type GrepToolDetails, type GrepToolInput, type GrepToolOptions, } from "./grep.ts";
5
+ export { createSearchTool, createSearchToolDefinition, type SearchToolDetails, type SearchToolInput, type SearchToolOptions, } from "./search.ts";
6
6
  export { createLsTool, createLsToolDefinition, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, } from "./ls.ts";
7
7
  export { createReadTool, createReadToolDefinition, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, } from "./read.ts";
8
8
  export { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationOptions, type TruncationResult, truncateHead, truncateLine, truncateTail, } from "./truncate.ts";
@@ -13,16 +13,17 @@ export { createTodoToolDefinition } from "./todos.ts";
13
13
  import type { AgentTool } from "@earendil-works/pi-agent-core";
14
14
  import type { TSchema } from "typebox";
15
15
  import type { ToolDefinition } from "../extensions/types.ts";
16
+ import { type HashlineSnapshotStore } from "./hashline.ts";
16
17
  import { type BashToolOptions } from "./bash.ts";
17
18
  import { type EditToolOptions } from "./edit.ts";
18
19
  import { type FindToolOptions } from "./find.ts";
19
- import { type GrepToolOptions } from "./grep.ts";
20
20
  import { type LsToolOptions } from "./ls.ts";
21
+ import { type SearchToolOptions } from "./search.ts";
21
22
  import { type ReadToolOptions } from "./read.ts";
22
23
  import { type WriteToolOptions } from "./write.ts";
23
24
  export type Tool = AgentTool<TSchema, unknown>;
24
25
  export type ToolDef = ToolDefinition<TSchema, unknown>;
25
- export type ToolName = "read" | "bash" | "edit" | "write" | "grep" | "find" | "ls" | "ask_user_question" | "todo";
26
+ export type ToolName = "read" | "bash" | "edit" | "write" | "find" | "search" | "ls" | "ask_user_question" | "todo";
26
27
  export declare const allToolNames: Set<ToolName>;
27
28
  export declare const defaultToolNames: readonly ToolName[];
28
29
  export interface ToolsOptions {
@@ -30,9 +31,10 @@ export interface ToolsOptions {
30
31
  bash?: BashToolOptions;
31
32
  write?: WriteToolOptions;
32
33
  edit?: EditToolOptions;
33
- grep?: GrepToolOptions;
34
34
  find?: FindToolOptions;
35
+ search?: SearchToolOptions;
35
36
  ls?: LsToolOptions;
37
+ hashlineStore?: HashlineSnapshotStore;
36
38
  }
37
39
  export declare function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef;
38
40
  export declare function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB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AG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAY1F","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\nexport { createAskUserQuestionToolDefinition } from \"./ask-user-question/index.ts\";\nexport {\n\tSTRUCTURED_OUTPUT_TOOL_NAME,\n\tcreateStructuredOutputCapture,\n\tcreateStructuredOutputTool,\n\ttype JsonObject,\n\ttype JsonPrimitive,\n\ttype JsonValue,\n\ttype StructuredOutputCapture,\n\ttype StructuredOutputFileCapture,\n\ttype StructuredOutputToolOptions,\n} from \"./structured-output.ts\";\nexport { createTodoToolDefinition } from \"./todos.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { TSchema } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { createAskUserQuestionToolDefinition } from \"./ask-user-question/index.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createTodoToolDefinition } from \"./todos.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<TSchema, unknown>;\nexport type ToolDef = ToolDefinition<TSchema, unknown>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"grep\"\n\t| \"find\"\n\t| \"ls\"\n\t| \"ask_user_question\"\n\t| \"todo\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"ask_user_question\",\n\t\"todo\",\n]);\n\nexport const defaultToolNames: readonly ToolName[] = [\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"ask_user_question\",\n\t\"todo\",\n];\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"ask_user_question\":\n\t\t\treturn createAskUserQuestionToolDefinition();\n\t\tcase \"todo\":\n\t\t\treturn createTodoToolDefinition(cwd);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"ask_user_question\":\n\t\t\treturn wrapToolDefinition(createAskUserQuestionToolDefinition());\n\t\tcase \"todo\":\n\t\t\treturn wrapToolDefinition(createTodoToolDefinition(cwd));\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\task_user_question: createAskUserQuestionToolDefinition(),\n\t\ttodo: createTodoToolDefinition(cwd),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\task_user_question: wrapToolDefinition(createAskUserQuestionToolDefinition()),\n\t\ttodo: wrapToolDefinition(createTodoToolDefinition(cwd)),\n\t};\n}\n"]}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN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AAQ,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAwBxF;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAU1F;AAED,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAQ5F;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAavG;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAU7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAQ/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAa1F","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateSearchTool,\n\tcreateSearchToolDefinition,\n\ttype SearchToolDetails,\n\ttype SearchToolInput,\n\ttype SearchToolOptions,\n} from \"./search.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\nexport { createAskUserQuestionToolDefinition } from \"./ask-user-question/index.ts\";\nexport {\n\tSTRUCTURED_OUTPUT_TOOL_NAME,\n\tcreateStructuredOutputCapture,\n\tcreateStructuredOutputTool,\n\ttype JsonObject,\n\ttype JsonPrimitive,\n\ttype JsonValue,\n\ttype StructuredOutputCapture,\n\ttype StructuredOutputFileCapture,\n\ttype StructuredOutputToolOptions,\n} from \"./structured-output.ts\";\nexport { createTodoToolDefinition } from \"./todos.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { TSchema } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { createAskUserQuestionToolDefinition } from \"./ask-user-question/index.ts\";\nimport { createHashlineSnapshotStore, type HashlineSnapshotStore } from \"./hashline.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createSearchTool, createSearchToolDefinition, type SearchToolOptions } from \"./search.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createTodoToolDefinition } from \"./todos.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<TSchema, unknown>;\nexport type ToolDef = ToolDefinition<TSchema, unknown>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"find\"\n\t| \"search\"\n\t| \"ls\"\n\t| \"ask_user_question\"\n\t| \"todo\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"find\",\n\t\"search\",\n\t\"ls\",\n\t\"ask_user_question\",\n\t\"todo\",\n]);\n\nexport const defaultToolNames: readonly ToolName[] = [\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"find\",\n\t\"search\",\n\t\"ask_user_question\",\n\t\"todo\",\n];\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tfind?: FindToolOptions;\n\tsearch?: SearchToolOptions;\n\tls?: LsToolOptions;\n\thashlineStore?: HashlineSnapshotStore;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\t// Default a shared store so the singular factories don't hand read/edit/\n\t// write/search isolated stores (which silently degrades drift recovery).\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, { ...options?.read, hashlineStore });\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, { ...options?.edit, hashlineStore });\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, { ...options?.write, hashlineStore });\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"search\":\n\t\t\treturn createSearchToolDefinition(cwd, { ...options?.search, hashlineStore });\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"ask_user_question\":\n\t\t\treturn createAskUserQuestionToolDefinition();\n\t\tcase \"todo\":\n\t\t\treturn createTodoToolDefinition(cwd);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, { ...options?.read, hashlineStore });\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, { ...options?.edit, hashlineStore });\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, { ...options?.write, hashlineStore });\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"search\":\n\t\t\treturn createSearchTool(cwd, { ...options?.search, hashlineStore });\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"ask_user_question\":\n\t\t\treturn wrapToolDefinition(createAskUserQuestionToolDefinition());\n\t\tcase \"todo\":\n\t\t\treturn wrapToolDefinition(createTodoToolDefinition(cwd));\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn [\n\t\tcreateReadToolDefinition(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateBashToolDefinition(cwd, { asyncEnabled: true, ...options?.bash }),\n\t\tcreateEditToolDefinition(cwd, { ...options?.edit, hashlineStore }),\n\t\tcreateWriteToolDefinition(cwd, { ...options?.write, hashlineStore }),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn [\n\t\tcreateReadToolDefinition(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn {\n\t\tread: createReadToolDefinition(cwd, { ...options?.read, hashlineStore }),\n\t\tbash: createBashToolDefinition(cwd, { asyncEnabled: true, ...options?.bash }),\n\t\tedit: createEditToolDefinition(cwd, { ...options?.edit, hashlineStore }),\n\t\twrite: createWriteToolDefinition(cwd, { ...options?.write, hashlineStore }),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tsearch: createSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\task_user_question: createAskUserQuestionToolDefinition(),\n\t\ttodo: createTodoToolDefinition(cwd),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn [\n\t\tcreateReadTool(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateBashTool(cwd, { asyncEnabled: true, ...options?.bash }),\n\t\tcreateEditTool(cwd, { ...options?.edit, hashlineStore }),\n\t\tcreateWriteTool(cwd, { ...options?.write, hashlineStore }),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateSearchTool(cwd, { ...options?.search, hashlineStore }),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn [\n\t\tcreateReadTool(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateSearchTool(cwd, { ...options?.search, hashlineStore }),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn {\n\t\tread: createReadTool(cwd, { ...options?.read, hashlineStore }),\n\t\tbash: createBashTool(cwd, { asyncEnabled: true, ...options?.bash }),\n\t\tedit: createEditTool(cwd, { ...options?.edit, hashlineStore }),\n\t\twrite: createWriteTool(cwd, { ...options?.write, hashlineStore }),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tsearch: createSearchTool(cwd, { ...options?.search, hashlineStore }),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\task_user_question: wrapToolDefinition(createAskUserQuestionToolDefinition()),\n\t\ttodo: wrapToolDefinition(createTodoToolDefinition(cwd)),\n\t};\n}\n"]}