@animalabs/agent-framework 0.23.2 → 0.24.0

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 (338) hide show
  1. package/README.md +212 -42
  2. package/dist/src/agent.d.ts +60 -9
  3. package/dist/src/agent.d.ts.map +1 -1
  4. package/dist/src/agent.js +92 -12
  5. package/dist/src/agent.js.map +1 -1
  6. package/dist/src/api/server.d.ts.map +1 -1
  7. package/dist/src/api/server.js +14 -12
  8. package/dist/src/api/server.js.map +1 -1
  9. package/dist/src/code-execution/engine.d.ts +177 -0
  10. package/dist/src/code-execution/engine.d.ts.map +1 -0
  11. package/dist/src/code-execution/engine.js +494 -0
  12. package/dist/src/code-execution/engine.js.map +1 -0
  13. package/dist/src/code-execution/index.d.ts +5 -10
  14. package/dist/src/code-execution/index.d.ts.map +1 -1
  15. package/dist/src/code-execution/index.js +5 -9
  16. package/dist/src/code-execution/index.js.map +1 -1
  17. package/dist/src/code-execution/isolate/calls.d.ts +114 -0
  18. package/dist/src/code-execution/isolate/calls.d.ts.map +1 -0
  19. package/dist/src/code-execution/isolate/calls.js +145 -0
  20. package/dist/src/code-execution/isolate/calls.js.map +1 -0
  21. package/dist/src/code-execution/isolate/child-entry.d.ts +2 -0
  22. package/dist/src/code-execution/isolate/child-entry.d.ts.map +1 -0
  23. package/dist/src/code-execution/isolate/child-entry.js +5 -0
  24. package/dist/src/code-execution/isolate/child-entry.js.map +1 -0
  25. package/dist/src/code-execution/isolate/child-main.d.ts +26 -0
  26. package/dist/src/code-execution/isolate/child-main.d.ts.map +1 -0
  27. package/dist/src/code-execution/isolate/child-main.js +132 -0
  28. package/dist/src/code-execution/isolate/child-main.js.map +1 -0
  29. package/dist/src/code-execution/isolate/child.d.ts +44 -0
  30. package/dist/src/code-execution/isolate/child.d.ts.map +1 -0
  31. package/dist/src/code-execution/isolate/child.js +315 -0
  32. package/dist/src/code-execution/isolate/child.js.map +1 -0
  33. package/dist/src/code-execution/isolate/frames.d.ts +80 -0
  34. package/dist/src/code-execution/isolate/frames.d.ts.map +1 -0
  35. package/dist/src/code-execution/isolate/frames.js +210 -0
  36. package/dist/src/code-execution/isolate/frames.js.map +1 -0
  37. package/dist/src/code-execution/isolate/output.d.ts +68 -0
  38. package/dist/src/code-execution/isolate/output.d.ts.map +1 -0
  39. package/dist/src/code-execution/isolate/output.js +143 -0
  40. package/dist/src/code-execution/isolate/output.js.map +1 -0
  41. package/dist/src/code-execution/isolate/prelude.d.ts +109 -0
  42. package/dist/src/code-execution/isolate/prelude.d.ts.map +1 -0
  43. package/dist/src/code-execution/isolate/prelude.js +401 -0
  44. package/dist/src/code-execution/isolate/prelude.js.map +1 -0
  45. package/dist/src/code-execution/isolate/protocol.d.ts +151 -0
  46. package/dist/src/code-execution/isolate/protocol.d.ts.map +1 -0
  47. package/dist/src/code-execution/isolate/protocol.js +150 -0
  48. package/dist/src/code-execution/isolate/protocol.js.map +1 -0
  49. package/dist/src/code-execution/isolate/render.d.ts +57 -0
  50. package/dist/src/code-execution/isolate/render.d.ts.map +1 -0
  51. package/dist/src/code-execution/isolate/render.js +214 -0
  52. package/dist/src/code-execution/isolate/render.js.map +1 -0
  53. package/dist/src/code-execution/isolate/runner.d.ts +250 -0
  54. package/dist/src/code-execution/isolate/runner.d.ts.map +1 -0
  55. package/dist/src/code-execution/isolate/runner.js +854 -0
  56. package/dist/src/code-execution/isolate/runner.js.map +1 -0
  57. package/dist/src/code-execution/isolate/scripts.d.ts +175 -0
  58. package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -0
  59. package/dist/src/code-execution/isolate/scripts.js +357 -0
  60. package/dist/src/code-execution/isolate/scripts.js.map +1 -0
  61. package/dist/src/code-execution/quickjs.wasm +0 -0
  62. package/dist/src/code-execution/tool-definition.d.ts +93 -43
  63. package/dist/src/code-execution/tool-definition.d.ts.map +1 -1
  64. package/dist/src/code-execution/tool-definition.js +176 -142
  65. package/dist/src/code-execution/tool-definition.js.map +1 -1
  66. package/dist/src/deadline-timer.d.ts +3 -0
  67. package/dist/src/deadline-timer.d.ts.map +1 -1
  68. package/dist/src/deadline-timer.js +1 -1
  69. package/dist/src/deadline-timer.js.map +1 -1
  70. package/dist/src/framework.d.ts +1027 -440
  71. package/dist/src/framework.d.ts.map +1 -1
  72. package/dist/src/framework.js +4093 -2238
  73. package/dist/src/framework.js.map +1 -1
  74. package/dist/src/gate/event-gate.d.ts +28 -1
  75. package/dist/src/gate/event-gate.d.ts.map +1 -1
  76. package/dist/src/gate/event-gate.js +88 -10
  77. package/dist/src/gate/event-gate.js.map +1 -1
  78. package/dist/src/held-writes.d.ts +16 -3
  79. package/dist/src/held-writes.d.ts.map +1 -1
  80. package/dist/src/held-writes.js +16 -3
  81. package/dist/src/held-writes.js.map +1 -1
  82. package/dist/src/index.d.ts +6 -6
  83. package/dist/src/index.d.ts.map +1 -1
  84. package/dist/src/index.js +9 -8
  85. package/dist/src/index.js.map +1 -1
  86. package/dist/src/mcpl/channel-registry.d.ts +471 -75
  87. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  88. package/dist/src/mcpl/channel-registry.js +1673 -337
  89. package/dist/src/mcpl/channel-registry.js.map +1 -1
  90. package/dist/src/mcpl/conversation-router.d.ts +12 -7
  91. package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
  92. package/dist/src/mcpl/conversation-router.js +12 -7
  93. package/dist/src/mcpl/conversation-router.js.map +1 -1
  94. package/dist/src/mcpl/convert-block.d.ts.map +1 -1
  95. package/dist/src/mcpl/convert-block.js +9 -5
  96. package/dist/src/mcpl/convert-block.js.map +1 -1
  97. package/dist/src/mcpl/inbound-source.d.ts +50 -0
  98. package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
  99. package/dist/src/mcpl/inbound-source.js +130 -0
  100. package/dist/src/mcpl/inbound-source.js.map +1 -1
  101. package/dist/src/mcpl/index.d.ts +2 -1
  102. package/dist/src/mcpl/index.d.ts.map +1 -1
  103. package/dist/src/mcpl/index.js +3 -2
  104. package/dist/src/mcpl/index.js.map +1 -1
  105. package/dist/src/mcpl/log-value.d.ts +6 -0
  106. package/dist/src/mcpl/log-value.d.ts.map +1 -1
  107. package/dist/src/mcpl/log-value.js +8 -0
  108. package/dist/src/mcpl/log-value.js.map +1 -1
  109. package/dist/src/mcpl/modern-connection.d.ts +15 -6
  110. package/dist/src/mcpl/modern-connection.d.ts.map +1 -1
  111. package/dist/src/mcpl/modern-connection.js +168 -53
  112. package/dist/src/mcpl/modern-connection.js.map +1 -1
  113. package/dist/src/mcpl/prose-grammar.d.ts +4 -5
  114. package/dist/src/mcpl/prose-grammar.d.ts.map +1 -1
  115. package/dist/src/mcpl/prose-grammar.js +4 -5
  116. package/dist/src/mcpl/prose-grammar.js.map +1 -1
  117. package/dist/src/mcpl/protocol-family.d.ts +97 -10
  118. package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
  119. package/dist/src/mcpl/protocol-family.js +173 -16
  120. package/dist/src/mcpl/protocol-family.js.map +1 -1
  121. package/dist/src/mcpl/push-coalescer.d.ts +132 -14
  122. package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
  123. package/dist/src/mcpl/push-coalescer.js +227 -50
  124. package/dist/src/mcpl/push-coalescer.js.map +1 -1
  125. package/dist/src/mcpl/push-handler.d.ts +6 -1
  126. package/dist/src/mcpl/push-handler.d.ts.map +1 -1
  127. package/dist/src/mcpl/push-handler.js +4 -1
  128. package/dist/src/mcpl/push-handler.js.map +1 -1
  129. package/dist/src/mcpl/reference-fetcher.d.ts +2 -2
  130. package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
  131. package/dist/src/mcpl/reference-fetcher.js +4 -4
  132. package/dist/src/mcpl/reference-fetcher.js.map +1 -1
  133. package/dist/src/mcpl/server-connection.d.ts +50 -21
  134. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  135. package/dist/src/mcpl/server-connection.js +158 -74
  136. package/dist/src/mcpl/server-connection.js.map +1 -1
  137. package/dist/src/mcpl/tags.d.ts +24 -0
  138. package/dist/src/mcpl/tags.d.ts.map +1 -1
  139. package/dist/src/mcpl/tags.js +33 -0
  140. package/dist/src/mcpl/tags.js.map +1 -1
  141. package/dist/src/mcpl/tool-result-normalize.d.ts +2 -1
  142. package/dist/src/mcpl/tool-result-normalize.d.ts.map +1 -1
  143. package/dist/src/mcpl/tool-result-normalize.js.map +1 -1
  144. package/dist/src/mcpl/transport.d.ts +55 -7
  145. package/dist/src/mcpl/transport.d.ts.map +1 -1
  146. package/dist/src/mcpl/transport.js +163 -34
  147. package/dist/src/mcpl/transport.js.map +1 -1
  148. package/dist/src/mcpl/types.d.ts +22 -6
  149. package/dist/src/mcpl/types.d.ts.map +1 -1
  150. package/dist/src/mcpl/types.js.map +1 -1
  151. package/dist/src/module-registry.d.ts +4 -2
  152. package/dist/src/module-registry.d.ts.map +1 -1
  153. package/dist/src/module-registry.js +100 -13
  154. package/dist/src/module-registry.js.map +1 -1
  155. package/dist/src/modules/discord/index.d.ts.map +1 -1
  156. package/dist/src/modules/discord/index.js +8 -13
  157. package/dist/src/modules/discord/index.js.map +1 -1
  158. package/dist/src/modules/history/index.d.ts.map +1 -1
  159. package/dist/src/modules/history/index.js +27 -4
  160. package/dist/src/modules/history/index.js.map +1 -1
  161. package/dist/src/modules/history/semantic.d.ts +15 -3
  162. package/dist/src/modules/history/semantic.d.ts.map +1 -1
  163. package/dist/src/modules/history/semantic.js +27 -5
  164. package/dist/src/modules/history/semantic.js.map +1 -1
  165. package/dist/src/modules/index.d.ts +1 -1
  166. package/dist/src/modules/index.d.ts.map +1 -1
  167. package/dist/src/modules/index.js.map +1 -1
  168. package/dist/src/modules/unknown-tool.d.ts +4 -1
  169. package/dist/src/modules/unknown-tool.d.ts.map +1 -1
  170. package/dist/src/modules/unknown-tool.js +4 -1
  171. package/dist/src/modules/unknown-tool.js.map +1 -1
  172. package/dist/src/modules/workspace/branch-intent.d.ts +3 -1
  173. package/dist/src/modules/workspace/branch-intent.d.ts.map +1 -1
  174. package/dist/src/modules/workspace/branch-intent.js +3 -1
  175. package/dist/src/modules/workspace/branch-intent.js.map +1 -1
  176. package/dist/src/modules/workspace/edit-plan.d.ts +265 -0
  177. package/dist/src/modules/workspace/edit-plan.d.ts.map +1 -0
  178. package/dist/src/modules/workspace/edit-plan.js +794 -0
  179. package/dist/src/modules/workspace/edit-plan.js.map +1 -0
  180. package/dist/src/modules/workspace/edit-text.d.ts +117 -0
  181. package/dist/src/modules/workspace/edit-text.d.ts.map +1 -0
  182. package/dist/src/modules/workspace/edit-text.js +584 -0
  183. package/dist/src/modules/workspace/edit-text.js.map +1 -0
  184. package/dist/src/modules/workspace/effects.d.ts +5 -4
  185. package/dist/src/modules/workspace/effects.d.ts.map +1 -1
  186. package/dist/src/modules/workspace/effects.js +78 -25
  187. package/dist/src/modules/workspace/effects.js.map +1 -1
  188. package/dist/src/modules/workspace/index.d.ts +484 -61
  189. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  190. package/dist/src/modules/workspace/index.js +2173 -645
  191. package/dist/src/modules/workspace/index.js.map +1 -1
  192. package/dist/src/modules/workspace/observe.d.ts +213 -38
  193. package/dist/src/modules/workspace/observe.d.ts.map +1 -1
  194. package/dist/src/modules/workspace/observe.js +416 -36
  195. package/dist/src/modules/workspace/observe.js.map +1 -1
  196. package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
  197. package/dist/src/modules/workspace/reconcile.js +15 -8
  198. package/dist/src/modules/workspace/reconcile.js.map +1 -1
  199. package/dist/src/modules/workspace/text.d.ts +32 -0
  200. package/dist/src/modules/workspace/text.d.ts.map +1 -0
  201. package/dist/src/modules/workspace/text.js +67 -0
  202. package/dist/src/modules/workspace/text.js.map +1 -0
  203. package/dist/src/modules/workspace/types.d.ts +210 -6
  204. package/dist/src/modules/workspace/types.d.ts.map +1 -1
  205. package/dist/src/modules/workspace/types.js.map +1 -1
  206. package/dist/src/modules/workspace/watcher.d.ts +3 -2
  207. package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
  208. package/dist/src/modules/workspace/watcher.js.map +1 -1
  209. package/dist/src/operator-log.d.ts +52 -24
  210. package/dist/src/operator-log.d.ts.map +1 -1
  211. package/dist/src/operator-log.js.map +1 -1
  212. package/dist/src/recovery/discord-awareness-outbox.d.ts +496 -72
  213. package/dist/src/recovery/discord-awareness-outbox.d.ts.map +1 -1
  214. package/dist/src/recovery/discord-awareness-outbox.js +1196 -289
  215. package/dist/src/recovery/discord-awareness-outbox.js.map +1 -1
  216. package/dist/src/recovery/offline-branch.d.ts +26 -1
  217. package/dist/src/recovery/offline-branch.d.ts.map +1 -1
  218. package/dist/src/recovery/offline-branch.js +164 -39
  219. package/dist/src/recovery/offline-branch.js.map +1 -1
  220. package/dist/src/recovery/recover-cli.js +23 -4
  221. package/dist/src/recovery/recover-cli.js.map +1 -1
  222. package/dist/src/send-tools.d.ts +11 -0
  223. package/dist/src/send-tools.d.ts.map +1 -0
  224. package/dist/src/send-tools.js +11 -0
  225. package/dist/src/send-tools.js.map +1 -0
  226. package/dist/src/tool-result-guard.d.ts +4 -3
  227. package/dist/src/tool-result-guard.d.ts.map +1 -1
  228. package/dist/src/tool-result-guard.js +5 -4
  229. package/dist/src/tool-result-guard.js.map +1 -1
  230. package/dist/src/tool-result-history.d.ts +1 -1
  231. package/dist/src/tool-result-history.js +1 -1
  232. package/dist/src/tune-out/coordinator.d.ts +21 -0
  233. package/dist/src/tune-out/coordinator.d.ts.map +1 -1
  234. package/dist/src/tune-out/coordinator.js +139 -37
  235. package/dist/src/tune-out/coordinator.js.map +1 -1
  236. package/dist/src/types/agent.d.ts +4 -0
  237. package/dist/src/types/agent.d.ts.map +1 -1
  238. package/dist/src/types/events.d.ts +62 -9
  239. package/dist/src/types/events.d.ts.map +1 -1
  240. package/dist/src/types/framework.d.ts +62 -58
  241. package/dist/src/types/framework.d.ts.map +1 -1
  242. package/dist/src/types/module.d.ts +40 -8
  243. package/dist/src/types/module.d.ts.map +1 -1
  244. package/dist/src/types/trace.d.ts +111 -10
  245. package/dist/src/types/trace.d.ts.map +1 -1
  246. package/dist/src/usage/types.d.ts +16 -0
  247. package/dist/src/usage/types.d.ts.map +1 -1
  248. package/dist/src/usage/usage-tracker.d.ts +14 -1
  249. package/dist/src/usage/usage-tracker.d.ts.map +1 -1
  250. package/dist/src/usage/usage-tracker.js +81 -41
  251. package/dist/src/usage/usage-tracker.js.map +1 -1
  252. package/package.json +6 -5
  253. package/src/agent.ts +93 -12
  254. package/src/api/server.ts +14 -12
  255. package/src/code-execution/engine.ts +595 -0
  256. package/src/code-execution/index.ts +5 -17
  257. package/src/code-execution/isolate/calls.ts +199 -0
  258. package/src/code-execution/isolate/child-entry.ts +5 -0
  259. package/src/code-execution/isolate/child-main.ts +132 -0
  260. package/src/code-execution/isolate/child.ts +327 -0
  261. package/src/code-execution/isolate/frames.ts +209 -0
  262. package/src/code-execution/isolate/output.ts +161 -0
  263. package/src/code-execution/isolate/prelude.ts +409 -0
  264. package/src/code-execution/isolate/protocol.ts +240 -0
  265. package/src/code-execution/isolate/render.ts +230 -0
  266. package/src/code-execution/isolate/runner.ts +911 -0
  267. package/src/code-execution/isolate/scripts.ts +479 -0
  268. package/src/code-execution/quickjs.wasm +0 -0
  269. package/src/code-execution/quickjs.wasm.LICENSES +149 -0
  270. package/src/code-execution/tool-definition.ts +236 -167
  271. package/src/deadline-timer.ts +1 -1
  272. package/src/framework.ts +4468 -2418
  273. package/src/gate/event-gate.ts +78 -11
  274. package/src/held-writes.ts +17 -3
  275. package/src/index.ts +30 -22
  276. package/src/mcpl/channel-registry.ts +1825 -368
  277. package/src/mcpl/conversation-router.ts +12 -7
  278. package/src/mcpl/convert-block.ts +9 -5
  279. package/src/mcpl/inbound-source.ts +131 -0
  280. package/src/mcpl/index.ts +4 -2
  281. package/src/mcpl/log-value.ts +9 -0
  282. package/src/mcpl/modern-connection.ts +162 -53
  283. package/src/mcpl/prose-grammar.ts +4 -5
  284. package/src/mcpl/protocol-family.ts +199 -21
  285. package/src/mcpl/push-coalescer.ts +306 -62
  286. package/src/mcpl/push-handler.ts +10 -2
  287. package/src/mcpl/reference-fetcher.ts +4 -4
  288. package/src/mcpl/server-connection.ts +180 -79
  289. package/src/mcpl/tags.ts +36 -0
  290. package/src/mcpl/tool-result-normalize.ts +2 -1
  291. package/src/mcpl/transport.ts +162 -33
  292. package/src/mcpl/types.ts +23 -6
  293. package/src/module-registry.ts +92 -13
  294. package/src/modules/discord/index.ts +8 -13
  295. package/src/modules/history/index.ts +25 -3
  296. package/src/modules/history/semantic.ts +29 -6
  297. package/src/modules/index.ts +1 -0
  298. package/src/modules/unknown-tool.ts +4 -1
  299. package/src/modules/workspace/branch-intent.ts +3 -1
  300. package/src/modules/workspace/edit-plan.ts +954 -0
  301. package/src/modules/workspace/edit-text.ts +618 -0
  302. package/src/modules/workspace/effects.ts +70 -19
  303. package/src/modules/workspace/index.ts +2247 -642
  304. package/src/modules/workspace/observe.ts +465 -56
  305. package/src/modules/workspace/reconcile.ts +14 -7
  306. package/src/modules/workspace/text.ts +68 -0
  307. package/src/modules/workspace/types.ts +211 -6
  308. package/src/modules/workspace/watcher.ts +3 -2
  309. package/src/operator-log.ts +47 -19
  310. package/src/recovery/discord-awareness-outbox.ts +1500 -356
  311. package/src/recovery/offline-branch.ts +189 -55
  312. package/src/recovery/recover-cli.ts +25 -4
  313. package/src/send-tools.ts +11 -0
  314. package/src/tool-result-guard.ts +6 -5
  315. package/src/tool-result-history.ts +1 -1
  316. package/src/tune-out/coordinator.ts +163 -42
  317. package/src/types/agent.ts +4 -0
  318. package/src/types/events.ts +62 -9
  319. package/src/types/framework.ts +62 -58
  320. package/src/types/module.ts +40 -8
  321. package/src/types/trace.ts +121 -15
  322. package/src/usage/types.ts +16 -0
  323. package/src/usage/usage-tracker.ts +86 -43
  324. package/dist/src/code-execution/py-runner.d.ts +0 -191
  325. package/dist/src/code-execution/py-runner.d.ts.map +0 -1
  326. package/dist/src/code-execution/py-runner.js +0 -655
  327. package/dist/src/code-execution/py-runner.js.map +0 -1
  328. package/dist/src/code-execution/runtime-py.d.ts +0 -50
  329. package/dist/src/code-execution/runtime-py.d.ts.map +0 -1
  330. package/dist/src/code-execution/runtime-py.js +0 -677
  331. package/dist/src/code-execution/runtime-py.js.map +0 -1
  332. package/dist/src/mcpl/prose-stream-router.d.ts +0 -88
  333. package/dist/src/mcpl/prose-stream-router.d.ts.map +0 -1
  334. package/dist/src/mcpl/prose-stream-router.js +0 -291
  335. package/dist/src/mcpl/prose-stream-router.js.map +0 -1
  336. package/src/code-execution/py-runner.ts +0 -791
  337. package/src/code-execution/runtime-py.ts +0 -677
  338. package/src/mcpl/prose-stream-router.ts +0 -268
