@herbertgao/pi-extensions 2026.10.0 → 2026.10.2

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 (769) hide show
  1. package/README.md +16 -12
  2. package/THIRD_PARTY_NOTICES.md +3 -3
  3. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-audit.md +2 -2
  4. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-debt.md +2 -2
  5. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-gain.md +1 -1
  6. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-help.md +1 -1
  7. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-review.md +2 -2
  8. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail.md +1 -1
  9. package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/index.js +4 -0
  10. package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail-frontmatter.cjs +43 -3
  11. package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail.mjs +142 -59
  12. package/node_modules/@dietrichgebert/ponytail/.qoder/rules/ponytail.md +21 -21
  13. package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +1 -1
  14. package/node_modules/@dietrichgebert/ponytail/AGENTS.md +21 -21
  15. package/node_modules/@dietrichgebert/ponytail/README.md +52 -242
  16. package/node_modules/@dietrichgebert/ponytail/hooks/claude-codex-hooks.json +3 -3
  17. package/node_modules/@dietrichgebert/ponytail/hooks/copilot-hooks.json +4 -4
  18. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-activate.js +70 -16
  19. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-config.js +8 -7
  20. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-instructions.js +30 -30
  21. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-map.js +103 -0
  22. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-mode-tracker.js +46 -23
  23. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-runtime.js +39 -7
  24. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-subagent.js +20 -3
  25. package/node_modules/@dietrichgebert/ponytail/hooks/qoder-hooks.json +3 -3
  26. package/node_modules/@dietrichgebert/ponytail/package.json +3 -3
  27. package/node_modules/@dietrichgebert/ponytail/pi-extension/index.js +47 -17
  28. package/node_modules/@dietrichgebert/ponytail/scripts/uninstall.js +21 -7
  29. package/node_modules/@dietrichgebert/ponytail/skills/plugin.json +5 -0
  30. package/node_modules/@dietrichgebert/ponytail/skills/ponytail/SKILL.md +33 -101
  31. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-audit/SKILL.md +89 -27
  32. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-debt/SKILL.md +13 -12
  33. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-gain/SKILL.md +21 -18
  34. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-help/SKILL.md +12 -13
  35. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-review/SKILL.md +96 -52
  36. package/node_modules/@herbertgao/pi-agency/LICENSE +21 -0
  37. package/node_modules/@herbertgao/pi-agency/README.md +40 -0
  38. package/node_modules/@herbertgao/pi-agency/package.json +53 -0
  39. package/node_modules/@herbertgao/pi-agency/src/index.ts +441 -0
  40. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +12 -12
  41. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +30 -6
  42. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +15 -9
  43. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +27 -9
  44. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/codemode.ts +4 -1
  45. package/node_modules/@herbertgao/pi-cc-extensions/package.json +2 -2
  46. package/node_modules/@narumitw/pi-caffeinate/package.json +4 -4
  47. package/node_modules/@tifan/pi-mermaid-open/package.json +5 -1
  48. package/node_modules/@tifan/pi-mermaid-open/src/index.ts +26 -9
  49. package/node_modules/@tifan/pi-recap/package.json +1 -1
  50. package/node_modules/@tifan/pi-recap/src/index.ts +104 -20
  51. package/node_modules/@tifan/pi-recap/src/models.ts +46 -4
  52. package/node_modules/pi-antigravity/README.md +23 -2
  53. package/node_modules/pi-antigravity/package.json +5 -3
  54. package/node_modules/pi-antigravity/src/diagnostics/diagnostics.ts +3 -2
  55. package/node_modules/pi-antigravity/src/features/generate-image.ts +72 -0
  56. package/node_modules/pi-antigravity/src/features/google-search.ts +71 -0
  57. package/node_modules/pi-antigravity/src/image/image.ts +86 -47
  58. package/node_modules/pi-antigravity/src/image/native.ts +69 -0
  59. package/node_modules/pi-antigravity/src/index.ts +52 -137
  60. package/node_modules/pi-antigravity/src/search/search.ts +130 -31
  61. package/node_modules/pi-antigravity/src/stream/stream.ts +162 -113
  62. package/node_modules/pi-antigravity/src/types/enums.ts +1 -0
  63. package/node_modules/pi-antigravity/src/types/types.ts +1 -1
  64. package/node_modules/pi-antigravity/src/utils/security.ts +47 -1
  65. package/node_modules/pi-antigravity/src/utils/util.ts +38 -6
  66. package/node_modules/pi-lens/CHANGELOG.md +1064 -0
  67. package/node_modules/pi-lens/README.md +115 -25
  68. package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +6 -2
  69. package/node_modules/pi-lens/dist/chunk-22AVIGXS.js +560 -0
  70. package/node_modules/pi-lens/dist/chunk-27BBHSZC.js +106 -0
  71. package/node_modules/pi-lens/dist/chunk-2BEMIWEW.js +51 -0
  72. package/node_modules/pi-lens/dist/chunk-2EECBNC5.js +89 -0
  73. package/node_modules/pi-lens/dist/chunk-34U7PLGE.js +23 -0
  74. package/node_modules/pi-lens/dist/chunk-3I5QFT3N.js +181 -0
  75. package/node_modules/pi-lens/dist/chunk-3MED75HT.js +37 -0
  76. package/node_modules/pi-lens/dist/chunk-47D2BO4S.js +87 -0
  77. package/node_modules/pi-lens/dist/chunk-4RERDEXR.js +348 -0
  78. package/node_modules/pi-lens/dist/chunk-4W2PLC4J.js +27 -0
  79. package/node_modules/pi-lens/dist/chunk-52H5B5TC.js +202 -0
  80. package/node_modules/pi-lens/dist/chunk-54B42YRX.js +27 -0
  81. package/node_modules/pi-lens/dist/chunk-5RXBNSW2.js +266 -0
  82. package/node_modules/pi-lens/dist/chunk-5THXD6X5.js +201 -0
  83. package/node_modules/pi-lens/dist/chunk-5W3R6LFT.js +24 -0
  84. package/node_modules/pi-lens/dist/chunk-5ZEJHV35.js +341 -0
  85. package/node_modules/pi-lens/dist/chunk-6P62QVEA.js +118 -0
  86. package/node_modules/pi-lens/dist/chunk-6QIUX4EP.js +459 -0
  87. package/node_modules/pi-lens/dist/chunk-6VCD4VKZ.js +78 -0
  88. package/node_modules/pi-lens/dist/chunk-7F72PXY2.js +326 -0
  89. package/node_modules/pi-lens/dist/chunk-7FBF7NPR.js +998 -0
  90. package/node_modules/pi-lens/dist/chunk-7U2IDNXN.js +37 -0
  91. package/node_modules/pi-lens/dist/chunk-ABBOA7UD.js +157 -0
  92. package/node_modules/pi-lens/dist/chunk-AHDW3GPE.js +50 -0
  93. package/node_modules/pi-lens/dist/chunk-AJ3QXTRQ.js +756 -0
  94. package/node_modules/pi-lens/dist/chunk-AJVLWNFN.js +1610 -0
  95. package/node_modules/pi-lens/dist/chunk-AJXODZY6.js +112 -0
  96. package/node_modules/pi-lens/dist/chunk-ARFCXG7S.js +84 -0
  97. package/node_modules/pi-lens/dist/chunk-AS44CFQ4.js +708 -0
  98. package/node_modules/pi-lens/dist/chunk-AWE5TMPO.js +38 -0
  99. package/node_modules/pi-lens/dist/chunk-B3I2UUT4.js +4692 -0
  100. package/node_modules/pi-lens/dist/chunk-BRJKOBZP.js +331 -0
  101. package/node_modules/pi-lens/dist/chunk-BW5KFIQC.js +59 -0
  102. package/node_modules/pi-lens/dist/chunk-C2AUYXQH.js +149 -0
  103. package/node_modules/pi-lens/dist/chunk-CGGAIP7J.js +29 -0
  104. package/node_modules/pi-lens/dist/chunk-D6QS3U6M.js +30 -0
  105. package/node_modules/pi-lens/dist/chunk-DFVMIKMQ.js +349 -0
  106. package/node_modules/pi-lens/dist/chunk-DIULIWKU.js +169 -0
  107. package/node_modules/pi-lens/dist/chunk-DQ2NZ7C4.js +2317 -0
  108. package/node_modules/pi-lens/dist/chunk-E2WFBRHM.js +213 -0
  109. package/node_modules/pi-lens/dist/chunk-E4MAEDPM.js +50 -0
  110. package/node_modules/pi-lens/dist/chunk-EOKRQ3SA.js +30 -0
  111. package/node_modules/pi-lens/dist/chunk-F3AU2TMM.js +2626 -0
  112. package/node_modules/pi-lens/dist/chunk-F3P7VQ7H.js +170 -0
  113. package/node_modules/pi-lens/dist/chunk-FC4RP4I2.js +12 -0
  114. package/node_modules/pi-lens/dist/chunk-FJNKANOS.js +32 -0
  115. package/node_modules/pi-lens/dist/chunk-GUOGVTCQ.js +146 -0
  116. package/node_modules/pi-lens/dist/chunk-GVXA6CCE.js +18 -0
  117. package/node_modules/pi-lens/dist/chunk-HHYAELLJ.js +2334 -0
  118. package/node_modules/pi-lens/dist/chunk-HMFXILPV.js +83 -0
  119. package/node_modules/pi-lens/dist/chunk-HVUZXSWK.js +421 -0
  120. package/node_modules/pi-lens/dist/chunk-HWBZIGMJ.js +62 -0
  121. package/node_modules/pi-lens/dist/chunk-I3R7GKDR.js +17 -0
  122. package/node_modules/pi-lens/dist/chunk-I7SPGOWI.js +55 -0
  123. package/node_modules/pi-lens/dist/chunk-IIXOAGHR.js +38 -0
  124. package/node_modules/pi-lens/dist/chunk-IVP5KAB7.js +2250 -0
  125. package/node_modules/pi-lens/dist/chunk-IXEBJSUE.js +22 -0
  126. package/node_modules/pi-lens/dist/chunk-JOLITGCC.js +27 -0
  127. package/node_modules/pi-lens/dist/chunk-K6VYLB2U.js +145 -0
  128. package/node_modules/pi-lens/dist/chunk-LJDODBBZ.js +78 -0
  129. package/node_modules/pi-lens/dist/chunk-LNAKEO63.js +78 -0
  130. package/node_modules/pi-lens/dist/chunk-LSMJ6KBE.js +4139 -0
  131. package/node_modules/pi-lens/dist/chunk-LW6XKDZQ.js +5565 -0
  132. package/node_modules/pi-lens/dist/chunk-N3YQJI6O.js +899 -0
  133. package/node_modules/pi-lens/dist/chunk-NABLC7W3.js +148 -0
  134. package/node_modules/pi-lens/dist/chunk-NKOUFPQF.js +659 -0
  135. package/node_modules/pi-lens/dist/chunk-NL5GLMFI.js +211 -0
  136. package/node_modules/pi-lens/dist/chunk-NMABWBZN.js +327 -0
  137. package/node_modules/pi-lens/dist/chunk-NTHH2J74.js +27 -0
  138. package/node_modules/pi-lens/dist/chunk-NTUJEGDZ.js +59 -0
  139. package/node_modules/pi-lens/dist/chunk-NXL4FFQQ.js +47 -0
  140. package/node_modules/pi-lens/dist/chunk-NXPS2L6U.js +466 -0
  141. package/node_modules/pi-lens/dist/chunk-O5WILGMI.js +42 -0
  142. package/node_modules/pi-lens/dist/chunk-O6TQT6RI.js +48 -0
  143. package/node_modules/pi-lens/dist/chunk-OAXNDZJ7.js +323 -0
  144. package/node_modules/pi-lens/dist/chunk-ODEEOXPH.js +44 -0
  145. package/node_modules/pi-lens/dist/chunk-OQGFCZJ4.js +4533 -0
  146. package/node_modules/pi-lens/dist/chunk-ORTMY4Q4.js +282 -0
  147. package/node_modules/pi-lens/dist/chunk-OS32RNR2.js +442 -0
  148. package/node_modules/pi-lens/dist/chunk-PAK6IDME.js +189 -0
  149. package/node_modules/pi-lens/dist/chunk-PWFHBTSF.js +406 -0
  150. package/node_modules/pi-lens/dist/chunk-Q5U6FMDI.js +2352 -0
  151. package/node_modules/pi-lens/dist/chunk-QOZXJ4NA.js +3364 -0
  152. package/node_modules/pi-lens/dist/chunk-QYF5S6P6.js +45 -0
  153. package/node_modules/pi-lens/dist/chunk-RIISMHKN.js +36 -0
  154. package/node_modules/pi-lens/dist/chunk-RPD4ZSB7.js +25 -0
  155. package/node_modules/pi-lens/dist/chunk-RPD5K5NC.js +79 -0
  156. package/node_modules/pi-lens/dist/chunk-RUOG5D2C.js +262 -0
  157. package/node_modules/pi-lens/dist/chunk-T4ERT73Y.js +599 -0
  158. package/node_modules/pi-lens/dist/chunk-T6D4Q4AQ.js +54 -0
  159. package/node_modules/pi-lens/dist/chunk-TGPXLY2J.js +391 -0
  160. package/node_modules/pi-lens/dist/chunk-TLGFBM3F.js +12116 -0
  161. package/node_modules/pi-lens/dist/chunk-TO6WL3GM.js +88 -0
  162. package/node_modules/pi-lens/dist/chunk-TT22N74J.js +517 -0
  163. package/node_modules/pi-lens/dist/chunk-TVN5N6GY.js +21216 -0
  164. package/node_modules/pi-lens/dist/chunk-U3VGR4VU.js +308 -0
  165. package/node_modules/pi-lens/dist/chunk-UK3CMEAL.js +1250 -0
  166. package/node_modules/pi-lens/dist/chunk-UOPVJQ4N.js +103 -0
  167. package/node_modules/pi-lens/dist/chunk-UXVNL3D7.js +23 -0
  168. package/node_modules/pi-lens/dist/chunk-UY752QSN.js +45 -0
  169. package/node_modules/pi-lens/dist/chunk-V5PXFSZK.js +188 -0
  170. package/node_modules/pi-lens/dist/chunk-V7R425XG.js +398 -0
  171. package/node_modules/pi-lens/dist/chunk-VCSRSYLF.js +81 -0
  172. package/node_modules/pi-lens/dist/chunk-VD4JQCQC.js +162 -0
  173. package/node_modules/pi-lens/dist/chunk-VDBPVIKD.js +62 -0
  174. package/node_modules/pi-lens/dist/chunk-VHQLPIRJ.js +114 -0
  175. package/node_modules/pi-lens/dist/chunk-VN2AXLEX.js +5414 -0
  176. package/node_modules/pi-lens/dist/chunk-VNMT7C64.js +478 -0
  177. package/node_modules/pi-lens/dist/chunk-WONERJTP.js +309 -0
  178. package/node_modules/pi-lens/dist/chunk-XECLWQZN.js +85 -0
  179. package/node_modules/pi-lens/dist/chunk-XIMYZ3JA.js +27 -0
  180. package/node_modules/pi-lens/dist/chunk-XK4CIILI.js +144 -0
  181. package/node_modules/pi-lens/dist/chunk-Y4T27COV.js +562 -0
  182. package/node_modules/pi-lens/dist/chunk-YGVYKNSN.js +1860 -0
  183. package/node_modules/pi-lens/dist/chunk-YLF3PPT5.js +308 -0
  184. package/node_modules/pi-lens/dist/chunk-YSNFMJKN.js +14 -0
  185. package/node_modules/pi-lens/dist/chunk-Z3CCVDUB.js +76 -0
  186. package/node_modules/pi-lens/dist/chunk-Z54ZSOBZ.js +61 -0
  187. package/node_modules/pi-lens/dist/chunk-ZAWW3AF6.js +97 -0
  188. package/node_modules/pi-lens/dist/chunk-ZMOL6RQC.js +167 -0
  189. package/node_modules/pi-lens/dist/index.js +16456 -8335
  190. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +186 -232
  191. package/node_modules/pi-lens/dist/mcp/cli.js +137 -98
  192. package/node_modules/pi-lens/dist/mcp/server.js +22589 -1573
  193. package/node_modules/pi-lens/dist/mcp/worker.js +97 -38
  194. package/node_modules/pi-lens/dist/probes/installer.js +135 -0
  195. package/node_modules/pi-lens/dist/workers/project-snapshot-persist-worker.js +22 -0
  196. package/node_modules/pi-lens/dist/workers/review-graph-persist-worker.js +15 -0
  197. package/node_modules/pi-lens/docs/agent-guide.md +13 -4
  198. package/node_modules/pi-lens/docs/agent-tools.md +42 -0
  199. package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +3 -2
  200. package/node_modules/pi-lens/docs/configuration.md +20 -1
  201. package/node_modules/pi-lens/docs/environment-variables.md +52 -2
  202. package/node_modules/pi-lens/docs/features.md +8 -4
  203. package/node_modules/pi-lens/docs/globalconfig.md +1 -0
  204. package/node_modules/pi-lens/docs/io-bridge-v2-migration.md +94 -0
  205. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +36 -4
  206. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +124 -0
  207. package/node_modules/pi-lens/docs/mcp.md +21 -5
  208. package/node_modules/pi-lens/docs/merge-queue-rollout.md +77 -0
  209. package/node_modules/pi-lens/docs/pi-lens-fixer.md +156 -88
  210. package/node_modules/pi-lens/docs/pi-lens-investigator.md +74 -26
  211. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +694 -0
  212. package/node_modules/pi-lens/docs/pi-lens-monitor.md +73 -7
  213. package/node_modules/pi-lens/docs/pi-lens-retro.md +6 -4
  214. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +188 -48
  215. package/node_modules/pi-lens/docs/pi-lens-subagent.md +246 -45
  216. package/node_modules/pi-lens/docs/pi-lens-warden.md +18 -7
  217. package/node_modules/pi-lens/docs/public-api-stability.md +55 -0
  218. package/node_modules/pi-lens/docs/release-qa-baseline.md +84 -17
  219. package/node_modules/pi-lens/docs/rfcs/3654-unified-io-bridge-v2.md +316 -0
  220. package/node_modules/pi-lens/docs/servercapabilities.md +53 -49
  221. package/node_modules/pi-lens/docs/settings.md +1 -0
  222. package/node_modules/pi-lens/docs/usage.md +5 -1
  223. package/node_modules/pi-lens/grammars/tree-sitter-bash.wasm +0 -0
  224. package/node_modules/pi-lens/grammars/tree-sitter-bash.wasm.json +3 -3
  225. package/node_modules/pi-lens/package.json +18 -6
  226. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/advisory-registry-subset-test.yml +41 -0
  227. package/node_modules/pi-lens/rules/ast-grep-rules/rules/advisory-registry-subset.yml +50 -0
  228. package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +1275 -62
  229. package/node_modules/pi-lens/scripts/download-grammars.js +5 -0
  230. package/node_modules/pi-lens/scripts/grammars.lock.json +6 -1
  231. package/node_modules/pi-lens/scripts/install-selftest.mjs +33 -34
  232. package/node_modules/pi-lens/scripts/lib/host-provided-deps.mjs +13 -4
  233. package/node_modules/pi-lens/scripts/lib/web-tree-sitter-dir.mjs +18 -0
  234. package/node_modules/pi-typesafe/README.md +1 -1
  235. package/node_modules/pi-typesafe/dist/backends.d.ts +15 -5
  236. package/node_modules/pi-typesafe/dist/backends.js +18 -0
  237. package/node_modules/pi-typesafe/dist/client.d.ts +4 -3
  238. package/node_modules/pi-typesafe/dist/client.js +22 -7
  239. package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
  240. package/node_modules/pi-typesafe/dist/index.js +1 -1
  241. package/node_modules/pi-typesafe/dist/usage.d.ts +14 -4
  242. package/node_modules/pi-typesafe/dist/usage.js +147 -42
  243. package/node_modules/pi-typesafe/package.json +1 -1
  244. package/node_modules/pi-web-access/CHANGELOG.md +48 -0
  245. package/node_modules/pi-web-access/README.md +57 -11
  246. package/node_modules/pi-web-access/brave-rate-limit.ts +8 -2
  247. package/node_modules/pi-web-access/curator-page.ts +5 -1
  248. package/node_modules/pi-web-access/curator-server.ts +2 -0
  249. package/node_modules/pi-web-access/declared-web-links.ts +2 -2
  250. package/node_modules/pi-web-access/degoog.ts +323 -0
  251. package/node_modules/pi-web-access/dist/index.js +3483 -2745
  252. package/node_modules/pi-web-access/dist/mcp-cli.js +27443 -0
  253. package/node_modules/pi-web-access/exa.ts +5 -1
  254. package/node_modules/pi-web-access/extract.ts +41 -3
  255. package/node_modules/pi-web-access/firecrawl.ts +35 -4
  256. package/node_modules/pi-web-access/gemini-search.ts +34 -11
  257. package/node_modules/pi-web-access/gemini-web.ts +14 -9
  258. package/node_modules/pi-web-access/index.ts +153 -1202
  259. package/node_modules/pi-web-access/keenable.ts +221 -0
  260. package/node_modules/pi-web-access/mcp-cli.ts +40 -0
  261. package/node_modules/pi-web-access/mcp-server.ts +81 -0
  262. package/node_modules/pi-web-access/mcp-tool-definitions.ts +117 -0
  263. package/node_modules/pi-web-access/openai-search.ts +34 -1
  264. package/node_modules/pi-web-access/package.json +23 -5
  265. package/node_modules/pi-web-access/perplexity.ts +64 -56
  266. package/node_modules/pi-web-access/tool-arguments.ts +20 -0
  267. package/node_modules/pi-web-access/video-extract.ts +1 -1
  268. package/node_modules/pi-web-access/web-tool-contract.ts +86 -0
  269. package/node_modules/pi-web-access/web-tool-core.ts +1502 -0
  270. package/node_modules/pi-web-access/youtube-extract.ts +2 -5
  271. package/package.json +17 -12
  272. package/node_modules/@dietrichgebert/ponytail/README.es.md +0 -329
  273. package/node_modules/@dietrichgebert/ponytail/README.ko.md +0 -346
  274. package/node_modules/@dietrichgebert/ponytail/assets/benchmark-3model.svg +0 -21
  275. package/node_modules/@dietrichgebert/ponytail/assets/benchmark-agentic.svg +0 -62
  276. package/node_modules/@dietrichgebert/ponytail/assets/logo-dark.png +0 -0
  277. package/node_modules/@dietrichgebert/ponytail/assets/logo-dark.svg +0 -115
  278. package/node_modules/@dietrichgebert/ponytail/assets/logo-greenpt-dark.svg +0 -27
  279. package/node_modules/@dietrichgebert/ponytail/assets/logo-greenpt.svg +0 -27
  280. package/node_modules/@dietrichgebert/ponytail/assets/logo.png +0 -0
  281. package/node_modules/@dietrichgebert/ponytail/assets/retriever-icon.png +0 -0
  282. package/node_modules/@dietrichgebert/ponytail/assets/retriever-logo-dark.svg +0 -4
  283. package/node_modules/@dietrichgebert/ponytail/assets/retriever-logo-light.svg +0 -4
  284. package/node_modules/@dietrichgebert/ponytail/assets/social-preview.png +0 -0
  285. package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner-es.png +0 -0
  286. package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner-ko.png +0 -0
  287. package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner.png +0 -0
  288. package/node_modules/pi-lens/dist/clients/actionable-warnings-logger.js +0 -35
  289. package/node_modules/pi-lens/dist/clients/actionable-warnings.js +0 -1610
  290. package/node_modules/pi-lens/dist/clients/advisory-provenance.js +0 -593
  291. package/node_modules/pi-lens/dist/clients/agent-behavior-client.js +0 -147
  292. package/node_modules/pi-lens/dist/clients/agent-nudge.js +0 -325
  293. package/node_modules/pi-lens/dist/clients/analysed-root.js +0 -1
  294. package/node_modules/pi-lens/dist/clients/ast-grep-client.js +0 -731
  295. package/node_modules/pi-lens/dist/clients/ast-grep-rule-manager.js +0 -146
  296. package/node_modules/pi-lens/dist/clients/ast-grep-tool-logger.js +0 -118
  297. package/node_modules/pi-lens/dist/clients/ast-grep-types.js +0 -10
  298. package/node_modules/pi-lens/dist/clients/ast-grep-yaml-synth.js +0 -154
  299. package/node_modules/pi-lens/dist/clients/atomic-write-staging.js +0 -75
  300. package/node_modules/pi-lens/dist/clients/atomic-write.js +0 -189
  301. package/node_modules/pi-lens/dist/clients/availability-probe-flight.js +0 -12
  302. package/node_modules/pi-lens/dist/clients/bash-file-access.js +0 -1056
  303. package/node_modules/pi-lens/dist/clients/biome-client.js +0 -357
  304. package/node_modules/pi-lens/dist/clients/blocker-freshness.js +0 -837
  305. package/node_modules/pi-lens/dist/clients/blocker-past-eof.js +0 -129
  306. package/node_modules/pi-lens/dist/clients/bootstrap.js +0 -569
  307. package/node_modules/pi-lens/dist/clients/bounded-cache.js +0 -190
  308. package/node_modules/pi-lens/dist/clients/bounded-pid-file-lock.js +0 -202
  309. package/node_modules/pi-lens/dist/clients/bounded-telemetry.js +0 -295
  310. package/node_modules/pi-lens/dist/clients/build-identity.js +0 -95
  311. package/node_modules/pi-lens/dist/clients/bundled-resource-health.js +0 -113
  312. package/node_modules/pi-lens/dist/clients/bus-events-logger.js +0 -105
  313. package/node_modules/pi-lens/dist/clients/bus-publish.js +0 -171
  314. package/node_modules/pi-lens/dist/clients/cache/rule-cache.js +0 -190
  315. package/node_modules/pi-lens/dist/clients/cache-manager.js +0 -524
  316. package/node_modules/pi-lens/dist/clients/cache-observability.js +0 -1313
  317. package/node_modules/pi-lens/dist/clients/call-graph.js +0 -852
  318. package/node_modules/pi-lens/dist/clients/cargo-manifest.js +0 -422
  319. package/node_modules/pi-lens/dist/clients/cascade-budget.js +0 -196
  320. package/node_modules/pi-lens/dist/clients/cascade-format.js +0 -315
  321. package/node_modules/pi-lens/dist/clients/cascade-logger.js +0 -31
  322. package/node_modules/pi-lens/dist/clients/cascade-types.js +0 -9
  323. package/node_modules/pi-lens/dist/clients/child-unref.js +0 -124
  324. package/node_modules/pi-lens/dist/clients/code-quality-warnings.js +0 -286
  325. package/node_modules/pi-lens/dist/clients/codebase-model.js +0 -173
  326. package/node_modules/pi-lens/dist/clients/collateral-test-role.js +0 -40
  327. package/node_modules/pi-lens/dist/clients/complexity-client.js +0 -462
  328. package/node_modules/pi-lens/dist/clients/config-core/deny.js +0 -221
  329. package/node_modules/pi-lens/dist/clients/config-core/index.js +0 -50
  330. package/node_modules/pi-lens/dist/clients/config-core/merge.js +0 -357
  331. package/node_modules/pi-lens/dist/clients/config-core/normalize.js +0 -340
  332. package/node_modules/pi-lens/dist/clients/config-core/process-spec.js +0 -248
  333. package/node_modules/pi-lens/dist/clients/config-core/provenance.js +0 -164
  334. package/node_modules/pi-lens/dist/clients/config-core/records.js +0 -218
  335. package/node_modules/pi-lens/dist/clients/config-core/resolve.js +0 -125
  336. package/node_modules/pi-lens/dist/clients/config-core/safe-object.js +0 -78
  337. package/node_modules/pi-lens/dist/clients/config-core/schema.js +0 -165
  338. package/node_modules/pi-lens/dist/clients/config-diagnostic-codes.js +0 -285
  339. package/node_modules/pi-lens/dist/clients/config-locations.js +0 -388
  340. package/node_modules/pi-lens/dist/clients/config-resolve.js +0 -798
  341. package/node_modules/pi-lens/dist/clients/config-schema.js +0 -251
  342. package/node_modules/pi-lens/dist/clients/config-warn.js +0 -407
  343. package/node_modules/pi-lens/dist/clients/console-guard-install.js +0 -26
  344. package/node_modules/pi-lens/dist/clients/cooperative-budget.js +0 -42
  345. package/node_modules/pi-lens/dist/clients/dead-code-client.js +0 -510
  346. package/node_modules/pi-lens/dist/clients/dead-code-logger.js +0 -30
  347. package/node_modules/pi-lens/dist/clients/deadline-utils.js +0 -280
  348. package/node_modules/pi-lens/dist/clients/debug-handles.js +0 -211
  349. package/node_modules/pi-lens/dist/clients/debug-heap.js +0 -174
  350. package/node_modules/pi-lens/dist/clients/deferred-lsp-work.js +0 -106
  351. package/node_modules/pi-lens/dist/clients/degradation-ledger.js +0 -426
  352. package/node_modules/pi-lens/dist/clients/demoted-finding-render.js +0 -169
  353. package/node_modules/pi-lens/dist/clients/dependency-checker.js +0 -885
  354. package/node_modules/pi-lens/dist/clients/deps/ast-grep-napi.js +0 -22
  355. package/node_modules/pi-lens/dist/clients/deps/js-yaml.js +0 -9
  356. package/node_modules/pi-lens/dist/clients/deps/minimatch.js +0 -4
  357. package/node_modules/pi-lens/dist/clients/deps/pi-tui.js +0 -14
  358. package/node_modules/pi-lens/dist/clients/deps/typebox.js +0 -14
  359. package/node_modules/pi-lens/dist/clients/deps/vscode-jsonrpc.js +0 -1
  360. package/node_modules/pi-lens/dist/clients/deps/web-tree-sitter.js +0 -24
  361. package/node_modules/pi-lens/dist/clients/diagnostic-dispositions.js +0 -630
  362. package/node_modules/pi-lens/dist/clients/diagnostic-line-freshness.js +0 -305
  363. package/node_modules/pi-lens/dist/clients/diagnostic-logger.js +0 -73
  364. package/node_modules/pi-lens/dist/clients/diagnostic-tracker.js +0 -105
  365. package/node_modules/pi-lens/dist/clients/diagnostics-publish.js +0 -230
  366. package/node_modules/pi-lens/dist/clients/dispatch/ast-grep-catalog.js +0 -65
  367. package/node_modules/pi-lens/dist/clients/dispatch/auxiliary-lsp.js +0 -343
  368. package/node_modules/pi-lens/dist/clients/dispatch/collect-later-tier.js +0 -35
  369. package/node_modules/pi-lens/dist/clients/dispatch/diagnostic-taxonomy.js +0 -66
  370. package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +0 -1269
  371. package/node_modules/pi-lens/dist/clients/dispatch/fact-provider-types.js +0 -1
  372. package/node_modules/pi-lens/dist/clients/dispatch/fact-rule-runner.js +0 -17
  373. package/node_modules/pi-lens/dist/clients/dispatch/fact-runner.js +0 -30
  374. package/node_modules/pi-lens/dist/clients/dispatch/fact-scheduler.js +0 -68
  375. package/node_modules/pi-lens/dist/clients/dispatch/fact-store.js +0 -377
  376. package/node_modules/pi-lens/dist/clients/dispatch/facts/comment-facts.js +0 -22
  377. package/node_modules/pi-lens/dist/clients/dispatch/facts/file-content.js +0 -19
  378. package/node_modules/pi-lens/dist/clients/dispatch/facts/function-facts.js +0 -348
  379. package/node_modules/pi-lens/dist/clients/dispatch/facts/import-facts.js +0 -204
  380. package/node_modules/pi-lens/dist/clients/dispatch/facts/tree-sitter-facts.js +0 -34
  381. package/node_modules/pi-lens/dist/clients/dispatch/facts/try-catch-facts.js +0 -119
  382. package/node_modules/pi-lens/dist/clients/dispatch/finding-policy.js +0 -339
  383. package/node_modules/pi-lens/dist/clients/dispatch/indent-detect.js +0 -417
  384. package/node_modules/pi-lens/dist/clients/dispatch/inline-suppressions.js +0 -89
  385. package/node_modules/pi-lens/dist/clients/dispatch/integration.js +0 -2377
  386. package/node_modules/pi-lens/dist/clients/dispatch/lazy.js +0 -11
  387. package/node_modules/pi-lens/dist/clients/dispatch/pending-runner-findings.js +0 -87
  388. package/node_modules/pi-lens/dist/clients/dispatch/plan.js +0 -278
  389. package/node_modules/pi-lens/dist/clients/dispatch/priorities.js +0 -20
  390. package/node_modules/pi-lens/dist/clients/dispatch/rule-id-normalize.js +0 -50
  391. package/node_modules/pi-lens/dist/clients/dispatch/rule-ignores.js +0 -69
  392. package/node_modules/pi-lens/dist/clients/dispatch/rule-policy.js +0 -135
  393. package/node_modules/pi-lens/dist/clients/dispatch/rules/async-noise.js +0 -40
  394. package/node_modules/pi-lens/dist/clients/dispatch/rules/async-unnecessary-wrapper.js +0 -27
  395. package/node_modules/pi-lens/dist/clients/dispatch/rules/cors-wildcard.js +0 -54
  396. package/node_modules/pi-lens/dist/clients/dispatch/rules/error-obscuring.js +0 -32
  397. package/node_modules/pi-lens/dist/clients/dispatch/rules/error-swallowing.js +0 -31
  398. package/node_modules/pi-lens/dist/clients/dispatch/rules/framework-call-noise.js +0 -67
  399. package/node_modules/pi-lens/dist/clients/dispatch/rules/high-complexity.js +0 -72
  400. package/node_modules/pi-lens/dist/clients/dispatch/rules/high-fan-out.js +0 -74
  401. package/node_modules/pi-lens/dist/clients/dispatch/rules/high-import-coupling.js +0 -37
  402. package/node_modules/pi-lens/dist/clients/dispatch/rules/missing-error-propagation.js +0 -62
  403. package/node_modules/pi-lens/dist/clients/dispatch/rules/no-commented-credentials.js +0 -52
  404. package/node_modules/pi-lens/dist/clients/dispatch/rules/pass-through-wrappers.js +0 -42
  405. package/node_modules/pi-lens/dist/clients/dispatch/rules/placeholder-comments.js +0 -40
  406. package/node_modules/pi-lens/dist/clients/dispatch/rules/unsafe-boundary.js +0 -126
  407. package/node_modules/pi-lens/dist/clients/dispatch/runner-context.js +0 -52
  408. package/node_modules/pi-lens/dist/clients/dispatch/runners/actionlint.js +0 -111
  409. package/node_modules/pi-lens/dist/clients/dispatch/runners/ast-grep-napi.js +0 -1196
  410. package/node_modules/pi-lens/dist/clients/dispatch/runners/biome-check.js +0 -296
  411. package/node_modules/pi-lens/dist/clients/dispatch/runners/cpp-check.js +0 -219
  412. package/node_modules/pi-lens/dist/clients/dispatch/runners/credo.js +0 -82
  413. package/node_modules/pi-lens/dist/clients/dispatch/runners/cue-vet.js +0 -416
  414. package/node_modules/pi-lens/dist/clients/dispatch/runners/dart-analyze.js +0 -183
  415. package/node_modules/pi-lens/dist/clients/dispatch/runners/detekt.js +0 -176
  416. package/node_modules/pi-lens/dist/clients/dispatch/runners/dotnet-build.js +0 -164
  417. package/node_modules/pi-lens/dist/clients/dispatch/runners/elixir-check.js +0 -195
  418. package/node_modules/pi-lens/dist/clients/dispatch/runners/eslint.js +0 -137
  419. package/node_modules/pi-lens/dist/clients/dispatch/runners/fact-rules.js +0 -29
  420. package/node_modules/pi-lens/dist/clients/dispatch/runners/fish-indent.js +0 -69
  421. package/node_modules/pi-lens/dist/clients/dispatch/runners/gleam-check.js +0 -167
  422. package/node_modules/pi-lens/dist/clients/dispatch/runners/go-vet.js +0 -104
  423. package/node_modules/pi-lens/dist/clients/dispatch/runners/golangci-lint.js +0 -135
  424. package/node_modules/pi-lens/dist/clients/dispatch/runners/hadolint.js +0 -91
  425. package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-lint.js +0 -171
  426. package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-render.js +0 -940
  427. package/node_modules/pi-lens/dist/clients/dispatch/runners/htmlhint.js +0 -117
  428. package/node_modules/pi-lens/dist/clients/dispatch/runners/index.js +0 -108
  429. package/node_modules/pi-lens/dist/clients/dispatch/runners/javac.js +0 -99
  430. package/node_modules/pi-lens/dist/clients/dispatch/runners/ktlint.js +0 -110
  431. package/node_modules/pi-lens/dist/clients/dispatch/runners/lsp.js +0 -379
  432. package/node_modules/pi-lens/dist/clients/dispatch/runners/markdownlint.js +0 -167
  433. package/node_modules/pi-lens/dist/clients/dispatch/runners/mypy.js +0 -102
  434. package/node_modules/pi-lens/dist/clients/dispatch/runners/oxlint.js +0 -414
  435. package/node_modules/pi-lens/dist/clients/dispatch/runners/php-lint.js +0 -85
  436. package/node_modules/pi-lens/dist/clients/dispatch/runners/phpstan.js +0 -120
  437. package/node_modules/pi-lens/dist/clients/dispatch/runners/prisma-validate.js +0 -62
  438. package/node_modules/pi-lens/dist/clients/dispatch/runners/psscriptanalyzer.js +0 -445
  439. package/node_modules/pi-lens/dist/clients/dispatch/runners/pyright.js +0 -169
  440. package/node_modules/pi-lens/dist/clients/dispatch/runners/rubocop.js +0 -99
  441. package/node_modules/pi-lens/dist/clients/dispatch/runners/ruff.js +0 -88
  442. package/node_modules/pi-lens/dist/clients/dispatch/runners/rust-clippy.js +0 -256
  443. package/node_modules/pi-lens/dist/clients/dispatch/runners/shellcheck.js +0 -173
  444. package/node_modules/pi-lens/dist/clients/dispatch/runners/shfmt.js +0 -102
  445. package/node_modules/pi-lens/dist/clients/dispatch/runners/spellcheck.js +0 -128
  446. package/node_modules/pi-lens/dist/clients/dispatch/runners/spotbugs.js +0 -259
  447. package/node_modules/pi-lens/dist/clients/dispatch/runners/sqlfluff.js +0 -183
  448. package/node_modules/pi-lens/dist/clients/dispatch/runners/stylelint.js +0 -166
  449. package/node_modules/pi-lens/dist/clients/dispatch/runners/swiftlint.js +0 -163
  450. package/node_modules/pi-lens/dist/clients/dispatch/runners/taplo.js +0 -174
  451. package/node_modules/pi-lens/dist/clients/dispatch/runners/terragrunt.js +0 -168
  452. package/node_modules/pi-lens/dist/clients/dispatch/runners/tflint.js +0 -125
  453. package/node_modules/pi-lens/dist/clients/dispatch/runners/tree-sitter.js +0 -643
  454. package/node_modules/pi-lens/dist/clients/dispatch/runners/trivy-config.js +0 -253
  455. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/availability-policy.js +0 -496
  456. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/candidate-probe.js +0 -90
  457. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -95
  458. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/lazy-installer.js +0 -274
  459. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +0 -1701
  460. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/spawn-outcome.js +0 -101
  461. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/tool-failure.js +0 -235
  462. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/toolchain-availability.js +0 -169
  463. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils.js +0 -15
  464. package/node_modules/pi-lens/dist/clients/dispatch/runners/vale.js +0 -128
  465. package/node_modules/pi-lens/dist/clients/dispatch/runners/yaml-rule-parser.js +0 -242
  466. package/node_modules/pi-lens/dist/clients/dispatch/runners/yamllint.js +0 -95
  467. package/node_modules/pi-lens/dist/clients/dispatch/runners/zig-check.js +0 -79
  468. package/node_modules/pi-lens/dist/clients/dispatch/suppress-writer.js +0 -79
  469. package/node_modules/pi-lens/dist/clients/dispatch/tool-profile.js +0 -30
  470. package/node_modules/pi-lens/dist/clients/dispatch/types.js +0 -21
  471. package/node_modules/pi-lens/dist/clients/dispatch/utils/format-utils.js +0 -45
  472. package/node_modules/pi-lens/dist/clients/dispatch/utils/lsp-diagnostics.js +0 -35
  473. package/node_modules/pi-lens/dist/clients/disposition-logger.js +0 -32
  474. package/node_modules/pi-lens/dist/clients/disposition-publish.js +0 -124
  475. package/node_modules/pi-lens/dist/clients/durable-store.js +0 -97
  476. package/node_modules/pi-lens/dist/clients/effective-config.js +0 -415
  477. package/node_modules/pi-lens/dist/clients/env-utils.js +0 -83
  478. package/node_modules/pi-lens/dist/clients/error-class.js +0 -23
  479. package/node_modules/pi-lens/dist/clients/eval-timestamp.js +0 -17
  480. package/node_modules/pi-lens/dist/clients/event-loop-hold.js +0 -274
  481. package/node_modules/pi-lens/dist/clients/event-loop-monitor.js +0 -250
  482. package/node_modules/pi-lens/dist/clients/extension-log.js +0 -504
  483. package/node_modules/pi-lens/dist/clients/extension-mode.js +0 -73
  484. package/node_modules/pi-lens/dist/clients/feature-hints.js +0 -103
  485. package/node_modules/pi-lens/dist/clients/file-kinds.js +0 -412
  486. package/node_modules/pi-lens/dist/clients/file-role.js +0 -134
  487. package/node_modules/pi-lens/dist/clients/file-time.js +0 -160
  488. package/node_modules/pi-lens/dist/clients/file-utils.js +0 -1032
  489. package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +0 -494
  490. package/node_modules/pi-lens/dist/clients/finding-identity.js +0 -88
  491. package/node_modules/pi-lens/dist/clients/fix-worklog.js +0 -103
  492. package/node_modules/pi-lens/dist/clients/format-events-publish.js +0 -343
  493. package/node_modules/pi-lens/dist/clients/format-service.js +0 -222
  494. package/node_modules/pi-lens/dist/clients/formatters-lazy.js +0 -9
  495. package/node_modules/pi-lens/dist/clients/formatters.js +0 -2032
  496. package/node_modules/pi-lens/dist/clients/freshness-cadence.js +0 -17
  497. package/node_modules/pi-lens/dist/clients/freshness.js +0 -38
  498. package/node_modules/pi-lens/dist/clients/generated-artifacts.js +0 -394
  499. package/node_modules/pi-lens/dist/clients/generation-guard.js +0 -215
  500. package/node_modules/pi-lens/dist/clients/git-guard.js +0 -1136
  501. package/node_modules/pi-lens/dist/clients/git-tracked-ignore.js +0 -243
  502. package/node_modules/pi-lens/dist/clients/gitleaks-client.js +0 -509
  503. package/node_modules/pi-lens/dist/clients/go-client.js +0 -104
  504. package/node_modules/pi-lens/dist/clients/govulncheck-client.js +0 -605
  505. package/node_modules/pi-lens/dist/clients/gradle-ktfmt-style.js +0 -348
  506. package/node_modules/pi-lens/dist/clients/grammar-source.js +0 -465
  507. package/node_modules/pi-lens/dist/clients/gzip-stage-write.js +0 -135
  508. package/node_modules/pi-lens/dist/clients/hashline-anchor.js +0 -424
  509. package/node_modules/pi-lens/dist/clients/hook-budgets.js +0 -76
  510. package/node_modules/pi-lens/dist/clients/host-edit-normalize.js +0 -140
  511. package/node_modules/pi-lens/dist/clients/host-ports.js +0 -39
  512. package/node_modules/pi-lens/dist/clients/indent-retarget.js +0 -154
  513. package/node_modules/pi-lens/dist/clients/inline-blocker-dispositions.js +0 -186
  514. package/node_modules/pi-lens/dist/clients/install-diagnostics.js +0 -156
  515. package/node_modules/pi-lens/dist/clients/installer/index.js +0 -5416
  516. package/node_modules/pi-lens/dist/clients/installer/managed-tool-refresh-session.js +0 -58
  517. package/node_modules/pi-lens/dist/clients/installer/managed-tool-refresh.js +0 -783
  518. package/node_modules/pi-lens/dist/clients/instance-reaper-state.js +0 -7
  519. package/node_modules/pi-lens/dist/clients/instance-reaper.js +0 -1137
  520. package/node_modules/pi-lens/dist/clients/instance-registry-lock.js +0 -145
  521. package/node_modules/pi-lens/dist/clients/instance-registry.js +0 -773
  522. package/node_modules/pi-lens/dist/clients/jscpd-client.js +0 -378
  523. package/node_modules/pi-lens/dist/clients/json-cache-read.js +0 -65
  524. package/node_modules/pi-lens/dist/clients/knip-client.js +0 -788
  525. package/node_modules/pi-lens/dist/clients/language-policy.js +0 -252
  526. package/node_modules/pi-lens/dist/clients/language-profile.js +0 -361
  527. package/node_modules/pi-lens/dist/clients/language-registry.js +0 -603
  528. package/node_modules/pi-lens/dist/clients/latency-logger.js +0 -727
  529. package/node_modules/pi-lens/dist/clients/lazy-import.js +0 -21
  530. package/node_modules/pi-lens/dist/clients/ledger-bounds.js +0 -54
  531. package/node_modules/pi-lens/dist/clients/lens-config.js +0 -404
  532. package/node_modules/pi-lens/dist/clients/lens-engine.js +0 -358
  533. package/node_modules/pi-lens/dist/clients/lens-events.js +0 -125
  534. package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +0 -467
  535. package/node_modules/pi-lens/dist/clients/lens-map.js +0 -1156
  536. package/node_modules/pi-lens/dist/clients/live-bus-emitter.js +0 -74
  537. package/node_modules/pi-lens/dist/clients/log-cleanup.js +0 -222
  538. package/node_modules/pi-lens/dist/clients/lsp/aggregation.js +0 -178
  539. package/node_modules/pi-lens/dist/clients/lsp/cascade-tier.js +0 -421
  540. package/node_modules/pi-lens/dist/clients/lsp/client.js +0 -4593
  541. package/node_modules/pi-lens/dist/clients/lsp/config.js +0 -691
  542. package/node_modules/pi-lens/dist/clients/lsp/content-limits.js +0 -41
  543. package/node_modules/pi-lens/dist/clients/lsp/diagnostic-binding.js +0 -225
  544. package/node_modules/pi-lens/dist/clients/lsp/document-drift.js +0 -467
  545. package/node_modules/pi-lens/dist/clients/lsp/edits.js +0 -1219
  546. package/node_modules/pi-lens/dist/clients/lsp/index.js +0 -8305
  547. package/node_modules/pi-lens/dist/clients/lsp/inferred-project.js +0 -216
  548. package/node_modules/pi-lens/dist/clients/lsp/jvm-runtime.js +0 -298
  549. package/node_modules/pi-lens/dist/clients/lsp/language.js +0 -63
  550. package/node_modules/pi-lens/dist/clients/lsp/launch.js +0 -746
  551. package/node_modules/pi-lens/dist/clients/lsp/lombok.js +0 -158
  552. package/node_modules/pi-lens/dist/clients/lsp/path-utils.js +0 -5
  553. package/node_modules/pi-lens/dist/clients/lsp/pending-aux-coverage.js +0 -251
  554. package/node_modules/pi-lens/dist/clients/lsp/position-encoding.js +0 -61
  555. package/node_modules/pi-lens/dist/clients/lsp/ruby-drive-dirs.js +0 -83
  556. package/node_modules/pi-lens/dist/clients/lsp/server.js +0 -3290
  557. package/node_modules/pi-lens/dist/clients/lsp/session-roots.js +0 -192
  558. package/node_modules/pi-lens/dist/clients/lsp/spawn-history.js +0 -17
  559. package/node_modules/pi-lens/dist/clients/lsp/sync-kind.js +0 -56
  560. package/node_modules/pi-lens/dist/clients/lsp/tsserver-sync.js +0 -332
  561. package/node_modules/pi-lens/dist/clients/lsp/wait-policy/capability-snapshot.js +0 -1
  562. package/node_modules/pi-lens/dist/clients/lsp/wait-policy/classification.js +0 -85
  563. package/node_modules/pi-lens/dist/clients/lsp/wait-policy/index.js +0 -10
  564. package/node_modules/pi-lens/dist/clients/lsp/wait-policy/strategies.js +0 -392
  565. package/node_modules/pi-lens/dist/clients/lsp/watch-queue.js +0 -61
  566. package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-cache.js +0 -639
  567. package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-session.js +0 -30
  568. package/node_modules/pi-lens/dist/clients/lsp/workspace-sweep-hold.js +0 -184
  569. package/node_modules/pi-lens/dist/clients/lsp-budget.js +0 -186
  570. package/node_modules/pi-lens/dist/clients/lsp-document-symbols.js +0 -110
  571. package/node_modules/pi-lens/dist/clients/lsp-lazy.js +0 -9
  572. package/node_modules/pi-lens/dist/clients/lsp-mutation.js +0 -396
  573. package/node_modules/pi-lens/dist/clients/lsp-status.js +0 -59
  574. package/node_modules/pi-lens/dist/clients/map-with-concurrency.js +0 -40
  575. package/node_modules/pi-lens/dist/clients/mcp/analyze.js +0 -420
  576. package/node_modules/pi-lens/dist/clients/mcp/host-shim.js +0 -31
  577. package/node_modules/pi-lens/dist/clients/mcp/ipc.js +0 -523
  578. package/node_modules/pi-lens/dist/clients/mcp/review.js +0 -197
  579. package/node_modules/pi-lens/dist/clients/mcp/session.js +0 -412
  580. package/node_modules/pi-lens/dist/clients/memory-sampler.js +0 -208
  581. package/node_modules/pi-lens/dist/clients/message-end-attribution.js +0 -30
  582. package/node_modules/pi-lens/dist/clients/metrics-client.js +0 -107
  583. package/node_modules/pi-lens/dist/clients/metrics-history.js +0 -327
  584. package/node_modules/pi-lens/dist/clients/middle-man-analysis.js +0 -263
  585. package/node_modules/pi-lens/dist/clients/model-provider.js +0 -53
  586. package/node_modules/pi-lens/dist/clients/module-report-lsp.js +0 -189
  587. package/node_modules/pi-lens/dist/clients/module-report.js +0 -2150
  588. package/node_modules/pi-lens/dist/clients/mutating-tool.js +0 -651
  589. package/node_modules/pi-lens/dist/clients/mutation-attribution.js +0 -368
  590. package/node_modules/pi-lens/dist/clients/mutation-bridge.js +0 -240
  591. package/node_modules/pi-lens/dist/clients/ndjson-logger.js +0 -734
  592. package/node_modules/pi-lens/dist/clients/observed-mutation-sources.js +0 -101
  593. package/node_modules/pi-lens/dist/clients/observed-mutation.js +0 -1253
  594. package/node_modules/pi-lens/dist/clients/oldtext-autopatch.js +0 -128
  595. package/node_modules/pi-lens/dist/clients/opaque-mutation-scan.js +0 -496
  596. package/node_modules/pi-lens/dist/clients/opengrep-client.js +0 -333
  597. package/node_modules/pi-lens/dist/clients/opengrep-config.js +0 -76
  598. package/node_modules/pi-lens/dist/clients/package-manager.js +0 -607
  599. package/node_modules/pi-lens/dist/clients/package-root.js +0 -38
  600. package/node_modules/pi-lens/dist/clients/partial-edit-apply.js +0 -439
  601. package/node_modules/pi-lens/dist/clients/path-attribution-telemetry.js +0 -43
  602. package/node_modules/pi-lens/dist/clients/path-keyed-map.js +0 -108
  603. package/node_modules/pi-lens/dist/clients/path-utils.js +0 -1244
  604. package/node_modules/pi-lens/dist/clients/performance-report.js +0 -331
  605. package/node_modules/pi-lens/dist/clients/persist-debounce.js +0 -70
  606. package/node_modules/pi-lens/dist/clients/persistent-reverify.js +0 -271
  607. package/node_modules/pi-lens/dist/clients/php-cs-fixer-config.js +0 -119
  608. package/node_modules/pi-lens/dist/clients/pipeline.js +0 -1480
  609. package/node_modules/pi-lens/dist/clients/post-autofix-notice.js +0 -37
  610. package/node_modules/pi-lens/dist/clients/print-mode.js +0 -21
  611. package/node_modules/pi-lens/dist/clients/probe-home-state.js +0 -228
  612. package/node_modules/pi-lens/dist/clients/process-bridge.js +0 -66
  613. package/node_modules/pi-lens/dist/clients/process-singletons.js +0 -210
  614. package/node_modules/pi-lens/dist/clients/process-snapshot.js +0 -68
  615. package/node_modules/pi-lens/dist/clients/project-changes.js +0 -181
  616. package/node_modules/pi-lens/dist/clients/project-conventions.js +0 -171
  617. package/node_modules/pi-lens/dist/clients/project-diagnostics/cache.js +0 -137
  618. package/node_modules/pi-lens/dist/clients/project-diagnostics/extractors.js +0 -109
  619. package/node_modules/pi-lens/dist/clients/project-diagnostics/fresh-fetch.js +0 -668
  620. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js +0 -118
  621. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/dead-code.js +0 -47
  622. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/gitleaks.js +0 -40
  623. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/govulncheck.js +0 -34
  624. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/jscpd.js +0 -38
  625. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/knip.js +0 -47
  626. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/madge.js +0 -48
  627. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/opengrep.js +0 -40
  628. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +0 -127
  629. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/trivy.js +0 -81
  630. package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +0 -520
  631. package/node_modules/pi-lens/dist/clients/project-diagnostics/types.js +0 -1
  632. package/node_modules/pi-lens/dist/clients/project-lens-config.js +0 -807
  633. package/node_modules/pi-lens/dist/clients/project-report.js +0 -701
  634. package/node_modules/pi-lens/dist/clients/project-scale.js +0 -237
  635. package/node_modules/pi-lens/dist/clients/project-scan-policy.js +0 -11
  636. package/node_modules/pi-lens/dist/clients/project-snapshot-fingerprint.js +0 -48
  637. package/node_modules/pi-lens/dist/clients/project-snapshot-persist-worker.js +0 -20
  638. package/node_modules/pi-lens/dist/clients/project-snapshot.js +0 -1653
  639. package/node_modules/pi-lens/dist/clients/project-trust.js +0 -181
  640. package/node_modules/pi-lens/dist/clients/python-environment.js +0 -217
  641. package/node_modules/pi-lens/dist/clients/python-provenance.js +0 -639
  642. package/node_modules/pi-lens/dist/clients/quiet-window-config.js +0 -47
  643. package/node_modules/pi-lens/dist/clients/quiet-window.js +0 -236
  644. package/node_modules/pi-lens/dist/clients/read-bridge.js +0 -139
  645. package/node_modules/pi-lens/dist/clients/read-expansion.js +0 -266
  646. package/node_modules/pi-lens/dist/clients/read-guard-logger.js +0 -251
  647. package/node_modules/pi-lens/dist/clients/read-guard-tool-lines.js +0 -1306
  648. package/node_modules/pi-lens/dist/clients/read-guard.js +0 -1561
  649. package/node_modules/pi-lens/dist/clients/recent-touches.js +0 -240
  650. package/node_modules/pi-lens/dist/clients/redact/secrets.js +0 -449
  651. package/node_modules/pi-lens/dist/clients/resource-sampler.js +0 -628
  652. package/node_modules/pi-lens/dist/clients/reverse-deps.js +0 -270
  653. package/node_modules/pi-lens/dist/clients/review-graph/builder.js +0 -5126
  654. package/node_modules/pi-lens/dist/clients/review-graph/format.js +0 -33
  655. package/node_modules/pi-lens/dist/clients/review-graph/git-identity.js +0 -163
  656. package/node_modules/pi-lens/dist/clients/review-graph/import-resolvers.js +0 -481
  657. package/node_modules/pi-lens/dist/clients/review-graph/persist-worker.js +0 -10
  658. package/node_modules/pi-lens/dist/clients/review-graph/query.js +0 -244
  659. package/node_modules/pi-lens/dist/clients/review-graph/revision-drift.js +0 -21
  660. package/node_modules/pi-lens/dist/clients/review-graph/service.js +0 -96
  661. package/node_modules/pi-lens/dist/clients/review-graph/shared-extraction-ir.js +0 -82
  662. package/node_modules/pi-lens/dist/clients/review-graph/symbol-id.js +0 -103
  663. package/node_modules/pi-lens/dist/clients/review-graph/tsconfig-paths.js +0 -299
  664. package/node_modules/pi-lens/dist/clients/review-graph/types.js +0 -1
  665. package/node_modules/pi-lens/dist/clients/review-graph/workspace-modules.js +0 -449
  666. package/node_modules/pi-lens/dist/clients/review-graph-logger.js +0 -81
  667. package/node_modules/pi-lens/dist/clients/ruff-client.js +0 -179
  668. package/node_modules/pi-lens/dist/clients/rules-scanner.js +0 -131
  669. package/node_modules/pi-lens/dist/clients/run-duration.js +0 -55
  670. package/node_modules/pi-lens/dist/clients/runtime-agent-end.js +0 -746
  671. package/node_modules/pi-lens/dist/clients/runtime-config.js +0 -77
  672. package/node_modules/pi-lens/dist/clients/runtime-context.js +0 -211
  673. package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +0 -1324
  674. package/node_modules/pi-lens/dist/clients/runtime-session.js +0 -2485
  675. package/node_modules/pi-lens/dist/clients/runtime-tool-call.js +0 -1295
  676. package/node_modules/pi-lens/dist/clients/runtime-tool-result.js +0 -2049
  677. package/node_modules/pi-lens/dist/clients/runtime-turn.js +0 -3767
  678. package/node_modules/pi-lens/dist/clients/rust-client.js +0 -97
  679. package/node_modules/pi-lens/dist/clients/safe-spawn.js +0 -2357
  680. package/node_modules/pi-lens/dist/clients/sanitize.js +0 -286
  681. package/node_modules/pi-lens/dist/clients/scan-utils.js +0 -25
  682. package/node_modules/pi-lens/dist/clients/scratch-tree-policy.js +0 -165
  683. package/node_modules/pi-lens/dist/clients/search-read-registration.js +0 -94
  684. package/node_modules/pi-lens/dist/clients/secret-findings.js +0 -114
  685. package/node_modules/pi-lens/dist/clients/security-scan-client.js +0 -352
  686. package/node_modules/pi-lens/dist/clients/session-event-guard.js +0 -297
  687. package/node_modules/pi-lens/dist/clients/session-lifecycle.js +0 -484
  688. package/node_modules/pi-lens/dist/clients/session-start-observability.js +0 -94
  689. package/node_modules/pi-lens/dist/clients/session-state-store.js +0 -101
  690. package/node_modules/pi-lens/dist/clients/session-summary.js +0 -15
  691. package/node_modules/pi-lens/dist/clients/sessionstart-logger.js +0 -27
  692. package/node_modules/pi-lens/dist/clients/sg-runner.js +0 -876
  693. package/node_modules/pi-lens/dist/clients/sgconfig.js +0 -347
  694. package/node_modules/pi-lens/dist/clients/shared-checkout-guard.js +0 -338
  695. package/node_modules/pi-lens/dist/clients/single-flight.js +0 -158
  696. package/node_modules/pi-lens/dist/clients/situational-tool-telemetry.js +0 -108
  697. package/node_modules/pi-lens/dist/clients/skills-resolver.js +0 -141
  698. package/node_modules/pi-lens/dist/clients/slow-fs.js +0 -138
  699. package/node_modules/pi-lens/dist/clients/smells-rollup.js +0 -231
  700. package/node_modules/pi-lens/dist/clients/source-filter.js +0 -596
  701. package/node_modules/pi-lens/dist/clients/source-walker.js +0 -211
  702. package/node_modules/pi-lens/dist/clients/spawn-output-cap.js +0 -120
  703. package/node_modules/pi-lens/dist/clients/spawn-timeout-cooldown.js +0 -110
  704. package/node_modules/pi-lens/dist/clients/stale-marker.js +0 -17
  705. package/node_modules/pi-lens/dist/clients/startup-scan.js +0 -400
  706. package/node_modules/pi-lens/dist/clients/startup-timing.js +0 -130
  707. package/node_modules/pi-lens/dist/clients/string-utils.js +0 -33
  708. package/node_modules/pi-lens/dist/clients/subagent-mode.js +0 -111
  709. package/node_modules/pi-lens/dist/clients/symbol-containment.js +0 -24
  710. package/node_modules/pi-lens/dist/clients/symbol-types.js +0 -5
  711. package/node_modules/pi-lens/dist/clients/test-runner-client.js +0 -2507
  712. package/node_modules/pi-lens/dist/clients/test-runner-delivery.js +0 -287
  713. package/node_modules/pi-lens/dist/clients/todo-scanner.js +0 -229
  714. package/node_modules/pi-lens/dist/clients/tool-agreement.js +0 -423
  715. package/node_modules/pi-lens/dist/clients/tool-config.js +0 -249
  716. package/node_modules/pi-lens/dist/clients/tool-cwd.js +0 -270
  717. package/node_modules/pi-lens/dist/clients/tool-definition.js +0 -47
  718. package/node_modules/pi-lens/dist/clients/tool-event.js +0 -105
  719. package/node_modules/pi-lens/dist/clients/tool-policy.js +0 -2755
  720. package/node_modules/pi-lens/dist/clients/tool-probe.js +0 -53
  721. package/node_modules/pi-lens/dist/clients/tool-render.js +0 -156
  722. package/node_modules/pi-lens/dist/clients/tool-set-policy.js +0 -118
  723. package/node_modules/pi-lens/dist/clients/tree-sitter-cache.js +0 -364
  724. package/node_modules/pi-lens/dist/clients/tree-sitter-client.js +0 -4195
  725. package/node_modules/pi-lens/dist/clients/tree-sitter-logger.js +0 -100
  726. package/node_modules/pi-lens/dist/clients/tree-sitter-navigator.js +0 -269
  727. package/node_modules/pi-lens/dist/clients/tree-sitter-query-loader.js +0 -569
  728. package/node_modules/pi-lens/dist/clients/tree-sitter-shared.js +0 -158
  729. package/node_modules/pi-lens/dist/clients/tree-sitter-symbol-extractor.js +0 -1265
  730. package/node_modules/pi-lens/dist/clients/trivy-client.js +0 -467
  731. package/node_modules/pi-lens/dist/clients/tui-fit.js +0 -50
  732. package/node_modules/pi-lens/dist/clients/turn-context.js +0 -52
  733. package/node_modules/pi-lens/dist/clients/turn-end/lane.js +0 -51
  734. package/node_modules/pi-lens/dist/clients/turn-end/lanes/govulncheck.js +0 -112
  735. package/node_modules/pi-lens/dist/clients/turn-end/lanes/secrets.js +0 -204
  736. package/node_modules/pi-lens/dist/clients/turn-summary-render.js +0 -72
  737. package/node_modules/pi-lens/dist/clients/turn-summary.js +0 -132
  738. package/node_modules/pi-lens/dist/clients/typos-config.js +0 -29
  739. package/node_modules/pi-lens/dist/clients/user-notify.js +0 -51
  740. package/node_modules/pi-lens/dist/clients/vanished-instance-marker.js +0 -57
  741. package/node_modules/pi-lens/dist/clients/warm-attach.js +0 -305
  742. package/node_modules/pi-lens/dist/clients/widget-state.js +0 -1808
  743. package/node_modules/pi-lens/dist/clients/word-index-logger.js +0 -49
  744. package/node_modules/pi-lens/dist/clients/word-index-store.js +0 -459
  745. package/node_modules/pi-lens/dist/clients/word-index.js +0 -2080
  746. package/node_modules/pi-lens/dist/clients/workspace-topology.js +0 -443
  747. package/node_modules/pi-lens/dist/clients/write-ordering-guard.js +0 -65
  748. package/node_modules/pi-lens/dist/clients/zizmor-config.js +0 -340
  749. package/node_modules/pi-lens/dist/i18n.js +0 -69
  750. package/node_modules/pi-lens/dist/mcp/build-staleness.js +0 -124
  751. package/node_modules/pi-lens/dist/scripts/lib/process-scan.mjs +0 -583
  752. package/node_modules/pi-lens/dist/scripts/lib/skills-predicate.mjs +0 -129
  753. package/node_modules/pi-lens/dist/scripts/lib/web-tree-sitter-dir.mjs +0 -123
  754. package/node_modules/pi-lens/dist/tools/activate-tools.js +0 -87
  755. package/node_modules/pi-lens/dist/tools/ast-grep-outline.js +0 -137
  756. package/node_modules/pi-lens/dist/tools/ast-grep-replace.js +0 -244
  757. package/node_modules/pi-lens/dist/tools/ast-grep-search.js +0 -762
  758. package/node_modules/pi-lens/dist/tools/effective-config.js +0 -90
  759. package/node_modules/pi-lens/dist/tools/lens-diagnostic-mark.js +0 -375
  760. package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +0 -2571
  761. package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +0 -1745
  762. package/node_modules/pi-lens/dist/tools/lsp-navigation.js +0 -1367
  763. package/node_modules/pi-lens/dist/tools/lsp-structured-output.js +0 -294
  764. package/node_modules/pi-lens/dist/tools/module-report.js +0 -382
  765. package/node_modules/pi-lens/dist/tools/project-report.js +0 -86
  766. package/node_modules/pi-lens/dist/tools/render-compact.js +0 -374
  767. package/node_modules/pi-lens/dist/tools/scan-progress.js +0 -53
  768. package/node_modules/pi-lens/dist/tools/shared.js +0 -29
  769. package/node_modules/pi-lens/dist/tools/symbol-search.js +0 -155
