@bastani/atomic 0.9.19-alpha.5 → 0.9.19-alpha.7

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 (209) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +2 -2
  3. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  4. package/dist/builtin/intercom/broker/client.ts +19 -1
  5. package/dist/builtin/intercom/index.bundle.mjs +8 -1
  6. package/dist/builtin/intercom/package.json +1 -1
  7. package/dist/builtin/mcp/package.json +1 -1
  8. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  9. package/dist/builtin/subagents/README.md +3 -1
  10. package/dist/builtin/subagents/agents/codebase-online-researcher.md +7 -7
  11. package/dist/builtin/subagents/package.json +1 -1
  12. package/dist/builtin/subagents/skills/subagent/SKILL.md +3 -1
  13. package/dist/builtin/subagents/src/extension/index.bundle.mjs +2 -1
  14. package/dist/builtin/web-access/CHANGELOG.md +13 -0
  15. package/dist/builtin/web-access/README.md +31 -24
  16. package/dist/builtin/web-access/index.bundle.mjs +16121 -80
  17. package/dist/builtin/web-access/package.json +2 -1
  18. package/dist/builtin/workflows/CHANGELOG.md +15 -0
  19. package/dist/builtin/workflows/README.md +1 -1
  20. package/dist/builtin/workflows/builtin/adversarial-verification.js +2 -2
  21. package/dist/builtin/workflows/builtin/{chunk-vhmnzdj9.js → chunk-1jth021m.js} +1 -1
  22. package/dist/builtin/workflows/builtin/{chunk-p8jjwfg6.js → chunk-2377r57g.js} +4 -2
  23. package/dist/builtin/workflows/builtin/{chunk-hbnwv56f.js → chunk-31j2gs7h.js} +2 -2
  24. package/dist/builtin/workflows/builtin/{chunk-n8zysf1t.js → chunk-ngkqkzej.js} +1 -1
  25. package/dist/builtin/workflows/builtin/{chunk-1nbq96fh.js → chunk-nkrafh9s.js} +1 -1
  26. package/dist/builtin/workflows/builtin/{chunk-1kx4aggw.js → chunk-wf741bv3.js} +2 -2
  27. package/dist/builtin/workflows/builtin/{chunk-t6x2d78s.js → chunk-z29qbehr.js} +1 -1
  28. package/dist/builtin/workflows/builtin/generate-and-filter.js +2 -2
  29. package/dist/builtin/workflows/builtin/goal.js +3 -3
  30. package/dist/builtin/workflows/builtin/index.js +7 -7
  31. package/dist/builtin/workflows/builtin/ralph.js +3 -3
  32. package/dist/builtin/workflows/builtin/tournament.js +2 -2
  33. package/dist/builtin/workflows/package.json +1 -1
  34. package/dist/builtin/workflows/src/extension/index.bundle.mjs +339 -31
  35. package/dist/builtin/workflows/src/index.js +67 -19
  36. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +2 -0
  37. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  38. package/dist/core/agent-session-tool-registry.js +10 -0
  39. package/dist/core/agent-session-tool-registry.js.map +1 -1
  40. package/dist/core/bash-executor.js.map +1 -1
  41. package/dist/core/tools/bash.d.ts +1 -1
  42. package/dist/core/tools/bash.d.ts.map +1 -1
  43. package/dist/core/tools/bash.js +3 -2
  44. package/dist/core/tools/bash.js.map +1 -1
  45. package/dist/core/tools/edit.d.ts +3 -0
  46. package/dist/core/tools/edit.d.ts.map +1 -1
  47. package/dist/core/tools/edit.js +91 -12
  48. package/dist/core/tools/edit.js.map +1 -1
  49. package/dist/core/tools/file-mutation-coordinator.d.ts +255 -0
  50. package/dist/core/tools/file-mutation-coordinator.d.ts.map +1 -0
  51. package/dist/core/tools/file-mutation-coordinator.js +300 -0
  52. package/dist/core/tools/file-mutation-coordinator.js.map +1 -0
  53. package/dist/core/tools/file-mutation-queue.d.ts +14 -1
  54. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  55. package/dist/core/tools/file-mutation-queue.js +15 -3
  56. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  57. package/dist/core/tools/hashline.d.ts +9 -0
  58. package/dist/core/tools/hashline.d.ts.map +1 -1
  59. package/dist/core/tools/hashline.js +12 -1
  60. package/dist/core/tools/hashline.js.map +1 -1
  61. package/dist/core/tools/index.d.ts +9 -1
  62. package/dist/core/tools/index.d.ts.map +1 -1
  63. package/dist/core/tools/index.js +67 -12
  64. package/dist/core/tools/index.js.map +1 -1
  65. package/dist/core/tools/non-minting-snapshot-store.d.ts +49 -0
  66. package/dist/core/tools/non-minting-snapshot-store.d.ts.map +1 -0
  67. package/dist/core/tools/non-minting-snapshot-store.js +64 -0
  68. package/dist/core/tools/non-minting-snapshot-store.js.map +1 -0
  69. package/dist/core/tools/powershell.d.ts +2 -2
  70. package/dist/core/tools/powershell.d.ts.map +1 -1
  71. package/dist/core/tools/powershell.js +2 -5
  72. package/dist/core/tools/powershell.js.map +1 -1
  73. package/dist/core/tools/read-document-extract.js.map +1 -1
  74. package/dist/core/tools/render-utils.js.map +1 -1
  75. package/dist/core/tools/write.d.ts +30 -1
  76. package/dist/core/tools/write.d.ts.map +1 -1
  77. package/dist/core/tools/write.js +97 -8
  78. package/dist/core/tools/write.js.map +1 -1
  79. package/dist/index.d.ts +1 -1
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js.map +1 -1
  82. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  83. package/dist/modes/interactive/components/task-live-transcript.d.ts +1 -1
  84. package/dist/modes/interactive/components/task-live-transcript.d.ts.map +1 -1
  85. package/dist/modes/interactive/components/task-live-transcript.js +19 -11
  86. package/dist/modes/interactive/components/task-live-transcript.js.map +1 -1
  87. package/dist/modes/interactive/interactive-mode-base.d.ts +1 -0
  88. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  89. package/dist/modes/interactive/interactive-mode-base.js +3 -1
  90. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  91. package/dist/modes/interactive/interactive-mode-surface.d.ts +1 -1
  92. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  93. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  94. package/dist/modes/interactive/interactive-render-chat.js +28 -4
  95. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  96. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  97. package/dist/modes/interactive/interactive-startup.js +3 -0
  98. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  99. package/dist/modes/interactive-engine/activity-watchdog.d.ts +2 -2
  100. package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -1
  101. package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
  102. package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts +3 -1
  103. package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts.map +1 -1
  104. package/dist/modes/interactive-engine/engine-diagnostic-view.js +11 -0
  105. package/dist/modes/interactive-engine/engine-diagnostic-view.js.map +1 -1
  106. package/dist/modes/interactive-engine/isolated-runtime.js +2 -1
  107. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  108. package/dist/modes/rpc/rpc-client-process.d.ts +2 -0
  109. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  110. package/dist/modes/rpc/rpc-client-process.js +23 -1
  111. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  112. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  113. package/dist/modes/rpc/rpc-client.js +20 -3
  114. package/dist/modes/rpc/rpc-client.js.map +1 -1
  115. package/dist/utils/markit.d.ts +2 -0
  116. package/dist/utils/markit.d.ts.map +1 -1
  117. package/dist/utils/markit.js +65 -5
  118. package/dist/utils/markit.js.map +1 -1
  119. package/docs/background-tasks.md +15 -11
  120. package/docs/build.md +51 -0
  121. package/docs/changelog.mdx +8 -8
  122. package/docs/compaction/reference.md +267 -0
  123. package/docs/compaction.md +36 -219
  124. package/docs/computer-use.md +35 -0
  125. package/docs/containerization.md +9 -5
  126. package/docs/custom-provider/api-reference.md +145 -0
  127. package/docs/custom-provider/oauth.md +131 -0
  128. package/docs/custom-provider/override.md +34 -0
  129. package/docs/custom-provider/registration.md +163 -0
  130. package/docs/custom-provider/streaming.md +214 -0
  131. package/docs/custom-provider.md +43 -607
  132. package/docs/development.md +87 -0
  133. package/docs/docs.json +199 -76
  134. package/docs/environment-variables.md +1 -1
  135. package/docs/extensions/api-reference.md +1001 -0
  136. package/docs/extensions/authoring.md +676 -0
  137. package/docs/extensions/events.md +793 -0
  138. package/docs/extensions/examples.md +94 -0
  139. package/docs/extensions/ui.md +470 -0
  140. package/docs/extensions.md +270 -2768
  141. package/docs/getting-started/authentication.md +55 -0
  142. package/docs/getting-started/first-session.md +172 -0
  143. package/docs/getting-started/installation.md +154 -0
  144. package/docs/getting-started/project-instructions.md +43 -0
  145. package/docs/guides/configuration.md +65 -0
  146. package/docs/guides/intercom.md +24 -0
  147. package/docs/guides/non-interactive.md +33 -0
  148. package/docs/guides/subagents.md +24 -0
  149. package/docs/guides/workflows.md +27 -0
  150. package/docs/guides.md +41 -0
  151. package/docs/index.md +13 -45
  152. package/docs/intercom/operations.md +178 -0
  153. package/docs/intercom/reference.md +146 -0
  154. package/docs/intercom.md +54 -259
  155. package/docs/json.md +17 -0
  156. package/docs/llama-cpp.md +5 -0
  157. package/docs/models/artificial-analysis-index.md +89 -0
  158. package/docs/models/evals.md +2 -2
  159. package/docs/models/model-selection.md +3 -3
  160. package/docs/models/pareto-efficiency.md +2 -2
  161. package/docs/models/reference.md +601 -0
  162. package/docs/models.md +45 -550
  163. package/docs/packages/authoring.md +88 -0
  164. package/docs/packages/reference.md +43 -0
  165. package/docs/packages.md +28 -107
  166. package/docs/programmatic.md +29 -0
  167. package/docs/prompt-templates.md +11 -0
  168. package/docs/providers/reference.md +23 -0
  169. package/docs/providers.md +10 -15
  170. package/docs/quickstart.md +44 -238
  171. package/docs/reference/cli.md +252 -0
  172. package/docs/reference.md +52 -0
  173. package/docs/rpc/examples.md +64 -0
  174. package/docs/rpc/extension-ui.md +198 -0
  175. package/docs/rpc/protocol.md +1341 -0
  176. package/docs/rpc.md +109 -1346
  177. package/docs/sdk/reference.md +1090 -0
  178. package/docs/sdk.md +56 -1002
  179. package/docs/session-format.md +2 -0
  180. package/docs/sessions.md +6 -10
  181. package/docs/settings.md +6 -45
  182. package/docs/skills/authoring.md +95 -0
  183. package/docs/skills/reference.md +60 -0
  184. package/docs/skills.md +20 -122
  185. package/docs/subagents/authoring.md +37 -0
  186. package/docs/subagents/reference.md +60 -0
  187. package/docs/subagents.md +42 -96
  188. package/docs/terminal-setup.md +1 -1
  189. package/docs/themes/reference.md +176 -0
  190. package/docs/themes.md +21 -135
  191. package/docs/tmux.md +5 -0
  192. package/docs/tools/edit.md +5 -0
  193. package/docs/tools.md +31 -0
  194. package/docs/tui/reference.md +343 -0
  195. package/docs/tui.md +23 -286
  196. package/docs/usage.md +26 -209
  197. package/docs/web-access.md +40 -0
  198. package/docs/windows.md +2 -1
  199. package/docs/workflows/api-reference.md +11 -4
  200. package/docs/workflows/authoring.md +4 -2
  201. package/docs/workflows/builtins.md +2 -2
  202. package/docs/workflows/operations.md +11 -7
  203. package/docs/workflows/reliable-design.md +21 -3
  204. package/docs/workflows/verification.md +8 -0
  205. package/examples/extensions/gondolin/index.ts +116 -148
  206. package/examples/extensions/gondolin/package.json +1 -1
  207. package/examples/extensions/ssh.ts +56 -34
  208. package/npm-shrinkwrap.json +33 -33
  209. package/package.json +4 -4
