pi-agent-ide 0.1.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/LICENSE +21 -0
- package/README.md +53 -0
- package/assets/banner.png +0 -0
- package/docs/architecture.md +100 -0
- package/docs/configuration.md +104 -0
- package/docs/development.md +102 -0
- package/docs/evaluation.md +14 -0
- package/docs/extensions.md +298 -0
- package/docs/tools.md +104 -0
- package/node_modules/pi-agent-filesystem/index.ts +60 -0
- package/node_modules/pi-agent-filesystem/package.json +23 -0
- package/node_modules/pi-agent-filesystem/src/resolver.ts +175 -0
- package/node_modules/pi-agent-filesystem-image/index.ts +14 -0
- package/node_modules/pi-agent-filesystem-image/package.json +20 -0
- package/node_modules/pi-agent-filesystem-pdf/index.ts +14 -0
- package/node_modules/pi-agent-filesystem-pdf/package.json +17 -0
- package/node_modules/pi-agent-filesystem-text/index.ts +23 -0
- package/node_modules/pi-agent-filesystem-text/package.json +20 -0
- package/node_modules/pi-agent-ide-ast/index.ts +1 -0
- package/node_modules/pi-agent-ide-ast/package.json +39 -0
- package/node_modules/pi-agent-ide-ast/src/api/scope.ts +1 -0
- package/node_modules/pi-agent-ide-ast/src/ast/collect-files.ts +24 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +374 -0
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +813 -0
- package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +30 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +85 -0
- package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +69 -0
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +221 -0
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +45 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +141 -0
- package/node_modules/pi-agent-ide-changes/index.ts +68 -0
- package/node_modules/pi-agent-ide-changes/package.json +29 -0
- package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +103 -0
- package/node_modules/pi-agent-ide-changes/src/changes/change-groups.ts +309 -0
- package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +223 -0
- package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +105 -0
- package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +325 -0
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +232 -0
- package/node_modules/pi-agent-ide-changes/src/index-mutation-queue.ts +11 -0
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +88 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +116 -0
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +153 -0
- package/node_modules/pi-agent-ide-formatter/index.ts +33 -0
- package/node_modules/pi-agent-ide-formatter/package.json +14 -0
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +50 -0
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +30 -0
- package/node_modules/pi-agent-ide-formatter/src/types.ts +10 -0
- package/node_modules/pi-agent-ide-lint/index.ts +237 -0
- package/node_modules/pi-agent-ide-lint/package.json +19 -0
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +160 -0
- package/node_modules/pi-agent-ide-lint/src/command-runner.ts +51 -0
- package/node_modules/pi-agent-ide-lint/src/registry.ts +30 -0
- package/node_modules/pi-agent-ide-lint/src/types.ts +10 -0
- package/node_modules/pi-agent-ide-lsp/index.ts +250 -0
- package/node_modules/pi-agent-ide-lsp/package.json +23 -0
- package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +139 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +463 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +577 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +179 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +59 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/language-map.ts +57 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +85 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +485 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +85 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +97 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +50 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +149 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +151 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +95 -0
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +42 -0
- package/node_modules/pi-agent-image/package.json +18 -0
- package/node_modules/pi-agent-image/src/image-converter.ts +318 -0
- package/node_modules/pi-agent-image/src/index.ts +6 -0
- package/node_modules/pi-agent-pdf/package.json +16 -0
- package/node_modules/pi-agent-pdf/src/index.ts +5 -0
- package/node_modules/pi-agent-pdf/src/pdf-converter.ts +197 -0
- package/node_modules/pi-agent-read/index.ts +1 -0
- package/node_modules/pi-agent-read/package.json +41 -0
- package/node_modules/pi-agent-read/src/api/connect-plugin.ts +67 -0
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +67 -0
- package/node_modules/pi-agent-read/src/api/rendering.ts +11 -0
- package/node_modules/pi-agent-read/src/api/tools/read.ts +208 -0
- package/node_modules/pi-agent-read/src/core/extension.ts +40 -0
- package/node_modules/pi-agent-read/src/core/read-core.ts +390 -0
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +193 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +400 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +187 -0
- package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +218 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +828 -0
- package/node_modules/pi-agent-resource/package.json +17 -0
- package/node_modules/pi-agent-resource/src/content-conversion/connect-plugin.ts +84 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-converter.ts +49 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +29 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +73 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-runner.ts +152 -0
- package/node_modules/pi-agent-resource/src/content-conversion/plugin-protocol.ts +74 -0
- package/node_modules/pi-agent-resource/src/content-conversion/validation.ts +149 -0
- package/node_modules/pi-agent-resource/src/content.ts +17 -0
- package/node_modules/pi-agent-resource/src/index.ts +65 -0
- package/node_modules/pi-agent-resource/src/resolver.ts +23 -0
- package/node_modules/pi-agent-resource/src/resource.ts +41 -0
- package/node_modules/pi-agent-resource/src/validation.ts +139 -0
- package/node_modules/pi-agent-search/index.ts +1 -0
- package/node_modules/pi-agent-search/package.json +35 -0
- package/node_modules/pi-agent-search/src/api/connect-plugin.ts +61 -0
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +60 -0
- package/node_modules/pi-agent-search/src/api/search.ts +91 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +126 -0
- package/node_modules/pi-agent-search/src/core/search-core.ts +400 -0
- package/node_modules/pi-agent-search-semantic/index.ts +105 -0
- package/node_modules/pi-agent-search-semantic/package.json +17 -0
- package/node_modules/pi-agent-search-text/index.ts +54 -0
- package/node_modules/pi-agent-search-text/package.json +33 -0
- package/node_modules/pi-agent-search-text/src/file-search.ts +105 -0
- package/node_modules/pi-agent-search-text/src/lucene-query-parser.d.ts +22 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +192 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +295 -0
- package/node_modules/pi-agent-search-text/src/search-query.ts +139 -0
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +420 -0
- package/node_modules/pi-agent-search-text/src/search-result.ts +193 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +338 -0
- package/node_modules/pi-agent-search-web/index.ts +74 -0
- package/node_modules/pi-agent-search-web/package.json +19 -0
- package/node_modules/pi-agent-search-web/src/config.ts +499 -0
- package/node_modules/pi-agent-search-web/src/providers/duckduckgo-html.ts +78 -0
- package/node_modules/pi-agent-search-web/src/providers/endpoints.ts +89 -0
- package/node_modules/pi-agent-search-web/src/providers/request.ts +430 -0
- package/node_modules/pi-agent-search-web/src/providers/response.ts +402 -0
- package/node_modules/pi-agent-search-web/src/search-format.ts +29 -0
- package/node_modules/pi-agent-search-web/src/search.ts +434 -0
- package/node_modules/pi-agent-search-web/src/types.ts +153 -0
- package/node_modules/pi-agent-text/package.json +18 -0
- package/node_modules/pi-agent-text/src/index.ts +31 -0
- package/node_modules/pi-agent-text/src/presented-text.ts +24 -0
- package/node_modules/pi-agent-text/src/source-line.ts +49 -0
- package/node_modules/pi-agent-text/src/text-anchor.ts +157 -0
- package/node_modules/pi-agent-text/src/text-converter.ts +109 -0
- package/node_modules/pi-agent-text/src/text-document.ts +149 -0
- package/node_modules/pi-agent-text-anchor-constant/index.ts +30 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +17 -0
- package/node_modules/pi-agent-text-anchor-constant/src/resolver.ts +47 -0
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +48 -0
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +24 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +110 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +47 -0
- package/node_modules/pi-agent-text-editor/index.ts +19 -0
- package/node_modules/pi-agent-text-editor/package.json +92 -0
- package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +24 -0
- package/node_modules/pi-agent-text-editor/src/api/connect-plugin.ts +67 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +19 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +64 -0
- package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +46 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +46 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +30 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +23 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +180 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +217 -0
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +147 -0
- package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -0
- package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +121 -0
- package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +11 -0
- package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +39 -0
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +59 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +150 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +386 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +129 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +359 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +648 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +117 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-recovery.ts +24 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +381 -0
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +273 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +607 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +127 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +45 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +432 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +115 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +2348 -0
- package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +28 -0
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +756 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1235 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +43 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +308 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +467 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +16 -0
- package/node_modules/pi-agent-text-editor/src/tools/extension.ts +19 -0
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +106 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +121 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +79 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +56 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +142 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +72 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +28 -0
- package/node_modules/pi-agent-text-editor-argument-order/index.ts +29 -0
- package/node_modules/pi-agent-text-editor-argument-order/package.json +16 -0
- package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +112 -0
- package/node_modules/pi-agent-text-editor-overwrite/index.ts +391 -0
- package/node_modules/pi-agent-text-editor-overwrite/package.json +16 -0
- package/node_modules/pi-agent-text-editor-renderer/index.ts +22 -0
- package/node_modules/pi-agent-text-editor-renderer/package.json +21 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +452 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +271 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-theme.ts +411 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +38 -0
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +205 -0
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +229 -0
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +407 -0
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +153 -0
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +8 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +728 -0
- package/node_modules/pi-agent-text-editor-renderer/src/typing-interpolation.ts +219 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +375 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +17 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +17 -0
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +418 -0
- package/node_modules/pi-agent-web/index.ts +37 -0
- package/node_modules/pi-agent-web/package.json +24 -0
- package/node_modules/pi-agent-web/src/resolver.ts +182 -0
- package/node_modules/pi-agent-web-html/index.ts +15 -0
- package/node_modules/pi-agent-web-html/package.json +18 -0
- package/node_modules/pi-agent-web-html/src/extract-readable-html.ts +101 -0
- package/node_modules/pi-agent-web-html/src/html-converter.ts +91 -0
- package/node_modules/pi-agent-web-image/index.ts +14 -0
- package/node_modules/pi-agent-web-image/package.json +17 -0
- package/node_modules/pi-agent-web-pdf/index.ts +14 -0
- package/node_modules/pi-agent-web-pdf/package.json +17 -0
- package/node_modules/pi-agent-web-text/index.ts +14 -0
- package/node_modules/pi-agent-web-text/package.json +17 -0
- package/package.json +176 -0
- package/src/api/code-view.ts +25 -0
- package/src/api/connect-plugin.ts +64 -0
- package/src/api/plugin-protocol.ts +63 -0
- package/src/api/read.ts +5 -0
- package/src/api/resource.ts +2 -0
- package/src/api/search.ts +4 -0
- package/src/api/text-editor.ts +3 -0
- package/src/api/text.ts +2 -0
- package/src/api/toolchain.ts +24 -0
- package/src/code-view/diagnostic-view.ts +82 -0
- package/src/code-view/reference.ts +113 -0
- package/src/code-view/source-view.ts +229 -0
- package/src/composite/builtin-extensions.ts +68 -0
- package/src/composite/config.ts +94 -0
- package/src/composite/selection.ts +66 -0
- package/src/core/extension.ts +48 -0
- package/src/core/ide-core.ts +117 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +60 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +20 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +17 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/index.ts +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +20 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +175 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +37 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +24 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/index.ts +15 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +18 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/extract-readable-html.ts +101 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +91 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +17 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +17 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +17 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +182 -0
- package/src/extensions/pi-agent-read/index.ts +1 -0
- package/src/extensions/pi-agent-read/package.json +41 -0
- package/src/extensions/pi-agent-read/src/api/connect-plugin.ts +67 -0
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +67 -0
- package/src/extensions/pi-agent-read/src/api/rendering.ts +11 -0
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +208 -0
- package/src/extensions/pi-agent-read/src/core/extension.ts +40 -0
- package/src/extensions/pi-agent-read/src/core/read-core.ts +390 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +193 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +400 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +187 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +218 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +828 -0
- package/src/extensions/pi-agent-search/index.ts +1 -0
- package/src/extensions/pi-agent-search/package.json +35 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/index.ts +105 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/package.json +17 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +54 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +33 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +105 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/lucene-query-parser.d.ts +22 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +192 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +295 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +139 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +420 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +193 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +338 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/index.ts +74 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/package.json +19 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/config.ts +499 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/duckduckgo-html.ts +78 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/endpoints.ts +89 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/request.ts +430 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/response.ts +402 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search-format.ts +29 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search.ts +434 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/types.ts +153 -0
- package/src/extensions/pi-agent-search/src/api/connect-plugin.ts +61 -0
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +60 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +91 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +126 -0
- package/src/extensions/pi-agent-search/src/core/search-core.ts +400 -0
- package/src/extensions/pi-agent-text-editor/index.ts +19 -0
- package/src/extensions/pi-agent-text-editor/package.json +92 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/index.ts +30 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +17 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/src/resolver.ts +47 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +48 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +24 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +110 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +47 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +29 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +16 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +112 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +391 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +16 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +22 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +21 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +452 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +271 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-theme.ts +411 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +38 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +205 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +229 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +407 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +153 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +8 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +728 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/typing-interpolation.ts +219 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +375 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +17 -0
- package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +24 -0
- package/src/extensions/pi-agent-text-editor/src/api/connect-plugin.ts +67 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +19 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +64 -0
- package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +46 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +46 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +30 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +23 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +180 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +217 -0
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +147 -0
- package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -0
- package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +121 -0
- package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +11 -0
- package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +39 -0
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +59 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +150 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +386 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +129 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +359 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +648 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +117 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-recovery.ts +24 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +381 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +273 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +607 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +127 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +45 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +432 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +115 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +2348 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +28 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +756 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1235 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +43 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +308 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +467 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +16 -0
- package/src/extensions/pi-agent-text-editor/src/tools/extension.ts +19 -0
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +106 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +121 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +79 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +56 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +142 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +72 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +28 -0
- package/src/index.ts +1 -0
- package/src/pi-agent-ide.ts +17 -0
- package/src/plugins/pi-agent-ide-ast/index.ts +1 -0
- package/src/plugins/pi-agent-ide-ast/package.json +39 -0
- package/src/plugins/pi-agent-ide-ast/src/api/scope.ts +1 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/collect-files.ts +24 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +374 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +813 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +30 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +85 -0
- package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +69 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +221 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +45 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +141 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +68 -0
- package/src/plugins/pi-agent-ide-changes/package.json +29 -0
- package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +103 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/change-groups.ts +309 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +223 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +105 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +325 -0
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +232 -0
- package/src/plugins/pi-agent-ide-changes/src/index-mutation-queue.ts +11 -0
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +88 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +116 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +153 -0
- package/src/plugins/pi-agent-ide-formatter/index.ts +33 -0
- package/src/plugins/pi-agent-ide-formatter/package.json +14 -0
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +50 -0
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +30 -0
- package/src/plugins/pi-agent-ide-formatter/src/types.ts +10 -0
- package/src/plugins/pi-agent-ide-lint/index.ts +237 -0
- package/src/plugins/pi-agent-ide-lint/package.json +19 -0
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +160 -0
- package/src/plugins/pi-agent-ide-lint/src/command-runner.ts +51 -0
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +30 -0
- package/src/plugins/pi-agent-ide-lint/src/types.ts +10 -0
- package/src/plugins/pi-agent-ide-lsp/index.ts +250 -0
- package/src/plugins/pi-agent-ide-lsp/package.json +23 -0
- package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +139 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +463 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +577 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +179 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +59 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/language-map.ts +57 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +85 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +485 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +85 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +97 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +50 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +149 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +151 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +95 -0
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +42 -0
- package/src/post-edit/gate.ts +153 -0
- package/src/toolchain/diagnostic.ts +7 -0
- package/src/toolchain/gate.ts +322 -0
- package/src/toolchain/registry.ts +223 -0
- package/src/toolchain/types.ts +164 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
|
|
3
|
+
import { TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND } from "#src/api/plugin-protocol.js";
|
|
4
|
+
import { lineAnchor, selectionRange, singleSelection, textSelections } from "#src/tools/text-selection.js";
|
|
5
|
+
|
|
6
|
+
import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
7
|
+
|
|
8
|
+
export const copySchema = Type.Object({
|
|
9
|
+
path: Type.Optional(Type.String({ description: "Source file to copy from" })),
|
|
10
|
+
start: Type.String({ description: "Registered text anchor selecting the first line to copy" }),
|
|
11
|
+
end: Type.Optional(
|
|
12
|
+
Type.String({ description: "Registered text anchor selecting the last line; defaults to start" }),
|
|
13
|
+
),
|
|
14
|
+
target: Type.Optional(Type.String({ description: "Target file; defaults to the source file" })),
|
|
15
|
+
targetStart: Type.String({
|
|
16
|
+
description: "First target line; copied text is inserted after it when targetEnd is omitted",
|
|
17
|
+
}),
|
|
18
|
+
targetEnd: Type.Optional(Type.String({ description: "Last target line; the inclusive target range is replaced" })),
|
|
19
|
+
}, { additionalProperties: false });
|
|
20
|
+
|
|
21
|
+
interface CopyParams
|
|
22
|
+
{
|
|
23
|
+
readonly path?: string;
|
|
24
|
+
readonly start: string;
|
|
25
|
+
readonly end?: string;
|
|
26
|
+
readonly target?: string;
|
|
27
|
+
readonly targetStart: string;
|
|
28
|
+
readonly targetEnd?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const copyMutationTool: TextMutationToolRegistration<typeof copySchema> = {
|
|
32
|
+
name: "copy",
|
|
33
|
+
description: "Copy selected lines and insert them after targetStart, or replace targetStart through targetEnd.",
|
|
34
|
+
parameters: copySchema,
|
|
35
|
+
source: { field: "path", inherited: true, targets: [{ field: "target", fallbackTo: "path" }] },
|
|
36
|
+
anchors: [
|
|
37
|
+
{ field: "start", sourceField: "path", kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND] },
|
|
38
|
+
{
|
|
39
|
+
field: "end",
|
|
40
|
+
sourceField: "path",
|
|
41
|
+
kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND],
|
|
42
|
+
optional: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
field: "targetStart",
|
|
46
|
+
sourceField: "target",
|
|
47
|
+
kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
field: "targetEnd",
|
|
51
|
+
sourceField: "target",
|
|
52
|
+
kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND],
|
|
53
|
+
optional: true,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
pair: ["start", "end"],
|
|
57
|
+
mutate: async (context, params: CopyParams) =>
|
|
58
|
+
{
|
|
59
|
+
const starts = await context.resolveAnchors("start");
|
|
60
|
+
const sourceSelections = textSelections(starts, "start");
|
|
61
|
+
let copied: string;
|
|
62
|
+
|
|
63
|
+
if (sourceSelections === undefined)
|
|
64
|
+
{
|
|
65
|
+
const source = context.sourceFor("path");
|
|
66
|
+
const start = lineAnchor(starts, "start");
|
|
67
|
+
const end = params.end === undefined
|
|
68
|
+
? start
|
|
69
|
+
: lineAnchor(await context.resolveAnchors("end"), "end");
|
|
70
|
+
const sourceDocument = context.documentFor(source);
|
|
71
|
+
copied = sourceDocument.text(sourceDocument.lineRange(start.lineNumber, end.lineNumber));
|
|
72
|
+
}
|
|
73
|
+
else
|
|
74
|
+
{
|
|
75
|
+
if (params.end !== undefined)
|
|
76
|
+
{
|
|
77
|
+
throw new Error("end cannot be combined with a search selection.");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const [source, range] = singleSelection(sourceSelections, "start");
|
|
81
|
+
copied = context.documentFor(source).text(selectionRange(context, source, range));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const targetStarts = await context.resolveAnchors("targetStart");
|
|
85
|
+
const targetSelections = textSelections(targetStarts, "targetStart");
|
|
86
|
+
|
|
87
|
+
if (targetSelections !== undefined)
|
|
88
|
+
{
|
|
89
|
+
if (params.targetEnd !== undefined)
|
|
90
|
+
{
|
|
91
|
+
throw new Error("targetEnd cannot be combined with a search selection.");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const [target, range] = singleSelection(targetSelections, "targetStart");
|
|
95
|
+
const targetDocument = context.documentFor(target);
|
|
96
|
+
const insertion = targetDocument.range(
|
|
97
|
+
range.end.lineNumber,
|
|
98
|
+
range.end.column,
|
|
99
|
+
range.end.lineNumber,
|
|
100
|
+
range.end.column,
|
|
101
|
+
);
|
|
102
|
+
return {
|
|
103
|
+
edits: new Map([[target, { changes: [{ ...insertion, insert: copied }], action: "edited" }]]),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const target = context.sourceFor("target");
|
|
108
|
+
const targetDocument = context.documentFor(target);
|
|
109
|
+
const targetStart = lineAnchor(targetStarts, "targetStart");
|
|
110
|
+
const targetEnd = params.targetEnd === undefined
|
|
111
|
+
? undefined
|
|
112
|
+
: lineAnchor(await context.resolveAnchors("targetEnd"), "targetEnd");
|
|
113
|
+
const change = targetEnd === undefined
|
|
114
|
+
? targetDocument.insertAfterLine(targetStart.lineNumber, copied)
|
|
115
|
+
: targetDocument.replaceLines(targetStart.lineNumber, targetEnd.lineNumber, copied);
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
edits: new Map([[target, { changes: [change], action: "edited" }]]),
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
|
|
3
|
+
import { TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND } from "#src/api/plugin-protocol.js";
|
|
4
|
+
import { lineAnchor, selectionChanges, textSelections } from "#src/tools/text-selection.js";
|
|
5
|
+
|
|
6
|
+
import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
7
|
+
|
|
8
|
+
export const deleteSchema = Type.Object({
|
|
9
|
+
path: Type.Optional(Type.String({ description: "File path to edit" })),
|
|
10
|
+
start: Type.Optional(Type.String({ description: "Registered text anchor selecting the first line to delete" })),
|
|
11
|
+
end: Type.Optional(Type.String({ description: "Registered text anchor selecting the last line to delete" })),
|
|
12
|
+
}, { additionalProperties: false });
|
|
13
|
+
|
|
14
|
+
interface DeleteParams
|
|
15
|
+
{
|
|
16
|
+
readonly path?: string;
|
|
17
|
+
readonly start?: string;
|
|
18
|
+
readonly end?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const deleteMutationTool: TextMutationToolRegistration<typeof deleteSchema> = {
|
|
22
|
+
name: "delete",
|
|
23
|
+
description: "Delete lines selected by registered text anchors.",
|
|
24
|
+
parameters: deleteSchema,
|
|
25
|
+
source: { field: "path", inherited: true },
|
|
26
|
+
anchors: [
|
|
27
|
+
{
|
|
28
|
+
field: "start",
|
|
29
|
+
sourceField: "path",
|
|
30
|
+
kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND],
|
|
31
|
+
optional: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
field: "end",
|
|
35
|
+
sourceField: "path",
|
|
36
|
+
kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND],
|
|
37
|
+
optional: true,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
pair: ["start", "end"],
|
|
41
|
+
mutate: async (context, params: DeleteParams) =>
|
|
42
|
+
{
|
|
43
|
+
if (params.start === undefined)
|
|
44
|
+
{
|
|
45
|
+
throw new Error("start anchor is required.");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const starts = await context.resolveAnchors("start");
|
|
49
|
+
const selections = textSelections(starts, "start");
|
|
50
|
+
|
|
51
|
+
if (selections !== undefined)
|
|
52
|
+
{
|
|
53
|
+
if (params.end !== undefined)
|
|
54
|
+
{
|
|
55
|
+
throw new Error("end cannot be combined with a search selection.");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const changes = selectionChanges(context, selections, "");
|
|
59
|
+
return {
|
|
60
|
+
edits: new Map([...changes].map(([source, sourceChanges]) => [
|
|
61
|
+
source,
|
|
62
|
+
{ changes: sourceChanges, action: "edited" as const },
|
|
63
|
+
])),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const source = context.sourceFor("path");
|
|
68
|
+
const start = lineAnchor(starts, "start");
|
|
69
|
+
const end = params.end === undefined
|
|
70
|
+
? start
|
|
71
|
+
: lineAnchor(await context.resolveAnchors("end"), "end");
|
|
72
|
+
return {
|
|
73
|
+
edits: new Map([[source, {
|
|
74
|
+
changes: [context.documentFor(source).deleteLines(start.lineNumber, end.lineNumber)],
|
|
75
|
+
action: "edited",
|
|
76
|
+
}]]),
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
|
|
3
|
+
import { TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND } from "#src/api/plugin-protocol.js";
|
|
4
|
+
import { insertionChanges, lineAnchor, textSelections } from "#src/tools/text-selection.js";
|
|
5
|
+
|
|
6
|
+
import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
7
|
+
|
|
8
|
+
export const insertSchema = Type.Object({
|
|
9
|
+
path: Type.Optional(Type.String({ description: "File path to edit" })),
|
|
10
|
+
anchor: Type.String({ description: "Registered text anchor; text is inserted after its resolved line" }),
|
|
11
|
+
text: Type.String({ description: "Content to insert" }),
|
|
12
|
+
}, { additionalProperties: false });
|
|
13
|
+
|
|
14
|
+
interface InsertParams
|
|
15
|
+
{
|
|
16
|
+
readonly path?: string;
|
|
17
|
+
readonly anchor: string;
|
|
18
|
+
readonly text: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const insertMutationTool: TextMutationToolRegistration<typeof insertSchema> = {
|
|
22
|
+
name: "insert",
|
|
23
|
+
description: "Insert text after the line resolved by a registered text anchor.",
|
|
24
|
+
parameters: insertSchema,
|
|
25
|
+
source: { field: "path", inherited: true },
|
|
26
|
+
anchors: [{
|
|
27
|
+
field: "anchor",
|
|
28
|
+
sourceField: "path",
|
|
29
|
+
kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND],
|
|
30
|
+
}],
|
|
31
|
+
mutate: async (context, params: InsertParams) =>
|
|
32
|
+
{
|
|
33
|
+
const anchors = await context.resolveAnchors("anchor");
|
|
34
|
+
const selections = textSelections(anchors, "anchor");
|
|
35
|
+
|
|
36
|
+
if (selections !== undefined)
|
|
37
|
+
{
|
|
38
|
+
const changes = insertionChanges(context, selections, params.text);
|
|
39
|
+
return {
|
|
40
|
+
edits: new Map([...changes].map(([source, sourceChanges]) => [
|
|
41
|
+
source,
|
|
42
|
+
{ changes: sourceChanges, action: "edited" as const },
|
|
43
|
+
])),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const source = context.sourceFor("path");
|
|
48
|
+
const anchor = lineAnchor(anchors, "anchor");
|
|
49
|
+
return {
|
|
50
|
+
edits: new Map([[source, {
|
|
51
|
+
changes: [context.documentFor(source).insertAfterLine(anchor.lineNumber, params.text)],
|
|
52
|
+
action: "edited",
|
|
53
|
+
}]]),
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
|
|
3
|
+
import { TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND } from "#src/api/plugin-protocol.js";
|
|
4
|
+
import { lineAnchor, selectionRange, singleSelection, textSelections } from "#src/tools/text-selection.js";
|
|
5
|
+
|
|
6
|
+
import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
7
|
+
import type { TextChange } from "#src/core/text-change-engine.js";
|
|
8
|
+
|
|
9
|
+
export const moveSchema = Type.Object({
|
|
10
|
+
path: Type.Optional(Type.String({ description: "Source file to move from" })),
|
|
11
|
+
start: Type.String({ description: "Registered text anchor selecting the first line to move" }),
|
|
12
|
+
end: Type.Optional(
|
|
13
|
+
Type.String({ description: "Registered text anchor selecting the last line; defaults to start" }),
|
|
14
|
+
),
|
|
15
|
+
target: Type.Optional(Type.String({ description: "Target file; defaults to the source file" })),
|
|
16
|
+
targetStart: Type.String({
|
|
17
|
+
description: "First target line; moved text is inserted after it when targetEnd is omitted",
|
|
18
|
+
}),
|
|
19
|
+
targetEnd: Type.Optional(Type.String({ description: "Last target line; the inclusive target range is replaced" })),
|
|
20
|
+
}, { additionalProperties: false });
|
|
21
|
+
|
|
22
|
+
interface MoveParams
|
|
23
|
+
{
|
|
24
|
+
readonly path?: string;
|
|
25
|
+
readonly start: string;
|
|
26
|
+
readonly end?: string;
|
|
27
|
+
readonly target?: string;
|
|
28
|
+
readonly targetStart: string;
|
|
29
|
+
readonly targetEnd?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const moveMutationTool: TextMutationToolRegistration<typeof moveSchema> = {
|
|
33
|
+
name: "move",
|
|
34
|
+
description: "Move selected lines and insert them after targetStart, or replace targetStart through targetEnd.",
|
|
35
|
+
parameters: moveSchema,
|
|
36
|
+
source: { field: "path", inherited: true, targets: [{ field: "target", fallbackTo: "path" }] },
|
|
37
|
+
anchors: [
|
|
38
|
+
{ field: "start", sourceField: "path", kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND] },
|
|
39
|
+
{
|
|
40
|
+
field: "end",
|
|
41
|
+
sourceField: "path",
|
|
42
|
+
kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND],
|
|
43
|
+
optional: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
field: "targetStart",
|
|
47
|
+
sourceField: "target",
|
|
48
|
+
kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
field: "targetEnd",
|
|
52
|
+
sourceField: "target",
|
|
53
|
+
kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND],
|
|
54
|
+
optional: true,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
pair: ["start", "end"],
|
|
58
|
+
mutate: async (context, params: MoveParams) =>
|
|
59
|
+
{
|
|
60
|
+
const starts = await context.resolveAnchors("start");
|
|
61
|
+
const sourceSelections = textSelections(starts, "start");
|
|
62
|
+
let source: string;
|
|
63
|
+
let copied: string;
|
|
64
|
+
let deletion: TextChange;
|
|
65
|
+
|
|
66
|
+
if (sourceSelections === undefined)
|
|
67
|
+
{
|
|
68
|
+
source = context.sourceFor("path");
|
|
69
|
+
const start = lineAnchor(starts, "start");
|
|
70
|
+
const end = params.end === undefined
|
|
71
|
+
? start
|
|
72
|
+
: lineAnchor(await context.resolveAnchors("end"), "end");
|
|
73
|
+
const sourceDocument = context.documentFor(source);
|
|
74
|
+
const sourceRange = sourceDocument.lineRange(start.lineNumber, end.lineNumber);
|
|
75
|
+
copied = sourceDocument.text(sourceRange);
|
|
76
|
+
deletion = sourceDocument.deleteLines(start.lineNumber, end.lineNumber);
|
|
77
|
+
}
|
|
78
|
+
else
|
|
79
|
+
{
|
|
80
|
+
if (params.end !== undefined)
|
|
81
|
+
{
|
|
82
|
+
throw new Error("end cannot be combined with a search selection.");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const selection = singleSelection(sourceSelections, "start");
|
|
86
|
+
[source] = selection;
|
|
87
|
+
const sourceRange = selectionRange(context, source, selection[1]);
|
|
88
|
+
copied = context.documentFor(source).text(sourceRange);
|
|
89
|
+
deletion = { ...sourceRange, insert: "" };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const targetStarts = await context.resolveAnchors("targetStart");
|
|
93
|
+
const targetSelections = textSelections(targetStarts, "targetStart");
|
|
94
|
+
let target: string;
|
|
95
|
+
let targetChange: TextChange;
|
|
96
|
+
|
|
97
|
+
if (targetSelections === undefined)
|
|
98
|
+
{
|
|
99
|
+
target = context.sourceFor("target");
|
|
100
|
+
const targetDocument = context.documentFor(target);
|
|
101
|
+
const targetStart = lineAnchor(targetStarts, "targetStart");
|
|
102
|
+
const targetEnd = params.targetEnd === undefined
|
|
103
|
+
? undefined
|
|
104
|
+
: lineAnchor(await context.resolveAnchors("targetEnd"), "targetEnd");
|
|
105
|
+
targetChange = targetEnd === undefined
|
|
106
|
+
? targetDocument.insertAfterLine(targetStart.lineNumber, copied)
|
|
107
|
+
: targetDocument.replaceLines(targetStart.lineNumber, targetEnd.lineNumber, copied);
|
|
108
|
+
}
|
|
109
|
+
else
|
|
110
|
+
{
|
|
111
|
+
if (params.targetEnd !== undefined)
|
|
112
|
+
{
|
|
113
|
+
throw new Error("targetEnd cannot be combined with a search selection.");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const selection = singleSelection(targetSelections, "targetStart");
|
|
117
|
+
[target] = selection;
|
|
118
|
+
const range = selection[1];
|
|
119
|
+
const insertion = context.documentFor(target).range(
|
|
120
|
+
range.end.lineNumber,
|
|
121
|
+
range.end.column,
|
|
122
|
+
range.end.lineNumber,
|
|
123
|
+
range.end.column,
|
|
124
|
+
);
|
|
125
|
+
targetChange = { ...insertion, insert: copied };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (source === target)
|
|
129
|
+
{
|
|
130
|
+
return {
|
|
131
|
+
edits: new Map([[source, { changes: [deletion, targetChange], action: "edited" }]]),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
edits: new Map([
|
|
137
|
+
[source, { changes: [deletion], action: "edited" }],
|
|
138
|
+
[target, { changes: [targetChange], action: "edited" }],
|
|
139
|
+
]),
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
|
|
3
|
+
import { TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND } from "#src/api/plugin-protocol.js";
|
|
4
|
+
import { lineAnchor, selectionChanges, textSelections } from "#src/tools/text-selection.js";
|
|
5
|
+
|
|
6
|
+
import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
7
|
+
|
|
8
|
+
export const replaceSchema = Type.Object({
|
|
9
|
+
path: Type.Optional(Type.String({ description: "File path to edit" })),
|
|
10
|
+
start: Type.String({ description: "Registered text anchor selecting the first line to replace" }),
|
|
11
|
+
end: Type.Optional(Type.String({ description: "Registered text anchor selecting the last line to replace" })),
|
|
12
|
+
text: Type.String({ description: "Replacement text" }),
|
|
13
|
+
}, { additionalProperties: false });
|
|
14
|
+
|
|
15
|
+
interface ReplaceParams
|
|
16
|
+
{
|
|
17
|
+
readonly path?: string;
|
|
18
|
+
readonly start: string;
|
|
19
|
+
readonly end?: string;
|
|
20
|
+
readonly text: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const replaceMutationTool: TextMutationToolRegistration<typeof replaceSchema> = {
|
|
24
|
+
name: "replace",
|
|
25
|
+
description:
|
|
26
|
+
"Replace lines or every exact search match selected by registered text anchors. For the same replacement at all matches, pass a SEARCH#HASH:all anchor from search as start.",
|
|
27
|
+
parameters: replaceSchema,
|
|
28
|
+
source: { field: "path", inherited: true },
|
|
29
|
+
anchors: [
|
|
30
|
+
{ field: "start", sourceField: "path", kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND] },
|
|
31
|
+
{
|
|
32
|
+
field: "end",
|
|
33
|
+
sourceField: "path",
|
|
34
|
+
kinds: [TEXT_POSITION_ANCHOR_KIND, TEXT_SEARCH_ANCHOR_KIND],
|
|
35
|
+
optional: true,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
pair: ["start", "end"],
|
|
39
|
+
mutate: async (context, params: ReplaceParams) =>
|
|
40
|
+
{
|
|
41
|
+
const starts = await context.resolveAnchors("start");
|
|
42
|
+
const selections = textSelections(starts, "start");
|
|
43
|
+
|
|
44
|
+
if (selections !== undefined)
|
|
45
|
+
{
|
|
46
|
+
if (params.end !== undefined)
|
|
47
|
+
{
|
|
48
|
+
throw new Error("end cannot be combined with a search selection.");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const changes = selectionChanges(context, selections, params.text);
|
|
52
|
+
return {
|
|
53
|
+
edits: new Map([...changes].map(([source, sourceChanges]) => [
|
|
54
|
+
source,
|
|
55
|
+
{ changes: sourceChanges, action: "edited" as const },
|
|
56
|
+
])),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const source = context.sourceFor("path");
|
|
61
|
+
const start = lineAnchor(starts, "start");
|
|
62
|
+
const end = params.end === undefined
|
|
63
|
+
? start
|
|
64
|
+
: lineAnchor(await context.resolveAnchors("end"), "end");
|
|
65
|
+
return {
|
|
66
|
+
edits: new Map([[source, {
|
|
67
|
+
changes: [context.documentFor(source).replaceLines(start.lineNumber, end.lineNumber, params.text)],
|
|
68
|
+
action: "edited",
|
|
69
|
+
}]]),
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
|
|
3
|
+
import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
4
|
+
|
|
5
|
+
export const writeSchema = Type.Object({
|
|
6
|
+
path: Type.String({ description: "Path to the file to create or overwrite" }),
|
|
7
|
+
content: Type.String({ description: "File content" }),
|
|
8
|
+
}, { additionalProperties: false });
|
|
9
|
+
|
|
10
|
+
interface WriteParams
|
|
11
|
+
{
|
|
12
|
+
readonly path: string;
|
|
13
|
+
readonly content: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const writeMutationTool: TextMutationToolRegistration<typeof writeSchema> = {
|
|
17
|
+
name: "write",
|
|
18
|
+
description: "Create a file or overwrite its complete text.",
|
|
19
|
+
parameters: writeSchema,
|
|
20
|
+
source: { field: "path" },
|
|
21
|
+
anchors: [],
|
|
22
|
+
mutate: (context, params: WriteParams) => ({
|
|
23
|
+
edits: new Map([[params.path, {
|
|
24
|
+
changes: [context.sourceDocument.replaceAll(params.content)],
|
|
25
|
+
action: "overwritten",
|
|
26
|
+
}]]),
|
|
27
|
+
}),
|
|
28
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "#src/core/extension.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BUILTIN_EXTENSIONS } from "#src/composite/builtin-extensions.js";
|
|
2
|
+
import { selectBuiltinExtensions } from "#src/composite/selection.js";
|
|
3
|
+
import { readPiAgentIdeConfig, resolvePiAgentIdeConfigPath } from "#src/composite/config.js";
|
|
4
|
+
|
|
5
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
|
|
7
|
+
/** Registers the configured built-ins as one Pi Agent IDE extension. */
|
|
8
|
+
export default async function registerUnifiedPiAgentIde(pi: ExtensionAPI): Promise<void>
|
|
9
|
+
{
|
|
10
|
+
const config = await readPiAgentIdeConfig(resolvePiAgentIdeConfigPath());
|
|
11
|
+
const { enabled } = selectBuiltinExtensions(BUILTIN_EXTENSIONS, config.disabledExtensions);
|
|
12
|
+
|
|
13
|
+
for (const extension of enabled)
|
|
14
|
+
{
|
|
15
|
+
await extension.register(pi);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./src/extension.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-agent-ide-ast",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"pi": {
|
|
6
|
+
"extensions": [
|
|
7
|
+
"./index.ts"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"imports": {
|
|
11
|
+
"#src/*": "./src/*"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
"./api/scope": {
|
|
15
|
+
"types": "./src/api/scope.ts",
|
|
16
|
+
"default": "./src/api/scope.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@tree-sitter-grammars/tree-sitter-toml": "^0.7.0",
|
|
21
|
+
"@tree-sitter-grammars/tree-sitter-yaml": "^0.7.1",
|
|
22
|
+
"pi-agent-read": "0.1.0",
|
|
23
|
+
"pi-agent-resource": "0.1.0",
|
|
24
|
+
"pi-agent-search": "0.1.0",
|
|
25
|
+
"pi-agent-text": "0.1.0",
|
|
26
|
+
"pi-agent-text-editor": "0.1.0",
|
|
27
|
+
"tree-sitter-cpp": "^0.23.4",
|
|
28
|
+
"tree-sitter-javascript": "^0.25.0",
|
|
29
|
+
"tree-sitter-json": "^0.24.8",
|
|
30
|
+
"tree-sitter-python": "^0.25.0",
|
|
31
|
+
"tree-sitter-rust": "^0.24.0",
|
|
32
|
+
"tree-sitter-typescript": "^0.23.2",
|
|
33
|
+
"web-tree-sitter": "^0.26.11"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
37
|
+
"pi-agent-ide": "0.1.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AstScopeManager, parseDocument, type ScopeEntry } from "../ast/manager.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export async function collectFiles(directory: string): Promise<string[]>
|
|
5
|
+
{
|
|
6
|
+
const files: string[] = [];
|
|
7
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
8
|
+
|
|
9
|
+
for (const entry of entries)
|
|
10
|
+
{
|
|
11
|
+
const entryPath = path.join(directory, entry.name);
|
|
12
|
+
|
|
13
|
+
if (entry.isDirectory())
|
|
14
|
+
{
|
|
15
|
+
files.push(...await collectFiles(entryPath));
|
|
16
|
+
}
|
|
17
|
+
else if (entry.isFile() || entry.isSymbolicLink())
|
|
18
|
+
{
|
|
19
|
+
files.push(entryPath);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return files;
|
|
24
|
+
}
|