@mrclrchtr/supi-code-intelligence 4.10.0 → 6.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/README.md +4 -3
- package/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
- package/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
- package/node_modules/@mrclrchtr/supi-core/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
- package/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
- package/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
- package/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +111 -5
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
- 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 +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +7 -6
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +22 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +245 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +78 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +171 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-evidence.ts +413 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +15 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-publication.ts +214 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-pull.ts +62 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +690 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +97 -16
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-waiters.ts +206 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +448 -298
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +70 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +231 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +25 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +529 -119
- package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +161 -33
- package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +12 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +5 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/config/defaults.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-extends.ts +68 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-path.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +176 -24
- package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +45 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/workspace-sentinels.ts +46 -10
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +79 -9
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-diagnostics.ts +17 -7
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +350 -26
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +5 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +586 -96
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +130 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +45 -329
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +57 -120
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +320 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +207 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/readiness.ts +72 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +151 -26
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +92 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +165 -118
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +49 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +102 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +17 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
- 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 +9 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/LICENSE +21 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/README.md +258 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/babel.cjs +257 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/jiti.cjs +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-cli.mjs +34 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-native.mjs +121 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.d.mts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.mjs +4 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-static.mjs +23 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.cjs +30 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.cts +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.mts +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.mjs +29 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/types.d.ts +420 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/package.json +146 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +6 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +0 -9
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +0 -8
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +16 -12
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +65 -87
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +47 -95
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-timing.ts +147 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client-lifecycle.ts +39 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +561 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-message-size.ts +24 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +452 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +4 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +12 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +4 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/imports.ts +4 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +5 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +33 -12
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/blocking-test-bootstrap.mjs +34 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/bootstrap.mjs +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store-helpers.ts +23 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store.ts +400 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/request-control.ts +48 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-parser-helpers.ts +24 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-query-helpers.ts +43 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +421 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +116 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +201 -0
- package/package.json +5 -5
- package/src/analysis/health/diagnostics.ts +221 -77
- package/src/analysis/health/file-scope.ts +184 -0
- package/src/analysis/health/recovery.ts +14 -3
- package/src/analysis/provider.ts +58 -0
- package/src/analysis/readiness.ts +34 -9
- package/src/analysis/refactor/apply.ts +45 -1
- package/src/analysis/refactor/mutation-authority.ts +143 -0
- package/src/analysis/relations/callees.ts +9 -1
- package/src/analysis/relations/types.ts +5 -2
- package/src/analysis/search/ast-scan-timing.ts +9 -2
- package/src/analysis/search/ast-scan.ts +5 -2
- package/src/analysis/search/deadline.ts +2 -2
- package/src/analysis/search/pattern-analysis.ts +54 -33
- package/src/analysis/search/pattern.ts +18 -3
- package/src/analysis/target/anchored.ts +20 -11
- package/src/analysis/target/file.ts +18 -11
- package/src/analysis/target/identity.ts +19 -3
- package/src/analysis/target/symbol.ts +36 -15
- package/src/api.ts +4 -0
- package/src/config.ts +35 -1
- package/src/diagnostics/evidence.ts +51 -0
- package/src/extension.ts +57 -14
- package/src/overview/overview-data.ts +9 -2
- package/src/overview/overview.ts +49 -30
- package/src/overview/types.ts +2 -0
- package/src/session/capability-adapter.ts +12 -3
- package/src/session/find-types.ts +2 -2
- package/src/session/find-workflow.ts +20 -9
- package/src/session/graph/collect.ts +18 -2
- package/src/session/graph-workflow.ts +19 -12
- package/src/session/health-refresh.ts +175 -0
- package/src/session/health-types.ts +43 -15
- package/src/session/health-workflow.ts +69 -54
- package/src/session/input/workflows.ts +2 -2
- package/src/session/inspect/collect.ts +20 -3
- package/src/session/inspect-workflow.ts +12 -6
- package/src/session/orientation/collect.ts +12 -3
- package/src/session/orientation/context-facts.ts +3 -1
- package/src/session/orientation/context-sections.ts +20 -7
- package/src/session/orientation/gather.ts +17 -11
- package/src/session/orientation-types.ts +4 -1
- package/src/session/orientation-workflow.ts +23 -10
- package/src/session/refactor-plans.ts +2 -0
- package/src/session/refactor-workflow.ts +61 -15
- package/src/session/session.ts +29 -2
- package/src/session/target-workflow.ts +54 -23
- package/src/session/workflow-control.ts +7 -3
- package/src/substrate/lsp/lifecycle.ts +26 -46
- package/src/substrate/lsp/maintenance.ts +284 -28
- package/src/substrate/lsp/recovery.ts +11 -5
- package/src/substrate/lsp/state.ts +2 -2
- package/src/substrate/workspace-provider-host.ts +25 -3
- package/src/tool/{find → code_find}/execute.ts +2 -16
- package/src/tool/code_find/guidance.ts +8 -0
- package/src/tool/{find → code_find}/render.ts +21 -4
- package/src/tool/{result/find.ts → code_find/result.ts} +78 -9
- package/src/tool/code_find/spec.ts +37 -0
- package/src/tool/code_find/tui.ts +41 -0
- package/src/tool/code_graph/execute.ts +24 -0
- package/src/tool/code_graph/guidance.ts +6 -0
- package/src/tool/{graph → code_graph}/markdown.ts +1 -1
- package/src/tool/{result/graph.ts → code_graph/result.ts} +111 -3
- package/src/tool/code_graph/spec.ts +39 -0
- package/src/tool/code_graph/tui.ts +117 -0
- package/src/tool/{health → code_health}/execute.ts +2 -13
- package/src/tool/code_health/guidance.ts +8 -0
- package/src/tool/{health → code_health}/markdown.ts +119 -27
- package/src/tool/code_health/refresh-status.ts +105 -0
- package/src/tool/{result/health.ts → code_health/result.ts} +80 -3
- package/src/tool/code_health/spec.ts +41 -0
- package/src/tool/{health → code_health}/tui.ts +95 -98
- package/src/tool/{inspect → code_inspect}/execute.ts +2 -16
- package/src/tool/code_inspect/guidance.ts +6 -0
- package/src/tool/{inspect → code_inspect}/markdown.ts +1 -1
- package/src/tool/{result/inspect.ts → code_inspect/result.ts} +143 -2
- package/src/tool/code_inspect/spec.ts +25 -0
- package/src/tool/code_inspect/tui.ts +44 -0
- package/src/tool/code_orientation/execute.ts +25 -0
- package/src/tool/code_orientation/guidance.ts +9 -0
- package/src/tool/{orientation → code_orientation}/markdown.ts +1 -1
- package/src/tool/code_orientation/result.ts +248 -0
- package/src/tool/code_orientation/spec.ts +25 -0
- package/src/tool/{orientation → code_orientation}/tui.ts +51 -35
- package/src/tool/code_refactor_apply/execute.ts +17 -0
- package/src/tool/code_refactor_apply/guidance.ts +5 -0
- package/src/tool/{refactor-apply/execute.ts → code_refactor_apply/result.ts} +8 -11
- package/src/tool/code_refactor_apply/spec.ts +26 -0
- package/src/tool/code_refactor_apply/tui.ts +73 -0
- package/src/tool/code_refactor_plan/execute.ts +27 -0
- package/src/tool/code_refactor_plan/guidance.ts +8 -0
- package/src/tool/{refactor-plan/execute.ts → code_refactor_plan/result.ts} +13 -22
- package/src/tool/code_refactor_plan/spec.ts +25 -0
- package/src/tool/code_refactor_plan/tui.ts +54 -0
- package/src/tool/code_resolve/execute.ts +19 -0
- package/src/tool/code_resolve/guidance.ts +8 -0
- package/src/tool/{resolve → code_resolve}/markdown.ts +1 -1
- package/src/tool/{result/resolve.ts → code_resolve/result.ts} +79 -29
- package/src/tool/code_resolve/spec.ts +25 -0
- package/src/tool/code_resolve/tui.ts +60 -0
- package/src/tool/guidance.ts +71 -52
- package/src/tool/infra/truncate.ts +40 -0
- package/src/tool/infra/workflow-control.ts +8 -0
- package/src/tool/{refactor-plan/markdown.ts → refactor-markdown.ts} +4 -7
- package/src/tool/register.ts +105 -88
- package/src/tool/result/display.ts +107 -0
- package/src/tool/result/errors.ts +20 -17
- package/src/tool/result/refactor.ts +37 -8
- package/src/tool/result/types.ts +20 -0
- package/src/tool/schemas.ts +26 -157
- package/src/tool/specs.ts +40 -126
- package/src/types/execution.ts +18 -5
- package/src/types/index.ts +8 -1
- package/src/ui/status-command.ts +5 -3
- package/src/ui/status-overlay.ts +4 -0
- package/src/ui/tui/common.ts +108 -10
- package/src/ui/tui/display.ts +48 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime.ts +0 -351
- package/src/tool/find/tui.ts +0 -39
- package/src/tool/graph/execute.ts +0 -62
- package/src/tool/graph/tui.ts +0 -104
- package/src/tool/inspect/tui.ts +0 -36
- package/src/tool/orientation/execute.ts +0 -62
- package/src/tool/refactor-apply/tui.ts +0 -55
- package/src/tool/refactor-plan/tui.ts +0 -41
- package/src/tool/resolve/execute.ts +0 -36
- package/src/tool/resolve/tui.ts +0 -42
- package/src/tool/result/orientation.ts +0 -132
- /package/src/tool/{find → code_find}/ast-kinds.ts +0 -0
- /package/src/tool/{find → code_find}/markdown.ts +0 -0
- /package/src/tool/{find → code_find}/modes.ts +0 -0
- /package/src/tool/{health → code_health}/semantic-state.ts +0 -0
|
@@ -3,16 +3,22 @@
|
|
|
3
3
|
// and notification/request dispatching through vscode-jsonrpc's MessageConnection.
|
|
4
4
|
|
|
5
5
|
import type { Readable, Writable } from "node:stream";
|
|
6
|
+
import {
|
|
7
|
+
type CodeRequestControl,
|
|
8
|
+
CodeRequestDeadlineError,
|
|
9
|
+
} from "@mrclrchtr/supi-code-runtime/api";
|
|
6
10
|
import { startDebugTimer } from "@mrclrchtr/supi-core/debug";
|
|
7
11
|
import {
|
|
8
12
|
CancellationTokenSource,
|
|
9
13
|
createMessageConnection,
|
|
14
|
+
ErrorCodes,
|
|
10
15
|
type MessageConnection,
|
|
11
16
|
NullLogger,
|
|
12
17
|
ResponseError,
|
|
13
18
|
StreamMessageReader,
|
|
14
19
|
StreamMessageWriter,
|
|
15
20
|
} from "vscode-jsonrpc/node";
|
|
21
|
+
import { boundCwd, LSP_REQUEST_TIMEOUT_ERROR_CODE, truncateIdentity } from "../debug-telemetry.ts";
|
|
16
22
|
|
|
17
23
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
18
24
|
|
|
@@ -37,13 +43,19 @@ export class JsonRpcClient {
|
|
|
37
43
|
private requestHandler: RequestHandler | null = null;
|
|
38
44
|
private closed = false;
|
|
39
45
|
private readonly timeoutMs: number;
|
|
46
|
+
private readonly server: string | undefined;
|
|
47
|
+
private readonly cwd: string | undefined;
|
|
48
|
+
/** Failures that signal a stalled protocol: repeated errors and local timeouts. */
|
|
49
|
+
private protocolFailureCount = 0;
|
|
40
50
|
|
|
41
51
|
constructor(
|
|
42
52
|
private readonly input: Readable,
|
|
43
53
|
private readonly output: Writable,
|
|
44
|
-
options?: { timeoutMs?: number },
|
|
54
|
+
options?: { timeoutMs?: number; server?: string; cwd?: string },
|
|
45
55
|
) {
|
|
46
56
|
this.timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
57
|
+
this.server = options?.server;
|
|
58
|
+
this.cwd = options?.cwd;
|
|
47
59
|
|
|
48
60
|
const reader = new StreamMessageReader(this.input);
|
|
49
61
|
const writer = new StreamMessageWriter(this.output);
|
|
@@ -55,6 +67,13 @@ export class JsonRpcClient {
|
|
|
55
67
|
this.notificationHandler?.(method, params);
|
|
56
68
|
});
|
|
57
69
|
|
|
70
|
+
// vscode-jsonrpc registers an internal $/progress handler that never
|
|
71
|
+
// reaches the catch-all handler. Route it explicitly so LSP progress
|
|
72
|
+
// notifications reach the client's readiness state machine.
|
|
73
|
+
this.connection.onNotification("$/progress", (params) => {
|
|
74
|
+
this.notificationHandler?.("$/progress", params);
|
|
75
|
+
});
|
|
76
|
+
|
|
58
77
|
// Register catch-all request handler for server-initiated requests
|
|
59
78
|
this.connection.onRequest(async (method, params, _token) => {
|
|
60
79
|
if (!this.requestHandler) {
|
|
@@ -85,26 +104,53 @@ export class JsonRpcClient {
|
|
|
85
104
|
sendRequest(
|
|
86
105
|
method: string,
|
|
87
106
|
params?: unknown,
|
|
88
|
-
options?: { timeoutMs?: number },
|
|
107
|
+
options?: { timeoutMs?: number } & CodeRequestControl,
|
|
89
108
|
): Promise<unknown> {
|
|
90
109
|
const timeoutMs = options?.timeoutMs ?? this.timeoutMs;
|
|
110
|
+
const signal = options?.signal;
|
|
111
|
+
const deadlineMs = options?.deadline === undefined ? undefined : options.deadline - Date.now();
|
|
91
112
|
const methodClass = classifyRequestMethod(method);
|
|
113
|
+
const boundedMethod = truncateIdentity(method);
|
|
92
114
|
const timer = startDebugTimer();
|
|
115
|
+
// An expired absolute deadline must not even send the request: the caller
|
|
116
|
+
// no longer awaits a result, so no protocol traffic may start.
|
|
117
|
+
if (deadlineMs !== undefined && deadlineMs <= 0) {
|
|
118
|
+
recordRequestTiming(
|
|
119
|
+
timer,
|
|
120
|
+
options?.operationId,
|
|
121
|
+
{
|
|
122
|
+
method: boundedMethod,
|
|
123
|
+
methodClass,
|
|
124
|
+
outcome: "timed-out",
|
|
125
|
+
errorCode: LSP_REQUEST_TIMEOUT_ERROR_CODE,
|
|
126
|
+
},
|
|
127
|
+
{ server: this.server, cwd: this.cwd },
|
|
128
|
+
);
|
|
129
|
+
return Promise.reject(new CodeRequestDeadlineError());
|
|
130
|
+
}
|
|
93
131
|
if (this.closed || !this.connection) {
|
|
94
|
-
recordRequestTiming(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
132
|
+
recordRequestTiming(
|
|
133
|
+
timer,
|
|
134
|
+
options?.operationId,
|
|
135
|
+
{
|
|
136
|
+
method: boundedMethod,
|
|
137
|
+
methodClass,
|
|
138
|
+
outcome: "cancelled",
|
|
139
|
+
},
|
|
140
|
+
{ server: this.server, cwd: this.cwd },
|
|
141
|
+
);
|
|
101
142
|
return Promise.reject(new Error("JSON-RPC client is closed"));
|
|
102
143
|
}
|
|
103
|
-
|
|
104
144
|
const tokenSource = new CancellationTokenSource();
|
|
105
145
|
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
106
146
|
let timedOut = false;
|
|
107
|
-
|
|
147
|
+
let aborted = false;
|
|
148
|
+
const timerDelayMs = deadlineMs === undefined ? timeoutMs : Math.min(timeoutMs, deadlineMs);
|
|
149
|
+
const timeoutError = Object.assign(
|
|
150
|
+
new Error(`Request ${method} timed out after ${timerDelayMs}ms`),
|
|
151
|
+
{ code: LSP_REQUEST_TIMEOUT_ERROR_CODE },
|
|
152
|
+
);
|
|
153
|
+
const abortError = new Error(`Request ${method} was cancelled`);
|
|
108
154
|
|
|
109
155
|
const request = this.connection.sendRequest(method, params, tokenSource.token);
|
|
110
156
|
// Catch the raw request promise to prevent unhandled rejections when
|
|
@@ -115,46 +161,79 @@ export class JsonRpcClient {
|
|
|
115
161
|
// the JSON-RPC token and rejects the caller. Using one timer avoids
|
|
116
162
|
// a leak where the rejecting timer in a second Promise stays alive
|
|
117
163
|
// after a successful response.
|
|
164
|
+
let abortHandler: (() => void) | undefined;
|
|
165
|
+
const abort = new Promise<never>((_resolve, reject) => {
|
|
166
|
+
abortHandler = () => {
|
|
167
|
+
aborted = true;
|
|
168
|
+
tokenSource.cancel();
|
|
169
|
+
// Reject with the caller's abort reason when one exists, matching the
|
|
170
|
+
// canonical throwIfCodeRequestInterrupted() behavior.
|
|
171
|
+
reject(signal?.reason ?? abortError);
|
|
172
|
+
};
|
|
173
|
+
if (signal?.aborted) abortHandler();
|
|
174
|
+
else signal?.addEventListener("abort", abortHandler, { once: true });
|
|
175
|
+
});
|
|
118
176
|
const promise = Promise.race([
|
|
119
177
|
request,
|
|
120
178
|
new Promise<never>((_resolve, reject) => {
|
|
121
179
|
timeout = setTimeout(() => {
|
|
122
180
|
timedOut = true;
|
|
123
181
|
tokenSource.cancel();
|
|
124
|
-
|
|
125
|
-
|
|
182
|
+
// A deadline that binds earlier than the timeout is a deadline
|
|
183
|
+
// outcome, distinct from an ordinary per-request timeout.
|
|
184
|
+
reject(
|
|
185
|
+
deadlineMs !== undefined && deadlineMs < timeoutMs
|
|
186
|
+
? new CodeRequestDeadlineError()
|
|
187
|
+
: timeoutError,
|
|
188
|
+
);
|
|
189
|
+
}, timerDelayMs);
|
|
126
190
|
}),
|
|
191
|
+
abort,
|
|
127
192
|
])
|
|
128
193
|
.then(
|
|
129
194
|
(result) => {
|
|
130
|
-
recordRequestTiming(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
195
|
+
recordRequestTiming(
|
|
196
|
+
timer,
|
|
197
|
+
options?.operationId,
|
|
198
|
+
{
|
|
199
|
+
method: boundedMethod,
|
|
200
|
+
methodClass,
|
|
201
|
+
outcome: "completed",
|
|
202
|
+
},
|
|
203
|
+
{ server: this.server, cwd: this.cwd },
|
|
204
|
+
);
|
|
137
205
|
return result;
|
|
138
206
|
},
|
|
139
207
|
(error: unknown) => {
|
|
140
|
-
const cancelled = timedOut || this.closed || isCancellationError(error);
|
|
208
|
+
const cancelled = timedOut || aborted || this.closed || isCancellationError(error);
|
|
141
209
|
const outcome: RequestOutcome = timedOut
|
|
142
210
|
? "timed-out"
|
|
143
211
|
: cancelled
|
|
144
212
|
? "cancelled"
|
|
145
213
|
: "failed";
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
214
|
+
const errorCode = requestErrorCode(outcome, error);
|
|
215
|
+
this.countProtocolStallFailure(outcome, errorCode, error);
|
|
216
|
+
recordRequestTiming(
|
|
217
|
+
timer,
|
|
218
|
+
options?.operationId,
|
|
219
|
+
{
|
|
220
|
+
method: boundedMethod,
|
|
221
|
+
methodClass,
|
|
222
|
+
outcome,
|
|
223
|
+
// Failed requests record the server-reported JSON-RPC error code
|
|
224
|
+
// when the error carries one; timed-out requests record the
|
|
225
|
+
// defined timeout code (also for deadline expiries, whose error
|
|
226
|
+
// carries none); cancellations carry no error code.
|
|
227
|
+
errorCode,
|
|
228
|
+
},
|
|
229
|
+
{ server: this.server, cwd: this.cwd },
|
|
230
|
+
);
|
|
153
231
|
throw error;
|
|
154
232
|
},
|
|
155
233
|
)
|
|
156
234
|
.finally(() => {
|
|
157
235
|
if (timeout !== undefined) clearTimeout(timeout);
|
|
236
|
+
if (abortHandler) signal?.removeEventListener("abort", abortHandler);
|
|
158
237
|
});
|
|
159
238
|
|
|
160
239
|
// Prevent unhandled rejection when dispose() cancels requests
|
|
@@ -184,6 +263,30 @@ export class JsonRpcClient {
|
|
|
184
263
|
this.connection = null;
|
|
185
264
|
}
|
|
186
265
|
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Count one protocol-stall failure: a local timeout (not a caller-imposed
|
|
269
|
+
* deadline expiry) or a repeated server-reported protocol error. A deadline
|
|
270
|
+
* expiry is not a stall: the request may be perfectly healthy (ADR 0020).
|
|
271
|
+
*/
|
|
272
|
+
private countProtocolStallFailure(
|
|
273
|
+
outcome: RequestOutcome,
|
|
274
|
+
errorCode: number | undefined,
|
|
275
|
+
error: unknown,
|
|
276
|
+
): void {
|
|
277
|
+
if (
|
|
278
|
+
(outcome === "timed-out" && !(error instanceof CodeRequestDeadlineError)) ||
|
|
279
|
+
errorCode === ErrorCodes.ServerNotInitialized ||
|
|
280
|
+
errorCode === ErrorCodes.InvalidRequest
|
|
281
|
+
) {
|
|
282
|
+
this.protocolFailureCount++;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** Number of protocol-stall failures observed on this connection. */
|
|
287
|
+
getProtocolFailureCount(): number {
|
|
288
|
+
return this.protocolFailureCount;
|
|
289
|
+
}
|
|
187
290
|
}
|
|
188
291
|
|
|
189
292
|
const SEMANTIC_REQUESTS = new Set([
|
|
@@ -218,25 +321,50 @@ function isCancellationError(error: unknown): boolean {
|
|
|
218
321
|
);
|
|
219
322
|
}
|
|
220
323
|
|
|
324
|
+
/** One bounded request-timing observation with exact method identity. */
|
|
221
325
|
interface RequestTimingObservation {
|
|
326
|
+
readonly method: string;
|
|
222
327
|
readonly methodClass: RequestMethodClass;
|
|
223
328
|
readonly outcome: RequestOutcome;
|
|
224
|
-
|
|
225
|
-
readonly
|
|
226
|
-
|
|
329
|
+
/** JSON-RPC error code reported by the server for a failed request. */
|
|
330
|
+
readonly errorCode?: number;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Return the JSON-RPC error code for one request outcome. */
|
|
334
|
+
function requestErrorCode(outcome: RequestOutcome, error: unknown): number | undefined {
|
|
335
|
+
if (outcome === "failed") return jsonRpcErrorCode(error);
|
|
336
|
+
if (outcome === "timed-out") return jsonRpcErrorCode(error) ?? LSP_REQUEST_TIMEOUT_ERROR_CODE;
|
|
337
|
+
return undefined;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** Return the numeric JSON-RPC error code carried by an error, if any. */
|
|
341
|
+
function jsonRpcErrorCode(error: unknown): number | undefined {
|
|
342
|
+
if (typeof error !== "object" || error === null) return undefined;
|
|
343
|
+
const code = (error as { code?: unknown }).code;
|
|
344
|
+
return typeof code === "number" && Number.isInteger(code) ? code : undefined;
|
|
227
345
|
}
|
|
228
346
|
|
|
229
347
|
function recordRequestTiming(
|
|
230
348
|
timer: ReturnType<typeof startDebugTimer>,
|
|
349
|
+
operationId: string | undefined,
|
|
231
350
|
observation: RequestTimingObservation,
|
|
351
|
+
identity: { server?: string; cwd?: string },
|
|
232
352
|
): void {
|
|
233
353
|
timer.finish(
|
|
234
354
|
() => ({
|
|
355
|
+
operationId,
|
|
235
356
|
source: "lsp",
|
|
236
357
|
level: "debug",
|
|
237
358
|
category: "request.timing",
|
|
238
|
-
message: `LSP ${observation.methodClass} request ${observation.outcome}`,
|
|
239
|
-
|
|
359
|
+
message: `LSP ${observation.methodClass} request ${observation.outcome} for ${observation.method}`,
|
|
360
|
+
cwd: boundCwd(identity.cwd),
|
|
361
|
+
data: {
|
|
362
|
+
method: observation.method,
|
|
363
|
+
methodClass: observation.methodClass,
|
|
364
|
+
outcome: observation.outcome,
|
|
365
|
+
...(identity.server !== undefined ? { server: truncateIdentity(identity.server) } : {}),
|
|
366
|
+
...(observation.errorCode !== undefined ? { errorCode: observation.errorCode } : {}),
|
|
367
|
+
},
|
|
240
368
|
}),
|
|
241
369
|
"request",
|
|
242
370
|
);
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
import type { ClientCapabilities } from "./types.ts";
|
|
4
4
|
|
|
5
5
|
export const CLIENT_CAPABILITIES: ClientCapabilities = {
|
|
6
|
+
general: {
|
|
7
|
+
positionEncodings: ["utf-16"],
|
|
8
|
+
},
|
|
6
9
|
textDocument: {
|
|
7
10
|
synchronization: {
|
|
8
11
|
didSave: true,
|
|
@@ -49,7 +52,10 @@ export const CLIENT_CAPABILITIES: ClientCapabilities = {
|
|
|
49
52
|
versionSupport: true,
|
|
50
53
|
},
|
|
51
54
|
diagnostic: {
|
|
52
|
-
|
|
55
|
+
// Dynamic registration lets servers such as pyright-langserver register
|
|
56
|
+
// `textDocument/diagnostic` support after initialization. Probes show
|
|
57
|
+
// only Pyright acts on this global flag among the built-in servers.
|
|
58
|
+
dynamicRegistration: true,
|
|
53
59
|
relatedDocumentSupport: true,
|
|
54
60
|
},
|
|
55
61
|
},
|
|
@@ -57,9 +63,12 @@ export const CLIENT_CAPABILITIES: ClientCapabilities = {
|
|
|
57
63
|
workDoneProgress: true,
|
|
58
64
|
},
|
|
59
65
|
workspace: {
|
|
60
|
-
workspaceFolders:
|
|
66
|
+
workspaceFolders: true,
|
|
67
|
+
workspaceEdit: {
|
|
68
|
+
documentChanges: true,
|
|
69
|
+
},
|
|
61
70
|
diagnostics: {
|
|
62
|
-
refreshSupport:
|
|
71
|
+
refreshSupport: true,
|
|
63
72
|
},
|
|
64
73
|
},
|
|
65
74
|
};
|
|
@@ -125,15 +125,15 @@ function mergeSingleServer(
|
|
|
125
125
|
override: Partial<ServerConfig>,
|
|
126
126
|
): ServerConfig | null {
|
|
127
127
|
if (!base) {
|
|
128
|
-
//
|
|
128
|
+
// A custom server needs a command and at least one file extension.
|
|
129
129
|
if (
|
|
130
|
-
override.command &&
|
|
130
|
+
typeof override.command === "string" &&
|
|
131
|
+
override.command.length > 0 &&
|
|
131
132
|
Array.isArray(override.fileTypes) &&
|
|
132
133
|
override.fileTypes.length > 0 &&
|
|
133
|
-
Array.isArray(override.rootMarkers)
|
|
134
|
-
override.rootMarkers.length > 0
|
|
134
|
+
(override.rootMarkers === undefined || Array.isArray(override.rootMarkers))
|
|
135
135
|
) {
|
|
136
|
-
return override as ServerConfig;
|
|
136
|
+
return { ...override, rootMarkers: override.rootMarkers ?? [] } as ServerConfig;
|
|
137
137
|
}
|
|
138
138
|
return null;
|
|
139
139
|
}
|
|
@@ -5,8 +5,11 @@ export interface ServerConfig {
|
|
|
5
5
|
command: string;
|
|
6
6
|
args?: string[];
|
|
7
7
|
fileTypes: string[];
|
|
8
|
+
/** Files that identify the project root. An empty list uses the session root. */
|
|
8
9
|
rootMarkers: string[];
|
|
9
10
|
enabled?: boolean;
|
|
11
|
+
/** Environment values added when the server process starts. */
|
|
12
|
+
env?: Record<string, string>;
|
|
10
13
|
initializationOptions?: unknown;
|
|
11
14
|
/** Maximum time to wait for a single $/progress cycle, in ms. Default: 10_000. */
|
|
12
15
|
readinessTimeoutMs?: number;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { normalizeTsconfigPath as normalizePath } from "./tsconfig-path.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Collect recognized local project configs declared by `extends`, including
|
|
7
|
+
* transitive dependencies and paths that do not exist yet.
|
|
8
|
+
*/
|
|
9
|
+
export function collectExtendedProjectConfigs(configPath: string): Set<string> {
|
|
10
|
+
const dependencies = new Set<string>();
|
|
11
|
+
const visited = new Set<string>();
|
|
12
|
+
|
|
13
|
+
const visit = (currentConfigPath: string): void => {
|
|
14
|
+
const normalizedConfigPath = normalizePath(currentConfigPath);
|
|
15
|
+
if (visited.has(normalizedConfigPath)) return;
|
|
16
|
+
visited.add(normalizedConfigPath);
|
|
17
|
+
|
|
18
|
+
const config = ts.readConfigFile(currentConfigPath, ts.sys.readFile).config;
|
|
19
|
+
if (!config || typeof config !== "object") return;
|
|
20
|
+
|
|
21
|
+
const extendsValues =
|
|
22
|
+
typeof config.extends === "string"
|
|
23
|
+
? [config.extends]
|
|
24
|
+
: Array.isArray(config.extends)
|
|
25
|
+
? config.extends.filter((value: unknown): value is string => typeof value === "string")
|
|
26
|
+
: [];
|
|
27
|
+
|
|
28
|
+
for (const extendsValue of extendsValues) {
|
|
29
|
+
const extendedConfigPath = resolveLocalExtendedConfigPath(currentConfigPath, extendsValue);
|
|
30
|
+
if (!extendedConfigPath) continue;
|
|
31
|
+
|
|
32
|
+
const normalizedExtendedConfigPath = normalizePath(extendedConfigPath);
|
|
33
|
+
dependencies.add(normalizedExtendedConfigPath);
|
|
34
|
+
visit(extendedConfigPath);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
visit(configPath);
|
|
39
|
+
return dependencies;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Resolve a local project-config extends entry.
|
|
44
|
+
*
|
|
45
|
+
* Package names are not local paths and are deliberately ignored. TypeScript
|
|
46
|
+
* uses the `.json` suffix for extensionless local config references. Only
|
|
47
|
+
* recognized project-config names are tracked; arbitrary local JSON files may
|
|
48
|
+
* still be parsed by TypeScript but are outside this invalidation contract.
|
|
49
|
+
*/
|
|
50
|
+
function resolveLocalExtendedConfigPath(configPath: string, extendsValue: string): string | null {
|
|
51
|
+
if (!path.isAbsolute(extendsValue) && !/^\.{1,2}(?:[\\/]|$)/.test(extendsValue)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const resolved = path.resolve(path.dirname(configPath), extendsValue);
|
|
56
|
+
const candidate =
|
|
57
|
+
path.extname(resolved).toLowerCase() === ".json" ? resolved : `${resolved}.json`;
|
|
58
|
+
return isProjectConfigFileName(path.basename(candidate)) ? candidate : null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Whether a file name is a tsconfig.json, jsconfig.json, or tsconfig.*.json name. */
|
|
62
|
+
export function isProjectConfigFileName(name: string): boolean {
|
|
63
|
+
return (
|
|
64
|
+
name === "tsconfig.json" ||
|
|
65
|
+
name === "jsconfig.json" ||
|
|
66
|
+
(name.startsWith("tsconfig.") && name.endsWith(".json"))
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
|
|
4
|
+
/** Normalize a path for tsconfig cache keys and comparisons. */
|
|
5
|
+
export function normalizeTsconfigPath(target: string): string {
|
|
6
|
+
const resolved = path.resolve(target).replaceAll("\\", "/");
|
|
7
|
+
return ts.sys.useCaseSensitiveFileNames ? resolved : resolved.toLowerCase();
|
|
8
|
+
}
|