@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
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import type { Diagnostic } from "../config/types.ts";
|
|
3
|
+
import { type DiagnosticCacheEntry, isTentativePushEntry } from "./client-diagnostic-evidence.ts";
|
|
4
|
+
|
|
5
|
+
/** One file's stored diagnostics as consumed by manager-level collection. */
|
|
6
|
+
export interface DiagnosticEntry {
|
|
7
|
+
uri: string;
|
|
8
|
+
diagnostics: Diagnostic[];
|
|
9
|
+
current: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** One tracked document's current diagnostic freshness. */
|
|
13
|
+
export interface ClientDiagnosticDocument {
|
|
14
|
+
uri: string;
|
|
15
|
+
current: boolean;
|
|
16
|
+
status: "confirmed" | "unconfirmed" | "failed" | "removed";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** One client's diagnostic snapshot, including empty cache freshness. */
|
|
20
|
+
export interface ClientDiagnosticSnapshot {
|
|
21
|
+
entries: DiagnosticEntry[];
|
|
22
|
+
documents: ClientDiagnosticDocument[];
|
|
23
|
+
current: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** One open document's current protocol and content state. */
|
|
27
|
+
export interface OpenDocumentState {
|
|
28
|
+
version: number;
|
|
29
|
+
synchronizationId: number;
|
|
30
|
+
evidenceRevision: number;
|
|
31
|
+
/** Last text sent to the server. Used to form incremental changes. */
|
|
32
|
+
content: string;
|
|
33
|
+
contentFingerprint: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Compute a path-free content identity for unchanged-document checks. */
|
|
37
|
+
export function fingerprintDocumentContent(content: string): string {
|
|
38
|
+
return createHash("sha256").update(content).digest("hex");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Test whether cached diagnostics still prove the current document state. */
|
|
42
|
+
export function hasCurrentDiagnosticEvidence(
|
|
43
|
+
document: OpenDocumentState | undefined,
|
|
44
|
+
entry: DiagnosticCacheEntry | undefined,
|
|
45
|
+
evidenceRevision: number,
|
|
46
|
+
): boolean {
|
|
47
|
+
return Boolean(
|
|
48
|
+
document &&
|
|
49
|
+
entry &&
|
|
50
|
+
document.evidenceRevision === evidenceRevision &&
|
|
51
|
+
entry.synchronizationId === document.synchronizationId &&
|
|
52
|
+
entry.evidenceRevision === evidenceRevision,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Test whether cached diagnostics confirm the current document state.
|
|
58
|
+
*
|
|
59
|
+
* A current tentative push matches the document state but cannot support a
|
|
60
|
+
* clean-result or cache-reuse claim until a republish confirms it (ADR 0021).
|
|
61
|
+
*/
|
|
62
|
+
export function hasConfirmedDiagnosticEvidence(
|
|
63
|
+
document: OpenDocumentState | undefined,
|
|
64
|
+
entry: DiagnosticCacheEntry | undefined,
|
|
65
|
+
evidenceRevision: number,
|
|
66
|
+
): boolean {
|
|
67
|
+
return (
|
|
68
|
+
hasCurrentDiagnosticEvidence(document, entry, evidenceRevision) && !isTentativePushEntry(entry)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import type { TextDocumentItem, VersionedTextDocumentIdentifier } from "../config/types.ts";
|
|
3
|
+
import type { DiagnosticSynchronization } from "./client-diagnostic-evidence.ts";
|
|
4
|
+
import type { DiagnosticWaitRegistry } from "./client-diagnostic-waiters.ts";
|
|
5
|
+
import { fingerprintDocumentContent, type OpenDocumentState } from "./client-document-state.ts";
|
|
6
|
+
import { getDiagnosticFileState } from "./client-file-state.ts";
|
|
7
|
+
|
|
8
|
+
type NotificationSender = (method: string, params: unknown) => void;
|
|
9
|
+
|
|
10
|
+
interface SynchronizeDocumentOptions {
|
|
11
|
+
uri: string;
|
|
12
|
+
content: string;
|
|
13
|
+
document: OpenDocumentState;
|
|
14
|
+
version: number;
|
|
15
|
+
synchronizationId: number;
|
|
16
|
+
evidenceRevision: number;
|
|
17
|
+
incrementalSync: boolean;
|
|
18
|
+
waiters: DiagnosticWaitRegistry;
|
|
19
|
+
sendNotification: NotificationSender;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function endPosition(content: string): { line: number; character: number } {
|
|
23
|
+
const lines = content.split(/\r\n|\r|\n/);
|
|
24
|
+
return { line: lines.length - 1, character: lines.at(-1)?.length ?? 0 };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* For incremental sync, replace the old full range with the new text.
|
|
29
|
+
* This is a valid incremental edit and avoids a second text-diff engine.
|
|
30
|
+
*/
|
|
31
|
+
function contentChanges(
|
|
32
|
+
previousContent: string,
|
|
33
|
+
content: string,
|
|
34
|
+
incrementalSync: boolean,
|
|
35
|
+
): unknown[] {
|
|
36
|
+
if (incrementalSync) {
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
range: {
|
|
40
|
+
start: { line: 0, character: 0 },
|
|
41
|
+
end: endPosition(previousContent),
|
|
42
|
+
},
|
|
43
|
+
text: content,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
return [{ text: content }];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Advance and publish one explicit document synchronization. */
|
|
51
|
+
export function synchronizeDocument(options: SynchronizeDocumentOptions): void {
|
|
52
|
+
options.waiters.releaseFile(options.uri);
|
|
53
|
+
options.waiters.cancelSettle();
|
|
54
|
+
options.document.version = options.version;
|
|
55
|
+
options.document.synchronizationId = options.synchronizationId;
|
|
56
|
+
options.document.evidenceRevision = options.evidenceRevision;
|
|
57
|
+
const changes = contentChanges(
|
|
58
|
+
options.document.content,
|
|
59
|
+
options.content,
|
|
60
|
+
options.incrementalSync,
|
|
61
|
+
);
|
|
62
|
+
options.document.content = options.content;
|
|
63
|
+
options.document.contentFingerprint = fingerprintDocumentContent(options.content);
|
|
64
|
+
options.sendNotification("textDocument/didChange", {
|
|
65
|
+
textDocument: {
|
|
66
|
+
uri: options.uri,
|
|
67
|
+
version: options.version,
|
|
68
|
+
} satisfies VersionedTextDocumentIdentifier,
|
|
69
|
+
contentChanges: changes,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Remove one document and release all diagnostic waits for its URI. */
|
|
74
|
+
export function clearTrackedDocumentState(
|
|
75
|
+
openDocuments: Map<string, OpenDocumentState>,
|
|
76
|
+
diagnosticStore: Map<string, unknown>,
|
|
77
|
+
waiters: DiagnosticWaitRegistry,
|
|
78
|
+
uri: string,
|
|
79
|
+
): void {
|
|
80
|
+
openDocuments.delete(uri);
|
|
81
|
+
diagnosticStore.delete(uri);
|
|
82
|
+
waiters.releaseFile(uri);
|
|
83
|
+
waiters.cancelSettle();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Close and reopen one open document while preserving cache and version history. */
|
|
87
|
+
export function reopenDocument(options: {
|
|
88
|
+
uri: string;
|
|
89
|
+
content: string;
|
|
90
|
+
document: OpenDocumentState;
|
|
91
|
+
languageId: string;
|
|
92
|
+
nextVersion(): number;
|
|
93
|
+
nextSynchronizationId(): number;
|
|
94
|
+
evidenceRevision: number;
|
|
95
|
+
waiters: DiagnosticWaitRegistry;
|
|
96
|
+
sendNotification: NotificationSender;
|
|
97
|
+
markUnversionedSyncMoment?(): void;
|
|
98
|
+
}): void {
|
|
99
|
+
// Mirror didClose release semantics: pending waiters for this URI observe
|
|
100
|
+
// the protocol close, and the settle generation is cancelled so concurrent
|
|
101
|
+
// settles re-arm against the reopened state.
|
|
102
|
+
options.waiters.releaseFile(options.uri);
|
|
103
|
+
options.waiters.cancelSettle();
|
|
104
|
+
options.markUnversionedSyncMoment?.();
|
|
105
|
+
options.sendNotification("textDocument/didClose", {
|
|
106
|
+
textDocument: { uri: options.uri },
|
|
107
|
+
});
|
|
108
|
+
const version = options.nextVersion();
|
|
109
|
+
options.document.version = version;
|
|
110
|
+
options.document.synchronizationId = options.nextSynchronizationId();
|
|
111
|
+
options.document.evidenceRevision = options.evidenceRevision;
|
|
112
|
+
options.document.content = options.content;
|
|
113
|
+
options.document.contentFingerprint = fingerprintDocumentContent(options.content);
|
|
114
|
+
options.sendNotification("textDocument/didOpen", {
|
|
115
|
+
textDocument: {
|
|
116
|
+
uri: options.uri,
|
|
117
|
+
languageId: options.languageId,
|
|
118
|
+
version,
|
|
119
|
+
text: options.content,
|
|
120
|
+
} satisfies TextDocumentItem,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Synchronize one open document, or open it when the route is not tracked yet. */
|
|
125
|
+
export function synchronizeTrackedDocument(options: {
|
|
126
|
+
uri: string;
|
|
127
|
+
content: string;
|
|
128
|
+
document: OpenDocumentState | undefined;
|
|
129
|
+
nextVersion(): number;
|
|
130
|
+
nextSynchronizationId(): number;
|
|
131
|
+
evidenceRevision: number;
|
|
132
|
+
incrementalSync: boolean;
|
|
133
|
+
waiters: DiagnosticWaitRegistry;
|
|
134
|
+
sendNotification: NotificationSender;
|
|
135
|
+
markUnversionedSyncMoment?(): void;
|
|
136
|
+
clearFailedFile?(): void;
|
|
137
|
+
open(): void;
|
|
138
|
+
}): void {
|
|
139
|
+
if (!options.document) {
|
|
140
|
+
options.open();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
options.markUnversionedSyncMoment?.();
|
|
144
|
+
synchronizeDocument({
|
|
145
|
+
uri: options.uri,
|
|
146
|
+
content: options.content,
|
|
147
|
+
document: options.document,
|
|
148
|
+
version: options.nextVersion(),
|
|
149
|
+
synchronizationId: options.nextSynchronizationId(),
|
|
150
|
+
evidenceRevision: options.evidenceRevision,
|
|
151
|
+
incrementalSync: options.incrementalSync,
|
|
152
|
+
waiters: options.waiters,
|
|
153
|
+
sendNotification: options.sendNotification,
|
|
154
|
+
});
|
|
155
|
+
options.clearFailedFile?.();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface ResynchronizeDocumentsOptions {
|
|
159
|
+
openDocuments: Map<string, OpenDocumentState>;
|
|
160
|
+
waiters: DiagnosticWaitRegistry;
|
|
161
|
+
nextVersion(uri: string): number;
|
|
162
|
+
nextSynchronizationId(): number;
|
|
163
|
+
evidenceRevision: number;
|
|
164
|
+
incrementalSync: boolean;
|
|
165
|
+
sendNotification: NotificationSender;
|
|
166
|
+
uriToFile(uri: string): string;
|
|
167
|
+
/** Disk content already read by classification; avoids a second read. */
|
|
168
|
+
preloadedContent?: ReadonlyMap<string, string>;
|
|
169
|
+
clearFile(uri: string): void;
|
|
170
|
+
invalidateEvidence(uri: string): void;
|
|
171
|
+
markUnversionedSyncMoment(uri: string): void;
|
|
172
|
+
clearFailedFile(uri: string): void;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Document coverage produced while re-reading tracked files for refresh. */
|
|
176
|
+
export interface ResynchronizeDocumentsResult {
|
|
177
|
+
/** Documents that were synchronized and can receive fresh evidence. */
|
|
178
|
+
synchronizations: DiagnosticSynchronization[];
|
|
179
|
+
/** URIs that received a new didChange synchronization in this pass. */
|
|
180
|
+
resynchronizedUris: ReadonlySet<string>;
|
|
181
|
+
/** Existing tracked documents removed because their files no longer exist. */
|
|
182
|
+
removedFiles: string[];
|
|
183
|
+
/** Existing tracked documents that could not be read or synchronized. */
|
|
184
|
+
failedFiles: string[];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Re-read and synchronize every existing open document. */
|
|
188
|
+
export function resynchronizeOpenDocuments(
|
|
189
|
+
options: ResynchronizeDocumentsOptions,
|
|
190
|
+
): ResynchronizeDocumentsResult {
|
|
191
|
+
const synchronizations: DiagnosticSynchronization[] = [];
|
|
192
|
+
const resynchronizedUris = new Set<string>();
|
|
193
|
+
const removedFiles: string[] = [];
|
|
194
|
+
const failedFiles: string[] = [];
|
|
195
|
+
for (const [uri, document] of options.openDocuments) {
|
|
196
|
+
const filePath = options.uriToFile(uri);
|
|
197
|
+
try {
|
|
198
|
+
options.markUnversionedSyncMoment(uri);
|
|
199
|
+
synchronizeDocument({
|
|
200
|
+
uri,
|
|
201
|
+
content: options.preloadedContent?.get(uri) ?? readFileSync(filePath, "utf-8"),
|
|
202
|
+
document,
|
|
203
|
+
version: options.nextVersion(uri),
|
|
204
|
+
synchronizationId: options.nextSynchronizationId(),
|
|
205
|
+
evidenceRevision: options.evidenceRevision,
|
|
206
|
+
incrementalSync: options.incrementalSync,
|
|
207
|
+
waiters: options.waiters,
|
|
208
|
+
sendNotification: options.sendNotification,
|
|
209
|
+
});
|
|
210
|
+
options.clearFailedFile(uri);
|
|
211
|
+
resynchronizedUris.add(uri);
|
|
212
|
+
synchronizations.push({
|
|
213
|
+
uri,
|
|
214
|
+
synchronizationId: document.synchronizationId,
|
|
215
|
+
evidenceRevision: document.evidenceRevision,
|
|
216
|
+
});
|
|
217
|
+
} catch {
|
|
218
|
+
if (getDiagnosticFileState(filePath) === "removed") {
|
|
219
|
+
options.clearFile(uri);
|
|
220
|
+
options.sendNotification("textDocument/didClose", { textDocument: { uri } });
|
|
221
|
+
removedFiles.push(filePath);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
options.invalidateEvidence(uri);
|
|
225
|
+
options.markUnversionedSyncMoment(uri);
|
|
226
|
+
failedFiles.push(filePath);
|
|
227
|
+
// Keep the document open when a transient read fails.
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return { synchronizations, resynchronizedUris, removedFiles, failedFiles };
|
|
231
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { accessSync, constants, statSync } from "node:fs";
|
|
2
|
+
|
|
3
|
+
/** State used to distinguish deleted files from files that cannot be read. */
|
|
4
|
+
export type DiagnosticFileState = "present" | "removed" | "unreadable";
|
|
5
|
+
|
|
6
|
+
/** Read the file-system state without treating access errors as deletion. */
|
|
7
|
+
export function getDiagnosticFileState(filePath: string): DiagnosticFileState {
|
|
8
|
+
try {
|
|
9
|
+
if (!statSync(filePath).isFile()) return "unreadable";
|
|
10
|
+
accessSync(filePath, constants.R_OK);
|
|
11
|
+
return "present";
|
|
12
|
+
} catch (error) {
|
|
13
|
+
return isMissingFileError(error) ? "removed" : "unreadable";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Identify file-system errors that prove that a tracked path is missing. */
|
|
18
|
+
export function isMissingFileError(error: unknown): boolean {
|
|
19
|
+
return (
|
|
20
|
+
typeof error === "object" &&
|
|
21
|
+
error !== null &&
|
|
22
|
+
"code" in error &&
|
|
23
|
+
(error.code === "ENOENT" || error.code === "ENOTDIR")
|
|
24
|
+
);
|
|
25
|
+
}
|