@@ -1,6 +1,19 @@
1
+ /**
2
+ * Canonical key for a mutation target: absolute, and symlink-resolved when the path
3
+ * exists so an alias and its target share one queue. A not-yet-created file falls back to
4
+ * the resolved path, which is what lets `write` create files.
5
+ *
6
+ * Exported so callers that need to name the same target (diagnostics, coordination) cannot
7
+ * drift into a second normalizer.
8
+ */
9
+ export declare function canonicalMutationKey(filePath: string): Promise<string>;
1
10
  /**
2
11
  * Serialize file mutation operations targeting the same file.
3
12
  * Operations for different files still run in parallel.
13
+ *
14
+ * The holder is handed the canonical key this call registered under. Registration already
15
+ * paid for the `realpath`, so a holder that has to name its own target in a diagnostic takes
16
+ * the answer from here instead of resolving the path a second time under the lock.
4
17
  */
5
- export declare function withFileMutationQueue<T>(filePath: string, fn: () => Promise<T>): Promise<T>;
18
+ export declare function withFileMutationQueue<T>(filePath: string, fn: (canonicalKey: string) => Promise<T>): Promise<T>;
6
19
  //# sourceMappingURL=file-mutation-queue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-mutation-queue.d.ts","sourceRoot":"","sources":["../../../src/core/tools/file-mutation-queue.ts"],"names":[],"mappings":"AA2BA;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA6BjG"}