@@ -0,0 +1,584 @@
1
+ /**
2
+ * What edit and edit_many say: a refusal that names edit's problem, or each of
3
+ * edit_many's problems in edit order, and a receipt that shows each edit's
4
+ * first changed region. What can grow with a call, problems, notes, files and
5
+ * regions, is held to the length the call's result may have
6
+ * (ToolCall.resultMaxChars). Past it, a problem keeps its first line, a region
7
+ * is named by its lines, and the answer's last line counts what it left out;
8
+ * edit's receipt keeps its path and notes whatever their length.
9
+ *
10
+ * Ported from anima-research/hands-mcp's src/edit.ts, where it words the Edit
11
+ * and EditMany tools' answers.
12
+ */
13
+ import { SHOWN_MATCHES } from './edit-plan.js';
14
+ import { MAX_LINE_CHARS, jsonLength, numberedLine, safeCut } from './text.js';
15
+ /** How many runs of edits a list names before it counts the rest. */
16
+ const LISTED_RUNS = 10;
17
+ /**
18
+ * "edit 3", or "edits 1–4, 7 and 9", numbered from 1: three or more edits in a
19
+ * row as a range, and past LISTED_RUNS of those and single edits, how many
20
+ * more, so a label stays short whatever the call's size.
21
+ */
22
+ export function editList(edits) {
23
+ const sorted = [...new Set(edits)].sort((a, b) => a - b).map((edit) => edit + 1);
24
+ if (sorted.length === 1)
25
+ return `edit ${sorted[0]}`;
26
+ const items = [];
27
+ let listed = 0;
28
+ for (let i = 0; i < sorted.length && items.length < LISTED_RUNS;) {
29
+ let j = i;
30
+ while (j + 1 < sorted.length && sorted[j + 1] === sorted[j] + 1)
31
+ j++;
32
+ const run = j - i >= 2;
33
+ items.push(run ? `${sorted[i]}–${sorted[j]}` : `${sorted[i]}`);
34
+ listed += run ? j - i + 1 : 1;
35
+ i = run ? j + 1 : i + 1;
36
+ }
37
+ const more = sorted.length - listed;
38
+ if (more > 0)
39
+ return `edits ${items.join(', ')} and ${more} more`;
40
+ return items.length === 1 ? `edits ${items[0]}` : `edits ${items.slice(0, -1).join(', ')} and ${items.at(-1)}`;
41
+ }
42
+ /**
43
+ * "line 5", "lines 5 and 9", "lines 5, 9 and 12", or "lines 5, 9 and 3
44
+ * more": the lines shown, each once, of `total` lines in all.
45
+ */
46
+ function lineList(shown, total) {
47
+ const more = total - shown.length;
48
+ const list = more > 0 ? `${shown.join(', ')} and ${more} more`
49
+ : shown.length < 2 ? `${shown[0] ?? ''}` : `${shown.slice(0, -1).join(', ')} and ${shown.at(-1)}`;
50
+ return `${plural(total, 'line')} ${list}`;
51
+ }
52
+ /** Each line once, the first SHOWN_MATCHES of them, and how many more, as lineList words them. */
53
+ function onLines(lines) {
54
+ const distinct = [...new Set(lines)];
55
+ return lineList(distinct.slice(0, SHOWN_MATCHES), distinct.length);
56
+ }
57
+ /**
58
+ * Where a count's occurrences are: the lines of those shown, each line once,
59
+ * and whether more occurrences follow them.
60
+ */
61
+ function countLines(problem) {
62
+ return problem.atLeast || problem.found > problem.lines.length
63
+ ? `the first ${problem.lines.length} on ${onLines(problem.lines)}`
64
+ : `on ${onLines(problem.lines)}`;
65
+ }
66
+ /**
67
+ * The edit a problem sorts by: its first. A loop rather than Math.min's
68
+ * spread, since a call's edits can be more than a spread passes as arguments.
69
+ */
70
+ function firstEdit(problem) {
71
+ if (!('edits' in problem))
72
+ return problem.edit;
73
+ let first = Infinity;
74
+ for (const edit of problem.edits)
75
+ if (edit < first)
76
+ first = edit;
77
+ return first;
78
+ }
79
+ const plural = (count, one, many = `${one}s`) => (count === 1 ? one : many);
80
+ /** How a refusal names a reading of an old text, by what it leaves out (readingsOf). */
81
+ const READS = {
82
+ nothing: 'as given',
83
+ cr: "with its last CR read as its CRLF line end's",
84
+ bom: "with its BOM read as the file's own",
85
+ both: "with its BOM read as the file's own and its last CR as a CRLF line end's",
86
+ };
87
+ /** A problem as an agent reads it, without the label edit_many puts before it. */
88
+ function problemText(problem, tool) {
89
+ switch (problem.kind) {
90
+ case 'input':
91
+ case 'file':
92
+ return problem.text;
93
+ case 'mounts':
94
+ return `the edits name files in more than one mount (${problem.mounts.join(', ')}); one call edits the files of one mount, so send the edits for each mount in a call of its own.`;
95
+ case 'miss':
96
+ return `oldString isn't in ${problem.path}.${problem.hint ? `\n${problem.hint}` : ''}\n`
97
+ + `Match exactly, including whitespace and indentation${problem.crlf ? "; the file's CRLF line ends are matched as LF" : ''}.`;
98
+ case 'count': {
99
+ const { found, expected, overlapping } = problem;
100
+ const occurs = `oldString occurs ${problem.atLeast ? 'at least ' : ''}${found} ${plural(found, 'time')} in ${problem.path} (${countLines(problem)})`;
101
+ const quotes = problem.quoteNormalized ? ', with straight and curly quotes treated as equal' : '';
102
+ const overlap = overlapping ? ", and they overlap, so they can't each be replaced" : '';
103
+ if (tool === 'edit') {
104
+ const hint = overlapping
105
+ ? 'Add the text around it to single out the text you mean.'
106
+ : 'Add the text around it to make it unique, or set replaceAll to replace every one.';
107
+ return `${occurs}${quotes}${overlap}. ${hint}\n${problem.shown}`;
108
+ }
109
+ // A count the scan stopped at is a floor, which differs from the one
110
+ // asked for only where it passes it.
111
+ const differs = typeof expected === 'number' && (problem.atLeast ? found > expected : found !== expected);
112
+ const hint = overlapping
113
+ ? 'Include more of the text around it to single out the text you mean.'
114
+ : problem.spent && !differs
115
+ ? `Whether it occurs the ${expected} ${plural(expected, 'time')} it asks for can't be told from this call.`
116
+ : problem.spent
117
+ ? `Include more of the text around it to single out the ${expected === 1 ? 'one' : 'ones'} you mean.`
118
+ : typeof expected === 'number' && found > expected
119
+ ? `Include more of the text around it to single out the ${expected === 1 ? 'one' : 'ones'} you mean, or set occurrences to ${found} if every one should change.`
120
+ : `Set occurrences to ${found} if those are all.`;
121
+ // Why a count is a floor goes on a line of its own, so it doesn't push
122
+ // the hint past the first line's cut (cutLine).
123
+ const floor = problem.spent && !overlapping
124
+ ? `This call counted as many occurrences as one call may, so ${found} is a floor: sent in a call of its own, the edit has every one counted, unless they overlap.\n`
125
+ : '';
126
+ return `${occurs}${quotes}${differs ? `, not ${expected}` : ''}${overlap}. ${hint}\n${floor}${problem.shown}`;
127
+ }
128
+ case 'clash': {
129
+ const [a, b] = problem.edits;
130
+ return problem.same
131
+ ? `edits ${a + 1} and ${b + 1} replace the same text in ${problem.path} (line ${problem.line}); give each its own stretch of text.`
132
+ : `edits ${a + 1} and ${b + 1} overlap in ${problem.path} (from line ${problem.line}); give each its own stretch of text, or make them one edit.`;
133
+ }
134
+ case 'crowded':
135
+ return `they ask for ${problem.asked.toLocaleString('en-US')} occurrences between them in ${problem.path}, whose text, with its line ends read as LF, is ${problem.length.toLocaleString('en-US')} UTF-16 code units long, `
136
+ + 'so some of their matches would overlap; give each its own stretch of text.';
137
+ case 'same':
138
+ return `oldString and newString are the same once the BOM or the line end's CR that oldString carries is read as ${problem.path}'s own, which the file keeps, so there's nothing to change.`;
139
+ case 'readings': {
140
+ const carries = problem.bom && problem.cr ? 'starts with a BOM and ends in a CR' : problem.bom ? 'starts with a BOM' : 'ends in a CR';
141
+ const ways = problem.readings.map((reading) => `${READS[reading.leaves]} (${countLines(reading)})`);
142
+ const list = ways.length < 3 ? ways.join(' and ') : `${ways.slice(0, -1).join(', ')} and ${ways.at(-1)}`;
143
+ // A reading that changes nothing means the file's own BOM or line end's
144
+ // CR, which an edit can't change, so the refusal says so.
145
+ const same = problem.readings.filter((reading) => reading.same);
146
+ const kept = [same.some((reading) => reading.leaves !== 'cr') && 'BOM', same.some((reading) => reading.leaves !== 'bom') && 'line ends'].filter(Boolean).join(' and ');
147
+ // The lines of each reading follow on a line of their own, so however
148
+ // long they run, they don't push the hint past the first line's cut
149
+ // (cutLine).
150
+ return `oldString ${carries}, and occurs in ${problem.path} read more than one way, so which you mean can't be told. `
151
+ + `Include more of the text around it, such as the line before or after it, to say which.\nIt occurs ${list}.`
152
+ + (same.length ? `\nWhere it occurs ${same.map((reading) => READS[reading.leaves]).join(' or ')}, the edit changes nothing, since the file keeps its ${kept}.` : '');
153
+ }
154
+ }
155
+ }
156
+ /** The label edit_many puts before a problem: its edits, or none for a clash, which names its own. */
157
+ function label(problem) {
158
+ if (problem.kind === 'clash' || problem.kind === 'mounts')
159
+ return '';
160
+ return `${'edits' in problem ? editList(problem.edits) : editList([problem.edit])}: `;
161
+ }
162
+ /**
163
+ * A part's first line past this many UTF-16 code units is cut, so one long
164
+ * path or text can't take the room the parts after it need.
165
+ */
166
+ const FIRST_LINE_MAX = 400;
167
+ /** A line cut to FIRST_LINE_MAX, as a part's first line is, and as a thrown message is in an answer's head. */
168
+ export function cutLine(line) {
169
+ return line.length > FIRST_LINE_MAX ? `${line.slice(0, safeCut(line, FIRST_LINE_MAX - 1))}…` : line;
170
+ }
171
+ /**
172
+ * The answer's last line: what it left out, and what to do. `cut` parts left
173
+ * out their details; `problems` and `notes` weren't shown at all. A refusal
174
+ * that leaves out problems, and shows at least one, says to answer those
175
+ * shown and send the call again to see the rest: once those are answered,
176
+ * their room can show the rest, details included. For edits stored, the
177
+ * problems are the files disk refused, and a last line that leaves some out
178
+ * points to ls.
179
+ */
180
+ function tailText(kind, maxChars, cut, problems, notes, anyShown) {
181
+ const items = [
182
+ ...(cut ? [`the details of ${cut} of these`] : []),
183
+ ...(problems ? [kind === 'refusal' ? `${problems} more ${plural(problems, 'problem')}` : `${problems} more ${plural(problems, 'file')} disk refused`] : []),
184
+ ...(notes ? [`${notes} ${plural(notes, 'note')} on the files' copies on disk`] : []),
185
+ ];
186
+ if (!items.length)
187
+ return '';
188
+ const next = kind === 'stored'
189
+ ? problems ? " ls shows each path's state." : ''
190
+ : problems && anyShown ? ' Answer the problems shown and send the call again to see the rest.' : '';
191
+ const list = items.length < 2 ? items[0] : `${items.slice(0, -1).join(', ')} and ${items.at(-1)}`;
192
+ return `[To keep this answer within ${maxChars.toLocaleString('en-US')} characters, it leaves out ${list}.${next}]`;
193
+ }
194
+ /**
195
+ * An answer's head, then its parts joined with blank lines, within
196
+ * `maxChars`: every part's first line while they fit, each cut at
197
+ * FIRST_LINE_MAX, so a call's problems are each named before any is
198
+ * explained, then, in order, the rest of each part whose rest still fits. The
199
+ * parts are `problems`, for edits stored the files disk refused, then `notes`
200
+ * on what the call's settling with disk found. A part whose first line
201
+ * doesn't fit is left out with every part after it. The last line counts
202
+ * what was left out, and for edits stored it never says to send the call
203
+ * again. Never longer than `maxChars`, unless the
204
+ * head and the last line alone are: with 1,000 characters, the least a
205
+ * residence or an agent can set, a refusal names its first problem at least.
206
+ */
207
+ export function fitted(head, problems, notes, maxChars, kind) {
208
+ const parts = [...problems, ...notes];
209
+ // The last line as long as it can be: every count at its most.
210
+ const reserve = tailText(kind, maxChars, parts.length, problems.length, notes.length, true).length + 2;
211
+ let left = maxChars - head.length - reserve;
212
+ const shown = [];
213
+ for (const part of parts) {
214
+ const end = part.indexOf('\n');
215
+ const line = end === -1 ? part : part.slice(0, end);
216
+ const first = cutLine(line);
217
+ // Each part costs the blank line before it too.
218
+ if (first.length + 2 > left)
219
+ break;
220
+ left -= first.length + 2;
221
+ shown.push(first);
222
+ }
223
+ let cut = 0;
224
+ for (const [i, first] of shown.entries()) {
225
+ const rest = parts[i].length - first.length;
226
+ if (rest === 0)
227
+ continue;
228
+ if (rest > left) {
229
+ cut++;
230
+ continue;
231
+ }
232
+ left -= rest;
233
+ shown[i] = parts[i];
234
+ }
235
+ const unshownProblems = Math.max(0, problems.length - shown.length);
236
+ const tail = tailText(kind, maxChars, cut, unshownProblems, parts.length - shown.length - unshownProblems, shown.length > 0);
237
+ return [head, ...shown, tail].filter(Boolean).join('\n\n');
238
+ }
239
+ /**
240
+ * The refusal, within `maxChars`. edit names its first problem after "The
241
+ * edit did nothing: ", unless it is a whole sentence already. edit_many
242
+ * counts its problems and names each, in edit order, labelled with its edits.
243
+ * `notes` follow the problems: which copy of a file the edits looked in, and
244
+ * a conflict with disk, which the agent needs whether or not the call stored
245
+ * anything.
246
+ */
247
+ export function refusalText(tool, problems, notes, maxChars) {
248
+ const sorted = [...problems].sort((a, b) => firstEdit(a) - firstEdit(b));
249
+ if (tool === 'edit') {
250
+ const [problem] = sorted;
251
+ const text = problemText(problem, tool);
252
+ const whole = problem.kind === 'file' && problem.whole ? text : `The edit did nothing: ${text}`;
253
+ return fitted('', [whole], notes, maxChars, 'refusal');
254
+ }
255
+ const head = `The edit_many call stored none of its edits: ${sorted.length} ${plural(sorted.length, 'problem')}.`;
256
+ return fitted(head, sorted.map((problem) => `${label(problem)}${problemText(problem, tool)}`), notes, maxChars, 'refusal');
257
+ }
258
+ /**
259
+ * The region a receipt shows around a change: two lines before it, its new
260
+ * text's lines, and two after, found by scanning for line ends around it,
261
+ * never past the file's end.
262
+ */
263
+ function regionOf(updated, change) {
264
+ const lineStart = (at) => (at === 0 ? 0 : updated.lastIndexOf('\n', at - 1) + 1);
265
+ let start = lineStart(change.at);
266
+ let from = change.line;
267
+ for (let k = 0; k < 2 && start > 0; k++) {
268
+ start = lineStart(start - 1);
269
+ from--;
270
+ }
271
+ let end = lineStart(change.at);
272
+ let to = change.line - 1;
273
+ for (let k = 0; k < change.lines + 2 && end < updated.length; k++) {
274
+ const newline = updated.indexOf('\n', end);
275
+ end = newline === -1 ? updated.length : newline + 1;
276
+ to++;
277
+ }
278
+ return { from, to, start, end };
279
+ }
280
+ /** How much of a long line an excerpt shows before the change it's for. */
281
+ const CHANGE_LEAD = 80;
282
+ /**
283
+ * A line too long to show whole, numbered, as a stretch for each change the
284
+ * receipt shows that starts on it (an edit's first change), at the ascending
285
+ * `columns`: from at most CHANGE_LEAD
286
+ * characters before the change, for as much as read shows of a line.
287
+ * Stretches that meet run together, and each stretch of the line left out is
288
+ * marked with how many characters it holds.
289
+ */
290
+ function excerptLine(line, n, columns) {
291
+ const stretches = [];
292
+ for (const column of columns) {
293
+ // safeCut takes a cut at or before 0 as 0.
294
+ const from = safeCut(line, column - CHANGE_LEAD);
295
+ const to = safeCut(line, from + MAX_LINE_CHARS);
296
+ const last = stretches.at(-1);
297
+ if (last && from <= last.to)
298
+ last.to = Math.max(last.to, to);
299
+ else
300
+ stretches.push({ from, to });
301
+ }
302
+ let text = '';
303
+ let shownTo = 0;
304
+ for (const { from, to } of stretches) {
305
+ if (from > shownTo)
306
+ text += shownTo === 0 ? `[… ${from} chars before] ` : ` [… ${from - shownTo} chars] `;
307
+ text += line.slice(from, to);
308
+ shownTo = to;
309
+ }
310
+ if (shownTo < line.length)
311
+ text += ` [… ${line.length - shownTo} more chars]`;
312
+ return `${String(n).padStart(6)}\t${text}`;
313
+ }
314
+ /**
315
+ * Each edit's first change in a file, as numbered regions merged where they
316
+ * meet, while the budget lasts, counted as the answer's JSON holds them; past
317
+ * it, the regions are named by their lines.
318
+ */
319
+ export function shownRegions(plan, budget, maxChars) {
320
+ const firsts = plan.edits.map((edit) => edit.first).sort((a, b) => a.at - b.at);
321
+ const regions = [];
322
+ for (const change of firsts) {
323
+ // An emptied file's region holds no line, and shows as nothing.
324
+ const region = regionOf(plan.updated, change);
325
+ const last = regions.at(-1);
326
+ if (last && region.from <= last.to + 1) {
327
+ last.to = Math.max(last.to, region.to);
328
+ last.end = Math.max(last.end, region.end);
329
+ }
330
+ else
331
+ regions.push(region);
332
+ }
333
+ // A line shows as the stored bytes hold it, its CRLF end's CR left out
334
+ // unless the line's own text ends in a CR, as a line of the old text shows
335
+ // (shownLine). A CR before a line feed in the updated text is the line's
336
+ // own, unless the edit put it before a bare LF: on disk the two are then a
337
+ // CRLF end, and the line's own text doesn't end in it. The new bytes tell
338
+ // these apart by the CRs before the line feed, read only for a line whose
339
+ // text ends in a CR, at a place that moves forward with the regions' lines.
340
+ // A file's line n is line n of its bytes, since both hold the same line
341
+ // feeds, and a BOM's bytes are neither a line feed nor a CR.
342
+ let byteAt = 0;
343
+ let byteLine = 1;
344
+ const asStored = (text, n, beforeLf) => {
345
+ if (!beforeLf || !text.endsWith('\r'))
346
+ return text;
347
+ for (; byteLine < n; byteLine++)
348
+ byteAt = plan.bytes.indexOf(10, byteAt) + 1;
349
+ const lf = plan.bytes.indexOf(10, byteAt);
350
+ let own = 0;
351
+ while (own < text.length && text.charCodeAt(text.length - 1 - own) === 13)
352
+ own++;
353
+ let stored = 0;
354
+ while (stored <= own && lf - 1 - stored >= byteAt && plan.bytes[lf - 1 - stored] === 13)
355
+ stored++;
356
+ // A CRLF end after the line's own CRs; or a bare LF, whose last CR read
357
+ // takes as the end's unless another comes before it.
358
+ if (stored > own)
359
+ return `${text}\r`;
360
+ return own > 1 ? text : text.slice(0, -1);
361
+ };
362
+ const out = [];
363
+ const omitted = [];
364
+ for (const region of regions) {
365
+ // The region's lines, numbered, built one at a time while they fit, so a
366
+ // region of millions of lines, which is named by its lines, isn't built
367
+ // whole first. The line before it ("…" between regions, or the line end)
368
+ // counts too, and each line feed between its lines.
369
+ let cost = out.length ? jsonLength('\n…\n') : jsonLength('\n');
370
+ const lines = [];
371
+ let fits = !omitted.length;
372
+ for (let lineStart = region.start, n = region.from; fits && lineStart < region.end; n++) {
373
+ const newline = plan.updated.indexOf('\n', lineStart);
374
+ const lineEnd = newline === -1 || newline >= region.end ? region.end : newline;
375
+ const text = asStored(plan.updated.slice(lineStart, lineEnd), n, lineEnd === newline);
376
+ // A line too long to show whole shows its start, or, where edits' first
377
+ // changes start on it, a stretch from shortly before each.
378
+ const columns = text.length > MAX_LINE_CHARS ? firsts.filter((first) => first.line === n).map((first) => first.at - lineStart) : [];
379
+ const numberedText = columns.length ? excerptLine(text, n, columns) : numberedLine(text, n);
380
+ cost += jsonLength(numberedText) + (lines.length ? jsonLength('\n') : 0);
381
+ if (cost > budget.left)
382
+ fits = false;
383
+ else
384
+ lines.push(numberedText);
385
+ lineStart = lineEnd + 1;
386
+ }
387
+ if (fits) {
388
+ budget.left -= cost;
389
+ if (out.length)
390
+ out.push('…');
391
+ out.push(lines.join('\n'));
392
+ }
393
+ else {
394
+ budget.left = 0;
395
+ omitted.push(region.from === region.to ? `${region.from}` : `${region.from}–${region.to}`);
396
+ }
397
+ }
398
+ if (omitted.length) {
399
+ const listed = omitted.slice(0, SHOWN_MATCHES);
400
+ out.push(regionsLeftOut(maxChars, listed, omitted.length - listed.length, omitted.length === 1 && !omitted[0].includes('–')));
401
+ }
402
+ return out;
403
+ }
404
+ /** The note naming the regions of a file a receipt leaves out: the lines of SHOWN_MATCHES at most, and how many more. */
405
+ function regionsLeftOut(maxChars, listed, more, oneLine) {
406
+ return `[not shown, to keep this answer within ${maxChars.toLocaleString('en-US')} characters: ${plural(oneLine ? 1 : 2, 'line')} ${listed.join(', ')}${more ? `, and ${more} more` : ''}]`;
407
+ }
408
+ /**
409
+ * edit_many's last line, counting what its receipt leaves out: files it
410
+ * doesn't list, and of those it lists, the regions, notes and edit numbers it
411
+ * doesn't show. Null when it leaves out nothing.
412
+ */
413
+ function filesLeftOut(maxChars, total, counts) {
414
+ const left = [
415
+ ...(counts.notListed ? [`${counts.notListed} of the call's ${total} ${plural(total, 'file')}`] : []),
416
+ ...(counts.unshown ? [`the changed regions of ${counts.unshown} more ${plural(counts.unshown, 'file')}`] : []),
417
+ ...(counts.notes ? [`the notes of ${counts.notes} ${plural(counts.notes, 'file')}`] : []),
418
+ ...(counts.edits ? [`the edit numbers of ${counts.edits} ${plural(counts.edits, 'file')}`] : []),
419
+ ];
420
+ if (!left.length)
421
+ return null;
422
+ const list = left.length < 2 ? left[0] : `${left.slice(0, -1).join(', ')} and ${left.at(-1)}`;
423
+ return `[To keep this answer within ${maxChars.toLocaleString('en-US')} characters, it leaves out ${list}.]`;
424
+ }
425
+ /** A receipt's note on a file's line ends, if they need one. */
426
+ export function lineEndNote(plan) {
427
+ if (plan.mixed)
428
+ return "The file's mixed line ends are kept: the new text's line ends take those of the text it replaces, by position.";
429
+ return plan.crlf ? "The file's CRLF line ends are kept." : null;
430
+ }
431
+ /**
432
+ * The lines of each edit's replacements after its first, for a receipt: the
433
+ * first SHOWN_MATCHES edits that made more than one, and how many more did.
434
+ */
435
+ export function otherReplacements(plan, labelled) {
436
+ const notes = [];
437
+ let more = 0;
438
+ for (const edit of [...plan.edits].sort((a, b) => a.first.edit - b.first.edit)) {
439
+ if (edit.count < 2)
440
+ continue;
441
+ if (notes.length === SHOWN_MATCHES) {
442
+ more++;
443
+ continue;
444
+ }
445
+ const lines = lineList(edit.otherLines, edit.otherLineCount);
446
+ notes.push(labelled ? `Edit ${edit.first.edit + 1}'s other replacements are on ${lines}.` : `The other replacements are on ${lines}.`);
447
+ }
448
+ if (more)
449
+ notes.push(`${more} more ${plural(more, 'edit')} made other replacements too.`);
450
+ return notes;
451
+ }
452
+ /**
453
+ * What a receipt keeps aside for what it adds after its budget is spent, at
454
+ * its longest for this call, as fitted keeps a refusal's last line: the note
455
+ * naming the regions of the one file whose regions pass the budget, which
456
+ * lists SHOWN_MATCHES of them at most, each as wide as that file's last
457
+ * region line could be, and counts the rest. A file has a region for each
458
+ * edit at most, and a region ends at most two lines past its change's new
459
+ * text (regionOf). Then edit_many's last line, every count at its most. Each
460
+ * with the line feed or blank line before it.
461
+ */
462
+ function receiptReserve(tool, files, maxChars) {
463
+ let regions = 0;
464
+ for (const { plan } of files) {
465
+ if (!plan.edits.length)
466
+ continue;
467
+ let last = 1;
468
+ for (const { first } of plan.edits)
469
+ last = Math.max(last, first.line + first.lines + 1);
470
+ const listed = Math.min(SHOWN_MATCHES, plan.edits.length);
471
+ const range = `${last}–${last}`;
472
+ const note = regionsLeftOut(maxChars, Array.from({ length: listed }, () => range), plan.edits.length - listed, false);
473
+ regions = Math.max(regions, jsonLength('\n') + jsonLength(note));
474
+ }
475
+ if (tool === 'edit')
476
+ return regions;
477
+ const most = files.length;
478
+ return regions + jsonLength('\n\n') + jsonLength(filesLeftOut(maxChars, most, { notListed: most, unshown: most, notes: most, edits: most }));
479
+ }
480
+ /**
481
+ * The receipt of edits stored: each file's size, replacements and notes, and
482
+ * each edit's first changed region, numbered as read numbers lines, held to
483
+ * `maxChars` as the answer's JSON holds it. Its counts and notes come first;
484
+ * the regions take what is left, and past it a file's regions are named by
485
+ * their lines. edit_many lists its files while they fit, a file whose notes
486
+ * don't fit without them, or without its edits' numbers too, and counts the
487
+ * rest. edit's receipt, of one file, keeps its counts and notes and shows no
488
+ * region where those alone pass `maxChars`.
489
+ */
490
+ export function editReceipt(tool, files, editCount, maxChars) {
491
+ const reserve = receiptReserve(tool, files, maxChars);
492
+ const notesOf = ({ plan, notes }) => {
493
+ const lineEnds = lineEndNote(plan);
494
+ return [
495
+ ...notes,
496
+ ...(plan.quoteNormalized.length
497
+ ? [`${tool === 'edit' ? 'The text' : capitalized(editList(plan.quoteNormalized))} matched with straight and curly quotes treated as equal.`]
498
+ : []),
499
+ ...(plan.readForm.length
500
+ ? [`${tool === 'edit' ? 'The text' : capitalized(editList(plan.readForm))} matched without the BOM or the line end's CR `
501
+ + `${tool === 'edit' ? 'it' : plan.readForm.length === 1 ? 'its old text' : 'their old text'} carried, which the file keeps.`]
502
+ : []),
503
+ ...(lineEnds !== null ? [lineEnds] : []),
504
+ ...otherReplacements(plan, tool === 'edit_many'),
505
+ ];
506
+ };
507
+ if (tool === 'edit') {
508
+ const file = files[0];
509
+ const notes = notesOf(file);
510
+ const data = {
511
+ path: file.path,
512
+ size: file.plan.bytes.length,
513
+ replacements: file.plan.replacements,
514
+ ...(notes.length ? { note: notes.join(' ') } : {}),
515
+ ...(file.modeKept ? { modeKept: file.modeKept } : {}),
516
+ changed: '',
517
+ };
518
+ const budget = { left: maxChars - JSON.stringify(data).length - reserve };
519
+ data.changed = shownRegions(file.plan, budget, maxChars).join('\n');
520
+ return data;
521
+ }
522
+ const listed = [];
523
+ const data = {
524
+ edits: editCount,
525
+ replacements: files.reduce((sum, file) => sum + file.plan.replacements, 0),
526
+ files: listed,
527
+ changed: '',
528
+ };
529
+ const fits = (entry) => {
530
+ listed.push(entry);
531
+ const fit = JSON.stringify(data).length <= maxChars - reserve;
532
+ listed.pop();
533
+ return fit;
534
+ };
535
+ let notesLeftOut = 0;
536
+ let editsLeftOut = 0;
537
+ let notListed = 0;
538
+ for (const [i, file] of files.entries()) {
539
+ const notes = notesOf(file);
540
+ const bare = {
541
+ path: file.path,
542
+ size: file.plan.bytes.length,
543
+ replacements: file.plan.replacements,
544
+ ...(file.modeKept ? { modeKept: file.modeKept } : {}),
545
+ };
546
+ const edits = file.plan.edits.map((edit) => edit.first.edit + 1).sort((a, b) => a - b);
547
+ // The fullest entry that fits: with its notes, then without them, then
548
+ // without its edits' numbers too, so a file is named before it's counted.
549
+ const entry = [
550
+ ...(notes.length ? [{ ...bare, edits, note: notes.join(' ') }] : []),
551
+ { ...bare, edits },
552
+ bare,
553
+ ].find(fits);
554
+ if (!entry) {
555
+ notListed = files.length - i;
556
+ data.filesNotListed = notListed;
557
+ break;
558
+ }
559
+ listed.push(entry);
560
+ if (notes.length && !('note' in entry))
561
+ notesLeftOut++;
562
+ if (!('edits' in entry))
563
+ editsLeftOut++;
564
+ }
565
+ const budget = { left: maxChars - JSON.stringify(data).length - reserve };
566
+ const sections = [];
567
+ let unshown = 0;
568
+ for (const file of files.slice(0, listed.length)) {
569
+ const heading = jsonLength(`${file.path}\n`) + (sections.length ? jsonLength('\n\n') : 0);
570
+ if (heading >= budget.left) {
571
+ unshown++;
572
+ continue;
573
+ }
574
+ budget.left -= heading;
575
+ sections.push(`${file.path}\n${shownRegions(file.plan, budget, maxChars).join('\n')}`);
576
+ }
577
+ const last = filesLeftOut(maxChars, files.length, { notListed, unshown, notes: notesLeftOut, edits: editsLeftOut });
578
+ if (last !== null)
579
+ sections.push(last);
580
+ data.changed = sections.join('\n\n');
581
+ return data;
582
+ }
583
+ const capitalized = (value) => value.charAt(0).toUpperCase() + value.slice(1);
584
+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AAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAC3B,OAAO,EAAE,CAAC;YACV,SAAS;QACX,CAAC;QACD,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC;QACvB,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM,IAAI,GAAG,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IACpH,IAAI,IAAI,KAAK,IAAI;QAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}
@@ -31,10 +31,11 @@
31
31
  * unlinked. Content writes stay bound to the descriptor verified before
32
32
  * modification: inside the mount, with no other hard links (a link another
33
33
  * process makes to it after that check shares the write). The hash, which
34
- * reads the whole file, comes before the checks of where the file is, and
35
- * the root is checked again beside the parent, since the parent is found by
36
- * path beneath the root's. A last look at the file (its descriptor's stat
37
- * before a write, its entry's lstat before an unlink) refuses one written
34
+ * reads the whole file, comes after a check of where the file is, which is
35
+ * made again with the others after it, and the root is checked again beside
36
+ * the parent, since the parent is found by path beneath the root's. A last
37
+ * look at the file (its descriptor's stat before a write, its entry's lstat
38
+ * before an unlink) refuses one written
38
39
  * since it was first seen, so only an edit made in the moment between that
39
40
  * look and the effect is overwritten or removed.
40
41
  */