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,47 @@
|
|
|
1
|
+
import { getTextSourceLine, type TextLinePresenter } from "pi-agent-text";
|
|
2
|
+
|
|
3
|
+
import { createLineHashAnchor } from "./anchor.js";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export function createLineHashPresenter(): TextLinePresenter
|
|
7
|
+
{
|
|
8
|
+
return {
|
|
9
|
+
id: "line-hash",
|
|
10
|
+
present(document, context)
|
|
11
|
+
{
|
|
12
|
+
const anchors = document.lines.map((line) =>
|
|
13
|
+
{
|
|
14
|
+
if (context.resolvedBy === "filesystem")
|
|
15
|
+
{
|
|
16
|
+
return createLineHashAnchor(line.lineNumber, line.content);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const sourceLine = getTextSourceLine(line);
|
|
20
|
+
|
|
21
|
+
return sourceLine === undefined
|
|
22
|
+
? undefined
|
|
23
|
+
: createLineHashAnchor(sourceLine.lineNumber, sourceLine.content);
|
|
24
|
+
});
|
|
25
|
+
const width = Math.max(0, ...anchors.map((anchor) => anchor?.value.length ?? 0));
|
|
26
|
+
const lines = document.lines.map((line, index) =>
|
|
27
|
+
{
|
|
28
|
+
const anchor = anchors[index];
|
|
29
|
+
|
|
30
|
+
if (anchor === undefined)
|
|
31
|
+
{
|
|
32
|
+
return line;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
...line,
|
|
37
|
+
presentation: {
|
|
38
|
+
...line.presentation,
|
|
39
|
+
prefix: `${anchor.value.padStart(width)}|${line.presentation?.prefix ?? ""}`,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return { ...document, lines };
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
import { registerBuiltinEditFilter } from "./src/core/builtin-edit-filter.js";
|
|
4
|
+
import registerTextEditorCore from "./src/core/extension.js";
|
|
5
|
+
import { registerTextEditBatching } from "./src/core/text-edit-batch-registrar.js";
|
|
6
|
+
import { registerTextEditorTools } from "./src/tools/extension.js";
|
|
7
|
+
|
|
8
|
+
export default async function registerTextEditor(pi: ExtensionAPI): Promise<void>
|
|
9
|
+
{
|
|
10
|
+
const core = await registerTextEditorCore(pi);
|
|
11
|
+
registerBuiltinEditFilter(pi);
|
|
12
|
+
|
|
13
|
+
if (!process.argv.includes("--old-tools"))
|
|
14
|
+
{
|
|
15
|
+
registerTextEditorTools(pi, core);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
registerTextEditBatching(pi, core);
|
|
19
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-agent-text-editor",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"pi": {
|
|
6
|
+
"extensions": [
|
|
7
|
+
"./index.ts"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"imports": {
|
|
11
|
+
"#src/*": "./src/*",
|
|
12
|
+
"#overwrite/*": "./plugins/pi-agent-text-editor-overwrite/*"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
"./api/anchor-inspection": {
|
|
16
|
+
"types": "./src/api/anchor-inspection.ts",
|
|
17
|
+
"default": "./src/api/anchor-inspection.ts"
|
|
18
|
+
},
|
|
19
|
+
"./api/connect-plugin": {
|
|
20
|
+
"types": "./src/api/connect-plugin.ts",
|
|
21
|
+
"default": "./src/api/connect-plugin.ts"
|
|
22
|
+
},
|
|
23
|
+
"./api/edit-completion": {
|
|
24
|
+
"types": "./src/api/edit-completion.ts",
|
|
25
|
+
"default": "./src/api/edit-completion.ts"
|
|
26
|
+
},
|
|
27
|
+
"./api/edit-pipeline": {
|
|
28
|
+
"types": "./src/api/edit-pipeline.ts",
|
|
29
|
+
"default": "./src/api/edit-pipeline.ts"
|
|
30
|
+
},
|
|
31
|
+
"./api/plugin-protocol": {
|
|
32
|
+
"types": "./src/api/plugin-protocol.ts",
|
|
33
|
+
"default": "./src/api/plugin-protocol.ts"
|
|
34
|
+
},
|
|
35
|
+
"./api/stale-anchor-message": {
|
|
36
|
+
"types": "./src/api/stale-anchor-message.ts",
|
|
37
|
+
"default": "./src/api/stale-anchor-message.ts"
|
|
38
|
+
},
|
|
39
|
+
"./api/text-selection-anchor": {
|
|
40
|
+
"types": "./src/api/text-selection-anchor.ts",
|
|
41
|
+
"default": "./src/api/text-selection-anchor.ts"
|
|
42
|
+
},
|
|
43
|
+
"./api/post-edit": {
|
|
44
|
+
"types": "./src/api/post-edit.ts",
|
|
45
|
+
"default": "./src/api/post-edit.ts"
|
|
46
|
+
},
|
|
47
|
+
"./api/mutation-result": {
|
|
48
|
+
"types": "./src/api/mutation-result.ts",
|
|
49
|
+
"default": "./src/api/mutation-result.ts"
|
|
50
|
+
},
|
|
51
|
+
"./api/mutation-guard": {
|
|
52
|
+
"types": "./src/api/mutation-guard.ts",
|
|
53
|
+
"default": "./src/api/mutation-guard.ts"
|
|
54
|
+
},
|
|
55
|
+
"./api/mutation-tool": {
|
|
56
|
+
"types": "./src/api/mutation-tool.ts",
|
|
57
|
+
"default": "./src/api/mutation-tool.ts"
|
|
58
|
+
},
|
|
59
|
+
"./api/mutation-preview": {
|
|
60
|
+
"types": "./src/api/mutation-preview.ts",
|
|
61
|
+
"default": "./src/api/mutation-preview.ts"
|
|
62
|
+
},
|
|
63
|
+
"./api/last-resolved-resource": {
|
|
64
|
+
"types": "./src/api/last-resolved-resource.ts",
|
|
65
|
+
"default": "./src/api/last-resolved-resource.ts"
|
|
66
|
+
},
|
|
67
|
+
"./api/tool-call-interceptor": {
|
|
68
|
+
"types": "./src/api/tool-call-interceptor.ts",
|
|
69
|
+
"default": "./src/api/tool-call-interceptor.ts"
|
|
70
|
+
},
|
|
71
|
+
"./api/tool-renderer": {
|
|
72
|
+
"types": "./src/api/tool-renderer.ts",
|
|
73
|
+
"default": "./src/api/tool-renderer.ts"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"@codemirror/state": "^6.5.0",
|
|
78
|
+
"diff": "^9.0.0",
|
|
79
|
+
"partial-json": "^0.1.7",
|
|
80
|
+
"pi-agent-read": "0.1.0",
|
|
81
|
+
"pi-agent-resource": "0.1.0",
|
|
82
|
+
"pi-agent-text": "0.1.0",
|
|
83
|
+
"pi-agent-tool-call-interception": "0.1.0",
|
|
84
|
+
"typebox-guard": "npm:typebox@^1.1.38"
|
|
85
|
+
},
|
|
86
|
+
"peerDependencies": {
|
|
87
|
+
"@earendil-works/pi-ai": "*",
|
|
88
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
89
|
+
"@earendil-works/pi-tui": "*",
|
|
90
|
+
"typebox": "*"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface TextAnchorContextRange
|
|
2
|
+
{
|
|
3
|
+
readonly offset: number;
|
|
4
|
+
readonly limit: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface TextAnchorInspectionRequest
|
|
8
|
+
{
|
|
9
|
+
readonly source: string;
|
|
10
|
+
readonly anchors: readonly [string] | readonly [string, string];
|
|
11
|
+
readonly kinds: readonly [readonly string[]] | readonly [readonly string[], readonly string[]];
|
|
12
|
+
readonly cwd: string;
|
|
13
|
+
readonly signal?: AbortSignal;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type TextAnchorInspectionOutcome =
|
|
17
|
+
| { readonly kind: "valid"; }
|
|
18
|
+
| {
|
|
19
|
+
readonly kind: "invalid";
|
|
20
|
+
readonly anchorIndex: number;
|
|
21
|
+
readonly reason: string;
|
|
22
|
+
readonly contextRange?: TextAnchorContextRange;
|
|
23
|
+
}
|
|
24
|
+
| { readonly kind: "failed"; readonly reason: string; readonly cause?: unknown; };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
isTextEditorCoreReady,
|
|
5
|
+
TEXT_EDITOR_CORE_READY_EVENT,
|
|
6
|
+
TEXT_EDITOR_PLUGIN_REGISTER_EVENT,
|
|
7
|
+
type TextEditorPlugin,
|
|
8
|
+
type TextEditorPluginRegistrationRequest,
|
|
9
|
+
} from "#src/api/plugin-protocol.js";
|
|
10
|
+
|
|
11
|
+
export function connectTextEditorPlugin(
|
|
12
|
+
pi: ExtensionAPI,
|
|
13
|
+
plugin: TextEditorPlugin,
|
|
14
|
+
): void | Promise<void>
|
|
15
|
+
{
|
|
16
|
+
const announce = (): Promise<void> | undefined =>
|
|
17
|
+
{
|
|
18
|
+
let registration: Promise<void> | undefined;
|
|
19
|
+
const request = {
|
|
20
|
+
plugin,
|
|
21
|
+
accept(value): void
|
|
22
|
+
{
|
|
23
|
+
if (registration !== undefined)
|
|
24
|
+
{
|
|
25
|
+
throw new Error(`Plugin ${plugin.id} registration was accepted more than once`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
registration = value;
|
|
29
|
+
},
|
|
30
|
+
} satisfies TextEditorPluginRegistrationRequest;
|
|
31
|
+
|
|
32
|
+
pi.events.emit(TEXT_EDITOR_PLUGIN_REGISTER_EVENT, request);
|
|
33
|
+
return registration;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
let unsubscribe = (): void =>
|
|
37
|
+
{};
|
|
38
|
+
unsubscribe = pi.events.on(TEXT_EDITOR_CORE_READY_EVENT, (ready) =>
|
|
39
|
+
{
|
|
40
|
+
if (!isTextEditorCoreReady(ready))
|
|
41
|
+
{
|
|
42
|
+
throw new Error("Invalid pi-agent-text-editor core readiness event");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const registration = announce();
|
|
46
|
+
|
|
47
|
+
if (registration === undefined)
|
|
48
|
+
{
|
|
49
|
+
throw new Error("pi-agent-text-editor core announced readiness without accepting the plugin");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
unsubscribe();
|
|
53
|
+
void registration.catch(() =>
|
|
54
|
+
{});
|
|
55
|
+
});
|
|
56
|
+
pi.on("session_shutdown", unsubscribe);
|
|
57
|
+
|
|
58
|
+
const registration = announce();
|
|
59
|
+
|
|
60
|
+
if (registration === undefined)
|
|
61
|
+
{
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
unsubscribe();
|
|
66
|
+
return registration;
|
|
67
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TextDocument } from "pi-agent-text";
|
|
2
|
+
|
|
3
|
+
export type TextEditIntent = "edit" | "restore" | "mixed";
|
|
4
|
+
|
|
5
|
+
export interface TextEditCompletion
|
|
6
|
+
{
|
|
7
|
+
readonly source: string;
|
|
8
|
+
readonly resourceSource: string;
|
|
9
|
+
readonly resolvedBy: string;
|
|
10
|
+
readonly cwd: string;
|
|
11
|
+
readonly existed: boolean;
|
|
12
|
+
readonly before: TextDocument;
|
|
13
|
+
readonly after: TextDocument;
|
|
14
|
+
readonly intent: TextEditIntent;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type TextEditCompletionListener = (
|
|
18
|
+
completion: TextEditCompletion,
|
|
19
|
+
) => void | Promise<void>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { Value } from "typebox/value";
|
|
3
|
+
|
|
4
|
+
import type { TextEditorToolId } from "#src/api/plugin-protocol.js";
|
|
5
|
+
|
|
6
|
+
export type TextEditPipelineStage = "text-pre-edit" | "text-edit" | "text-post-edit";
|
|
7
|
+
|
|
8
|
+
export interface TextPreEditState<Input = unknown>
|
|
9
|
+
{
|
|
10
|
+
readonly cwd: string;
|
|
11
|
+
readonly input: Input;
|
|
12
|
+
readonly signal?: AbortSignal;
|
|
13
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TextEditState<Input = unknown, Result = unknown> extends TextPreEditState<Input>
|
|
17
|
+
{
|
|
18
|
+
readonly result: Result;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type TextPreEditHandler = (
|
|
22
|
+
state: TextPreEditState,
|
|
23
|
+
) => TextPreEditState | Promise<TextPreEditState>;
|
|
24
|
+
|
|
25
|
+
export type TextEditHandler = (
|
|
26
|
+
state: TextEditState,
|
|
27
|
+
) => TextEditState | Promise<TextEditState>;
|
|
28
|
+
|
|
29
|
+
export type TextEditHandlerRegistration =
|
|
30
|
+
| { readonly stage: "text-pre-edit"; readonly handler: TextPreEditHandler; }
|
|
31
|
+
| { readonly stage: "text-edit"; readonly handler: TextEditHandler; }
|
|
32
|
+
| { readonly stage: "text-post-edit"; readonly handler: TextEditHandler; };
|
|
33
|
+
|
|
34
|
+
export interface TextEditorToolPluginApi
|
|
35
|
+
{
|
|
36
|
+
addHandler(registration: TextEditHandlerRegistration): void;
|
|
37
|
+
describe(description: string): void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface TextEditPipelineFailure
|
|
41
|
+
{
|
|
42
|
+
readonly code: "PLUGIN_FAILED";
|
|
43
|
+
readonly pluginId: string;
|
|
44
|
+
readonly tool: TextEditorToolId;
|
|
45
|
+
readonly stage: TextEditPipelineStage;
|
|
46
|
+
readonly message: string;
|
|
47
|
+
readonly cause: unknown;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type TextEditExecutionOutcome<Input = unknown, Result = unknown> =
|
|
51
|
+
| { readonly kind: "completed"; readonly state: TextEditState<Input, Result>; }
|
|
52
|
+
| { readonly kind: "failed"; readonly failure: TextEditPipelineFailure; };
|
|
53
|
+
|
|
54
|
+
const handlerSchema = Type.Function([], Type.Unknown());
|
|
55
|
+
const textEditHandlerRegistrationSchema = Type.Union([
|
|
56
|
+
Type.Object({ stage: Type.Literal("text-pre-edit"), handler: handlerSchema }),
|
|
57
|
+
Type.Object({ stage: Type.Literal("text-edit"), handler: handlerSchema }),
|
|
58
|
+
Type.Object({ stage: Type.Literal("text-post-edit"), handler: handlerSchema }),
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
export function isTextEditHandlerRegistration(value: unknown): value is TextEditHandlerRegistration
|
|
62
|
+
{
|
|
63
|
+
return Value.Check(textEditHandlerRegistrationSchema, value);
|
|
64
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
export interface ResolvedResourceReference
|
|
4
|
+
{
|
|
5
|
+
readonly source: string;
|
|
6
|
+
readonly resolverId: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const lastResolvedResourceKey = Symbol.for("pi-agent-text-editor.last-resolved-resource");
|
|
10
|
+
|
|
11
|
+
type ResourceContextHost = ExtensionAPI & {
|
|
12
|
+
[lastResolvedResourceKey]: ResolvedResourceReference | undefined;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function rememberLastResolvedResource(pi: ExtensionAPI, details: unknown): void
|
|
16
|
+
{
|
|
17
|
+
if (!isRecord(details))
|
|
18
|
+
{
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const source = details.source;
|
|
23
|
+
const resolverId = details.resolvedBy;
|
|
24
|
+
|
|
25
|
+
if (typeof source !== "string" || source.length === 0 || typeof resolverId !== "string" || resolverId.length === 0)
|
|
26
|
+
{
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
(pi as ResourceContextHost)[lastResolvedResourceKey] = { source, resolverId };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getLastResolvedResource(pi: ExtensionAPI): ResolvedResourceReference | undefined
|
|
34
|
+
{
|
|
35
|
+
return (pi as ResourceContextHost)[lastResolvedResourceKey];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function clearLastResolvedResource(pi: ExtensionAPI): void
|
|
39
|
+
{
|
|
40
|
+
(pi as ResourceContextHost)[lastResolvedResourceKey] = undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isRecord(value: unknown): value is Record<string, unknown>
|
|
44
|
+
{
|
|
45
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { TextEditIntent } from "#src/api/edit-completion.js";
|
|
2
|
+
import type { AppliedTextChange } from "#src/core/text-change-engine.js";
|
|
3
|
+
import type { TextDocument } from "pi-agent-text";
|
|
4
|
+
|
|
5
|
+
export interface TextMutationPlanResource
|
|
6
|
+
{
|
|
7
|
+
readonly source: string;
|
|
8
|
+
readonly existed: boolean;
|
|
9
|
+
readonly before: TextDocument;
|
|
10
|
+
readonly after: TextDocument;
|
|
11
|
+
readonly changes: readonly AppliedTextChange[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TextMutationPlan
|
|
15
|
+
{
|
|
16
|
+
readonly resources: readonly TextMutationPlanResource[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TextMutationGuardRejection
|
|
20
|
+
{
|
|
21
|
+
readonly code: string;
|
|
22
|
+
readonly reason: string;
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly annotation?: Readonly<Record<string, unknown>>;
|
|
25
|
+
readonly effect: "not-applied";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type TextMutationGuardOutcome =
|
|
29
|
+
| { readonly kind: "accepted"; }
|
|
30
|
+
| { readonly kind: "rejected"; readonly rejection: TextMutationGuardRejection; };
|
|
31
|
+
|
|
32
|
+
export interface TextMutationGuardContext
|
|
33
|
+
{
|
|
34
|
+
readonly cwd: string;
|
|
35
|
+
readonly intent?: TextEditIntent;
|
|
36
|
+
readonly signal?: AbortSignal;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface TextMutationGuardRegistration
|
|
40
|
+
{
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly guard: (
|
|
43
|
+
plan: TextMutationPlan,
|
|
44
|
+
context: TextMutationGuardContext,
|
|
45
|
+
) => TextMutationGuardOutcome | Promise<TextMutationGuardOutcome>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface TextMutationPreviewRequest
|
|
2
|
+
{
|
|
3
|
+
readonly tool: string;
|
|
4
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
5
|
+
readonly cwd: string;
|
|
6
|
+
readonly signal?: AbortSignal;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface TextMutationPreviewRange
|
|
10
|
+
{
|
|
11
|
+
readonly from: number;
|
|
12
|
+
readonly to: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type TextMutationPreviewRanges = readonly TextMutationPreviewRange[];
|
|
16
|
+
|
|
17
|
+
export interface TextMutationPreviewResource
|
|
18
|
+
{
|
|
19
|
+
readonly path: string;
|
|
20
|
+
readonly existed?: boolean;
|
|
21
|
+
readonly beforeRanges?: TextMutationPreviewRanges;
|
|
22
|
+
readonly link?: string;
|
|
23
|
+
readonly ranges: readonly TextMutationPreviewRange[];
|
|
24
|
+
readonly beforeContent: string;
|
|
25
|
+
readonly afterContent: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type TextMutationPreviewOutcome =
|
|
29
|
+
| { readonly kind: "completed"; readonly resources: readonly TextMutationPreviewResource[]; }
|
|
30
|
+
| { readonly kind: "failed"; readonly reason: string; };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export {
|
|
2
|
+
type AppliedTextChange,
|
|
3
|
+
type DiagnosticHint,
|
|
4
|
+
type EditDiagnosticLine,
|
|
5
|
+
type EditFailureOptions,
|
|
6
|
+
type FileChange,
|
|
7
|
+
type FileError,
|
|
8
|
+
type FileMutationBatchResult,
|
|
9
|
+
type FileMutationData,
|
|
10
|
+
FileMutationResult,
|
|
11
|
+
FileRange,
|
|
12
|
+
type GatePhase,
|
|
13
|
+
type LintViolation,
|
|
14
|
+
type MutationAnchor,
|
|
15
|
+
type MutationSnapshot,
|
|
16
|
+
type StaleAnchorDiagnostic,
|
|
17
|
+
type StaleEditInfo,
|
|
18
|
+
type StrictEditErrorCode,
|
|
19
|
+
type SyntaxErrorSummary,
|
|
20
|
+
type Warning,
|
|
21
|
+
} from "#src/core/mutation-result/file-mutation-result.js";
|
|
22
|
+
|
|
23
|
+
export { type ChangedRange, computeChangedRanges } from "#src/core/mutation-result/diff.js";
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { TextEditIntent } from "#src/api/edit-completion.js";
|
|
2
|
+
import type { TextChange, TextChangeDocument } from "#src/core/text-change-engine.js";
|
|
3
|
+
import type { TextAnchor } from "pi-agent-text";
|
|
4
|
+
import type { Static, TSchema } from "typebox";
|
|
5
|
+
|
|
6
|
+
export interface TextMutationEdit
|
|
7
|
+
{
|
|
8
|
+
readonly changes: readonly TextChange[];
|
|
9
|
+
readonly action: "edited" | "overwritten";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface TextMutation
|
|
13
|
+
{
|
|
14
|
+
readonly edits: ReadonlyMap<string, TextMutationEdit>;
|
|
15
|
+
readonly afterWrite?: () => void | Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface TextMutationContext
|
|
19
|
+
{
|
|
20
|
+
readonly cwd: string;
|
|
21
|
+
readonly signal?: AbortSignal;
|
|
22
|
+
readonly sourceDocument: TextChangeDocument;
|
|
23
|
+
targetDocument(field: string): TextChangeDocument;
|
|
24
|
+
sourceFor(field: string): string;
|
|
25
|
+
documentFor(source: string): TextChangeDocument;
|
|
26
|
+
resolveAnchors(field: string): Promise<ReadonlyMap<string, TextAnchor>>;
|
|
27
|
+
resolveAnchor(field: string): Promise<TextAnchor>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface TextMutationSourceDescriptor
|
|
31
|
+
{
|
|
32
|
+
readonly field: string;
|
|
33
|
+
readonly inherited?: boolean;
|
|
34
|
+
readonly targets?: readonly TextMutationTargetSource[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface TextMutationTargetSource
|
|
38
|
+
{
|
|
39
|
+
readonly field: string;
|
|
40
|
+
readonly fallbackTo: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface TextMutationAnchorField
|
|
44
|
+
{
|
|
45
|
+
readonly field: string;
|
|
46
|
+
readonly sourceField: string;
|
|
47
|
+
readonly kinds: readonly string[];
|
|
48
|
+
readonly optional?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type TextMutationIntent = Exclude<TextEditIntent, "mixed">;
|
|
52
|
+
|
|
53
|
+
export interface TextMutationToolRegistration<TParams extends TSchema = TSchema>
|
|
54
|
+
{
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly description: string;
|
|
57
|
+
readonly parameters: TParams;
|
|
58
|
+
readonly intent?: TextMutationIntent;
|
|
59
|
+
readonly source: TextMutationSourceDescriptor;
|
|
60
|
+
readonly anchors?: readonly TextMutationAnchorField[];
|
|
61
|
+
readonly pair?: readonly [string, string];
|
|
62
|
+
readonly mutate: (
|
|
63
|
+
context: TextMutationContext,
|
|
64
|
+
params: Static<TParams>,
|
|
65
|
+
) => TextMutation | Promise<TextMutation>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type AnyTextMutationToolRegistration = TextMutationToolRegistration;
|
|
69
|
+
|
|
70
|
+
export type TextMutationToolListener = (registration: AnyTextMutationToolRegistration) => void;
|
|
71
|
+
|
|
72
|
+
export function assertTextMutationToolRegistration(value: AnyTextMutationToolRegistration): void
|
|
73
|
+
{
|
|
74
|
+
if (typeof value.name !== "string" || value.name.trim().length === 0)
|
|
75
|
+
{
|
|
76
|
+
throw new TypeError("Mutation tool name must be a non-empty string");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (typeof value.description !== "string" || typeof value.mutate !== "function")
|
|
80
|
+
{
|
|
81
|
+
throw new TypeError(`Mutation tool ${value.name} has an invalid description or operation`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const intent: unknown = (value as { readonly intent?: unknown; }).intent;
|
|
85
|
+
|
|
86
|
+
if (intent !== undefined && intent !== "edit" && intent !== "restore")
|
|
87
|
+
{
|
|
88
|
+
throw new TypeError(`Mutation tool ${value.name} has an invalid intent`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const properties = schemaProperties(value.parameters, value.name);
|
|
92
|
+
assertProperty(properties, value.source.field, `${value.name} primary source`);
|
|
93
|
+
const sourceFields = new Set([value.source.field]);
|
|
94
|
+
|
|
95
|
+
for (const target of value.source.targets ?? [])
|
|
96
|
+
{
|
|
97
|
+
assertProperty(properties, target.field, `${value.name} target source`);
|
|
98
|
+
|
|
99
|
+
if (!sourceFields.has(target.fallbackTo))
|
|
100
|
+
{
|
|
101
|
+
throw new TypeError(
|
|
102
|
+
`Mutation tool ${value.name} target ${target.field} has an unknown fallback ${target.fallbackTo}`,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
sourceFields.add(target.field);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const anchorFields = new Set<string>();
|
|
110
|
+
|
|
111
|
+
for (const anchor of value.anchors ?? [])
|
|
112
|
+
{
|
|
113
|
+
assertProperty(properties, anchor.field, `${value.name} anchor`);
|
|
114
|
+
|
|
115
|
+
if (!sourceFields.has(anchor.sourceField))
|
|
116
|
+
{
|
|
117
|
+
throw new TypeError(
|
|
118
|
+
`Mutation tool ${value.name} anchor ${anchor.field} has an unknown source ${anchor.sourceField}`,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (
|
|
123
|
+
!Array.isArray(anchor.kinds)
|
|
124
|
+
|| anchor.kinds.length === 0
|
|
125
|
+
|| anchor.kinds.some((kind) => typeof kind !== "string" || kind.trim().length === 0)
|
|
126
|
+
)
|
|
127
|
+
{
|
|
128
|
+
throw new TypeError(`Mutation tool ${value.name} anchor ${anchor.field} must accept non-empty kinds`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (new Set(anchor.kinds).size !== anchor.kinds.length)
|
|
132
|
+
{
|
|
133
|
+
throw new TypeError(`Mutation tool ${value.name} anchor ${anchor.field} declares duplicate kinds`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (anchorFields.has(anchor.field))
|
|
137
|
+
{
|
|
138
|
+
throw new TypeError(`Mutation tool ${value.name} declares anchor ${anchor.field} more than once`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
anchorFields.add(anchor.field);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
for (const field of value.pair ?? [])
|
|
145
|
+
{
|
|
146
|
+
if (!anchorFields.has(field))
|
|
147
|
+
{
|
|
148
|
+
throw new TypeError(`Mutation tool ${value.name} pair field ${field} is not an anchor`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function mutationSource(
|
|
154
|
+
registration: AnyTextMutationToolRegistration,
|
|
155
|
+
params: Readonly<Record<string, unknown>>,
|
|
156
|
+
): string
|
|
157
|
+
{
|
|
158
|
+
const value = params[registration.source.field];
|
|
159
|
+
return typeof value === "string" ? value : "";
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function schemaProperties(schema: TSchema, name: string): Readonly<Record<string, unknown>>
|
|
163
|
+
{
|
|
164
|
+
const properties = (schema as { readonly properties?: unknown; }).properties;
|
|
165
|
+
|
|
166
|
+
if (typeof properties !== "object" || properties === null)
|
|
167
|
+
{
|
|
168
|
+
throw new TypeError(`Mutation tool ${name} parameters must be an object schema`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return properties as Readonly<Record<string, unknown>>;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function assertProperty(properties: Readonly<Record<string, unknown>>, field: string, label: string): void
|
|
175
|
+
{
|
|
176
|
+
if (typeof field !== "string" || field.length === 0 || !(field in properties))
|
|
177
|
+
{
|
|
178
|
+
throw new TypeError(`${label} field ${field} is not declared by its schema`);
|
|
179
|
+
}
|
|
180
|
+
}
|