pi-agent-ide 0.6.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (395) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +2 -2
  3. package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
  4. package/dist/{chunk-QEJGED4V.js → chunk-3HYXQ4YA.js} +1 -1
  5. package/dist/chunk-3JO7QFIL.js +1 -0
  6. package/dist/{chunk-5J43L2RL.js → chunk-4NIFBFFR.js} +1 -1
  7. package/dist/{chunk-BSICWXMH.js → chunk-64M3SQPG.js} +1 -1
  8. package/dist/{chunk-3BBJZSMS.js → chunk-7LD2OQH3.js} +1 -1
  9. package/dist/chunk-7LZKOHH2.js +1 -0
  10. package/dist/chunk-AJRIASPQ.js +2 -0
  11. package/dist/chunk-EAZGN5ND.js +7 -0
  12. package/dist/{chunk-GIRAEVUJ.js → chunk-F5YZG77W.js} +1 -1
  13. package/dist/chunk-FK42RSF4.js +1 -0
  14. package/dist/{chunk-WJTHY6AG.js → chunk-FXNKMNSJ.js} +1 -1
  15. package/dist/chunk-GBLKIB6O.js +2 -0
  16. package/dist/{chunk-KUPHNMUK.js → chunk-KBP3QUDT.js} +1 -1
  17. package/dist/{chunk-VBICI5YA.js → chunk-KR36BT5E.js} +1 -1
  18. package/dist/chunk-OE7QVAI2.js +5 -0
  19. package/dist/chunk-PNU3E7IO.js +3 -0
  20. package/dist/chunk-PS2B6THP.js +3 -0
  21. package/dist/{chunk-HPUAIWIH.js → chunk-PYPPV2F5.js} +1 -1
  22. package/dist/{chunk-FUG2TEKI.js → chunk-QFTBY67N.js} +2 -2
  23. package/dist/chunk-S5LXX32D.js +28 -0
  24. package/dist/chunk-SQKAXYIR.js +2 -0
  25. package/dist/chunk-VCGNVTXQ.js +1 -0
  26. package/dist/chunk-XYS4FSCC.js +12 -0
  27. package/dist/{chunk-FBOW7XOV.js → chunk-YRF7OATP.js} +1 -1
  28. package/dist/entry-11.js +1 -1
  29. package/dist/entry-13.js +1 -1
  30. package/dist/entry-14.js +1 -1
  31. package/dist/entry-15.js +1 -1
  32. package/dist/entry-17.js +1 -1
  33. package/dist/entry-25.js +1 -1
  34. package/dist/entry-26.js +1 -1
  35. package/dist/entry-28.js +1 -1
  36. package/dist/entry-29.js +1 -1
  37. package/dist/entry-30.js +1 -1
  38. package/dist/entry-31.js +13 -11
  39. package/dist/entry-33.js +1 -1
  40. package/dist/entry-37.js +6 -6
  41. package/dist/entry-42.js +1 -1
  42. package/dist/entry-44.js +1 -1
  43. package/dist/entry-45.js +13 -13
  44. package/dist/entry-46.js +1 -1
  45. package/dist/entry-49.js +1 -1
  46. package/dist/entry-50.js +3 -6
  47. package/dist/entry-51.js +11 -9
  48. package/dist/entry-52.js +1 -1
  49. package/dist/entry-53.js +1 -1
  50. package/dist/entry-54.js +1 -1
  51. package/dist/entry-56.js +1 -1
  52. package/dist/entry-58.js +1 -1
  53. package/dist/entry-60.js +1 -1
  54. package/dist/entry-61.js +0 -1
  55. package/dist/entry-62.js +1 -0
  56. package/dist/entry-63.js +0 -1
  57. package/dist/entry-64.js +1 -0
  58. package/dist/entry-65.js +1 -1
  59. package/dist/entry-66.js +1 -1
  60. package/dist/entry-67.js +1 -1
  61. package/dist/entry-68.js +1 -1
  62. package/dist/entry-69.js +1 -1
  63. package/dist/entry-70.js +1 -1
  64. package/dist/entry-71.js +0 -1
  65. package/dist/entry-72.js +1 -0
  66. package/dist/entry-73.js +0 -1
  67. package/dist/entry-74.js +1 -0
  68. package/dist/entry-75.js +1 -1
  69. package/dist/entry-76.js +1 -1
  70. package/dist/entry-77.js +67 -1
  71. package/dist/entry-78.js +14 -325
  72. package/dist/entry-79.js +2 -18
  73. package/dist/entry-80.js +1 -2
  74. package/dist/entry-81.js +1 -1
  75. package/dist/entry-82.js +5 -1
  76. package/dist/entry-83.js +3 -5
  77. package/dist/entry-84.js +1 -3
  78. package/dist/entry-85.js +1 -1
  79. package/dist/entry-86.js +1 -1
  80. package/dist/pi-agent-ide.js +5 -5
  81. package/docs/agent-guides/editing.md +20 -4
  82. package/docs/agent-guides/git-changes.md +1 -1
  83. package/docs/agent-guides/read-resources.md +9 -1
  84. package/docs/agent-guides/search-code.md +38 -1
  85. package/docs/agent-guides/select-code.md +194 -0
  86. package/docs/configuration.md +12 -17
  87. package/docs/development.md +2 -1
  88. package/docs/releases.md +1 -1
  89. package/docs/research/apply-native-capability-matrix.md +174 -0
  90. package/docs/research/apply-read-latency.md +2 -0
  91. package/docs/research/lpt-393-fuzzy-results/file.json +152 -0
  92. package/docs/research/lpt-393-fuzzy-results/repo.json +122 -0
  93. package/docs/research/lpt-393-search-fuzzy-fallback.md +97 -0
  94. package/docs/research/native-codemode-batch-decision.md +2 -0
  95. package/docs/research/native-codemode-batching.md +1 -1
  96. package/docs/structured-results.md +32 -5
  97. package/docs/tools.md +6 -2
  98. package/docs/user-hooks.md +1 -1
  99. package/node_modules/pi-agent-doctor/package.json +1 -1
  100. package/node_modules/pi-agent-documentation/package.json +1 -1
  101. package/node_modules/pi-agent-filesystem/package.json +7 -7
  102. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  103. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  104. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  105. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  106. package/node_modules/pi-agent-ide-ast/package.json +15 -10
  107. package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
  108. package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
  109. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +5 -1
  110. package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +204 -0
  111. package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
  112. package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -2
  113. package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
  114. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +107 -21
  115. package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +104 -0
  116. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +384 -0
  117. package/node_modules/pi-agent-ide-ast/src/selection-region.ts +41 -0
  118. package/node_modules/pi-agent-ide-ast/src/source-text.ts +92 -0
  119. package/node_modules/pi-agent-ide-ast/src/text-selection.ts +214 -0
  120. package/node_modules/pi-agent-ide-ast/src/tool-select.ts +251 -0
  121. package/node_modules/pi-agent-ide-changes/index.ts +2 -18
  122. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  123. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
  124. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
  125. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  126. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  127. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  128. package/node_modules/pi-agent-ide-lsp/index.ts +2 -2
  129. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  130. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
  131. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
  132. package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
  133. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
  134. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
  135. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +88 -45
  136. package/node_modules/pi-agent-image/package.json +2 -2
  137. package/node_modules/pi-agent-invariant/package.json +1 -1
  138. package/node_modules/pi-agent-pdf/package.json +2 -2
  139. package/node_modules/pi-agent-read/package.json +7 -7
  140. package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
  141. package/node_modules/pi-agent-read/src/api/tools/read.ts +4 -0
  142. package/node_modules/pi-agent-read/src/core/extension.ts +11 -0
  143. package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
  144. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +2 -0
  145. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +8 -1
  146. package/node_modules/pi-agent-resource/package.json +1 -1
  147. package/node_modules/pi-agent-resource/src/index.ts +10 -0
  148. package/node_modules/pi-agent-resource/src/result-targets.ts +233 -0
  149. package/node_modules/pi-agent-search/package.json +5 -5
  150. package/node_modules/pi-agent-search/src/api/fuzzy.ts +208 -0
  151. package/node_modules/pi-agent-search/src/api/presentation.ts +68 -0
  152. package/node_modules/pi-agent-search/src/api/search-parameters.ts +9 -3
  153. package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
  154. package/node_modules/pi-agent-search/src/api/search.ts +28 -0
  155. package/node_modules/pi-agent-search/src/api/structured-result.ts +69 -14
  156. package/node_modules/pi-agent-search/src/core/extension.ts +56 -16
  157. package/node_modules/pi-agent-search/src/core/search-core.ts +9 -1
  158. package/node_modules/pi-agent-search-text/index.ts +3 -1
  159. package/node_modules/pi-agent-search-text/package.json +7 -6
  160. package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +164 -0
  161. package/node_modules/pi-agent-search-text/src/resolvers.ts +161 -30
  162. package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
  163. package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -17
  164. package/node_modules/pi-agent-search-text/src/search-renderer.ts +89 -292
  165. package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
  166. package/node_modules/pi-agent-search-text/src/search-session.ts +96 -11
  167. package/node_modules/pi-agent-text/package.json +2 -2
  168. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  169. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  170. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  171. package/node_modules/pi-agent-text-editor/index.ts +0 -5
  172. package/node_modules/pi-agent-text-editor/package.json +26 -31
  173. package/node_modules/pi-agent-text-editor/runtime/entry-77.js +1 -0
  174. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
  175. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
  176. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
  177. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
  178. package/node_modules/pi-agent-text-editor/src/core/extension.ts +12 -2
  179. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
  180. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +1 -1
  181. package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
  182. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
  183. package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
  184. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +199 -19
  185. package/node_modules/pi-agent-text-editor/src/core/result-input.ts +22 -0
  186. package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
  187. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
  188. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +109 -11
  189. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
  190. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
  191. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +211 -223
  192. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
  193. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
  194. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
  195. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
  196. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
  197. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
  198. package/node_modules/pi-agent-text-editor-renderer/index.ts +1 -72
  199. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  200. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
  201. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
  202. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  203. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  204. package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +1 -0
  205. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  206. package/node_modules/pi-agent-tool-ui/src/index.ts +7 -0
  207. package/node_modules/pi-agent-tool-ui/src/result-panel.ts +298 -0
  208. package/node_modules/pi-agent-web/index.ts +3 -0
  209. package/node_modules/pi-agent-web/package.json +8 -8
  210. package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
  211. package/node_modules/pi-agent-web/src/search.ts +111 -2
  212. package/node_modules/pi-agent-web-html/package.json +3 -3
  213. package/node_modules/pi-agent-web-image/package.json +4 -4
  214. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  215. package/node_modules/pi-agent-web-text/package.json +4 -4
  216. package/package.json +35 -36
  217. package/src/composite/module-labels.ts +1 -1
  218. package/src/composite/preferences.ts +0 -5
  219. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  220. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  221. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  222. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  223. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  224. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +3 -0
  225. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
  226. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  227. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +2 -0
  228. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  229. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  230. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  231. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +2 -0
  232. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +111 -2
  233. package/src/extensions/pi-agent-read/package.json +7 -7
  234. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
  235. package/src/extensions/pi-agent-read/src/api/tools/read.ts +4 -0
  236. package/src/extensions/pi-agent-read/src/core/extension.ts +11 -0
  237. package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
  238. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +2 -0
  239. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +8 -1
  240. package/src/extensions/pi-agent-search/package.json +5 -5
  241. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -1
  242. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -6
  243. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +164 -0
  244. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +161 -30
  245. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +103 -0
  246. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -17
  247. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +89 -292
  248. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +77 -0
  249. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +96 -11
  250. package/src/extensions/pi-agent-search/src/api/fuzzy.ts +208 -0
  251. package/src/extensions/pi-agent-search/src/api/presentation.ts +68 -0
  252. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +9 -3
  253. package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
  254. package/src/extensions/pi-agent-search/src/api/search.ts +28 -0
  255. package/src/extensions/pi-agent-search/src/api/structured-result.ts +69 -14
  256. package/src/extensions/pi-agent-search/src/core/extension.ts +56 -16
  257. package/src/extensions/pi-agent-search/src/core/search-core.ts +9 -1
  258. package/src/extensions/pi-agent-text-editor/index.ts +0 -5
  259. package/src/extensions/pi-agent-text-editor/package.json +26 -31
  260. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  261. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  262. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  263. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +1 -72
  264. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  265. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +2 -0
  266. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
  267. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
  268. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  269. package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +1 -0
  270. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
  271. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
  272. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
  273. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
  274. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +12 -2
  275. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
  276. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +1 -1
  277. package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
  278. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
  279. package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
  280. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +199 -19
  281. package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +22 -0
  282. package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
  283. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
  284. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +109 -11
  285. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
  286. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
  287. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +211 -223
  288. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
  289. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
  290. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
  291. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
  292. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
  293. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
  294. package/src/pi-agent-ide.ts +0 -6
  295. package/src/plugins/pi-agent-ide-ast/package.json +15 -10
  296. package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
  297. package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
  298. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +5 -1
  299. package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +204 -0
  300. package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
  301. package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -2
  302. package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
  303. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +107 -21
  304. package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +104 -0
  305. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +384 -0
  306. package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +41 -0
  307. package/src/plugins/pi-agent-ide-ast/src/source-text.ts +92 -0
  308. package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +214 -0
  309. package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +251 -0
  310. package/src/plugins/pi-agent-ide-changes/index.ts +2 -18
  311. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  312. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
  313. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
  314. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  315. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  316. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  317. package/src/plugins/pi-agent-ide-lsp/index.ts +2 -2
  318. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  319. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
  320. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
  321. package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
  322. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
  323. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
  324. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +88 -45
  325. package/src/plugins/pi-agent-ide-terminal/src/search.ts +10 -36
  326. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +1 -1
  327. package/src/plugins/pi-agent-ide-vision/index.ts +19 -0
  328. package/dist/chunk-2P2OGO3G.js +0 -2
  329. package/dist/chunk-6EYWFBNG.js +0 -0
  330. package/dist/chunk-7AVXUV4A.js +0 -7
  331. package/dist/chunk-7WCZOO5I.js +0 -1
  332. package/dist/chunk-BAYETTZZ.js +0 -16
  333. package/dist/chunk-BVK5A7ED.js +0 -28
  334. package/dist/chunk-F7NVAC4Q.js +0 -0
  335. package/dist/chunk-FZBCKIJJ.js +0 -1
  336. package/dist/chunk-I5JLCFUX.js +0 -1
  337. package/dist/chunk-MIZAFRDR.js +0 -1
  338. package/dist/chunk-PJPA5EEE.js +0 -2
  339. package/dist/chunk-PXWDDBBC.js +0 -0
  340. package/dist/chunk-TQZBVOTT.js +0 -5
  341. package/dist/chunk-VWW3RLUX.js +0 -12
  342. package/dist/chunk-YHUTTZC6.js +0 -2
  343. package/dist/chunk-ZODCBFBL.js +0 -2
  344. package/dist/entry-87.js +0 -1
  345. package/docs/agent-guides/apply.md +0 -333
  346. package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
  347. package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
  348. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
  349. package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
  350. package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
  351. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
  352. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
  353. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +0 -276
  354. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
  355. package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
  356. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
  357. package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +0 -137
  358. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
  359. package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
  360. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
  361. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
  362. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
  363. package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +0 -1
  364. package/node_modules/pi-agent-web-text/runtime/entry-87.js +0 -2
  365. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +0 -2
  366. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +0 -2
  367. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
  368. package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -2
  369. package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
  370. package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
  371. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
  372. package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
  373. package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
  374. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
  375. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
  376. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +0 -276
  377. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
  378. package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
  379. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
  380. package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +0 -137
  381. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
  382. package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
  383. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
  384. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
  385. /package/node_modules/{pi-agent-text-editor → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
  386. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
  387. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-81.js +0 -0
  388. /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-83.js +0 -0
  389. /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
  390. /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
  391. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
  392. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
  393. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
  394. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
  395. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
@@ -8,6 +8,14 @@ Use uppercase `AND` and `OR`, infix `NOT`, `||`, or a space-separated `|` for Bo
8
8
 
9
9
  Use `files:<pattern>` for paths. Slash-containing globs match workspace-relative paths; basename globs match at any depth. Narrow with `path`, `include`, and `exclude` before broadening a noisy query.
10
10
 
11
+ ## Possible names after zero matches
12
+
13
+ Use possible-name groups as spelling hints, not synonyms or proof of equivalent behavior. Inspect the candidate source before choosing an edit. The original match list stays empty; each group is a separate exact alternative in the same scope.
14
+
15
+ Inside native Codemode, use `data.fuzzy.candidates` when returned. Check each group's `selection.complete` separately from `selection.truncated`. Pass a registered local `selection` or its `target` to compatible tools for strict snapshot composition; its preview does not clip the stored candidate scope. Use its `selection.all` only when returned, or its individual match references. A candidate all-reference refreshes that exact alternative, not the fuzzy ranking. For URL groups, read the returned URL and line range; no editable Search references exist. Structured result-scoped queries stay exact and do not run this extra branch.
16
+
17
+ If the extra branch reports a budget skip, narrow `path` rather than treating the skip as proof that no nearby name exists. Keep quoted exact queries, Boolean queries, and explicit protocols exact.
18
+
11
19
  ## Search resources
12
20
 
13
21
  Inside native Codemode, check `status` and use `data.matches`, their exact `range`, and `references.line` or `references.match`. Use `data.all` only when returned. Check backend `complete` separately from public-window `truncated`; an empty successful match list is not an error.
@@ -16,14 +24,43 @@ Local text results expose `SEARCH#HASH:N:line` for its containing line and `SEAR
16
24
 
17
25
  A single-result reference becomes stale after its file changes. Re-run the search before reuse. A complete `:all` reference refreshes its original query when selected files change. Compacted output retains complete all-selections.
18
26
 
27
+ ## Searching returned scopes
28
+
29
+ Pass a source-aware Read/Search/mutation result with a live target, its `data`, a `RESULT#` reference, or an array of returned matches/resources as `path` to search their exact source ranges. Local text, `regex:`, `ast:`, and `symbols:` queries support this input. Sparse ranges and files stay separate; gaps and neighboring text are not searched.
30
+
31
+ A replace/insert result searches only that call's resulting text, including an empty resulting position. Copy/move search only destination text; whole-file transfers, write and undo search whole resulting files. Delete and restored absence have no live text target. In native Codemode, passing a pending result commits the batch first. Final formatting runs at script end; targets from before changed formatting become stale, not silently rebound.
32
+
33
+ Pass `found.data.matches.filter(...)` to narrow a result with JavaScript. A whole result's `target` still selects its complete stored scope; changing its preview does not narrow it. Preserve returned target handles instead of reconstructing coordinates from text.
34
+
35
+ Check `complete` before treating zero matches as absence. Inherited incompleteness survives non-empty subsets. Empty arrays select no sources; they do not default to the workspace. Result-scoped text Boolean queries and text include/exclude globs remain unsupported. AST and LSP providers retain their own path/glob filters. File/process and unsupported provider scopes fail without widening the scope.
36
+
19
37
  ## AST search
20
38
 
21
- Use `ast:<pattern>` for syntax-aware matching. `$NAME` captures one syntax node and `$$$BODY` captures several nodes. Returned search references can select multiline matches for read, replace, copy, move, delete, and Apply. An incomplete result does not provide a complete all-selection. Text replacement through an AST selection does not update imports or references automatically.
39
+ Use `ast:<pattern>` for syntax-aware matching. `$NAME` captures one syntax node and `$$$BODY` captures several nodes. Returned search references can select multiline matches for read, replace, copy, move, and delete. An incomplete result does not provide a complete all-selection. Text replacement through an AST selection does not update imports or references automatically.
40
+
41
+ Pass `found.data.matches[index].captures.NAME` to Search or replace to use an AST capture without Select. Each name contains an array of source targets associated with that parent match. Multi captures retain all provider nodes, including punctuation; an absent or empty capture is not an invented source range. Use ordinary JavaScript to choose nodes. AST matches and captures must be wholly contained in one requested region; they are not clipped at a scope boundary.
42
+
43
+ ```js
44
+ const window = await tools.read({ path: "client.ts", offset: 10, limit: 4 });
45
+ if (window.status !== "success") throw Error(JSON.stringify(window.errors));
46
+ const calls = await tools.search({ path: window, query: "ast:request($OPTIONS)" });
47
+ if (calls.status !== "success") throw Error(JSON.stringify(calls.errors));
48
+ const options = calls.data.matches[0]?.captures.OPTIONS;
49
+ if (options === undefined) throw Error("No captured options");
50
+ const values = await tools.search({ path: options, query: "1000" });
51
+ if (values.status !== "success") throw Error(JSON.stringify(values.errors));
52
+ const changed = await tools.replace({ path: values, text: "2000" });
53
+ text(changed);
54
+ ```
22
55
 
23
56
  ## Symbols and graphs
24
57
 
25
58
  Use `symbols:<query>` to locate declarations and references when the source file is unknown. Use `symbol:<file>#<selector>` to read one declaration. Use `graph:<file>` for the file's top-level declarations and relationships, or `graph:<file>#<selector>` for incoming and outgoing references of one declaration.
26
59
 
60
+ Pass a result scope to `symbols:` for strict discovery inside its exact ranges. Inspect `matches[].role` (`definition` or `reference`) and `matches[].symbol` for the originating declaration's identity, name, kind, source, and range. Name equality alone does not establish reference identity.
61
+
62
+ Use `navigation: "references"` only when following symbols represented inside the input scope to references outside it. Navigation stays within the workspace. Path and globs define the seed scope in this mode, not the destination references. Omit navigation for strict discovery. Check `complete`; failed requests and unavailable providers are errors, not proof of absence. Text replacement through an LSP match changes only that range; it is not semantic rename.
63
+
27
64
  Append `#name` to an exact symbol resource only for a native language-server rename across references. If semantic support is unavailable, use a precise text or AST operation instead of pretending it was a semantic rename. Pending or empty language-server output does not prove that no declaration or reference exists.
28
65
 
29
66
  ## Other search protocols
@@ -0,0 +1,194 @@
1
+ # Select source boundaries
2
+
3
+ Use Search to find text or code by a predicate. Use Select when an existing target needs new text or structural boundaries. Ordinary JavaScript chooses returned items; it cannot grant source authority to reconstructed coordinates or strings.
4
+
5
+ ## AST operations
6
+
7
+ AST operations support JavaScript (.js/.mjs/.cjs) and TypeScript (.ts/.mts/.cts), without JSX/TSX. Syntax errors and unavailable providers are errors, not evidence of absence. Text operations do not require a parser.
8
+
9
+ ### Enclosing constructs
10
+
11
+ Use `{kind:"object", object:"function"}` to find the nearest function containing the entire seed. An exact function selects itself. Set level:2 for the next outer function; levels count only the requested category. The optional relation/extent spellings remain enclosing/around. Enclosing can expand outside a Read/Search window and reports each input association and expansion. Seeds crossing separate constructs are rejected instead of choosing from their first character.
12
+
13
+ Supported object categories:
14
+
15
+ - function: declarations, expressions, arrows, class/object methods, async/generator forms and bodyless TS signatures. Default parameter expressions belong to their function.
16
+ - call: calls and new expressions.
17
+ - class, if, switch, loop (for/for-in/for-of/while/do), try and catch.
18
+ - binding: a variable declarator, not the surrounding const/let/var statement. assignment: ordinary and compound assignment expressions.
19
+ - object/array: literals and destructuring patterns; property: key/value pairs and shorthand object properties.
20
+ - return and throw.
21
+
22
+ These are syntax categories, not resolved symbol identities. Parser-only wrappers, punctuation, type nodes and comments do not become extra public construct categories. Class fields, JSX/TSX and other unlisted forms are not promised as constructs. ownBody is not implemented.
23
+
24
+ ### Navigate
25
+
26
+ Use `{kind:"navigate", relation:"parent"}` on an exact named syntax node. Returned constructs skip parser-only wrappers. Exact part/capture targets can be used directly; if a text range cuts through a node, first use object/enclosing. When several nested nodes have identical bounds, the supported construct takes precedence; otherwise the innermost exact named node is the starting node. A whole-file seed is not implicitly split into constructs.
27
+
28
+ - parent returns the nearest normalized construct ancestor, excluding the starting node.
29
+ - ancestors returns all normalized ancestors in source order, excluding the starting node.
30
+ - children returns the nearest nested constructs. descendants returns all nested constructs. Neither includes the starting node.
31
+ - siblings requires an exact normalized construct. direction previous/next returns its immediate neighbor under the same normalized parent; omit direction or use all for every other sibling. Top-level constructs share the document root. Missing parents/neighbors are valid absence.
32
+
33
+ Set object to filter results by category after navigation. A filter never changes topology: parent with object:function does not jump past an intervening call; children with object:call does not jump through an if. previous/next do not skip a different-category neighbor. Use ancestors/descendants when deeper matching constructs are wanted.
34
+
35
+ Ancestors and descendants can overlap. Choose the intended disjoint targets before editing; edit tools still reject overlapping writes. JavaScript chooses items by syntax.object or source/range; the item's stored target supplies source authority.
36
+
37
+ ### Named parts
38
+
39
+ Use `{kind:"part", part:"arguments"}` on an exact construct. Parts retain provider boundaries and delimiters: a function block body includes braces, parameter/argument lists include parentheses, return/type annotations include their colon, and an else/finalizer clause includes its keyword. A single unparenthesized arrow parameter has no invented parentheses; an expression arrow body is its exact expression.
40
+
41
+ | Construct | Supported parts |
42
+ | ----------------------------------------- | ---------------------------------------------------------- |
43
+ | function | name, parameters, returnType, body |
44
+ | call/new | callee, arguments |
45
+ | class | name, body |
46
+ | if | condition, then, else |
47
+ | switch | condition, body |
48
+ | classic for | initializer, condition, update, body |
49
+ | for-in / for-of | left, iterable, body |
50
+ | while / do | condition, body |
51
+ | try | body, handler, finalizer |
52
+ | catch | parameter, body |
53
+ | finally clause returned by part/finalizer | body |
54
+ | binding | name, type, value |
55
+ | assignment | left, right |
56
+ | property | key, value; shorthand selects the same identifier for both |
57
+ | return / throw | value |
58
+
59
+ A supported optional part that is absent produces no selection and increments missingInputs: anonymous function name, optional else, bodyless TS declaration, missing annotation, bare return, optional catch parameter, or new without arguments. Unsupported parts return an error listing available names. Objects and arrays do not invent a body or arguments part; use navigation for nested constructs and AST Search for scalar elements. For argument/parameter separator ownership, use elementExtent below; array/object list extents are not implemented.
60
+
61
+ Structural items include parser-derived syntax.object and, for part selections, syntax.part where a normalized owner exists. These labels are descriptive, not editable authority. Read takes the item's target string; its displayed line context never widens the exact part's source scope.
62
+
63
+ ```js
64
+ const found = await tools.search({ path: "client.ts", query: "ast:send($$$ARGS)" });
65
+ const call = await tools.select({ path: found, operation: { kind: "object", object: "call" } });
66
+ const args = await tools.select({ path: call, operation: { kind: "part", part: "arguments" } });
67
+ await tools.read({ path: args.data.target });
68
+ const number = await tools.search({ path: args, query: "10" });
69
+ await tools.replace({ path: number, text: "20" });
70
+ ```
71
+
72
+ ## List element extents
73
+
74
+ Use `{kind:"elementExtent", extent:"inside"}` on an exact direct JS/TS call/new argument or parenthesized function/method/arrow parameter. AST captures can provide those element targets. Variadic captures may also contain punctuation; choose the element items in JavaScript before passing them here. Commas themselves are not elements. A typed/default parameter must include its type/default, not just its name. Partial expressions, whole lists, array/object elements and unparenthesized arrow parameters are unsupported; this operation never silently selects an enclosing element.
75
+
76
+ `inside` keeps only the element. `around` adds owned comma/whitespace, reports expansion and preserves list parentheses:
77
+
78
+ | Element | around includes |
79
+ | ----------------------------------- | -------------------------------------------------------------------------------------- |
80
+ | First or middle with a next element | Element through the next element's start, including the following comma and whitespace |
81
+ | Last with a trailing comma | Element through the closing parenthesis, excluding the parenthesis |
82
+ | Last without a trailing comma | Previous element's end through this element's end; keeps closing whitespace |
83
+ | Only element | Entire list interior, including leading/trailing whitespace and any trailing comma |
84
+
85
+ Both adjacent gaps must contain only the expected comma and whitespace for around. Comments in those gaps return AMBIGUOUS_LIST_TRIVIA instead of guessing their owner. Comments inside the element are retained. inside does not assign neighboring trivia and remains available when an around request is refused.
86
+
87
+ Example: `send(a, b, c)` selects `b, ` around b and `, c` around c. Removing either single extent preserves the comma structure. Several selected extents can overlap: edit tools still reject overlap; do not assume arbitrary bulk deletion is repaired. Source bytes and CRLF stay exact.
88
+
89
+ Copy/move transports precisely the selected bytes, not a refactoring. A following-comma extent can be inserted before an existing destination element; a preceding-comma extent can be inserted after one. Destination syntax, parameter ordering and semantic validity are the caller's responsibility. Read the extent's target to preview it before editing. No new edit input contract or implicit syntax repair is provided.
90
+
91
+ ```js
92
+ const found = await tools.search({ path: "client.ts", query: "ast:send($FIRST, $MIDDLE, $LAST)" });
93
+ const element = await tools.select({
94
+ path: found.data.matches[0].captures.MIDDLE,
95
+ operation: { kind: "elementExtent", extent: "around" },
96
+ });
97
+ await tools.read({ path: element.data.target });
98
+ await tools.delete({ path: element });
99
+ ```
100
+
101
+ ## Text operations
102
+
103
+ Use `operation.kind` to choose a text transformation:
104
+
105
+ - `range` with startLine/startColumn/endLine/endColumn selects absolute source coordinates in one source. Lines are one-based, columns UTF-16 and the end exclusive. The entire requested range must fit one input region.
106
+ - `lines` with first/last selects inclusive absolute complete lines in one source, including their existing line endings. Require containment in one input region.
107
+ - `between` with non-empty literal start/end markers and extent inside/around/lines pairs the next opening marker with the nearest following closing marker, then resumes after that pair. inside excludes markers; around includes them; lines explicitly expands to complete containing lines. There is no nesting or bracket balancing. Identical markers pair successive occurrences. An unmatched opening is an error; no opening is valid absence.
108
+ - `sliceText` with non-negative from and optional to slices each region by relative UTF-16 offsets. to is exclusive and defaults to the region end. This slices source text, not the items array.
109
+ - `trim` with side start/end/both removes Unicode whitespace from those edges of each region. Whitespace-only input returns a zero-width point at its end.
110
+ - `split` with a non-empty literal delimiter returns segments without the delimiter. Empty segments remain zero-width points.
111
+ - `linesOf` explicitly expands each region to its complete containing lines. An exclusive end at next-line column zero leaves that untouched next line out.
112
+ - `position` with edge before/after returns each region's zero-width start/end. Use a whole-file Read for file edges.
113
+ - `columns` with from/to returns the exclusive UTF-16 column interval on each touched line, without line endings. Every interval must fit both its line and input scope.
114
+
115
+ Except for range/lines, apply each operation independently to every input region. Keep files and sparse gaps separate; markers or delimiters cannot span those gaps. Invalid bounds, short-line columns and boundaries inside surrogate pairs or CRLF are errors, not clipped ranges. Preserve original CRLF/LF/bare-CR endings and unterminated EOF. Only linesOf and between/lines explicitly expand text input and report expansion.
116
+
117
+ Resolve registered anchors through existing Read inputs, then pass their verified target to Select. Use Search for regex captures rather than a second regex language inside Select. Use JavaScript array slice/filter to choose items; use sliceText to derive source boundaries.
118
+
119
+ ```js
120
+ const source = await tools.read({ path: "notes.txt", offset: 2, limit: 1 });
121
+ const inside = await tools.select({
122
+ path: source,
123
+ operation: { kind: "between", start: "<", end: ">", extent: "inside" },
124
+ });
125
+ const value = await tools.select({
126
+ path: inside,
127
+ operation: { kind: "trim", side: "both" },
128
+ });
129
+ await tools.read({ path: value.data.target });
130
+ await tools.replace({ path: value, text: "new value" });
131
+ ```
132
+
133
+ Select works as an ordinary tool as well as inside native Codemode. A position can be consumed by replace or a paired copy/move destination for exact insertion. insert keeps its string-path/anchor contract.
134
+
135
+ ## Range sets
136
+
137
+ Use path for candidates and operation.scopes for comparison scopes. Both accept verified results/data/targets/item arrays and readable source strings. Match sets by file and snapshot, never by array order; different files do not match. Every input is verified even when it has no counterpart. Stale or incompatible snapshots reject the operation.
138
+
139
+ - within retains a complete candidate only when one scope contains it. It does not clip or join adjacent scopes for containment.
140
+ - intersection clips each candidate to the union of comparison scopes.
141
+ - difference subtracts the union of scopes from each candidate and returns separate surviving fragments.
142
+ - merge explicitly joins overlapping candidates. Set adjacent:true to also join touching nonempty ranges; default false. Never fill a real gap.
143
+
144
+ Clipping/subtraction keeps different candidate seeds separate. Equal output geometry is deduplicated; origins retain the candidate associations, not comparison scopes. Merge retains every contributor and reports its expansion relative to each candidate.
145
+
146
+ A point belongs to a nonempty [start,end) range at its included start but not its excluded end. Equal points match. Intersection with an explicit point keeps that point when contained; touching nonempty text does not create a point. Difference removes covered candidate points, but subtracting a point does not cut text. Merge absorbs covered points and keeps other points separate without extending text or bridging gaps. EOF points are outside a range ending at EOF.
147
+
148
+ Empty comparison scopes make within/intersection empty and difference unchanged. Empty candidates stay empty. Binary output complete is the conjunction of both inputs, including unmatched comparison files. Incomplete scopes do not establish absence or authorize an edit. missingInputs counts candidates that produce no output.
149
+
150
+ ```js
151
+ const candidates = await tools.search({ path: "notes.txt", query: "regex:<[^>]+>" });
152
+ const protectedText = await tools.search({ path: candidates, query: "KEEP" });
153
+ const editable = await tools.select({
154
+ path: candidates,
155
+ operation: { kind: "difference", scopes: protectedText },
156
+ });
157
+ const found = await tools.search({ path: editable, query: "old" });
158
+ await tools.replace({ path: found, text: "new" });
159
+ ```
160
+
161
+ ## Source inputs and results
162
+
163
+ path accepts compatible Read/Search/mutation/Select results, their data, RESULT# references and arrays of returned items. A file path obtains a fresh whole-file Read snapshot; the chosen operation still must make sense for that entire seed. A multi-function file is not implicitly split into functions.
164
+
165
+ The result has kind selection, a complete stored target, items with individual targets, exact ranges and original-input associations, complete, totalItems, missingInputs and truncated. Lines are one-based and columns are UTF-16; character ends are exclusive. Identical output geometry is deduplicated while origins retain the separate input ranges. Empty results remain valid source sets. Unsupported part inputs, ambiguity and stale/expired inputs are errors.
166
+
167
+ Items are limited to 100 and each text preview to 1000 UTF-16 code units. truncated describes presentation, not execution completeness. The top-level target retains all selected ranges. complete inherits input completeness; an incomplete result cannot establish absence or safely authorize edits. Source snapshots stay strict: refresh Read/Search after edits, session changes or reload. Select never writes or runs formatting.
168
+
169
+ ## Compose with existing tools
170
+
171
+ ```js
172
+ const calls = await tools.search({ path: "client.ts", query: "ast:legacyRequest($OPTIONS)" });
173
+ const owners = await tools.select({
174
+ path: calls,
175
+ operation: {
176
+ kind: "object",
177
+ object: "function",
178
+ relation: "enclosing",
179
+ level: 1,
180
+ extent: "around",
181
+ },
182
+ });
183
+ const body = await tools.select({
184
+ path: owners.data.items[0],
185
+ operation: { kind: "part", part: "body" },
186
+ });
187
+ const retry = await tools.search({ path: body, query: "ast:retry($$$ARGS)" });
188
+ ```
189
+
190
+ A body includes nested functions. To test for retry in that function's own body, select each retry call's nearest enclosing function and compare its source/range to the original owner. This keeps outer retry calls containing callbacks while excluding calls in nested functions or their default parameters. Do not establish absence from incomplete Search or clipped items.
191
+
192
+ For the initial timeout scenario, retain the original legacyRequest calls associated with eligible owners, use AST captures for inline object-literal options and their direct timeout values, preview, then replace only those values. Do not edit unrelated or nested-object properties, resolve variables, or imply semantic identity from a syntactic call name.
193
+
194
+ Search and compatible edits consume selection results through their stored targets. Read keeps its existing string-path schema: pass the result's target (for example, `read({path:body.data.target})`), not the whole object. Its whole-line context does not change the exact selection target. Whole-file write/undo still reject partial selections; selection never widens their guards. insert keeps its existing string/anchor contract. Formatting at the end of a native Codemode script may invalidate earlier selection targets just like other source results.
@@ -8,13 +8,9 @@ Default removes the selected scope’s override. Module descriptions show effect
8
8
 
9
9
  Feature overrides are stored under `flags` in `extensions.json`, keyed by their CLI name. Existing `noAnimations` and `noPostProcessing` fields still work; changing the corresponding feature in the menu replaces that field with its flag override.
10
10
 
11
- The Features tab includes **Disable Apply** (`pi-agent-ide-no-apply`). Enable it and reload to remove only the `apply` tool; standalone tools remain available. It defaults to off. The obsolete `old-tools` switch has been removed.
12
-
13
11
  Agent Vision adds separate opt-ins for **Capture arbitrary windows** and **Capture full displays**. Both default to off. Its text settings control the default sequence duration, frame interval, image scale, and a comma-separated list of exact executable file names that may be captured without arbitrary-window access. Press Enter to edit a text value, Enter again to commit it, then Ctrl+S to save.
14
12
 
15
- The UI tab contains separate presentation settings for Apply previews, diffs, Read, Search, and terminal output. Each setting supports **Full**, **Compact**, and **Disabled**. Compact is the product default. Full shows all available content, while Disabled keeps only a concise, honest status and still shows failures and warnings. Expanding a tool call always shows the full presentation, regardless of its collapsed preference. These settings affect only the TUI; agent-facing results and tool behavior do not change.
16
-
17
- Apply previews never execute arguments and do not indicate successful edits; operation results are shown separately. In compact mode, completed source is formatted before recognized helper calls are projected into concise operation headers. Incomplete code uses the recoverable source preview. Headers keep supplied anchors and compact long argument expressions with their source size; those sizes are not counts of applied edits. Full mode shows the complete display copy. Execution always receives the original source.
13
+ The UI tab contains separate presentation settings for diffs, Read, Search, and terminal output. Each setting supports **Full**, **Compact**, and **Disabled**. Compact is the product default. Full shows all available content, while Disabled keeps only a concise, honest status and still shows failures and warnings. Expanding a tool call always shows the full presentation, regardless of its collapsed preference. These settings affect only the TUI; agent-facing results and tool behavior do not change.
18
14
 
19
15
  All user-configurable presentation and behavior preferences belong in Agent IDE settings. New options must carry a human name, explanation and default in their registration. Presentation options belong in the UI tab.
20
16
 
@@ -28,17 +24,16 @@ Pi Agent IDE enables every built-in extension by default. Project and global con
28
24
 
29
25
  Tools use fixed native exposure; there are no IDE exposure overrides or named profiles.
30
26
 
31
- | Namespace | Tools | Exposure |
32
- | -------------- | -------------------------------- | ------------ |
33
- | `ide_read` | `read`, `diff` | `direct` |
34
- | `ide_search` | `search` | `direct` |
35
- | `ide_edit` | `apply` | `model-only` |
36
- | `ide_edit` | Standalone editing tools | `direct` |
37
- | `ide_terminal` | `bash` (`powershell` on Windows) | `direct` |
38
- | `ide_git` | `stage`, `unstage` | `deferred` |
39
- | `ide_debug` | `debug` | `deferred` |
27
+ | Namespace | Tools | Exposure |
28
+ | -------------- | -------------------------------- | ---------- |
29
+ | `ide_read` | `read`, `diff` | `direct` |
30
+ | `ide_search` | `search` | `direct` |
31
+ | `ide_edit` | Standalone editing tools | `direct` |
32
+ | `ide_terminal` | `bash` (`powershell` on Windows) | `direct` |
33
+ | `ide_git` | `stage`, `unstage` | `deferred` |
34
+ | `ide_debug` | `debug` | `deferred` |
40
35
 
41
- Apply stays directly declared, including in Codemode-only mode. Nested calls and Codemode scripts cannot call it. Direct tools keep their normal calls and can also run through Codemode while active.
36
+ Direct tools keep their normal calls and can also run through Codemode while active. Select derives exact boundaries; edits consume its snapshot-bound targets.
42
37
 
43
38
  Git staging and debugger tools are not declared ahead of time. Short agent guidance names the enabled capabilities and tells the agent to find them through native `tool_search`. IDE activates `tool_search` when an enabled deferred capability needs it and the host allows it. Native namespace filtering, BM25 ranking and Codemode declaration budgets apply; workspace `search` still searches workspace content.
44
39
 
@@ -80,7 +75,7 @@ Built-in entry modules are imported only after selection. Disabled built-ins, in
80
75
 
81
76
  ## Animations and post-edit processing
82
77
 
83
- Apply stages guarded text and file operations against immutable snapshots. An explicit `apply()` validates and commits the current multi-file transaction. Invalid, stale, ambiguous, or overlapping changes fail before writing. A later execution failure triggers rollback and reports whether restoration completed. A script may commit several transactions; reads after a commit see its changes. Configured formatting runs once per surviving changed file at the end of the outer Apply call, and diagnostics start after post-processing. Copied and moved UTF-8 text targets also receive configured post-processing; binary contents stay unchanged.
78
+ Standalone editing tools validate source snapshots before writing. Native Codemode composes those same tools and can commit pending local edits with `tools.flush({})`. Accepted child calls are not proof of persistence. Ordinary script errors keep accepted edits; aborts discard only pending work. Formatting runs once per surviving changed file at script end, followed by diagnostics. Text copy/move destinations receive post-processing; binary contents stay unchanged.
84
79
 
85
80
  Automatic diagnostic findings are grouped for five seconds from the first finding. The UI tab’s **Immediate diagnostic notices** option (`pi-agent-ide-no-diagnostic-buffer`) disables this delay. Combined notices keep each file and reporting tool identifiable. Empty completed diagnostic reads tell the agent that checks finished without findings, but do not draw an empty diagnostic panel. Pending, unavailable and incomplete checks are not reported as clean.
86
81
 
@@ -261,7 +256,7 @@ Missing fields use these defaults. Invalid values stop the editor from loading.
261
256
 
262
257
  ### Diff presentation
263
258
 
264
- Use **Diff presentation** in the Agent IDE settings UI to choose Full, Compact, or Disabled diff panels. Compact is the default and shows a focused sliding window. Full shows every available diff row. Disabled hides diff rows but keeps mutation totals, status, failures, and warnings visible. Expanding a tool call temporarily shows the full diff. The setting applies to standalone mutations, the `diff` tool, and Apply results.
259
+ Use **Diff presentation** in the Agent IDE settings UI to choose Full, Compact, or Disabled diff panels. Compact is the default and shows a focused sliding window. Full shows every available diff row. Disabled hides diff rows but keeps mutation totals, status, failures, and warnings visible. Expanding a tool call temporarily shows the full diff. The setting applies to standalone mutations, native Codemode edit panels, and the `diff` tool.
265
260
 
266
261
  ## Extension config behavior
267
262
 
@@ -58,7 +58,8 @@ The root runner uses native rendering by default. The published harness's raw re
58
58
 
59
59
  Tests that need an unchanged conversation use `#integration/support/pi-runtime/native-pi-coding-agent-test.js`. The root `pi-coding-agent-test` alias uses the same native adapter and keeps its existing surrounding read calls. Both adapters forward explicit launch options; the native adapter also reads the system prompt from Pi 0.99's transcript system messages using the SDK.
60
60
 
61
- `pnpm test:integration:shards` runs four independent Pi pools. Each run prints its own log directory under `.tmp/integration-shards.*`, so parallel audits do not overwrite each other's logs. Set `LOG_DIR` to choose another parent directory.
61
+ `pnpm test:integration:shards` runs four standalone shards. Each scenario closes its Pi process instead of retaining a shared process for every fixture configuration. Each run prints its own log directory under `.tmp/integration-shards.*`, so parallel audits do not overwrite each other's logs. Set `LOG_DIR` to choose another parent directory.
62
+ CI uses the same four shards without changing test or job timeouts. Set `REPORT_DIR` to write a separate `integration-N.xml` JUnit report for each shard. CI retains all shard reports and logs, and builds the release candidate only after every shard passes.
62
63
 
63
64
  `--no-extensions` also disables Pi's native built-ins. Native fixtures explicitly load `builtin:codemode`, `builtin:tool-search`, and `builtin:mcp`; ordinary fixtures do not. `native-host.integration.test.ts` checks the version inside the launched process, deferred discovery, nested execution, and isolation from personal MCP servers.
64
65
 
package/docs/releases.md CHANGED
@@ -19,7 +19,7 @@ See [Develop nightly](nightly.md). Nightlies test a pinned `develop` commit and
19
19
  Choose a release cut by its full commit SHA. If that commit is not yet on main, promote it through a separate pinned branch such as `chore/promote-X.Y.Z`, not a PR whose head is the moving `develop` branch. Keep that promotion head unchanged while CI runs. New develop merges do not join the release unless its scope is explicitly changed. After promotion and main-to-develop synchronization succeed, start the versioned release below. See `.pi/skills/publish-pi-agent-ide/SKILL.md` for the agent runbook.
20
20
 
21
21
  Run **Start release** on `main` with an unused `X.Y.Z` and finished release notes. The workflow checks that no other release branch or registry version exists, creates `release/X.Y.Z` with the version and changelog update, and opens a PR to `main`. The App needs Contents and Pull requests write access to this public repository. Configure `RELEASE_APP_ID` and `RELEASE_APP_PRIVATE_KEY` as Actions secrets; never commit the key. A release branch is the freeze marker. The `Validate` check is required on PRs to `main`; it rejects `develop` while a release branch exists. It admits only the matching release PR or a `fix/release-*` PR labeled `release-fix`. Review the fix itself: a label is not proof that a change is a fix.
22
- Only a branch named exactly `release/X.Y.Z` is an active release marker; older `release/v*` and `release/official-*` branches remain untouched and do not block a new release.
22
+ Only a branch named exactly `release/X.Y.Z` is an active release marker; older `release/v*` and `release/official-*` branches do not block a new release. Remove merged or abandoned release branches when no open PR, running workflow, or worktree still needs them. Delete with an expected-head lease and keep all release tags. Active release branches stay until publication and synchronization, or confirmed cancellation, finish.
23
23
 
24
24
  During the freeze, fix defects in `main` through a labeled fix PR. Rebase `release/X.Y.Z` onto the updated `main` using `--force-with-lease` and wait for the release PR's new CI run. A changed base, head or archive requires fresh candidate evidence. Do not merge features into `main` while a release is active.
25
25
 
@@ -0,0 +1,174 @@
1
+ # Can native tools replace Apply?
2
+
3
+ The tables record the pre-removal audit at `c4ccbf9`. LPT-403 then fixed empty-file creation and removed Apply under the approved native contract. Historical differences below are evidence, not current API promises.
4
+
5
+ ## Answer
6
+
7
+ **Native tools replace the agreed practical workflows, not every historical Apply guarantee.** The user chose to retire grouped undo and aggregate transfers, keep native batching semantics, fix empty creation, and remove the duplicate tool.
8
+
9
+ The audit found three major differences. The first two were dropped from the required replacement contract; the third was fixed before removal:
10
+
11
+ 1. Native batches do not produce grouped undo receipts. `undo last` cannot restore an Apply checkpoint containing several files, file creation/deletion, moves, or binary files.
12
+ 2. Native text copy/move pairs ranges. Apply concatenates sources and broadcasts the result. JavaScript can build the same destination text, but that alone does not preserve source guards or a coherent multi-file move.
13
+ 3. Creating a new empty file with native `write` creates the file but reports a failed batch. A tested temporary-file composition avoids that failure and refuses overwriting an existing destination, but adds intermediate effects and is not a transaction.
14
+
15
+ Other differences are intentional or can be handled by composition. In particular, committing accepted edits after an ordinary script error is already the approved [native batching policy](native-codemode-batch-decision.md). It should not be changed silently to imitate Apply.
16
+
17
+ This audit does **not** require preserving every historical Apply behavior. The user chose the native contract and important practical scenarios, not full historical compatibility. The tables below keep the observed differences visible; the approved removal contract at the end says which ones still matter.
18
+
19
+ ## How to read the historical matrix
20
+
21
+ - **Covered**: an existing native mechanism covers the operation. This is not a claim of identical execution guarantees.
22
+ - **Compose**: ordinary tools plus JavaScript can express the operation; the stated caveats still apply.
23
+ - **Different**: both routes exist, but their observable behavior differs.
24
+ - **Gap**: there is no replacement for the stated guarantee in the current native API.
25
+ - **Unproven**: a proposed replacement has not been checked end to end.
26
+
27
+ The public inventory comes from [Apply's runtime bindings][apply-runtime], not just its prompt. `editorOpen`, `editorResolve`, and `editorApply` are private bridges. `__finishApplyScript` is an internal completion hook. There is no public `result()` helper bound by this runtime; Read/Search/Diff results are recorded automatically.
28
+
29
+ ## Public operations
30
+
31
+ | Apply capability | Native route | Status and limits | Evidence |
32
+ | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
33
+ | JavaScript conditions, loops, computed edits | Native Codemode JavaScript calling `tools.*` | Covered. Async tool calls replace synchronous Apply helpers. Do not call Apply from the replacement chain. | [Runtime][apply-runtime]; [native composition suite][composition-tests] |
34
+ | `read(request)` | `await tools.read(request)` | Covered for resource reading. Different result envelopes and clipping rules; see snapshots below. Read still takes a string path, so use a stored target string for a selection. | [Apply execution][apply-execution]; [Read targets][read-targets] |
35
+ | `search(request)` | `await tools.search(request)` | Covered: text, regex, AST, symbols, files, web, terminal and process providers. Use native structured matches/captures, not Apply's adapter fields. | [Structural Search suite][structural-tests]; [composition suite][composition-tests] |
36
+ | `diff({before, after})` | `await tools.diff({before, after})` | Covered by the same comparison implementation. It compares complete resolved text unless explicitly windowed. A diff is not an editable target. | [Diff core][diff-core]; [Diff tests][diff-tests] |
37
+ | `open(path)` / `open({path, views})` | Read a resource; keep its returned target and data | Compose, not a mutable editor handle. Full-file reading and checkpoint refresh differ; see snapshots below. | [Runtime][apply-runtime]; [Read targets][read-targets] |
38
+ | `file.source` | Result item's `source` | Covered. Keep source identity, not a display path or preview. | [Result store][result-store] |
39
+ | `file.content` | Read `lines`, preserving each `lineEnding`, and page as needed | Compose. A bounded Read is not complete file content. Bulk snapshot-equivalent reconstruction is unproven in this audit. | [Read targets][read-targets]; [Apply execution][apply-execution] |
40
+ | `file.lines` | Read structured `lines` | Covered for returned lines. Apply also has snapshot line offsets; native selection coordinates are absolute lines and UTF-16 columns. | [Runtime][apply-runtime]; [text Select][text-select] |
41
+ | `file.find(text)` | Strict literal Search on the original target | Compose. Quote and escape the literal, use `caseSensitive: true`, and check completeness. Ordinary unquoted Search can fall back to separate terms; that is not `find`. Arbitrary multiline literal parity is not newly proven here. | [Search parser][search-query]; [Runtime][apply-runtime] |
42
+ | `file.select(searchMatch)` | Pass a match/capture or its target to Search/Select/edit tools | Covered. No conversion to an Apply SelectionSet is needed. Stored native targets also reject stale, forged and expired inputs. | [Structural Search suite][structural-tests]; [composition suite][composition-tests] |
43
+ | `file.between(start, end, {inside, lines})` with literal markers | Select `between` with `extent: inside/around/lines` | Different. Native refuses an unmatched opening marker; Apply stops without an error. The native refusal is an approved guard. | [Runtime][apply-runtime]; [text Select suite][text-tests] |
44
+ | `file.between(selectionSet, selectionSet)` | Derive endpoints and Select `range` within a common original snapshot | Unproven as a general replacement. Native `between` itself accepts literal markers only. Do not manufacture authority from preview coordinates. | [Runtime][apply-runtime]; [text Select][text-select] |
45
+ | `file.slice(set, start, end)` | JavaScript `items.slice(start, end)`, passed as native inputs | Covered for choosing items, including negative array indexes. This is not Select `sliceText`, which slices text within every item. Preview clipping means the returned `items` array may omit target ranges; do not treat it as complete without checking. | [Runtime][apply-runtime]; [Select tool][select-tool] |
46
+ | `file.union(...sets)` | Combine native inputs; optionally Select `merge` | Different. Apply sorts, deduplicates and refuses overlapping ranges. Native merge explicitly joins overlaps. Add a checked overlap refusal if that old guard is required. | [Runtime][apply-runtime]; [geometry Select][geometry-select] |
47
+ | `file.within(candidates, scopes)` | Select `within` | Covered for non-empty ranges; different point membership. Native uses half-open scopes and excludes a point at a non-empty scope's end. Apply's numeric containment includes that point. | [geometry Select][geometry-select]; [geometry suite][geometry-tests] |
48
+ | `file.linesOf(selection)` | Select `linesOf` | Covered for deriving whole lines. It does not imply Apply's automatic linewise insertion/transfer behavior. | [text Select][text-select]; [text suite][text-tests] |
49
+ | `file.line(first, last)` | Select `lines` from a sufficiently broad original target | Covered, with strict containment. Partial Read authority is never silently widened. | [text suite][text-tests] |
50
+ | `file.start()` / `file.end()` | Select `position: before/after` from a whole-file target | Covered for character positions, including empty files. Unlike Apply's points, these do not carry a linewise insertion flag. | [text suite][text-tests]; paired check P8 |
51
+ | `file.before(selection)` / `file.after(selection)` | Select `position: before/after` | Covered for exact positions. Supply line separators deliberately when using character-point edits or transfers. | [text Select][text-select]; [element suite][element-tests] |
52
+ | SelectionSet `.text` / each selection's `.text` | Read stored target(s), then join returned content | Compose. Read whole-line context is not the exact selection text; clip it to the verified range. A preview is not a full value. Source-guarded bulk concatenation remains unproven. | [Read targets][read-targets]; [transfer core][transfer-core] |
53
+ | SelectionSet identity, generation, provenance | Session-owned result targets, strict snapshots, Select origins and syntax metadata | Covered with a different representation. Targets expire across session/reload and do not silently refresh. | [Result store][result-store]; [Select suites][select-tests] |
54
+ | `file.replace(selection, text)` / global `replace(selection, text)` | `tools.replace({path: selection, text})` | Covered for exact guarded ranges, sparse and multi-file selections. A bare exact string uses the native anchor contract, not a SelectionSet. | [composition suite][composition-tests] |
55
+ | `file.remove(selection)` / global `remove(selection)` | Structured `tools.delete({path: selection})` or empty replacement | Covered. Structured deletion keeps the file and exposes no editable removal target; empty replacement can expose the resulting position. | [composition suite][composition-tests]; [editing guide][editing-guide] |
56
+ | `file.insertBefore/insertAfter` / global variants | Line-based `insert` for anchors; Select position + replace/copy/move for exact character points | Compose. `insert` does not accept arbitrary structured inputs. The EOF CRLF blank-line case is paired and proven; general linewise transfer is not established by that one example. | Paired check P8; [transfer tests][apply-transaction-tests] |
57
+ | `copy(sourceSet, destinationSet)` | Structured native `copy` | Different: native pairs equal counts; Apply concatenates all source text and broadcasts it. | Paired check P4; [transfer core][transfer-core] |
58
+ | `move(sourceSet, destinationSet)` | Structured native `move` | Different for the same aggregation reason. JavaScript copy/replace then delete is not automatically one coherent guarded move. | [Apply transaction][apply-transaction]; [transfer core][transfer-core]; [transfer tests][apply-transaction-tests] |
59
+ | `createFile(path, content)` | `write`, or owned temporary file + non-overwriting whole-file copy | Different. Write overwrites; the tested composition protects an existing destination, including empty creation, but has intermediate effects. | Paired checks P2, P3, P5 |
60
+ | `deleteFile(path)` / `file.delete()` | `tools.delete({path})` with an ordinary path | Covered for regular-file deletion. Native action is a commit boundary, not a queued Apply operation. | [file operations][file-operations]; [composition suite][composition-tests] |
61
+ | `copyFile(path, target, {overwrite})` | Whole-file `tools.copy` with ordinary paths | Covered: same byte-preserving primitive, default refusal to overwrite, regular-file/symlink checks. Outer rollback/undo differs. | [file operations][file-operations]; [Apply transaction][apply-transaction] |
62
+ | `moveFile(path, target, {overwrite})` | Whole-file `tools.move` with ordinary paths | Covered with the same rollback/undo caveat. | [file operations][file-operations]; [composition suite][composition-tests] |
63
+ | Global `flush()` / normal script completion | `tools.flush({})` / native script completion | Covered as a checkpoint mechanism, not receipt or error parity. Inspect final per-call effects, not just pending child results. | Paired checks P1, P6; [native batch][native-batch] |
64
+ | `file.flush()` | Reorder staging, then global native flush | Different. No file-selective native flush exists. Apply skips selective flush when that file participates in a pending cross-file transfer. | Paired check P7; [Runtime][apply-runtime] |
65
+
66
+ ## Execution guarantees
67
+
68
+ | Guarantee | Apply | Native Codemode | Assessment |
69
+ | -------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
70
+ | Pending edits use original coordinates | Immutable document snapshot and SelectionSet generation | Original snapshots within a batch; pending mutation targets can start dependent work | Covered by existing native tests, with explicit boundary rules. |
71
+ | Ordinary uncaught script error | Does not auto-commit still-pending operations | Commits accepted surviving edits, then reports the error | Different, paired P1 and live. Native behavior was already approved. |
72
+ | Abort/deadline | No final pending checkpoint; already committed effects remain | Discards pending batch; already committed effects remain | Comparable intent. Existing native cancellation tests are evidence, not rerun in this audit. |
73
+ | Read/Search after pending edits | Reads snapshot/disk without implicitly committing queued edits | Another tool or pending-result dependency can commit the batch first | Different timing. Native reads see committed, not yet finally formatted text. |
74
+ | Explicit checkpoint | Global or eligible file-selective flush | Global flush plus automatic boundaries | Different, paired P7. Scheduling can express many workflows, not identical pending-state semantics. |
75
+ | Handle after checkpoint | Open document handles refresh; old SelectionSets become stale | Earlier target strings remain strict; obtain or use a confirmed fresh target | Different by design. No silent native refresh. |
76
+ | Independent operation failure | Can keep successful siblings; failures/unknown effects are recorded | Can keep successful siblings; structured domain errors must be inspected | Both are partial-success systems. Neither is all-script atomic. |
77
+ | Failed text write / transfer | Per-operation saved-path rollback plus dependency blocking when outcome is unknown | Shared multi-resource text-write rollback and guarded per-call effects | Source-level overlap, not full failure parity. Newly created paths and whole-file failures need separate adversarial proof. |
78
+ | Whole-file copy/move/delete rollback | Apply adds its saved-before operation journal | Shared file primitive reports an unknown effect if failure occurs after the operation starts | Gap in equivalent restoration guarantees; not newly fault-injected here. |
79
+ | Grouped undo | Checkpoint creates `APPLY#`; preflight guards then restore all touched paths, including binary/absent paths | Can consume an existing Apply receipt, but native flush cannot produce one. `undo last` is per-file text undo | Gap, paired receipt producer P6 plus source inspection. Calling Apply to make a receipt is not a replacement. |
80
+ | Repeated overlapping edits | Checkpoint checks original ranges and records failures | Batch checks original ranges and refuses conflicting changes | Covered in broad mechanism only. Ordering of multiple insertions at the exact same point was not paired here. |
81
+ | Stale source authority | Snapshot checks and selection generation | Expected content/existence, source identity, strict stored targets and completeness | Covered, not permission to replace a guarded source with an unguarded string reconstruction. |
82
+ | Sparse/multi-file selections | Apply SelectionSets belong to one document; global operations compose them | Native results retain separate source/ranges and origins | Covered; native does not match across gaps. |
83
+ | No-op / empty selections | Can record a warning without edits | Successful `not-applied` no-op for eligible text operations | Covered goal, different receipts. Whole-file write/undo do not widen an empty/partial selection. |
84
+ | Formatting and post-edit handlers | Final processing after surviving Apply work, with final snapshots/results | Once per surviving resource at native script end; flush does not format | Covered goal by existing native integration tests. Final processing can stale earlier targets. No formatter success claim for ignored live `.tmp` fixtures. |
85
+ | Script sandbox | Fresh Run guest, fixed private IDE bridge; no shell/import/Node access | Native QuickJS orchestration, registered tool pipeline; no Node filesystem API in guest | Different implementation. Test ordinary tool composition, not a shell script that sidesteps guards. |
86
+ | Concurrency | Guest calls use an ordered host queue; file reservations protect effects | Independent disjoint calls can run concurrently; await dependent same-source calls | Covered with a richer native model, not identical scheduling. |
87
+ | Output and TUI | Recorded read results, operation outcomes, refreshed snapshots and checkpoint receipts | Native child calls, pending receipts, final batch effects and formatting contributions | Covered presentation goal, different envelopes. Live viewport verified ordinary-error effects, not every historical Apply output shape. |
88
+ | Large inputs/outputs | Full opened snapshots, bridge/output budgets and overflow artifacts | Bounded Read/item previews; stored targets can retain more ranges than the preview | Unproven for arbitrary bulk `.content`/`.text` replacement. Do not call clipped data complete. |
89
+
90
+ ### Snapshot-safe composition rules
91
+
92
+ A matching final string is not enough to establish parity:
93
+
94
+ - Check `status`, `effect`, completeness and the parent final batch outcome. Native domain errors can resolve instead of rejecting the JavaScript promise.
95
+ - Use a returned stored target or a filtered array of complete returned items. Read context and preview text do not create new editing authority.
96
+ - Retain original source/snapshot guards when reconstructing text. Replacing only the destination does not check that the source still matches the text you copied.
97
+ - Read's default target is its returned window. A whole-file target can be obtained through Select on the file, but any paged reconstruction must stay tied to that target and preserve line endings. This bulk composition was not executed here.
98
+ - For exact `find`, escape quotes/backslashes inside a quoted Search term rather than relying on JSON's `\n` escape decoding. Check arbitrary multiline cases before replacing Apply's literal scanning.
99
+ - A sequence of successful calls is not an atomic transaction. Compensation code can itself fail and does not replace a preflight-guarded grouped undo receipt.
100
+
101
+ ## Targeted evidence from this audit
102
+
103
+ All checks are in [apply-native-parity.integration.test.ts][paired-tests]. Apply is the reference call; native replacement chains do not invoke Apply. No production code was changed.
104
+
105
+ | ID | Check | Observed result |
106
+ | --- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
107
+ | P1 | Pending replacement, then ordinary throw | Apply file stays `old`; native file becomes `new`. Both report the script error. |
108
+ | P2 | Create an already existing file | Apply refuses and preserves it. Native write replaces it. |
109
+ | P3 | Create a missing empty file | Apply succeeds. Native creates the empty file, but its batch reports `Text changes must change the document.` This is a real observed bug, not the desired contract. |
110
+ | P4 | Two source fragments copied to two destination ranges | Apply produces `ab ab`; native produces `a b`. Protected CRLF neighbors remain unchanged. |
111
+ | P5 | Create-only composition using an owned temporary file and whole-file copy | Existing destination is refused and preserved. A nonempty pending write followed by replacement through its returned target can prepare an empty source; copy creates the empty destination, then cleanup removes the owned temporary file. |
112
+ | P6 | Commit two edited files | Apply publishes a grouped receipt. Native flush confirms two operations but has no `transaction` or `transactions`. |
113
+ | P7 | Stage two files, flush selectively/globally, then throw | Apply commits only the selected file; native global flush commits both. |
114
+ | P8 | Blank-line insertion after an unterminated CRLF file | Both produce exact `😀 first\r\nlast\r\n\r\nNEW`. This proves this composition, not every linewise transfer. |
115
+
116
+ **All eight checks passed across focused runs, not in one uninterrupted eight-test run.** Passing P3 means the audit reproduced the bug; it does not mean empty native creation works correctly.
117
+
118
+ The run history is intentionally kept honest:
119
+
120
+ - First six-check run: no scenario could start because `node-pty` had not been built after the local install with scripts disabled. Building that dependency fixed the environment, without repository source changes.
121
+ - Retry: five passed; one assertion used the wrong Apply result envelope. Correcting it proved P6 in isolation.
122
+ - New creation workaround exposed P3. The first workaround used a literal selector before a pending file creation had committed; the replacement failed and the file contained `seed`. The final version checks child statuses and replaces through the returned pending write target; P5 then passed.
123
+ - Only targeted serial runs were used: `env -u PI_INTEGRATION_TEST_RUNNER pnpm exec vitest run --config vitest.integration.config.mjs --maxWorkers=1 --no-file-parallelism`. No shared runner pool, shards, or full-suite rerun.
124
+
125
+ Run logs remain in `.tmp/lpt-403-paired-integration.log`, `.tmp/lpt-403-paired-integration-retry.log`, `.tmp/lpt-403-paired-followup.log`, `.tmp/lpt-403-create-followup.log` and `.tmp/lpt-403-create-composition-retry.log`. Real-Pi artifacts remain under `.tmp/test-runs/`. These local logs support this audit; the reusable checks and this matrix belong in Git.
126
+
127
+ Live checks separately reproduced P1 and native empty creation. Read-only byte checks confirmed P1's exact CRLF files. Actual Herdr pane `w3HS:p1`, revision 40, showed both script failures and the native `new` diff. No model-facing text was used as a substitute for that viewport check.
128
+
129
+ The existing suites linked above are source evidence and earlier contract coverage. They were **not** all rerun for LPT-403.
130
+
131
+ ## Approved removal contract
132
+
133
+ The user reviewed the matrix and chose:
134
+
135
+ 1. **Drop grouped checkpoint undo.** Do not add a native grouped receipt producer just to preserve Apply. Existing per-file text undo is a separate capability.
136
+ 2. **Keep equal-pair copy/move.** Concatenating sources and broadcasting to all destinations is not a required native operation.
137
+ 3. **Fix empty-file creation separately before removing Apply.** The temporary-file composition is evidence of a workaround, not the chosen permanent API.
138
+ 4. **Keep the native error/checkpoint/target model.** Ordinary errors keep accepted surviving edits; checkpoints are global/automatic; targets never silently refresh. Remove old Apply promises from removal-facing docs and examples.
139
+ 5. **Check the native contract and important practical scenarios.** Do not chase full compatibility with every historical helper or convenience rule. The unproven areas above remain honest limitations, not automatically mandatory new features.
140
+
141
+ ### Removal implementation
142
+
143
+ - Fixed empty native creation. The standalone and Codemode regressions check actual zero-byte content, truthful applied effects and a usable point target. See [empty creation tests](https://github.com/alexshpunt/pi-agent-ide/blob/5c318fd2081a3bc4e187efb06c7e9eeae4a22317/tests/integration/native-empty-write.integration.test.ts).
144
+ - Removed Apply registration, runtime, grouped undo receipts, private plugin APIs, preview settings and dependencies. Ordinary editing, Diff, Git change undo and per-file last undo remain.
145
+ - Migrated practical shared integration scenarios to native tools. The removal checks cover post-edit processing, scoped semantic/AST operations, module settings, user hooks, CRLF insertion, native result schemas, discovery and hidden-tool boundaries, resource scheduling and progressive guides.
146
+ - Kept the native contract: strict snapshots, equal-pair transfers, global checkpoints and final processing once per surviving resource. Ordinary errors keep accepted edits; cancellation discards only pending work. There is no grouped rollback or silent syntax repair.
147
+
148
+ Historical audit checks below were not rerun after removal: they deliberately depend on the old Apply runtime, and P3 reproduces the old empty-write defect. Their source stays in Git history. The original serial removal check passed 58 contracts and failed one outdated hook expectation; targeted retries verify the corrected native Read/error and blocked-commit behavior. Final live and check evidence is recorded in the task Workpad. No full suite was run for this removal.
149
+
150
+ Full historical equivalence remains false by design. That is not the accepted product requirement.
151
+
152
+ [apply-runtime]: https://github.com/alexshpunt/pi-agent-ide/blob/c4ccbf9e8620976b5130e6f351f2678ce1d1a067/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts
153
+ [apply-execution]: https://github.com/alexshpunt/pi-agent-ide/blob/c4ccbf9e8620976b5130e6f351f2678ce1d1a067/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts
154
+ [apply-transaction]: https://github.com/alexshpunt/pi-agent-ide/blob/c4ccbf9e8620976b5130e6f351f2678ce1d1a067/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts
155
+ [apply-transaction-tests]: https://github.com/alexshpunt/pi-agent-ide/blob/c4ccbf9e8620976b5130e6f351f2678ce1d1a067/src/extensions/pi-agent-text-editor/tests/core/apply-transaction.test.ts
156
+ [native-batch]: ../../src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts
157
+ [file-operations]: ../../src/extensions/pi-agent-text-editor/src/core/file-operations.ts
158
+ [transfer-core]: ../../src/extensions/pi-agent-text-editor/src/core/result-transfer.ts
159
+ [read-targets]: ../../src/extensions/pi-agent-read/src/core/tools/read/result-target.ts
160
+ [result-store]: ../../packages/pi-agent-resource/src/result-targets.ts
161
+ [select-tool]: ../../src/plugins/pi-agent-ide-ast/src/tool-select.ts
162
+ [text-select]: ../../src/plugins/pi-agent-ide-ast/src/text-selection.ts
163
+ [geometry-select]: ../../src/plugins/pi-agent-ide-ast/src/geometry-selection.ts
164
+ [search-query]: ../../src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts
165
+ [diff-core]: ../../src/extensions/pi-agent-text-editor/src/core/diff-tool.ts
166
+ [diff-tests]: ../../src/extensions/pi-agent-text-editor/tests/core/diff-tool.test.ts
167
+ [paired-tests]: https://github.com/alexshpunt/pi-agent-ide/blob/8336931d17056149fe1d4fd3f0340061533438c9/tests/integration/apply-native-parity.integration.test.ts
168
+ [composition-tests]: ../../tests/integration/native-tool-composition.integration.test.ts
169
+ [structural-tests]: ../../tests/integration/native-structural-search.integration.test.ts
170
+ [select-tests]: ../../tests/integration/native-select.integration.test.ts
171
+ [text-tests]: ../../tests/integration/native-text-select.integration.test.ts
172
+ [geometry-tests]: ../../tests/integration/native-geometry-select.integration.test.ts
173
+ [element-tests]: ../../tests/integration/native-element-select.integration.test.ts
174
+ [editing-guide]: ../agent-guides/editing.md
@@ -1,5 +1,7 @@
1
1
  # Apply and Read latency research
2
2
 
3
+ This is historical research. Apply was removed in LPT-403; source paths below refer to [the last pre-removal revision](https://github.com/alexshpunt/pi-agent-ide/tree/c4ccbf9e8620976b5130e6f351f2678ce1d1a067).
4
+
3
5
  This report records the LPT-238 investigation. It describes the current code on `develop` at `bf7f36db` and the retained benchmark evidence available on 17 September 2026. No product behavior was changed.
4
6
 
5
7
  ## Summary