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.
- package/CHANGELOG.md +38 -0
- package/README.md +2 -2
- package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
- package/dist/{chunk-QEJGED4V.js → chunk-3HYXQ4YA.js} +1 -1
- package/dist/chunk-3JO7QFIL.js +1 -0
- package/dist/{chunk-5J43L2RL.js → chunk-4NIFBFFR.js} +1 -1
- package/dist/{chunk-BSICWXMH.js → chunk-64M3SQPG.js} +1 -1
- package/dist/{chunk-3BBJZSMS.js → chunk-7LD2OQH3.js} +1 -1
- package/dist/chunk-7LZKOHH2.js +1 -0
- package/dist/chunk-AJRIASPQ.js +2 -0
- package/dist/chunk-EAZGN5ND.js +7 -0
- package/dist/{chunk-GIRAEVUJ.js → chunk-F5YZG77W.js} +1 -1
- package/dist/chunk-FK42RSF4.js +1 -0
- package/dist/{chunk-WJTHY6AG.js → chunk-FXNKMNSJ.js} +1 -1
- package/dist/chunk-GBLKIB6O.js +2 -0
- package/dist/{chunk-KUPHNMUK.js → chunk-KBP3QUDT.js} +1 -1
- package/dist/{chunk-VBICI5YA.js → chunk-KR36BT5E.js} +1 -1
- package/dist/chunk-OE7QVAI2.js +5 -0
- package/dist/chunk-PNU3E7IO.js +3 -0
- package/dist/chunk-PS2B6THP.js +3 -0
- package/dist/{chunk-HPUAIWIH.js → chunk-PYPPV2F5.js} +1 -1
- package/dist/{chunk-FUG2TEKI.js → chunk-QFTBY67N.js} +2 -2
- package/dist/chunk-S5LXX32D.js +28 -0
- package/dist/chunk-SQKAXYIR.js +2 -0
- package/dist/chunk-VCGNVTXQ.js +1 -0
- package/dist/chunk-XYS4FSCC.js +12 -0
- package/dist/{chunk-FBOW7XOV.js → chunk-YRF7OATP.js} +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +1 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +13 -11
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -13
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +3 -6
- package/dist/entry-51.js +11 -9
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +0 -1
- package/dist/entry-62.js +1 -0
- package/dist/entry-63.js +0 -1
- package/dist/entry-64.js +1 -0
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +0 -1
- package/dist/entry-72.js +1 -0
- package/dist/entry-73.js +0 -1
- package/dist/entry-74.js +1 -0
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +67 -1
- package/dist/entry-78.js +14 -325
- package/dist/entry-79.js +2 -18
- package/dist/entry-80.js +1 -2
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +5 -1
- package/dist/entry-83.js +3 -5
- package/dist/entry-84.js +1 -3
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +5 -5
- package/docs/agent-guides/editing.md +20 -4
- package/docs/agent-guides/git-changes.md +1 -1
- package/docs/agent-guides/read-resources.md +9 -1
- package/docs/agent-guides/search-code.md +38 -1
- package/docs/agent-guides/select-code.md +194 -0
- package/docs/configuration.md +12 -17
- package/docs/development.md +2 -1
- package/docs/releases.md +1 -1
- package/docs/research/apply-native-capability-matrix.md +174 -0
- package/docs/research/apply-read-latency.md +2 -0
- package/docs/research/lpt-393-fuzzy-results/file.json +152 -0
- package/docs/research/lpt-393-fuzzy-results/repo.json +122 -0
- package/docs/research/lpt-393-search-fuzzy-fallback.md +97 -0
- package/docs/research/native-codemode-batch-decision.md +2 -0
- package/docs/research/native-codemode-batching.md +1 -1
- package/docs/structured-results.md +32 -5
- package/docs/tools.md +6 -2
- package/docs/user-hooks.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +15 -10
- package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -2
- package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +107 -21
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/node_modules/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/node_modules/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/node_modules/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +251 -0
- package/node_modules/pi-agent-ide-changes/index.ts +2 -18
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/index.ts +2 -2
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +88 -45
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/node_modules/pi-agent-read/src/api/tools/read.ts +4 -0
- package/node_modules/pi-agent-read/src/core/extension.ts +11 -0
- package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +2 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +8 -1
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +10 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +233 -0
- package/node_modules/pi-agent-search/package.json +5 -5
- package/node_modules/pi-agent-search/src/api/fuzzy.ts +208 -0
- package/node_modules/pi-agent-search/src/api/presentation.ts +68 -0
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +9 -3
- package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
- package/node_modules/pi-agent-search/src/api/search.ts +28 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +69 -14
- package/node_modules/pi-agent-search/src/core/extension.ts +56 -16
- package/node_modules/pi-agent-search/src/core/search-core.ts +9 -1
- package/node_modules/pi-agent-search-text/index.ts +3 -1
- package/node_modules/pi-agent-search-text/package.json +7 -6
- package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +164 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +161 -30
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -17
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +89 -292
- package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +96 -11
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/index.ts +0 -5
- package/node_modules/pi-agent-text-editor/package.json +26 -31
- package/node_modules/pi-agent-text-editor/runtime/entry-77.js +1 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +12 -2
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +199 -19
- package/node_modules/pi-agent-text-editor/src/core/result-input.ts +22 -0
- package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +109 -11
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +211 -223
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +1 -72
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/src/index.ts +7 -0
- package/node_modules/pi-agent-tool-ui/src/result-panel.ts +298 -0
- package/node_modules/pi-agent-web/index.ts +3 -0
- package/node_modules/pi-agent-web/package.json +8 -8
- package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-web/src/search.ts +111 -2
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/package.json +35 -36
- package/src/composite/module-labels.ts +1 -1
- package/src/composite/preferences.ts +0 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +3 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +111 -2
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +4 -0
- package/src/extensions/pi-agent-read/src/core/extension.ts +11 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +2 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +8 -1
- package/src/extensions/pi-agent-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +164 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +161 -30
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -17
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +89 -292
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +77 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +96 -11
- package/src/extensions/pi-agent-search/src/api/fuzzy.ts +208 -0
- package/src/extensions/pi-agent-search/src/api/presentation.ts +68 -0
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +9 -3
- package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +28 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +69 -14
- package/src/extensions/pi-agent-search/src/core/extension.ts +56 -16
- package/src/extensions/pi-agent-search/src/core/search-core.ts +9 -1
- package/src/extensions/pi-agent-text-editor/index.ts +0 -5
- package/src/extensions/pi-agent-text-editor/package.json +26 -31
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +1 -72
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +12 -2
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +199 -19
- package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +22 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +109 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +211 -223
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/src/pi-agent-ide.ts +0 -6
- package/src/plugins/pi-agent-ide-ast/package.json +15 -10
- package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -2
- package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +107 -21
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/src/plugins/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +251 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +2 -18
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/index.ts +2 -2
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +88 -45
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +10 -36
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +1 -1
- package/src/plugins/pi-agent-ide-vision/index.ts +19 -0
- package/dist/chunk-2P2OGO3G.js +0 -2
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/chunk-7AVXUV4A.js +0 -7
- package/dist/chunk-7WCZOO5I.js +0 -1
- package/dist/chunk-BAYETTZZ.js +0 -16
- package/dist/chunk-BVK5A7ED.js +0 -28
- package/dist/chunk-F7NVAC4Q.js +0 -0
- package/dist/chunk-FZBCKIJJ.js +0 -1
- package/dist/chunk-I5JLCFUX.js +0 -1
- package/dist/chunk-MIZAFRDR.js +0 -1
- package/dist/chunk-PJPA5EEE.js +0 -2
- package/dist/chunk-PXWDDBBC.js +0 -0
- package/dist/chunk-TQZBVOTT.js +0 -5
- package/dist/chunk-VWW3RLUX.js +0 -12
- package/dist/chunk-YHUTTZC6.js +0 -2
- package/dist/chunk-ZODCBFBL.js +0 -2
- package/dist/entry-87.js +0 -1
- package/docs/agent-guides/apply.md +0 -333
- package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
- package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
- package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +0 -276
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
- package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +0 -137
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +0 -1
- package/node_modules/pi-agent-web-text/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
- package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
- package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +0 -276
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
- package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +0 -137
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-81.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-83.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
- /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
- /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
- /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
- /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
package/dist/chunk-PJPA5EEE.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as R}from"./chunk-7WCZOO5I.js";import{t as y,u as T}from"./chunk-ZPT5D4VP.js";import{a as b}from"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import O from"node:path";import{keyText as D}from"@earendil-works/pi-coding-agent";import{Text as W,truncateToWidth as f,visibleWidth as u,wrapTextWithAnsi as E}from"@earendil-works/pi-tui";function $(e){return e.replaceAll("\u27E6","").replaceAll("\u27E7","")}l($,"sourceText");function U(e,t){let{files:r,...n}=e,o=$(t);return{...n,storedFiles:r.map(({lines:s,...a})=>({...a,lines:s.map(i=>{let d=[i.lineNumber,y(i.text,o),i.ranges];return i.logicalMatchIds===void 0?d:[...d,i.logicalMatchIds]})}))}}l(U,"compactSearchDetails");function C(e,t){if("files"in e)return e;let{storedFiles:r,...n}=e,o=$(t);return{...n,files:r.map(({lines:s,...a})=>({...a,lines:s.map(([i,d,c,m])=>({lineNumber:i,text:T(d,o),ranges:c,matchCount:c.length,...m===void 0?{}:{logicalMatchIds:m}}))}))}}l(C,"restoreSearchDetails");var M=new WeakMap,g=12,L=2048,k=256,P={".ts":{label:"TS",color:"accent"},".tsx":{label:"TX",color:"accent"},".js":{label:"JS",color:"warning"},".jsx":{label:"JX",color:"warning"},".json":{label:"{}",color:"warning"},".md":{label:"MD",color:"mdHeading"},".py":{label:"PY",color:"accent"},".rs":{label:"RS",color:"accent"},".go":{label:"GO",color:"accent"},".css":{label:"CS",color:"accent"},".html":{label:"<>",color:"accent"}};function oe(e,t,r,n){if(typeof e.details=="object"){let a=M.get(e.details);a===void 0&&(a=C(e.details,e.content.flatMap(i=>i.type==="text"?[i.text]:[]).join(`
|
|
2
|
-
`)),M.set(e.details,a)),e={...e,details:a}}if(t.isPartial||n.isError||!R(e.details)){let a=e.content[0],i=a?.type==="text"?a.text:"",d=n.isError?"error":t.isPartial?"dim":"toolOutput";return new W(r.fg(d,i),0,0)}let s=(n.lastComponent instanceof S?n.lastComponent:void 0)??new S(e.details,r,t.expanded);return s.update(e.details,r,t.expanded),s}l(oe,"renderSearchResult");var S=class{constructor(t,r,n){this.details=t;this.theme=r;this.expanded=n}static{l(this,"SearchResultPanel")}cached;update(t,r,n){this.details===t&&this.theme===r&&this.expanded===n||(this.details=t,this.theme=r,this.expanded=n,this.invalidate())}render(t){if(this.cached?.width===t)return this.cached.lines;if(t<4){let c=[f(A(this.details),Math.max(1,t))];return this.cached={width:t,lines:c},c}let r=t-2,n=B(this.details,this.expanded),o=J(this.details.files),s=n.flatMap(c=>I(c,r,o,this.theme)),a=j(s,this.expanded,r,this.theme),i=[G(this.details,r,this.theme),...a];i.push(this.theme.fg("borderMuted",`\u2570${"\u2500".repeat(r)}\u256F`));let d=i.map(c=>f(c,t));return this.cached={width:t,lines:d},d}invalidate(){this.cached=void 0}};function B(e,t){let r=e.files.length===0?[{kind:"empty"}]:e.files.flatMap(a=>[{kind:"file",file:a},...a.uniqueLineCount===void 0?a.lines.map(i=>({kind:"line",file:a,line:i})):[{kind:"summary",text:`${String(a.uniqueLineCount)} unique line texts \xB7 search this path with a narrower query`},...(a.groups??[]).map(i=>({kind:"summary",text:`\xD7${String(i.matchCount)} ${i.text}`}))]]);if(t||r.length<=g)return r;let n=r.slice(0,g-1);for(;n.at(-1)?.kind==="file";)n.pop();let o=new Set(n.flatMap(a=>a.kind==="line"?a.line.logicalMatchIds??[]:[])),s=o.size>0?o.size:n.reduce((a,i)=>a+(i.kind==="line"?i.line.matchCount:0),0);return[...n,{kind:"omitted",matches:Math.max(0,e.matchCount-s)}]}l(B,"searchViewport");function j(e,t,r,n){if(t||e.length<=g)return e;let o=`${D("app.tools.expand")} to expand`,s=h(n.fg("dim",` \u2026 output truncated \xB7 ${o}`),r,n);return[...e.slice(0,g-1),s]}l(j,"compactRenderedRows");function I(e,t,r,n){if(e.kind==="file")return[h(N(e.file,t,n),t,n,!0)];if(e.kind==="line")return H(e.line,t,r,n);if(e.kind==="summary")return[h(n.fg("dim",` ${p(e.text.length>L?`${e.text.slice(0,k)}\u2026`:e.text)}`),t,n)];if(e.kind==="omitted"){let o=`${D("app.tools.expand")} to expand`;return[h(n.fg("dim",` \u2026 ${String(e.matches)} more ${x(e.matches,"match","matches")} \xB7 ${o}`),t,n)]}return[h(n.fg("dim"," No matches found"),t,n)]}l(I,"renderPanelRow");function N(e,t,r){let n=V(e.path,r),o=r.fg("accent",r.bold(String(e.matchCount))),s=u(n)+u(o)+4,a=Math.max(1,t-s),i=z(e.path,a),d=w(i,e.link,r),c=` ${n} ${d}`,m=" ".repeat(Math.max(1,t-u(c)-u(o)-1));return f(`${c}${m}${o} `,t)}l(N,"renderFileHeader");function H(e,t,r,n){let o=String(e.lineNumber).padStart(r),s=` ${n.fg("dim",o)} ${n.fg("borderMuted","\u2502")} `,a=Math.max(1,t-u(s)-1),i=_(e),d=E(q(i,n),a),c=" ".repeat(u(s)),m=d.map((F,v)=>h(`${v===0?s:c}${F}`,t,n));return i!==e&&m.push(h(n.fg("dim"," \u2026 line shortened \xB7 read file for full text"),t,n)),m}l(H,"renderMatchLine");function _(e){if(e.text.length<=L)return e;let t=Math.max(0,(e.ranges[0]?.from??0)-64),r=Math.min(e.text.length,t+k),n=t>0?"\u2026":"";return{...e,text:`${n}${e.text.slice(t,r)}${r<e.text.length?"\u2026":""}`,ranges:e.ranges.filter(o=>o.from<r&&o.to>t).map(o=>({from:Math.max(o.from,t)-t+n.length,to:Math.min(o.to,r)-t+n.length}))}}l(_,"previewMatchLine");function q(e,t){let r="",n=0;for(let o of e.ranges){o.from>n&&(r+=t.fg("toolOutput",p(e.text.slice(n,o.from))));let s=p(e.text.slice(o.from,o.to));r+=t.bg("selectedBg",t.fg("accent",t.bold(s))),n=o.to}return n<e.text.length&&(r+=t.fg("toolOutput",p(e.text.slice(n)))),r}l(q,"renderHighlightedLine");function G(e,t,r){let n=l(a=>r.fg("borderMuted",a),"frame"),o=f(` ${A(e)} `,Math.max(0,t-1),""),s="\u2500".repeat(Math.max(0,t-u(o)-1));return`${n("\u256D\u2500")}${r.fg("accent",o)}${n(`${s}\u256E`)}`}l(G,"renderTopBorder");function A(e){return e.matchCount===0?"No matches":`${`${String(e.matchCount)}${e.complete?"":"+"}`} ${x(e.matchCount,"match","matches")} in ${String(e.fileCount)} ${x(e.fileCount,"file","files")}`}l(A,"searchSummary");function h(e,t,r,n=!1){let o=f(e,t),s=`${o}${" ".repeat(Math.max(0,t-u(o)))}`,a=n?r.bg("selectedBg",s):s,i=r.fg("borderMuted","\u2502");return`${i}${a}${i}`}l(h,"framed");function V(e,t){let r=O.extname(e).toLowerCase(),n=P[r]??{label:"\u25C7 ",color:r.length===0?"muted":"accent"};return t.fg(n.color,t.bold(n.label))}l(V,"fileBadge");function w(e,t,r){let n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),o=n===-1?"":e.slice(0,n+1),s=n===-1?e:e.slice(n+1),a=r.fg("muted",o)+r.underline(r.fg("accent",s));return t.includes("\x07")||t.includes("\x1B")?a:`\x1B]8;;${t}\x07${a}\x1B]8;;\x07`}l(w,"fileLink");function z(e,t){return u(e)<=t?e:t<=1?"\u2026":`\u2026${e.slice(-(t-1))}`}l(z,"truncatePath");function p(e){let t="";for(let r of e){if(r===" "){t+=" ".repeat(4);continue}let n=b(r.codePointAt(0));t+=n<32||n===127?"\uFFFD":r}return t}l(p,"safeText");function J(e){let t=1;for(let r of e)for(let n of r.lines)t=Math.max(t,n.lineNumber);return Math.max(3,String(t).length)}l(J,"maximumLineNumberWidth");function x(e,t,r){return e===1?t:r}l(x,"plural");export{U as a,oe as b,S as c};
|
package/dist/chunk-PXWDDBBC.js
DELETED
|
File without changes
|
package/dist/chunk-TQZBVOTT.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{a as _}from"./chunk-M5IVSCR2.js";import{e as q,f as $}from"./chunk-T7I2VX3J.js";import{a as U}from"./chunk-6CZO43OH.js";import{a as O,b as T}from"./chunk-OBNING2A.js";import{a as W}from"./chunk-ZTYWHL2F.js";import{a as k,b as L}from"./chunk-7UGNGK7Y.js";import{a as c}from"./chunk-EI7MMDWY.js";import{execFile as ne}from"node:child_process";import te from"node:os";import{promisify as re}from"node:util";import{createCanvas as z,loadImage as oe}from"@napi-rs/canvas";var w=re(ne),I=20*1024*1024,F={durationSeconds:2,intervalSeconds:.5,scale:.5},H=new Set;function j(e){let n=R({mode:"sequence",durationSeconds:Number(e.durationSeconds??2),intervalSeconds:Number(e.intervalSeconds??.5),scale:Number(e.scale??.5)});F={durationSeconds:n.durationSeconds,intervalSeconds:n.intervalSeconds,scale:n.scale},H=new Set((e.allowedExecutables??"").split(",").map(r=>r.trim().toLowerCase()).filter(Boolean))}c(j,"configureVision");function y(){return F}c(y,"getVisionDefaults");function G(e){let n=e.includes("\\")?e.slice(e.lastIndexOf("\\")+1):e,r=n.trim().split(/\s+/u)[0]??"",t=r.slice(r.lastIndexOf("/")+1);return H.has((e.includes("\\")?n:t).toLowerCase())}c(G,"isExecutableAllowed");function J(e,n){let r=e?.filter(i=>/^(?:image|sequence)(?::|$)/u.test(i))??[];if(r.length===0)return;if(r.length>1)throw new Error("Use only one image or sequence view");let t=r[0],s=t.indexOf(":"),a=t.slice(0,s<0?void 0:s),o={};if(s>=0&&ie(t.slice(s+1),o),a==="image"&&(o.duration!==void 0||o.interval!==void 0))throw new Error("duration and interval are supported only by the sequence view");return R({mode:a,durationSeconds:o.duration??n.durationSeconds,intervalSeconds:o.interval??n.intervalSeconds,scale:o.scale??n.scale,...o.region===void 0?{}:{region:o.region}})}c(J,"parseVisionView");function ie(e,n){if(e.length===0)throw new Error("View parameters cannot be empty");let r=e.split(",");for(let t=0;t<r.length;t+=1){let s=r[t],a=s.indexOf("=");if(a<=0)throw new Error(`Invalid view parameter ${s}`);let o=s.slice(0,a),i=s.slice(a+1);if(o==="region"){let l=[i,r[t+1],r[t+2],r[t+3]].map(Number);if(l.some(m=>!Number.isFinite(m)))throw new Error("region requires x,y,width,height values");n.region={x:l[0],y:l[1],width:l[2],height:l[3]},t+=3;continue}if(o!=="duration"&&o!=="interval"&&o!=="scale")throw new Error(`Unknown view parameter ${o}`);let d=Number(i);if(!Number.isFinite(d))throw new Error(`View parameter ${o} must be a number`);if(n[o]!==void 0)throw new Error(`Duplicate view parameter ${o}`);n[o]=d}}c(ie,"parseViewParameters");function X(e){if(!e.startsWith("display:"))return;if(e==="display:")return 0;let n=/^display:#(\d+)$/u.exec(e);if(n===null)throw new Error("Display sources use display: or display:#N with a zero-based index");let r=Number(n[1]);if(!Number.isSafeInteger(r))throw new Error("Display sources use display: or display:#N with a zero-based index");return r}c(X,"parseDisplaySource");async function E(e){let n=new Map(e.list().flatMap(s=>s.pid===void 0?[]:[[s.pid,s]]));if(process.platform!=="linux"&&process.platform!=="darwin")return[...n].map(([s,a])=>({pid:s,command:a.description,owned:!0,source:a.source,host:"local"}));let{stdout:r}=await w("ps",["-eo","pid=,ppid=,lstart=,args="],{maxBuffer:4*1024*1024}),t=r.split(`
|
|
2
|
-
`).flatMap(s=>{let a=/^\s*(\d+)\s+(\d+)\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+(.*)$/u.exec(s);if(a===null)return[];let o=Number(a[1]),i=n.get(o);return[{pid:o,parentPid:Number(a[2]),started:a[3],command:a[4]??"",owned:i!==void 0,host:"local",...i===void 0?{}:{source:i.source}}]});return x()?[...t,...await se()]:t}c(E,"listProcesses");async function se(){try{let{stdout:e}=await w("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-Command","Get-Process | Select-Object Id,ProcessName,Path,StartTime | ConvertTo-Json -Compress"],{maxBuffer:4194304}),n=JSON.parse(e);return(Array.isArray(n)?n:[n]).flatMap(t=>{if(typeof t!="object"||t===null||!("Id"in t)||typeof t.Id!="number")return[];let s="ProcessName"in t&&typeof t.ProcessName=="string"?t.ProcessName:"Windows process",a="Path"in t&&typeof t.Path=="string"?t.Path:void 0,o="StartTime"in t&&typeof t.StartTime=="string"?t.StartTime:void 0;return[{pid:t.Id,command:a??s,owned:!1,host:"windows",...o===void 0?{}:{started:o}}]})}catch{return[]}}c(se,"listWindowsProcesses");async function A(e,n){if(!Number.isSafeInteger(e)||e<=0)throw new Error("Process PID must be a positive integer");let r=(await E(n)).find(t=>t.pid===e);if(r===void 0)throw new Error(`Process ${e} is not running`);return r}c(A,"readProcess");function R(e){let n=e.scale??1;if(!(n>0&&n<=1))throw new Error("Image scale must be greater than 0 and at most 1");let r=e.durationSeconds??0,t=e.intervalSeconds??1;if(e.mode==="sequence"){if(!(r>0&&r<=10))throw new Error("Sequence duration must be greater than 0 and at most 10 seconds");if(!(t>0))throw new Error("Sequence interval must be greater than 0 seconds");if(Math.floor(r/t)+1>20)throw new Error("Sequence capture is limited to 20 frames")}if(e.region!==void 0){let{x:s,y:a,width:o,height:i}=e.region;if(s<0||a<0||o<=0||i<=0||s+o>1||a+i>1)throw new Error("Image region x,y,width,height must fit within normalized bounds 0..1")}if(e.cellIndex!==void 0&&e.cellSize===void 0)throw new Error("Image offset requires limit to set the square grid cell size");if(e.cellSize!==void 0&&(!Number.isSafeInteger(e.cellSize)||e.cellSize<=0))throw new Error("Image limit must be a positive integer pixel size");if(e.cellIndex!==void 0&&(!Number.isSafeInteger(e.cellIndex)||e.cellIndex<0))throw new Error("Image offset must be a zero-based cell index");return e}c(R,"validateVisionOptions");async function b(e,n,r){let t=R(n),s=t.mode==="image"?1:Math.floor(t.durationSeconds/t.intervalSeconds)+1,a=[],o=0;for(let i=0;i<s;i+=1){r?.throwIfAborted(),i>0&&await me(t.intervalSeconds*1e3,r);let d=await e();if(o+=d.byteLength,o>I)throw new Error("Captured images exceed the 20MB aggregate limit");for(let l of await ae(d,t))a.push({type:"image",data:Buffer.from(l).toString("base64"),mimeType:"image/png"})}return a}c(b,"captureImages");async function ae(e,n){let r=await oe(e),t=n.region??{x:0,y:0,width:1,height:1},s=Math.round(t.x*r.width),a=Math.round(t.y*r.height),o=Math.max(1,Math.round(t.width*r.width)),i=Math.max(1,Math.round(t.height*r.height)),d=n.scale??1,l=Math.max(1,Math.round(o*d)),m=Math.max(1,Math.round(i*d)),p=z(l,m);if(p.getContext("2d").drawImage(r,s,a,o,i,0,0,l,m),n.cellSize===void 0)return[await p.encode("png")];let u=Math.ceil(l/n.cellSize),f=Math.ceil(m/n.cellSize),h=n.cellIndex??0;if(h>=u*f)throw new Error(`Image cell offset ${h} exceeds the ${u}x${f} grid`);let Z=h%u,ee=Math.floor(h/u),C=Z*n.cellSize,M=ee*n.cellSize,P=Math.min(n.cellSize,l-C),S=Math.min(n.cellSize,m-M),V=z(P,S);return V.getContext("2d").drawImage(p,C,M,P,S,0,0,P,S),[await V.encode("png")]}c(ae,"selectImage");function ce(e,n){return e&&n==="windows"}c(ce,"usesWindowsHostWindowCapture");function Y(){return{async captureWindow(e,n,r){if(r?.throwIfAborted(),ce(x(),n))return de(e,r);if(process.platform!=="linux"&&process.platform!=="darwin")throw new Error(`Window capture is unsupported on ${process.platform}`);let{Window:t}=await import("node-screenshots"),s;try{s=t.all()}catch(i){throw new Error(`Desktop window enumeration is unavailable: ${B(i)}`,{cause:i})}let a=s.find(i=>{try{return i.pid()===e}catch{return!1}});if(a===void 0)throw new Error(`No capturable desktop window belongs to PID ${e}`);let o=await a.captureImage();return r?.throwIfAborted(),new Uint8Array(await o.toPng())},async captureDisplay(e,n){if(n?.throwIfAborted(),x())return ue(e,n);if(process.platform!=="linux"&&process.platform!=="darwin"&&process.platform!=="win32")throw new Error(`Display capture is unsupported on ${process.platform}`);let{Monitor:r}=await import("node-screenshots"),t;try{t=r.all()}catch(o){throw new Error(`Desktop display enumeration is unavailable: ${B(o)}`,{cause:o})}let s=t[e];if(s===void 0)throw new Error(`Display index ${e} is unavailable; found ${t.length} display(s)`);let a=await s.captureImage();return n?.throwIfAborted(),new Uint8Array(await a.toPng())},async captureUrl(e,n){if(e.protocol!=="http:"&&e.protocol!=="https:")throw new Error("Web screenshots require an HTTP(S) URL");let{chromium:r}=await import("playwright-core"),t=await le(),s=await r.launch({executablePath:t,headless:!0,chromiumSandbox:!1,timeout:3e4}),a=c(()=>{s.close()},"abort");n?.addEventListener("abort",a,{once:!0});try{let o=await s.newPage({viewport:{width:1280,height:720}});return await o.goto(e.href,{waitUntil:"domcontentloaded",timeout:3e4}),await o.waitForLoadState("networkidle",{timeout:1500}).catch(()=>{}),n?.throwIfAborted(),new Uint8Array(await o.screenshot({type:"png",fullPage:!0}))}finally{n?.removeEventListener("abort",a),await s.close().catch(()=>{})}}}}c(Y,"createCaptureBackend");async function de(e,n){let r=new URL("windows-window-capture.ps1",new URL("../src/plugins/pi-agent-ide-vision/src/vision.ts",import.meta.url).href);n?.throwIfAborted();let{stdout:t}=await w("wslpath",["-w",r.pathname],{signal:n}),{stdout:s}=await w("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-File",t.trim(),"-ProcessId",String(e)],{encoding:"buffer",maxBuffer:I,signal:n});return new Uint8Array(s)}c(de,"captureWslWindow");async function ue(e,n){let r=new URL("windows-display-capture.ps1",new URL("../src/plugins/pi-agent-ide-vision/src/vision.ts",import.meta.url).href);n?.throwIfAborted();let{stdout:t}=await w("wslpath",["-w",r.pathname],{signal:n}),{stdout:s}=await w("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-File",t.trim(),"-DisplayIndex",String(e)],{encoding:"buffer",maxBuffer:I,signal:n});return new Uint8Array(s)}c(ue,"captureWslDisplay");function x(){return process.platform==="linux"&&(process.env.WSL_DISTRO_NAME!==void 0||te.release().toLowerCase().includes("microsoft"))}c(x,"isWsl");async function le(){let e=process.env.PI_AGENT_IDE_BROWSER_PATH;if(e!==void 0)return e;let{stdout:n}=await w("bash",["-lc","command -v google-chrome-stable || command -v google-chrome || command -v chromium || command -v chromium-browser"]),r=n.trim();if(r.length===0)throw new Error("No Chrome or Chromium executable was found; set PI_AGENT_IDE_BROWSER_PATH");return r}c(le,"resolveBrowser");function me(e,n){return new Promise((r,t)=>{let s=setTimeout(r,e),a=c(()=>{clearTimeout(s),t(n?.reason??new Error("Capture aborted"))},"abort");n?.addEventListener("abort",a,{once:!0}),s.unref()})}c(me,"delay");function B(e){return e instanceof Error?e.message:String(e)}c(B,"errorMessage");async function fe(e,n){$(e,[await q({id:"vision",description:"Window, display, image, and sequence capture",triggers:[{tool:"read",resourcePrefixes:["window:","display:"]}]})]);let r=n?.preferences??{};j({durationSeconds:r["vision.sequenceDurationSeconds"],intervalSeconds:r["vision.sequenceIntervalSeconds"],scale:r["vision.imageScale"],allowedExecutables:r["vision.allowedExecutables"]});let t=_(e),s=Y();await Promise.all([U(e,{protocol:O,apiVersion:T,id:"vision",setup(a){for(let i of["image","sequence"])a.addView({view:i,presenter:{id:`vision-${i}`,present:c(d=>d,"present")}});a.addHandler({stage:"pre-read",async handler(i){let d=i.request.path;if(d===void 0)return{kind:"continue",context:i};let l=X(d);if(l!==void 0){if(e.getFlag("pi-agent-ide-vision-displays")!==!0)return g(d,"Display capture is disabled. Enable --pi-agent-ide-vision-displays to allow it.");try{let u=await b(()=>s.captureDisplay(l,i.resolverContext.signal),D(i.request),i.resolverContext.signal);return v(d,u)}catch(u){return g(d,N(u))}}let m=K(d,"process:");if(m!==void 0){let u=await A(m,t);return v(d,[{type:"text",text:Q(u)}])}let p=K(d,"window:");if(p!==void 0){let u=await A(p,t);if(!u.owned&&!G(u.command)&&e.getFlag("pi-agent-ide-vision-arbitrary-windows")!==!0)return g(d,`Window capture for PID ${p} is denied because the process is neither Agent IDE-owned nor allowlisted by executable name. Enable --pi-agent-ide-vision-arbitrary-windows to allow it.`);try{let f=await b(()=>s.captureWindow(p,u.host,i.resolverContext.signal),D(i.request),i.resolverContext.signal);return v(d,f)}catch(f){return g(d,N(f))}}if(/^https?:\/\//iu.test(d)&&pe(i.request)){let u=new URL(d);try{let f=await b(()=>s.captureUrl(u,i.resolverContext.signal),D(i.request),i.resolverContext.signal);return v(u.href,f)}catch(f){return g(u.href,N(f))}}return{kind:"continue",context:i}}});let o=y();a.describe(`Process metadata: process:PID. Visual capture: window:PID and display: or display:#N. HTTP(S) sources accept image and sequence screenshots. Use named view parameters such as sequence:duration=2,interval=0.5,scale=0.5 and image:scale=0.5,region=0.25,0.25,0.5,0.5. Duration is limited to 10 seconds and sequences to 20 frames. Defaults: duration=${o.durationSeconds}, interval=${o.intervalSeconds}, scale=${o.scale}. Region uses normalized x,y,width,height and runs before scaling. For captures, limit is a square grid cell size in output pixels and offset is one zero-based row-major cell index; limit without offset selects cell 0, while offset without limit is invalid. Omit both for the bounded transformed image.`)}}),W(e,{protocol:k,apiVersion:L,id:"vision-processes",setup(a){a.addResolver({priority:-100,resolver:{id:"processes",readResources:c(o=>/^process:/iu.test(o.query)?void 0:[],"readResources"),toScriptData(o){return{kind:"custom",resolverId:"processes",value:{processes:o.map(d=>({pid:d.pid,command:d.command}))}}},async tryResolve(o){let i=/^process:(.*)$/isu.exec(o.query);if(i===null)return{kind:"not-handled"};let d=(i[1]??"").trim().toLowerCase();return{kind:"resolved",payload:(await E(t)).filter(m=>d.length===0||String(m.pid)===d||m.command.toLowerCase().includes(d)).slice(0,Math.min(o.limit??50,100))}},format(o){let i=o;return{content:[{type:"text",text:i.length===0?"No matching processes.":i.map(Q).join(`
|
|
3
|
-
|
|
4
|
-
`)}],details:{count:i.length,processes:i}}}}}),a.describe("process:<query> finds running processes by PID or command for process:PID metadata reads and guarded window:PID capture.")}})])}c(fe,"registerVision");function K(e,n){if(!e.startsWith(n))return;let r=e.slice(n.length);if(!/^\d+$/u.test(r))throw new Error(`${n} sources require a numeric PID`);return Number(r)}c(K,"prefixedPid");function D(e){return{...J(e.views,y())??{mode:"image",...y()},...e.limit===void 0?{}:{cellSize:e.limit},...e.offset===void 0?{}:{cellIndex:e.offset}}}c(D,"options");function pe(e){return e.views?.some(n=>/^(?:image|sequence)(?::|$)/u.test(n))===!0}c(pe,"requestsScreenshot");function v(e,n){return{kind:"return",result:{content:n,script:{kind:"native",source:e,blocks:n},details:{source:e,resolvedBy:"vision"}}}}c(v,"returned");function g(e,n){return{kind:"return",result:{content:[{type:"text",text:n}],details:{source:e,resolvedBy:"vision",failure:{code:"READ_FAILED",source:e,resolverId:"vision",message:n}},isError:!0}}}c(g,"failed");function N(e){return e instanceof Error?e.message:String(e)}c(N,"errorMessage");function Q(e){return[`PID: ${e.pid}`,`Command: ${e.command}`,`Owned by Agent IDE: ${e.owned?"yes":"no"}`,...e.parentPid===void 0?[]:[`Parent PID: ${e.parentPid}`],...e.started===void 0?[]:[`Started: ${e.started}`],...e.source===void 0?[]:[`Agent IDE source: ${e.source}`]].join(`
|
|
5
|
-
`)}c(Q,"formatProcess");export{fe as default};
|
package/dist/chunk-VWW3RLUX.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{d as C}from"./chunk-7AVXUV4A.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import{diffChars as j}from"diff";import{DefaultLinesDiffComputer as J}from"vscode-diff";var F=2,_=.5,k=100,Q=16e3,H=1e6,Z=new J,ee=new Set(["async","boolean","const","export","false","function","interface","let","new","null","number","private","protected","public","readonly","return","static","string","true","type","undefined","var"]);function E(e,n,t=[],r={}){let o=ne(e,n,(r.beforeLineOffset??0)+1,(r.afterLineOffset??0)+1);if(o===void 0)return{rows:[],added:0,modified:0,removed:0,focusRow:0,omittedChanges:{outside:0,ambiguous:0,unavailable:!0}};let i=r.project===!1?o:oe(o),s=r.focusAfterLine??(t.length===0?void 0:fe(n,y(t.at(-1)).to)+(r.afterLineOffset??0));return{rows:i,added:o.filter(({kind:f})=>f==="added").length,modified:o.filter(({kind:f})=>f==="modified").length,removed:o.filter(({kind:f})=>f==="removed").length,focusRow:se(i,s)}}c(E,"createDiffModel");function ne(e,n,t=1,r=1){if(e.length+n.length>H)return;let o=performance.now()+k,i=W(e),s=W(n),f=[];if(i.length===0||s.length===0)return[...i.map((d,g)=>({kind:"removed",text:d,beforeLine:t+g,changed:!0})),...s.map((d,g)=>({kind:"added",text:d,afterLine:r+g,changed:!0}))];let a=Z.computeDiff([...i],[...s],{ignoreTrimWhitespace:!0,computeMoves:!1,maxComputationTimeMs:k});if(a.hitTimeout||performance.now()>=o)return;let u=0,l=0,m=c(d=>{for(;l<d;)f.push({kind:"context",text:y(s[l]),beforeLine:t+u++,afterLine:r+l++,changed:!1})},"appendContext");for(let d of a.changes){m(d.modified.startLineNumber-1);let g=i.slice(d.original.startLineNumber-1,d.original.endLineNumberExclusive-1).map((b,R)=>({text:b,line:t+u+R})),h=s.slice(d.modified.startLineNumber-1,d.modified.endLineNumberExclusive-1).map((b,R)=>({text:b,line:r+l+R})),w=te(g,h,o);f.push(...w??[...g.map(({text:b,line:R})=>({kind:"removed",text:b,beforeLine:R,changed:!0})),...h.map(({text:b,line:R})=>({kind:"added",text:b,afterLine:R,changed:!0}))]),u+=g.length,l+=h.length}if(m(s.length),e.endsWith(`
|
|
2
|
-
`)!==n.endsWith(`
|
|
3
|
-
`)){let d=f.at(-1);d?.kind==="context"&&(f[f.length-1]={...d,kind:"modified",changed:!0,addedRanges:[],deletedOffsets:e.endsWith(`
|
|
4
|
-
`)?[d.text.length]:[]})}return f}c(ne,"createSemanticRows");function D(e,n,t){let r=e[n]?.[t];if(r===void 0)throw new RangeError(`Score [${n}, ${t}] is outside the alignment matrix.`);return r}c(D,"scoreAt");function te(e,n,t){let r=new Map,o=c((l,m)=>{if(performance.now()>=t)return;let d=r.get(l)?.get(m);if(d!==void 0)return d;let g=ie(l,m,t);if(g!==void 0){let h=r.get(l);h===void 0&&(h=new Map,r.set(l,h)),h.set(m,g)}return g},"compareCharacters");if(e.length>1&&e.length===n.length){let l=[];for(let[m,d]of e.entries()){let g=y(n[m]),h=z(d.text,g.text,o);if(h===void 0)return;if(h<_)break;let w=v(d,g,t);if(w===void 0)return;l.push(w)}if(l.length===e.length)return l}if(e.length===1&&n.length===1){let l=v(y(e[0]),y(n[0]),t);return l===void 0?void 0:[l]}if(e.length*n.length>Q)return;let i=Array.from({length:e.length},()=>Array(n.length).fill(0)),s=Array.from({length:e.length+1},()=>Array.from({length:n.length+1}).fill(0));for(let l=1;l<=e.length;l++)for(let m=1;m<=n.length;m++){let d=z(y(e[l-1]).text,y(n[m-1]).text,o);if(d===void 0)return;y(i[l-1])[m-1]=d;let g=d>=_?D(s,l-1,m-1)+d:Number.NEGATIVE_INFINITY;y(s[l])[m]=Math.max(D(s,l-1,m),D(s,l,m-1),g)}let f=[],a=e.length,u=n.length;for(;a>0||u>0;){let l=a>0&&u>0?D(i,a-1,u-1):0;if((a>0&&u>0&&l>=_?D(s,a-1,u-1)+l:Number.NEGATIVE_INFINITY)===D(s,a,u)){let d=v(y(e[a-1]),y(n[u-1]),t);if(d===void 0)return;f.push(d),a--,u--}else if(u>0&&D(s,a,u-1)>=(a>0?D(s,a-1,u):Number.NEGATIVE_INFINITY)){let d=y(n[u-1]);f.push({kind:"added",text:d.text,afterLine:d.line,changed:!0}),u--}else{let d=y(e[a-1]);f.push({kind:"removed",text:d.text,beforeLine:d.line,changed:!0}),a--}}return f.reverse()}c(te,"alignChangedLines");function v(e,n,t){let r=re(e.text,n.text,t);if(r!==void 0)return{kind:"modified",text:n.text,beforeLine:e.line,afterLine:n.line,changed:!0,...r}}c(v,"modifiedRow");function re(e,n,t=performance.now()+k){let r=t-performance.now();if(r<=0||e.length+n.length>H)return;let o=j(e.trim(),n.trim(),{timeout:r,maxEditLength:5e3});if(o===void 0)return;let i=[],s=[],f=n.length-n.trimStart().length;for(let a=0;a<o.length;a++){let u=y(o[a]);u.removed?o[a+1]?.added||s.push(f):(u.added&&i.push({from:f,to:f+u.value.length}),f+=u.value.length)}return{addedRanges:i,deletedOffsets:s}}c(re,"compareInlineText");function z(e,n,t){let r=t(e,n);if(r===void 0)return;let o=V(e),i=V(n);if(o.length===0&&i.length===0)return r;let s=B(o,i,t),f=B(i,o,t);if(s===void 0||f===void 0)return;let a=(s+f)/2;return r*.35+a*.65}c(z,"lineSimilarity");function V(e){return(e.toLowerCase().match(/[\p{L}\p{N}_$]+/gu)??[]).filter(n=>!ee.has(n))}c(V,"semanticTokens");function B(e,n,t){if(e.length===0||n.length===0)return 0;let r=0;for(let o of e){let i=0;for(let s of n){let f=t(o,s);if(f===void 0)return;i=Math.max(i,f)}r+=i}return r/e.length}c(B,"directionalTokenSimilarity");function ie(e,n,t){if(t-performance.now()<=0)return;let o=Math.max(e.length,n.length);if(o===0||e===n)return 1;let i=Array.from(e),s=Array.from(n),f=0,a=0;for(;f<i.length&&f<s.length&&i[f]===s[f];)a+=y(i[f]).length,f++;let u=i.length,l=s.length;for(;u>f&&l>f&&i[u-1]===s[l-1];)a+=y(i[--u]).length,l--;let m=i.slice(f,u),d=s.slice(f,l);if(d.length>m.length&&([m,d]=[d,m]),d.length<=31&&m.every(w=>w.length===1)){let w=new Map;for(let[T,x]of d.entries())w.set(x,(w.get(x)??0)|1<<T);let b=0;for(let T of m){let x=(w.get(T)??0)|b;b=x&~(x-(b<<1|1))}let R=a;for(;b!==0;)b&=b-1,R++;return R/o}let g=j(e,n,{timeout:t-performance.now(),maxEditLength:2e3});return g===void 0?void 0:g.filter(w=>!w.added&&!w.removed).reduce((w,b)=>w+b.value.length,0)/o}c(ie,"characterSimilarity");function oe(e){let n=[];for(let t=0;t<e.length;t++){if(!y(e[t]).changed)continue;let r=t;for(;t+1<e.length&&y(e[t+1]).changed;)t++;let o={start:Math.max(0,r-F),end:Math.min(e.length-1,t+F)},i=n.at(-1);i!==void 0&&o.start<=i.end+1?n[n.length-1]={start:i.start,end:Math.max(i.end,o.end)}:n.push(o)}return n.flatMap((t,r)=>{let o=n[r-1];return[...o===void 0?[]:[de(t.start-o.end-1)],...e.slice(t.start,t.end+1)]})}c(oe,"projectHunks");function de(e){return{kind:"omitted",text:"",changed:!1,omitted:e}}c(de,"omittedRow");function W(e){if(e.length===0)return[];let n=e.replaceAll(`\r
|
|
5
|
-
`,`
|
|
6
|
-
`),t=n.split(`
|
|
7
|
-
`);return n.endsWith(`
|
|
8
|
-
`)&&t.pop(),t}c(W,"splitPart");function fe(e,n){let t=1;for(let r=0;r<Math.min(n,e.length);r++)e[r]===`
|
|
9
|
-
`&&t++;return t}c(fe,"lineAtOffset");function se(e,n){if(n!==void 0){let t=e.findLastIndex(r=>r.afterLine!==void 0&&r.afterLine<=n&&r.changed);if(t!==-1)return t}return Math.max(0,e.findLastIndex(t=>t.changed))}c(se,"findFocusRow");function G(e){return{resources:e.flatMap(n=>{let t=n.model??E(n.beforeContent,n.afterContent,n.ranges),r=ae(t,n),o=t.rows[t.focusRow]?.afterLine;return r.length===0?[]:[{path:n.path,windows:r,...o!==void 0&&{focusAfterLine:o}}]})}}c(G,"freezeMutationViewports");function $(e,n){return e.map(t=>{let r=n?.resources.find(o=>ce(o.path,t.path));return r===void 0?{...t,model:E(t.beforeContent,t.afterContent,t.ranges)}:{...t,model:ue(t.beforeContent,t.afterContent,r,t.diffPeerRanges,t.finalLineOwnership)}})}c($,"projectFinalResources");function ae(e,n){let t=[],r=[],o=c(()=>{if(r.length===0)return;let i=r.flatMap(h=>h.beforeLine===void 0?[]:[h.beforeLine]),s=I(n.beforeContent,n.beforeRanges?.at(-1)),f=i.length===0?s-1:Math.min(...i)-1,a=i.length===0?f:Math.max(...i),u=r.flatMap(h=>h.changed&&h.beforeLine!==void 0?[h.beforeLine]:[]),l=r.findIndex(h=>h.changed),m=r.slice(0,l).findLast(h=>h.beforeLine!==void 0)?.beforeLine,d=r.slice(l+1).find(h=>h.beforeLine!==void 0)?.beforeLine,g=m??(d===void 0?s-1:d-1);t.push({beforeStart:f,beforeEnd:a,seedStart:u.length===0?g:Math.min(...u)-1,seedEnd:u.length===0?g:Math.max(...u)}),r=[]},"flush");for(let i of e.rows)i.kind==="omitted"?o():r.push(i);return o(),t}c(ae,"freezeWindows");function ue(e,n,t,r=[],o){let i=E(e,n,[],{project:!1});if(i.rows.length===0&&e!==n)return{...i,omittedChanges:{outside:0,ambiguous:0,unavailable:!0}};let s=new Set,f=0,a=0,u=0;for(let d=0;d<i.rows.length;){let g=y(i.rows[d]);if(!g.changed){u=g.beforeLine??u,d++;continue}let h=d,w=u,b=[];for(;d<i.rows.length&&y(i.rows[d]).changed;){let p=y(i.rows[d]).beforeLine;p!==void 0&&(b.push(p),u=p),d++}let R=b.length===0?w:Math.min(...b)-1,T=b.length===0?w:Math.max(...b),x=t.windows.filter(p=>P(R,T,p.seedStart,p.seedEnd));if(r.some(p=>{let M=I(e,p)-1,A=I(e,{from:Math.max(p.from,p.to-1),to:p.to});return P(R,T,M,p.from===p.to?M:A)})){if(x.length>0)for(let p=h;p<d;p++){let M=y(i.rows[p]).beforeLine,A=y(i.rows[p]).afterLine;if(M===void 0&&A!==void 0&&o!==void 0){let L=o.own.includes(A),N=o.peers.includes(A);L&&!N?s.add(p):(L||!N)&&a++;continue}let S=M!==void 0&&x.some(L=>P(M-1,M,L.seedStart,L.seedEnd)),O=M!==void 0&&r.some(L=>{let N=I(e,L)-1,U=I(e,{from:Math.max(L.from,L.to-1),to:L.to});return P(M-1,M,N,U)});S&&!O?s.add(p):(!O||S)&&a++}continue}if(x.length===0){f+=d-h;continue}if(!x.some(p=>R>=p.beforeStart&&T<=p.beforeEnd)){a+=d-h;continue}for(let p=h;p<d;p++)s.add(p)}for(let d of[...s])for(let g=Math.max(0,d-F);g<Math.min(i.rows.length,d+F+1);g++)y(i.rows[g]).changed||s.add(g);let l=[],m=-1;for(let d of[...s].sort((g,h)=>g-h))m!==-1&&d>m+1&&l.push({kind:"omitted",text:"",changed:!1,omitted:d-m-1}),l.push(y(i.rows[d])),m=d;return{rows:l,added:l.filter(({kind:d})=>d==="added").length,modified:l.filter(({kind:d})=>d==="modified").length,removed:l.filter(({kind:d})=>d==="removed").length,focusRow:le(l,t.focusAfterLine),...f+a>0&&{omittedChanges:{outside:f,ambiguous:a}}}}c(ue,"createFrozenModel");function P(e,n,t,r){return e===n?e>=t&&e<=r:t===r?t>=e&&t<=n:e<r&&n>t}c(P,"overlaps");function I(e,n){let t=n?.from??0;return e.slice(0,t).split(`
|
|
10
|
-
`).length}c(I,"lineAtRange");function le(e,n){if(n!==void 0){let t=e.findLastIndex(r=>r.afterLine!==void 0&&r.afterLine<=n);if(t!==-1)return t}return Math.max(0,e.findLastIndex(({changed:t})=>t))}c(le,"focusRowAt");function ce(e,n){return e===n||e.endsWith(`/${n}`)||n.endsWith(`/${e}`)}c(ce,"samePath");function X(e,n,t=!0){let r=e?.mutationRender;if(r!==void 0)return r.map(({path:f,model:a,diffStatuses:u})=>({path:f,model:a,...u===void 0?{}:{diffStatuses:u},ranges:[],beforeContent:"",afterContent:""}));let o=(e?.results??[]).map(f=>C.ensure(f)),i=o.flatMap(me);if(!t)return i;let s=n??he(o);return $(i,s)}c(X,"resolveMutationResultResources");function me(e){let n=e.afterContent,t=Y(e.data.rawChanges);return!e.ok||typeof n!="string"?[]:K(e).flatMap(r=>{let o=e.beforeContentMap?.[r];if(typeof o!="string"&&o!==null)return[];let i=t===void 0?void 0:q(o??"",t),s=ge(o??"",n,t,e.data.diffPeerRanges),f=i===n?{beforeRanges:t?.map(({fromA:a,toA:u})=>({from:a,to:u}))??[],ranges:t?.map(({fromB:a,toB:u})=>({from:a,to:u}))??[]}:void 0;return[{path:r,ranges:[],beforeContent:o??"",...f===void 0?{}:{typingIdentity:f},...s===void 0?{}:{finalLineOwnership:s},...e.data.diffPeerRanges===void 0?{}:{diffPeerRanges:e.data.diffPeerRanges},...e.data.diffStatuses===void 0?{}:{diffStatuses:e.data.diffStatuses},afterContent:n}]})}c(me,"finalResource");function ge(e,n,t,r){if(t===void 0||r===void 0)return;let o=[...t.map(({fromA:a,toA:u,insertedText:l})=>({from:a,to:u,insert:l,own:!0})),...r.map(a=>({...a,own:!1}))].sort((a,u)=>a.from-u.from),i={own:new Set,peers:new Set},s="",f=0;for(let a of o){if(a.from<f||a.to<a.from||a.to>e.length)return;s+=e.slice(f,a.from);let u=s.split(`
|
|
11
|
-
`).length;if(s+=a.insert,a.insert.length>0){let l=s.slice(0,-1).split(`
|
|
12
|
-
`).length;for(let m=u;m<=l;m++)i[a.own?"own":"peers"].add(m)}f=a.to}if(s+e.slice(f)===n)return{own:[...i.own],peers:[...i.peers]}}c(ge,"unchangedBatchOwnership");function he(e){let n=e.flatMap(pe);return n.length===0?void 0:G(n)}c(he,"persistedViewports");function pe(e){if(!e.ok)return[];let n=Y(e.data.rawChanges);return n===void 0||n.length===0?[]:K(e).flatMap(t=>{let r=e.beforeContentMap?.[t];if(typeof r!="string"&&r!==null)return[];let o=r??"",i=q(o,n);return i===void 0?[]:[{path:t,beforeContent:o,afterContent:i,beforeRanges:n.map(({fromA:s,toA:f})=>({from:s,to:f})),ranges:n.map(({fromB:s,toB:f})=>({from:s,to:f}))}]})}c(pe,"generatedResource");function K(e){return e.files.length>0?e.files.map(({path:n})=>n):e.path===void 0?[]:[e.path]}c(K,"resultPaths");function Y(e){if(!(!Array.isArray(e)||!e.every(ye)))return[...e].sort((n,t)=>n.fromA-t.fromA)}c(Y,"persistedChanges");function ye(e){if(typeof e!="object"||e===null)return!1;let n=e;return Number.isInteger(n.fromA)&&Number.isInteger(n.toA)&&Number.isInteger(n.fromB)&&Number.isInteger(n.toB)&&typeof n.insertedText=="string"}c(ye,"isPersistedTextChange");function q(e,n){let t="",r=0;for(let o of n){if(o.fromA<r||o.toA<o.fromA||o.toA>e.length)return;t+=e.slice(r,o.fromA)+o.insertedText,r=o.toA}return t+e.slice(r)}c(q,"replayChanges");function ve(e){let n=X(e,void 0),{displayResults:t,...r}=e;return{...r,results:e.results?.map(o=>{let i=C.ensure(o),{beforeContentMap:s,afterContent:f,afterDocument:a,snapshot:u,activeEdits:l,inputEdits:m,beforeReadText:d,rawChanges:g,diffPeerRanges:h,diffs:w,...b}=i.data;return new C(b)}),mutationRender:n.flatMap(({path:o,model:i,diffStatuses:s})=>i===void 0?[]:[{path:o,model:i,...s===void 0?{}:{diffStatuses:s}}])}}c(ve,"compactMutationDetails");export{F as a,E as b,re as c,G as d,X as e,ve as f};
|
package/dist/chunk-YHUTTZC6.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-EI7MMDWY.js";import{sliceByColumn as S,truncateToWidth as f,visibleWidth as d,wrapTextWithAnsi as H}from"@earendil-works/pi-tui";function D(t,e){return t.getBgAnsi(e.isPartial?"toolPendingBg":e.isError?"toolErrorBg":"toolSuccessBg")}a(D,"toolBackgroundAnsi");var p=class{constructor(e,n){this.model=e;this.theme=n}static{a(this,"ToolCallHeader")}cache;update(e,n){this.model===e&&this.theme===n||(this.model=e,this.theme=n,this.invalidate())}render(e){if(this.cache?.width===e)return[...this.cache.lines];let n=B(this.model,this.theme,e);return this.cache={width:e,lines:n},[...n]}invalidate(){this.cache=void 0}};function q(t,e,n){let r=t instanceof p?t:new p(e,n);return r.update(e,n),r}a(q,"toolCallHeader");function B(t,e,n){let r=Math.max(1,n),i=M(t,e,r),o=t.details;return!t.expanded||o===void 0||o.length===0?[i]:[i,...$(o,e,r)]}a(B,"renderToolCallHeader");function $(t,e,n){if(t.length===0)return[];let r=[e.fg("dim","args ")].concat(t.map(({label:o,value:l},s)=>`${s===0?"":e.fg("dim"," \xB7 ")}${e.fg("muted",`${u(o)}=`)}${e.fg("toolOutput",u(l))}`)).join(""),i=Math.max(1,n);return H(r,i).map(o=>f(o,i))}a($,"renderToolCallDetails");var P=/\u001B\[([\d:;]*)m/gu,W=/^\u001B\[([\d:;]*)m/u;function N(t,e){return e.length===0?t:t.replace(P,(n,r,i,o)=>T(r)==="reset"&&!k(o,i+n.length)?`${n}${e}`:n)}a(N,"preserveEnclosingBackground");function k(t,e){let n=W.exec(t.slice(e));return n!==null&&T(n[1]??"")==="set"}a(k,"backgroundIsImmediatelySet");function T(t){let e=t.length===0?["0"]:t.split(";"),n="unchanged";for(let r=0;r<e.length;r++){let i=e[r]??"",o=Number(i.split(":",1)[0]||"0");if(o===0||o===49){n="reset";continue}if(o>=40&&o<=47||o>=100&&o<=107){n="set";continue}if(o!==38&&o!==48&&o!==58||(o===48&&(n="set"),i.includes(":")))continue;let l=Number(e[r+1]);r+=l===2?4:l===5?2:0}return n}a(T,"sgrBackgroundState");function u(t){let e="",n=typeof t=="string"?t:"";for(let r of n){if(r===`
|
|
2
|
-
`){e+="\\n";continue}if(r==="\r"){e+="\\r";continue}if(r===" "){e+="\\t";continue}let i=r.codePointAt(0)??0;e+=i<32||i===127?"\uFFFD":r}return e}a(u,"singleLine");function M(t,e,n){let r=e.fg("toolTitle",e.bold(u(t.tool))),i=d(r);if(i>=n||t.primary===void 0)return f(r,n);let o=e.fg("dim"," \xB7 "),l=[...t.qualifiers??[]],s=0;for(;l.length>0&&E(r,t.primary,l,s,e)>n;)l.pop(),s++;let c=l.reduce((m,C)=>m+d(o)+d(g(C,e)),0),y=s===0?"":e.fg("dim",` \xB7 \u2026 +${String(s)}`),h=Math.max(1,n-i-1-c-d(y)),b=g({...t.primary,text:v(u(t.primary.text),h,t.primary.truncate)},e),x=l.map(m=>`${o}${g(m,e)}`).join("");return f(`${r} ${b}${x}${y}`,n)}a(M,"renderSummary");function E(t,e,n,r,i){let o=n.reduce((s,c)=>s+3+d(g(c,i)),0),l=r===0?0:d(` \xB7 \u2026 +${String(r)}`);return d(t)+1+d(u(e.text))+o+l}a(E,"summaryWidth");function g(t,e){let n=u(t.text);return t.bold===!0&&(n=e.bold(n)),t.underline===!0&&(n=e.underline(n)),e.fg(t.color??"muted",n)}a(g,"renderPart");function v(t,e,n){if(d(t)<=e)return t;if(e<=1)return"\u2026";if(n!=="start")return f(t,e);let r=e-1;return`\u2026${S(t,d(t)-r,r,!0)}`}a(v,"truncatePart");export{D as a,p as b,q as c,B as d,$ as e,N as f,u as g};
|
package/dist/chunk-ZODCBFBL.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as W}from"./chunk-PLKYHUNT.js";import{m as w}from"./chunk-ZPT5D4VP.js";import{a as b}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import{createHash as ye}from"node:crypto";import{readFile as Z}from"node:fs/promises";import m from"node:path";import{spawn as le}from"node:child_process";import{stat as ue}from"node:fs/promises";import k from"node:path";import{createInterface as de}from"node:readline";import{existsSync as oe}from"node:fs";import ie from"node:os";import q from"node:path";function Q(e=process.env.PI_CODING_AGENT_DIR??q.join(ie.homedir(),".pi","agent"),t=process.platform){let n=q.join(e,"bin",t==="win32"?"rg.exe":"rg");return oe(n)?n:"rg"}c(Q,"resolveRipgrepExecutable");function j(e,t=!1){let n=E(e);return N(n)?I(A(new v(e,n).parse(),t)):t?e:O(e)}c(j,"compileSearchQuery");function L(e,t=!1){let n=E(e);return N(n)?A(new v(e,n).parse(),t):void 0}c(L,"compileSearchCondition");function T(e,t){if(e.kind==="term")return t(e.value);let n=T(e.left,t);if(e.kind==="or")return n||T(e.right,t);let r=T(e.right,t);return n&&(e.kind==="not"?!r:r)}c(T,"satisfiesSearchCondition");function z(e){if(N(E(e)))return;let t=[...new Set(e.trim().split(/\s+/u).filter(Boolean))];return t.length>1?`(?:${t.map(O).join("|")})`:void 0}c(z,"compileSearchFallbackQuery");function N(e){return e.some(t=>t.quoted===!0||t.type==="and"||t.type==="or"||t.type==="not")}c(N,"containsBooleanSyntax");var v=class{static{c(this,"BooleanQueryParser")}#t;#r;#i=0;constructor(t,n){this.#t=t,this.#r=n}parse(){let t=this.#s(),n=this.#e();if(n.type!=="end"){let r=n.type==="right"?"unexpected ')'.":`unexpected ${ce(n)}.`;throw y(n.offset,r)}return t}#s(){let t=this.#n();for(;this.#e().type==="or";){let n=this.#o(),r=this.#a(`after ${n.value}`);t={kind:"or",left:t,right:this.#c(r)}}return t}#n(){return this.#c(this.#a())}#c(t){let n=t;for(;;){let r=this.#e();if(r.type==="and"||r.type==="not"){this.#o();let o=this.#a(`after ${r.value}`);n={kind:r.type,left:n,right:o};continue}if(r.type==="term"||r.type==="left"){n={kind:"and",left:n,right:this.#a()};continue}return n}}#a(t){let n=this.#e();if(n.type==="term")return this.#o(),{kind:"term",value:n.value,quoted:n.quoted};if(n.type==="left"){if(this.#o(),this.#e().type==="right"||this.#e().type==="end")throw y(this.#e().offset,"expected a term after '('.");let o=this.#s();if(this.#e().type!=="right")throw y(this.#e().offset,"expected ')'.");return this.#o(),o}if(t===void 0&&(n.type==="and"||n.type==="or"||n.type==="not"))throw y(n.offset,`expected a term before ${n.value}.`);let r=t===void 0?"":` ${t}`;throw y(n.offset,`expected a term${r}.`)}#e(){return this.#r[this.#i]??{type:"end",value:"",offset:this.#t.length}}#o(){let t=this.#e();return this.#i+=1,t}};function E(e){let t=[],n=0;for(;n<e.length;){let r=e.charAt(n);if(/\s/u.test(r)){n+=1;continue}if(r==="("&&se(e,n)){t.push({type:"left",value:r,offset:n}),n+=1;continue}if(r===")"){t.push({type:"right",value:r,offset:n}),n+=1;continue}if(G(e,n)){let s=e.charAt(n+1)==="|"?2:1;t.push({type:"or",value:e.slice(n,n+s),offset:n}),n+=s;continue}if(r==="'"||r==='"'){let s=n,l=r,a="";for(n+=1;n<e.length&&e.charAt(n)!==l;)e.charAt(n)==="\\"&&(e.charAt(n+1)===l||e.charAt(n+1)==="\\")&&(n+=1),a+=e.charAt(n++);if(n>=e.length)throw y(s,`unterminated ${l==="'"?"single":"double"}-quoted term.`);if(n+=1,a.length===0)throw y(s,"quoted terms must not be empty.");t.push({type:"term",value:a,offset:s,quoted:!0});continue}let o=n;for(;n<e.length;){let s=e.charAt(n);if(/\s/u.test(s)||s===")"||G(e,n))break;s==="\\"&&n+1<e.length?n+=2:s==="["||s==="("?n=H(e,n)??n+1:n+=1}let i=e.slice(o,n);t.push({type:ae(i),value:i,offset:o})}return t.push({type:"end",value:"",offset:e.length}),t}c(E,"tokenize");function G(e,t){return e.charAt(t)==="|"&&(e.charAt(t+1)==="|"||/\s/u.test(e.charAt(t-1))&&/\s/u.test(e.charAt(t+1)))}c(G,"isBooleanPipe");function H(e,t){let n=e.charAt(t)==="["?"]":")",r=t+1;for(;r<e.length;){let o=e.charAt(r);if(o==="\\")r+=2;else{if(o===n)return r+1;if(n===")"&&(o==="("||o==="[")){let i=H(e,r);if(i===void 0)return;r=i}else r+=1}}}c(H,"regexBlockEnd");function se(e,t){let n=H(e,t);if(n===void 0)return!0;let r=e.slice(t+1,n-1);return r.trim().length===0?!0:N(E(r))}c(se,"isBooleanGroup");function ae(e){return e==="AND"?"and":e==="OR"?"or":e==="NOT"?"not":"term"}c(ae,"operatorType");function ce(e){return e.value.length>0?JSON.stringify(e.value):"the end of the query"}c(ce,"quoteToken");function y(e,t){return new SyntaxError(`Invalid Boolean search query at column ${String(e+1)}: ${t}`)}c(y,"syntaxError");function A(e,t){return e.kind==="term"?{kind:"term",value:t&&!e.quoted?e.value:O(e.value)}:{kind:e.kind,left:A(e.left,t),right:A(e.right,t)}}c(A,"compileTerms");function I(e){if(e.kind==="term")return e.value;let t=I(e.left);return e.kind==="not"?t:`(?:${t}|${I(e.right)})`}c(I,"matchPattern");function O(e){return e.replace(/[\\^$.*+?()[\]{}|]/gu,"\\$&")}c(O,"escapeRegex");async function M(e,t,n){if(e.query.length===0)throw new Error("Search query must not be empty.");if(/\r|\n/u.test(e.query))throw new Error("Search supports one-line patterns only.");return e.condition!==void 0?he(e,t,n):K(e,t,n)}c(M,"searchText");async function K(e,t,n,r){let o=k.resolve(t,pe(e.path??".")),i=(await ue(o)).isDirectory(),s=i?o:k.dirname(o),l=["--json","--no-config","--no-ignore-parent","--color=never","--with-filename","--line-number",e.caseSensitive===!0?"--case-sensitive":"--ignore-case",...e.wholeWord===!0?["--word-regexp"]:[],...U(e.include).flatMap(a=>["--glob",a]),...U(e.exclude).flatMap(a=>["--glob",`!${a}`]),"--",e.query,i?".":k.basename(o)];if(e.regex!==!0)return F(["--fixed-strings",...l],s,n,r);try{return await F(["--engine","auto",...l],s,n,r)}catch(a){if(!fe(a))throw a instanceof Error&&/PCRE2 is not available|does not support PCRE2/iu.test(a.message)?new Error("This regex requires PCRE2. Install ripgrep with PCRE2 support or simplify the regex.",{cause:a}):a;try{return await F(["--engine","default",...l],s,n,r)}catch(u){throw n?.aborted?u:new AggregateError([a,u],"Regex exceeded the PCRE2 match limit and cannot run with the default engine. Narrow the search or simplify the regex.",{cause:u})}}}c(K,"searchPattern");async function he(e,t,n){let r=e.condition;if(r===void 0)throw new Error("Boolean search requires a line condition.");let o=new Set;function i(h){if(h.kind==="term"){o.add(h.value);return}i(h.left),i(h.right)}c(i,"collect"),i(r);let{condition:s,...l}=e,a=new Map,u=c(h=>JSON.stringify([h.source,h.lineNumber]),"lineKey");for(let h of o){n?.throwIfAborted();let f=new Set;await K({...l,query:h,regex:!0,wholeWord:!1},t,n,(S,C)=>f.add(JSON.stringify([S,C]))),a.set(h,f)}let d=await M(l,t,n),g=new Set,p=d.matches.filter(h=>{let f=u(h);return g.has(f)||!T(r,S=>a.get(S)?.has(f)===!0)?!1:(g.add(f),!0)});return{...d,matches:p}}c(he,"searchBoolean");function F(e,t,n,r){return new Promise((o,i)=>{let s=le(Q(),e,{stdio:["ignore","pipe","pipe"],cwd:t}),l=de({input:s.stdout}),a=[],u="",d,g=c(()=>{s.kill()},"abort"),p=c(()=>{n?.removeEventListener("abort",g),l.close()},"cleanup");s.stderr.setEncoding("utf8"),s.stderr.on("data",h=>{u+=h}),l.on("line",h=>{if(!(d!==void 0||h.length===0))try{let f=JSON.parse(h);if(f.type!=="match")return;if(r!==void 0){let{path:S,line_number:C}=f.data;S.text!==void 0&&Number.isSafeInteger(C)&&r(k.resolve(t,S.text),C);return}for(let S of me(f,t))a.push(S)}catch(f){d=f,s.kill()}}),s.once("error",h=>{p(),i(h)}),s.once("close",h=>{if(p(),n?.aborted===!0){let f=new Error("Search was aborted.");f.name="AbortError",i(f);return}if(d!==void 0){i(new Error("Unable to parse ripgrep search output.",{cause:d}));return}if(h!==0&&h!==1){i(new Error(u.trim()||`ripgrep exited with code ${String(h)}.`));return}a.sort(ge),o({matches:a,complete:!0})}),n?.addEventListener("abort",g,{once:!0}),n?.aborted===!0&&g()})}c(F,"runRipgrep");function fe(e){return e instanceof Error&&/PCRE2: error matching: match limit exceeded/iu.test(e.message)}c(fe,"isPcre2MatchLimitError");function me(e,t){let n=e.data.path.text,r=e.data.lines.text;if(n===void 0||r===void 0||!Number.isSafeInteger(e.data.line_number))return[];let o=r.replace(/(?:\r\n|\n)$/u,""),i=Buffer.from(r),s=[];for(let l of e.data.submatches){if(l.start<0||l.end<=l.start||l.end>i.length)continue;let a=i.subarray(0,l.start).toString("utf8").length,u=i.subarray(0,l.end).toString("utf8").length;s.push({source:k.resolve(t,n),lineNumber:e.data.line_number,startColumn:a,endColumn:u,matchedText:o.slice(a,u),lineText:o})}return s}c(me,"matchesFromEvent");function U(e){if(e===void 0)return[];let t=[],n=0,r="";for(let o of e){if(o==="{"?n+=1:o==="}"&&(n=Math.max(0,n-1)),n===0&&(o===","||/\s/u.test(o))){r.length>0&&(t.push(r),r="");continue}r+=o}return r.length>0&&t.push(r),t}c(U,"splitGlobList");function pe(e){return e.startsWith("@")?e.slice(1):e}c(pe,"stripFilePrefix");function ge(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||e.endColumn-t.endColumn}c(ge,"compareMatches");function Je(e){let t=j(e.query),n=j(e.query,!0),r=z(e.query),o=[],i=L(e.query),s=L(e.query,!0);return(n!==t||JSON.stringify(i)!==JSON.stringify(s))&&o.push({query:n,mode:"regex",condition:s}),r!==void 0&&r!==t&&r!==n&&o.push({query:r,mode:"words"}),{...e,query:t,regex:!0,condition:i,fallbacks:o}}c(Je,"createSearchRecipe");async function _(e,t,n){let r=e.query,o=await M(e,t,n),i=[];for(let s of e.fallbacks??[]){if(o.matches.length>0||!o.complete)break;n?.throwIfAborted();try{o=await M({...e,query:s.query,regex:!0,condition:s.condition},t,n),r=s.query,i.push(s.mode==="regex"?"Search fallback: no literal matches; tried unquoted terms as regex.":"Search fallback: no matches in earlier modes; tried separate words.")}catch(l){if(s.mode!=="regex"||!Se(l)||n?.aborted)throw l;i.push("Search fallback: invalid regex skipped; literal search found no matches.")}}return{...o,query:r,notices:i}}c(_,"runSearchRecipe");function Se(e){return e instanceof Error&&/regex parse error:|PCRE2: error compiling pattern/iu.test(e.message)}c(Se,"isRegexSyntaxError");var be=/^SEARCH#([A-F0-9]{4,64}):(all|[1-9]\d*):(line|match)$/u,ee=4;function Ye(e,t,n,r){return te(e,t,n,r).slice(0,ee)}c(Ye,"createSearchSessionId");function te(e,t,n,r){let o=n===void 0?ke(t.map(a=>a.source)):m.resolve(n),i=t.map(a=>({match:a,source:m.relative(o,m.resolve(a.source))})).sort((a,u)=>a.source.localeCompare(u.source)||J(a.match,u.match)).map(({match:a,source:u})=>[u,a.lineNumber,a.startColumn,a.endLineNumber??a.lineNumber,a.endColumn,a.matchedText,a.lineText]),{limit:s,...l}=ne(r??{query:e,regex:!0},o);return ye("sha256").update(JSON.stringify([e,o,l,i])).digest("hex").toUpperCase()}c(te,"createSearchSessionIdentity");function xe(e,t){if(!/^[A-F0-9]{64}$/u.test(e))throw new Error("Search session identity must be a 64-character uppercase hexadecimal value.");for(let n=ee;n<=e.length;n+=1){let r=e.slice(0,n);if(!t.has(r))return r}throw new Error("Could not allocate a unique search session id.")}c(xe,"allocateSearchSessionId");function ne(e,t){return{query:e.query,path:m.resolve(t,e.path??"."),include:e.include??"",exclude:e.exclude??"",caseSensitive:e.caseSensitive===!0,wholeWord:e.wholeWord===!0,limit:e.limit??50,regex:e.regex===!0,condition:e.condition,fallbacks:e.fallbacks??[]}}c(ne,"normalizeRecipe");var $=class extends Error{static{c(this,"SearchSnapshotChangedError")}constructor(t){super(`Search result in ${t} changed before its anchors were registered.`),this.name="SearchSnapshotChangedError"}},V=class{constructor(t=te){this.createIdentity=t}static{c(this,"SearchSessionStore")}#t=new Map;#r=new Map;async register(t,n,r,o,i,s={query:t,regex:!0},l){let a=n.map(f=>({...f,source:m.resolve(f.source)})).sort(J),u=await Y(a,i),d=this.createIdentity(t,a,o,s),p=this.#r.get(d)??xe(d,new Set(this.#t.keys())),h={id:p,query:t,matches:a,complete:r,contentBySource:u,recipe:s,...l!==void 0&&{refresh:l},cwd:m.resolve(o)};return this.#r.set(d,p),this.#t.set(p,h),h}async registerIfCurrent(t,n,r,o,i,s,l){try{return await this.register(t,n,r,o,i,s,l)}catch(a){if(a instanceof $)return;throw a}}async observeAfterEdit(t,n){let r=new Set(t.flatMap(i=>{let s=typeof i=="string"?P(i):void 0;return s===void 0?[]:[s.id]})),o=[];for(let i of r){let s=this.#t.get(i);if(s===void 0)continue;let l={sessionId:i,query:s.recipe.originalQuery??s.query,scope:ne(s.recipe,s.cwd)};try{let a=s.refresh===void 0?await _(s.recipe,s.cwd,n):await s.refresh(n);o.push({...l,matches:a.matches.length,complete:a.complete,notices:a.notices})}catch(a){o.push({...l,error:a instanceof Error?a.message:String(a)})}}return o}anchorResolver(){return{id:"search",description:["`SEARCH#HASH:N:line` selects one result's full line; `SEARCH#HASH:N:match` selects its exact match.","`SEARCH#HASH:all:line` selects each unique containing line; `SEARCH#HASH:all:match` selects every exact match.","Omit `path` when `all` spans files."].join(`
|
|
2
|
-
`),renderFull(t){return t},renderCompact(t){let n=P(t);return n===void 0?"selected result":n.selector==="all"?n.mode==="match"?"all matches":"all lines":n.mode==="match"?`match ${String(n.selector)}`:`line ${String(n.selector)}`},tryResolve:c((t,n)=>this.#i(t,n.source,n.signal),"tryResolve")}}resourceResolver(){return{id:"search-targets",tryResolve:c((t,n)=>this.#s(t,n.cwd),"tryResolve")}}async#i(t,n,r){let o=P(t);if(o===void 0)return{kind:"not-handled"};let i=this.#t.get(o.id);if(i===void 0)return R();if(o.selector==="all"&&!i.complete)return x();let s=m.resolve(n),l=i;if(o.selector==="all"){if(i.refreshedComplete?.complete===!0)l=i.refreshedComplete;else if(i.refreshedComplete!==void 0&&(l=await this.#n(i,r),!l.complete))return x()}let a=B(l,o.selector,o.mode),u=a.filter(p=>p.source===s);if(u.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};let d=await D(s,r);if(d===void 0)return R(b(u[0]).lineNumber);if(o.selector==="all"&&d!==l.contentBySource.get(s)){if(l=await this.#n(i,r),!l.complete)return x();a=B(l,o.selector,o.mode),u=a.filter(p=>p.source===s)}if(u.length===0)return{kind:"rejected",rejection:{code:"missing",reason:"search anchor does not select this resource"}};if(o.selector!=="all"&&d!==i.contentBySource.get(s))return R(b(u[0]).lineNumber);let g=w(s,d);return{kind:"resolved",anchor:new W(t,s,u.map(p=>X(g,p,o.mode)))}}async#s(t,n){let r=P(t);if(r===void 0)return{kind:"not-handled"};let o=this.#t.get(r.id);if(o===void 0)return R();if(r.selector==="all"&&!o.complete)return x();let i=o;if(r.selector==="all"){if(o.refreshedComplete?.complete===!0)i=o.refreshedComplete;else if(o.refreshedComplete!==void 0&&(i=await this.#n(o),!i.complete))return x();let u=new Set(B(i,r.selector,r.mode).map(d=>d.source));for(let d of u)if(await D(d)!==i.contentBySource.get(d)){if(i=await this.#n(o),!i.complete)return x();break}}let s=B(i,r.selector,r.mode);if(r.selector!=="all"){let u=s[0]?.source;if(u!==void 0&&await D(u)!==i.contentBySource.get(u))return R(s[0]?.lineNumber)}let l=new Map;for(let u of s){let d=l.get(u.source)??[];d.push(X(w(u.source,i.contentBySource.get(u.source)??u.lineText),u,r.mode)),l.set(u.source,d)}let a=[...l].map(([u,d])=>({source:u,ranges:d,expectedContent:i.contentBySource.get(u)}));return a.length===0?{kind:"rejected",rejection:{code:"missing",reason:"search anchor has no matches"}}:{kind:"resolved",targets:a}}async#n(t,n){let r=t.refresh===void 0?await _(t.recipe,t.cwd,n):await t.refresh(n),o=r.matches.map(s=>({...s,source:m.resolve(s.source)})).sort(J),i={matches:o,complete:r.complete,contentBySource:await Y(o,n)};return this.#t.set(t.id,{...t,refreshedComplete:i}),i}};function P(e){let t=be.exec(e);if(t!==null)return{id:b(t[1]),selector:t[2]==="all"?"all":Number(t[2]),mode:t[3]==="line"?"line":"match"}}c(P,"parseSearchAnchor");function B(e,t,n){let r=t==="all"?e.matches:[e.matches[t-1]].filter(we);if(n==="match"||t!=="all")return r;let o=new Set;return r.flatMap(i=>{let s=w(i.source,e.contentBySource.get(i.source)??i.lineText),l=re(i);return s.lines.slice(i.lineNumber-1,l).flatMap(a=>{let u=`${i.source}\0${String(a.lineNumber)}`;return o.has(u)?[]:(o.add(u),[{...i,lineNumber:a.lineNumber,endLineNumber:a.lineNumber,startColumn:0,endColumn:a.content.length,lineText:a.content,matchedText:a.content}])})})}c(B,"selectMatches");function we(e){return e!==void 0}c(we,"isMatch");function re(e){let t=e.endLineNumber??e.lineNumber;return t>e.lineNumber&&e.endColumn===0?t-1:t}c(re,"lastContainingLine");function X(e,t,n){if(n==="match")return{start:{lineNumber:t.lineNumber,column:t.startColumn},end:{lineNumber:t.endLineNumber??t.lineNumber,column:t.endColumn}};let r=re(t),o=b(e.lines[r-1]);return{start:{lineNumber:t.lineNumber,column:0},end:{lineNumber:r+(o.lineEnding.length>0?1:0),column:o.lineEnding.length>0?0:o.content.length},linewise:!0}}c(X,"selectionRange");function Te(e,t){let n=t.endLineNumber??t.lineNumber;return e.lines.slice(t.lineNumber-1,n).map(r=>{let o=r.lineNumber===t.lineNumber?t.startColumn:0,i=r.lineNumber===n?t.endColumn:r.content.length;return r.content.slice(o,i)+(r.lineNumber===n?"":r.lineEnding)}).join("")}c(Te,"matchedSourceText");async function Y(e,t){let n=[...new Set(e.map(i=>i.source))],r=await Promise.allSettled(n.map(async i=>{let s=await Z(i,{encoding:"utf8",...t!==void 0&&{signal:t}}),l=w(i,s);for(let a of e.filter(u=>u.source===i))if(l.lines[a.lineNumber-1]?.content!==a.lineText||Te(l,a)!==a.matchedText)throw new $(i);return[i,s]})),o=new Map;for(let i of r){if(i.status==="rejected")throw i.reason;o.set(...i.value)}return o}c(Y,"snapshotContents");async function D(e,t){try{return await Z(e,{encoding:"utf8",...t!==void 0&&{signal:t}})}catch{return}}c(D,"readCurrent");function R(e=1){return{kind:"rejected",rejection:{code:"stale",reason:"search anchor is stale",contextRange:{offset:Math.max(1,e-2),limit:5}}}}c(R,"staleAnchor");function x(){return{kind:"rejected",rejection:{code:"missing",reason:"search did not register an all anchor because its result was limited"}}}c(x,"missingCompleteAnchor");function ke(e){if(e.length===0)return".";let t=m.dirname(m.resolve(b(e[0])));for(let n of e.slice(1)){let r=m.resolve(n);for(;!Re(t,r);){let o=m.dirname(t);if(o===t)return t;t=o}}return t}c(ke,"commonSourceDirectory");function Re(e,t){let n=m.relative(e,t);return n!==".."&&!n.startsWith(`..${m.sep}`)&&!m.isAbsolute(n)}c(Re,"isWithin");function J(e,t){return e.source.localeCompare(t.source)||e.lineNumber-t.lineNumber||e.startColumn-t.startColumn||(e.endLineNumber??e.lineNumber)-(t.endLineNumber??t.lineNumber)||e.endColumn-t.endColumn}c(J,"compareMatches");export{Q as a,Je as b,_ as c,Ye as d,te as e,xe as f,$ as g,V as h};
|
package/dist/entry-87.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as r}from"./chunk-2P2OGO3G.js";import{p as e}from"./chunk-ZPT5D4VP.js";import{a as t}from"./chunk-EI7MMDWY.js";var n={target:{provider:"web",capability:"read"},converter:e(),priority:300};async function i(o){await r(o,n)}t(i,"registerWebText");export{i as default};
|
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
# Apply scripting reference
|
|
2
|
-
|
|
3
|
-
## Before using Apply
|
|
4
|
-
|
|
5
|
-
Read this guide before writing an Apply script. Use Apply only for computed or conditional edits, selection composition, explicit checkpoints, or one coherent cross-file transaction.
|
|
6
|
-
|
|
7
|
-
When each change is already known and independent, use standalone text tools instead. Submit those tools together in one assistant response; they share the original file snapshots and work for several edits in one file or across files. Do not write a JavaScript Apply program merely to group straightforward replacements, insertions, removals, copies, or moves. Read `docs:editing` for that workflow.
|
|
8
|
-
|
|
9
|
-
Open every source first, select from immutable snapshots, stage operations, and let normal completion commit once. A thrown script commits no pending operations. Check every operation outcome: independent valid edits may succeed when another edit is rejected. Keep each returned `APPLY#` receipt for atomic undo of that checkpoint.
|
|
10
|
-
|
|
11
|
-
## Choosing a selection
|
|
12
|
-
|
|
13
|
-
Choose boundaries from the request's source of truth. Prefer content-based selections when content identifies the target:
|
|
14
|
-
|
|
15
|
-
1. Use `find` for exact occurrences.
|
|
16
|
-
2. Use `between` for blocks identified by opening and closing content.
|
|
17
|
-
3. Use `select` for a structured search result.
|
|
18
|
-
4. Use `within`, `slice`, or `union` to narrow or combine those selections.
|
|
19
|
-
5. Use `linesOf` or `between(..., { lines: true })` when the operation must include complete lines.
|
|
20
|
-
6. Use `line(first, last)` only when the user supplied those line numbers or you independently verified both inclusive bounds.
|
|
21
|
-
|
|
22
|
-
Do not infer line ranges from the starting lines of nearby blocks. Do not include a following blank line unless the requested change includes that separator.
|
|
23
|
-
|
|
24
|
-
Selections are immutable and belong to one file snapshot. A flush refreshes open documents and makes earlier selections stale. Build new selections after each checkpoint.
|
|
25
|
-
|
|
26
|
-
## Read-only helpers
|
|
27
|
-
|
|
28
|
-
### `read({...})`
|
|
29
|
-
|
|
30
|
-
Use it to inspect a resource from inside an Apply script. It accepts the same arguments as the standalone Read tool and records its result automatically.
|
|
31
|
-
|
|
32
|
-
```js
|
|
33
|
-
read({ path: "config.json", offset: 1, limit: 40 });
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Effect: reads the requested window without staging a mutation.
|
|
37
|
-
|
|
38
|
-
### `search({...})`
|
|
39
|
-
|
|
40
|
-
Use it to discover files, text, symbols, or structures before opening a document. It accepts the standalone Search arguments and records its result automatically.
|
|
41
|
-
|
|
42
|
-
```js
|
|
43
|
-
const matches = search({ query: '"oldName"', path: "src" });
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Effect: returns structured matches without changing files.
|
|
47
|
-
|
|
48
|
-
### `diff({before, after})`
|
|
49
|
-
|
|
50
|
-
Use it to compare two sources before deciding what to edit. It accepts the standalone Diff arguments and records its result automatically.
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
diff({ before: "old\n", after: "new\n" });
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Effect: returns a read-only textual comparison.
|
|
57
|
-
|
|
58
|
-
## Opening documents
|
|
59
|
-
|
|
60
|
-
### `open(path | { path, views? })`
|
|
61
|
-
|
|
62
|
-
Use it before selecting or editing an existing text resource.
|
|
63
|
-
|
|
64
|
-
```js
|
|
65
|
-
const file = open("src/example.ts");
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
Effect: creates an editor handle backed by an immutable snapshot. `file.source`, `file.content`, and `file.lines` expose its source, full canonical text, and line count. Supplying `views` changes how the source is opened when that resource supports views.
|
|
69
|
-
|
|
70
|
-
## Selection primitives
|
|
71
|
-
|
|
72
|
-
### `file.find(text)`
|
|
73
|
-
|
|
74
|
-
Use it when an exact string identifies one or more targets.
|
|
75
|
-
|
|
76
|
-
```js
|
|
77
|
-
const names = file.find("oldName");
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Effect: returns every exact occurrence in source order. It does not silently choose one occurrence. Use `slice` or `within` when only some occurrences are intended.
|
|
81
|
-
|
|
82
|
-
### `file.select(searchMatch)`
|
|
83
|
-
|
|
84
|
-
Use it to turn one structured Search match into a selection in its source document.
|
|
85
|
-
|
|
86
|
-
```js
|
|
87
|
-
const target = file.select(matches[0]);
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
Effect: maps the match's line and column range to the open snapshot. It rejects matches from another file and matches whose recorded text is stale.
|
|
91
|
-
|
|
92
|
-
### `file.between(start, end, options?)`
|
|
93
|
-
|
|
94
|
-
Use it for blocks whose boundaries are identified by content or existing selections.
|
|
95
|
-
|
|
96
|
-
```js
|
|
97
|
-
const block = file.between("BEGIN", "END", { lines: true });
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Effect: pairs each start with the first end after that start, then continues with later non-overlapping pairs. By default both boundaries are included. `{ inside: true }` excludes both boundaries. `{ lines: true }` expands through the complete lines containing both boundaries, including the closing line's newline but not a following blank separator. `inside` and `lines` cannot be combined.
|
|
101
|
-
|
|
102
|
-
If repeated boundaries produce several blocks, narrow the result with `slice` rather than assuming only one pair exists.
|
|
103
|
-
|
|
104
|
-
### `file.line(first, last?)`
|
|
105
|
-
|
|
106
|
-
Use it only when the 1-based line bounds are authoritative or already verified.
|
|
107
|
-
|
|
108
|
-
```js
|
|
109
|
-
const header = file.line(1, 3);
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
Effect: selects complete lines from `first` through `last`, inclusive. Omitting `last` selects one line. Invalid, negative, reversed, or out-of-range bounds are rejected.
|
|
113
|
-
|
|
114
|
-
### `file.start()` and `file.end()`
|
|
115
|
-
|
|
116
|
-
Use them as zero-width destinations when `copy` or `move` should insert at the beginning or end of a document.
|
|
117
|
-
|
|
118
|
-
```js
|
|
119
|
-
copy(source.find("preamble"), target.start());
|
|
120
|
-
move(source.find("appendix"), target.end());
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
Effect: returns a zero-width linewise selection at byte zero or end of file. These are positions, not existing text.
|
|
124
|
-
|
|
125
|
-
### `file.before(selection)` and `file.after(selection)`
|
|
126
|
-
|
|
127
|
-
Use them to convert selected content into insertion positions.
|
|
128
|
-
|
|
129
|
-
```js
|
|
130
|
-
const destination = file.before(file.find("export default"));
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
Effect: returns zero-width positions immediately before or after every selected range. Linewise selections retain linewise insertion behavior.
|
|
134
|
-
|
|
135
|
-
### `file.slice(selection, start?, end?)`
|
|
136
|
-
|
|
137
|
-
Use it to choose occurrences by position after a broader selector has found them.
|
|
138
|
-
|
|
139
|
-
```js
|
|
140
|
-
const first = file.slice(file.find("token"), 0, 1);
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
Effect: returns the same ranges that normal JavaScript array `slice(start, end)` would retain. It does not alter the document.
|
|
144
|
-
|
|
145
|
-
### `file.union(...selections)`
|
|
146
|
-
|
|
147
|
-
Use it to combine separate selections from the same snapshot into one mutation target.
|
|
148
|
-
|
|
149
|
-
```js
|
|
150
|
-
const targets = file.union(file.find("alpha"), file.find("beta"));
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
Effect: sorts ranges, removes exact duplicates, and rejects overlaps. It never turns sparse targets into one wide range containing the text between them.
|
|
154
|
-
|
|
155
|
-
### `file.within(candidates, scopes)`
|
|
156
|
-
|
|
157
|
-
Use it to keep only candidates fully contained by selected scopes.
|
|
158
|
-
|
|
159
|
-
```js
|
|
160
|
-
const localNames = file.within(file.find("name"), file.between("class A", "}"));
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
Effect: returns each candidate whose complete range lies inside at least one scope.
|
|
164
|
-
|
|
165
|
-
### `file.linesOf(selection)`
|
|
166
|
-
|
|
167
|
-
Use it when content matches identify targets but the operation must affect their complete containing lines.
|
|
168
|
-
|
|
169
|
-
```js
|
|
170
|
-
const declarations = file.linesOf(file.find("const obsolete ="));
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
Effect: expands every range to its containing line, preserves line endings, and removes duplicate line ranges.
|
|
174
|
-
|
|
175
|
-
## Text mutations
|
|
176
|
-
|
|
177
|
-
Every text mutation stages one operation for every selected range. Empty selections produce a warning rather than a guessed edit. Global forms infer the document from the SelectionSet; document methods provide the same behavior and may also accept a directly resolvable string target.
|
|
178
|
-
|
|
179
|
-
### `replace(selection, text)` and `file.replace(target, text)`
|
|
180
|
-
|
|
181
|
-
Use them to replace selected text.
|
|
182
|
-
|
|
183
|
-
```js
|
|
184
|
-
replace(file.find("oldName"), "newName");
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
Effect: replaces every selected range with `text` in one transaction.
|
|
188
|
-
|
|
189
|
-
### `remove(selection)` and `file.remove(target)`
|
|
190
|
-
|
|
191
|
-
Use them to remove selected text, not files.
|
|
192
|
-
|
|
193
|
-
```js
|
|
194
|
-
remove(file.linesOf(file.find("obsolete();")));
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
Effect: replaces every selected range with an empty string. Use precise sparse selections instead of a broad range spanning unrelated content.
|
|
198
|
-
|
|
199
|
-
### `insertBefore(selection, text)` and `file.insertBefore(target, text)`
|
|
200
|
-
|
|
201
|
-
Use them to insert text immediately before each selected range.
|
|
202
|
-
|
|
203
|
-
```js
|
|
204
|
-
insertBefore(file.linesOf(file.find("function run")), "// Entry point\n");
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
Effect: keeps the selected text and inserts before it. For linewise selections, Apply supplies the needed line boundary. Pass `{ separation: "blank-line" }` as a third argument to add only missing blank lines around a separate block; the default is `"line"`. An empty insert is rejected.
|
|
208
|
-
|
|
209
|
-
### `insertAfter(selection, text)` and `file.insertAfter(target, text)`
|
|
210
|
-
|
|
211
|
-
Use them to insert text immediately after each selected range.
|
|
212
|
-
|
|
213
|
-
```js
|
|
214
|
-
insertAfter(file.linesOf(file.find("import value")), 'import other from "./other.js";\n');
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
Effect: keeps the selected text and inserts after it. For linewise selections, Apply supplies the needed line boundary, including at an unterminated final line.
|
|
218
|
-
|
|
219
|
-
## Moving and copying text
|
|
220
|
-
|
|
221
|
-
### `copy(source, destination)`
|
|
222
|
-
|
|
223
|
-
Use it to duplicate selected text within one file or across open files.
|
|
224
|
-
|
|
225
|
-
```js
|
|
226
|
-
copy(source.find("sharedValue"), target.end());
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
Effect: concatenates source ranges in selection order. A zero-width destination inserts that text; a non-empty destination replaces it. Source text remains unchanged.
|
|
230
|
-
|
|
231
|
-
### `move(source, destination)`
|
|
232
|
-
|
|
233
|
-
Use it to relocate selected text within one file or across open files.
|
|
234
|
-
|
|
235
|
-
```js
|
|
236
|
-
move(source.between("BEGIN", "END", { lines: true }), target.end());
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
Effect: performs the same destination insertion or replacement as `copy`, then removes every source range in the same coherent transaction. Prefer linewise selections when moving complete blocks so separators remain stable.
|
|
240
|
-
|
|
241
|
-
## Whole-file operations
|
|
242
|
-
|
|
243
|
-
### `createFile(path, content)`
|
|
244
|
-
|
|
245
|
-
Use it to create a new file from complete content.
|
|
246
|
-
|
|
247
|
-
```js
|
|
248
|
-
createFile("src/new.ts", "export const value = 1;\n");
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
Effect: stages creation at `path`. It does not overwrite an existing file.
|
|
252
|
-
|
|
253
|
-
### `file.delete()` and `deleteFile(path)`
|
|
254
|
-
|
|
255
|
-
Use `file.delete()` when an opened file should be deleted after its earlier staged operations. Use `deleteFile(path)` when no document handle is needed.
|
|
256
|
-
|
|
257
|
-
```js
|
|
258
|
-
const obsolete = open("src/obsolete.ts");
|
|
259
|
-
obsolete.delete();
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
Effect: stages whole-file deletion. This is distinct from `remove(selection)`, which removes text.
|
|
263
|
-
|
|
264
|
-
### `copyFile(path, target, { overwrite? })`
|
|
265
|
-
|
|
266
|
-
Use it to copy one complete file.
|
|
267
|
-
|
|
268
|
-
```js
|
|
269
|
-
copyFile("config.example.json", "config.json");
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
Effect: stages a file copy. An existing regular target is rejected unless `overwrite: true` is explicit.
|
|
273
|
-
|
|
274
|
-
### `moveFile(path, target, { overwrite? })`
|
|
275
|
-
|
|
276
|
-
Use it to rename or relocate one complete file.
|
|
277
|
-
|
|
278
|
-
```js
|
|
279
|
-
moveFile("src/old.ts", "src/new.ts");
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
Effect: stages a file move. An existing regular target is rejected unless `overwrite: true` is explicit.
|
|
283
|
-
|
|
284
|
-
## Checkpoints and transaction guarantees
|
|
285
|
-
|
|
286
|
-
### `file.flush()`
|
|
287
|
-
|
|
288
|
-
Use it to checkpoint independent operations staged for one document when later work needs a refreshed snapshot.
|
|
289
|
-
|
|
290
|
-
```js
|
|
291
|
-
file.replace(file.find("old"), "new");
|
|
292
|
-
file.flush();
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
Effect: commits that file's independent pending operations, refreshes its open handle, and makes its earlier selections stale. If the file participates in a pending cross-file `copy` or `move`, nothing for that file is flushed so the transfer keeps one coherent snapshot.
|
|
296
|
-
|
|
297
|
-
### `flush()`
|
|
298
|
-
|
|
299
|
-
Use it only when the script deliberately needs a global checkpoint before continuing.
|
|
300
|
-
|
|
301
|
-
```js
|
|
302
|
-
flush();
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
Effect: commits every pending operation, refreshes affected open handles, and can return an `APPLY#` receipt. Normal successful completion already performs one global flush. A later thrown error does not undo an earlier explicit checkpoint.
|
|
306
|
-
|
|
307
|
-
## Failure, ordering, and undo
|
|
308
|
-
|
|
309
|
-
Operations are evaluated against their captured snapshots, not against text shifted by earlier staged edits. This makes several non-overlapping edits safe without compensating line numbers. Overlapping or stale selections are rejected rather than guessed.
|
|
310
|
-
|
|
311
|
-
A successful checkpoint may return an `APPLY#` receipt. Restore every path touched by that checkpoint atomically with:
|
|
312
|
-
|
|
313
|
-
```js
|
|
314
|
-
undo({ transaction: "APPLY#..." });
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
Separate explicit checkpoints can produce separate receipts. Do not assume one receipt covers changes committed by an earlier flush.
|
|
318
|
-
|
|
319
|
-
## Standalone anchors and specialized resources
|
|
320
|
-
|
|
321
|
-
Standalone text tools support line anchors, syntax-scope anchors, search selections, and unique exact strings. With an `end` selector, they operate on complete lines through the line containing the end boundary. Without `end`, an exact string selects only that fragment.
|
|
322
|
-
|
|
323
|
-
When a standalone text tool allows an omitted path, it can inherit the source identified by its anchor, the last read, or the preceding edit in the same batch. Supply the path explicitly when that inheritance would be ambiguous.
|
|
324
|
-
|
|
325
|
-
Some resources attach non-text actions to the same tools:
|
|
326
|
-
|
|
327
|
-
- `shell:<session>` — `write` sends exact input, `insert` sends named keys, and `delete` terminates the session.
|
|
328
|
-
- `debug:<session>` — `insert` controls the debugger and `delete` removes a breakpoint or terminates the session.
|
|
329
|
-
- `symbol:<file>#<selector>#name` — `replace` performs a native language-server rename when available.
|
|
330
|
-
|
|
331
|
-
Read `docs:terminal`, `docs:debugger`, or `docs:search-code` before using those specialized resources.
|
|
332
|
-
|
|
333
|
-
Never guess after a stale snapshot, empty selection, ambiguous target, or unknown rollback effect.
|