1
+ {"version":3,"file":"file-mutation-queue.d.ts","sourceRoot":"","sources":["../../../src/core/tools/file-mutation-queue.ts"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAU5E;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA6BrH"}
@@ -8,7 +8,15 @@ function isMissingPathError(error) {
8
8
  "code" in error &&
9
9
  (error.code === "ENOENT" || error.code === "ENOTDIR"));
10
10
  }
11
- async function getMutationQueueKey(filePath) {
11
+ /**
12
+ * Canonical key for a mutation target: absolute, and symlink-resolved when the path
13
+ * exists so an alias and its target share one queue. A not-yet-created file falls back to
14
+ * the resolved path, which is what lets `write` create files.
15
+ *
16
+ * Exported so callers that need to name the same target (diagnostics, coordination) cannot
17
+ * drift into a second normalizer.
18
+ */
19
+ export async function canonicalMutationKey(filePath) {
12
20
  const resolvedPath = resolve(filePath);
13
21
  try {
14
22
  return await realpath(resolvedPath);
@@ -23,10 +31,14 @@ async function getMutationQueueKey(filePath) {
23
31
  /**
24
32
  * Serialize file mutation operations targeting the same file.
25
33
  * Operations for different files still run in parallel.
34
+ *
35
+ * The holder is handed the canonical key this call registered under. Registration already
36
+ * paid for the `realpath`, so a holder that has to name its own target in a diagnostic takes
37
+ * the answer from here instead of resolving the path a second time under the lock.
26
38
  */
27
39
  export async function withFileMutationQueue(filePath, fn) {
28
40
  const registration = registrationQueue.then(async () => {
29
- const key = await getMutationQueueKey(filePath);
41
+ const key = await canonicalMutationKey(filePath);
30
42
  const currentQueue = fileMutationQueues.get(key) ?? Promise.resolve();
31
43
  let releaseNext;
32
44
  const nextQueue = new Promise((resolveQueue) => {
@@ -40,7 +52,7 @@ export async function withFileMutationQueue(filePath, fn) {
40
52
  const { key, currentQueue, chainedQueue, releaseNext } = await registration;
41
53
  await currentQueue;
42
54
  try {
43
- return await fn();
55
+ return await fn(key);
44
56
  }
45
57
  finally {
46
58
  releaseNext();
@@ -1 +1 @@
1
- {"version":3,"file":"file-mutation-queue.js","sourceRoot":"","sources":["../../../src/core/tools/file-mutation-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAyB,CAAC;AAC5D,IAAI,iBAAiB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;AAE1C,SAAS,kBAAkB,CAAC,KAAc;IACzC,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CACrD,CAAC;AACH,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,CAAC;QACJ,OAAO,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC;IACr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GAAG,CAAC,KAAK,YAAY,EAAE,CAAC;YAClD,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import { realpath } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nconst fileMutationQueues = new Map<string, Promise<void>>();\nlet registrationQueue = Promise.resolve();\n\nfunction isMissingPathError(error: unknown): boolean {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t\"code\" in error &&\n\t\t(error.code === \"ENOENT\" || error.code === \"ENOTDIR\")\n\t);\n}\n\nasync function getMutationQueueKey(filePath: string): Promise<string> {\n\tconst resolvedPath = resolve(filePath);\n\ttry {\n\t\treturn await realpath(resolvedPath);\n\t} catch (error) {\n\t\tif (isMissingPathError(error)) {\n\t\t\treturn resolvedPath;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * Serialize file mutation operations targeting the same file.\n * Operations for different files still run in parallel.\n */\nexport async function withFileMutationQueue<T>(filePath: string, fn: () => Promise<T>): Promise<T> {\n\tconst registration = registrationQueue.then(async () => {\n\t\tconst key = await getMutationQueueKey(filePath);\n\t\tconst currentQueue = fileMutationQueues.get(key) ?? Promise.resolve();\n\n\t\tlet releaseNext!: () => void;\n\t\tconst nextQueue = new Promise<void>((resolveQueue) => {\n\t\t\treleaseNext = resolveQueue;\n\t\t});\n\t\tconst chainedQueue = currentQueue.then(() => nextQueue);\n\t\tfileMutationQueues.set(key, chainedQueue);\n\n\t\treturn { key, currentQueue, chainedQueue, releaseNext };\n\t});\n\tregistrationQueue = registration.then(\n\t\t() => undefined,\n\t\t() => undefined,\n\t);\n\n\tconst { key, currentQueue, chainedQueue, releaseNext } = await registration;\n\tawait currentQueue;\n\ttry {\n\t\treturn await fn();\n\t} finally {\n\t\treleaseNext();\n\t\tif (fileMutationQueues.get(key) === chainedQueue) {\n\t\t\tfileMutationQueues.delete(key);\n\t\t}\n\t}\n}\n"]}
1
+ {"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B,MAAM,SAAS,GAAG,IAAI,OAAO,CAAO,CAAC,YAAY,EAAE,EAAE;YACpD,WAAW,GAAG,YAAY,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,MAAM,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACxD,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAE1C,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;IACH,iBAAiB,GAAG,YAAY,CAAC,IAAI,CACpC,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,SAAS,CACf,CAAC;IAEF,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,YAAY,CAAC;IAC5E,MAAM,YAAY,CAAC;IACnB,IAAI,CAAC;QACJ,OAAO,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;YAAS,CAAC;QACV,WAAW,EAAE,CAAC;QACd,IAAI,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,YAAY,EAAE,CAAC;YAClD,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import { realpath } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\n\nconst fileMutationQueues = new Map<string, Promise<void>>();\nlet registrationQueue = Promise.resolve();\n\nfunction isMissingPathError(error: unknown): boolean {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t\"code\" in error &&\n\t\t(error.code === \"ENOENT\" || error.code === \"ENOTDIR\")\n\t);\n}\n\n/**\n * Canonical key for a mutation target: absolute, and symlink-resolved when the path\n * exists so an alias and its target share one queue. A not-yet-created file falls back to\n * the resolved path, which is what lets `write` create files.\n *\n * Exported so callers that need to name the same target (diagnostics, coordination) cannot\n * drift into a second normalizer.\n */\nexport async function canonicalMutationKey(filePath: string): Promise<string> {\n\tconst resolvedPath = resolve(filePath);\n\ttry {\n\t\treturn await realpath(resolvedPath);\n\t} catch (error) {\n\t\tif (isMissingPathError(error)) {\n\t\t\treturn resolvedPath;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * Serialize file mutation operations targeting the same file.\n * Operations for different files still run in parallel.\n *\n * The holder is handed the canonical key this call registered under. Registration already\n * paid for the `realpath`, so a holder that has to name its own target in a diagnostic takes\n * the answer from here instead of resolving the path a second time under the lock.\n */\nexport async function withFileMutationQueue<T>(filePath: string, fn: (canonicalKey: string) => Promise<T>): Promise<T> {\n\tconst registration = registrationQueue.then(async () => {\n\t\tconst key = await canonicalMutationKey(filePath);\n\t\tconst currentQueue = fileMutationQueues.get(key) ?? Promise.resolve();\n\n\t\tlet releaseNext!: () => void;\n\t\tconst nextQueue = new Promise<void>((resolveQueue) => {\n\t\t\treleaseNext = resolveQueue;\n\t\t});\n\t\tconst chainedQueue = currentQueue.then(() => nextQueue);\n\t\tfileMutationQueues.set(key, chainedQueue);\n\n\t\treturn { key, currentQueue, chainedQueue, releaseNext };\n\t});\n\tregistrationQueue = registration.then(\n\t\t() => undefined,\n\t\t() => undefined,\n\t);\n\n\tconst { key, currentQueue, chainedQueue, releaseNext } = await registration;\n\tawait currentQueue;\n\ttry {\n\t\treturn await fn(key);\n\t} finally {\n\t\treleaseNext();\n\t\tif (fileMutationQueues.get(key) === chainedQueue) {\n\t\t\tfileMutationQueues.delete(key);\n\t\t}\n\t}\n}\n"]}
@@ -11,6 +11,15 @@ export interface HashlineSnapshotStore {
11
11
  findByHeader(displayPath: string, tag: string): HashlineSnapshot | undefined;
12
12
  }
13
13
  export declare function hashlineDisplayPath(absolutePath: string, cwd: string): string;
14
+ /**
15
+ * The key a path's snapshots are filed under in the underlying {@link SnapshotStore}.
16
+ *
17
+ * `record` below is the only place that decides this, so anything asking the store about a
18
+ * path it did not itself record goes through here rather than re-deriving the convention and
19
+ * drifting from it. Note this is `path.normalize`, not `realpath`: two symlinked spellings of
20
+ * one file are two keys here, unlike `canonicalMutationKey`.
21
+ */
22
+ export declare function hashlineStoreKey(absolutePath: string): string;
14
23
  export declare function normalizeHashlineContent(content: string): string;
15
24
  export declare function computeHashlineTag(content: string): string;
16
25
  export declare function createHashlineSnapshotStore(): HashlineSnapshotStore;
@@ -1 +1 @@
1
- {"version":3,"file":"hashline.d.ts","sourceRoot":"","sources":["../../../src/core/tools/hashline.ts"],"names":[],"mappings":"AACA,OAAO,EAKN,KAAK,aAAa,EAClB,MAAM,4BAA4B,CAAC;AAEpC,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,CAKhE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,2BAA2B,IAAI,qBAAqB,CAkBnE;AAED,wBAAgB,sBAAsB,CACrC,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,qBAAqB,GAC1B,gB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A;CAAE,EAClD,QAAQ,GAAE,SAAS,MAAM,EAAO,GAC9B,MAAM,CAMR"}
@@ -9,6 +9,17 @@ export function hashlineDisplayPath(absolutePath, cwd) {
9
9
  return toPosixPath(relativePath);
10
10
  return toPosixPath(absolutePath);
11
11
  }
12
+ /**
13
+ * The key a path's snapshots are filed under in the underlying {@link SnapshotStore}.
14
+ *
15
+ * `record` below is the only place that decides this, so anything asking the store about a
16
+ * path it did not itself record goes through here rather than re-deriving the convention and
17
+ * drifting from it. Note this is `path.normalize`, not `realpath`: two symlinked spellings of
18
+ * one file are two keys here, unlike `canonicalMutationKey`.
19
+ */
20
+ export function hashlineStoreKey(absolutePath) {
21
+ return normalizePath(absolutePath);
22
+ }
12
23
  export function normalizeHashlineContent(content) {
13
24
  return content
14
25
  .replace(/^\uFEFF/, "")
@@ -24,7 +35,7 @@ export function createHashlineSnapshotStore() {
24
35
  return {
25
36
  snapshots,
26
37
  record(absolutePath, cwd, content) {
27
- const normalizedPath = normalizePath(absolutePath);
38
+ const normalizedPath = hashlineStoreKey(absolutePath);
28
39
  const normalized = normalizeHashlineContent(content);
29
40
  const displayPath = hashlineDisplayPath(normalizedPath, cwd);
30
41
  const tag = snapshots.record(normalizedPath, normalized);
@@ -1 +1 @@
1
- {"version":3,"file":"hashline.js","sourceRoot":"","sources":["../../../src/core/tools/hashline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,IAAI,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EACN,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,GAErB,MAAM,4BAA4B,CAAC;AAepC,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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AQ,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,CAC9C,OAAe,EACf,YAAoB,EACpB,GAAW,EACX,KAA4B,EAC5B,WAAmB;IAEnB,OAAO,uCAAuC,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC;AACxG,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC9C,QAA0B,EAC1B,IAAkD,EAClD,QAAQ,GAAsB,EAAE;IAEhC,OAAO;QACN,oBAAoB,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC;QACxD,GAAG,QAAQ;QACX,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,uBAAuB,IAAI,CAAC,gBAAgB,IAAI,CAAC,EAAE;KACxE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC","sourcesContent":["import { isAbsolute, normalize as normalizePath, relative, sep } from \"node:path\";\nimport {\n\tcomputeFileHash,\n\tformatHashlineHeader,\n\tformatNumberedLines,\n\tInMemorySnapshotStore,\n\ttype SnapshotStore,\n} from \"./hashline-engine/index.ts\";\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\n\t\t.replace(/^\\uFEFF/, \"\")\n\t\t.replace(/\\r\\n/g, \"\\n\")\n\t\t.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(\n\tabsolutePath: string,\n\tcwd: string,\n\tcontent: string,\n\tstore: HashlineSnapshotStore,\n): HashlineSnapshot {\n\treturn store.record(absolutePath, cwd, content);\n}\n\nexport function formatHashlineContent(snapshot: HashlineSnapshot, content = snapshot.content, startLine = 1): string {\n\treturn [\n\t\tformatHashlineHeader(snapshot.displayPath, snapshot.tag),\n\t\tformatNumberedLines(normalizeHashlineContent(content), startLine),\n\t].join(\"\\n\");\n}\n\nexport interface StrippedHashlineContent {\n\tcontent: string;\n\tstripped: boolean;\n}\n\nexport function stripKnownHashlineCopiedContentWithMeta(\n\tcontent: string,\n\tabsolutePath: string,\n\tcwd: string,\n\tstore: HashlineSnapshotStore,\n\temittedPath: string,\n): StrippedHashlineContent {\n\tconst normalized = normalizeHashlineContent(content);\n\tconst lines = normalized.split(\"\\n\");\n\tconst headerIndex = lines.findIndex(\n\t\t(line, index) =>\n\t\t\t/^\\[[^\\]\\n]+#[0-9A-Fa-f]{4}\\]$/.test(line) &&\n\t\t\tlines.slice(0, index).every((prefix) => prefix.trim() === \"\" || /^#\\s+.+\\/?$/.test(prefix)),\n\t);\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\t// The write tool emits its confirmation from the raw `path` argument it was\n\t// called with (`Successfully wrote to ${path}`), not from the resolved path,\n\t// so `emittedPath` is the authoritative anchor: it is the only form that is\n\t// guaranteed to round-trip. The resolved and cwd-relative forms are accepted\n\t// because a caller may have named the file either way, and the snapshot's own\n\t// paths are accepted because a copied confirmation may belong to the write\n\t// that produced the snapshot being copied. Every candidate is a complete\n\t// path — a bare basename is deliberately NOT accepted, since `Successfully\n\t// wrote to notes.md` is ordinary prose when the target is `deep/dir/notes.md`,\n\t// and treating it as chrome destroys that line and everything after it.\n\tconst knownConfirmationPaths = new Set<string>();\n\tconst addKnownPath = (filePath: string): void => {\n\t\tif (!filePath) return;\n\t\tknownConfirmationPaths.add(filePath);\n\t\tknownConfirmationPaths.add(filePath.replaceAll(\"\\\\\", \"/\"));\n\t\tknownConfirmationPaths.add(filePath.replaceAll(\"/\", \"\\\\\"));\n\t};\n\taddKnownPath(emittedPath);\n\taddKnownPath(absolutePath);\n\tif (absolutePath) addKnownPath(relative(cwd, absolutePath));\n\taddKnownPath(snapshot.absolutePath);\n\taddKnownPath(snapshot.displayPath);\n\tconst isKnownWriteConfirmation = (line: string): boolean => {\n\t\tconst match = line.match(/^Successfully wrote (?:\\d+ bytes )?to (.+)$/);\n\t\treturn match !== null && knownConfirmationPaths.has(match[1] ?? \"\");\n\t};\n\tconst stripped: string[] = [];\n\tconst snapshotLines = snapshot.content.split(\"\\n\");\n\tlet sawRow = false;\n\tlet lastCopiedLineNumber: number | undefined;\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// confirmation (and its stripped-note), and `Resolved …` conflict footers.\n\t// A write confirmation is chrome only when it names the exact path the write\n\t// was asked for; a matching prefix or basename alone may be user content.\n\t// The optional byte count keeps pre-e583b290 confirmations matchable.\n\t// These footers never carry a line number, so they mark the end of the\n\t// numbered body instead of aborting stripping like an arbitrary line.\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\tisKnownWriteConfirmation(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\tlastCopiedLineNumber = lineNumber;\n\t\tstripped.push(strippedLine);\n\t}\n\tif (sawRow) {\n\t\tlet strippedContent = stripped.join(\"\\n\");\n\t\tif (snapshot.content.endsWith(\"\\n\") && lastCopiedLineNumber === snapshotLines.length - 1) strippedContent += \"\\n\";\n\t\treturn { content: strippedContent, stripped: true };\n\t}\n\n\t// Header + only tool chrome (e.g. a copied write confirmation\n\t// `Successfully wrote to <path>`) names a known snapshot with no numbered\n\t// 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(\n\tcontent: string,\n\tabsolutePath: string,\n\tcwd: string,\n\tstore: HashlineSnapshotStore,\n\temittedPath: string,\n): string {\n\treturn stripKnownHashlineCopiedContentWithMeta(content, absolutePath, cwd, store, emittedPath).content;\n}\n\nexport function formatCompactHashlineEditResult(\n\tsnapshot: HashlineSnapshot,\n\tdiff: { diff?: string; firstChangedLine?: number },\n\tmessages: readonly string[] = [],\n): string {\n\treturn [\n\t\tformatHashlineHeader(snapshot.displayPath, snapshot.tag),\n\t\t...messages,\n\t\tdiff.diff?.trim() || `First changed line: ${diff.firstChangedLine ?? 1}`,\n\t].join(\"\\n\");\n}\n"]}
1
+ {"version":3,"file":"hashline.js","sourceRoot":"","sources":["../../../src/core/tools/hashline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,IAAI,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EACN,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,GAErB,MAAM,4BAA4B,CAAC;AAepC,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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0EAA0E;IAC1E,8DAA8D;IAC9D,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,CAC9C,OAAe,EACf,YAAoB,EACpB,GAAW,EACX,KAA4B,EAC5B,WAAmB;IAEnB,OAAO,uCAAuC,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC;AACxG,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC9C,QAA0B,EAC1B,IAAkD,EAClD,QAAQ,GAAsB,EAAE;IAEhC,OAAO;QACN,oBAAoB,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC;QACxD,GAAG,QAAQ;QACX,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,uBAAuB,IAAI,CAAC,gBAAgB,IAAI,CAAC,EAAE;KACxE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC","sourcesContent":["import { isAbsolute, normalize as normalizePath, relative, sep } from \"node:path\";\nimport {\n\tcomputeFileHash,\n\tformatHashlineHeader,\n\tformatNumberedLines,\n\tInMemorySnapshotStore,\n\ttype SnapshotStore,\n} from \"./hashline-engine/index.ts\";\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\n/**\n * The key a path's snapshots are filed under in the underlying {@link SnapshotStore}.\n *\n * `record` below is the only place that decides this, so anything asking the store about a\n * path it did not itself record goes through here rather than re-deriving the convention and\n * drifting from it. Note this is `path.normalize`, not `realpath`: two symlinked spellings of\n * one file are two keys here, unlike `canonicalMutationKey`.\n */\nexport function hashlineStoreKey(absolutePath: string): string {\n\treturn normalizePath(absolutePath);\n}\n\nexport function normalizeHashlineContent(content: string): string {\n\treturn content\n\t\t.replace(/^\\uFEFF/, \"\")\n\t\t.replace(/\\r\\n/g, \"\\n\")\n\t\t.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 = hashlineStoreKey(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(\n\tabsolutePath: string,\n\tcwd: string,\n\tcontent: string,\n\tstore: HashlineSnapshotStore,\n): HashlineSnapshot {\n\treturn store.record(absolutePath, cwd, content);\n}\n\nexport function formatHashlineContent(snapshot: HashlineSnapshot, content = snapshot.content, startLine = 1): string {\n\treturn [\n\t\tformatHashlineHeader(snapshot.displayPath, snapshot.tag),\n\t\tformatNumberedLines(normalizeHashlineContent(content), startLine),\n\t].join(\"\\n\");\n}\n\nexport interface StrippedHashlineContent {\n\tcontent: string;\n\tstripped: boolean;\n}\n\nexport function stripKnownHashlineCopiedContentWithMeta(\n\tcontent: string,\n\tabsolutePath: string,\n\tcwd: string,\n\tstore: HashlineSnapshotStore,\n\temittedPath: string,\n): StrippedHashlineContent {\n\tconst normalized = normalizeHashlineContent(content);\n\tconst lines = normalized.split(\"\\n\");\n\tconst headerIndex = lines.findIndex(\n\t\t(line, index) =>\n\t\t\t/^\\[[^\\]\\n]+#[0-9A-Fa-f]{4}\\]$/.test(line) &&\n\t\t\tlines.slice(0, index).every((prefix) => prefix.trim() === \"\" || /^#\\s+.+\\/?$/.test(prefix)),\n\t);\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\t// The write tool emits its confirmation from the raw `path` argument it was\n\t// called with (`Successfully wrote to ${path}`), not from the resolved path,\n\t// so `emittedPath` is the authoritative anchor: it is the only form that is\n\t// guaranteed to round-trip. The resolved and cwd-relative forms are accepted\n\t// because a caller may have named the file either way, and the snapshot's own\n\t// paths are accepted because a copied confirmation may belong to the write\n\t// that produced the snapshot being copied. Every candidate is a complete\n\t// path — a bare basename is deliberately NOT accepted, since `Successfully\n\t// wrote to notes.md` is ordinary prose when the target is `deep/dir/notes.md`,\n\t// and treating it as chrome destroys that line and everything after it.\n\tconst knownConfirmationPaths = new Set<string>();\n\tconst addKnownPath = (filePath: string): void => {\n\t\tif (!filePath) return;\n\t\tknownConfirmationPaths.add(filePath);\n\t\tknownConfirmationPaths.add(filePath.replaceAll(\"\\\\\", \"/\"));\n\t\tknownConfirmationPaths.add(filePath.replaceAll(\"/\", \"\\\\\"));\n\t};\n\taddKnownPath(emittedPath);\n\taddKnownPath(absolutePath);\n\tif (absolutePath) addKnownPath(relative(cwd, absolutePath));\n\taddKnownPath(snapshot.absolutePath);\n\taddKnownPath(snapshot.displayPath);\n\tconst isKnownWriteConfirmation = (line: string): boolean => {\n\t\tconst match = line.match(/^Successfully wrote (?:\\d+ bytes )?to (.+)$/);\n\t\treturn match !== null && knownConfirmationPaths.has(match[1] ?? \"\");\n\t};\n\tconst stripped: string[] = [];\n\tconst snapshotLines = snapshot.content.split(\"\\n\");\n\tlet sawRow = false;\n\tlet lastCopiedLineNumber: number | undefined;\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// confirmation (and its stripped-note), and `Resolved …` conflict footers.\n\t// A write confirmation is chrome only when it names the exact path the write\n\t// was asked for; a matching prefix or basename alone may be user content.\n\t// The optional byte count keeps pre-e583b290 confirmations matchable.\n\t// These footers never carry a line number, so they mark the end of the\n\t// numbered body instead of aborting stripping like an arbitrary line.\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\tisKnownWriteConfirmation(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\tlastCopiedLineNumber = lineNumber;\n\t\tstripped.push(strippedLine);\n\t}\n\tif (sawRow) {\n\t\tlet strippedContent = stripped.join(\"\\n\");\n\t\tif (snapshot.content.endsWith(\"\\n\") && lastCopiedLineNumber === snapshotLines.length - 1) strippedContent += \"\\n\";\n\t\treturn { content: strippedContent, stripped: true };\n\t}\n\n\t// Header + only tool chrome (e.g. a copied write confirmation\n\t// `Successfully wrote to <path>`) names a known snapshot with no numbered\n\t// 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(\n\tcontent: string,\n\tabsolutePath: string,\n\tcwd: string,\n\tstore: HashlineSnapshotStore,\n\temittedPath: string,\n): string {\n\treturn stripKnownHashlineCopiedContentWithMeta(content, absolutePath, cwd, store, emittedPath).content;\n}\n\nexport function formatCompactHashlineEditResult(\n\tsnapshot: HashlineSnapshot,\n\tdiff: { diff?: string; firstChangedLine?: number },\n\tmessages: readonly string[] = [],\n): string {\n\treturn [\n\t\tformatHashlineHeader(snapshot.displayPath, snapshot.tag),\n\t\t...messages,\n\t\tdiff.diff?.trim() || `First changed line: ${diff.firstChangedLine ?? 1}`,\n\t].join(\"\\n\");\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  export { createAskUserQuestionToolDefinition } from "./ask-user-question/index.ts";
2
2
  export { BASH_SHELL_PRESENTATION, type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, bashToolSystemPromptContribution, createBashTool, createBashToolDefinition, createLocalBashOperations, type ShellToolPresentation, } from "./bash.js";
3
3
  export { createEditTool, createEditToolDefinition, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, editToolSystemPromptContribution, } from "./edit.ts";
4
+ export { FILE_MUTATION_CONFLICT_CODE, FileMutationConflict, type FileMutationConflictDetails, type FileMutationConflictEvidence, type FileMutationConflictReason, type FileMutationLiveState, type MutationRequester, type MutationRequesterResolver, } from "./file-mutation-coordinator.ts";
4
5
  export { withFileMutationQueue } from "./file-mutation-queue.ts";
5
6
  export { createFindTool, createFindToolDefinition, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, findToolSystemPromptContribution, } from "./find.ts";
6
7
  export { createKillTool, createKillToolDefinition, type KillToolOptions } from "./kill.ts";
@@ -11,12 +12,13 @@ export { createSearchTool, createSearchToolDefinition, type SearchToolDetails, t
11
12
  export { createStructuredOutputCapture, createStructuredOutputTool, type JsonObject, type JsonPrimitive, type JsonValue, STRUCTURED_OUTPUT_TOOL_NAME, type StructuredOutputCapture, type StructuredOutputFileCapture, type StructuredOutputToolOptions, } from "./structured-output.ts";
12
13
  export { createTodoToolDefinition } from "./todos.ts";
13
14
  export { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationOptions, type TruncationResult, truncateHead, truncateLine, truncateTail, } from "./truncate.ts";
14
- export { createWriteTool, createWriteToolDefinition, type WriteOperations, type WriteToolInput, type WriteToolOptions, writeToolSystemPromptContribution, } from "./write.ts";
15
+ export { createWriteTool, createWriteToolDefinition, type WriteFileOptions, type WriteOperations, type WriteToolInput, type WriteToolOptions, writeToolSystemPromptContribution, } from "./write.ts";
15
16
  import type { AgentTool } from "@earendil-works/pi-agent-core";
16
17
  import type { TSchema } from "typebox";
17
18
  import type { ToolDefinition } from "../extensions/types.ts";
18
19
  import { type BashToolOptions } from "./bash.js";
19
20
  import { type EditToolOptions } from "./edit.ts";
21
+ import type { MutationRequesterResolver } from "./file-mutation-coordinator.ts";
20
22
  import { type FindToolOptions } from "./find.ts";
21
23
  import { type HashlineSnapshotStore } from "./hashline.ts";
22
24
  import { type KillToolOptions } from "./kill.ts";
@@ -54,6 +56,12 @@ export interface ToolsOptions {
54
56
  search?: SearchToolOptions;
55
57
  ls?: LsToolOptions;
56
58
  hashlineStore?: HashlineSnapshotStore;
59
+ /**
60
+ * Session-scoped identity for whichever mutation gets rejected, forwarded to the two tools
61
+ * that can raise a conflict. Deliberately not defaulted the way `hashlineStore` is: absence
62
+ * means no identity is available, which the conflict path already handles.
63
+ */
64
+ resolveMutationRequester?: MutationRequesterResolver;
57
65
  }
58
66
  export declare function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef;
59
67
  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,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EACN,uBAAuB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,gCAAgC,EAChC,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,KAAK,qBAAqB,GAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,gCAAgC,GAChC,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,EACpB,gCAAgC,GAChC,MAAM,WAAW,CA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AC,CA2BrG;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAoB7E;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,cAAc,CAAC,IAAI,CAAC,CA2BxF"}
@@ -1,6 +1,7 @@
1
1
  export { createAskUserQuestionToolDefinition } from "./ask-user-question/index.js";
2
2
  export { BASH_SHELL_PRESENTATION, bashToolSystemPromptContribution, createBashTool, createBashToolDefinition, createLocalBashOperations, } from "./bash.js";
3
3
  export { createEditTool, createEditToolDefinition, editToolSystemPromptContribution, } from "./edit.js";
4
+ export { FILE_MUTATION_CONFLICT_CODE, FileMutationConflict, } from "./file-mutation-coordinator.js";
4
5
  export { withFileMutationQueue } from "./file-mutation-queue.js";
5
6
  export { createFindTool, createFindToolDefinition, findToolSystemPromptContribution, } from "./find.js";
6
7
  export { createKillTool, createKillToolDefinition } from "./kill.js";
@@ -70,6 +71,7 @@ export function createToolDefinition(toolName, cwd, options) {
70
71
  // Default a shared store so the singular factories don't hand read/edit/
71
72
  // write/search isolated stores (which silently degrades drift recovery).
72
73
  const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
74
+ const resolveMutationRequester = options?.resolveMutationRequester;
73
75
  switch (toolName) {
74
76
  case "read":
75
77
  return createReadToolDefinition(cwd, { ...options?.read, hashlineStore });
@@ -80,9 +82,17 @@ export function createToolDefinition(toolName, cwd, options) {
80
82
  case "kill":
81
83
  return createKillToolDefinition(options?.kill);
82
84
  case "edit":
83
- return createEditToolDefinition(cwd, { ...options?.edit, hashlineStore });
85
+ return createEditToolDefinition(cwd, {
86
+ ...options?.edit,
87
+ hashlineStore,
88
+ ...(resolveMutationRequester ? { resolveMutationRequester } : {}),
89
+ });
84
90
  case "write":
85
- return createWriteToolDefinition(cwd, { ...options?.write, hashlineStore });
91
+ return createWriteToolDefinition(cwd, {
92
+ ...options?.write,
93
+ hashlineStore,
94
+ ...(resolveMutationRequester ? { resolveMutationRequester } : {}),
95
+ });
86
96
  case "find":
87
97
  return createFindToolDefinition(cwd, options?.find);
88
98
  case "search":
@@ -99,6 +109,7 @@ export function createToolDefinition(toolName, cwd, options) {
99
109
  }
100
110
  export function createTool(toolName, cwd, options) {
101
111
  const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
112
+ const resolveMutationRequester = options?.resolveMutationRequester;
102
113
  switch (toolName) {
103
114
  case "read":
104
115
  return createReadTool(cwd, { ...options?.read, hashlineStore });
@@ -109,9 +120,17 @@ export function createTool(toolName, cwd, options) {
109
120
  case "kill":
110
121
  return createKillTool(options?.kill);
111
122
  case "edit":
112
- return createEditTool(cwd, { ...options?.edit, hashlineStore });
123
+ return createEditTool(cwd, {
124
+ ...options?.edit,
125
+ hashlineStore,
126
+ ...(resolveMutationRequester ? { resolveMutationRequester } : {}),
127
+ });
113
128
  case "write":
114
- return createWriteTool(cwd, { ...options?.write, hashlineStore });
129
+ return createWriteTool(cwd, {
130
+ ...options?.write,
131
+ hashlineStore,
132
+ ...(resolveMutationRequester ? { resolveMutationRequester } : {}),
133
+ });
115
134
  case "find":
116
135
  return createFindTool(cwd, options?.find);
117
136
  case "search":
@@ -128,12 +147,21 @@ export function createTool(toolName, cwd, options) {
128
147
  }
129
148
  export function createCodingToolDefinitions(cwd, options) {
130
149
  const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
150
+ const resolveMutationRequester = options?.resolveMutationRequester;
131
151
  return [
132
152
  createReadToolDefinition(cwd, { ...options?.read, hashlineStore }),
133
153
  createBashToolDefinition(cwd, options?.bash),
134
154
  createKillToolDefinition(options?.kill),
135
- createEditToolDefinition(cwd, { ...options?.edit, hashlineStore }),
136
- createWriteToolDefinition(cwd, { ...options?.write, hashlineStore }),
155
+ createEditToolDefinition(cwd, {
156
+ ...options?.edit,
157
+ hashlineStore,
158
+ ...(resolveMutationRequester ? { resolveMutationRequester } : {}),
159
+ }),
160
+ createWriteToolDefinition(cwd, {
161
+ ...options?.write,
162
+ hashlineStore,
163
+ ...(resolveMutationRequester ? { resolveMutationRequester } : {}),
164
+ }),
137
165
  createFindToolDefinition(cwd, options?.find),
138
166
  createSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),
139
167
  ];
@@ -149,12 +177,21 @@ export function createReadOnlyToolDefinitions(cwd, options) {
149
177
  }
150
178
  export function createAllToolDefinitions(cwd, options) {
151
179
  const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
180
+ const resolveMutationRequester = options?.resolveMutationRequester;
152
181
  const definitions = {
153
182
  read: createReadToolDefinition(cwd, { ...options?.read, hashlineStore }),
154
183
  bash: createBashToolDefinition(cwd, options?.bash),
155
184
  kill: createKillToolDefinition(options?.kill),
156
- edit: createEditToolDefinition(cwd, { ...options?.edit, hashlineStore }),
157
- write: createWriteToolDefinition(cwd, { ...options?.write, hashlineStore }),
185
+ edit: createEditToolDefinition(cwd, {
186
+ ...options?.edit,
187
+ hashlineStore,
188
+ ...(resolveMutationRequester ? { resolveMutationRequester } : {}),
189
+ }),
190
+ write: createWriteToolDefinition(cwd, {
191
+ ...options?.write,
192
+ hashlineStore,
193
+ ...(resolveMutationRequester ? { resolveMutationRequester } : {}),
194
+ }),
158
195
  find: createFindToolDefinition(cwd, options?.find),
159
196
  search: createSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),
160
197
  ls: createLsToolDefinition(cwd, options?.ls),
@@ -168,12 +205,21 @@ export function createAllToolDefinitions(cwd, options) {
168
205
  }
169
206
  export function createCodingTools(cwd, options) {
170
207
  const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
208
+ const resolveMutationRequester = options?.resolveMutationRequester;
171
209
  return [
172
210
  createReadTool(cwd, { ...options?.read, hashlineStore }),
173
211
  createBashTool(cwd, options?.bash),
174
212
  createKillTool(options?.kill),
175
- createEditTool(cwd, { ...options?.edit, hashlineStore }),
176
- createWriteTool(cwd, { ...options?.write, hashlineStore }),
213
+ createEditTool(cwd, {
214
+ ...options?.edit,
215
+ hashlineStore,
216
+ ...(resolveMutationRequester ? { resolveMutationRequester } : {}),
217
+ }),
218
+ createWriteTool(cwd, {
219
+ ...options?.write,
220
+ hashlineStore,
221
+ ...(resolveMutationRequester ? { resolveMutationRequester } : {}),
222
+ }),
177
223
  createFindTool(cwd, options?.find),
178
224
  createSearchTool(cwd, { ...options?.search, hashlineStore }),
179
225
  ];
@@ -189,12 +235,21 @@ export function createReadOnlyTools(cwd, options) {
189
235
  }
190
236
  export function createAllTools(cwd, options) {
191
237
  const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
238
+ const resolveMutationRequester = options?.resolveMutationRequester;
192
239
  const tools = {
193
240
  read: createReadTool(cwd, { ...options?.read, hashlineStore }),
194
241
  bash: createBashTool(cwd, options?.bash),
195
242
  kill: createKillTool(options?.kill),
196
- edit: createEditTool(cwd, { ...options?.edit, hashlineStore }),
197
- write: createWriteTool(cwd, { ...options?.write, hashlineStore }),
243
+ edit: createEditTool(cwd, {
244
+ ...options?.edit,
245
+ hashlineStore,
246
+ ...(resolveMutationRequester ? { resolveMutationRequester } : {}),
247
+ }),
248
+ write: createWriteTool(cwd, {
249
+ ...options?.write,
250
+ hashlineStore,
251
+ ...(resolveMutationRequester ? { resolveMutationRequester } : {}),
252
+ }),
198
253
  find: createFindTool(cwd, options?.find),
199
254
  search: createSearchTool(cwd, { ...options?.search, hashlineStore }),
200
255
  ls: createLsTool(cwd, options?.ls),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EACN,uBAAuB,EAOvB,gCAAgC,EAChC,cAAc,EAC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IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;QAC9D,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;QACjE,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,MAAM,EAAE,gBAAgB,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;QACpE,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QAClC,iBAAiB,EAAE,kBAAkB,CAAC,mCAAmC,EAAE,CAAC;QAC5E,IAAI,EAAE,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;KACvD,CAAC;IACF,IAAI,qBAAqB,EAAE,EAAE,CAAC;QAC7B,KAAK,CAAC,UAAU,GAAG,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["export { createAskUserQuestionToolDefinition } from \"./ask-user-question/index.ts\";\nexport {\n\tBASH_SHELL_PRESENTATION,\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tbashToolSystemPromptContribution,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n\ttype ShellToolPresentation,\n} from \"./bash.js\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\teditToolSystemPromptContribution,\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\tfindToolSystemPromptContribution,\n} from \"./find.ts\";\nexport { createKillTool, createKillToolDefinition, type KillToolOptions } from \"./kill.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\tlsToolSystemPromptContribution,\n} from \"./ls.ts\";\nexport {\n\tcreateLocalPowerShellOperations,\n\tcreatePowerShellTool,\n\tcreatePowerShellToolDefinition,\n\ttype PowerShellOperations,\n\ttype PowerShellSpawnContext,\n\ttype PowerShellSpawnHook,\n\ttype PowerShellToolDetails,\n\ttype PowerShellToolInput,\n\ttype PowerShellToolOptions,\n} from \"./powershell.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\treadToolSystemPromptContribution,\n} from \"./read.ts\";\nexport {\n\tcreateSearchTool,\n\tcreateSearchToolDefinition,\n\ttype SearchToolDetails,\n\ttype SearchToolInput,\n\ttype SearchToolOptions,\n\tsearchToolSystemPromptContribution,\n} from \"./search.ts\";\nexport {\n\tcreateStructuredOutputCapture,\n\tcreateStructuredOutputTool,\n\ttype JsonObject,\n\ttype JsonPrimitive,\n\ttype JsonValue,\n\tSTRUCTURED_OUTPUT_TOOL_NAME,\n\ttype StructuredOutputCapture,\n\ttype StructuredOutputFileCapture,\n\ttype StructuredOutputToolOptions,\n} from \"./structured-output.ts\";\nexport { createTodoToolDefinition } from \"./todos.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\twriteToolSystemPromptContribution,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { TSchema } from \"typebox\";\nimport { isPowerShellAvailable } from \"../../utils/shell.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { createAskUserQuestionToolDefinition } from \"./ask-user-question/index.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.js\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createHashlineSnapshotStore, type HashlineSnapshotStore } from \"./hashline.ts\";\nimport { createKillTool, createKillToolDefinition, type KillToolOptions } from \"./kill.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createPowerShellTool, createPowerShellToolDefinition, type PowerShellToolOptions } from \"./powershell.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createSearchTool, createSearchToolDefinition, type SearchToolOptions } from \"./search.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| \"powershell\"\n\t| \"kill\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"find\"\n\t| \"search\"\n\t| \"ls\"\n\t| \"ask_user_question\"\n\t| \"todo\";\nexport type BuiltinToolMap<T> = Omit<Record<ToolName, T>, \"powershell\"> & { powershell?: T };\n// The universe of built-in tool names, matching the `ToolName` union exactly.\n// Availability is decided per platform in `getDefaultToolNames()` and\n// `createAllToolDefinitions()`; this set stays static so a name is never\n// \"unknown\" merely because the host cannot run it.\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"powershell\",\n\t\"kill\",\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\n/**\n * Built-in tools enabled at startup.\n *\n * `powershell` is conditional: it is Windows-only and additionally needs a\n * resolvable `pwsh.exe`/`powershell.exe`. That probe reads PATH, so it runs per\n * call rather than at module load, and callers can decide it explicitly through\n * `powerShellAvailable` instead of depending on the host running the process.\n */\nexport function getDefaultToolNames(options?: { powerShellAvailable?: boolean }): readonly ToolName[] {\n\tconst powerShell = options?.powerShellAvailable ?? isPowerShellAvailable();\n\treturn [\n\t\t\"read\",\n\t\t\"bash\",\n\t\t...(powerShell ? ([\"powershell\"] as const satisfies readonly ToolName[]) : []),\n\t\t\"kill\",\n\t\t\"edit\",\n\t\t\"write\",\n\t\t\"find\",\n\t\t\"search\",\n\t\t\"ask_user_question\",\n\t\t\"todo\",\n\t];\n}\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\tpowershell?: PowerShellToolOptions;\n\tkill?: KillToolOptions;\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 \"powershell\":\n\t\t\treturn createPowerShellToolDefinition(cwd, options?.powershell);\n\t\tcase \"kill\":\n\t\t\treturn createKillToolDefinition(options?.kill);\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 \"powershell\":\n\t\t\treturn createPowerShellTool(cwd, options?.powershell);\n\t\tcase \"kill\":\n\t\t\treturn createKillTool(options?.kill);\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, options?.bash),\n\t\tcreateKillToolDefinition(options?.kill),\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): BuiltinToolMap<ToolDef> {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst definitions: BuiltinToolMap<ToolDef> = {\n\t\tread: createReadToolDefinition(cwd, { ...options?.read, hashlineStore }),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tkill: createKillToolDefinition(options?.kill),\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\tif (isPowerShellAvailable()) {\n\t\tdefinitions.powershell = createPowerShellToolDefinition(cwd, options?.powershell);\n\t}\n\treturn definitions;\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, options?.bash),\n\t\tcreateKillTool(options?.kill),\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): BuiltinToolMap<Tool> {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst tools: BuiltinToolMap<Tool> = {\n\t\tread: createReadTool(cwd, { ...options?.read, hashlineStore }),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tkill: createKillTool(options?.kill),\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\tif (isPowerShellAvailable()) {\n\t\ttools.powershell = createPowerShellTool(cwd, options?.powershell);\n\t}\n\treturn tools;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EACN,uBAAuB,EAOvB,gCAAgC,EAChC,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GAEzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EAKxB,gCAAgC,GAChC,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,2BAA2B,EAC3B,oBAAoB,GAOpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EAKxB,gCAAgC,GAChC,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAwB,MAAM,WAAW,CAAC;AAC3F,OAAO,EACN,YAAY,EACZ,sBAAsB,EAKtB,8BAA8B,GAC9B,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,+BAA+B,EAC/B,oBAAoB,EACpB,8BAA8B,GAO9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,cAAc,EACd,wBAAwB,EAKxB,gCAAgC,GAChC,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,gBAAgB,EAChB,0BAA0B,EAI1B,kCAAkC,GAClC,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,6BAA6B,EAC7B,0BAA0B,EAI1B,2BAA2B,GAI3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC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,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["export { createAskUserQuestionToolDefinition } from \"./ask-user-question/index.ts\";\nexport {\n\tBASH_SHELL_PRESENTATION,\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tbashToolSystemPromptContribution,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n\ttype ShellToolPresentation,\n} from \"./bash.js\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\teditToolSystemPromptContribution,\n} from \"./edit.ts\";\nexport {\n\tFILE_MUTATION_CONFLICT_CODE,\n\tFileMutationConflict,\n\ttype FileMutationConflictDetails,\n\ttype FileMutationConflictEvidence,\n\ttype FileMutationConflictReason,\n\ttype FileMutationLiveState,\n\ttype MutationRequester,\n\ttype MutationRequesterResolver,\n} from \"./file-mutation-coordinator.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\tfindToolSystemPromptContribution,\n} from \"./find.ts\";\nexport { createKillTool, createKillToolDefinition, type KillToolOptions } from \"./kill.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\tlsToolSystemPromptContribution,\n} from \"./ls.ts\";\nexport {\n\tcreateLocalPowerShellOperations,\n\tcreatePowerShellTool,\n\tcreatePowerShellToolDefinition,\n\ttype PowerShellOperations,\n\ttype PowerShellSpawnContext,\n\ttype PowerShellSpawnHook,\n\ttype PowerShellToolDetails,\n\ttype PowerShellToolInput,\n\ttype PowerShellToolOptions,\n} from \"./powershell.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\treadToolSystemPromptContribution,\n} from \"./read.ts\";\nexport {\n\tcreateSearchTool,\n\tcreateSearchToolDefinition,\n\ttype SearchToolDetails,\n\ttype SearchToolInput,\n\ttype SearchToolOptions,\n\tsearchToolSystemPromptContribution,\n} from \"./search.ts\";\nexport {\n\tcreateStructuredOutputCapture,\n\tcreateStructuredOutputTool,\n\ttype JsonObject,\n\ttype JsonPrimitive,\n\ttype JsonValue,\n\tSTRUCTURED_OUTPUT_TOOL_NAME,\n\ttype StructuredOutputCapture,\n\ttype StructuredOutputFileCapture,\n\ttype StructuredOutputToolOptions,\n} from \"./structured-output.ts\";\nexport { createTodoToolDefinition } from \"./todos.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 WriteFileOptions,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twriteToolSystemPromptContribution,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { TSchema } from \"typebox\";\nimport { isPowerShellAvailable } from \"../../utils/shell.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { createAskUserQuestionToolDefinition } from \"./ask-user-question/index.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.js\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport type { MutationRequesterResolver } from \"./file-mutation-coordinator.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createHashlineSnapshotStore, type HashlineSnapshotStore } from \"./hashline.ts\";\nimport { createKillTool, createKillToolDefinition, type KillToolOptions } from \"./kill.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createPowerShellTool, createPowerShellToolDefinition, type PowerShellToolOptions } from \"./powershell.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createSearchTool, createSearchToolDefinition, type SearchToolOptions } from \"./search.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| \"powershell\"\n\t| \"kill\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"find\"\n\t| \"search\"\n\t| \"ls\"\n\t| \"ask_user_question\"\n\t| \"todo\";\nexport type BuiltinToolMap<T> = Omit<Record<ToolName, T>, \"powershell\"> & { powershell?: T };\n// The universe of built-in tool names, matching the `ToolName` union exactly.\n// Availability is decided per platform in `getDefaultToolNames()` and\n// `createAllToolDefinitions()`; this set stays static so a name is never\n// \"unknown\" merely because the host cannot run it.\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"powershell\",\n\t\"kill\",\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\n/**\n * Built-in tools enabled at startup.\n *\n * `powershell` is conditional: it is Windows-only and additionally needs a\n * resolvable `pwsh.exe`/`powershell.exe`. That probe reads PATH, so it runs per\n * call rather than at module load, and callers can decide it explicitly through\n * `powerShellAvailable` instead of depending on the host running the process.\n */\nexport function getDefaultToolNames(options?: { powerShellAvailable?: boolean }): readonly ToolName[] {\n\tconst powerShell = options?.powerShellAvailable ?? isPowerShellAvailable();\n\treturn [\n\t\t\"read\",\n\t\t\"bash\",\n\t\t...(powerShell ? ([\"powershell\"] as const satisfies readonly ToolName[]) : []),\n\t\t\"kill\",\n\t\t\"edit\",\n\t\t\"write\",\n\t\t\"find\",\n\t\t\"search\",\n\t\t\"ask_user_question\",\n\t\t\"todo\",\n\t];\n}\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\tpowershell?: PowerShellToolOptions;\n\tkill?: KillToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tfind?: FindToolOptions;\n\tsearch?: SearchToolOptions;\n\tls?: LsToolOptions;\n\thashlineStore?: HashlineSnapshotStore;\n\t/**\n\t * Session-scoped identity for whichever mutation gets rejected, forwarded to the two tools\n\t * that can raise a conflict. Deliberately not defaulted the way `hashlineStore` is: absence\n\t * means no identity is available, which the conflict path already handles.\n\t */\n\tresolveMutationRequester?: MutationRequesterResolver;\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\tconst resolveMutationRequester = options?.resolveMutationRequester;\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 \"powershell\":\n\t\t\treturn createPowerShellToolDefinition(cwd, options?.powershell);\n\t\tcase \"kill\":\n\t\t\treturn createKillToolDefinition(options?.kill);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, {\n\t\t\t\t...options?.edit,\n\t\t\t\thashlineStore,\n\t\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t\t});\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, {\n\t\t\t\t...options?.write,\n\t\t\t\thashlineStore,\n\t\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t\t});\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\tconst resolveMutationRequester = options?.resolveMutationRequester;\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 \"powershell\":\n\t\t\treturn createPowerShellTool(cwd, options?.powershell);\n\t\tcase \"kill\":\n\t\t\treturn createKillTool(options?.kill);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, {\n\t\t\t\t...options?.edit,\n\t\t\t\thashlineStore,\n\t\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t\t});\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, {\n\t\t\t\t...options?.write,\n\t\t\t\thashlineStore,\n\t\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t\t});\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\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\treturn [\n\t\tcreateReadToolDefinition(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateKillToolDefinition(options?.kill),\n\t\tcreateEditToolDefinition(cwd, {\n\t\t\t...options?.edit,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\n\t\tcreateWriteToolDefinition(cwd, {\n\t\t\t...options?.write,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\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): BuiltinToolMap<ToolDef> {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\tconst definitions: BuiltinToolMap<ToolDef> = {\n\t\tread: createReadToolDefinition(cwd, { ...options?.read, hashlineStore }),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tkill: createKillToolDefinition(options?.kill),\n\t\tedit: createEditToolDefinition(cwd, {\n\t\t\t...options?.edit,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\n\t\twrite: createWriteToolDefinition(cwd, {\n\t\t\t...options?.write,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\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\tif (isPowerShellAvailable()) {\n\t\tdefinitions.powershell = createPowerShellToolDefinition(cwd, options?.powershell);\n\t}\n\treturn definitions;\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\treturn [\n\t\tcreateReadTool(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateKillTool(options?.kill),\n\t\tcreateEditTool(cwd, {\n\t\t\t...options?.edit,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\n\t\tcreateWriteTool(cwd, {\n\t\t\t...options?.write,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\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): BuiltinToolMap<Tool> {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\tconst tools: BuiltinToolMap<Tool> = {\n\t\tread: createReadTool(cwd, { ...options?.read, hashlineStore }),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tkill: createKillTool(options?.kill),\n\t\tedit: createEditTool(cwd, {\n\t\t\t...options?.edit,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\n\t\twrite: createWriteTool(cwd, {\n\t\t\t...options?.write,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\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\tif (isPowerShellAvailable()) {\n\t\ttools.powershell = createPowerShellTool(cwd, options?.powershell);\n\t}\n\treturn tools;\n}\n"]}
@@ -0,0 +1,49 @@
1
+ import { type Snapshot, SnapshotStore } from "./hashline-engine/index.ts";
2
+ /**
3
+ * {@link SnapshotStore} decorator that answers every read from the session's real store but
4
+ * never persists anything through {@link NonMintingSnapshotStore.record}.
5
+ *
6
+ * It exists because building a hashline rejection mints provenance. `Patcher`'s mismatch path
7
+ * records the live file into the snapshot store before constructing the error, then hands the
8
+ * model that tag as `actualFileHash`. An identical retry quoting that tag validates, because
9
+ * the tag now names content the store has seen, even though the model never re-read the file.
10
+ * The rejection issues the credential that defeats it.
11
+ *
12
+ * The engine is vendored and must not be edited, so the fix is injected at the single
13
+ * `new Patcher(...)` construction site instead. That is safe because every record the patcher
14
+ * would make is either unreachable or redundant when it is driven by the edit tool:
15
+ *
16
+ * - `commit()`'s no-op branch never runs. `edit.ts` filters no-op sections and returns before
17
+ * `apply` is ever called.
18
+ * - `commit()`'s post-write record is duplicated by `recordHashlineSnapshot` in `edit.ts`,
19
+ * which is also what populates the display-header map the patcher bypasses. That call stays
20
+ * the single writer of provenance.
21
+ * - The mismatch record is the bug.
22
+ *
23
+ * Reads delegate, so `Recovery` still resolves stale tags against the real per-session history
24
+ * and in-session drift recovery is unchanged.
25
+ *
26
+ * @see https://github.com/bastani-inc/atomic/issues/2329
27
+ */
28
+ export declare class NonMintingSnapshotStore extends SnapshotStore {
29
+ #private;
30
+ constructor(inner: SnapshotStore);
31
+ head(path: string): Snapshot | null;
32
+ byHash(path: string, hash: string): Snapshot | null;
33
+ /**
34
+ * Delegated rather than inherited. The base implementation is derived from
35
+ * {@link SnapshotStore.byHash}, but `InMemorySnapshotStore` overrides it with different
36
+ * hash-collision semantics, and a decorator must present whichever the wrapped store
37
+ * actually implements.
38
+ */
39
+ byHashAndText(path: string, hash: string, text: string): Snapshot | null;
40
+ /**
41
+ * Returns the tag the content would receive without retaining it, so a tag quoted back in
42
+ * an error never becomes valid provenance. Callers that legitimately need to record a
43
+ * snapshot do so against the session store directly.
44
+ */
45
+ record(_path: string, fullText: string): string;
46
+ invalidate(path: string): void;
47
+ clear(): void;
48
+ }
49
+ //# sourceMappingURL=non-minting-snapshot-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"non-minting-snapshot-store.d.ts","sourceRoot":"","sources":["../../../src/core/tools/non-minting-snapshot-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,QAAQ,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3F;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,uBAAwB,SAAQ,aAAa;;IAGzD,YAAY,KAAK,EAAE,aAAa,EAG/B;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAElC;IAED,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAElD;IAED;;;;;OAKG;IACM,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAEhF;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE9C;IAED,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE7B;IAED,KAAK,IAAI,IAAI,CAEZ;CACD"}