@mrclrchtr/supi-code-intelligence 11.4.0 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/README.md +17 -9
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +51 -23
- package/node_modules/@mrclrchtr/supi-core/package.json +3 -1
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
- package/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
- package/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
- package/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
- package/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
- package/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +21 -16
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +51 -23
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +3 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +8 -8
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +3 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +102 -47
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +13 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +15 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +71 -13
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-disk-stamp.ts +60 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +28 -6
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-edit-capture.ts +258 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +17 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +53 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +75 -14
- package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +48 -79
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-extends.ts +2 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-path.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +14 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-module.ts +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +2 -17
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-removal-ledger.ts +52 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +43 -21
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +6 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +21 -35
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +6 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-command-capture.ts +139 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +202 -47
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +13 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/session/route-boundary.ts +26 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +74 -14
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +11 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +24 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +51 -23
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +3 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +50 -75
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +50 -75
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +6 -6
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +50 -75
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +7 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +7 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +50 -75
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +5 -5
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -5
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/tree-sitter-latex.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/coordinates.ts +16 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +4 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-errors.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-range.ts +94 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +26 -6
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +6 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +13 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +1 -9
- package/node_modules/fast-xml-parser/CHANGELOG.md +886 -0
- package/node_modules/fast-xml-parser/LICENSE +21 -0
- package/node_modules/fast-xml-parser/README.md +204 -0
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -0
- package/node_modules/fast-xml-parser/lib/fxp.d.cts +774 -0
- package/node_modules/fast-xml-parser/lib/fxp.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxparser.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/README.md +92 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/package.json +57 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/EntityDecoder.js +644 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/EntityEncoder.js +239 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/all-entities.js +53 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/entities.js +1139 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/entityTries.js +60 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/index.d.ts +358 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/index.js +29 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/CHANGELOG.md +52 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/README.md +77 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.d.cts +270 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/package.json +77 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/fxb.d.ts +270 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/fxb.js +609 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/ignoreAttributes.js +18 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/orderedJs2Xml.js +360 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/prettifyJs2Xml.js +0 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/util.js +23 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/README.md +632 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/package.json +56 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/html.js +102 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/log.js +98 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/nosql.js +114 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/redos.js +60 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/shell.js +105 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/sql-strict.js +47 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/sql.js +95 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/svg.js +81 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/xml.js +79 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.cjs +27 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.d.ts +103 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.js +292 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/util/decode-entities.js +48 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/README.md +947 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.d.cts +725 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.min.js +2 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/package.json +79 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Expression.js +232 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/ExpressionSet.js +225 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Matcher.js +663 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/index.d.ts +589 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/index.js +30 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/CHANGELOG.md +63 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/README.md +113 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/README.md +142 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/anynum.js +135 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/digitTable.js +116 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/package.json +42 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/package.json +36 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/strnum.js +176 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/README.md +287 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/package.json +56 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/src/index.d.ts +108 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/src/index.js +382 -0
- package/node_modules/fast-xml-parser/package.json +93 -0
- package/node_modules/fast-xml-parser/src/cli/cli.js +97 -0
- package/node_modules/fast-xml-parser/src/cli/man.js +17 -0
- package/node_modules/fast-xml-parser/src/cli/read.js +43 -0
- package/node_modules/fast-xml-parser/src/fxp.d.ts +754 -0
- package/node_modules/fast-xml-parser/src/fxp.js +14 -0
- package/node_modules/fast-xml-parser/src/ignoreAttributes.js +18 -0
- package/node_modules/fast-xml-parser/src/util.js +61 -0
- package/node_modules/fast-xml-parser/src/v6/CharsSymbol.js +16 -0
- package/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +106 -0
- package/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +61 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +69 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +103 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +100 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +154 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +94 -0
- package/node_modules/fast-xml-parser/src/v6/Report.js +0 -0
- package/node_modules/fast-xml-parser/src/v6/TagPath.js +81 -0
- package/node_modules/fast-xml-parser/src/v6/TagPathMatcher.js +13 -0
- package/node_modules/fast-xml-parser/src/v6/XMLParser.js +83 -0
- package/node_modules/fast-xml-parser/src/v6/Xml2JsParser.js +235 -0
- package/node_modules/fast-xml-parser/src/v6/XmlPartReader.js +210 -0
- package/node_modules/fast-xml-parser/src/v6/XmlSpecialTagsReader.js +111 -0
- package/node_modules/fast-xml-parser/src/v6/inputSource/BufferSource.js +116 -0
- package/node_modules/fast-xml-parser/src/v6/inputSource/StringSource.js +121 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +105 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParser.js +22 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParserExt.js +19 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/currency.js +38 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/join.js +13 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/number.js +14 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/trim.js +6 -0
- package/node_modules/fast-xml-parser/src/validator.js +518 -0
- package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +6 -0
- package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +426 -0
- package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +164 -0
- package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +907 -0
- package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +77 -0
- package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +177 -0
- package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +54 -0
- package/package.json +10 -8
- package/src/analysis/evidence.ts +331 -73
- package/src/analysis/health/diagnostics.ts +66 -18
- package/src/analysis/health/evidence-reason.ts +44 -0
- package/src/analysis/health/server-status.ts +41 -12
- package/src/analysis/search/pattern.ts +3 -3
- package/src/analysis/target/anchored-structural.ts +4 -1
- package/src/analysis/target/anchored.ts +3 -6
- package/src/analysis/target/symbol.ts +42 -48
- package/src/analysis/target/types.ts +4 -9
- package/src/analysis/workspace/cmake-parser.ts +207 -0
- package/src/analysis/workspace/cmake.ts +141 -0
- package/src/analysis/workspace/maven.ts +310 -0
- package/src/analysis/workspace/membership.ts +100 -26
- package/src/analysis/workspace/metadata.ts +6 -1
- package/src/analysis/workspace/observe.ts +6 -0
- package/src/analysis/workspace/types.ts +11 -3
- package/src/diagnostics/coverage.ts +49 -0
- package/src/diagnostics/evidence.ts +10 -2
- package/src/session/find-types.ts +8 -4
- package/src/session/find-workflow.ts +11 -16
- package/src/session/health-workflow.ts +6 -0
- package/src/session/input/common.ts +1 -1
- package/src/session/input/health-refactor.ts +48 -34
- package/src/session/input/workflows.ts +45 -46
- package/src/session/inspect/file-point.ts +2 -2
- package/src/session/inspect-types.ts +1 -1
- package/src/session/inspect-workflow.ts +3 -3
- package/src/session/orientation/collect.ts +42 -7
- package/src/session/orientation/context-facts.ts +3 -3
- package/src/session/orientation/context-sections.ts +13 -15
- package/src/session/orientation/facts.ts +5 -8
- package/src/session/orientation-workflow.ts +4 -19
- package/src/session/refactor-file-actions.ts +122 -0
- package/src/session/refactor-plan-pipeline.ts +152 -0
- package/src/session/refactor-plans.ts +18 -15
- package/src/session/refactor-types.ts +24 -12
- package/src/session/refactor-workflow.ts +68 -243
- package/src/session/target-workflow.ts +25 -18
- package/src/tool/code_find/execute.ts +6 -7
- package/src/tool/code_find/result.ts +5 -7
- package/src/tool/code_find/spec.ts +9 -16
- package/src/tool/code_find/tui.ts +12 -6
- package/src/tool/code_graph/display.ts +5 -6
- package/src/tool/code_graph/format.ts +8 -24
- package/src/tool/code_graph/result.ts +16 -75
- package/src/tool/code_graph/section.ts +21 -33
- package/src/tool/code_graph/spec.ts +6 -0
- package/src/tool/code_graph/tui.ts +10 -5
- package/src/tool/code_health/diagnostic-tui.ts +49 -0
- package/src/tool/code_health/guidance.ts +27 -0
- package/src/tool/code_health/markdown.ts +60 -8
- package/src/tool/code_health/result.ts +20 -9
- package/src/tool/code_health/spec.ts +6 -0
- package/src/tool/code_health/structured-schema.ts +18 -4
- package/src/tool/code_health/structured.ts +22 -18
- package/src/tool/code_health/tui.ts +33 -40
- package/src/tool/code_inspect/execute.ts +1 -1
- package/src/tool/code_inspect/markdown.ts +33 -6
- package/src/tool/code_inspect/result.ts +24 -19
- package/src/tool/code_inspect/spec.ts +14 -6
- package/src/tool/code_inspect/structured.ts +4 -21
- package/src/tool/code_inspect/tui.ts +2 -2
- package/src/tool/code_orientation/result.ts +53 -100
- package/src/tool/code_orientation/spec.ts +8 -0
- package/src/tool/code_orientation/structured-schema.ts +16 -12
- package/src/tool/code_orientation/structured-workspace.ts +13 -7
- package/src/tool/code_orientation/structured.ts +31 -39
- package/src/tool/code_orientation/workspace-format.ts +4 -10
- package/src/tool/code_orientation/workspace-instructions.ts +4 -5
- package/src/tool/code_orientation/workspace-observations.ts +2 -2
- package/src/tool/code_orientation/workspace-output.ts +16 -7
- package/src/tool/code_orientation/workspace-projects.ts +7 -10
- package/src/tool/code_orientation/workspace-sections.ts +13 -19
- package/src/tool/code_refactor_apply/result.ts +2 -1
- package/src/tool/code_refactor_apply/spec.ts +7 -0
- package/src/tool/code_refactor_plan/execute.ts +0 -2
- package/src/tool/code_refactor_plan/result.ts +23 -13
- package/src/tool/code_refactor_plan/spec.ts +8 -2
- package/src/tool/code_refactor_plan/structured.ts +59 -12
- package/src/tool/code_refactor_plan/tui.ts +14 -17
- package/src/tool/code_resolve/markdown.ts +5 -47
- package/src/tool/code_resolve/result.ts +43 -72
- package/src/tool/code_resolve/spec.ts +6 -0
- package/src/tool/infra/truncate.ts +2 -16
- package/src/tool/namespace.ts +14 -0
- package/src/tool/refactor-markdown.ts +55 -15
- package/src/tool/register.ts +3 -0
- package/src/tool/result/candidate-selection.ts +141 -0
- package/src/tool/result/display.ts +41 -45
- package/src/tool/result/errors.ts +1 -0
- package/src/tool/result/model-budget.ts +26 -1
- package/src/tool/result/refactor-preview.ts +118 -0
- package/src/tool/result/refactor-unavailable.ts +16 -0
- package/src/tool/result/refactor.ts +19 -10
- package/src/tool/result/structured.ts +2 -1
- package/src/tool/result/types.ts +9 -8
- package/src/tool/schemas.ts +76 -38
- package/src/tool/specs.ts +3 -0
- package/src/ui/footer.ts +2 -4
- package/src/ui/status-overlay.ts +1 -1
- package/src/ui/status-presentation.ts +4 -7
- package/src/ui/tui/candidate-selection.ts +40 -95
- package/src/ui/tui/common.ts +16 -70
- package/src/ui/tui/display.ts +6 -24
- package/src/tool/result/candidate-row.ts +0 -49
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
createEvidenceList,
|
|
10
10
|
createPartialEvidenceList,
|
|
11
11
|
type EvidenceListMetadata,
|
|
12
|
+
toEvidenceListFacts,
|
|
12
13
|
} from "../../analysis/evidence.ts";
|
|
13
14
|
import {
|
|
14
15
|
type ReadNextItem,
|
|
@@ -237,19 +238,34 @@ function targetContextFacts(
|
|
|
237
238
|
: { file: toDisplayPath(cwd, uri) }),
|
|
238
239
|
range: publicRange(range),
|
|
239
240
|
})),
|
|
240
|
-
|
|
241
|
-
|
|
241
|
+
evidence: sourceEvidence(
|
|
242
|
+
"context.definitions",
|
|
243
|
+
treeContext.operations.definition,
|
|
244
|
+
treeContext.definition,
|
|
245
|
+
limit,
|
|
246
|
+
),
|
|
242
247
|
}
|
|
243
248
|
: {}),
|
|
244
249
|
},
|
|
245
250
|
sourceContext: {
|
|
246
|
-
outline: sourceSelection(
|
|
251
|
+
outline: sourceSelection(
|
|
252
|
+
"context.outline",
|
|
253
|
+
treeContext.operations.outline,
|
|
254
|
+
treeContext.outline,
|
|
255
|
+
limit,
|
|
256
|
+
),
|
|
247
257
|
imports: sourceSelection(
|
|
258
|
+
"context.imports",
|
|
248
259
|
treeContext.operations.imports,
|
|
249
260
|
treeContext.imports.map(({ moduleSpecifier }) => ({ moduleSpecifier })),
|
|
250
261
|
limit,
|
|
251
262
|
),
|
|
252
|
-
exports: sourceSelection(
|
|
263
|
+
exports: sourceSelection(
|
|
264
|
+
"context.exports",
|
|
265
|
+
treeContext.operations.exports,
|
|
266
|
+
treeContext.exports,
|
|
267
|
+
limit,
|
|
268
|
+
),
|
|
253
269
|
},
|
|
254
270
|
}
|
|
255
271
|
: {};
|
|
@@ -675,8 +691,9 @@ function publicRange(range: SourceRange): SourceRange {
|
|
|
675
691
|
};
|
|
676
692
|
}
|
|
677
693
|
|
|
678
|
-
/** These best-effort lists preserve availability separately from
|
|
694
|
+
/** These best-effort lists preserve availability separately from their Evidence list. */
|
|
679
695
|
function sourceSelection<T>(
|
|
696
|
+
key: string,
|
|
680
697
|
status: { status: "complete" | "partial" | "unavailable"; reason: string | null },
|
|
681
698
|
entries: readonly T[],
|
|
682
699
|
limit: number,
|
|
@@ -684,11 +701,29 @@ function sourceSelection<T>(
|
|
|
684
701
|
return {
|
|
685
702
|
...status,
|
|
686
703
|
entries: entries.slice(0, limit),
|
|
687
|
-
|
|
688
|
-
omittedCount: Math.max(0, entries.length - limit),
|
|
704
|
+
evidence: sourceEvidence(key, status, entries, limit),
|
|
689
705
|
};
|
|
690
706
|
}
|
|
691
707
|
|
|
708
|
+
/** A partial observation counts its collected atoms; more may exist. */
|
|
709
|
+
function sourceEvidence<T>(
|
|
710
|
+
key: string,
|
|
711
|
+
status: { status: string; reason: string | null },
|
|
712
|
+
entries: readonly T[],
|
|
713
|
+
limit: number,
|
|
714
|
+
) {
|
|
715
|
+
const params = { key, items: entries, maxResults: limit };
|
|
716
|
+
return toEvidenceListFacts(
|
|
717
|
+
status.status === "complete"
|
|
718
|
+
? createEvidenceList(params).metadata
|
|
719
|
+
: createPartialEvidenceList({
|
|
720
|
+
...params,
|
|
721
|
+
partialReason: "provider-limited",
|
|
722
|
+
...(status.reason ? { partialMessage: status.reason } : {}),
|
|
723
|
+
}).metadata,
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
|
|
692
727
|
function uniqueRecoveryRanges(
|
|
693
728
|
recovery: readonly { errorRanges: readonly SourceRange[] }[],
|
|
694
729
|
): SourceRange[] {
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
ModuleInfo,
|
|
10
10
|
} from "../../analysis/architecture/model.ts";
|
|
11
11
|
import { findModuleForPath } from "../../analysis/architecture/model.ts";
|
|
12
|
-
import type {
|
|
12
|
+
import type { CollectionPartialReason } from "../../analysis/evidence.ts";
|
|
13
13
|
import type { CodeProvider } from "../../analysis/provider.ts";
|
|
14
14
|
import type { OrientationProvenance, OrientationResultData } from "../orientation-types.ts";
|
|
15
15
|
import {
|
|
@@ -290,7 +290,7 @@ function appendRelationshipFacts(
|
|
|
290
290
|
edges: readonly DependencyEdge[];
|
|
291
291
|
status: "complete" | "partial" | "unavailable";
|
|
292
292
|
reason: string | null;
|
|
293
|
-
partialReason:
|
|
293
|
+
partialReason: CollectionPartialReason | undefined;
|
|
294
294
|
},
|
|
295
295
|
): void {
|
|
296
296
|
if (input.status === "unavailable") return;
|
|
@@ -318,7 +318,7 @@ function appendRelationshipFacts(
|
|
|
318
318
|
});
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
function topologyPartialReason(model: ArchitectureModel):
|
|
321
|
+
function topologyPartialReason(model: ArchitectureModel): CollectionPartialReason | undefined {
|
|
322
322
|
if (model.topology.status !== "partial") return undefined;
|
|
323
323
|
return model.topology.failedPackageManifestCount > 0 ? "filesystem-error" : "configuration-error";
|
|
324
324
|
}
|
|
@@ -9,8 +9,11 @@ import {
|
|
|
9
9
|
} from "@mrclrchtr/supi-code-runtime/api";
|
|
10
10
|
import { isWithinOrEqual } from "@mrclrchtr/supi-core/project";
|
|
11
11
|
import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
|
|
12
|
-
import
|
|
13
|
-
|
|
12
|
+
import {
|
|
13
|
+
type CollectionPartialReason,
|
|
14
|
+
createEvidenceList,
|
|
15
|
+
createPartialEvidenceList,
|
|
16
|
+
} from "../../analysis/evidence.ts";
|
|
14
17
|
import type { CodeProvider } from "../../analysis/provider.ts";
|
|
15
18
|
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
16
19
|
import type {
|
|
@@ -38,7 +41,7 @@ export interface ListSectionInput<T> {
|
|
|
38
41
|
readonly status?: "complete" | "partial";
|
|
39
42
|
readonly reason?: string | null;
|
|
40
43
|
readonly unknownRemainder?: boolean;
|
|
41
|
-
readonly partialReason?:
|
|
44
|
+
readonly partialReason?: CollectionPartialReason;
|
|
42
45
|
readonly errorRanges?: readonly SourceRange[];
|
|
43
46
|
readonly facts?: (items: readonly T[]) => import("./facts.ts").OrientationFacts;
|
|
44
47
|
}
|
|
@@ -58,19 +61,14 @@ export function appendList<T>(
|
|
|
58
61
|
builder: ContextOrientationBuilder,
|
|
59
62
|
input: ListSectionInput<T>,
|
|
60
63
|
): void {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
const metadata: EvidenceListMetadata = input.unknownRemainder
|
|
67
|
-
? {
|
|
68
|
-
...list.metadata,
|
|
69
|
-
totalCount: null,
|
|
64
|
+
const params = { key: input.key, items: [...input.items], maxResults: builder.maxResults };
|
|
65
|
+
const list = input.unknownRemainder
|
|
66
|
+
? createPartialEvidenceList({
|
|
67
|
+
...params,
|
|
70
68
|
partialReason: input.partialReason ?? "filesystem-error",
|
|
71
69
|
...(input.reason ? { partialMessage: input.reason } : {}),
|
|
72
|
-
}
|
|
73
|
-
:
|
|
70
|
+
})
|
|
71
|
+
: createEvidenceList(params);
|
|
74
72
|
builder.sections.push({
|
|
75
73
|
key: input.key,
|
|
76
74
|
title: input.title,
|
|
@@ -78,7 +76,7 @@ export function appendList<T>(
|
|
|
78
76
|
reason: input.reason ?? null,
|
|
79
77
|
confidence: input.confidence,
|
|
80
78
|
provenance: input.provenance,
|
|
81
|
-
evidenceLists: [
|
|
79
|
+
evidenceLists: [list.metadata],
|
|
82
80
|
items: list.items.map((item) => ({ kind: "list-item", text: input.render(item) })),
|
|
83
81
|
...(input.facts ? { facts: input.facts(list.items) } : {}),
|
|
84
82
|
...(input.errorRanges ? { errorRanges: [...input.errorRanges] } : {}),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SourceRange } from "@mrclrchtr/supi-code-runtime/api";
|
|
2
|
+
import type { EvidenceListFacts } from "../../analysis/evidence.ts";
|
|
2
3
|
|
|
3
4
|
/** Named, selected observations retained independently of their text rendering. */
|
|
4
5
|
export interface OrientationFacts {
|
|
@@ -84,8 +85,7 @@ export interface OrientationFacts {
|
|
|
84
85
|
readonly reason: string;
|
|
85
86
|
}
|
|
86
87
|
)[];
|
|
87
|
-
readonly
|
|
88
|
-
readonly omittedCount?: number;
|
|
88
|
+
readonly evidence?: EvidenceListFacts;
|
|
89
89
|
};
|
|
90
90
|
readonly recovery?: readonly {
|
|
91
91
|
readonly operation: string;
|
|
@@ -103,22 +103,19 @@ export interface OrientationFacts {
|
|
|
103
103
|
readonly startLine: number;
|
|
104
104
|
readonly endLine: number;
|
|
105
105
|
}[];
|
|
106
|
-
readonly
|
|
107
|
-
readonly omittedCount: number;
|
|
106
|
+
readonly evidence: EvidenceListFacts;
|
|
108
107
|
};
|
|
109
108
|
readonly imports: {
|
|
110
109
|
readonly status: "complete" | "partial" | "unavailable";
|
|
111
110
|
readonly reason: string | null;
|
|
112
111
|
readonly entries: readonly { readonly moduleSpecifier: string }[];
|
|
113
|
-
readonly
|
|
114
|
-
readonly omittedCount: number;
|
|
112
|
+
readonly evidence: EvidenceListFacts;
|
|
115
113
|
};
|
|
116
114
|
readonly exports: {
|
|
117
115
|
readonly status: "complete" | "partial" | "unavailable";
|
|
118
116
|
readonly reason: string | null;
|
|
119
117
|
readonly entries: readonly { readonly name: string; readonly kind: string }[];
|
|
120
|
-
readonly
|
|
121
|
-
readonly omittedCount: number;
|
|
118
|
+
readonly evidence: EvidenceListFacts;
|
|
122
119
|
};
|
|
123
120
|
};
|
|
124
121
|
readonly documentation?: readonly string[];
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { existsSync, statSync } from "node:fs";
|
|
4
4
|
import { buildArchitectureModel } from "../analysis/architecture/discovery.ts";
|
|
5
5
|
import type { ArchitectureModel } from "../analysis/architecture/model.ts";
|
|
6
|
+
import { createEvidenceList } from "../analysis/evidence.ts";
|
|
6
7
|
import {
|
|
7
8
|
collectInstructionFiles,
|
|
8
9
|
findInstructionFilesForDirectory,
|
|
@@ -148,19 +149,9 @@ async function orientTarget(options: {
|
|
|
148
149
|
kind: "kind-mismatch",
|
|
149
150
|
requestedKind: target.requestedKind,
|
|
150
151
|
candidates,
|
|
151
|
-
|
|
152
|
-
omittedCount: target.omittedCount,
|
|
153
|
-
partialReason: target.partialReason,
|
|
154
|
-
partialMessage: target.partialMessage,
|
|
152
|
+
candidateEvidence: target.candidateEvidence,
|
|
155
153
|
}
|
|
156
|
-
: {
|
|
157
|
-
kind: "disambiguation",
|
|
158
|
-
candidates,
|
|
159
|
-
totalCount: target.totalCount,
|
|
160
|
-
omittedCount: target.omittedCount,
|
|
161
|
-
partialReason: target.partialReason,
|
|
162
|
-
partialMessage: target.partialMessage,
|
|
163
|
-
};
|
|
154
|
+
: { kind: "disambiguation", candidates, candidateEvidence: target.candidateEvidence };
|
|
164
155
|
}
|
|
165
156
|
if (target.kind !== "resolved") return target;
|
|
166
157
|
throwIfAborted(control);
|
|
@@ -280,13 +271,7 @@ function addInstructionFiles(
|
|
|
280
271
|
confidence: "unavailable",
|
|
281
272
|
provenance: [{ source: "filesystem", detail: "configured instruction files" }],
|
|
282
273
|
evidenceLists: [
|
|
283
|
-
{
|
|
284
|
-
key: "instructions.files",
|
|
285
|
-
totalCount: collected.files.length,
|
|
286
|
-
shownCount: collected.files.length,
|
|
287
|
-
omittedCount: 0,
|
|
288
|
-
partialReason: null,
|
|
289
|
-
},
|
|
274
|
+
createEvidenceList({ key: "instructions.files", items: collected.files }).metadata,
|
|
290
275
|
],
|
|
291
276
|
items,
|
|
292
277
|
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/** Code- and source-action refactor planning for one named file. */
|
|
2
|
+
|
|
3
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
4
|
+
import type { RefactorRequest, SourceRange } from "@mrclrchtr/supi-code-runtime/api";
|
|
5
|
+
import { toLspPosition } from "@mrclrchtr/supi-lsp/api";
|
|
6
|
+
import { normalizePath } from "../analysis/search/paths.ts";
|
|
7
|
+
import {
|
|
8
|
+
ensureFileReadiness,
|
|
9
|
+
finishProviderPlan,
|
|
10
|
+
planWithProvider,
|
|
11
|
+
type RefactorWorkflowDeps,
|
|
12
|
+
} from "./refactor-plan-pipeline.ts";
|
|
13
|
+
import type {
|
|
14
|
+
PublicSourceRange,
|
|
15
|
+
RefactorOperationInput,
|
|
16
|
+
RefactorPlanWorkflowOutcome,
|
|
17
|
+
} from "./refactor-types.ts";
|
|
18
|
+
import { reportProgress, throwIfAborted, type WorkflowControl } from "./workflow-control.ts";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Plan one code or source action. These operations name a file directly and
|
|
22
|
+
* never resolve a symbol target; source actions cover the whole document.
|
|
23
|
+
*/
|
|
24
|
+
export async function planFileAction(
|
|
25
|
+
operation: Exclude<RefactorOperationInput, { rename_symbol: unknown }>,
|
|
26
|
+
deps: RefactorWorkflowDeps,
|
|
27
|
+
control?: WorkflowControl,
|
|
28
|
+
): Promise<RefactorPlanWorkflowOutcome> {
|
|
29
|
+
const { name, selection, range } =
|
|
30
|
+
"code_action" in operation
|
|
31
|
+
? {
|
|
32
|
+
name: "code_action" as const,
|
|
33
|
+
selection: operation.code_action,
|
|
34
|
+
range: operation.code_action.range,
|
|
35
|
+
}
|
|
36
|
+
: { name: "source_action" as const, selection: operation.source_action, range: undefined };
|
|
37
|
+
const file = normalizePath(selection.file, deps.cwd);
|
|
38
|
+
const fileError = validateActionFile(file, selection.file, `operation.${name}.file`);
|
|
39
|
+
if (fileError) return { kind: "invalid-input", message: fileError };
|
|
40
|
+
const rangeError = range
|
|
41
|
+
? validateRangeWithinFile(file, selection.file, range, `operation.${name}.range`)
|
|
42
|
+
: null;
|
|
43
|
+
if (rangeError) return { kind: "invalid-input", message: rangeError };
|
|
44
|
+
|
|
45
|
+
const readiness = await ensureFileReadiness(file, deps, control);
|
|
46
|
+
if (readiness) return readiness;
|
|
47
|
+
reportProgress(control, {
|
|
48
|
+
intent: "refactor-plan",
|
|
49
|
+
phase: "provider",
|
|
50
|
+
message: `Requesting ${selection.kind} code actions`,
|
|
51
|
+
});
|
|
52
|
+
const action = {
|
|
53
|
+
file,
|
|
54
|
+
kind: selection.kind,
|
|
55
|
+
...(selection.title === undefined ? {} : { title: selection.title }),
|
|
56
|
+
};
|
|
57
|
+
const request: RefactorRequest = range
|
|
58
|
+
? { operation: "code_action", ...action, range: toLspRange(range) }
|
|
59
|
+
: { operation: "source_action", ...action };
|
|
60
|
+
const result = await planWithProvider(
|
|
61
|
+
deps.capability.getSemanticProvider(deps.cwd),
|
|
62
|
+
request,
|
|
63
|
+
control,
|
|
64
|
+
);
|
|
65
|
+
throwIfAborted(control);
|
|
66
|
+
return finishProviderPlan(result, deps, {
|
|
67
|
+
operation: name,
|
|
68
|
+
file,
|
|
69
|
+
discriminator: `${selection.kind}:${selection.title ?? ""}:${JSON.stringify(range ?? null)}`,
|
|
70
|
+
fields: range ? { range } : {},
|
|
71
|
+
evidenceSource: "semantic",
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Check that an action file exists and is a file. The routed language server
|
|
77
|
+
* enforces its own project root before any request.
|
|
78
|
+
*/
|
|
79
|
+
function validateActionFile(file: string, input: string, label: string): string | null {
|
|
80
|
+
if (!existsSync(file)) return `File not found: \`${input}\``;
|
|
81
|
+
if (statSync(file).isDirectory()) {
|
|
82
|
+
return `${label} must be a file, not a directory: \`${input}\`.`;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Check that both range ends lie inside the file's current disk text, so an
|
|
89
|
+
* out-of-range position fails as input instead of as a server error. Positions
|
|
90
|
+
* are one-based UTF-16; a line's maximum character is one past its last character.
|
|
91
|
+
*/
|
|
92
|
+
function validateRangeWithinFile(
|
|
93
|
+
file: string,
|
|
94
|
+
input: string,
|
|
95
|
+
range: PublicSourceRange,
|
|
96
|
+
label: string,
|
|
97
|
+
): string | null {
|
|
98
|
+
let lines: string[];
|
|
99
|
+
try {
|
|
100
|
+
lines = readFileSync(file, "utf-8").split(/\r\n|\r|\n/);
|
|
101
|
+
} catch {
|
|
102
|
+
return `Cannot read file: \`${input}\``;
|
|
103
|
+
}
|
|
104
|
+
for (const end of ["start", "end"] as const) {
|
|
105
|
+
const { line, character } = range[end];
|
|
106
|
+
if (line > lines.length) {
|
|
107
|
+
return `${label}.${end} line ${line} is beyond the end of \`${input}\` (${lines.length} lines).`;
|
|
108
|
+
}
|
|
109
|
+
const maximum = (lines[line - 1] ?? "").length + 1;
|
|
110
|
+
if (character > maximum) {
|
|
111
|
+
return `${label}.${end} character ${character} is beyond line ${line} of \`${input}\` (maximum ${maximum}, 1-based UTF-16).`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function toLspRange(range: PublicSourceRange): SourceRange {
|
|
118
|
+
return {
|
|
119
|
+
start: toLspPosition(range.start.line, range.start.character),
|
|
120
|
+
end: toLspPosition(range.end.line, range.end.character),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/** Shared refactor-plan pipeline: provider calls, readiness, validation, and plan storage. */
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
RefactorOperation,
|
|
5
|
+
RefactorRequest,
|
|
6
|
+
RefactorResult,
|
|
7
|
+
SemanticProvider,
|
|
8
|
+
} from "@mrclrchtr/supi-code-runtime/api";
|
|
9
|
+
import { SEMANTIC_READINESS_TIMEOUT_REASON } from "../analysis/readiness.ts";
|
|
10
|
+
import { establishMutationAuthority } from "../analysis/refactor/mutation-authority.ts";
|
|
11
|
+
import { validateEdit } from "../analysis/refactor/safety.ts";
|
|
12
|
+
import type { CapabilityAdapter } from "./capability-adapter.ts";
|
|
13
|
+
import { collectFileFingerprints, dropIdentityEdits } from "./refactor-identity.ts";
|
|
14
|
+
import {
|
|
15
|
+
generatePlanId,
|
|
16
|
+
type RefactorPlan,
|
|
17
|
+
validateSynchronizedContentFingerprints,
|
|
18
|
+
} from "./refactor-plans.ts";
|
|
19
|
+
import type { RefactorPlanWorkflowOutcome } from "./refactor-types.ts";
|
|
20
|
+
import type { TargetWorkflowDeps } from "./target-workflow.ts";
|
|
21
|
+
import { throwIfAborted, type WorkflowControl } from "./workflow-control.ts";
|
|
22
|
+
|
|
23
|
+
/** Session collaborators for refactor planning and apply workflows. */
|
|
24
|
+
export interface RefactorWorkflowDeps extends TargetWorkflowDeps {
|
|
25
|
+
readonly capability: CapabilityAdapter;
|
|
26
|
+
readonly storePlan: (plan: RefactorPlan) => string;
|
|
27
|
+
readonly getPlan: (id: string) => RefactorPlan | undefined;
|
|
28
|
+
readonly removePlan: (id: string) => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Wait for semantic readiness for one file; returns an outcome only when planning must stop. */
|
|
32
|
+
export async function ensureFileReadiness(
|
|
33
|
+
file: string,
|
|
34
|
+
deps: RefactorWorkflowDeps,
|
|
35
|
+
control?: WorkflowControl,
|
|
36
|
+
): Promise<RefactorPlanWorkflowOutcome | null> {
|
|
37
|
+
const readiness = await deps.capability.ensureSemanticReadiness(
|
|
38
|
+
deps.cwd,
|
|
39
|
+
{ kind: "file", file },
|
|
40
|
+
control,
|
|
41
|
+
);
|
|
42
|
+
throwIfAborted(control);
|
|
43
|
+
if (readiness.kind === "timeout") {
|
|
44
|
+
return { kind: "unavailable", reason: SEMANTIC_READINESS_TIMEOUT_REASON };
|
|
45
|
+
}
|
|
46
|
+
if (readiness.kind === "unavailable") return readiness;
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Validate a provider result and store it as a fingerprinted plan. */
|
|
51
|
+
export async function finishProviderPlan(
|
|
52
|
+
result: RefactorResult,
|
|
53
|
+
deps: RefactorWorkflowDeps,
|
|
54
|
+
plan: {
|
|
55
|
+
readonly operation: RefactorOperation;
|
|
56
|
+
readonly file: string;
|
|
57
|
+
readonly discriminator: string;
|
|
58
|
+
readonly fields: Pick<RefactorPlan, "newName" | "target" | "range">;
|
|
59
|
+
readonly evidenceSource: "semantic" | "structural";
|
|
60
|
+
readonly sourceFingerprint?: string;
|
|
61
|
+
},
|
|
62
|
+
): Promise<RefactorPlanWorkflowOutcome> {
|
|
63
|
+
if (result.kind === "unavailable") return { kind: "unavailable", reason: result.reason };
|
|
64
|
+
if (result.kind === "ambiguous") {
|
|
65
|
+
return { kind: "ambiguous", candidates: result.candidates };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const validation = validateEdit(result.edits);
|
|
69
|
+
if (!validation.safe) {
|
|
70
|
+
return { kind: "invalid-input", message: `Refactor safety check failed: ${validation.reason}` };
|
|
71
|
+
}
|
|
72
|
+
const authority = establishMutationAuthority(
|
|
73
|
+
result.edits.edits.map((edit) => edit.file),
|
|
74
|
+
result.authorizedMutationRoots,
|
|
75
|
+
);
|
|
76
|
+
if (authority.kind === "unavailable") return authority;
|
|
77
|
+
const fileFingerprints = collectFileFingerprints(
|
|
78
|
+
result.edits.edits,
|
|
79
|
+
plan.sourceFingerprint ? { file: plan.file, fingerprint: plan.sourceFingerprint } : undefined,
|
|
80
|
+
);
|
|
81
|
+
const snapshotError = validateSynchronizedContentFingerprints(
|
|
82
|
+
result.edits.documentPreconditions,
|
|
83
|
+
fileFingerprints,
|
|
84
|
+
deps.cwd,
|
|
85
|
+
);
|
|
86
|
+
if (snapshotError) return { kind: "unavailable", reason: snapshotError };
|
|
87
|
+
const changed = dropIdentityEdits(result.edits, fileFingerprints);
|
|
88
|
+
if (changed.kind === "unavailable") return changed;
|
|
89
|
+
if (changed.edits.edits.length === 0) {
|
|
90
|
+
return {
|
|
91
|
+
kind: "invalid-input",
|
|
92
|
+
message: `The ${plan.operation} refactor produces no changes; every planned edit matches the current text.`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const stored: RefactorPlan = {
|
|
97
|
+
id: generatePlanId(plan.operation, plan.file, plan.discriminator),
|
|
98
|
+
operation: plan.operation,
|
|
99
|
+
file: plan.file,
|
|
100
|
+
...plan.fields,
|
|
101
|
+
...(result.action ? { action: { ...result.action } } : {}),
|
|
102
|
+
edits: changed.edits,
|
|
103
|
+
evidenceSource: plan.evidenceSource,
|
|
104
|
+
authorizedMutationRoots: authority.canonicalRoots,
|
|
105
|
+
fileFingerprints: changed.fileFingerprints,
|
|
106
|
+
createdAt: Date.now(),
|
|
107
|
+
};
|
|
108
|
+
deps.storePlan(stored);
|
|
109
|
+
return { kind: "completed", plan: immutablePlan(stored) };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Ask the active semantic provider for one refactor result. */
|
|
113
|
+
export async function planWithProvider(
|
|
114
|
+
provider: SemanticProvider | null,
|
|
115
|
+
request: RefactorRequest,
|
|
116
|
+
control?: WorkflowControl,
|
|
117
|
+
): Promise<RefactorResult> {
|
|
118
|
+
if (!provider) return { kind: "unavailable", reason: "No semantic provider is active." };
|
|
119
|
+
if (provider.refactor) return provider.refactor(request, control);
|
|
120
|
+
if (request.operation === "rename_symbol" && provider.rename) {
|
|
121
|
+
return provider.rename(request.file, request.position, request.newName, control);
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
kind: "unavailable",
|
|
125
|
+
reason: `The semantic provider cannot plan ${request.operation}.`,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Freeze a stored plan before it leaves the session. */
|
|
130
|
+
export function immutablePlan(plan: RefactorPlan): Readonly<RefactorPlan> {
|
|
131
|
+
return Object.freeze({
|
|
132
|
+
...plan,
|
|
133
|
+
...(plan.target ? { target: Object.freeze({ ...plan.target }) } : {}),
|
|
134
|
+
...(plan.range ? { range: Object.freeze({ ...plan.range }) } : {}),
|
|
135
|
+
...(plan.action ? { action: Object.freeze({ ...plan.action }) } : {}),
|
|
136
|
+
edits: Object.freeze({
|
|
137
|
+
...plan.edits,
|
|
138
|
+
edits: Object.freeze(plan.edits.edits.map((edit) => Object.freeze({ ...edit }))),
|
|
139
|
+
documentPreconditions: plan.edits.documentPreconditions
|
|
140
|
+
? Object.freeze(
|
|
141
|
+
plan.edits.documentPreconditions.map((precondition) =>
|
|
142
|
+
Object.freeze({ ...precondition }),
|
|
143
|
+
),
|
|
144
|
+
)
|
|
145
|
+
: undefined,
|
|
146
|
+
}),
|
|
147
|
+
authorizedMutationRoots: Object.freeze([...plan.authorizedMutationRoots]),
|
|
148
|
+
fileFingerprints: Object.freeze(
|
|
149
|
+
plan.fileFingerprints.map((fingerprint) => Object.freeze({ ...fingerprint })),
|
|
150
|
+
),
|
|
151
|
+
}) as Readonly<RefactorPlan>;
|
|
152
|
+
}
|
|
@@ -8,17 +8,27 @@
|
|
|
8
8
|
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import { readFileSync } from "node:fs";
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
RefactorActionIdentity,
|
|
13
|
+
RefactorOperation,
|
|
14
|
+
WorkspaceEdit,
|
|
15
|
+
} from "@mrclrchtr/supi-code-runtime/api";
|
|
12
16
|
import { toDisplayPath } from "../analysis/search/paths.ts";
|
|
17
|
+
import type { PublicSourceRange } from "./refactor-types.ts";
|
|
13
18
|
|
|
14
19
|
export interface RefactorPlan {
|
|
15
20
|
id: string;
|
|
16
21
|
operation: RefactorOperation;
|
|
22
|
+
/** Absolute file the operation was requested for. */
|
|
23
|
+
file: string;
|
|
24
|
+
/** `rename_symbol`: the requested name. */
|
|
17
25
|
newName?: string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
/** `rename_symbol`: one-based target position in `file`. */
|
|
27
|
+
target?: { line: number; character: number };
|
|
28
|
+
/** `code_action`: the one-based requested range in `file`. */
|
|
29
|
+
range?: PublicSourceRange;
|
|
30
|
+
/** `code_action` / `source_action`: the selected server action. */
|
|
31
|
+
action?: RefactorActionIdentity;
|
|
22
32
|
edits: WorkspaceEdit;
|
|
23
33
|
/** Evidence source used to compose this plan. */
|
|
24
34
|
evidenceSource?: "semantic" | "structural";
|
|
@@ -56,17 +66,10 @@ export function validateSynchronizedContentFingerprints(
|
|
|
56
66
|
return null;
|
|
57
67
|
}
|
|
58
68
|
|
|
59
|
-
/** Generate a
|
|
60
|
-
|
|
61
|
-
export function generatePlanId(
|
|
62
|
-
operation: string,
|
|
63
|
-
file: string,
|
|
64
|
-
line: number,
|
|
65
|
-
character: number,
|
|
66
|
-
discriminator: string = "",
|
|
67
|
-
): string {
|
|
69
|
+
/** Generate a plan id from operation details and a time discriminator. */
|
|
70
|
+
export function generatePlanId(operation: string, file: string, discriminator: string): string {
|
|
68
71
|
const hash = createHash("sha256")
|
|
69
|
-
.update(`${operation}:${file}:${
|
|
72
|
+
.update(`${operation}:${file}:${discriminator}:${Date.now()}`)
|
|
70
73
|
.digest("hex")
|
|
71
74
|
.slice(0, 12);
|
|
72
75
|
return `plan-${hash}`;
|
|
@@ -6,38 +6,50 @@ import type { RefactorTargetInput, SourcePointInput } from "./target-input.ts";
|
|
|
6
6
|
/** Public refactor operations exposed by code_refactor_plan. */
|
|
7
7
|
export const PUBLIC_REFACTOR_OPERATION_NAMES = [
|
|
8
8
|
"rename_symbol",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"update_imports",
|
|
12
|
-
"delete_dead_code",
|
|
9
|
+
"code_action",
|
|
10
|
+
"source_action",
|
|
13
11
|
] as const;
|
|
14
12
|
|
|
15
13
|
export type PublicRefactorOperationName = (typeof PUBLIC_REFACTOR_OPERATION_NAMES)[number];
|
|
16
14
|
|
|
15
|
+
/** One-based public source range; the end is exclusive. */
|
|
17
16
|
export interface PublicSourceRange {
|
|
18
17
|
readonly start: Omit<SourcePointInput, "file">;
|
|
19
18
|
readonly end: Omit<SourcePointInput, "file">;
|
|
20
19
|
}
|
|
21
20
|
|
|
21
|
+
/**
|
|
22
|
+
* One refactor operation with its own scope. Only `rename_symbol` needs a
|
|
23
|
+
* symbol target; code and source actions name a file directly.
|
|
24
|
+
*/
|
|
22
25
|
export type RefactorOperationInput =
|
|
23
|
-
| { readonly rename_symbol: { readonly newName: string } }
|
|
24
26
|
| {
|
|
25
|
-
readonly
|
|
27
|
+
readonly rename_symbol: {
|
|
28
|
+
readonly target: RefactorTargetInput;
|
|
26
29
|
readonly newName: string;
|
|
27
|
-
readonly range: PublicSourceRange;
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
32
|
| {
|
|
31
|
-
readonly
|
|
32
|
-
readonly
|
|
33
|
+
readonly code_action: {
|
|
34
|
+
readonly file: string;
|
|
33
35
|
readonly range: PublicSourceRange;
|
|
36
|
+
/** CodeActionKind prefix under `refactor`. */
|
|
37
|
+
readonly kind: string;
|
|
38
|
+
/** Exact action title that selects one matching action. */
|
|
39
|
+
readonly title?: string;
|
|
34
40
|
};
|
|
35
41
|
}
|
|
36
|
-
| {
|
|
37
|
-
|
|
42
|
+
| {
|
|
43
|
+
readonly source_action: {
|
|
44
|
+
readonly file: string;
|
|
45
|
+
/** CodeActionKind prefix under `source`. */
|
|
46
|
+
readonly kind: string;
|
|
47
|
+
/** Exact action title that selects one matching action. */
|
|
48
|
+
readonly title?: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
38
51
|
|
|
39
52
|
export interface RefactorPlanWorkflowInput {
|
|
40
|
-
readonly target: RefactorTargetInput;
|
|
41
53
|
readonly operation: RefactorOperationInput;
|
|
42
54
|
}
|
|
43
55
|
|