@@ -1,1306 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import * as nodeFs from "node:fs";
3
- import { BoundedFifoMap } from "./bounded-cache.js";
4
- import { hostWouldApplyOldText, normalizeForGuardMatch, normalizeToLF, stripBom, } from "./host-edit-normalize.js";
5
- import { classifyMutatingTool } from "./mutating-tool.js";
6
- import { isExactAppliedRetry, } from "./partial-edit-apply.js";
7
- import { boundedEditIndexes, createReadGuardEditBatchSummary, logReadGuardEvent, } from "./read-guard-logger.js";
8
- // Track repeated oldtext_not_found failures per (filePath, preview) to escalate messages.
9
- export const MAX_FAILURE_TRACKER_SIZE = 200;
10
- const recentOldTextFailures = new BoundedFifoMap(MAX_FAILURE_TRACKER_SIZE);
11
- const REPEAT_FAILURE_TTL_MS = 300_000;
12
- function trackOldTextFailure(filePath, preview) {
13
- const key = `${filePath}::${preview}`;
14
- const now = Date.now();
15
- const prev = recentOldTextFailures.get(key);
16
- const count = prev && now - prev.lastTs < REPEAT_FAILURE_TTL_MS ? prev.count + 1 : 1;
17
- recentOldTextFailures.set(key, { count, lastTs: now });
18
- return count;
19
- }
20
- /** #2442 test-only: exercise the bounded failure tracker's capacity
21
- * eviction directly, without a full read-guard preflight call. */
22
- export function _trackOldTextFailureForTests(filePath, preview) {
23
- return trackOldTextFailure(filePath, preview);
24
- }
25
- /** #2442 test-only: was this (filePath, preview) pair's escalation count
26
- * reset by capacity eviction? (A fresh `_trackOldTextFailureForTests` call
27
- * answering 1 again, after previously answering >1, means yes — but this
28
- * reads the tracker's residency directly instead.) */
29
- export function _hasOldTextFailureForTests(filePath, preview) {
30
- return recentOldTextFailures.has(`${filePath}::${preview}`);
31
- }
32
- function findFirstLineOfOldText(content, oldText) {
33
- const firstLine = oldText.replace(/\r\n/g, "\n").split("\n")[0].trim();
34
- if (firstLine.length < 5)
35
- return undefined;
36
- const lines = content.split("\n");
37
- for (let i = 0; i < lines.length; i++) {
38
- if (lines[i].trim() === firstLine)
39
- return i + 1;
40
- }
41
- return undefined;
42
- }
43
- function tokenizeForSimilarity(text) {
44
- return text.toLowerCase().match(/[a-z0-9_]+/g) ?? [];
45
- }
46
- /** Jaccard similarity over identifier/number tokens (whitespace + punctuation insensitive). */
47
- function tokenSimilarity(a, b) {
48
- const ta = new Set(tokenizeForSimilarity(a));
49
- const tb = new Set(tokenizeForSimilarity(b));
50
- if (ta.size === 0 || tb.size === 0)
51
- return 0;
52
- let intersection = 0;
53
- for (const token of ta)
54
- if (tb.has(token))
55
- intersection += 1;
56
- return intersection / (ta.size + tb.size - intersection);
57
- }
58
- /**
59
- * "Did you mean?" recovery: when an oldText line can't be found, surface the
60
- * closest *current* file lines (by token similarity) so the model can rebuild
61
- * its edit from verbatim text in one turn instead of re-reading blind. Scans a
62
- * ±window around `nearLine` when known (the first-line locator), else the whole
63
- * file. Returns the top matches above `minScore`, with their real line numbers.
64
- *
65
- * Scores in normalized space but returns only `{ line, score }` — the caller
66
- * renders the text from a structurally-aligned RAW view so a suggestion can
67
- * never quote the normalized projection (#1050). NFKC folds CJK full-width
68
- * punctuation (`:`→`:`, `,`→`,`, `;`→`;`) and HOST_UNICODE_DASHES folds
69
- * `—`→`-`, so a suggestion rendered from normalized content told the agent to
70
- * copy bytes the file does not contain; the host's edit tool then fuzzy-matched
71
- * it and wrote the folded form onto the touched line. Normalization here is
72
- * comparison-only, exactly as everywhere else in this file.
73
- */
74
- function findSimilarLines(content, target, options = {}) {
75
- const { nearLine, window = 60, max = 3, minScore = 0.5 } = options;
76
- const needle = target.trim();
77
- if (needle.length < 4)
78
- return [];
79
- const lines = content.split("\n");
80
- const start = nearLine ? Math.max(0, nearLine - 1 - window) : 0;
81
- const end = nearLine
82
- ? Math.min(lines.length, nearLine - 1 + window)
83
- : lines.length;
84
- const scored = [];
85
- for (let i = start; i < end; i += 1) {
86
- const text = lines[i];
87
- if (text.trim() === "")
88
- continue;
89
- const score = tokenSimilarity(needle, text);
90
- if (score >= minScore)
91
- scored.push({ line: i + 1, score });
92
- }
93
- scored.sort((a, b) => b.score - a.score);
94
- return scored.slice(0, max);
95
- }
96
- /**
97
- * Render did-you-mean rows from the file's real characters rather than the
98
- * normalized match space the line numbers were scored in. Taking only
99
- * `{ line }` from the scan makes quoting normalized text structurally
100
- * impossible (#1050).
101
- *
102
- * `rawLineAligned` must be `normalizeToLF(stripBom(raw).text)`: the same
103
- * STRUCTURAL normalization `normalizeForGuardMatch` applies (so line indices
104
- * cross-index 1:1 even for lone-CR or BOM files) but none of its CHARACTER
105
- * folding, so full-width punctuation, smart quotes, and NBSP survive.
106
- */
107
- function formatSimilarLines(suggestions, rawLineAligned) {
108
- const rawLines = rawLineAligned.split("\n");
109
- const pad = (n) => String(n).padStart(4, " ");
110
- const rows = suggestions.map(({ line }) => ` ${pad(line)} │ ${(rawLines[line - 1] ?? "").trimEnd()}`);
111
- return `\n\nDid you mean one of these current lines?\n${rows.join("\n")}`;
112
- }
113
- export function countFileLines(filePath) {
114
- try {
115
- const content = nodeFs.readFileSync(filePath, "utf-8");
116
- if (content.length === 0)
117
- return 1;
118
- return content.split(/\r?\n/).length;
119
- }
120
- catch {
121
- return 1;
122
- }
123
- }
124
- // Match the host edit tool's fuzzy-match space (NFKC + smart quotes/dashes/
125
- // spaces + BOM + lone-CR), so the guard resolves oldText -> range exactly where
126
- // the host would apply it instead of false-blocking valid edits (#257).
127
- //
128
- // This is also where #505's "confusable-hyphen normalization" bundled item
129
- // lives: normalizeForGuardMatch folds HOST_UNICODE_DASHES (U+2010, U+2011,
130
- // U+2012, U+2013, U+2014, U+2015, U+2212 -> ASCII '-') before either side of
131
- // the comparison below, so it runs on the PRIMARY match here, before any of
132
- // the Tier A/B/C fallbacks in tryCorrectIndentationMismatchFromContent are
133
- // even reached. Comparison-only, same as every tier below it — the bytes
134
- // actually written on a successful edit are always the caller's original
135
- // oldText/newText (see resolveOldTextEdits / applyPartiallyApplicableEdits),
136
- // never this normalized form.
137
- function normalizeContent(text) {
138
- return normalizeForGuardMatch(text);
139
- }
140
- function lineNumberAt(content, index) {
141
- return content.substring(0, index).split("\n").length;
142
- }
143
- /**
144
- * Deduplicated overlapping pairs, in candidate order, for the overlap error
145
- * message. Each overlapping edit appears in exactly one pair where possible;
146
- * a chain (A-B-C all overlapping) reports A-B and A-C.
147
- */
148
- function overlapPairs(candidates) {
149
- const pairs = [];
150
- const reported = new Set();
151
- for (let i = 0; i < candidates.length; i += 1) {
152
- const a = candidates[i];
153
- if (reported.has(a))
154
- continue;
155
- for (let j = i + 1; j < candidates.length; j += 1) {
156
- const b = candidates[j];
157
- if (reported.has(b))
158
- continue;
159
- if (b.spanStart < a.spanEnd && a.spanStart < b.spanEnd) {
160
- pairs.push([a, b]);
161
- reported.add(a);
162
- reported.add(b);
163
- break;
164
- }
165
- }
166
- }
167
- return pairs;
168
- }
169
- /** ✅ note appended to preflight/composed messages for recognized retries. */
170
- export function formatAlreadyAppliedNotes(editIndexes) {
171
- if (!editIndexes || editIndexes.length === 0)
172
- return "";
173
- const list = boundedEditIndexes(editIndexes)
174
- .map((index) => `edits[${index}]`)
175
- .join(", ");
176
- const suffix = editIndexes.length === 1 ? "was" : "were";
177
- const pronoun = editIndexes.length === 1 ? "it" : "them";
178
- return `\n\n✅ ${list} ${suffix} already applied by an identical earlier edit — the file already contains the result. Do NOT resubmit ${pronoun}.`;
179
- }
180
- function findOccurrenceLines(content, needle) {
181
- const lines = [];
182
- let pos = 0;
183
- while (pos < content.length) {
184
- const idx = content.indexOf(needle, pos);
185
- if (idx === -1)
186
- break;
187
- lines.push(lineNumberAt(content, idx));
188
- pos = idx + needle.length;
189
- }
190
- return lines;
191
- }
192
- function formatOccurrenceContext(content, occurrenceLines, matchSpanLines, maxOccurrences = 5) {
193
- const fileLines = content.split("\n");
194
- const shown = occurrenceLines.slice(0, maxOccurrences);
195
- const extra = occurrenceLines.length - shown.length;
196
- const pad = (n) => String(n).padStart(4, " ");
197
- const blocks = shown.map((startLine) => {
198
- const endLine = startLine + matchSpanLines - 1;
199
- const before = startLine > 1 ? fileLines[startLine - 2] : undefined;
200
- const after = endLine < fileLines.length ? fileLines[endLine] : undefined;
201
- const lines = [` • Line ${startLine}:`];
202
- if (before !== undefined)
203
- lines.push(` ${pad(startLine - 1)} │ ${before}`);
204
- if (matchSpanLines === 1) {
205
- lines.push(` ${pad(startLine)} │ ${fileLines[startLine - 1] ?? ""} ← match`);
206
- }
207
- else {
208
- lines.push(` ${pad(startLine)} │ ${fileLines[startLine - 1] ?? ""} ← match start`);
209
- if (matchSpanLines > 2) {
210
- lines.push(` ${pad(0)} │ … (${matchSpanLines - 2} more line${matchSpanLines - 2 === 1 ? "" : "s"})`);
211
- }
212
- lines.push(` ${pad(endLine)} │ ${fileLines[endLine - 1] ?? ""} ← match end`);
213
- }
214
- if (after !== undefined)
215
- lines.push(` ${pad(endLine + 1)} │ ${after}`);
216
- return lines.join("\n");
217
- });
218
- const tail = extra > 0
219
- ? `\n • … and ${extra} more occurrence${extra === 1 ? "" : "s"}`
220
- : "";
221
- return blocks.join("\n") + tail;
222
- }
223
- function countRawOccurrences(content, needle) {
224
- if (!needle)
225
- return 0;
226
- let count = 0;
227
- let pos = 0;
228
- while (pos < content.length) {
229
- const idx = content.indexOf(needle, pos);
230
- if (idx === -1)
231
- break;
232
- count += 1;
233
- pos = idx + needle.length;
234
- }
235
- return count;
236
- }
237
- function exactOldTextForApply(rawContentLf, normalizedContent, oldText, candidate) {
238
- const oldTextLf = oldText.replace(/\r\n/g, "\n");
239
- if (countRawOccurrences(rawContentLf, oldTextLf) === 1) {
240
- const start = rawContentLf.indexOf(oldTextLf);
241
- return { text: oldTextLf, start, end: start + oldTextLf.length };
242
- }
243
- if (candidate !== oldTextLf &&
244
- countRawOccurrences(rawContentLf, candidate) === 1) {
245
- const start = rawContentLf.indexOf(candidate);
246
- return { text: candidate, start, end: start + candidate.length };
247
- }
248
- if (candidate !== oldTextLf)
249
- return undefined;
250
- const matchStart = normalizedContent.indexOf(candidate);
251
- if (matchStart < 0)
252
- return undefined;
253
- const rawLines = rawContentLf.split("\n");
254
- const normalizedLines = normalizedContent.split("\n");
255
- const rawLineStarts = [];
256
- let rawOffset = 0;
257
- for (const line of rawLines) {
258
- rawLineStarts.push(rawOffset);
259
- rawOffset += line.length + 1;
260
- }
261
- const normalizedLineStarts = [];
262
- let normalizedOffset = 0;
263
- for (const line of normalizedLines) {
264
- normalizedLineStarts.push(normalizedOffset);
265
- normalizedOffset += line.length + 1;
266
- }
267
- const mapOffset = (offset, preferEnd) => {
268
- const line = Math.min(normalizedLines.length - 1, normalizedContent.slice(0, offset).split("\n").length - 1);
269
- const rawLine = rawLines[line] ?? "";
270
- const bomOffset = line === 0 && rawLine.startsWith("\uFEFF") ? 1 : 0;
271
- const rawMatchLine = rawLine.slice(bomOffset);
272
- const target = offset - normalizedLineStarts[line];
273
- const normalizedLine = normalizedLines[line] ?? "";
274
- if (target >= normalizedLine.length) {
275
- if (preferEnd)
276
- return rawLineStarts[line] + rawLine.length;
277
- return rawLineStarts[line] + bomOffset + rawMatchLine.length;
278
- }
279
- let lower = 0;
280
- let upper = rawMatchLine.length;
281
- for (let boundary = 0; boundary <= rawMatchLine.length; boundary += 1) {
282
- const length = normalizeContent(rawMatchLine.slice(0, boundary)).length;
283
- if (length === target)
284
- return rawLineStarts[line] + bomOffset + boundary;
285
- if (length < target)
286
- lower = boundary;
287
- else if (upper === rawMatchLine.length)
288
- upper = boundary;
289
- }
290
- return rawLineStarts[line] + bomOffset + (preferEnd ? upper : lower);
291
- };
292
- const start = mapOffset(matchStart, false);
293
- const end = mapOffset(matchStart + candidate.length, true);
294
- const text = rawContentLf.slice(start, end);
295
- return normalizeContent(text) === candidate
296
- ? { text, start, end }
297
- : undefined;
298
- }
299
- function resolveOldTextEdits(edits, filePath, sessionId, correlationId, partialApplyRecords) {
300
- const startedAt = Date.now();
301
- const requestedIndexes = [];
302
- const logBatchEvent = (entry) => logReadGuardEvent({ ...entry, correlationId });
303
- let rawBytes;
304
- try {
305
- rawBytes = nodeFs.readFileSync(filePath);
306
- }
307
- catch {
308
- const editBatchSummary = createReadGuardEditBatchSummary({
309
- requestedIndexes: edits.map((edit, index) => edit.originalIndex ?? index),
310
- rejectedReasons: edits.map((edit, index) => ({
311
- index: edit.originalIndex ?? index,
312
- code: "preflight_blocked",
313
- })),
314
- });
315
- logBatchEvent({
316
- event: "touched_lines_missing",
317
- sessionId,
318
- filePath,
319
- metadata: {
320
- tool: "edit",
321
- source: "edits_without_ranges",
322
- editCount: edits.length,
323
- },
324
- });
325
- logBatchEvent({
326
- event: "edit_batch_summary",
327
- filePath,
328
- metadata: { tool: "edit", editBatchSummary },
329
- });
330
- return { touchedLines: undefined, editBatchSummary };
331
- }
332
- const rawContent = rawBytes.toString("utf8");
333
- const rawContentLf = normalizeToLF(rawContent);
334
- const content = normalizeContent(rawContent);
335
- // #1053: the identity the spans below are resolved against. The apply step
336
- // re-reads the file and rejects the whole batch when this no longer holds,
337
- // so spans are never re-interpreted against changed bytes. The hash covers
338
- // byte identity; spans carry their own bounds checks.
339
- const snapshot = {
340
- hash: createHash("sha256").update(rawBytes).digest("hex"),
341
- };
342
- const errors = [];
343
- const failureKinds = [];
344
- const failedEditIndexes = [];
345
- const failedOldTextPreviews = [];
346
- const rejectedReasons = [];
347
- const resolvedIndexes = [];
348
- const resolvedRanges = [];
349
- const candidateEdits = [];
350
- const passedEdits = [];
351
- let overlapRejectedCount = 0;
352
- const alreadyAppliedEdits = [];
353
- let maxFailCount = 0;
354
- for (let i = 0; i < edits.length; i++) {
355
- const oldText = edits[i].oldText;
356
- const editIndex = edits[i].originalIndex ?? i;
357
- if (requestedIndexes.length < 100)
358
- requestedIndexes.push(editIndex);
359
- if (!oldText)
360
- continue;
361
- // Exact-retry recognition (#2402): an identical (oldText, newText) pair
362
- // this session already applied is recognized from the applied record and
363
- // confirmed by content evidence — never resolved again, never re-applied,
364
- // never counted as a failure. This is deliberately NOT a global
365
- // newText-present heuristic: the record only exists for pairs this
366
- // process actually committed.
367
- if (partialApplyRecords) {
368
- const record = partialApplyRecords.find(filePath, oldText, edits[i].newText);
369
- if (record &&
370
- isExactAppliedRetry({
371
- contentLf: rawContentLf,
372
- oldKey: normalizeContent(oldText),
373
- newKey: normalizeContent(edits[i].newText ?? ""),
374
- contentHash: snapshot.hash,
375
- expectedContentHash: record.contentHash,
376
- expectedAfterWriteHash: record.afterWriteContentHash,
377
- })) {
378
- if (alreadyAppliedEdits.length < 100)
379
- alreadyAppliedEdits.push(editIndex);
380
- logBatchEvent({
381
- event: "edit_already_applied_retry",
382
- sessionId,
383
- filePath,
384
- metadata: {
385
- tool: "edit",
386
- source: "edits_without_ranges",
387
- editIndex,
388
- },
389
- });
390
- continue;
391
- }
392
- }
393
- let needle = normalizeContent(oldText);
394
- let occurrenceLines = findOccurrenceLines(content, needle);
395
- if (occurrenceLines.length === 0) {
396
- const corrected = tryCorrectIndentationMismatchFromContent(oldText, rawContentLf);
397
- if (corrected !== undefined) {
398
- needle = normalizeContent(corrected);
399
- occurrenceLines = findOccurrenceLines(content, needle);
400
- if (occurrenceLines.length > 0) {
401
- logBatchEvent({
402
- event: "oldtext_indent_corrected",
403
- sessionId,
404
- filePath,
405
- metadata: {
406
- tool: "edit",
407
- source: "edits_without_ranges",
408
- editIndex,
409
- },
410
- });
411
- }
412
- }
413
- }
414
- if (occurrenceLines.length === 0) {
415
- const preview = oldText.trimStart().substring(0, 60).replace(/\n/g, "↵");
416
- failureKinds.push("oldtext_not_found");
417
- if (failedEditIndexes.length < 100) {
418
- failedEditIndexes.push(editIndex);
419
- failedOldTextPreviews.push(preview);
420
- }
421
- if (rejectedReasons.length < 100) {
422
- rejectedReasons.push({ index: editIndex, code: "oldtext_not_found" });
423
- }
424
- const failCount = trackOldTextFailure(filePath, preview);
425
- if (failCount > maxFailCount)
426
- maxFailCount = failCount;
427
- let errorMsg = `edits[${editIndex}].oldText ("${preview}") was not found in the current file content.`;
428
- // Quote-style hint: if swapping " ↔ ' gives exactly one match, tell the agent why it failed.
429
- const quoteSwapCandidates = [];
430
- if (needle.includes('"'))
431
- quoteSwapCandidates.push(needle.replace(/"/g, "'"));
432
- if (needle.includes("'"))
433
- quoteSwapCandidates.push(needle.replace(/'/g, '"'));
434
- const quoteHit = quoteSwapCandidates.find((s) => s !== needle && findOccurrenceLines(content, s).length === 1);
435
- if (quoteHit !== undefined) {
436
- errorMsg += ` The file uses a different quote style — your oldText has ${needle.includes('"') ? "double" : "single"} quotes but the file has ${needle.includes('"') ? "single" : "double"} quotes. Fix the quote style in both oldText and newText before retrying.`;
437
- }
438
- else {
439
- const lineHint = findFirstLineOfOldText(content, oldText);
440
- const offsetHint = lineHint !== undefined
441
- ? `\`offset=${Math.max(1, lineHint - 2)} limit=20\``
442
- : undefined;
443
- if (lineHint !== undefined) {
444
- // First line content exists in the file — the surrounding block has drifted.
445
- // Indentation autopatch already ran before this point and did not fix it,
446
- // so this is a content-drift failure, not a whitespace issue.
447
- if (failCount >= 2) {
448
- errorMsg +=
449
- ` This is attempt #${failCount} — the first line of your oldText appears near line ${lineHint}` +
450
- ` but the surrounding content no longer matches. This is a content-drift failure,` +
451
- ` not an indentation issue (indentation autopatch already ran and did not fix it).` +
452
- ` Re-read ${offsetHint} and rebuild oldText verbatim from the current file.`;
453
- }
454
- else {
455
- errorMsg +=
456
- ` The first line of your oldText appears near line ${lineHint} but the rest doesn't match.` +
457
- ` The file has likely changed since your last read — this is a content-drift issue, not indentation.` +
458
- ` Re-read ${offsetHint} and rebuild oldText from the verbatim file content.`;
459
- }
460
- }
461
- else {
462
- // First line not found anywhere in the file, even ignoring whitespace.
463
- if (failCount >= 2) {
464
- errorMsg +=
465
- ` This is attempt #${failCount} — this text does not appear anywhere in the file,` +
466
- ` even ignoring whitespace differences. Do NOT retry from memory.` +
467
- ` Re-read the relevant section before rebuilding your edit.`;
468
- }
469
- else {
470
- errorMsg +=
471
- ` This text does not appear anywhere in the file, even ignoring indentation differences —` +
472
- ` the file has likely changed significantly. Re-read the relevant section before retrying.`;
473
- }
474
- }
475
- }
476
- // "Did you mean?" — surface the closest current lines (token
477
- // similarity) so the model can rebuild oldText verbatim in one turn
478
- // instead of re-reading blind. Skipped on the quote-style path, which
479
- // already names the precise fix. Anchored near the first-line locator
480
- // when known, else scans the whole file. Scored against `content`
481
- // (normalized) but RENDERED from a structurally-aligned raw view —
482
- // quoting the normalized projection told the agent to copy bytes the
483
- // file does not contain (#1050).
484
- if (!errorMsg.includes("quote style")) {
485
- const similarLines = findSimilarLines(content, oldText.replace(/\r\n/g, "\n").split("\n")[0], { nearLine: findFirstLineOfOldText(content, oldText) });
486
- if (similarLines.length > 0) {
487
- errorMsg += formatSimilarLines(similarLines, normalizeToLF(stripBom(rawContent).text));
488
- }
489
- }
490
- errors.push(errorMsg);
491
- // Counterfactual: would the host's edit tool have applied this oldText
492
- // anyway? hostWouldApply=true => this block is a false-block (pi-lens
493
- // friction the host wouldn't have); false => a genuine miss. This is the
494
- // measurement that tells us whether the guard earns its keep (#257).
495
- const hostMatch = hostWouldApplyOldText(rawContent, oldText);
496
- logBatchEvent({
497
- event: "oldtext_not_found",
498
- sessionId,
499
- filePath,
500
- metadata: {
501
- tool: "edit",
502
- source: "edits_without_ranges",
503
- editIndex,
504
- oldTextPreview: preview,
505
- repeatFailureCount: failCount,
506
- hostWouldApply: hostMatch.wouldApply,
507
- hostOccurrences: hostMatch.occurrences,
508
- hostUsedFuzzyMatch: hostMatch.usedFuzzyMatch,
509
- },
510
- });
511
- }
512
- else if (occurrenceLines.length === 1) {
513
- const startLine = occurrenceLines[0];
514
- const endLine = startLine + needle.split("\n").length - 1;
515
- const applySpan = exactOldTextForApply(rawContentLf, content, oldText, needle);
516
- if (applySpan !== undefined) {
517
- // #1053: carry the exact span the preflight approved, plus the
518
- // snapshot identity it was resolved against. The apply step
519
- // consumes these instead of re-searching oldText.
520
- candidateEdits.push({
521
- oldText,
522
- appliedSpanText: applySpan.text,
523
- newText: edits[i].newText,
524
- originalIndex: editIndex,
525
- snapshot,
526
- spanStart: applySpan.start,
527
- spanEnd: applySpan.end,
528
- });
529
- resolvedRanges.push([startLine, endLine]);
530
- if (resolvedIndexes.length < 100)
531
- resolvedIndexes.push(editIndex);
532
- }
533
- else {
534
- failureKinds.push("oldtext_unrepresentable");
535
- if (failedEditIndexes.length < 100)
536
- failedEditIndexes.push(editIndex);
537
- if (rejectedReasons.length < 100) {
538
- rejectedReasons.push({
539
- index: editIndex,
540
- code: "oldtext_unrepresentable",
541
- });
542
- }
543
- errors.push(`edits[${editIndex}].oldText matched normalized content but could not be mapped to one raw file span; the whole batch must be rebuilt from the current file content.`);
544
- logBatchEvent({
545
- event: "edit_preflight_blocked",
546
- sessionId,
547
- filePath,
548
- metadata: {
549
- tool: "edit",
550
- source: "edits_without_ranges",
551
- reasonKind: "oldtext_unrepresentable",
552
- editIndex,
553
- },
554
- });
555
- }
556
- if (applySpan !== undefined) {
557
- logBatchEvent({
558
- event: "oldtext_resolved",
559
- sessionId,
560
- filePath,
561
- metadata: {
562
- tool: "edit",
563
- source: "edits_without_ranges",
564
- editIndex,
565
- touchedLines: [startLine, endLine],
566
- },
567
- });
568
- }
569
- }
570
- else {
571
- const preview = oldText.trimStart().substring(0, 60).replace(/\n/g, "↵");
572
- failureKinds.push("oldtext_duplicate");
573
- if (failedEditIndexes.length < 100) {
574
- failedEditIndexes.push(editIndex);
575
- failedOldTextPreviews.push(preview);
576
- }
577
- if (rejectedReasons.length < 100) {
578
- rejectedReasons.push({ index: editIndex, code: "oldtext_duplicate" });
579
- }
580
- const matchSpanLines = needle.split("\n").length;
581
- const contextBlock = formatOccurrenceContext(content, occurrenceLines, matchSpanLines);
582
- errors.push(`edits[${editIndex}].oldText ("${preview}") appears ${occurrenceLines.length} times:\n${contextBlock}\nPick the location you want and extend your oldText with the unique line above or below it (shown as context).`);
583
- logBatchEvent({
584
- event: "oldtext_duplicate",
585
- sessionId,
586
- filePath,
587
- metadata: {
588
- tool: "edit",
589
- source: "edits_without_ranges",
590
- editIndex,
591
- occurrenceLines: occurrenceLines.slice(0, 100),
592
- occurrenceCount: occurrenceLines.length,
593
- oldTextPreview: preview,
594
- },
595
- });
596
- }
597
- }
598
- // Overlap guard (#1053): individually-unique matches can still overlap
599
- // (e.g. "abc" and "bcd" both matching inside "xabcy"). Applying both would
600
- // splice corrupt content, so overlapping candidates are rejected together
601
- // with one explicit message instead of being silently skipped.
602
- const sortedCandidates = [...candidateEdits].sort((a, b) => a.spanStart - b.spanStart);
603
- const overlaps = overlapPairs(sortedCandidates);
604
- for (let i = 0; i < sortedCandidates.length; i += 1) {
605
- const candidate = sortedCandidates[i];
606
- const overlapping = sortedCandidates.find((other) => other !== candidate &&
607
- other.spanStart < candidate.spanEnd &&
608
- candidate.spanStart < other.spanEnd);
609
- if (overlapping) {
610
- overlapRejectedCount += 1;
611
- if (rejectedReasons.length < 100) {
612
- rejectedReasons.push({
613
- index: candidate.originalIndex,
614
- code: "span_overlap",
615
- });
616
- }
617
- continue;
618
- }
619
- passedEdits.push(candidate);
620
- }
621
- for (const [a, b] of overlaps) {
622
- errors.push(`edits[${a.originalIndex}] and edits[${b.originalIndex}] resolved to overlapping spans of the file — their oldTexts match regions that share bytes. Extend one oldText with a unique neighboring line so each edit targets one unambiguous span, or apply them in separate calls.`);
623
- }
624
- // Overlap is a batch-level safety failure. Do not partially commit an
625
- // unrelated candidate from the same request while another pair is
626
- // ambiguous; the apply seam promises all-or-nothing preflight rejection.
627
- if (overlaps.length > 0)
628
- passedEdits.length = 0;
629
- const oldTextEditCount = edits.filter((edit) => !!edit.oldText).length;
630
- // Pure already-applied batch (#2402): every oldText edit is a recognized
631
- // exact retry, nothing failed, nothing remains to apply. The verdict is the
632
- // idempotent "already applied" note, never an escalating error.
633
- if (errors.length === 0 &&
634
- passedEdits.length === 0 &&
635
- alreadyAppliedEdits.length > 0 &&
636
- alreadyAppliedEdits.length === oldTextEditCount) {
637
- const header = `✅ ALREADY APPLIED — every edit in this call was already applied by an identical earlier submission. Do NOT retry this payload; re-read the file if you need to build a new edit.`;
638
- const details = alreadyAppliedEdits.map((editIndex) => `edits[${editIndex}]: already applied — do not resubmit.`);
639
- const editBatchSummary = createReadGuardEditBatchSummary({
640
- requestedIndexes,
641
- requestedTotal: edits.length,
642
- alreadyAppliedIndexes: boundedEditIndexes(alreadyAppliedEdits),
643
- alreadyAppliedTotal: alreadyAppliedEdits.length,
644
- durationMs: Date.now() - startedAt,
645
- terminalStatus: "skipped",
646
- });
647
- logBatchEvent({
648
- event: "edit_batch_summary",
649
- correlationId,
650
- filePath,
651
- metadata: { tool: "edit", editBatchSummary },
652
- });
653
- return {
654
- touchedLines: undefined,
655
- preflightError: `${header}\n\n${details.join("\n")}`,
656
- preflightHeader: header,
657
- preflightDetails: details,
658
- alreadyAppliedEdits,
659
- editBatchSummary,
660
- };
661
- }
662
- if (errors.length > 0 ||
663
- alreadyAppliedEdits.length > 0 ||
664
- resolvedRanges.length !== oldTextEditCount) {
665
- const failureDetails = errors.length > 0
666
- ? errors
667
- : alreadyAppliedEdits.map((editIndex) => `edits[${editIndex}]: already applied — do not resubmit.`);
668
- const uniqueFailureKinds = [...new Set(failureKinds)];
669
- const editBatchSummary = createReadGuardEditBatchSummary({
670
- requestedIndexes,
671
- requestedTotal: edits.length,
672
- resolvedIndexes,
673
- resolvedTotal: resolvedRanges.length,
674
- rejectedReasons,
675
- rejectedTotal: Math.max(0, oldTextEditCount -
676
- resolvedRanges.length -
677
- alreadyAppliedEdits.length +
678
- overlapRejectedCount),
679
- alreadyAppliedIndexes: boundedEditIndexes(alreadyAppliedEdits),
680
- alreadyAppliedTotal: alreadyAppliedEdits.length,
681
- durationMs: Date.now() - startedAt,
682
- terminalStatus: "blocked",
683
- });
684
- logBatchEvent({
685
- event: "edit_preflight_blocked",
686
- correlationId,
687
- sessionId,
688
- filePath,
689
- metadata: {
690
- tool: "edit",
691
- source: "edits_without_ranges",
692
- reasonKind: uniqueFailureKinds.length === 1
693
- ? uniqueFailureKinds[0]
694
- : "oldtext_resolution_failed",
695
- failureKinds: uniqueFailureKinds,
696
- editCount: edits.length,
697
- oldTextEditCount,
698
- resolvedOldTextEditCount: resolvedRanges.length,
699
- unresolvedOldTextEditCount: oldTextEditCount - resolvedRanges.length,
700
- alreadyAppliedCount: alreadyAppliedEdits.length,
701
- overlapRejectedCount,
702
- failedEditIndexes,
703
- oldTextPreviews: failedOldTextPreviews.slice(0, 5),
704
- errorCount: errors.length,
705
- },
706
- });
707
- const header = errors.length === 0
708
- ? `✅ ALREADY APPLIED — some edits in this call were already applied by an identical earlier submission. Do NOT resubmit them.`
709
- : maxFailCount >= 2
710
- ? `🛑 RE-READ REQUIRED — You have submitted this oldText before and it still does not match.\n\nDo NOT retry from memory. Re-read \`${filePath}\` to get the current content, then rebuild your edit from the verbatim file text.`
711
- : uniqueFailureKinds.length === 1 &&
712
- uniqueFailureKinds[0] === "span_overlap"
713
- ? `🔄 RETRYABLE — Overlapping edit spans`
714
- : `🔄 RETRYABLE — Edit target not found`;
715
- logBatchEvent({
716
- event: "edit_batch_summary",
717
- correlationId,
718
- filePath,
719
- metadata: { tool: "edit", editBatchSummary },
720
- });
721
- return {
722
- touchedLines: undefined,
723
- preflightError: `${header}\n\n${failureDetails.join("\n\n")}${formatAlreadyAppliedNotes(alreadyAppliedEdits)}`,
724
- preflightHeader: header,
725
- preflightDetails: failureDetails,
726
- partiallyApplicable: passedEdits.length > 0 &&
727
- !failureKinds.includes("oldtext_unrepresentable")
728
- ? passedEdits
729
- : undefined,
730
- alreadyAppliedEdits: alreadyAppliedEdits.length > 0 ? alreadyAppliedEdits : undefined,
731
- editBatchSummary,
732
- };
733
- }
734
- if (resolvedRanges.length === 0) {
735
- const editBatchSummary = createReadGuardEditBatchSummary({
736
- requestedIndexes,
737
- requestedTotal: edits.length,
738
- rejectedTotal: oldTextEditCount,
739
- terminalStatus: "blocked",
740
- });
741
- logBatchEvent({
742
- event: "touched_lines_missing",
743
- sessionId,
744
- filePath,
745
- metadata: {
746
- tool: "edit",
747
- source: "edits_without_ranges",
748
- editCount: edits.length,
749
- },
750
- });
751
- logBatchEvent({
752
- event: "edit_batch_summary",
753
- filePath,
754
- metadata: { tool: "edit", editBatchSummary },
755
- });
756
- return { touchedLines: undefined, editBatchSummary };
757
- }
758
- const starts = resolvedRanges.map(([s]) => s);
759
- const ends = resolvedRanges.map(([, e]) => e);
760
- const touchedLines = [
761
- Math.min(...starts),
762
- Math.max(...ends),
763
- ];
764
- const editRanges = resolvedRanges.length > 1 ? resolvedRanges : undefined;
765
- logBatchEvent({
766
- event: "touched_lines_detected",
767
- sessionId,
768
- filePath,
769
- metadata: {
770
- tool: "edit",
771
- source: "oldtext_resolved",
772
- touchedLines,
773
- resolvedEditCount: resolvedRanges.length,
774
- totalEditCount: edits.length,
775
- },
776
- });
777
- const editBatchSummary = createReadGuardEditBatchSummary({
778
- requestedIndexes,
779
- requestedTotal: edits.length,
780
- resolvedIndexes,
781
- resolvedTotal: resolvedRanges.length,
782
- durationMs: Date.now() - startedAt,
783
- terminalStatus: "success",
784
- });
785
- return {
786
- touchedLines,
787
- editRanges,
788
- contentMatchValidated: true,
789
- editBatchSummary,
790
- };
791
- }
792
- // Canonical applied-edit keying lives beside the partial-apply seam that both
793
- // writes and consumes it (partial-edit-apply.ts, #1053/#2402).
794
- export { stripOldTextTrailingWhitespace } from "./partial-edit-apply.js";
795
- /**
796
- * Normalises an oldText string for whitespace-only differences that editors routinely
797
- * introduce: trailing spaces/tabs on each line are stripped, and any trailing blank
798
- * lines (lines that are empty after trimming) are removed from the end. CRLF is
799
- * normalised to LF. Returns the same string if no change was needed.
800
- */
801
- /**
802
- * Tries to fix a tab/space indentation mismatch between the model's oldText and the
803
- * actual file. Returns the corrected oldText if a matching variant is found, or
804
- * undefined if the text already matches or no indentation conversion fixes it.
805
- */
806
- export function tryCorrectIndentationMismatchFromContent(oldText, content) {
807
- const normalized = oldText.replace(/\r\n/g, "\n");
808
- if (content.includes(normalized))
809
- return undefined;
810
- const conversions = [
811
- // tabs → 2 spaces
812
- (s) => s
813
- .split("\n")
814
- .map((l) => l.replace(/^\t+/, (m) => " ".repeat(m.length)))
815
- .join("\n"),
816
- // tabs → 4 spaces
817
- (s) => s
818
- .split("\n")
819
- .map((l) => l.replace(/^\t+/, (m) => " ".repeat(m.length)))
820
- .join("\n"),
821
- // 2 spaces → tabs
822
- (s) => s
823
- .split("\n")
824
- .map((l) => l.replace(/^( {2})+/, (m) => "\t".repeat(m.length / 2)))
825
- .join("\n"),
826
- // 4 spaces → tabs
827
- (s) => s
828
- .split("\n")
829
- .map((l) => l.replace(/^( {4})+/, (m) => "\t".repeat(m.length / 4)))
830
- .join("\n"),
831
- ];
832
- for (const convert of conversions) {
833
- const candidate = convert(normalized);
834
- if (candidate !== normalized && content.includes(candidate))
835
- return candidate;
836
- }
837
- const indentationInsensitiveCandidate = findIndentationInsensitiveCandidate(content, normalized);
838
- if (indentationInsensitiveCandidate !== undefined) {
839
- return indentationInsensitiveCandidate;
840
- }
841
- // Tier A (#200): the fixed-length matchers above can't bridge a mid-block
842
- // blank-line difference; fall back to a blank-line-insensitive match that
843
- // recovers the real file span (unique-match guarded).
844
- const blankLineCandidate = findBlankLineInsensitiveCandidate(content, normalized);
845
- if (blankLineCandidate !== undefined) {
846
- return blankLineCandidate;
847
- }
848
- // Tier B: interior-whitespace drift the earlier tiers can't bridge — the
849
- // indentation- and blank-line-insensitive tiers both still require each
850
- // non-blank line to match character-for-character after trimming only the
851
- // OUTER edges. When whitespace drifts INSIDE a line (a formatter collapsed
852
- // `a + b` → `a + b`, re-spaced operators/args, etc.) those tiers miss.
853
- // Matching on a fully-whitespace-collapsed signature catches it. Same
854
- // safety contract as Tier A: unique-match guarded, ≥2 anchors, recovers the
855
- // verbatim file span.
856
- const whitespaceCandidate = findWhitespaceInsensitiveCandidate(content, normalized);
857
- if (whitespaceCandidate !== undefined) {
858
- return whitespaceCandidate;
859
- }
860
- // Tier C: Unicode-punctuation drift the whitespace tiers can't bridge — the
861
- // model emitted smart quotes / em-dashes / NBSP where the file has straight
862
- // quotes / hyphens / regular spaces (or vice versa), common when text is
863
- // pasted from rendered Markdown or the model "tidies" punctuation. Folding
864
- // those to their ASCII equivalents (on top of whitespace collapse) catches it.
865
- // Same safety contract as Tier B: signature-matched, unique-match guarded, ≥2
866
- // anchors, recovers the verbatim file span (the file's real characters).
867
- const unicodeCandidate = findUnicodePunctuationInsensitiveCandidate(content, normalized);
868
- if (unicodeCandidate !== undefined) {
869
- return unicodeCandidate;
870
- }
871
- return undefined;
872
- }
873
- export function tryCorrectIndentationMismatch(oldText, filePath) {
874
- try {
875
- return tryCorrectIndentationMismatchFromContent(oldText, nodeFs.readFileSync(filePath, "utf-8").replace(/\r\n/g, "\n"));
876
- }
877
- catch {
878
- return undefined;
879
- }
880
- }
881
- function findIndentationInsensitiveCandidate(content, oldText) {
882
- const contentLines = content.split("\n");
883
- const oldLines = oldText.split("\n");
884
- const stripIndent = (line) => line.replace(/^[\t ]+/, "").trimEnd();
885
- const expected = oldLines.map(stripIndent);
886
- for (let start = 0; start <= contentLines.length - oldLines.length; start += 1) {
887
- let matches = true;
888
- for (let offset = 0; offset < oldLines.length; offset += 1) {
889
- if (stripIndent(contentLines[start + offset] ?? "") !== expected[offset]) {
890
- matches = false;
891
- break;
892
- }
893
- }
894
- if (matches) {
895
- const candidate = contentLines
896
- .slice(start, start + oldLines.length)
897
- .join("\n");
898
- if (candidate !== oldText)
899
- return candidate;
900
- }
901
- }
902
- return undefined;
903
- }
904
- /**
905
- * Tier A of the blank-line autopatch (#200): tolerate mid-block blank-line
906
- * divergence — a blank line added or removed *inside* the block — which the
907
- * fixed-length window in {@link findIndentationInsensitiveCandidate} can't (any
908
- * interior blank-line delta breaks its 1:1 alignment). Blank lines are
909
- * semantically insignificant in every supported language, so matching the
910
- * oldText's non-blank lines (indentation-insensitive) against consecutive
911
- * content while skipping interior blanks on the content side is safe.
912
- *
913
- * Safety: matches by the non-blank "signature" but **recovers and returns the
914
- * real file span** (first→last matched non-blank line, real interior blanks
915
- * included) so the applied oldText is verbatim file bytes; requires the
916
- * signature to match **exactly once** (returns undefined on 0 or ≥2). Anchored
917
- * on ≥2 non-blank lines to avoid trivial single-line collisions.
918
- */
919
- function findBlankLineInsensitiveCandidate(content, oldText) {
920
- const stripIndent = (line) => line.replace(/^[\t ]+/, "").trimEnd();
921
- const isBlank = (line) => stripIndent(line) === "";
922
- const contentLines = content.split("\n");
923
- const oldNonBlank = oldText
924
- .split("\n")
925
- .map(stripIndent)
926
- .filter((line) => line !== "");
927
- // Need ≥2 anchors to be meaningful and collision-resistant; single-line
928
- // drift has no interior to differ and is handled by other tiers.
929
- if (oldNonBlank.length < 2)
930
- return undefined;
931
- const spans = [];
932
- for (let start = 0; start < contentLines.length; start += 1) {
933
- if (stripIndent(contentLines[start]) !== oldNonBlank[0])
934
- continue;
935
- let contentIdx = start + 1;
936
- let oldIdx = 1;
937
- let end = start;
938
- let ok = true;
939
- while (oldIdx < oldNonBlank.length) {
940
- while (contentIdx < contentLines.length &&
941
- isBlank(contentLines[contentIdx]))
942
- contentIdx += 1;
943
- if (contentIdx >= contentLines.length ||
944
- stripIndent(contentLines[contentIdx]) !== oldNonBlank[oldIdx]) {
945
- ok = false;
946
- break;
947
- }
948
- end = contentIdx;
949
- oldIdx += 1;
950
- contentIdx += 1;
951
- }
952
- if (ok)
953
- spans.push([start, end]);
954
- }
955
- if (spans.length !== 1)
956
- return undefined;
957
- const [start, end] = spans[0];
958
- const candidate = contentLines.slice(start, end + 1).join("\n");
959
- return candidate === oldText ? undefined : candidate;
960
- }
961
- /**
962
- * Tier B of the whitespace autopatch: tolerate INTERIOR whitespace divergence
963
- * that {@link findBlankLineInsensitiveCandidate} (outer-trim only) and the
964
- * fixed-width converters can't bridge. The signature is each non-blank line
965
- * with **all** whitespace removed (`/\s+/g` → ""), so re-spacing inside a line
966
- * — `a + b` ↔ `a + b`, `foo( x )` ↔ `foo(x)`, tab/space mixes mid-line — no
967
- * longer breaks the match. This mirrors the content-hash normalization the
968
- * read-guard already uses for staleness (`lineContentHash`), so a span that
969
- * passes here is a span the guard considers semantically identical.
970
- *
971
- * Safety mirrors Tier A exactly: matches by the collapsed signature but
972
- * **recovers and returns the real file span** (verbatim bytes, interior blanks
973
- * included) so the applied oldText is exact; requires the signature to match
974
- * **exactly once** (0 or ≥2 → undefined); anchored on ≥2 non-blank lines to
975
- * resist single-line collisions (collapsing whitespace makes single-line
976
- * collisions more likely, so the ≥2 floor matters more here than in Tier A).
977
- */
978
- function findWhitespaceInsensitiveCandidate(content, oldText) {
979
- const collapse = (line) => line.replace(/\s+/g, "");
980
- const isBlank = (line) => collapse(line) === "";
981
- const contentLines = content.split("\n");
982
- const oldSignature = oldText
983
- .split("\n")
984
- .map(collapse)
985
- .filter((line) => line !== "");
986
- if (oldSignature.length < 2)
987
- return undefined;
988
- const spans = [];
989
- for (let start = 0; start < contentLines.length; start += 1) {
990
- if (collapse(contentLines[start]) !== oldSignature[0])
991
- continue;
992
- let contentIdx = start + 1;
993
- let sigIdx = 1;
994
- let end = start;
995
- let ok = true;
996
- while (sigIdx < oldSignature.length) {
997
- while (contentIdx < contentLines.length &&
998
- isBlank(contentLines[contentIdx]))
999
- contentIdx += 1;
1000
- if (contentIdx >= contentLines.length ||
1001
- collapse(contentLines[contentIdx]) !== oldSignature[sigIdx]) {
1002
- ok = false;
1003
- break;
1004
- }
1005
- end = contentIdx;
1006
- sigIdx += 1;
1007
- contentIdx += 1;
1008
- }
1009
- if (ok)
1010
- spans.push([start, end]);
1011
- }
1012
- if (spans.length !== 1)
1013
- return undefined;
1014
- const [start, end] = spans[0];
1015
- const candidate = contentLines.slice(start, end + 1).join("\n");
1016
- return candidate === oldText ? undefined : candidate;
1017
- }
1018
- /**
1019
- * Fold the Unicode punctuation that models and rendered text routinely swap for
1020
- * ASCII (and back) to a canonical ASCII form: smart single/double quotes →
1021
- * `'`/`"`, the dash family (hyphen, figure/en/em dash, horizontal bar, minus) →
1022
- * `-`, and non-breaking / typographic spaces → a regular space. Used only to
1023
- * build a match signature — never to rewrite file content.
1024
- */
1025
- function normalizeUnicodePunctuation(text) {
1026
- return text
1027
- .replace(/[‘’‚‛]/g, "'")
1028
- .replace(/[“”„‟]/g, '"')
1029
- .replace(/[‐-―−]/g, "-")
1030
- .replace(/[  -    ]/g, " ");
1031
- }
1032
- /**
1033
- * Tier C of the autopatch ladder: tolerate Unicode-punctuation divergence the
1034
- * whitespace tiers can't bridge (smart quotes ↔ straight, em/en-dash ↔ hyphen,
1035
- * NBSP ↔ space). The signature folds Unicode punctuation to ASCII and then
1036
- * collapses all whitespace (so it subsumes Tier B and additionally absorbs the
1037
- * punctuation swap). Safety mirrors Tier B exactly: matches by the folded
1038
- * signature but **recovers and returns the verbatim file span** (the file's real
1039
- * characters), requires the signature to match **exactly once**, and anchors on
1040
- * ≥2 non-blank lines to resist single-line collisions.
1041
- */
1042
- function findUnicodePunctuationInsensitiveCandidate(content, oldText) {
1043
- const fold = (line) => normalizeUnicodePunctuation(line).replace(/\s+/g, "");
1044
- const isBlank = (line) => fold(line) === "";
1045
- const contentLines = content.split("\n");
1046
- const oldSignature = oldText
1047
- .split("\n")
1048
- .map(fold)
1049
- .filter((line) => line !== "");
1050
- if (oldSignature.length < 2)
1051
- return undefined;
1052
- const spans = [];
1053
- for (let start = 0; start < contentLines.length; start += 1) {
1054
- if (fold(contentLines[start]) !== oldSignature[0])
1055
- continue;
1056
- let contentIdx = start + 1;
1057
- let sigIdx = 1;
1058
- let end = start;
1059
- let ok = true;
1060
- while (sigIdx < oldSignature.length) {
1061
- while (contentIdx < contentLines.length &&
1062
- isBlank(contentLines[contentIdx]))
1063
- contentIdx += 1;
1064
- if (contentIdx >= contentLines.length ||
1065
- fold(contentLines[contentIdx]) !== oldSignature[sigIdx]) {
1066
- ok = false;
1067
- break;
1068
- }
1069
- end = contentIdx;
1070
- sigIdx += 1;
1071
- contentIdx += 1;
1072
- }
1073
- if (ok)
1074
- spans.push([start, end]);
1075
- }
1076
- if (spans.length !== 1)
1077
- return undefined;
1078
- const [start, end] = spans[0];
1079
- const candidate = contentLines.slice(start, end + 1).join("\n");
1080
- return candidate === oldText ? undefined : candidate;
1081
- }
1082
- /**
1083
- * Shift a native range edit's line numbers, in place, by the relocation delta.
1084
- * Returns true when a range matching `from` was found and rewritten. Powers the
1085
- * content-verified range-stale auto-apply: the lines the agent meant to edit
1086
- * moved (proven by read-time line hashes uniquely matching the new location),
1087
- * so we re-target the positional edit to where the content now lives.
1088
- *
1089
- * Shifts by a constant line delta (`to[0] - from[0]`) applied to both the start
1090
- * and end lines, so inclusive/exclusive end conventions and any character
1091
- * offsets are preserved untouched — only the line position moves. Matches both
1092
- * the single `oldRange` shape and `edits[].range` entries.
1093
- */
1094
- export function relocateEditRange(input, from, to) {
1095
- const delta = to[0] - from[0];
1096
- if (delta === 0 || !input || typeof input !== "object")
1097
- return false;
1098
- const editInput = input;
1099
- const matchesFrom = (start, end) => start === from[0] && end === from[1];
1100
- let applied = false;
1101
- const oldRange = editInput.oldRange;
1102
- if (oldRange?.start?.line !== undefined &&
1103
- oldRange.end?.line !== undefined &&
1104
- matchesFrom(oldRange.start.line, oldRange.end.line)) {
1105
- oldRange.start.line += delta;
1106
- oldRange.end.line += delta;
1107
- applied = true;
1108
- }
1109
- if (Array.isArray(editInput.edits)) {
1110
- for (const edit of editInput.edits) {
1111
- const start = edit.range?.start?.line;
1112
- const end = edit.range?.end?.line ?? start;
1113
- if (start !== undefined && matchesFrom(start, end)) {
1114
- edit.range.start.line = start + delta;
1115
- if (edit.range?.end?.line !== undefined) {
1116
- edit.range.end.line += delta;
1117
- }
1118
- applied = true;
1119
- }
1120
- }
1121
- }
1122
- return applied;
1123
- }
1124
- export function getTouchedLinesForGuard(event, filePath, sessionId, correlationId, partialApplyRecords) {
1125
- // #2423: the seam decides whether this event mutates a file, and which shape
1126
- // adapter (if any) already resolved its ranges. A tool named `replace` or
1127
- // `insert` reaches the native-shape ladder below exactly like `edit` does.
1128
- const mutation = classifyMutatingTool(event, {
1129
- filePath,
1130
- sessionId,
1131
- correlationId,
1132
- });
1133
- if (mutation === undefined)
1134
- return { touchedLines: undefined };
1135
- if (mutation.kind === "edit") {
1136
- // An adapter that recognized the input owns the answer, including a
1137
- // blocking preflight error.
1138
- if (mutation.touchedLines !== undefined || mutation.preflightError) {
1139
- return {
1140
- touchedLines: mutation.touchedLines,
1141
- ...(mutation.editRanges ? { editRanges: mutation.editRanges } : {}),
1142
- ...(mutation.preflightError
1143
- ? { preflightError: mutation.preflightError }
1144
- : {}),
1145
- ...(mutation.editBatchSummary
1146
- ? { editBatchSummary: mutation.editBatchSummary }
1147
- : {}),
1148
- };
1149
- }
1150
- // The host standard-edit fields (path, edits[].oldText/newText) are pinned
1151
- // to the SDK's EditToolInput, so a host edit-schema change is a compile
1152
- // error instead of silently falling through to `unknown_edit_schema`. The
1153
- // remaining keys are pi-lens's own extensions for native-ranged + hashline
1154
- // edit tools; oldText/newText are probed as optional because range-only
1155
- // edits omit them (refs #3).
1156
- const editInput = event.input;
1157
- if (editInput.oldRange) {
1158
- const touchedLines = [
1159
- editInput.oldRange.start.line,
1160
- editInput.oldRange.end.line,
1161
- ];
1162
- if (filePath) {
1163
- logReadGuardEvent({
1164
- event: "touched_lines_detected",
1165
- correlationId,
1166
- sessionId,
1167
- filePath,
1168
- metadata: {
1169
- tool: "edit",
1170
- source: "oldRange",
1171
- touchedLines,
1172
- },
1173
- });
1174
- }
1175
- return { touchedLines };
1176
- }
1177
- if (editInput.edits?.length) {
1178
- const rangedEdits = editInput.edits
1179
- .map((edit) => {
1180
- const start = edit.range?.start?.line;
1181
- const end = edit.range?.end?.line ?? start;
1182
- if (typeof start !== "number" || typeof end !== "number") {
1183
- return null;
1184
- }
1185
- return [start, end];
1186
- })
1187
- .filter((range) => range !== null);
1188
- const unresolvedOldTextEdits = editInput.edits
1189
- .map((edit, index) => ({ ...edit, originalIndex: index }))
1190
- .filter((edit) => typeof edit.range?.start?.line !== "number" && !!edit.oldText);
1191
- if (rangedEdits.length === 0) {
1192
- if (filePath) {
1193
- return resolveOldTextEdits(editInput.edits, filePath, sessionId, correlationId, partialApplyRecords);
1194
- }
1195
- return { touchedLines: undefined };
1196
- }
1197
- let oldTextTouchedLines;
1198
- let oldTextEditRanges;
1199
- if (unresolvedOldTextEdits.length > 0 && filePath) {
1200
- const resolved = resolveOldTextEdits(unresolvedOldTextEdits, filePath, sessionId, correlationId, partialApplyRecords);
1201
- if (resolved.preflightError) {
1202
- // A mixed range/oldText request is one host operation. If any
1203
- // oldText edit cannot be represented as a carried raw span,
1204
- // close the whole batch instead of letting the host apply only
1205
- // the native ranges.
1206
- return {
1207
- ...resolved,
1208
- partiallyApplicable: undefined,
1209
- touchedLines: undefined,
1210
- };
1211
- }
1212
- oldTextTouchedLines = resolved.touchedLines;
1213
- oldTextEditRanges = resolved.editRanges;
1214
- }
1215
- const starts = rangedEdits.map(([start]) => start);
1216
- const ends = rangedEdits.map(([, end]) => end);
1217
- if (oldTextTouchedLines) {
1218
- starts.push(oldTextTouchedLines[0]);
1219
- ends.push(oldTextTouchedLines[1]);
1220
- }
1221
- const touchedLines = [
1222
- Math.min(...starts),
1223
- Math.max(...ends),
1224
- ];
1225
- const allEditRanges = [...rangedEdits];
1226
- if (oldTextEditRanges?.length) {
1227
- allEditRanges.push(...oldTextEditRanges);
1228
- }
1229
- else if (oldTextTouchedLines) {
1230
- allEditRanges.push(oldTextTouchedLines);
1231
- }
1232
- const editRanges = allEditRanges.length > 1 ? allEditRanges : undefined;
1233
- if (filePath) {
1234
- logReadGuardEvent({
1235
- event: "touched_lines_detected",
1236
- correlationId,
1237
- sessionId,
1238
- filePath,
1239
- metadata: {
1240
- tool: "edit",
1241
- source: unresolvedOldTextEdits.length > 0
1242
- ? "edits_mixed"
1243
- : "edits_ranges",
1244
- touchedLines,
1245
- rangedEditCount: rangedEdits.length,
1246
- resolvedOldTextEditCount: unresolvedOldTextEdits.length,
1247
- totalEditCount: editInput.edits.length,
1248
- },
1249
- });
1250
- }
1251
- return { touchedLines, editRanges };
1252
- }
1253
- if (filePath) {
1254
- const topLevelKeys = Object.keys(editInput);
1255
- logReadGuardEvent({
1256
- event: "touched_lines_missing",
1257
- correlationId,
1258
- sessionId,
1259
- filePath,
1260
- metadata: {
1261
- tool: "edit",
1262
- source: "unknown_edit_schema",
1263
- // #2423: name the tool. An unknown schema under a third-party
1264
- // tool name is the actionable case — it says which producer
1265
- // needs a shape adapter.
1266
- mutatingToolName: mutation.toolName,
1267
- mutationProvenance: mutation.provenance,
1268
- // #2423 review round 1 (F1): an adapter that RECOGNIZED the
1269
- // shape but could not turn its anchors into lines says so here.
1270
- // `adapterSource: "hashline-edit-pro"` with
1271
- // `unresolvedReason: "remove_from:anchor_not_found"` is the
1272
- // production record of a stale anchor — a report, not a block.
1273
- adapterSource: mutation.source,
1274
- unresolvedReason: mutation.unresolvedReason,
1275
- topLevelKeys,
1276
- hasNativeOldRange: !!editInput.oldRange,
1277
- hasNativeEdits: Array.isArray(editInput.edits),
1278
- hasHashlineSetLine: !!editInput.set_line,
1279
- hasHashlineReplaceLines: !!editInput.replace_lines,
1280
- hasHashlineReplaceSymbol: !!editInput.replace_symbol,
1281
- hasHashlineBatch: Array.isArray(editInput.operations) || Array.isArray(editInput.ops),
1282
- strictModeWouldBlock: true,
1283
- },
1284
- });
1285
- }
1286
- return { touchedLines: undefined };
1287
- }
1288
- // kind === "write": the whole file is the touched range.
1289
- const lineCount = filePath ? countFileLines(filePath) : 1;
1290
- const writeTouchedLines = [1, lineCount];
1291
- if (filePath) {
1292
- logReadGuardEvent({
1293
- event: "touched_lines_detected",
1294
- correlationId,
1295
- sessionId,
1296
- filePath,
1297
- metadata: {
1298
- tool: "write",
1299
- source: "full_file_write",
1300
- touchedLines: writeTouchedLines,
1301
- lineCount,
1302
- },
1303
- });
1304
- }
1305
- return { touchedLines: writeTouchedLines };
1306
- }