@duckmind/dm-darwin-x64 0.67.1 → 0.67.3
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 +2 -2
- package/dm +2 -2
- package/extensions/.dm-extensions.json +147 -32
- package/extensions/dm-lens/clients/actionable-warnings.js +12 -4
- package/extensions/dm-lens/clients/advisory-provenance.js +11 -10
- package/extensions/dm-lens/clients/agent-nudge.js +1 -1
- package/extensions/dm-lens/clients/analysis-root.js +75 -34
- package/extensions/dm-lens/clients/bash-file-access.js +550 -123
- package/extensions/dm-lens/clients/blocker-freshness.js +202 -19
- package/extensions/dm-lens/clients/blocker-past-eof.js +3 -1
- package/extensions/dm-lens/clients/bounded-telemetry.js +3 -0
- package/extensions/dm-lens/clients/cache-manager.js +22 -1
- package/extensions/dm-lens/clients/cache-observability.js +278 -17
- package/extensions/dm-lens/clients/cargo-manifest.js +8 -12
- package/extensions/dm-lens/clients/cascade-format.js +162 -19
- package/extensions/dm-lens/clients/codebase-model.js +2 -2
- package/extensions/dm-lens/clients/config-locations.js +1 -8
- package/extensions/dm-lens/clients/content-stamp.js +16 -0
- package/extensions/dm-lens/clients/context-injection-ledger.js +160 -0
- package/extensions/dm-lens/clients/deferred-runner-blockers.js +46 -6
- package/extensions/dm-lens/clients/degradation-ledger.js +21 -1
- package/extensions/dm-lens/clients/deps/ast-grep-napi.js +10 -0
- package/extensions/dm-lens/clients/diagnostic-dispositions.js +28 -12
- package/extensions/dm-lens/clients/disk-change-consumers.js +312 -0
- package/extensions/dm-lens/clients/disk-change-subscribers.js +197 -0
- package/extensions/dm-lens/clients/disk-changes.js +168 -0
- package/extensions/dm-lens/clients/dispatch/auxiliary-lsp.js +10 -6
- package/extensions/dm-lens/clients/dispatch/dispatcher.js +300 -61
- package/extensions/dm-lens/clients/dispatch/fact-store.js +2 -8
- package/extensions/dm-lens/clients/dispatch/facts/function-facts.js +87 -94
- package/extensions/dm-lens/clients/dispatch/finding-policy.js +25 -1
- package/extensions/dm-lens/clients/dispatch/indent-detect.js +1 -1
- package/extensions/dm-lens/clients/dispatch/integration.js +349 -135
- package/extensions/dm-lens/clients/dispatch/lane-copies.js +23 -0
- package/extensions/dm-lens/clients/dispatch/pending-runner-findings.js +3 -0
- package/extensions/dm-lens/clients/dispatch/pre-edit-seed.js +57 -0
- package/extensions/dm-lens/clients/dispatch/rule-id-normalize.js +6 -1
- package/extensions/dm-lens/clients/dispatch/rules/high-complexity.js +2 -17
- package/extensions/dm-lens/clients/dispatch/rules/high-fan-out.js +1 -9
- package/extensions/dm-lens/clients/dispatch/runner-context.js +9 -10
- package/extensions/dm-lens/clients/dispatch/runners/ast-grep-literal-anchors.js +58 -0
- package/extensions/dm-lens/clients/dispatch/runners/ast-grep-napi.js +59 -14
- package/extensions/dm-lens/clients/dispatch/runners/biome-check.js +9 -18
- package/extensions/dm-lens/clients/dispatch/runners/cue-vet.js +11 -21
- package/extensions/dm-lens/clients/dispatch/runners/dart-analyze.js +1 -1
- package/extensions/dm-lens/clients/dispatch/runners/detekt.js +4 -3
- package/extensions/dm-lens/clients/dispatch/runners/dotnet-build.js +15 -6
- package/extensions/dm-lens/clients/dispatch/runners/fish-indent.js +59 -5
- package/extensions/dm-lens/clients/dispatch/runners/gleam-check.js +9 -19
- package/extensions/dm-lens/clients/dispatch/runners/go-vet.js +2 -2
- package/extensions/dm-lens/clients/dispatch/runners/golangci-lint.js +17 -1
- package/extensions/dm-lens/clients/dispatch/runners/helm-lint.js +8 -5
- package/extensions/dm-lens/clients/dispatch/runners/helm-render.js +1 -1
- package/extensions/dm-lens/clients/dispatch/runners/ktlint.js +27 -5
- package/extensions/dm-lens/clients/dispatch/runners/lsp.js +91 -30
- package/extensions/dm-lens/clients/dispatch/runners/oxlint.js +9 -18
- package/extensions/dm-lens/clients/dispatch/runners/shellcheck.js +11 -20
- package/extensions/dm-lens/clients/dispatch/runners/shfmt.js +7 -0
- package/extensions/dm-lens/clients/dispatch/runners/taplo.js +2 -1
- package/extensions/dm-lens/clients/dispatch/runners/tree-sitter.js +29 -16
- package/extensions/dm-lens/clients/dispatch/runners/utils/availability-policy.js +32 -4
- package/extensions/dm-lens/clients/dispatch/runners/utils/candidate-probe.js +8 -0
- package/extensions/dm-lens/clients/dispatch/runners/utils/diagnostic-parsers.js +2 -1
- package/extensions/dm-lens/clients/dispatch/runners/utils/runner-helpers.js +1 -1
- package/extensions/dm-lens/clients/dispatch/runners/utils/tool-failure.js +9 -18
- package/extensions/dm-lens/clients/dispatch/runners/vale.js +2 -16
- package/extensions/dm-lens/clients/dispatch/types.js +45 -0
- package/extensions/dm-lens/clients/dispatch/utils/lsp-diagnostics.js +2 -1
- package/extensions/dm-lens/clients/ephemeral-root.js +10 -20
- package/extensions/dm-lens/clients/file-kinds.js +6 -2
- package/extensions/dm-lens/clients/file-mutation-queue.js +4 -8
- package/extensions/dm-lens/clients/file-utils.js +167 -28
- package/extensions/dm-lens/clients/finding-delivery-gate.js +15 -1
- package/extensions/dm-lens/clients/finding-identity.js +56 -0
- package/extensions/dm-lens/clients/fix-run-restore.js +10 -0
- package/extensions/dm-lens/clients/format-service.js +23 -5
- package/extensions/dm-lens/clients/formatters.js +33 -25
- package/extensions/dm-lens/clients/git-guard.js +516 -85
- package/extensions/dm-lens/clients/govulncheck-client.js +8 -0
- package/extensions/dm-lens/clients/grammar-source.js +39 -5
- package/extensions/dm-lens/clients/gzip-stage-write.js +99 -18
- package/extensions/dm-lens/clients/inline-blocker-fields.js +1 -1
- package/extensions/dm-lens/clients/installer/index.js +83 -85
- package/extensions/dm-lens/clients/installer/managed-tool-refresh.js +211 -8
- package/extensions/dm-lens/clients/instance-reaper.js +19 -8
- package/extensions/dm-lens/clients/instance-registry.js +12 -0
- package/extensions/dm-lens/clients/jscpd-client.js +20 -4
- package/extensions/dm-lens/clients/language-profile.js +8 -7
- package/extensions/dm-lens/clients/language-registry.js +45 -4
- package/extensions/dm-lens/clients/latency-logger.js +10 -2
- package/extensions/dm-lens/clients/lens-config.js +14 -4
- package/extensions/dm-lens/clients/lens-engine.js +10 -2
- package/extensions/dm-lens/clients/lens-flag-registry.js +19 -3
- package/extensions/dm-lens/clients/line-alignment.js +200 -0
- package/extensions/dm-lens/clients/lsp/capabilities.js +2 -2
- package/extensions/dm-lens/clients/lsp/cascade-tier.js +148 -38
- package/extensions/dm-lens/clients/lsp/client-registry.js +906 -0
- package/extensions/dm-lens/clients/lsp/client.js +413 -108
- package/extensions/dm-lens/clients/lsp/config.js +151 -47
- package/extensions/dm-lens/clients/lsp/content-limits.js +2 -2
- package/extensions/dm-lens/clients/lsp/content-scan.js +69 -0
- package/extensions/dm-lens/clients/lsp/created-import-targets.js +134 -0
- package/extensions/dm-lens/clients/lsp/diagnostic-binding.js +34 -0
- package/extensions/dm-lens/clients/lsp/document-drift.js +63 -15
- package/extensions/dm-lens/clients/lsp/edits.js +109 -26
- package/extensions/dm-lens/clients/lsp/environment-gap.js +186 -0
- package/extensions/dm-lens/clients/lsp/file-server-match.js +26 -0
- package/extensions/dm-lens/clients/lsp/implicit-scope.js +208 -0
- package/extensions/dm-lens/clients/lsp/index.js +574 -916
- package/extensions/dm-lens/clients/lsp/inferred-project.js +37 -15
- package/extensions/dm-lens/clients/lsp/jvm-runtime.js +15 -9
- package/extensions/dm-lens/clients/lsp/language.js +8 -1
- package/extensions/dm-lens/clients/lsp/launch.js +93 -43
- package/extensions/dm-lens/clients/lsp/lombok.js +0 -13
- package/extensions/dm-lens/clients/lsp/path-utils.js +2 -0
- package/extensions/dm-lens/clients/lsp/position-encoding.js +0 -7
- package/extensions/dm-lens/clients/lsp/server-config-files.js +11 -0
- package/extensions/dm-lens/clients/lsp/server-traits.js +8 -2
- package/extensions/dm-lens/clients/lsp/server.js +273 -76
- package/extensions/dm-lens/clients/lsp/session-roots.js +38 -3
- package/extensions/dm-lens/clients/lsp/wait-policy/strategies.js +87 -5
- package/extensions/dm-lens/clients/lsp/watch-queue.js +23 -2
- package/extensions/dm-lens/clients/lsp/workspace-diagnostics-cache.js +183 -47
- package/extensions/dm-lens/clients/lsp/workspace-diagnostics-session.js +35 -0
- package/extensions/dm-lens/clients/lsp-mutation.js +1 -1
- package/extensions/dm-lens/clients/mcp/analyze.js +51 -13
- package/extensions/dm-lens/clients/mcp/ipc.js +24 -1
- package/extensions/dm-lens/clients/mcp/session.js +2 -7
- package/extensions/dm-lens/clients/memory-sampler.js +19 -1
- package/extensions/dm-lens/clients/metrics-history.js +16 -29
- package/extensions/dm-lens/clients/mutating-tool.js +4 -2
- package/extensions/dm-lens/clients/mutation-attribution.js +1 -4
- package/extensions/dm-lens/clients/observed-mutation.js +7 -1
- package/extensions/dm-lens/clients/opaque-mutation-scan.js +273 -59
- package/extensions/dm-lens/clients/opengrep-client.js +6 -1
- package/extensions/dm-lens/clients/opengrep-config.js +10 -5
- package/extensions/dm-lens/clients/opengrep-rule-pack.js +19 -0
- package/extensions/dm-lens/clients/out-of-band-changes.js +342 -0
- package/extensions/dm-lens/clients/package-manager.js +51 -62
- package/extensions/dm-lens/clients/package-root.js +8 -12
- package/extensions/dm-lens/clients/partial-edit-apply.js +8 -4
- package/extensions/dm-lens/clients/path-birth.js +58 -0
- package/extensions/dm-lens/clients/path-utils.js +145 -23
- package/extensions/dm-lens/clients/persist-worker-stats.js +8 -0
- package/extensions/dm-lens/clients/persistent-reverify.js +2 -1
- package/extensions/dm-lens/clients/pipeline.js +248 -35
- package/extensions/dm-lens/clients/probe-home-state.js +6 -0
- package/extensions/dm-lens/clients/project-changes.js +9 -3
- package/extensions/dm-lens/clients/project-diagnostics/fresh-fetch.js +1 -1
- package/extensions/dm-lens/clients/project-diagnostics/scanner.js +4 -2
- package/extensions/dm-lens/clients/project-lens-config.js +4 -6
- package/extensions/dm-lens/clients/project-root-markers.js +8 -0
- package/extensions/dm-lens/clients/project-snapshot-persist-worker.js +26 -8
- package/extensions/dm-lens/clients/project-snapshot.js +36 -10
- package/extensions/dm-lens/clients/python-environment.js +239 -12
- package/extensions/dm-lens/clients/read-guard-tool-lines.js +2 -8
- package/extensions/dm-lens/clients/read-guard.js +130 -43
- package/extensions/dm-lens/clients/review-graph/builder.js +102 -19
- package/extensions/dm-lens/clients/review-graph/git-identity.js +7 -2
- package/extensions/dm-lens/clients/review-graph/import-resolvers.js +9 -0
- package/extensions/dm-lens/clients/review-graph/tsconfig-paths.js +35 -2
- package/extensions/dm-lens/clients/ruff-client.js +0 -2
- package/extensions/dm-lens/clients/rules-scanner.js +0 -43
- package/extensions/dm-lens/clients/runtime-agent-end.js +37 -6
- package/extensions/dm-lens/clients/runtime-coordinator.js +177 -31
- package/extensions/dm-lens/clients/runtime-session.js +106 -66
- package/extensions/dm-lens/clients/runtime-tool-call.js +162 -65
- package/extensions/dm-lens/clients/runtime-tool-result.js +634 -147
- package/extensions/dm-lens/clients/runtime-turn.js +472 -150
- package/extensions/dm-lens/clients/rust-client.js +11 -13
- package/extensions/dm-lens/clients/safe-spawn.js +149 -17
- package/extensions/dm-lens/clients/sanitize.js +0 -169
- package/extensions/dm-lens/clients/search-read-registration.js +22 -4
- package/extensions/dm-lens/clients/session-lifecycle.js +44 -1
- package/extensions/dm-lens/clients/session-repository.js +119 -0
- package/extensions/dm-lens/clients/session-scope.js +1 -1
- package/extensions/dm-lens/clients/session-start-observability.js +12 -0
- package/extensions/dm-lens/clients/session-state-store.js +6 -1
- package/extensions/dm-lens/clients/sg-runner.js +5 -8
- package/extensions/dm-lens/clients/sgconfig.js +7 -14
- package/extensions/dm-lens/clients/single-flight.js +1 -0
- package/extensions/dm-lens/clients/source-filter.js +19 -16
- package/extensions/dm-lens/clients/source-walker.js +21 -3
- package/extensions/dm-lens/clients/startup-scan.js +18 -23
- package/extensions/dm-lens/clients/test-runner-client.js +21 -27
- package/extensions/dm-lens/clients/test-runner-delivery.js +2 -10
- package/extensions/dm-lens/clients/tool-config.js +24 -4
- package/extensions/dm-lens/clients/tool-cwd.js +11 -9
- package/extensions/dm-lens/clients/tool-policy.js +1 -8
- package/extensions/dm-lens/clients/tool-set-policy.js +32 -3
- package/extensions/dm-lens/clients/tree-sitter-client.js +70 -24
- package/extensions/dm-lens/clients/tree-sitter-query-loader.js +13 -1
- package/extensions/dm-lens/clients/tree-sitter-symbol-extractor.js +81 -56
- package/extensions/dm-lens/clients/warm-attach.js +33 -8
- package/extensions/dm-lens/clients/widget-state.js +48 -31
- package/extensions/dm-lens/clients/word-index-logger.js +3 -0
- package/extensions/dm-lens/clients/word-index.js +15 -2
- package/extensions/dm-lens/clients/workspace-topology.js +10 -8
- package/extensions/dm-lens/config/biome/core.jsonc +3 -3
- package/extensions/dm-lens/config/dependency-cruiser-eager-allowlist.json +1 -0
- package/extensions/dm-lens/dist/clients/actionable-warnings.js +8 -4
- package/extensions/dm-lens/dist/clients/advisory-provenance.js +11 -10
- package/extensions/dm-lens/dist/clients/agent-nudge.js +1 -1
- package/extensions/dm-lens/dist/clients/analysis-root.js +67 -34
- package/extensions/dm-lens/dist/clients/bash-file-access.js +550 -123
- package/extensions/dm-lens/dist/clients/blocker-freshness.js +195 -19
- package/extensions/dm-lens/dist/clients/blocker-past-eof.js +3 -1
- package/extensions/dm-lens/dist/clients/bounded-telemetry.js +3 -0
- package/extensions/dm-lens/dist/clients/cache-manager.js +22 -1
- package/extensions/dm-lens/dist/clients/cache-observability.js +275 -17
- package/extensions/dm-lens/dist/clients/cargo-manifest.js +8 -12
- package/extensions/dm-lens/dist/clients/cascade-format.js +160 -19
- package/extensions/dm-lens/dist/clients/codebase-model.js +2 -2
- package/extensions/dm-lens/dist/clients/config-locations.js +2 -8
- package/extensions/dm-lens/dist/clients/content-stamp.js +16 -0
- package/extensions/dm-lens/dist/clients/context-injection-ledger.js +157 -0
- package/extensions/dm-lens/dist/clients/deferred-runner-blockers.js +46 -6
- package/extensions/dm-lens/dist/clients/degradation-ledger.js +18 -1
- package/extensions/dm-lens/dist/clients/deps/ast-grep-napi.js +10 -0
- package/extensions/dm-lens/dist/clients/diagnostic-dispositions.js +28 -12
- package/extensions/dm-lens/dist/clients/disk-change-consumers.js +312 -0
- package/extensions/dm-lens/dist/clients/disk-change-subscribers.js +191 -0
- package/extensions/dm-lens/dist/clients/disk-changes.js +165 -0
- package/extensions/dm-lens/dist/clients/dispatch/auxiliary-lsp.js +10 -6
- package/extensions/dm-lens/dist/clients/dispatch/dispatcher.js +284 -61
- package/extensions/dm-lens/dist/clients/dispatch/fact-store.js +2 -8
- package/extensions/dm-lens/dist/clients/dispatch/facts/function-facts.js +87 -94
- package/extensions/dm-lens/dist/clients/dispatch/finding-policy.js +25 -1
- package/extensions/dm-lens/dist/clients/dispatch/indent-detect.js +1 -1
- package/extensions/dm-lens/dist/clients/dispatch/integration.js +333 -137
- package/extensions/dm-lens/dist/clients/dispatch/lane-copies.js +23 -0
- package/extensions/dm-lens/dist/clients/dispatch/pending-runner-findings.js +3 -0
- package/extensions/dm-lens/dist/clients/dispatch/pre-edit-seed.js +57 -0
- package/extensions/dm-lens/dist/clients/dispatch/rule-id-normalize.js +6 -1
- package/extensions/dm-lens/dist/clients/dispatch/rules/high-complexity.js +2 -17
- package/extensions/dm-lens/dist/clients/dispatch/rules/high-fan-out.js +1 -9
- package/extensions/dm-lens/dist/clients/dispatch/runner-context.js +5 -10
- package/extensions/dm-lens/dist/clients/dispatch/runners/ast-grep-literal-anchors.js +58 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/ast-grep-napi.js +59 -14
- package/extensions/dm-lens/dist/clients/dispatch/runners/biome-check.js +9 -18
- package/extensions/dm-lens/dist/clients/dispatch/runners/cue-vet.js +11 -21
- package/extensions/dm-lens/dist/clients/dispatch/runners/dart-analyze.js +1 -1
- package/extensions/dm-lens/dist/clients/dispatch/runners/detekt.js +4 -3
- package/extensions/dm-lens/dist/clients/dispatch/runners/dotnet-build.js +12 -6
- package/extensions/dm-lens/dist/clients/dispatch/runners/fish-indent.js +59 -5
- package/extensions/dm-lens/dist/clients/dispatch/runners/gleam-check.js +9 -19
- package/extensions/dm-lens/dist/clients/dispatch/runners/go-vet.js +2 -2
- package/extensions/dm-lens/dist/clients/dispatch/runners/golangci-lint.js +17 -1
- package/extensions/dm-lens/dist/clients/dispatch/runners/helm-lint.js +8 -5
- package/extensions/dm-lens/dist/clients/dispatch/runners/helm-render.js +1 -1
- package/extensions/dm-lens/dist/clients/dispatch/runners/ktlint.js +27 -5
- package/extensions/dm-lens/dist/clients/dispatch/runners/lsp.js +79 -30
- package/extensions/dm-lens/dist/clients/dispatch/runners/oxlint.js +9 -18
- package/extensions/dm-lens/dist/clients/dispatch/runners/shellcheck.js +11 -20
- package/extensions/dm-lens/dist/clients/dispatch/runners/shfmt.js +7 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/taplo.js +2 -1
- package/extensions/dm-lens/dist/clients/dispatch/runners/tree-sitter.js +29 -16
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/availability-policy.js +32 -4
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/candidate-probe.js +5 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +2 -1
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +1 -1
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/tool-failure.js +9 -19
- package/extensions/dm-lens/dist/clients/dispatch/runners/vale.js +2 -16
- package/extensions/dm-lens/dist/clients/dispatch/types.js +45 -0
- package/extensions/dm-lens/dist/clients/dispatch/utils/lsp-diagnostics.js +2 -1
- package/extensions/dm-lens/dist/clients/ephemeral-root.js +8 -20
- package/extensions/dm-lens/dist/clients/file-kinds.js +6 -2
- package/extensions/dm-lens/dist/clients/file-mutation-queue.js +4 -8
- package/extensions/dm-lens/dist/clients/file-utils.js +163 -29
- package/extensions/dm-lens/dist/clients/finding-delivery-gate.js +15 -1
- package/extensions/dm-lens/dist/clients/finding-identity.js +56 -0
- package/extensions/dm-lens/dist/clients/fix-run-restore.js +10 -0
- package/extensions/dm-lens/dist/clients/format-service.js +23 -5
- package/extensions/dm-lens/dist/clients/formatters.js +25 -25
- package/extensions/dm-lens/dist/clients/git-guard.js +507 -85
- package/extensions/dm-lens/dist/clients/govulncheck-client.js +5 -0
- package/extensions/dm-lens/dist/clients/grammar-source.js +39 -5
- package/extensions/dm-lens/dist/clients/gzip-stage-write.js +99 -18
- package/extensions/dm-lens/dist/clients/inline-blocker-fields.js +1 -1
- package/extensions/dm-lens/dist/clients/installer/index.js +76 -83
- package/extensions/dm-lens/dist/clients/installer/managed-tool-refresh.js +208 -9
- package/extensions/dm-lens/dist/clients/instance-reaper.js +19 -8
- package/extensions/dm-lens/dist/clients/instance-registry.js +12 -0
- package/extensions/dm-lens/dist/clients/jscpd-client.js +15 -4
- package/extensions/dm-lens/dist/clients/language-profile.js +3 -7
- package/extensions/dm-lens/dist/clients/language-registry.js +45 -4
- package/extensions/dm-lens/dist/clients/latency-logger.js +10 -2
- package/extensions/dm-lens/dist/clients/lens-config.js +12 -4
- package/extensions/dm-lens/dist/clients/lens-engine.js +10 -3
- package/extensions/dm-lens/dist/clients/lens-flag-registry.js +19 -3
- package/extensions/dm-lens/dist/clients/line-alignment.js +200 -0
- package/extensions/dm-lens/dist/clients/lsp/capabilities.js +2 -2
- package/extensions/dm-lens/dist/clients/lsp/cascade-tier.js +148 -38
- package/extensions/dm-lens/dist/clients/lsp/client-registry.js +877 -0
- package/extensions/dm-lens/dist/clients/lsp/client.js +398 -109
- package/extensions/dm-lens/dist/clients/lsp/config.js +147 -47
- package/extensions/dm-lens/dist/clients/lsp/content-limits.js +2 -2
- package/extensions/dm-lens/dist/clients/lsp/content-scan.js +69 -0
- package/extensions/dm-lens/dist/clients/lsp/created-import-targets.js +134 -0
- package/extensions/dm-lens/dist/clients/lsp/diagnostic-binding.js +34 -0
- package/extensions/dm-lens/dist/clients/lsp/document-drift.js +63 -15
- package/extensions/dm-lens/dist/clients/lsp/edits.js +104 -26
- package/extensions/dm-lens/dist/clients/lsp/environment-gap.js +186 -0
- package/extensions/dm-lens/dist/clients/lsp/file-server-match.js +26 -0
- package/extensions/dm-lens/dist/clients/lsp/implicit-scope.js +205 -0
- package/extensions/dm-lens/dist/clients/lsp/index.js +547 -894
- package/extensions/dm-lens/dist/clients/lsp/inferred-project.js +34 -15
- package/extensions/dm-lens/dist/clients/lsp/jvm-runtime.js +15 -9
- package/extensions/dm-lens/dist/clients/lsp/language.js +4 -1
- package/extensions/dm-lens/dist/clients/lsp/launch.js +85 -43
- package/extensions/dm-lens/dist/clients/lsp/lombok.js +0 -13
- package/extensions/dm-lens/dist/clients/lsp/path-utils.js +1 -1
- package/extensions/dm-lens/dist/clients/lsp/position-encoding.js +0 -7
- package/extensions/dm-lens/dist/clients/lsp/server-config-files.js +11 -0
- package/extensions/dm-lens/dist/clients/lsp/server-traits.js +8 -2
- package/extensions/dm-lens/dist/clients/lsp/server.js +267 -80
- package/extensions/dm-lens/dist/clients/lsp/session-roots.js +34 -3
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/strategies.js +85 -5
- package/extensions/dm-lens/dist/clients/lsp/watch-queue.js +23 -2
- package/extensions/dm-lens/dist/clients/lsp/workspace-diagnostics-cache.js +172 -47
- package/extensions/dm-lens/dist/clients/lsp/workspace-diagnostics-session.js +35 -0
- package/extensions/dm-lens/dist/clients/lsp-mutation.js +1 -1
- package/extensions/dm-lens/dist/clients/mcp/analyze.js +51 -14
- package/extensions/dm-lens/dist/clients/mcp/ipc.js +24 -1
- package/extensions/dm-lens/dist/clients/mcp/session.js +2 -7
- package/extensions/dm-lens/dist/clients/memory-sampler.js +19 -1
- package/extensions/dm-lens/dist/clients/metrics-history.js +16 -29
- package/extensions/dm-lens/dist/clients/mutating-tool.js +4 -2
- package/extensions/dm-lens/dist/clients/mutation-attribution.js +1 -4
- package/extensions/dm-lens/dist/clients/observed-mutation.js +7 -1
- package/extensions/dm-lens/dist/clients/opaque-mutation-scan.js +260 -59
- package/extensions/dm-lens/dist/clients/opengrep-client.js +6 -1
- package/extensions/dm-lens/dist/clients/opengrep-config.js +10 -5
- package/extensions/dm-lens/dist/clients/opengrep-rule-pack.js +19 -0
- package/extensions/dm-lens/dist/clients/out-of-band-changes.js +329 -0
- package/extensions/dm-lens/dist/clients/package-manager.js +36 -62
- package/extensions/dm-lens/dist/clients/package-root.js +8 -12
- package/extensions/dm-lens/dist/clients/partial-edit-apply.js +8 -4
- package/extensions/dm-lens/dist/clients/path-birth.js +58 -0
- package/extensions/dm-lens/dist/clients/path-utils.js +142 -23
- package/extensions/dm-lens/dist/clients/persist-worker-stats.js +8 -0
- package/extensions/dm-lens/dist/clients/persistent-reverify.js +2 -1
- package/extensions/dm-lens/dist/clients/pipeline.js +229 -35
- package/extensions/dm-lens/dist/clients/probe-home-state.js +6 -0
- package/extensions/dm-lens/dist/clients/project-changes.js +9 -3
- package/extensions/dm-lens/dist/clients/project-diagnostics/fresh-fetch.js +1 -1
- package/extensions/dm-lens/dist/clients/project-diagnostics/scanner.js +4 -2
- package/extensions/dm-lens/dist/clients/project-lens-config.js +4 -6
- package/extensions/dm-lens/dist/clients/project-root-markers.js +8 -0
- package/extensions/dm-lens/dist/clients/project-snapshot-persist-worker.js +26 -8
- package/extensions/dm-lens/dist/clients/project-snapshot.js +33 -11
- package/extensions/dm-lens/dist/clients/python-environment.js +239 -13
- package/extensions/dm-lens/dist/clients/read-guard-tool-lines.js +2 -8
- package/extensions/dm-lens/dist/clients/read-guard.js +127 -39
- package/extensions/dm-lens/dist/clients/review-graph/builder.js +94 -22
- package/extensions/dm-lens/dist/clients/review-graph/git-identity.js +7 -2
- package/extensions/dm-lens/dist/clients/review-graph/import-resolvers.js +9 -0
- package/extensions/dm-lens/dist/clients/review-graph/tsconfig-paths.js +35 -2
- package/extensions/dm-lens/dist/clients/ruff-client.js +0 -2
- package/extensions/dm-lens/dist/clients/rules-scanner.js +0 -43
- package/extensions/dm-lens/dist/clients/runtime-agent-end.js +37 -6
- package/extensions/dm-lens/dist/clients/runtime-coordinator.js +168 -31
- package/extensions/dm-lens/dist/clients/runtime-session.js +103 -65
- package/extensions/dm-lens/dist/clients/runtime-tool-call.js +155 -64
- package/extensions/dm-lens/dist/clients/runtime-tool-result.js +586 -148
- package/extensions/dm-lens/dist/clients/runtime-turn.js +450 -152
- package/extensions/dm-lens/dist/clients/rust-client.js +11 -13
- package/extensions/dm-lens/dist/clients/safe-spawn.js +144 -17
- package/extensions/dm-lens/dist/clients/sanitize.js +0 -169
- package/extensions/dm-lens/dist/clients/search-read-registration.js +20 -4
- package/extensions/dm-lens/dist/clients/session-lifecycle.js +41 -1
- package/extensions/dm-lens/dist/clients/session-repository.js +113 -0
- package/extensions/dm-lens/dist/clients/session-scope.js +1 -1
- package/extensions/dm-lens/dist/clients/session-start-observability.js +12 -0
- package/extensions/dm-lens/dist/clients/session-state-store.js +6 -1
- package/extensions/dm-lens/dist/clients/sg-runner.js +5 -8
- package/extensions/dm-lens/dist/clients/sgconfig.js +7 -14
- package/extensions/dm-lens/dist/clients/single-flight.js +1 -0
- package/extensions/dm-lens/dist/clients/source-filter.js +19 -16
- package/extensions/dm-lens/dist/clients/source-walker.js +21 -3
- package/extensions/dm-lens/dist/clients/startup-scan.js +14 -23
- package/extensions/dm-lens/dist/clients/test-runner-client.js +17 -28
- package/extensions/dm-lens/dist/clients/test-runner-delivery.js +2 -10
- package/extensions/dm-lens/dist/clients/tool-config.js +24 -4
- package/extensions/dm-lens/dist/clients/tool-cwd.js +10 -9
- package/extensions/dm-lens/dist/clients/tool-policy.js +1 -8
- package/extensions/dm-lens/dist/clients/tool-set-policy.js +32 -3
- package/extensions/dm-lens/dist/clients/tree-sitter-client.js +69 -25
- package/extensions/dm-lens/dist/clients/tree-sitter-query-loader.js +13 -1
- package/extensions/dm-lens/dist/clients/tree-sitter-symbol-extractor.js +81 -56
- package/extensions/dm-lens/dist/clients/warm-attach.js +31 -9
- package/extensions/dm-lens/dist/clients/widget-state.js +48 -31
- package/extensions/dm-lens/dist/clients/word-index-logger.js +3 -0
- package/extensions/dm-lens/dist/clients/word-index.js +11 -2
- package/extensions/dm-lens/dist/clients/workspace-topology.js +10 -4
- package/extensions/dm-lens/dist/index.js +315 -144
- package/extensions/dm-lens/dist/mcp/analyze-cli.js +1 -1
- package/extensions/dm-lens/dist/mcp/cli.js +1 -1
- package/extensions/dm-lens/dist/mcp/server.js +16 -14
- package/extensions/dm-lens/dist/mcp/worker.js +1 -1
- package/extensions/dm-lens/dist/scripts/lib/process-scan.mjs +1 -1
- package/extensions/dm-lens/dist/tools/activate-tools.js +3 -2
- package/extensions/dm-lens/dist/tools/ast-grep-outline.js +6 -4
- package/extensions/dm-lens/dist/tools/ast-grep-replace.js +17 -10
- package/extensions/dm-lens/dist/tools/ast-grep-search.js +22 -19
- package/extensions/dm-lens/dist/tools/lens-diagnostic-mark.js +3 -3
- package/extensions/dm-lens/dist/tools/lens-diagnostics.js +245 -70
- package/extensions/dm-lens/dist/tools/lsp-diagnostics.js +276 -77
- package/extensions/dm-lens/dist/tools/lsp-navigation.js +152 -100
- package/extensions/dm-lens/dist/tools/module-report.js +2 -1
- package/extensions/dm-lens/dist/tools/shared.js +16 -2
- package/extensions/dm-lens/index.js +336 -141
- package/extensions/dm-lens/mcp/analyze-cli.js +1 -1
- package/extensions/dm-lens/mcp/cli.js +1 -1
- package/extensions/dm-lens/mcp/server.js +16 -13
- package/extensions/dm-lens/mcp/worker.js +1 -1
- package/extensions/dm-lens/package.json +1 -1
- package/extensions/dm-lens/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +17 -0
- package/extensions/dm-lens/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-js-test.yml +86 -0
- package/extensions/dm-lens/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-test.yml +86 -0
- package/extensions/dm-lens/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +15 -0
- package/extensions/dm-lens/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +9 -4
- package/extensions/dm-lens/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +119 -0
- package/extensions/dm-lens/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +119 -0
- package/extensions/dm-lens/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +13 -2
- package/extensions/dm-lens/rules/rule-catalog.json +25 -1
- package/extensions/dm-lens/scripts/lib/process-scan.mjs +1 -1
- package/extensions/dm-lens/skills/{pi-lens-ast-grep → dm-lens-ast-grep}/SKILL.md +1 -1
- package/extensions/dm-lens/tools/activate-tools.js +3 -2
- package/extensions/dm-lens/tools/ast-grep-outline.js +6 -4
- package/extensions/dm-lens/tools/ast-grep-replace.js +17 -10
- package/extensions/dm-lens/tools/ast-grep-search.js +27 -19
- package/extensions/dm-lens/tools/lens-diagnostic-mark.js +3 -3
- package/extensions/dm-lens/tools/lens-diagnostics.js +260 -68
- package/extensions/dm-lens/tools/lsp-diagnostics.js +303 -76
- package/extensions/dm-lens/tools/lsp-navigation.js +168 -102
- package/extensions/dm-lens/tools/module-report.js +2 -1
- package/extensions/dm-lens/tools/shared.js +16 -2
- package/extensions/dm-mcp-adapter/.github/workflows/ci.yml +82 -0
- package/extensions/dm-mcp-adapter/THIRD_PARTY_NOTICES.md +1 -1
- package/extensions/dm-mcp-adapter/VISION.md +94 -0
- package/extensions/dm-mcp-adapter/agent-dir.js +2 -2
- package/extensions/dm-mcp-adapter/bearer-command-resolver.js +5 -3
- package/extensions/dm-mcp-adapter/bench/server-memory.mjs +432 -0
- package/extensions/dm-mcp-adapter/bench/session.js +105 -0
- package/extensions/dm-mcp-adapter/bench/token-cost/data.mjs +231 -0
- package/extensions/dm-mcp-adapter/bench/token-cost/run.mjs +190 -0
- package/extensions/dm-mcp-adapter/bench/token-cost/server.mjs +109 -0
- package/extensions/dm-mcp-adapter/cli.js +55 -100
- package/extensions/dm-mcp-adapter/codemode-bridge.js +92 -0
- package/extensions/dm-mcp-adapter/commands.js +143 -26
- package/extensions/dm-mcp-adapter/config.js +303 -78
- package/extensions/dm-mcp-adapter/conformance/baseline-client.yml +22 -0
- package/extensions/dm-mcp-adapter/conformance/driver.js +200 -0
- package/extensions/dm-mcp-adapter/conformance/driver.sh +24 -0
- package/extensions/dm-mcp-adapter/conformance/run.sh +130 -0
- package/extensions/dm-mcp-adapter/deferred-tool-surface.js +69 -0
- package/extensions/dm-mcp-adapter/direct-tool-surface.js +96 -72
- package/extensions/dm-mcp-adapter/direct-tools.js +76 -53
- package/extensions/dm-mcp-adapter/dist/agent-dir.js +2 -2
- package/extensions/dm-mcp-adapter/dist/bearer-command-resolver.js +5 -3
- package/extensions/dm-mcp-adapter/dist/config.js +304 -55
- package/extensions/dm-mcp-adapter/dist/elicitation-handler.js +4 -0
- package/extensions/dm-mcp-adapter/dist/extraction-settings.js +43 -0
- package/extensions/dm-mcp-adapter/dist/mcp-probe.js +1 -1
- package/extensions/dm-mcp-adapter/dist/mcp-tasks.js +46 -7
- package/extensions/dm-mcp-adapter/dist/metadata-cache.js +93 -5
- package/extensions/dm-mcp-adapter/dist/output-shape.js +1 -1
- package/extensions/dm-mcp-adapter/dist/project-server-trust.js +108 -20
- package/extensions/dm-mcp-adapter/dist/request-headers-command.js +17 -1
- package/extensions/dm-mcp-adapter/dist/runtime-owner.js +7 -6
- package/extensions/dm-mcp-adapter/dist/sampling-handler.js +8 -2
- package/extensions/dm-mcp-adapter/dist/script-tools.js +72 -0
- package/extensions/dm-mcp-adapter/dist/semantic-settings.js +51 -0
- package/extensions/dm-mcp-adapter/dist/server-log.js +19 -0
- package/extensions/dm-mcp-adapter/dist/server-manager.js +62 -21
- package/extensions/dm-mcp-adapter/dist/task-entries.js +60 -0
- package/extensions/dm-mcp-adapter/dist/task-jobs.js +259 -0
- package/extensions/dm-mcp-adapter/dist/types.js +7 -0
- package/extensions/dm-mcp-adapter/dist/utils.js +33 -7
- package/extensions/dm-mcp-adapter/dm-host-tool-context.js +0 -0
- package/extensions/dm-mcp-adapter/elicitation-handler.js +4 -0
- package/extensions/dm-mcp-adapter/error-signal.js +12 -1
- package/extensions/dm-mcp-adapter/executor-accounts.js +192 -0
- package/extensions/dm-mcp-adapter/executor-app-tools.js +61 -0
- package/extensions/dm-mcp-adapter/executor-catalog.js +157 -0
- package/extensions/dm-mcp-adapter/executor-pauses.js +105 -0
- package/extensions/dm-mcp-adapter/extraction-settings.js +43 -0
- package/extensions/dm-mcp-adapter/extraction.js +396 -0
- package/extensions/dm-mcp-adapter/host-html-template.js +1 -1
- package/extensions/dm-mcp-adapter/host-managed.js +24 -5
- package/extensions/dm-mcp-adapter/index.js +761 -76
- package/extensions/dm-mcp-adapter/init.js +235 -11
- package/extensions/dm-mcp-adapter/jev-semantic-search.js +161 -0
- package/extensions/dm-mcp-adapter/mcp-code.js +12 -11
- package/extensions/dm-mcp-adapter/mcp-keyring-helper.cjs +1 -1
- package/extensions/dm-mcp-adapter/mcp-output-guard.js +7 -0
- package/extensions/dm-mcp-adapter/mcp-panel.js +23 -21
- package/extensions/dm-mcp-adapter/mcp-probe.js +1 -1
- package/extensions/dm-mcp-adapter/mcp-status.js +2 -1
- package/extensions/dm-mcp-adapter/mcp-tasks.js +46 -7
- package/extensions/dm-mcp-adapter/metadata-cache.js +93 -5
- package/extensions/dm-mcp-adapter/namespace-tools.js +12 -4
- package/extensions/dm-mcp-adapter/output-shape.js +1 -1
- package/extensions/dm-mcp-adapter/package.json +1 -1
- package/extensions/dm-mcp-adapter/pi-mcp.mp4 +0 -0
- package/extensions/dm-mcp-adapter/pi-signin-import.js +1 -1
- package/extensions/dm-mcp-adapter/project-server-trust.js +108 -20
- package/extensions/dm-mcp-adapter/proxy-modes.js +320 -110
- package/extensions/dm-mcp-adapter/request-headers-command.js +17 -1
- package/extensions/dm-mcp-adapter/runtime-owner.js +7 -6
- package/extensions/dm-mcp-adapter/sampling-handler.js +8 -2
- package/extensions/dm-mcp-adapter/script-tool-save.js +251 -0
- package/extensions/dm-mcp-adapter/script-tool-surface.js +100 -0
- package/extensions/dm-mcp-adapter/script-tools.js +72 -0
- package/extensions/dm-mcp-adapter/semantic-search.js +176 -50
- package/extensions/dm-mcp-adapter/semantic-settings.js +51 -0
- package/extensions/dm-mcp-adapter/server-log.js +19 -0
- package/extensions/dm-mcp-adapter/server-manager.js +64 -21
- package/extensions/dm-mcp-adapter/task-entries.js +60 -0
- package/extensions/dm-mcp-adapter/task-jobs.js +263 -0
- package/extensions/dm-mcp-adapter/tool-approval.js +49 -2
- package/extensions/dm-mcp-adapter/tool-metadata.js +70 -3
- package/extensions/dm-mcp-adapter/tool-registrar.js +8 -1
- package/extensions/dm-mcp-adapter/tool-result-renderer.js +10 -6
- package/extensions/dm-mcp-adapter/types.js +7 -0
- package/extensions/dm-mcp-adapter/ui-server.js +24 -18
- package/extensions/dm-mcp-adapter/ui-session.js +3 -3
- package/extensions/dm-mcp-adapter/upgrade-notice.js +42 -0
- package/extensions/dm-mcp-adapter/utils.js +33 -7
- package/extensions/dm-ponytail/extensions/ponytail.mjs +11 -3
- package/extensions/dm-ponytail/hooks/band/board.js +524 -0
- package/extensions/dm-ponytail/hooks/band/logo.js +2 -0
- package/extensions/dm-ponytail/hooks/band/metrics.js +238 -0
- package/extensions/dm-ponytail/hooks/band/register.js +532 -0
- package/extensions/dm-ponytail/hooks/claude-band.json +6 -0
- package/extensions/dm-ponytail/hooks/claude-codex-hooks.json +6 -6
- package/extensions/dm-ponytail/hooks/copilot-hooks.json +6 -6
- package/extensions/dm-ponytail/hooks/cursor-hooks.json +2 -2
- package/extensions/dm-ponytail/hooks/ponytail-activate.js +105 -70
- package/extensions/dm-ponytail/hooks/ponytail-band-import.js +308 -0
- package/extensions/dm-ponytail/hooks/ponytail-config.js +4 -0
- package/extensions/dm-ponytail/hooks/ponytail-instructions.js +1 -1
- package/extensions/dm-ponytail/hooks/ponytail-map.js +7 -3
- package/extensions/dm-ponytail/hooks/ponytail-mode-tracker.js +41 -4
- package/extensions/dm-ponytail/hooks/ponytail-runtime.js +11 -8
- package/extensions/dm-ponytail/pi-extension/index.js +11 -3
- package/extensions/dm-ponytail/skills/ponytail/SKILL.md +1 -1
- package/extensions/dm-ponytail/skills/ponytail-debt/SKILL.md +4 -5
- package/extensions/dm-ponytail/skills/ponytail-gain/SKILL.md +0 -1
- package/extensions/dm-ponytail/skills/ponytail-help/SKILL.md +6 -0
- package/extensions/dm-skills-manager/package.json +1 -1
- package/extensions/dm-subagents/VISION.md +98 -0
- package/extensions/dm-subagents/agents/evidence-auditor.md +1 -0
- package/extensions/dm-subagents/agents/oracle.md +1 -0
- package/extensions/dm-subagents/agents/reviewer.md +1 -0
- package/extensions/dm-subagents/package.json +2 -1
- package/extensions/dm-subagents/scripts/build-package.mjs +128 -0
- package/extensions/dm-subagents/skills/council-mode/SKILL.md +1 -4
- package/extensions/dm-subagents/skills/dm-subagents/SKILL.md +130 -106
- package/extensions/dm-subagents/skills/dm-subagents/references/execution-controls.md +4 -3
- package/extensions/dm-subagents/skills/dm-subagents/references/orchestration.md +124 -0
- package/extensions/dm-subagents/skills/dm-subagents/references/prompting-and-roles.md +96 -295
- package/extensions/dm-subagents/src/agents/agent-management.js +14 -19
- package/extensions/dm-subagents/src/agents/agent-memory.js +2 -1
- package/extensions/dm-subagents/src/agents/agent-serializer.js +1 -2
- package/extensions/dm-subagents/src/agents/agents.js +7 -8
- package/extensions/dm-subagents/src/agents/frontmatter.js +34 -16
- package/extensions/dm-subagents/src/agents/skills.js +1 -1
- package/extensions/dm-subagents/src/api/background-work.js +8 -5
- package/extensions/dm-subagents/src/api/external-runs.js +3 -4
- package/extensions/dm-subagents/src/extension/active-runs-prompt.js +20 -0
- package/extensions/dm-subagents/src/extension/config.js +12 -0
- package/extensions/dm-subagents/src/extension/declaration-pinning.js +20 -3
- package/extensions/dm-subagents/src/extension/herdr-dm-bridge.js +24 -12
- package/extensions/dm-subagents/src/extension/index.js +125 -20
- package/extensions/dm-subagents/src/extension/public-execution.js +3 -0
- package/extensions/dm-subagents/src/extension/reply-workflow-script.js +3 -2
- package/extensions/dm-subagents/src/extension/rpc.js +5 -3
- package/extensions/dm-subagents/src/extension/schemas.js +6 -5
- package/extensions/dm-subagents/src/extension/subagent-guide.js +1 -2
- package/extensions/dm-subagents/src/extension/tool-activation.js +60 -26
- package/extensions/dm-subagents/src/extension/tool-description.js +2 -2
- package/extensions/dm-subagents/src/extension/upgrade-notice.js +5 -1
- package/extensions/dm-subagents/src/intercom/native-supervisor-channel.js +143 -15
- package/extensions/dm-subagents/src/missions/actions.js +4 -1
- package/extensions/dm-subagents/src/missions/lifecycle.js +32 -8
- package/extensions/dm-subagents/src/missions/store.js +1 -0
- package/extensions/dm-subagents/src/runs/background/active-async-capacity.js +15 -9
- package/extensions/dm-subagents/src/runs/background/async-execution.js +30 -16
- package/extensions/dm-subagents/src/runs/background/async-job-tracker.js +12 -3
- package/extensions/dm-subagents/src/runs/background/async-resume.js +5 -3
- package/extensions/dm-subagents/src/runs/background/async-status-snapshot.js +4 -2
- package/extensions/dm-subagents/src/runs/background/async-status.js +32 -10
- package/extensions/dm-subagents/src/runs/background/auto-drain.js +2 -1
- package/extensions/dm-subagents/src/runs/background/await-async-run.js +2 -7
- package/extensions/dm-subagents/src/runs/background/boot-id.js +36 -0
- package/extensions/dm-subagents/src/runs/background/chain-root-attachment.js +4 -4
- package/extensions/dm-subagents/src/runs/background/index-segment.js +1 -1
- package/extensions/dm-subagents/src/runs/background/inspect-rpc.js +17 -3
- package/extensions/dm-subagents/src/runs/background/interrupted-elsewhere.js +55 -0
- package/extensions/dm-subagents/src/runs/background/notify.js +98 -10
- package/extensions/dm-subagents/src/runs/background/result-delivery-ownership.js +20 -22
- package/extensions/dm-subagents/src/runs/background/result-files.js +9 -6
- package/extensions/dm-subagents/src/runs/background/result-watcher.js +32 -17
- package/extensions/dm-subagents/src/runs/background/resume-guidance.js +2 -1
- package/extensions/dm-subagents/src/runs/background/retained-children.js +1 -1
- package/extensions/dm-subagents/src/runs/background/run-child-session.js +40 -21
- package/extensions/dm-subagents/src/runs/background/run-status.js +12 -5
- package/extensions/dm-subagents/src/runs/background/runner-aliases.js +7 -5
- package/extensions/dm-subagents/src/runs/background/runner-child-launch.js +1 -2
- package/extensions/dm-subagents/src/runs/background/stale-run-reconciler.js +89 -21
- package/extensions/dm-subagents/src/runs/background/subagent-runner-bootstrap.js +2 -0
- package/extensions/dm-subagents/src/runs/background/subagent-runner.js +190 -244
- package/extensions/dm-subagents/src/runs/background/subagent-wait.js +5 -2
- package/extensions/dm-subagents/src/runs/background/terminal-run-index.js +39 -4
- package/extensions/dm-subagents/src/runs/background/wait-subscriptions.js +5 -1
- package/extensions/dm-subagents/src/runs/background/workflow-terminal-proof.js +28 -2
- package/extensions/dm-subagents/src/runs/foreground/async-dismiss-action.js +2 -1
- package/extensions/dm-subagents/src/runs/foreground/async-steering-action.js +21 -7
- package/extensions/dm-subagents/src/runs/foreground/async-stop-action.js +10 -8
- package/extensions/dm-subagents/src/runs/foreground/command-action.js +2 -1
- package/extensions/dm-subagents/src/runs/foreground/execution.js +107 -66
- package/extensions/dm-subagents/src/runs/foreground/foreground-history.js +111 -32
- package/extensions/dm-subagents/src/runs/foreground/prompt-audit.js +2 -2
- package/extensions/dm-subagents/src/runs/foreground/subagent-executor.js +377 -126
- package/extensions/dm-subagents/src/runs/shared/async-status-projection.js +18 -1
- package/extensions/dm-subagents/src/runs/shared/child-commands.js +7 -1
- package/extensions/dm-subagents/src/runs/shared/child-runtime-config.js +1 -0
- package/extensions/dm-subagents/src/runs/shared/child-session.js +184 -65
- package/extensions/dm-subagents/src/runs/shared/child-tool-plan.js +14 -3
- package/extensions/dm-subagents/src/runs/shared/dm-spawn.js +71 -25
- package/extensions/dm-subagents/src/runs/shared/external-cli-runner.js +2 -1
- package/extensions/dm-subagents/src/runs/shared/herdr-connection.js +20 -10
- package/extensions/dm-subagents/src/runs/shared/herdr-external-adapters.js +1 -1
- package/extensions/dm-subagents/src/runs/shared/herdr-machine.js +50 -8
- package/extensions/dm-subagents/src/runs/shared/herdr-pane-host.js +212 -0
- package/extensions/dm-subagents/src/runs/shared/herdr-placed-run.js +47 -503
- package/extensions/dm-subagents/src/runs/shared/local-machine-access.js +29 -0
- package/extensions/dm-subagents/src/runs/shared/long-running-guard.js +70 -17
- package/extensions/dm-subagents/src/runs/shared/model-resolution.js +7 -1
- package/extensions/dm-subagents/src/runs/shared/nested-events.js +2 -0
- package/extensions/dm-subagents/src/runs/shared/orca-progress-tabs.js +2 -24
- package/extensions/dm-subagents/src/runs/shared/parallel-handoff.js +9 -6
- package/extensions/dm-subagents/src/runs/shared/partial-output.js +5 -0
- package/extensions/dm-subagents/src/runs/shared/placed-run-owner.js +157 -0
- package/extensions/dm-subagents/src/runs/shared/placement-host.js +166 -0
- package/extensions/dm-subagents/src/runs/shared/rex-machine.js +75 -0
- package/extensions/dm-subagents/src/runs/shared/rex-pane-host.js +306 -0
- package/extensions/dm-subagents/src/runs/shared/run-ownership.js +7 -0
- package/extensions/dm-subagents/src/runs/shared/single-output.js +29 -6
- package/extensions/dm-subagents/src/runs/shared/structured-output.js +1 -0
- package/extensions/dm-subagents/src/runs/shared/subagent-control.js +2 -1
- package/extensions/dm-subagents/src/runs/shared/subagent-prompt-runtime.js +177 -17
- package/extensions/dm-subagents/src/runs/shared/tool-budget.js +1 -1
- package/extensions/dm-subagents/src/shared/accessible-dir.js +1 -1
- package/extensions/dm-subagents/src/shared/child-transcript.js +1 -1
- package/extensions/dm-subagents/src/shared/completion-owner.js +1 -0
- package/extensions/dm-subagents/src/shared/dm-declarations.js +36 -1
- package/extensions/dm-subagents/src/shared/dm-safeguards.js +1 -1
- package/extensions/dm-subagents/src/shared/dm-settlement.js +2 -0
- package/extensions/dm-subagents/src/shared/extension-context.js +3 -0
- package/extensions/dm-subagents/src/shared/file-lease.js +4 -1
- package/extensions/dm-subagents/src/shared/fork-context.js +21 -8
- package/extensions/dm-subagents/src/shared/parent-wake.js +6 -11
- package/extensions/dm-subagents/src/shared/provider-diagnostics.js +59 -0
- package/extensions/dm-subagents/src/shared/session-identity.js +24 -0
- package/extensions/dm-subagents/src/shared/session-succession.js +18 -0
- package/extensions/dm-subagents/src/shared/types.js +5 -4
- package/extensions/dm-subagents/src/shared/utils.js +13 -0
- package/extensions/dm-subagents/src/slash/delegation-adapters.js +8 -1
- package/extensions/dm-subagents/src/slash/prompt-template-bridge.js +2 -1
- package/extensions/dm-subagents/src/slash/slash-commands.js +6 -4
- package/extensions/dm-subagents/src/slash/subagents-admin.js +3 -2
- package/extensions/dm-subagents/src/tui/dm-mouse-region.js +9 -1
- package/extensions/dm-subagents/src/tui/fleet-layout.js +19 -0
- package/extensions/dm-subagents/src/tui/fleet-status.js +20 -3
- package/extensions/dm-subagents/src/tui/fleet-viewport.js +59 -0
- package/extensions/dm-subagents/src/tui/fleet.js +92 -69
- package/extensions/dm-subagents/src/tui/render.js +45 -19
- package/extensions/dm-subagents/src/tui/subagent-messages.js +1 -0
- package/extensions/dm-subagents/src/watchdog/change-signature.js +1 -3
- package/extensions/dm-subagents/src/watchdog/diff-tool.js +7 -3
- package/extensions/dm-subagents/src/watchdog/permission-arbiter.js +15 -6
- package/extensions/dm-subagents/src/watchdog/register-main.js +10 -9
- package/extensions/dm-subagents/src/watchdog/review.js +9 -1
- package/extensions/dm-subagents/src/watchdog/runtime.js +3 -5
- package/extensions/dm-subagents/src/workflows/scripted-workflow.js +33 -6
- package/extensions/dm-subagents/src/workflows/structured-workflow-scripts.js +21 -8
- package/extensions/dm-subagents/src/workflows/workflow-auto-resume.js +81 -0
- package/extensions/dm-subagents/src/workflows/workflow-child-summary.js +18 -2
- package/extensions/dm-subagents/src/workflows/workflow-launch-record.js +45 -0
- package/extensions/dm-subagents/src/workflows/workflow-resources.js +2 -2
- package/extensions/dm-subagents/src/workflows/workflow-resume-claim.js +171 -0
- package/extensions/dm-subagents/src/workflows/workflow-resume.js +88 -0
- package/extensions/dm-subagents/src/workflows/workflow-reuse.js +72 -3
- package/extensions/dm-subagents/src/workflows/workflow-revival.js +1 -1
- package/extensions/dm-subagents/src/workflows/workflow-stop-cause.js +5 -0
- package/extensions/dm-web-access/.github/workflows/test.yml +28 -0
- package/extensions/dm-web-access/anysearch.js +3 -3
- package/extensions/dm-web-access/bocha.js +3 -3
- package/extensions/dm-web-access/brave-rate-limit.js +2 -2
- package/extensions/dm-web-access/brave.js +5 -10
- package/extensions/dm-web-access/brightdata-unlocker.js +2 -2
- package/extensions/dm-web-access/brightdata.js +3 -3
- package/extensions/dm-web-access/ceramic.js +2 -2
- package/extensions/dm-web-access/chrome-cookies.js +1 -1
- package/extensions/dm-web-access/claim-judge.js +147 -0
- package/extensions/dm-web-access/content-find.js +1 -1
- package/extensions/dm-web-access/credential-source.js +42 -5
- package/extensions/dm-web-access/curator-page.js +8 -2
- package/extensions/dm-web-access/curator-server.js +6 -0
- package/extensions/dm-web-access/deepseek.js +331 -0
- package/extensions/dm-web-access/duckduckgo-rate-limit.js +75 -0
- package/extensions/dm-web-access/duckduckgo.js +49 -43
- package/extensions/dm-web-access/endpoint-pdf-extract.js +30 -77
- package/extensions/dm-web-access/eval/claim-judge.mjs +96 -0
- package/extensions/dm-web-access/eval/field-extract.mjs +84 -0
- package/extensions/dm-web-access/eval/fixtures/claims-calibration.json +1026 -0
- package/extensions/dm-web-access/eval/fixtures/claims-holdout.json +896 -0
- package/extensions/dm-web-access/eval/fixtures/claims-sibling-holdout.json +226 -0
- package/extensions/dm-web-access/eval/fixtures/extract-calibration.json +12 -0
- package/extensions/dm-web-access/eval/fixtures/extract-holdout.json +172 -0
- package/extensions/dm-web-access/eval/fixtures/offtopic-calibration.json +103 -0
- package/extensions/dm-web-access/eval/fixtures/offtopic-holdout.json +307 -0
- package/extensions/dm-web-access/eval/offtopic-judge.mjs +66 -0
- package/extensions/dm-web-access/evidence/CONTRACT-EVIDENCE.md +496 -0
- package/extensions/dm-web-access/evidence/contract-probe.mjs +127 -0
- package/extensions/dm-web-access/exa.js +42 -4
- package/extensions/dm-web-access/extract.js +110 -19
- package/extensions/dm-web-access/fetch-params.js +12 -3
- package/extensions/dm-web-access/field-extract.js +324 -0
- package/extensions/dm-web-access/gemini-adc.js +47 -1
- package/extensions/dm-web-access/gemini-api.js +11 -0
- package/extensions/dm-web-access/gemini-search.js +204 -196
- package/extensions/dm-web-access/github-extract.js +1 -1
- package/extensions/dm-web-access/github-issue-pr.js +6 -6
- package/extensions/dm-web-access/index.js +159 -112
- package/extensions/dm-web-access/jina-search.js +6 -4
- package/extensions/dm-web-access/kagi.js +4 -4
- package/extensions/dm-web-access/keenable.js +2 -2
- package/extensions/dm-web-access/linkup.js +160 -0
- package/extensions/dm-web-access/mistral-search.js +4 -4
- package/extensions/dm-web-access/ninerouter.js +100 -0
- package/extensions/dm-web-access/offtopic-judge.js +56 -0
- package/extensions/dm-web-access/ollama.js +4 -4
- package/extensions/dm-web-access/openai-search.js +32 -12
- package/extensions/dm-web-access/package.json +1 -1
- package/extensions/dm-web-access/page-query.js +7 -4
- package/extensions/dm-web-access/parallel.js +6 -7
- package/extensions/dm-web-access/pdf-extract.js +1 -3
- package/extensions/dm-web-access/perplexity.js +6 -5
- package/extensions/dm-web-access/querit.js +3 -3
- package/extensions/dm-web-access/query-rewrite.js +32 -8
- package/extensions/dm-web-access/scripts/dm-extensions-dist.js +16 -0
- package/extensions/dm-web-access/scripts/publish.js +38 -0
- package/extensions/dm-web-access/search1api.js +3 -3
- package/extensions/dm-web-access/searchinfinity.js +3 -3
- package/extensions/dm-web-access/searxng.js +2 -1
- package/extensions/dm-web-access/serpapi.js +6 -5
- package/extensions/dm-web-access/serpbase.js +4 -4
- package/extensions/dm-web-access/serpdive.js +3 -3
- package/extensions/dm-web-access/serper.js +5 -4
- package/extensions/dm-web-access/serply.js +2 -2
- package/extensions/dm-web-access/source-check.js +22 -14
- package/extensions/dm-web-access/ssrf-protection.js +29 -4
- package/extensions/dm-web-access/summary-model-scope.js +11 -1
- package/extensions/dm-web-access/summary-review.js +36 -43
- package/extensions/dm-web-access/tool-activation.js +11 -2
- package/extensions/dm-web-access/upgrade-notice.js +41 -0
- package/extensions/dm-web-access/utils.js +51 -3
- package/extensions/dm-web-access/valyu.js +3 -3
- package/extensions/dm-web-access/video-extract.js +3 -2
- package/extensions/dm-web-access/web-tool-core.js +161 -51
- package/extensions/dm-web-access/xai-search.js +44 -9
- package/extensions/dm-web-access/xcrawl.js +3 -3
- package/extensions/dm-web-access/you.js +2 -2
- package/package.json +4 -4
- package/extensions/dm-web-access/dist/index.js +0 -28396
- package/extensions/dm-web-access/dist/mcp-cli.js +0 -28185
- /package/extensions/dm-lens/skills/{pi-lens-lsp-navigation → dm-lens-lsp-navigation}/SKILL.md +0 -0
- /package/extensions/dm-lens/skills/{pi-lens-write-ast-grep-rule → dm-lens-write-ast-grep-rule}/SKILL.md +0 -0
- /package/extensions/dm-lens/skills/{pi-lens-write-ast-grep-rule → dm-lens-write-ast-grep-rule}/reference.md +0 -0
- /package/extensions/dm-lens/skills/{pi-lens-write-tree-sitter-rule → dm-lens-write-tree-sitter-rule}/SKILL.md +0 -0
|
@@ -1,26 +1,37 @@
|
|
|
1
1
|
import { CASCADE_DIAGNOSTICS_TTL_MS } from "../cascade-types.js";
|
|
2
2
|
import * as nodeFs from "node:fs";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
|
+
import os from "node:os";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import { pathToFileURL, URL } from "node:url";
|
|
6
7
|
import { BoundedFifoMap } from "../bounded-cache.js";
|
|
8
|
+
import {
|
|
9
|
+
CONTENT_HASH_MAX_BYTES,
|
|
10
|
+
stampContentBytes
|
|
11
|
+
} from "../content-stamp.js";
|
|
12
|
+
import {
|
|
13
|
+
FILE_CHANGED,
|
|
14
|
+
FILE_CREATED,
|
|
15
|
+
watchedTypeForOpen
|
|
16
|
+
} from "./watch-queue.js";
|
|
17
|
+
import {
|
|
18
|
+
noteWorkspaceFilesChangedOnDisk,
|
|
19
|
+
workspaceFileCreatedAtFor
|
|
20
|
+
} from "./workspace-diagnostics-session.js";
|
|
21
|
+
import {
|
|
22
|
+
emitCreatedImportScanRollupAtSessionEnd,
|
|
23
|
+
goPackageFilesToAnnounce,
|
|
24
|
+
importTargetsToAnnounce
|
|
25
|
+
} from "./created-import-targets.js";
|
|
7
26
|
import { getProjectIgnoreMatcher, isExcludedDirName } from "../file-utils.js";
|
|
8
|
-
import { recordLsp } from "../widget-state.js";
|
|
9
27
|
import { applyAuxiliarySuppressions } from "../dispatch/auxiliary-lsp.js";
|
|
10
28
|
import { detectFileRole } from "../file-role.js";
|
|
11
29
|
import { emitBounded } from "../bounded-telemetry.js";
|
|
12
30
|
import { logLatency, phaseFinished, phaseStarted } from "../latency-logger.js";
|
|
13
|
-
import { logSessionStart } from "../sessionstart-logger.js";
|
|
14
31
|
import {
|
|
15
32
|
incrementDegradationCount,
|
|
16
|
-
recordDegradation,
|
|
17
33
|
recordDegradationOnce
|
|
18
34
|
} from "../degradation-ledger.js";
|
|
19
|
-
import { assertInstallAllowed } from "../project-trust.js";
|
|
20
|
-
import {
|
|
21
|
-
isLspSpawnAllowedByTrust,
|
|
22
|
-
projectTrustDenialReason
|
|
23
|
-
} from "../project-trust.js";
|
|
24
35
|
import { shouldPreferPullOnlyDiagnostics } from "../lsp-budget.js";
|
|
25
36
|
import { sampleProcessTreeCpuPercent } from "../resource-sampler.js";
|
|
26
37
|
import { bounded, withDeadline, withTimeout } from "../deadline-utils.js";
|
|
@@ -35,6 +46,7 @@ import {
|
|
|
35
46
|
DocumentDriftTracker,
|
|
36
47
|
fingerprintDocumentContent
|
|
37
48
|
} from "./document-drift.js";
|
|
49
|
+
import { exceedsLspSyncLimits } from "./content-limits.js";
|
|
38
50
|
import {
|
|
39
51
|
captureAuxPublicationBacklog,
|
|
40
52
|
markPendingAuxiliaryCoverage,
|
|
@@ -42,12 +54,11 @@ import {
|
|
|
42
54
|
} from "./pending-aux-coverage.js";
|
|
43
55
|
import {
|
|
44
56
|
isAtOrAboveHomeDir,
|
|
45
|
-
isWindowsPath,
|
|
46
57
|
normalizeMapKey,
|
|
58
|
+
realpathOrResolve,
|
|
47
59
|
uriToPath
|
|
48
60
|
} from "../path-utils.js";
|
|
49
61
|
import { recordLspMutation } from "../lsp-mutation.js";
|
|
50
|
-
import { createLSPClient } from "./client.js";
|
|
51
62
|
import {
|
|
52
63
|
auxiliaryCoverageGap,
|
|
53
64
|
auxiliaryPublicationEvidence,
|
|
@@ -55,25 +66,16 @@ import {
|
|
|
55
66
|
composeBoundToCurrentDisk,
|
|
56
67
|
createDiskBindingCache,
|
|
57
68
|
hashDiagnosticContent,
|
|
69
|
+
primaryUnavailableCause,
|
|
58
70
|
resolveTouchVerdict,
|
|
59
71
|
touchCoverageGap
|
|
60
72
|
} from "./diagnostic-binding.js";
|
|
73
|
+
import { getServersForFileWithConfig } from "./config.js";
|
|
74
|
+
import { serverIdsForConfigFile } from "./server-config-files.js";
|
|
61
75
|
import {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
} from "./config.js";
|
|
65
|
-
import {
|
|
66
|
-
getSessionRootsForTelemetry,
|
|
67
|
-
isOutsideAllSessionRoots
|
|
76
|
+
disabledPrimaries,
|
|
77
|
+
getSessionRootsForTelemetry
|
|
68
78
|
} from "./session-roots.js";
|
|
69
|
-
import {
|
|
70
|
-
findLocalBinUpwards,
|
|
71
|
-
isProjectLocalBinPath
|
|
72
|
-
} from "../package-manager.js";
|
|
73
|
-
import {
|
|
74
|
-
resolveAnalysisRoot,
|
|
75
|
-
resolveAnalysisRootPath
|
|
76
|
-
} from "../analysis-root.js";
|
|
77
79
|
import {
|
|
78
80
|
configureLspServiceLifecycle,
|
|
79
81
|
getOwnedLspService,
|
|
@@ -82,27 +84,31 @@ import {
|
|
|
82
84
|
} from "./service-singleton.js";
|
|
83
85
|
import { groupFilesByPrimaryServer, runPerServerGroups } from "./grouping.js";
|
|
84
86
|
export { groupFilesByPrimaryServer, runPerServerGroups } from "./grouping.js";
|
|
85
|
-
import {
|
|
87
|
+
import {
|
|
88
|
+
BROKEN_BASE_COOLDOWN_MS,
|
|
89
|
+
ClientRegistry
|
|
90
|
+
} from "./client-registry.js";
|
|
91
|
+
export {
|
|
92
|
+
getLspClientCeiling,
|
|
93
|
+
getLspIdleEvictMs,
|
|
94
|
+
getLspIdleEvictMsForRoot,
|
|
95
|
+
mergeInitializationOptions
|
|
96
|
+
} from "./client-registry.js";
|
|
86
97
|
import { getLanguageId } from "./language.js";
|
|
87
98
|
import {
|
|
88
99
|
getReverseDepsFromIndex,
|
|
89
100
|
loadReverseDependencyIndexFromSnapshot
|
|
90
101
|
} from "../reverse-deps.js";
|
|
91
|
-
import { isSameOrWithin } from "./server.js";
|
|
92
|
-
import {
|
|
93
|
-
refuseUntrustedLspExecution,
|
|
94
|
-
withLspProjectCodePermission
|
|
95
|
-
} from "./launch.js";
|
|
96
102
|
import {
|
|
97
|
-
|
|
103
|
+
declinesLooseFileRoot,
|
|
98
104
|
getServerById,
|
|
99
|
-
hasProjectBoundaryMarker,
|
|
100
|
-
isDirectLspCommandTemporarilyUnavailable,
|
|
101
105
|
resetClassicTsRepairGuard,
|
|
102
|
-
resetLspLaunchAvailabilityGeneration
|
|
103
|
-
resolveLspServerCwd
|
|
106
|
+
resetLspLaunchAvailabilityGeneration
|
|
104
107
|
} from "./server.js";
|
|
105
|
-
import {
|
|
108
|
+
import {
|
|
109
|
+
isAuxiliary,
|
|
110
|
+
serverTraits
|
|
111
|
+
} from "./server-traits.js";
|
|
106
112
|
import {
|
|
107
113
|
auxWaitBudgetMs,
|
|
108
114
|
readEnvAuxGraceMs,
|
|
@@ -126,11 +132,10 @@ const AUX_WAIT_DEMOTION_THRESHOLD = 5;
|
|
|
126
132
|
const AUX_WAIT_DEMOTION_RATIO = 0.9;
|
|
127
133
|
const AUX_WAIT_REPROMOTION_THRESHOLD = 5;
|
|
128
134
|
const AUX_WAIT_REPROMOTION_RATIO = 0.5;
|
|
129
|
-
const ADOPTED_ROOT_CAP = 2;
|
|
130
|
-
const ADOPTED_ROOT_IDLE_EVICT_MS = 60000;
|
|
131
135
|
import { raceToCompletion } from "./aggregation.js";
|
|
132
136
|
import {
|
|
133
137
|
applyWorkspaceEdit,
|
|
138
|
+
captureRenameExpectedContent,
|
|
134
139
|
mergeWorkspaceTextEditsByPriority,
|
|
135
140
|
summarizeWorkspaceEdit,
|
|
136
141
|
validateWorkspaceEdit
|
|
@@ -139,12 +144,10 @@ import {
|
|
|
139
144
|
buildScopeKey,
|
|
140
145
|
createWorkspaceDiagnosticsCacheContext
|
|
141
146
|
} from "./workspace-diagnostics-cache.js";
|
|
147
|
+
import { demoteInferredProjectDiagnostics } from "./inferred-project.js";
|
|
142
148
|
import { attemptTsserverSyncDiagnostics } from "./tsserver-sync.js";
|
|
143
149
|
import { isWarmAttached, tryWarmAttachedDiagnostics } from "../warm-attach.js";
|
|
144
|
-
import {
|
|
145
|
-
getSuccessfulLspSpawnDurationMs,
|
|
146
|
-
recordSuccessfulLspSpawn
|
|
147
|
-
} from "./spawn-history.js";
|
|
150
|
+
import { getSuccessfulLspSpawnDurationMs } from "./spawn-history.js";
|
|
148
151
|
function destinationUriPreservingSpelling(oldUri, oldFilePath, newFilePath) {
|
|
149
152
|
const canonical = pathToFileURL(newFilePath);
|
|
150
153
|
try {
|
|
@@ -179,36 +182,10 @@ function destinationUriPreservingSpelling(oldUri, oldFilePath, newFilePath) {
|
|
|
179
182
|
return canonical.href;
|
|
180
183
|
}
|
|
181
184
|
}
|
|
182
|
-
function deepMergeObjects(base, override) {
|
|
183
|
-
const result = { ...base };
|
|
184
|
-
for (const [key, val] of Object.entries(override)) {
|
|
185
|
-
if (val !== null && typeof val === "object" && !Array.isArray(val) && result[key] !== null && typeof result[key] === "object" && !Array.isArray(result[key])) {
|
|
186
|
-
result[key] = deepMergeObjects(result[key], val);
|
|
187
|
-
} else {
|
|
188
|
-
result[key] = val;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return result;
|
|
192
|
-
}
|
|
193
|
-
export function mergeInitializationOptions(base, override) {
|
|
194
|
-
if (!override)
|
|
195
|
-
return base;
|
|
196
|
-
if (!base)
|
|
197
|
-
return override;
|
|
198
|
-
return deepMergeObjects(base, override);
|
|
199
|
-
}
|
|
200
|
-
const BROKEN_BASE_COOLDOWN_MS = 15000;
|
|
201
|
-
const BROKEN_MAX_COOLDOWN_MS = 5 * 60000;
|
|
202
|
-
const BROKEN_PERMANENT_AFTER = 5;
|
|
203
|
-
const RUNTIME_EXIT_UPTIME_THRESHOLD_MS = 60000;
|
|
204
|
-
const RUNTIME_EXIT_WINDOW_MS = 15 * 60000;
|
|
205
|
-
const RUNTIME_EXIT_WINDOW_TRIP_COUNT = BROKEN_PERMANENT_AFTER;
|
|
206
|
-
const RUNTIME_EXIT_WINDOW_UPTIME_CEILING_MS = 10 * 60000;
|
|
207
185
|
const NOTIFY_BACKPRESSURE_BROKEN_AFTER = 3;
|
|
208
|
-
const OPTIONAL_LSP_RETRY_COOLDOWN_MS = 5 * 60000;
|
|
209
|
-
const OPTIONAL_LSP_SERVER_IDS = new Set;
|
|
210
186
|
const NAV_CLIENT_WAIT_TIMEOUT_MS = Math.max(0, Number.parseInt(process.env.DM_LENS_LSP_NAV_CLIENT_WAIT_MS ?? "1500", 10) || 1500);
|
|
211
187
|
const TOUCH_DEBOUNCE_MS = Math.max(0, Number.parseInt(process.env.DM_LENS_LSP_TOUCH_DEBOUNCE_MS ?? "1500", 10) || 1500);
|
|
188
|
+
const RECENT_TOUCH_CAP = 800;
|
|
212
189
|
const SCOPED_DEPENDENCY_TOUCH_MAX = 32;
|
|
213
190
|
const RENAME_NOTIFY_TIMEOUT_MS = Math.max(50, Number.parseInt(process.env.DM_LENS_LSP_RENAME_NOTIFY_TIMEOUT_MS ?? "1500", 10) || 1500);
|
|
214
191
|
async function runRenameNotify(send, timeoutMs) {
|
|
@@ -224,31 +201,6 @@ async function runRenameNotify(send, timeoutMs) {
|
|
|
224
201
|
};
|
|
225
202
|
}
|
|
226
203
|
}
|
|
227
|
-
const DEFAULT_LSP_CLIENT_CEILING = 24;
|
|
228
|
-
const DEFAULT_IDLE_EVICT_MS = 20 * 60000;
|
|
229
|
-
const DEFAULT_EPHEMERAL_IDLE_EVICT_MS = 60000;
|
|
230
|
-
export function getLspIdleEvictMs() {
|
|
231
|
-
for (const name of [
|
|
232
|
-
"DM_LENS_LSP_IDLE_EVICT_MS",
|
|
233
|
-
"DM_LENS_TS_IDLE_EVICT_MS"
|
|
234
|
-
]) {
|
|
235
|
-
const parsed = Number.parseInt(process.env[name] ?? "", 10);
|
|
236
|
-
if (Number.isSafeInteger(parsed) && parsed > 0)
|
|
237
|
-
return parsed;
|
|
238
|
-
}
|
|
239
|
-
return DEFAULT_IDLE_EVICT_MS;
|
|
240
|
-
}
|
|
241
|
-
function getEphemeralLspIdleEvictMs() {
|
|
242
|
-
const parsed = Number.parseInt(process.env.DM_LENS_EPHEMERAL_LSP_IDLE_EVICT_MS ?? "", 10);
|
|
243
|
-
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : DEFAULT_EPHEMERAL_IDLE_EVICT_MS;
|
|
244
|
-
}
|
|
245
|
-
export function getLspIdleEvictMsForRoot(root) {
|
|
246
|
-
return isEphemeralCheckoutRoot(root) ? getEphemeralLspIdleEvictMs() : getLspIdleEvictMs();
|
|
247
|
-
}
|
|
248
|
-
export function getLspClientCeiling() {
|
|
249
|
-
const parsed = Number.parseInt(process.env.DM_LENS_LSP_CLIENT_CEILING ?? "", 10);
|
|
250
|
-
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : DEFAULT_LSP_CLIENT_CEILING;
|
|
251
|
-
}
|
|
252
204
|
function documentIsOpenOn(client, filePath) {
|
|
253
205
|
const probe = client.isDocumentOpen;
|
|
254
206
|
if (typeof probe !== "function")
|
|
@@ -295,6 +247,19 @@ const MAX_TOUCH_CANDIDATES = 8;
|
|
|
295
247
|
const DIAGNOSTICS_SEMANTIC_SETTLE_THRESHOLD_MS = Math.max(0, Number.parseInt(process.env.DM_LENS_LSP_DIAGNOSTICS_SEMANTIC_THRESHOLD_MS ?? "250", 10) || 250);
|
|
296
248
|
const DIAGNOSTICS_SEMANTIC_SETTLE_WAIT_MS = Math.max(0, Number.parseInt(process.env.DM_LENS_LSP_DIAGNOSTICS_SEMANTIC_SETTLE_MS ?? "400", 10) || 400);
|
|
297
249
|
const EARLY_UNBLOCK_GRACE_MS = Math.max(0, Number.parseInt(process.env.DM_LENS_LSP_EARLY_UNBLOCK_GRACE_MS ?? "400", 10) || 400);
|
|
250
|
+
function unansweredPrimaries(spawned, resolvedPrimaryRoots, filePath) {
|
|
251
|
+
if (spawned.some((entry) => !isAuxiliary(entry.info)))
|
|
252
|
+
return { serverIds: [], disabledServerIds: [], cause: "unstarted" };
|
|
253
|
+
const { disabledServerIds, fallbackServerIds } = disabledPrimaries(filePath);
|
|
254
|
+
const serverIds = [
|
|
255
|
+
...new Set([...resolvedPrimaryRoots.keys(), ...disabledServerIds])
|
|
256
|
+
];
|
|
257
|
+
return {
|
|
258
|
+
serverIds,
|
|
259
|
+
disabledServerIds,
|
|
260
|
+
cause: primaryUnavailableCause(serverIds, disabledServerIds, fallbackServerIds)
|
|
261
|
+
};
|
|
262
|
+
}
|
|
298
263
|
function mergeLspDiagnostics(diagnostics) {
|
|
299
264
|
const merged = [];
|
|
300
265
|
const seen = new Set;
|
|
@@ -314,6 +279,12 @@ function mergeLspDiagnostics(diagnostics) {
|
|
|
314
279
|
function attributeDiagnostics(serverId, diagnostics) {
|
|
315
280
|
return diagnostics.map((diagnostic) => ({ ...diagnostic, serverId }));
|
|
316
281
|
}
|
|
282
|
+
const SWEEP_REASON_FOR_CAUSE = {
|
|
283
|
+
unstarted: "primary_unavailable",
|
|
284
|
+
either: "primary_unavailable",
|
|
285
|
+
disabled: "primary_disabled",
|
|
286
|
+
disabledFallback: "primary_disabled_fallback"
|
|
287
|
+
};
|
|
317
288
|
export function createSweepIndexGate() {
|
|
318
289
|
const seen = new Set;
|
|
319
290
|
return {
|
|
@@ -367,7 +338,7 @@ function getMaxWorkspaceDiagnosticFiles() {
|
|
|
367
338
|
}
|
|
368
339
|
async function collectWorkspaceDiagnosticFiles(root, maxFiles = getMaxWorkspaceDiagnosticFiles(), signal, homeDir) {
|
|
369
340
|
const files = [];
|
|
370
|
-
if (isAtOrAboveHomeDir(root, homeDir))
|
|
341
|
+
if (isAtOrAboveHomeDir(realpathOrResolve(root), realpathOrResolve(homeDir ?? os.homedir())))
|
|
371
342
|
return files;
|
|
372
343
|
const ignoreMatcher = getProjectIgnoreMatcher(root);
|
|
373
344
|
await ignoreMatcher.ensureTrackedIndex();
|
|
@@ -405,28 +376,29 @@ async function collectWorkspaceDiagnosticFiles(root, maxFiles = getMaxWorkspaceD
|
|
|
405
376
|
|
|
406
377
|
export class LSPService {
|
|
407
378
|
static MAX_SIBLING_ANNOUNCEMENTS = 1024;
|
|
408
|
-
|
|
379
|
+
static MAX_UNHELD_STAMPS = 4096;
|
|
409
380
|
state;
|
|
381
|
+
unheldStamps = new BoundedFifoMap(LSPService.MAX_UNHELD_STAMPS);
|
|
410
382
|
siblingAnnouncementHashes = new BoundedFifoMap(LSPService.MAX_SIBLING_ANNOUNCEMENTS);
|
|
411
|
-
workspaceProbeLogged = new Set;
|
|
412
|
-
projectBoundaryCache = new Map;
|
|
413
|
-
warmStartLogged = new Set;
|
|
414
|
-
optionalFailureLogged = new Set;
|
|
415
|
-
unavailableLogged = new Set;
|
|
416
|
-
optionalDisabled = new Set;
|
|
417
383
|
firstContactWaits = new Map;
|
|
418
384
|
auxWaitPressureStreak = new Map;
|
|
419
385
|
auxWaitFastAnswerStreak = new Map;
|
|
420
386
|
demotedAuxiliaryServerIds = new Set;
|
|
421
387
|
demotedAuxiliaryBudgets = new Map;
|
|
422
|
-
lastSpawnVerdict = new Map;
|
|
423
|
-
failureCounts = new Map;
|
|
424
|
-
runtimeExitCounts = new Map;
|
|
425
|
-
runtimeExitWindow = new Map;
|
|
426
|
-
permanentlyBroken = new Set;
|
|
427
388
|
lastKnownDiagnostics = new Map;
|
|
428
389
|
lastKnownContentHash = new Map;
|
|
429
|
-
documentDrift = new DocumentDriftTracker
|
|
390
|
+
documentDrift = new DocumentDriftTracker({
|
|
391
|
+
holdsDocument: (filePath) => this.hasLiveClientHoldingDocument(filePath),
|
|
392
|
+
onCapOverflow: ({ tracked, cap }) => {
|
|
393
|
+
logLatency({
|
|
394
|
+
type: "phase",
|
|
395
|
+
phase: "lsp_document_drift_cap",
|
|
396
|
+
filePath: "",
|
|
397
|
+
durationMs: 0,
|
|
398
|
+
metadata: { tracked, cap }
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
});
|
|
430
402
|
diskBindingCache = createDiskBindingCache();
|
|
431
403
|
lastDiagnosticsHealth = new Map;
|
|
432
404
|
recentTouches = new Map;
|
|
@@ -436,24 +408,34 @@ export class LSPService {
|
|
|
436
408
|
outstandingAuxNotifyWrites = new Map;
|
|
437
409
|
static MAX_NOTIFY_STALL_DEMOTIONS = 50;
|
|
438
410
|
notifyStallDemotions = new BoundedFifoMap(LSPService.MAX_NOTIFY_STALL_DEMOTIONS);
|
|
439
|
-
clientLastUsedAt = new Map;
|
|
440
|
-
adoptedRootLastUsedAt = new Map;
|
|
441
|
-
adoptedClientKeys = new Set;
|
|
442
|
-
clientLeases = new Map;
|
|
443
|
-
idleEvictionTimers = new Map;
|
|
444
|
-
clientSpawnGate = Promise.resolve();
|
|
445
|
-
isDestroyed = false;
|
|
446
411
|
shutdownController = new AbortController;
|
|
447
|
-
|
|
412
|
+
clientRegistry;
|
|
448
413
|
constructor(generationHandoff, sessionCwd) {
|
|
449
|
-
this.
|
|
450
|
-
|
|
414
|
+
this.clientRegistry = new ClientRegistry({
|
|
415
|
+
releaseNotifyWrite: (key) => this.releaseOutstandingAuxNotifyWrite(key),
|
|
416
|
+
forgetReadiness: (key) => this.forgetReadiness(key),
|
|
417
|
+
forgetNotifyBacklog: (key) => {
|
|
418
|
+
this.auxNotifyInflight.delete(key);
|
|
419
|
+
this.auxNotifyDrainLatencyEwma.delete(key);
|
|
420
|
+
},
|
|
421
|
+
clearStallDemotion: (key) => {
|
|
422
|
+
this.notifyStallDemotions.delete(key);
|
|
423
|
+
},
|
|
424
|
+
rearmFirstContact: (serverId) => {
|
|
425
|
+
this.state.diagnosticsPublished.delete(serverId);
|
|
426
|
+
this.state.diagnosticsUnsupported.delete(serverId);
|
|
427
|
+
this.firstContactWaits.delete(serverId);
|
|
428
|
+
},
|
|
429
|
+
noteDiagnosticsPublished: (serverId) => {
|
|
430
|
+
this.state.diagnosticsPublished.add(serverId);
|
|
431
|
+
}
|
|
432
|
+
}, generationHandoff, sessionCwd);
|
|
451
433
|
this.state = {
|
|
452
|
-
clients:
|
|
434
|
+
clients: this.clientRegistry.clients,
|
|
453
435
|
servers: new Map,
|
|
454
|
-
broken:
|
|
455
|
-
inFlight:
|
|
456
|
-
clientSpawnedAt:
|
|
436
|
+
broken: this.clientRegistry.broken,
|
|
437
|
+
inFlight: this.clientRegistry.inFlight,
|
|
438
|
+
clientSpawnedAt: this.clientRegistry.clientSpawnedAt,
|
|
457
439
|
demonstratedReady: new Set,
|
|
458
440
|
demonstratedCold: new Set,
|
|
459
441
|
diagnosticsPublished: new Set,
|
|
@@ -507,120 +489,16 @@ export class LSPService {
|
|
|
507
489
|
reason: "auxiliary produced five consecutive late answers below half its declared wait budget"
|
|
508
490
|
});
|
|
509
491
|
}
|
|
510
|
-
analysisRootModeForFile(filePath) {
|
|
511
|
-
const roots = getSessionRootsForTelemetry(128);
|
|
512
|
-
if (this.sessionCwd)
|
|
513
|
-
roots.push(this.sessionCwd);
|
|
514
|
-
let adopted = false;
|
|
515
|
-
for (const root of new Set(roots)) {
|
|
516
|
-
const mode = resolveAnalysisRoot(filePath, root);
|
|
517
|
-
if (mode === "session" || mode === "linked-worktree")
|
|
518
|
-
return mode;
|
|
519
|
-
adopted ||= mode === "adopted";
|
|
520
|
-
}
|
|
521
|
-
return adopted ? "adopted" : "none";
|
|
522
|
-
}
|
|
523
|
-
fileIsOutsideRegisteredRoots(filePath) {
|
|
524
|
-
const roots = getSessionRootsForTelemetry(128);
|
|
525
|
-
if (roots.length === 0)
|
|
526
|
-
return isOutsideAllSessionRoots(filePath);
|
|
527
|
-
return !roots.some((root) => isSameOrWithin(root, filePath));
|
|
528
|
-
}
|
|
529
|
-
admitAdoptedRoot(root, filePath) {
|
|
530
|
-
if (this.analysisRootModeForFile(filePath) !== "adopted")
|
|
531
|
-
return false;
|
|
532
|
-
const normalized = normalizeMapKey(root);
|
|
533
|
-
const liveRoots = new Set;
|
|
534
|
-
for (const key of this.state.clients.keys()) {
|
|
535
|
-
if (this.adoptedClientKeys.has(key))
|
|
536
|
-
liveRoots.add(key.slice(key.indexOf(":") + 1));
|
|
537
|
-
}
|
|
538
|
-
for (const root of this.adoptedRootLastUsedAt.keys()) {
|
|
539
|
-
if (!liveRoots.has(root))
|
|
540
|
-
this.adoptedRootLastUsedAt.delete(root);
|
|
541
|
-
}
|
|
542
|
-
if (liveRoots.has(normalized)) {
|
|
543
|
-
this.adoptedRootLastUsedAt.set(normalized, Date.now());
|
|
544
|
-
return true;
|
|
545
|
-
}
|
|
546
|
-
if (this.adoptedRootLastUsedAt.size < ADOPTED_ROOT_CAP) {
|
|
547
|
-
this.adoptedRootLastUsedAt.set(normalized, Date.now());
|
|
548
|
-
return true;
|
|
549
|
-
}
|
|
550
|
-
this.adoptedRootLastUsedAt.set(normalized, Date.now());
|
|
551
|
-
const victim = [...this.adoptedRootLastUsedAt.keys()].sort((a, b) => (this.adoptedRootLastUsedAt.get(a) ?? 0) - (this.adoptedRootLastUsedAt.get(b) ?? 0)).find((candidate) => candidate !== normalized);
|
|
552
|
-
if (!victim)
|
|
553
|
-
return true;
|
|
554
|
-
this.adoptedRootLastUsedAt.delete(victim);
|
|
555
|
-
for (const [key, client] of this.state.clients) {
|
|
556
|
-
if (!this.adoptedClientKeys.has(key) || !key.endsWith(`:${victim}`))
|
|
557
|
-
continue;
|
|
558
|
-
if ((this.clientLeases.get(key) ?? 0) > 0)
|
|
559
|
-
continue;
|
|
560
|
-
this.retireClient(key);
|
|
561
|
-
client.shutdown({ reason: "adopted-root-lru" }).catch(() => {});
|
|
562
|
-
}
|
|
563
|
-
incrementDegradationCount({
|
|
564
|
-
kind: "lsp-adopted-root-evicted",
|
|
565
|
-
subject: victim,
|
|
566
|
-
reason: `adopted root cap ${ADOPTED_ROOT_CAP} evicted ${victim}`
|
|
567
|
-
});
|
|
568
|
-
return true;
|
|
569
|
-
}
|
|
570
|
-
async resolveServerRoot(server, filePath, onRootFailure) {
|
|
571
|
-
const candidate = await resolveLspServerCwd(server, filePath, this.sessionCwd ?? process.cwd(), onRootFailure);
|
|
572
|
-
if (!candidate)
|
|
573
|
-
return;
|
|
574
|
-
const mode = this.analysisRootModeForFile(filePath);
|
|
575
|
-
if (mode === "adopted") {
|
|
576
|
-
const classifierRoot = resolveAnalysisRootPath(filePath, this.sessionCwd ?? process.cwd());
|
|
577
|
-
if (!classifierRoot || normalizeMapKey(classifierRoot) !== normalizeMapKey(candidate))
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
if (this.fileIsOutsideRegisteredRoots(filePath) && this.analysisRootModeForFile(filePath) !== "adopted")
|
|
581
|
-
return;
|
|
582
|
-
const root = enforceLspRootCeiling(candidate, process.cwd(), filePath);
|
|
583
|
-
if (normalizeMapKey(root) === normalizeMapKey(process.cwd()))
|
|
584
|
-
return root;
|
|
585
|
-
const rootKey = normalizeMapKey(root);
|
|
586
|
-
const prefix = `${server.id}:`;
|
|
587
|
-
let nearestAncestor;
|
|
588
|
-
for (const key of new Set([
|
|
589
|
-
...this.state.clients.keys(),
|
|
590
|
-
...this.state.inFlight.keys()
|
|
591
|
-
])) {
|
|
592
|
-
if (!key.startsWith(prefix))
|
|
593
|
-
continue;
|
|
594
|
-
const ancestorKey = key.slice(prefix.length);
|
|
595
|
-
const pathApi = isWindowsPath(ancestorKey) || isWindowsPath(rootKey) ? path.win32 : path;
|
|
596
|
-
const relative = pathApi.relative(ancestorKey, rootKey);
|
|
597
|
-
if (relative === "" || relative.startsWith("..") || pathApi.isAbsolute(relative)) {
|
|
598
|
-
continue;
|
|
599
|
-
}
|
|
600
|
-
if (!nearestAncestor || ancestorKey.length > nearestAncestor.length) {
|
|
601
|
-
nearestAncestor = ancestorKey;
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
if (!nearestAncestor)
|
|
605
|
-
return root;
|
|
606
|
-
let boundary = this.projectBoundaryCache.get(rootKey);
|
|
607
|
-
if (!boundary) {
|
|
608
|
-
boundary = hasProjectBoundaryMarker(root);
|
|
609
|
-
this.projectBoundaryCache.set(rootKey, boundary);
|
|
610
|
-
}
|
|
611
|
-
if (await boundary)
|
|
612
|
-
return root;
|
|
613
|
-
return this.state.clients.get(`${server.id}:${nearestAncestor}`)?.root ?? nearestAncestor;
|
|
614
|
-
}
|
|
615
492
|
checkDestroyed() {
|
|
616
|
-
return this.
|
|
493
|
+
return this.clientRegistry.checkDestroyed();
|
|
617
494
|
}
|
|
618
495
|
announceToSiblings(filePath, content, contentHash = this.hashContent(content)) {
|
|
619
496
|
const normalizedPath = normalizeMapKey(filePath);
|
|
620
497
|
if (this.siblingAnnouncementHashes.get(normalizedPath) === contentHash) {
|
|
621
498
|
return Promise.resolve();
|
|
622
499
|
}
|
|
623
|
-
|
|
500
|
+
this.announceCreatedFiles([filePath]);
|
|
501
|
+
return Promise.all(getServersForFileWithConfig(filePath).map((server) => this.clientRegistry.resolveServerRoot(server, filePath).then((root) => {
|
|
624
502
|
if (!root)
|
|
625
503
|
return false;
|
|
626
504
|
const ownKey = `${server.id}:${normalizeMapKey(root)}`;
|
|
@@ -641,121 +519,22 @@ export class LSPService {
|
|
|
641
519
|
}
|
|
642
520
|
return notified;
|
|
643
521
|
}
|
|
644
|
-
async withClientSpawnGate(operation) {
|
|
645
|
-
const previous = this.clientSpawnGate;
|
|
646
|
-
let release;
|
|
647
|
-
this.clientSpawnGate = new Promise((resolve) => {
|
|
648
|
-
release = resolve;
|
|
649
|
-
});
|
|
650
|
-
await previous;
|
|
651
|
-
try {
|
|
652
|
-
return await operation();
|
|
653
|
-
} finally {
|
|
654
|
-
release();
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
async clientKeyFor(entry, filePath) {
|
|
658
|
-
const root = await this.resolveServerRoot(entry.info, filePath);
|
|
659
|
-
return root ? `${entry.info.id}:${normalizeMapKey(root)}` : undefined;
|
|
660
|
-
}
|
|
661
|
-
async acquireClientLease(entry, filePath) {
|
|
662
|
-
const key = await this.clientKeyFor(entry, filePath);
|
|
663
|
-
if (!key)
|
|
664
|
-
return;
|
|
665
|
-
return this.withClientSpawnGate(async () => {
|
|
666
|
-
if (this.isDestroyed || this.state.clients.get(key) !== entry.client) {
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
this.clientLeases.set(key, (this.clientLeases.get(key) ?? 0) + 1);
|
|
670
|
-
return key;
|
|
671
|
-
});
|
|
672
|
-
}
|
|
673
|
-
async acquireClientLeases(entries, filePath) {
|
|
674
|
-
const keys = await Promise.all(entries.map((entry) => this.clientKeyFor(entry, filePath)));
|
|
675
|
-
if (keys.some((key) => key === undefined))
|
|
676
|
-
return;
|
|
677
|
-
const keyed = entries.map((entry, index) => [keys[index], entry]);
|
|
678
|
-
return this.withClientSpawnGate(async () => {
|
|
679
|
-
if (this.isDestroyed || keyed.some(([key, entry]) => this.state.clients.get(key) !== entry.client)) {
|
|
680
|
-
return;
|
|
681
|
-
}
|
|
682
|
-
for (const [key] of keyed) {
|
|
683
|
-
this.clientLeases.set(key, (this.clientLeases.get(key) ?? 0) + 1);
|
|
684
|
-
}
|
|
685
|
-
return keyed.map(([key, entry]) => ({ key, server: entry.info }));
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
releaseClientLease(key, server) {
|
|
689
|
-
const remaining = (this.clientLeases.get(key) ?? 1) - 1;
|
|
690
|
-
if (remaining > 0) {
|
|
691
|
-
this.clientLeases.set(key, remaining);
|
|
692
|
-
return;
|
|
693
|
-
}
|
|
694
|
-
this.clientLeases.delete(key);
|
|
695
|
-
if (this.state.clients.has(key)) {
|
|
696
|
-
this.clientLastUsedAt.set(key, Date.now());
|
|
697
|
-
this.scheduleIdleEviction(key, server);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
522
|
async withClientForFileUse(filePath, maxWaitMs, hardCapMs, use) {
|
|
701
|
-
while (!this.
|
|
523
|
+
while (!this.checkDestroyed()) {
|
|
702
524
|
const entry = await this.getClientForFile(filePath, maxWaitMs, hardCapMs);
|
|
703
525
|
if (!entry)
|
|
704
526
|
return;
|
|
705
|
-
const leaseKey = await this.acquireClientLease(entry, filePath);
|
|
527
|
+
const leaseKey = await this.clientRegistry.acquireClientLease(entry, filePath);
|
|
706
528
|
if (!leaseKey)
|
|
707
529
|
continue;
|
|
708
530
|
try {
|
|
709
531
|
return await use(entry);
|
|
710
532
|
} finally {
|
|
711
|
-
this.releaseClientLease(leaseKey, entry.info);
|
|
533
|
+
this.clientRegistry.releaseClientLease(leaseKey, entry.info);
|
|
712
534
|
}
|
|
713
535
|
}
|
|
714
536
|
return;
|
|
715
537
|
}
|
|
716
|
-
async makeCapacityForClient(key) {
|
|
717
|
-
const occupiedKeys = new Set(this.state.inFlight.keys());
|
|
718
|
-
for (const [clientKey, client] of this.state.clients) {
|
|
719
|
-
if (client.isAlive())
|
|
720
|
-
occupiedKeys.add(clientKey);
|
|
721
|
-
}
|
|
722
|
-
const occupied = occupiedKeys.size;
|
|
723
|
-
if (occupied < getLspClientCeiling())
|
|
724
|
-
return true;
|
|
725
|
-
const idle = [...this.state.clients.entries()].filter(([candidateKey, client]) => candidateKey !== key && client.isAlive() && client.isBusy?.() !== true && (this.clientLeases.get(candidateKey) ?? 0) === 0).sort(([a], [b]) => (this.clientLastUsedAt.get(a) ?? this.state.clientSpawnedAt.get(a) ?? 0) - (this.clientLastUsedAt.get(b) ?? this.state.clientSpawnedAt.get(b) ?? 0));
|
|
726
|
-
const victim = idle[0];
|
|
727
|
-
if (!victim) {
|
|
728
|
-
logSessionStart(`lsp client ceiling ${getLspClientCeiling()}: spawn declined; all clients are in use`);
|
|
729
|
-
return false;
|
|
730
|
-
}
|
|
731
|
-
const [victimKey, victimClient] = victim;
|
|
732
|
-
this.releaseOutstandingAuxNotifyWrite(victimKey);
|
|
733
|
-
await victimClient.shutdown({ reason: "client_ceiling_lru" });
|
|
734
|
-
this.retireClient(victimKey);
|
|
735
|
-
logSessionStart(`lsp client ceiling ${getLspClientCeiling()}: evicted idle LRU ${victimKey}`);
|
|
736
|
-
return true;
|
|
737
|
-
}
|
|
738
|
-
clearIdleEvictionTimer(key) {
|
|
739
|
-
const timer = this.idleEvictionTimers.get(key);
|
|
740
|
-
if (timer)
|
|
741
|
-
clearTimeout(timer);
|
|
742
|
-
this.idleEvictionTimers.delete(key);
|
|
743
|
-
}
|
|
744
|
-
retireClient(key) {
|
|
745
|
-
this.releaseOutstandingAuxNotifyWrite(key);
|
|
746
|
-
this.state.clients.delete(key);
|
|
747
|
-
this.state.clientSpawnedAt.delete(key);
|
|
748
|
-
this.forgetReadiness(key);
|
|
749
|
-
this.clientLastUsedAt.delete(key);
|
|
750
|
-
if (this.adoptedClientKeys.delete(key)) {
|
|
751
|
-
const root = key.slice(key.indexOf(":") + 1);
|
|
752
|
-
if (![...this.adoptedClientKeys].some((candidate) => candidate.endsWith(`:${root}`)))
|
|
753
|
-
this.adoptedRootLastUsedAt.delete(root);
|
|
754
|
-
}
|
|
755
|
-
this.clearIdleEvictionTimer(key);
|
|
756
|
-
this.auxNotifyInflight.delete(key);
|
|
757
|
-
this.auxNotifyDrainLatencyEwma.delete(key);
|
|
758
|
-
}
|
|
759
538
|
releaseOutstandingAuxNotifyWrite(key, token) {
|
|
760
539
|
const current = this.outstandingAuxNotifyWrites.get(key);
|
|
761
540
|
if (!current || token !== undefined && current !== token)
|
|
@@ -764,82 +543,78 @@ export class LSPService {
|
|
|
764
543
|
this.outstandingAuxNotifyWrites.delete(key);
|
|
765
544
|
current.resolveSettled();
|
|
766
545
|
}
|
|
767
|
-
|
|
768
|
-
if (server.idleEviction !== "transparent" && !this.adoptedClientKeys.has(key))
|
|
769
|
-
return;
|
|
770
|
-
this.clearIdleEvictionTimer(key);
|
|
771
|
-
const lastUsedAt = this.clientLastUsedAt.get(key) ?? Date.now();
|
|
772
|
-
const root = key.slice(key.indexOf(":") + 1);
|
|
773
|
-
const idleMs = this.adoptedClientKeys.has(key) ? ADOPTED_ROOT_IDLE_EVICT_MS : getLspIdleEvictMsForRoot(root);
|
|
774
|
-
const timer = setTimeout(() => {
|
|
775
|
-
this.idleEvictionTimers.delete(key);
|
|
776
|
-
this.withClientSpawnGate(async () => {
|
|
777
|
-
if (this.isDestroyed)
|
|
778
|
-
return;
|
|
779
|
-
const client = this.state.clients.get(key);
|
|
780
|
-
if (!client?.isAlive())
|
|
781
|
-
return;
|
|
782
|
-
if (client.isBusy?.() === true || (this.clientLeases.get(key) ?? 0) > 0 || (this.clientLastUsedAt.get(key) ?? 0) !== lastUsedAt) {
|
|
783
|
-
this.scheduleIdleEviction(key, server);
|
|
784
|
-
return;
|
|
785
|
-
}
|
|
786
|
-
this.retireClient(key);
|
|
787
|
-
try {
|
|
788
|
-
await client.shutdown({ reason: "idle_eviction" });
|
|
789
|
-
} catch {}
|
|
790
|
-
logSessionStart(`lsp idle eviction: released ${key}`);
|
|
791
|
-
recordDegradation({
|
|
792
|
-
kind: "lsp-idle-eviction",
|
|
793
|
-
subject: key,
|
|
794
|
-
reason: "idle LSP client released to bound memory"
|
|
795
|
-
});
|
|
796
|
-
}).catch(() => {});
|
|
797
|
-
}, idleMs);
|
|
798
|
-
timer.unref?.();
|
|
799
|
-
this.idleEvictionTimers.set(key, timer);
|
|
800
|
-
}
|
|
801
|
-
shouldSkipTouch(filePath, contentFingerprint, clientScope, waitForDiagnostics, spawned) {
|
|
546
|
+
shouldSkipTouch(filePath, sentContentHash, waitForDiagnostics, spawned) {
|
|
802
547
|
if (waitForDiagnostics)
|
|
803
548
|
return false;
|
|
804
549
|
if (spawned.length === 0)
|
|
805
550
|
return false;
|
|
806
|
-
return spawned.every((entry) => this.shouldSkipNotify(filePath,
|
|
551
|
+
return spawned.every((entry) => this.shouldSkipNotify(filePath, sentContentHash, entry.info.id, entry.client));
|
|
807
552
|
}
|
|
808
|
-
shouldSkipNotify(filePath,
|
|
553
|
+
shouldSkipNotify(filePath, sentContentHash, serverId, client) {
|
|
809
554
|
if (TOUCH_DEBOUNCE_MS <= 0)
|
|
810
555
|
return false;
|
|
811
|
-
const previous = this.recentTouches.get(this.recentTouchKey(filePath,
|
|
556
|
+
const previous = this.recentTouches.get(this.recentTouchKey(filePath, serverId));
|
|
812
557
|
if (!previous)
|
|
813
558
|
return false;
|
|
814
|
-
const now = Date.now();
|
|
815
|
-
if (now - previous.touchedAt > TOUCH_DEBOUNCE_MS)
|
|
816
|
-
return false;
|
|
817
559
|
if (previous.client.deref() !== client)
|
|
818
560
|
return false;
|
|
819
|
-
|
|
561
|
+
if (workspaceFileCreatedAtFor((id) => id === client.serverId, (root) => root === client.root) >= previous.touchedAt) {
|
|
562
|
+
return false;
|
|
563
|
+
}
|
|
564
|
+
const sentContent = client.getSentContent?.(filePath);
|
|
565
|
+
if (sentContent === undefined || sentContent.hash !== sentContentHash) {
|
|
566
|
+
return false;
|
|
567
|
+
}
|
|
568
|
+
return client.hasNotifyInFlight?.(filePath) === false;
|
|
820
569
|
}
|
|
821
|
-
|
|
822
|
-
|
|
570
|
+
saveDebouncedPush(filePath, entry, saved, sentContentHash, retryOnFailure = true) {
|
|
571
|
+
if (!saved)
|
|
572
|
+
return;
|
|
573
|
+
const previous = this.recentTouches.get(this.recentTouchKey(filePath, entry.info.id));
|
|
574
|
+
if (!previous || entry.client.getSentContent?.(filePath)?.savedHash === sentContentHash)
|
|
575
|
+
return;
|
|
576
|
+
if (entry.client.getSaveOptions?.() === undefined)
|
|
577
|
+
return;
|
|
578
|
+
const save = entry.client.notify.save;
|
|
579
|
+
if (!save)
|
|
580
|
+
return;
|
|
581
|
+
const recover = () => {
|
|
582
|
+
if (retryOnFailure) {
|
|
583
|
+
this.saveDebouncedPush(filePath, entry, true, sentContentHash, false);
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
recordDegradationOnce({
|
|
587
|
+
kind: "lsp-did-save-recovery-exhausted",
|
|
588
|
+
subject: entry.info.id,
|
|
589
|
+
reason: "a standalone didSave and its one retry both sent nothing",
|
|
590
|
+
metadata: { filePath }
|
|
591
|
+
});
|
|
592
|
+
};
|
|
593
|
+
save.call(entry.client.notify, filePath, true).then((sent) => {
|
|
594
|
+
if (sent === false)
|
|
595
|
+
recover();
|
|
596
|
+
}, recover);
|
|
597
|
+
return entry.info.id;
|
|
823
598
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
599
|
+
recentTouchKey(filePath, serverId) {
|
|
600
|
+
return `${normalizeMapKey(filePath)}:${serverId}`;
|
|
601
|
+
}
|
|
602
|
+
markTouched(filePath, serverId, client) {
|
|
603
|
+
const key = this.recentTouchKey(filePath, serverId);
|
|
604
|
+
this.recentTouches.delete(key);
|
|
827
605
|
this.recentTouches.set(key, {
|
|
828
|
-
|
|
829
|
-
touchedAt: now,
|
|
830
|
-
clientScope,
|
|
606
|
+
touchedAt: Date.now(),
|
|
831
607
|
client: new WeakRef(client)
|
|
832
608
|
});
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
}
|
|
609
|
+
while (this.recentTouches.size > RECENT_TOUCH_CAP) {
|
|
610
|
+
const oldest = this.recentTouches.keys().next();
|
|
611
|
+
if (oldest.done)
|
|
612
|
+
break;
|
|
613
|
+
this.recentTouches.delete(oldest.value);
|
|
839
614
|
}
|
|
840
615
|
}
|
|
841
616
|
async demonstratedReadyKeyFor(server, filePath) {
|
|
842
|
-
const root = await this.resolveServerRoot(server, filePath);
|
|
617
|
+
const root = await this.clientRegistry.resolveServerRoot(server, filePath);
|
|
843
618
|
if (!root)
|
|
844
619
|
return;
|
|
845
620
|
return `${server.id}:${normalizeMapKey(root)}`;
|
|
@@ -853,9 +628,6 @@ export class LSPService {
|
|
|
853
628
|
this.state.demonstratedReady.add(key);
|
|
854
629
|
this.state.demonstratedCold.delete(key);
|
|
855
630
|
}
|
|
856
|
-
recordBreaker(key, reason) {
|
|
857
|
-
recordDegradationOnce({ kind: "lsp-breaker", subject: key, reason });
|
|
858
|
-
}
|
|
859
631
|
recordNotifyWriteBackpressure(key, entry, filePath) {
|
|
860
632
|
if (!key)
|
|
861
633
|
return;
|
|
@@ -874,11 +646,11 @@ export class LSPService {
|
|
|
874
646
|
async demoteNotifyStallCpuGuarded(key, entry, filePath, reason) {
|
|
875
647
|
if (this.state.clients.get(key) !== entry.client)
|
|
876
648
|
return;
|
|
877
|
-
this.clearIdleEvictionTimer(key);
|
|
649
|
+
this.clientRegistry.clearIdleEvictionTimer(key);
|
|
878
650
|
const verdict = await this.notifyStallCpuVerdict(entry);
|
|
879
651
|
if (verdict.cpuVerdict === "busy") {
|
|
880
652
|
if (this.state.clients.get(key) === entry.client) {
|
|
881
|
-
this.scheduleIdleEviction(key, entry.info);
|
|
653
|
+
this.clientRegistry.scheduleIdleEviction(key, entry.info);
|
|
882
654
|
}
|
|
883
655
|
this.logNotifyStallCpuBusy(key, entry, filePath, 0, verdict);
|
|
884
656
|
return;
|
|
@@ -933,10 +705,10 @@ export class LSPService {
|
|
|
933
705
|
demoteForNotifyStall(key, entry, filePath, reason) {
|
|
934
706
|
if (this.state.clients.get(key) !== entry.client)
|
|
935
707
|
return;
|
|
936
|
-
this.
|
|
708
|
+
this.clientRegistry.coolDown(key, BROKEN_BASE_COOLDOWN_MS);
|
|
937
709
|
this.notifyStallDemotions.set(key, Date.now());
|
|
938
710
|
entry.client.shutdown().catch(() => {});
|
|
939
|
-
this.retireClient(key);
|
|
711
|
+
this.clientRegistry.retireClient(key);
|
|
940
712
|
logLatency({
|
|
941
713
|
type: "phase",
|
|
942
714
|
phase: "lsp_notify_backpressure_broken",
|
|
@@ -1224,12 +996,13 @@ export class LSPService {
|
|
|
1224
996
|
};
|
|
1225
997
|
}
|
|
1226
998
|
}
|
|
1227
|
-
async
|
|
999
|
+
async skippedAuxiliaryServerIds(filePath, clientScope, options, spawned) {
|
|
1228
1000
|
if (clientScope === "primary")
|
|
1229
|
-
return [];
|
|
1001
|
+
return { brokenSkippedServerIds: [], policySkippedServerIds: [] };
|
|
1230
1002
|
const enabledAuxiliaries = clientScope === "with-auxiliary" ? new Set(options.auxiliaryServerIds ?? []) : undefined;
|
|
1231
1003
|
const attached = new Set(spawned.map((entry) => entry.info.id));
|
|
1232
|
-
const
|
|
1004
|
+
const brokenSkippedServerIds = [];
|
|
1005
|
+
const policySkippedServerIds = [];
|
|
1233
1006
|
for (const server of getServersForFileWithConfig(filePath)) {
|
|
1234
1007
|
if (!isAuxiliary(server))
|
|
1235
1008
|
continue;
|
|
@@ -1239,15 +1012,20 @@ export class LSPService {
|
|
|
1239
1012
|
continue;
|
|
1240
1013
|
if (enabledAuxiliaries && !enabledAuxiliaries.has(server.id))
|
|
1241
1014
|
continue;
|
|
1242
|
-
const
|
|
1243
|
-
if (!
|
|
1015
|
+
const root = await this.clientRegistry.resolveServerRoot(server, filePath);
|
|
1016
|
+
if (!root)
|
|
1244
1017
|
continue;
|
|
1018
|
+
if (declinesLooseFileRoot(server, root)) {
|
|
1019
|
+
policySkippedServerIds.push(server.id);
|
|
1020
|
+
continue;
|
|
1021
|
+
}
|
|
1022
|
+
const key = `${server.id}:${normalizeMapKey(root)}`;
|
|
1245
1023
|
const brokenUntil = this.state.broken.get(key);
|
|
1246
|
-
if (this.permanentlyBroken.has(key) || typeof brokenUntil === "number" && brokenUntil > Date.now()) {
|
|
1247
|
-
|
|
1024
|
+
if (this.clientRegistry.permanentlyBroken.has(key) || typeof brokenUntil === "number" && brokenUntil > Date.now()) {
|
|
1025
|
+
brokenSkippedServerIds.push(server.id);
|
|
1248
1026
|
}
|
|
1249
1027
|
}
|
|
1250
|
-
return
|
|
1028
|
+
return { brokenSkippedServerIds, policySkippedServerIds };
|
|
1251
1029
|
}
|
|
1252
1030
|
activeClientsForCwd(cwd, priorityServerIds = []) {
|
|
1253
1031
|
const normalizedCwd = normalizeMapKey(cwd);
|
|
@@ -1262,7 +1040,7 @@ export class LSPService {
|
|
|
1262
1040
|
const sameOrNested = root === normalizedCwd || root.startsWith(`${normalizedCwd}/`) || normalizedCwd.startsWith(`${root}/`);
|
|
1263
1041
|
if (!sameOrNested)
|
|
1264
1042
|
continue;
|
|
1265
|
-
entries.push({ serverId, client });
|
|
1043
|
+
entries.push({ clientKey: key, serverId, client });
|
|
1266
1044
|
}
|
|
1267
1045
|
return entries.sort((a, b) => (priority.get(a.serverId) ?? Number.MAX_SAFE_INTEGER) - (priority.get(b.serverId) ?? Number.MAX_SAFE_INTEGER));
|
|
1268
1046
|
}
|
|
@@ -1276,9 +1054,18 @@ export class LSPService {
|
|
|
1276
1054
|
}
|
|
1277
1055
|
return [...paths];
|
|
1278
1056
|
}
|
|
1279
|
-
getTrackedContent(filePath, cwd) {
|
|
1057
|
+
getTrackedContent(filePath, cwd, sourceClientKeys) {
|
|
1280
1058
|
const priorityServerIds = getServersForFileWithConfig(filePath).map((server) => server.id);
|
|
1281
|
-
|
|
1059
|
+
const clients = this.activeClientsForCwd(cwd, priorityServerIds);
|
|
1060
|
+
if (sourceClientKeys !== undefined) {
|
|
1061
|
+
const sourceSet = new Set(sourceClientKeys);
|
|
1062
|
+
const sends = clients.filter(({ clientKey }) => sourceSet.has(clientKey)).flatMap(({ clientKey, client }) => {
|
|
1063
|
+
const sent = client.getSentContent?.(filePath);
|
|
1064
|
+
return sent === undefined ? [] : [{ ...sent, clientKey }];
|
|
1065
|
+
});
|
|
1066
|
+
return sends;
|
|
1067
|
+
}
|
|
1068
|
+
for (const { client } of clients) {
|
|
1282
1069
|
const sent = client.getSentContent?.(filePath);
|
|
1283
1070
|
if (sent !== undefined)
|
|
1284
1071
|
return sent;
|
|
@@ -1296,7 +1083,7 @@ export class LSPService {
|
|
|
1296
1083
|
try {
|
|
1297
1084
|
return {
|
|
1298
1085
|
server,
|
|
1299
|
-
root: await this.resolveServerRootOnce(server, filePath, rootMemo, (reason) => {
|
|
1086
|
+
root: await this.clientRegistry.resolveServerRootOnce(server, filePath, rootMemo, (reason) => {
|
|
1300
1087
|
rootFailureReason = reason;
|
|
1301
1088
|
}),
|
|
1302
1089
|
reason: rootFailureReason
|
|
@@ -1343,7 +1130,7 @@ export class LSPService {
|
|
|
1343
1130
|
const acquisition = {
|
|
1344
1131
|
outcome: "declined"
|
|
1345
1132
|
};
|
|
1346
|
-
const spawned = await this.ensureClientForServer(filePath, server, resolvedRoots, noteSpawnInFlight, (reported) => {
|
|
1133
|
+
const spawned = await this.clientRegistry.ensureClientForServer(filePath, server, resolvedRoots, noteSpawnInFlight, (reported) => {
|
|
1347
1134
|
acquisition.outcome = reported;
|
|
1348
1135
|
}, rootMemo);
|
|
1349
1136
|
if (spawned) {
|
|
@@ -1381,14 +1168,14 @@ export class LSPService {
|
|
|
1381
1168
|
});
|
|
1382
1169
|
}
|
|
1383
1170
|
const unavailable = (await Promise.all(servers.map(async (server) => {
|
|
1384
|
-
const root = await this.resolveServerRootOnce(server, filePath, rootMemo);
|
|
1171
|
+
const root = await this.clientRegistry.resolveServerRootOnce(server, filePath, rootMemo);
|
|
1385
1172
|
return {
|
|
1386
1173
|
server,
|
|
1387
1174
|
key: `${server.id}:${root ? normalizeMapKey(root) : "<unresolved>"}`
|
|
1388
1175
|
};
|
|
1389
|
-
}))).filter(({ key }) => !this.unavailableLogged.has(key));
|
|
1176
|
+
}))).filter(({ key }) => !this.clientRegistry.unavailableLogged.has(key));
|
|
1390
1177
|
for (const { key } of unavailable)
|
|
1391
|
-
this.unavailableLogged.add(key);
|
|
1178
|
+
this.clientRegistry.unavailableLogged.add(key);
|
|
1392
1179
|
if (unavailable.length === 0)
|
|
1393
1180
|
return;
|
|
1394
1181
|
logLatency({
|
|
@@ -1491,7 +1278,7 @@ export class LSPService {
|
|
|
1491
1278
|
return { clients: [], serverCountAttempted: 0 };
|
|
1492
1279
|
const rootedServers = (await Promise.all(servers.map(async (server) => ({
|
|
1493
1280
|
server,
|
|
1494
|
-
root: await this.resolveServerRoot(server, filePath)
|
|
1281
|
+
root: await this.clientRegistry.resolveServerRoot(server, filePath)
|
|
1495
1282
|
})))).filter((entry) => entry.root !== undefined);
|
|
1496
1283
|
for (const { server, root } of rootedServers)
|
|
1497
1284
|
if (isAuxiliary(server))
|
|
@@ -1500,7 +1287,7 @@ export class LSPService {
|
|
|
1500
1287
|
const acquisitions = new Map;
|
|
1501
1288
|
const acquire = (server) => {
|
|
1502
1289
|
serverCountAttempted += 1;
|
|
1503
|
-
return this.ensureClientForServer(filePath, server, resolvedRoots);
|
|
1290
|
+
return this.clientRegistry.ensureClientForServer(filePath, server, resolvedRoots);
|
|
1504
1291
|
};
|
|
1505
1292
|
for (const { server } of rootedServers) {
|
|
1506
1293
|
const preferred = server.fallbackFor ? acquisitions.get(server.fallbackFor) : undefined;
|
|
@@ -1521,7 +1308,7 @@ export class LSPService {
|
|
|
1521
1308
|
const effectiveSignal = signal ?? getAmbientAbortSignal();
|
|
1522
1309
|
const effectiveHook = hook ?? "tool_result_edit";
|
|
1523
1310
|
const spawned = await Promise.all(servers.map(async (server) => {
|
|
1524
|
-
const acquisition = this.ensureClientForServer(filePath, server, undefined, undefined, (reported) => onOutcome?.(server.id, reported), rootMemo);
|
|
1311
|
+
const acquisition = this.clientRegistry.ensureClientForServer(filePath, server, undefined, undefined, (reported) => onOutcome?.(server.id, reported), rootMemo);
|
|
1525
1312
|
if (!maxWaitMs || maxWaitMs <= 0) {
|
|
1526
1313
|
return acquisition;
|
|
1527
1314
|
}
|
|
@@ -1540,7 +1327,7 @@ export class LSPService {
|
|
|
1540
1327
|
const servers = getServersForFileWithConfig(filePath);
|
|
1541
1328
|
const missed = [];
|
|
1542
1329
|
for (const server of servers) {
|
|
1543
|
-
const root = await this.resolveServerRoot(server, filePath);
|
|
1330
|
+
const root = await this.clientRegistry.resolveServerRoot(server, filePath);
|
|
1544
1331
|
if (!root)
|
|
1545
1332
|
continue;
|
|
1546
1333
|
const key = `${server.id}:${normalizeMapKey(root)}`;
|
|
@@ -1572,7 +1359,7 @@ export class LSPService {
|
|
|
1572
1359
|
for (const server of getServersForFileWithConfig(filePath)) {
|
|
1573
1360
|
if (server.id !== serverId)
|
|
1574
1361
|
continue;
|
|
1575
|
-
const root = await this.resolveServerRoot(server, filePath);
|
|
1362
|
+
const root = await this.clientRegistry.resolveServerRoot(server, filePath);
|
|
1576
1363
|
if (!root)
|
|
1577
1364
|
continue;
|
|
1578
1365
|
const key = `${server.id}:${normalizeMapKey(root)}`;
|
|
@@ -1590,7 +1377,7 @@ export class LSPService {
|
|
|
1590
1377
|
for (const server of getServersForFileWithConfig(filePath)) {
|
|
1591
1378
|
if (!serverIds.has(server.id) || out.has(server.id))
|
|
1592
1379
|
continue;
|
|
1593
|
-
const root = await this.resolveServerRoot(server, filePath);
|
|
1380
|
+
const root = await this.clientRegistry.resolveServerRoot(server, filePath);
|
|
1594
1381
|
if (!root)
|
|
1595
1382
|
continue;
|
|
1596
1383
|
const key = `${server.id}:${normalizeMapKey(root)}`;
|
|
@@ -1619,7 +1406,7 @@ export class LSPService {
|
|
|
1619
1406
|
for (const server of getServersForFileWithConfig(filePath)) {
|
|
1620
1407
|
if (server.id !== serverId)
|
|
1621
1408
|
continue;
|
|
1622
|
-
const root = await this.resolveServerRoot(server, filePath);
|
|
1409
|
+
const root = await this.clientRegistry.resolveServerRoot(server, filePath);
|
|
1623
1410
|
if (root === undefined)
|
|
1624
1411
|
return;
|
|
1625
1412
|
this.noteAuxiliaryLateAnswer(`${serverId}:${normalizeMapKey(root)}`, elapsedMs);
|
|
@@ -1630,12 +1417,213 @@ export class LSPService {
|
|
|
1630
1417
|
if (this.checkDestroyed())
|
|
1631
1418
|
return;
|
|
1632
1419
|
for (const server of getServersForFileWithConfig(filePath)) {
|
|
1633
|
-
const root = await this.resolveServerRoot(server, filePath);
|
|
1420
|
+
const root = await this.clientRegistry.resolveServerRoot(server, filePath);
|
|
1634
1421
|
if (!root)
|
|
1635
1422
|
continue;
|
|
1636
1423
|
this.notifyLiveClientsForServer(server.id, filePath, type, `${server.id}:${normalizeMapKey(root)}`, true);
|
|
1637
1424
|
}
|
|
1638
1425
|
}
|
|
1426
|
+
notifyOutOfBandFileChanges(changes) {
|
|
1427
|
+
if (this.checkDestroyed() || changes.length === 0)
|
|
1428
|
+
return;
|
|
1429
|
+
for (const { filePath, type } of changes) {
|
|
1430
|
+
const serverIds = new Set([
|
|
1431
|
+
...serverIdsForConfigFile(filePath) ?? [],
|
|
1432
|
+
...getServersForFileWithConfig(filePath).map((server) => server.id)
|
|
1433
|
+
]);
|
|
1434
|
+
for (const serverId of serverIds)
|
|
1435
|
+
this.notifyLiveClientsForServer(serverId, filePath, type, "", true);
|
|
1436
|
+
this.noteUnheldSent(filePath);
|
|
1437
|
+
}
|
|
1438
|
+
for (const client of this.state.clients.values())
|
|
1439
|
+
if (client.isAlive())
|
|
1440
|
+
client.notify.flushWatched?.();
|
|
1441
|
+
}
|
|
1442
|
+
noteUnheldSent(filePath) {
|
|
1443
|
+
const key = normalizeMapKey(filePath);
|
|
1444
|
+
let stat;
|
|
1445
|
+
try {
|
|
1446
|
+
stat = nodeFs.statSync(filePath, { throwIfNoEntry: false });
|
|
1447
|
+
} catch {
|
|
1448
|
+
stat = undefined;
|
|
1449
|
+
}
|
|
1450
|
+
if (stat === undefined) {
|
|
1451
|
+
this.unheldStamps.delete(key);
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
const seen = this.unheldStamps.get(key);
|
|
1455
|
+
if (seen?.size === stat.size && seen.mtimeMs === stat.mtimeMs)
|
|
1456
|
+
return;
|
|
1457
|
+
this.unheldStamps.set(key, { size: stat.size, mtimeMs: stat.mtimeMs });
|
|
1458
|
+
}
|
|
1459
|
+
async restartPrimaryClientsUnder(root) {
|
|
1460
|
+
if (this.checkDestroyed())
|
|
1461
|
+
return 0;
|
|
1462
|
+
return (await this.clientRegistry.restartPrimaryClientsUnder(root)).length;
|
|
1463
|
+
}
|
|
1464
|
+
livePrimaryClientRoots() {
|
|
1465
|
+
if (this.checkDestroyed())
|
|
1466
|
+
return [];
|
|
1467
|
+
return this.clientRegistry.livePrimaryClientRoots();
|
|
1468
|
+
}
|
|
1469
|
+
announceCreatedFiles(filePaths, importTargets = []) {
|
|
1470
|
+
if (this.checkDestroyed() || this.state.clients.size === 0)
|
|
1471
|
+
return;
|
|
1472
|
+
this.sendUnheldChanges(importTargets);
|
|
1473
|
+
const byServer = new Map;
|
|
1474
|
+
for (const filePath of [...filePaths, ...importTargets]) {
|
|
1475
|
+
let stat;
|
|
1476
|
+
try {
|
|
1477
|
+
stat = nodeFs.statSync(filePath);
|
|
1478
|
+
} catch {
|
|
1479
|
+
continue;
|
|
1480
|
+
}
|
|
1481
|
+
for (const server of getServersForFileWithConfig(filePath)) {
|
|
1482
|
+
const entries = byServer.get(server.id) ?? [];
|
|
1483
|
+
entries.push({ filePath, stat });
|
|
1484
|
+
byServer.set(server.id, entries);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
for (const [key, client] of this.state.clients) {
|
|
1488
|
+
if (!client.isAlive())
|
|
1489
|
+
continue;
|
|
1490
|
+
const entries = [...byServer].flatMap(([serverId, list]) => key.startsWith(`${serverId}:`) ? list : []);
|
|
1491
|
+
client.notify.announceCreated(entries);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
sendUnheldChanges(filePaths) {
|
|
1495
|
+
const changed = [];
|
|
1496
|
+
const at = Date.now();
|
|
1497
|
+
for (const filePath of filePaths) {
|
|
1498
|
+
let stat;
|
|
1499
|
+
try {
|
|
1500
|
+
stat = nodeFs.statSync(filePath);
|
|
1501
|
+
} catch {
|
|
1502
|
+
continue;
|
|
1503
|
+
}
|
|
1504
|
+
const servers = getServersForFileWithConfig(filePath);
|
|
1505
|
+
if (!this.unheldBytesMoved(filePath, stat, servers))
|
|
1506
|
+
continue;
|
|
1507
|
+
changed.push({ filePath, type: FILE_CHANGED });
|
|
1508
|
+
for (const client of this.liveClientsOf(servers, filePath))
|
|
1509
|
+
noteWorkspaceFilesChangedOnDisk(client.root, [normalizeMapKey(filePath)], at);
|
|
1510
|
+
}
|
|
1511
|
+
if (changed.length === 0)
|
|
1512
|
+
return;
|
|
1513
|
+
this.notifyOutOfBandFileChanges(changed);
|
|
1514
|
+
logLatency({
|
|
1515
|
+
type: "phase",
|
|
1516
|
+
phase: "lsp_unheld_dependency_changed",
|
|
1517
|
+
filePath: changed[0]?.filePath ?? "",
|
|
1518
|
+
durationMs: Date.now() - at,
|
|
1519
|
+
result: `changed:${changed.length}`,
|
|
1520
|
+
metadata: {
|
|
1521
|
+
changed: changed.length,
|
|
1522
|
+
paths: changed.slice(0, 5).map((change) => change.filePath)
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
unheldBytesMoved(filePath, stat, servers) {
|
|
1527
|
+
const live = this.liveClientsOf(servers, filePath);
|
|
1528
|
+
if (live.every((client) => client.holds))
|
|
1529
|
+
return false;
|
|
1530
|
+
const key = normalizeMapKey(filePath);
|
|
1531
|
+
const seen = this.unheldStamps.get(key);
|
|
1532
|
+
if (seen?.size === stat.size && seen.mtimeMs === stat.mtimeMs)
|
|
1533
|
+
return false;
|
|
1534
|
+
let stamp = { size: stat.size, mtimeMs: stat.mtimeMs };
|
|
1535
|
+
if (stat.size <= CONTENT_HASH_MAX_BYTES) {
|
|
1536
|
+
try {
|
|
1537
|
+
stamp = stampContentBytes(nodeFs.readFileSync(filePath), stat.mtimeMs);
|
|
1538
|
+
} catch (cause) {
|
|
1539
|
+
recordDegradationOnce({
|
|
1540
|
+
kind: "lsp-unheld-dependency-unreadable",
|
|
1541
|
+
subject: key,
|
|
1542
|
+
reason: `could not read a closed module to compare its bytes; a change of its stat is sent as a change: ${cause instanceof Error ? cause.message : String(cause)}`
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
this.unheldStamps.set(key, stamp);
|
|
1547
|
+
if (seen === undefined)
|
|
1548
|
+
return live.some((client) => watchedTypeForOpen(stat.mtimeMs, client.launchedAt) === FILE_CREATED);
|
|
1549
|
+
return seen.sha256 === undefined || seen.sha256 !== stamp.sha256;
|
|
1550
|
+
}
|
|
1551
|
+
liveClientsOf(servers, filePath) {
|
|
1552
|
+
const live = [];
|
|
1553
|
+
for (const [key, client] of this.state.clients) {
|
|
1554
|
+
if (!client.isAlive())
|
|
1555
|
+
continue;
|
|
1556
|
+
if (!servers.some((server) => key.startsWith(`${server.id}:`)))
|
|
1557
|
+
continue;
|
|
1558
|
+
live.push({
|
|
1559
|
+
root: client.root,
|
|
1560
|
+
launchedAt: this.clientRegistry.clientLaunchStartedAt.get(key) ?? 0,
|
|
1561
|
+
holds: documentIsOpenOn(client, filePath)
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
return live;
|
|
1565
|
+
}
|
|
1566
|
+
async resyncHeldPrimaries(filePaths, drainMs) {
|
|
1567
|
+
let sent = 0;
|
|
1568
|
+
const sentTo = new Map;
|
|
1569
|
+
for (const filePath of filePaths) {
|
|
1570
|
+
if (this.checkDestroyed())
|
|
1571
|
+
break;
|
|
1572
|
+
const servers = getServersForFileWithConfig(filePath);
|
|
1573
|
+
const exclude = await this.serverIdsNotHoldingDocument(filePath);
|
|
1574
|
+
for (const server of servers)
|
|
1575
|
+
if (isAuxiliary(server))
|
|
1576
|
+
exclude.add(server.id);
|
|
1577
|
+
if (servers.every((server) => exclude.has(server.id)))
|
|
1578
|
+
continue;
|
|
1579
|
+
const readStamp = performance.now();
|
|
1580
|
+
let content;
|
|
1581
|
+
try {
|
|
1582
|
+
content = await fs.readFile(filePath, "utf8");
|
|
1583
|
+
} catch {
|
|
1584
|
+
continue;
|
|
1585
|
+
}
|
|
1586
|
+
await this.touchFile(filePath, content, {
|
|
1587
|
+
diagnostics: "none",
|
|
1588
|
+
source: "head_move_primary",
|
|
1589
|
+
clientScope: "all",
|
|
1590
|
+
excludeServerIds: exclude,
|
|
1591
|
+
readStamp
|
|
1592
|
+
});
|
|
1593
|
+
sent += 1;
|
|
1594
|
+
for (const server of servers) {
|
|
1595
|
+
if (exclude.has(server.id))
|
|
1596
|
+
continue;
|
|
1597
|
+
const root = await this.clientRegistry.resolveServerRoot(server, filePath);
|
|
1598
|
+
const key = root ? `${server.id}:${normalizeMapKey(root)}` : undefined;
|
|
1599
|
+
const client = key ? this.state.clients.get(key) : undefined;
|
|
1600
|
+
if (key && client) {
|
|
1601
|
+
const traits = serverTraits(server);
|
|
1602
|
+
const documents = sentTo.get(key)?.documents ?? [];
|
|
1603
|
+
documents.push({ filePath, content, readStamp });
|
|
1604
|
+
sentTo.set(key, {
|
|
1605
|
+
client,
|
|
1606
|
+
ordered: traits.replyOrdering === "single-task-ordered",
|
|
1607
|
+
rechecks: traits.resendRecheck === "rechecks",
|
|
1608
|
+
documents
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
if (sentTo.size === 0)
|
|
1614
|
+
return { sent, drained: true };
|
|
1615
|
+
await Promise.all([...sentTo.values()].flatMap(({ client, rechecks, documents }) => (rechecks ? documents : []).slice(0, -1).map(({ filePath, content, readStamp }) => client.notify.open(filePath, content, getLanguageId(filePath) ?? "plaintext", undefined, undefined, undefined, readStamp))));
|
|
1616
|
+
const answers = await Promise.all([...sentTo.values()].map(async ({ client, ordered }) => {
|
|
1617
|
+
if (!ordered)
|
|
1618
|
+
return false;
|
|
1619
|
+
try {
|
|
1620
|
+
return await client.pingLiveness?.(drainMs) ?? true;
|
|
1621
|
+
} catch {
|
|
1622
|
+
return false;
|
|
1623
|
+
}
|
|
1624
|
+
}));
|
|
1625
|
+
return { sent, drained: answers.every(Boolean) };
|
|
1626
|
+
}
|
|
1639
1627
|
async resyncGitChangedFiles(changedPaths, options = {}) {
|
|
1640
1628
|
const dispositions = new Map;
|
|
1641
1629
|
if (this.checkDestroyed() || changedPaths.length === 0) {
|
|
@@ -1646,7 +1634,7 @@ export class LSPService {
|
|
|
1646
1634
|
for (const changedPath of changedPaths) {
|
|
1647
1635
|
const resolved = path.resolve(changedPath);
|
|
1648
1636
|
for (const server of getServersForFileWithConfig(resolved)) {
|
|
1649
|
-
const root = await this.resolveServerRoot(server, resolved);
|
|
1637
|
+
const root = await this.clientRegistry.resolveServerRoot(server, resolved);
|
|
1650
1638
|
if (!root)
|
|
1651
1639
|
continue;
|
|
1652
1640
|
const index = loadReverseDependencyIndexFromSnapshot({ cwd: root });
|
|
@@ -1661,7 +1649,21 @@ export class LSPService {
|
|
|
1661
1649
|
const written = new Set(changed.values());
|
|
1662
1650
|
this.documentDrift.enqueueResync(openTargets.filter((filePath) => !written.has(filePath)));
|
|
1663
1651
|
this.documentDrift.enqueueResync(openTargets.filter((filePath) => written.has(filePath)), { saved: options.saved === true });
|
|
1664
|
-
|
|
1652
|
+
let pass;
|
|
1653
|
+
let passes = 0;
|
|
1654
|
+
const reached = new Map;
|
|
1655
|
+
const waiting = (filePath) => {
|
|
1656
|
+
const disposition = reached.get(normalizeMapKey(filePath));
|
|
1657
|
+
return disposition === undefined || disposition === "deferred";
|
|
1658
|
+
};
|
|
1659
|
+
for (let n = 0;n < Math.max(1, options.maxPasses ?? 1); n++) {
|
|
1660
|
+
pass = await this.sweepDocumentDrift({ force: true });
|
|
1661
|
+
passes += 1;
|
|
1662
|
+
for (const [key, disposition] of pass?.queued ?? [])
|
|
1663
|
+
reached.set(key, disposition);
|
|
1664
|
+
if (!pass || !openTargets.some(waiting))
|
|
1665
|
+
break;
|
|
1666
|
+
}
|
|
1665
1667
|
logLatency({
|
|
1666
1668
|
type: "phase",
|
|
1667
1669
|
phase: "lsp_external_change_resync",
|
|
@@ -1670,11 +1672,12 @@ export class LSPService {
|
|
|
1670
1672
|
metadata: {
|
|
1671
1673
|
changedCount: changedPaths.length,
|
|
1672
1674
|
enqueued: openTargets.length,
|
|
1673
|
-
deferred: pass?.deferred ?? this.documentDrift.pendingResyncCount
|
|
1675
|
+
deferred: pass?.deferred ?? this.documentDrift.pendingResyncCount,
|
|
1676
|
+
passes
|
|
1674
1677
|
}
|
|
1675
1678
|
});
|
|
1676
1679
|
for (const [changedPath, resolved] of changed) {
|
|
1677
|
-
dispositions.set(changedPath, openTargets.includes(resolved) ?
|
|
1680
|
+
dispositions.set(changedPath, openTargets.includes(resolved) ? reached.get(normalizeMapKey(resolved)) ?? "deferred" : "unheld");
|
|
1678
1681
|
}
|
|
1679
1682
|
return dispositions;
|
|
1680
1683
|
}
|
|
@@ -1683,6 +1686,8 @@ export class LSPService {
|
|
|
1683
1686
|
return;
|
|
1684
1687
|
return this.documentDrift.sweep({
|
|
1685
1688
|
resync: async (filePath, content, _driftAgeMs, readStamp, saved) => {
|
|
1689
|
+
if (exceedsLspSyncLimits(content).tooLarge)
|
|
1690
|
+
return false;
|
|
1686
1691
|
await this.touchFile(filePath, content, {
|
|
1687
1692
|
diagnostics: "none",
|
|
1688
1693
|
source: "drift_resync",
|
|
@@ -1693,7 +1698,6 @@ export class LSPService {
|
|
|
1693
1698
|
});
|
|
1694
1699
|
return this.documentDrift.peek(filePath)?.fingerprint === fingerprintDocumentContent(content);
|
|
1695
1700
|
},
|
|
1696
|
-
holdsDocument: (filePath) => this.hasLiveClientHoldingDocument(filePath),
|
|
1697
1701
|
onDrift: (event) => {
|
|
1698
1702
|
if (event.disposition === "unchanged" || event.disposition === "vanished" || event.disposition === "unheld") {
|
|
1699
1703
|
return;
|
|
@@ -1733,7 +1737,7 @@ export class LSPService {
|
|
|
1733
1737
|
async serverIdsNotHoldingDocument(filePath) {
|
|
1734
1738
|
const exclude = new Set;
|
|
1735
1739
|
for (const server of getServersForFileWithConfig(filePath)) {
|
|
1736
|
-
const root = await this.resolveServerRoot(server, filePath);
|
|
1740
|
+
const root = await this.clientRegistry.resolveServerRoot(server, filePath);
|
|
1737
1741
|
const existing = root ? this.state.clients.get(`${server.id}:${normalizeMapKey(root)}`) : undefined;
|
|
1738
1742
|
if (existing?.isAlive() && documentIsOpenOn(existing, filePath))
|
|
1739
1743
|
continue;
|
|
@@ -1755,366 +1759,6 @@ export class LSPService {
|
|
|
1755
1759
|
}
|
|
1756
1760
|
this.documentDrift.recordSynced(filePath, content, at, contentFingerprint?.() ?? fingerprintDocumentContent(content));
|
|
1757
1761
|
}
|
|
1758
|
-
noteSpawnVerdict(key, verdict) {
|
|
1759
|
-
this.lastSpawnVerdict.set(key, verdict);
|
|
1760
|
-
}
|
|
1761
|
-
resolveServerRootOnce(server, filePath, memo, onRootFailure) {
|
|
1762
|
-
if (!memo)
|
|
1763
|
-
return this.resolveServerRoot(server, filePath, onRootFailure);
|
|
1764
|
-
const pending = memo.get(server.id);
|
|
1765
|
-
if (pending !== undefined)
|
|
1766
|
-
return pending;
|
|
1767
|
-
const started = this.resolveServerRoot(server, filePath, onRootFailure);
|
|
1768
|
-
memo.set(server.id, started);
|
|
1769
|
-
return started;
|
|
1770
|
-
}
|
|
1771
|
-
async ensureClientForServer(filePath, server, resolvedRoots, onSpawnInFlight, onOutcome, rootMemo) {
|
|
1772
|
-
const handoff = this.generationHandoff;
|
|
1773
|
-
if (handoff) {
|
|
1774
|
-
await handoff;
|
|
1775
|
-
if (this.generationHandoff === handoff) {
|
|
1776
|
-
this.generationHandoff = undefined;
|
|
1777
|
-
}
|
|
1778
|
-
if (this.checkDestroyed())
|
|
1779
|
-
return;
|
|
1780
|
-
}
|
|
1781
|
-
const root = await this.resolveServerRootOnce(server, filePath, rootMemo);
|
|
1782
|
-
if (!root || this.checkDestroyed())
|
|
1783
|
-
return;
|
|
1784
|
-
if (!isAuxiliary(server)) {
|
|
1785
|
-
resolvedRoots?.set(server.id, normalizeMapKey(root));
|
|
1786
|
-
}
|
|
1787
|
-
const allowInstall = this.shouldAllowInstall(server.id);
|
|
1788
|
-
const normalizedRoot = normalizeMapKey(root);
|
|
1789
|
-
const key = `${server.id}:${normalizedRoot}`;
|
|
1790
|
-
const adopted = this.analysisRootModeForFile(filePath) === "adopted";
|
|
1791
|
-
if (adopted) {
|
|
1792
|
-
const localCommand = server.command ?? server.projectLocalCommand ?? server.availabilityKey;
|
|
1793
|
-
const localBinary = localCommand ? path.isAbsolute(localCommand) ? isProjectLocalBinPath(localCommand, root) ? localCommand : undefined : findLocalBinUpwards(localCommand, root) : undefined;
|
|
1794
|
-
if (localBinary) {
|
|
1795
|
-
recordDegradationOnce({
|
|
1796
|
-
kind: "lsp-registry-decision",
|
|
1797
|
-
subject: `${server.id}:${normalizeMapKey(root)}`,
|
|
1798
|
-
reason: "project-local LSP binary refused for adopted root"
|
|
1799
|
-
});
|
|
1800
|
-
return;
|
|
1801
|
-
}
|
|
1802
|
-
this.adoptedClientKeys.add(key);
|
|
1803
|
-
if (!this.admitAdoptedRoot(root, filePath))
|
|
1804
|
-
return;
|
|
1805
|
-
}
|
|
1806
|
-
const isOptionalServer = OPTIONAL_LSP_SERVER_IDS.has(server.id);
|
|
1807
|
-
if (server.availabilityKey && isDirectLspCommandTemporarilyUnavailable(server.availabilityKey)) {
|
|
1808
|
-
emitBounded("lsp_client_skipped_unavailable_command", `${server.availabilityKey}:${normalizeMapKey(filePath)}`, {
|
|
1809
|
-
filePath,
|
|
1810
|
-
durationMs: 0,
|
|
1811
|
-
metadata: {
|
|
1812
|
-
serverId: server.id,
|
|
1813
|
-
command: server.availabilityKey
|
|
1814
|
-
}
|
|
1815
|
-
}, {
|
|
1816
|
-
ledgerKind: "lsp-client-skipped-unavailable-command",
|
|
1817
|
-
risingEdgePer: "identity",
|
|
1818
|
-
reason: `command ${server.availabilityKey} temporarily unavailable`
|
|
1819
|
-
});
|
|
1820
|
-
return;
|
|
1821
|
-
}
|
|
1822
|
-
if (isOptionalServer && this.optionalDisabled.has(key)) {
|
|
1823
|
-
return;
|
|
1824
|
-
}
|
|
1825
|
-
if (this.permanentlyBroken.has(key)) {
|
|
1826
|
-
emitBounded("lsp_client_skipped_broken", `${server.id}:${normalizeMapKey(filePath)}`, {
|
|
1827
|
-
filePath,
|
|
1828
|
-
durationMs: 0,
|
|
1829
|
-
metadata: {
|
|
1830
|
-
serverId: server.id,
|
|
1831
|
-
permanent: true
|
|
1832
|
-
}
|
|
1833
|
-
}, {
|
|
1834
|
-
ledgerKind: "lsp-client-skipped-broken",
|
|
1835
|
-
risingEdgePer: "identity",
|
|
1836
|
-
reason: `${server.id} latched permanently broken`
|
|
1837
|
-
});
|
|
1838
|
-
return;
|
|
1839
|
-
}
|
|
1840
|
-
const existing = this.state.clients.get(key);
|
|
1841
|
-
if (existing) {
|
|
1842
|
-
if (existing.isAlive()) {
|
|
1843
|
-
this.unavailableLogged.delete(key);
|
|
1844
|
-
this.clientLastUsedAt.set(key, Date.now());
|
|
1845
|
-
this.scheduleIdleEviction(key, server);
|
|
1846
|
-
if (!this.warmStartLogged.has(key)) {
|
|
1847
|
-
logSessionStart(`lsp warm-start ${server.id}: reused root=${root} file=${filePath}`);
|
|
1848
|
-
this.warmStartLogged.add(key);
|
|
1849
|
-
}
|
|
1850
|
-
onOutcome?.("warm-reuse");
|
|
1851
|
-
return { client: existing, info: server };
|
|
1852
|
-
}
|
|
1853
|
-
const spawnedAt = this.state.clientSpawnedAt.get(key);
|
|
1854
|
-
const wasIntentional = existing.wasShutdownIntentional();
|
|
1855
|
-
const exitedAt = existing.getExitedAt();
|
|
1856
|
-
const uptimeMs = exitedAt != null && spawnedAt != null ? exitedAt - spawnedAt : spawnedAt != null ? Date.now() - spawnedAt : null;
|
|
1857
|
-
logLatency({
|
|
1858
|
-
type: "phase",
|
|
1859
|
-
phase: "lsp_server_respawn",
|
|
1860
|
-
filePath,
|
|
1861
|
-
durationMs: 0,
|
|
1862
|
-
metadata: {
|
|
1863
|
-
serverId: server.id,
|
|
1864
|
-
root,
|
|
1865
|
-
uptimeMs,
|
|
1866
|
-
intentional: wasIntentional
|
|
1867
|
-
}
|
|
1868
|
-
});
|
|
1869
|
-
this.releaseOutstandingAuxNotifyWrite(key);
|
|
1870
|
-
try {
|
|
1871
|
-
await existing.shutdown();
|
|
1872
|
-
} catch {}
|
|
1873
|
-
this.retireClient(key);
|
|
1874
|
-
this.state.broken.delete(key);
|
|
1875
|
-
if (wasIntentional) {} else {
|
|
1876
|
-
if (this.recordRuntimeExitWindow(key, exitedAt, uptimeMs)) {
|
|
1877
|
-
const rate = `${RUNTIME_EXIT_WINDOW_TRIP_COUNT} deaths within ${Math.round(RUNTIME_EXIT_WINDOW_MS / 60000)}m`;
|
|
1878
|
-
this.state.broken.set(key, Math.max(this.state.broken.get(key) ?? 0, Date.now() + (isOptionalServer ? OPTIONAL_LSP_RETRY_COOLDOWN_MS : BROKEN_MAX_COOLDOWN_MS)));
|
|
1879
|
-
if (isOptionalServer) {
|
|
1880
|
-
this.optionalDisabled.add(key);
|
|
1881
|
-
this.runtimeExitWindow.delete(key);
|
|
1882
|
-
logSessionStart(`lsp respawn ${server.id}: optional server cooled down (windowed-rate trip: ${rate})`);
|
|
1883
|
-
} else {
|
|
1884
|
-
this.permanentlyBroken.add(key);
|
|
1885
|
-
this.recordBreaker(key, `windowed runtime-exit trip: ${rate}`);
|
|
1886
|
-
logSessionStart(`lsp respawn ${server.id}: permanently disabled (windowed-rate trip: ${rate}, uptimeMs=${uptimeMs})`);
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
if (uptimeMs != null && uptimeMs < RUNTIME_EXIT_UPTIME_THRESHOLD_MS) {
|
|
1890
|
-
const rCount = (this.runtimeExitCounts.get(key) ?? 0) + 1;
|
|
1891
|
-
this.runtimeExitCounts.set(key, rCount);
|
|
1892
|
-
const rCooldown = Math.min(BROKEN_BASE_COOLDOWN_MS * 2 ** (rCount - 1), BROKEN_MAX_COOLDOWN_MS);
|
|
1893
|
-
this.state.broken.set(key, Date.now() + rCooldown);
|
|
1894
|
-
if (!isOptionalServer && rCount >= BROKEN_PERMANENT_AFTER) {
|
|
1895
|
-
this.permanentlyBroken.add(key);
|
|
1896
|
-
this.recordBreaker(key, `permanently disabled after ${rCount} early post-init exits`);
|
|
1897
|
-
logSessionStart(`lsp respawn ${server.id}: permanently disabled after ${rCount} early post-init exits (uptimeMs=${uptimeMs})`);
|
|
1898
|
-
} else {
|
|
1899
|
-
logSessionStart(`lsp respawn ${server.id}: early post-init exit ${rCount}/${BROKEN_PERMANENT_AFTER} (uptimeMs=${uptimeMs}), cooldown=${rCooldown}ms`);
|
|
1900
|
-
}
|
|
1901
|
-
} else {
|
|
1902
|
-
this.runtimeExitCounts.delete(key);
|
|
1903
|
-
const windowDeaths = this.runtimeExitWindow.get(key);
|
|
1904
|
-
if (windowDeaths) {
|
|
1905
|
-
const windowNow = exitedAt ?? Date.now();
|
|
1906
|
-
if (!windowDeaths.some((t) => t >= windowNow - RUNTIME_EXIT_WINDOW_MS)) {
|
|
1907
|
-
this.runtimeExitWindow.delete(key);
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
const brokenUntil = this.state.broken.get(key);
|
|
1914
|
-
if (typeof brokenUntil === "number" && brokenUntil > Date.now()) {
|
|
1915
|
-
emitBounded("lsp_client_skipped_broken", `${server.id}:${normalizeMapKey(filePath)}`, {
|
|
1916
|
-
filePath,
|
|
1917
|
-
durationMs: 0,
|
|
1918
|
-
metadata: {
|
|
1919
|
-
serverId: server.id,
|
|
1920
|
-
retryInMs: Math.max(0, brokenUntil - Date.now())
|
|
1921
|
-
}
|
|
1922
|
-
}, {
|
|
1923
|
-
ledgerKind: "lsp-client-skipped-broken",
|
|
1924
|
-
risingEdgePer: "identity",
|
|
1925
|
-
reason: `${server.id} in breaker cooldown`
|
|
1926
|
-
});
|
|
1927
|
-
return;
|
|
1928
|
-
}
|
|
1929
|
-
if (typeof brokenUntil === "number" && brokenUntil <= Date.now()) {
|
|
1930
|
-
this.state.broken.delete(key);
|
|
1931
|
-
if (isOptionalServer)
|
|
1932
|
-
this.optionalDisabled.delete(key);
|
|
1933
|
-
}
|
|
1934
|
-
let startedSpawn = false;
|
|
1935
|
-
let spawnPromise = this.state.inFlight.get(key);
|
|
1936
|
-
if (!spawnPromise) {
|
|
1937
|
-
const started = await this.withClientSpawnGate(async () => {
|
|
1938
|
-
const raced = this.state.inFlight.get(key);
|
|
1939
|
-
if (raced)
|
|
1940
|
-
return { promise: raced, startedSpawn: false };
|
|
1941
|
-
if (this.checkDestroyed())
|
|
1942
|
-
return;
|
|
1943
|
-
if (!await this.makeCapacityForClient(key))
|
|
1944
|
-
return;
|
|
1945
|
-
const promise = this.spawnClient(server, root, key, filePath, allowInstall);
|
|
1946
|
-
this.state.inFlight.set(key, promise);
|
|
1947
|
-
return { promise, startedSpawn: true };
|
|
1948
|
-
});
|
|
1949
|
-
if (!started)
|
|
1950
|
-
return;
|
|
1951
|
-
spawnPromise = started.promise;
|
|
1952
|
-
startedSpawn = started.startedSpawn;
|
|
1953
|
-
}
|
|
1954
|
-
onSpawnInFlight?.(server.id);
|
|
1955
|
-
try {
|
|
1956
|
-
const spawned = await spawnPromise;
|
|
1957
|
-
onOutcome?.(spawned ? startedSpawn ? "cold-spawn" : "cold-spawn-joined" : this.lastSpawnVerdict.get(key) === "failed" ? startedSpawn ? "spawn-failure" : "spawn-failure-joined" : "declined");
|
|
1958
|
-
return spawned;
|
|
1959
|
-
} catch (err) {
|
|
1960
|
-
onOutcome?.("spawn-failure");
|
|
1961
|
-
throw err;
|
|
1962
|
-
} finally {
|
|
1963
|
-
if (this.state.inFlight.get(key) === spawnPromise) {
|
|
1964
|
-
this.state.inFlight.delete(key);
|
|
1965
|
-
}
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
shouldAllowInstall(serverId) {
|
|
1969
|
-
if (!assertInstallAllowed(`lsp install: ${serverId}`))
|
|
1970
|
-
return false;
|
|
1971
|
-
return process.env.DM_LENS_DISABLE_LSP_INSTALL !== "1";
|
|
1972
|
-
}
|
|
1973
|
-
async spawnClient(server, root, key, filePath, allowInstall) {
|
|
1974
|
-
try {
|
|
1975
|
-
if (server.executesProjectCode === true) {
|
|
1976
|
-
refuseUntrustedLspExecution({
|
|
1977
|
-
kind: "project-code-server",
|
|
1978
|
-
serverId: server.id,
|
|
1979
|
-
root
|
|
1980
|
-
});
|
|
1981
|
-
}
|
|
1982
|
-
} catch (error) {
|
|
1983
|
-
logSessionStart(`lsp spawn ${server.id}: refused — ${error instanceof Error ? error.message : String(error)}`);
|
|
1984
|
-
this.noteSpawnVerdict(key, "failed");
|
|
1985
|
-
return;
|
|
1986
|
-
}
|
|
1987
|
-
if (server.trustAllowed !== true && !isLspSpawnAllowedByTrust()) {
|
|
1988
|
-
logSessionStart(`lsp spawn ${server.id}: refused — ${projectTrustDenialReason()}`);
|
|
1989
|
-
this.noteSpawnVerdict(key, "declined");
|
|
1990
|
-
return;
|
|
1991
|
-
}
|
|
1992
|
-
const isOptionalServer = OPTIONAL_LSP_SERVER_IDS.has(server.id);
|
|
1993
|
-
const startedAt = Date.now();
|
|
1994
|
-
logSessionStart(`lsp spawn ${server.id}: start root=${root} install=${allowInstall ? "enabled" : "disabled"} file=${filePath}`);
|
|
1995
|
-
recordLsp(server.id, root, "spawn_start");
|
|
1996
|
-
try {
|
|
1997
|
-
const projectCodeAllowed = this.analysisRootModeForFile(filePath) !== "adopted";
|
|
1998
|
-
const spawned = await withLspProjectCodePermission(projectCodeAllowed, () => server.spawn(root, {
|
|
1999
|
-
allowInstall,
|
|
2000
|
-
projectCodeAllowed,
|
|
2001
|
-
sessionRoot: this.sessionCwd ?? process.cwd()
|
|
2002
|
-
}));
|
|
2003
|
-
if (this.isDestroyed) {
|
|
2004
|
-
try {
|
|
2005
|
-
spawned?.process?.process?.kill();
|
|
2006
|
-
} catch {}
|
|
2007
|
-
logSessionStart(`lsp spawn ${server.id}: aborted (service shut down mid-spawn)`);
|
|
2008
|
-
this.noteSpawnVerdict(key, "declined");
|
|
2009
|
-
return;
|
|
2010
|
-
}
|
|
2011
|
-
if (!spawned) {
|
|
2012
|
-
logSessionStart(`lsp spawn ${server.id}: unavailable (${Date.now() - startedAt}ms)`);
|
|
2013
|
-
recordLsp(server.id, root, "spawn_failed", Date.now() - startedAt);
|
|
2014
|
-
if (!allowInstall) {
|
|
2015
|
-
logSessionStart(`lsp spawn ${server.id}: unavailable with install disabled; temporary cooldown only`);
|
|
2016
|
-
this.state.broken.set(key, Date.now() + BROKEN_BASE_COOLDOWN_MS);
|
|
2017
|
-
this.noteSpawnVerdict(key, "declined");
|
|
2018
|
-
return;
|
|
2019
|
-
}
|
|
2020
|
-
const uCount = (this.failureCounts.get(key) ?? 0) + 1;
|
|
2021
|
-
this.failureCounts.set(key, uCount);
|
|
2022
|
-
const uCooldown = Math.min(BROKEN_BASE_COOLDOWN_MS * 2 ** (uCount - 1), BROKEN_MAX_COOLDOWN_MS);
|
|
2023
|
-
this.state.broken.set(key, Date.now() + uCooldown);
|
|
2024
|
-
if (uCount >= BROKEN_PERMANENT_AFTER) {
|
|
2025
|
-
this.permanentlyBroken.add(key);
|
|
2026
|
-
this.recordBreaker(key, `permanently disabled after ${uCount} unavailable spawns`);
|
|
2027
|
-
logSessionStart(`lsp spawn ${server.id}: permanently disabled after ${uCount} failures`);
|
|
2028
|
-
}
|
|
2029
|
-
this.noteSpawnVerdict(key, "failed");
|
|
2030
|
-
return;
|
|
2031
|
-
}
|
|
2032
|
-
const override = getServerInitOverride(server.id, filePath);
|
|
2033
|
-
const mergedInit = spawned.launchVariant === "classic" ? mergeInitializationOptions(override?.initializationOptions, spawned.initialization) : mergeInitializationOptions(spawned.initialization, override?.initializationOptions);
|
|
2034
|
-
this.state.diagnosticsPublished.delete(server.id);
|
|
2035
|
-
this.state.diagnosticsUnsupported.delete(server.id);
|
|
2036
|
-
this.firstContactWaits.delete(server.id);
|
|
2037
|
-
const client = await createLSPClient({
|
|
2038
|
-
serverId: server.id,
|
|
2039
|
-
process: spawned.process,
|
|
2040
|
-
root,
|
|
2041
|
-
sessionCwd: this.sessionCwd,
|
|
2042
|
-
initialization: mergedInit,
|
|
2043
|
-
initializeTimeoutMs: server.initializeTimeoutMs,
|
|
2044
|
-
launchVariant: spawned.launchVariant,
|
|
2045
|
-
onDiagnosticsPublished: (serverId) => {
|
|
2046
|
-
this.state.diagnosticsPublished.add(serverId);
|
|
2047
|
-
}
|
|
2048
|
-
});
|
|
2049
|
-
if (this.isDestroyed) {
|
|
2050
|
-
client.shutdown({ fast: true }).catch(() => {});
|
|
2051
|
-
logSessionStart(`lsp spawn ${server.id}: aborted (service shut down mid-initialize)`);
|
|
2052
|
-
this.noteSpawnVerdict(key, "declined");
|
|
2053
|
-
return;
|
|
2054
|
-
}
|
|
2055
|
-
const wsDiag = typeof client.getWorkspaceDiagnosticsSupport === "function" ? client.getWorkspaceDiagnosticsSupport() : {
|
|
2056
|
-
advertised: false,
|
|
2057
|
-
mode: "push-only",
|
|
2058
|
-
diagnosticProviderKind: "unavailable"
|
|
2059
|
-
};
|
|
2060
|
-
this.state.clients.set(key, client);
|
|
2061
|
-
this.forgetReadiness(key);
|
|
2062
|
-
this.notifyStallDemotions.delete(key);
|
|
2063
|
-
this.unavailableLogged.delete(key);
|
|
2064
|
-
this.lastSpawnVerdict.delete(key);
|
|
2065
|
-
this.state.clientSpawnedAt.set(key, Date.now());
|
|
2066
|
-
this.clientLastUsedAt.set(key, Date.now());
|
|
2067
|
-
this.scheduleIdleEviction(key, server);
|
|
2068
|
-
this.failureCounts.delete(key);
|
|
2069
|
-
if (isOptionalServer) {
|
|
2070
|
-
this.optionalDisabled.delete(key);
|
|
2071
|
-
this.optionalFailureLogged.delete(key);
|
|
2072
|
-
}
|
|
2073
|
-
logSessionStart(`lsp spawn ${server.id}: success source=${spawned.source ?? "unknown"} (${Date.now() - startedAt}ms)`);
|
|
2074
|
-
const spawnDurationMs = Date.now() - startedAt;
|
|
2075
|
-
recordLsp(server.id, root, "spawn_success", spawnDurationMs);
|
|
2076
|
-
recordSuccessfulLspSpawn(server.id, spawnDurationMs);
|
|
2077
|
-
logLatency({
|
|
2078
|
-
type: "phase",
|
|
2079
|
-
phase: "lsp_server_spawned",
|
|
2080
|
-
filePath: root,
|
|
2081
|
-
durationMs: spawnDurationMs,
|
|
2082
|
-
metadata: {
|
|
2083
|
-
serverId: server.id,
|
|
2084
|
-
source: spawned.source ?? "unknown",
|
|
2085
|
-
launchVariant: spawned.launchVariant ?? "default",
|
|
2086
|
-
triggerFilePath: filePath
|
|
2087
|
-
}
|
|
2088
|
-
});
|
|
2089
|
-
if (!this.workspaceProbeLogged.has(key)) {
|
|
2090
|
-
logSessionStart(`lsp workspace-diag probe ${server.id}: advertised=${wsDiag.advertised} mode=${wsDiag.mode} provider=${wsDiag.diagnosticProviderKind}`);
|
|
2091
|
-
this.workspaceProbeLogged.add(key);
|
|
2092
|
-
}
|
|
2093
|
-
return { client, info: server };
|
|
2094
|
-
} catch (err) {
|
|
2095
|
-
recordLsp(server.id, root, "spawn_failed", Date.now() - startedAt);
|
|
2096
|
-
if (!isOptionalServer || !this.optionalFailureLogged.has(key)) {
|
|
2097
|
-
logSessionStart(`lsp spawn ${server.id}: failed (${Date.now() - startedAt}ms) error=${err instanceof Error ? err.message : String(err)}`);
|
|
2098
|
-
if (isOptionalServer) {
|
|
2099
|
-
this.optionalFailureLogged.add(key);
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
const eCount = (this.failureCounts.get(key) ?? 0) + 1;
|
|
2103
|
-
this.failureCounts.set(key, eCount);
|
|
2104
|
-
const eCooldown = isOptionalServer ? OPTIONAL_LSP_RETRY_COOLDOWN_MS : Math.min(BROKEN_BASE_COOLDOWN_MS * 2 ** (eCount - 1), BROKEN_MAX_COOLDOWN_MS);
|
|
2105
|
-
this.state.broken.set(key, Date.now() + eCooldown);
|
|
2106
|
-
if (!isOptionalServer && eCount >= BROKEN_PERMANENT_AFTER) {
|
|
2107
|
-
this.permanentlyBroken.add(key);
|
|
2108
|
-
this.recordBreaker(key, `permanently disabled after ${eCount} spawn/initialize failures`);
|
|
2109
|
-
logSessionStart(`lsp spawn ${server.id}: permanently disabled after ${eCount} failures`);
|
|
2110
|
-
}
|
|
2111
|
-
if (isOptionalServer) {
|
|
2112
|
-
this.optionalDisabled.add(key);
|
|
2113
|
-
}
|
|
2114
|
-
this.noteSpawnVerdict(key, "failed");
|
|
2115
|
-
return;
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
1762
|
async openFile(filePath, content, options) {
|
|
2119
1763
|
if (this.checkDestroyed())
|
|
2120
1764
|
return;
|
|
@@ -2220,6 +1864,8 @@ export class LSPService {
|
|
|
2220
1864
|
}
|
|
2221
1865
|
if (spawned.length === 0) {
|
|
2222
1866
|
const failureKind = this.isSpawnInFlight(filePath, resolvedPrimaryRoots) ? "spawn_in_flight_budget_elapsed" : "no_clients_none_spawning";
|
|
1867
|
+
const unanswered = diagnosticsMode === "none" ? undefined : unansweredPrimaries(spawned, resolvedPrimaryRoots, filePath);
|
|
1868
|
+
const disabledPrimaryServerIds = unanswered?.disabledServerIds ?? [];
|
|
2223
1869
|
logLatency({
|
|
2224
1870
|
type: "phase",
|
|
2225
1871
|
phase: "lsp_touch_file",
|
|
@@ -2234,12 +1880,30 @@ export class LSPService {
|
|
|
2234
1880
|
maxClientWaitMs: options.maxClientWaitMs,
|
|
2235
1881
|
failureKind,
|
|
2236
1882
|
...waitSkipReasons.size > 0 ? { reason: [...waitSkipReasons][0] } : {},
|
|
1883
|
+
...disabledPrimaryServerIds.length > 0 && {
|
|
1884
|
+
disabledPrimaryServerIds
|
|
1885
|
+
},
|
|
2237
1886
|
candidates: this.describeTouchCandidates(filePath, resolvedPrimaryRoots, attemptedAuxiliaryRoots)
|
|
2238
1887
|
}
|
|
2239
1888
|
});
|
|
1889
|
+
if (unanswered !== undefined && (disabledPrimaryServerIds.length > 0 || options.nameUnansweredPrimaries === true && unanswered.serverIds.length > 0)) {
|
|
1890
|
+
return {
|
|
1891
|
+
diags: [],
|
|
1892
|
+
...resolveTouchVerdict({
|
|
1893
|
+
unavailablePrimaryServerIds: unanswered.serverIds,
|
|
1894
|
+
disabledPrimaryServerIds,
|
|
1895
|
+
primaryUnavailableCause: unanswered.cause,
|
|
1896
|
+
primaryNotifyWriteTimedOutServerIds: [],
|
|
1897
|
+
diagnosticsTimedOut: false,
|
|
1898
|
+
diagnosticsUnansweredServerIds: []
|
|
1899
|
+
})
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
2240
1902
|
return;
|
|
2241
1903
|
}
|
|
2242
|
-
const
|
|
1904
|
+
const unanswered = unansweredPrimaries(spawned, resolvedPrimaryRoots, filePath);
|
|
1905
|
+
const unavailablePrimaryServerIds = unanswered.serverIds;
|
|
1906
|
+
const leaseKeys = await this.clientRegistry.acquireClientLeases(spawned, filePath);
|
|
2243
1907
|
if (!leaseKeys) {
|
|
2244
1908
|
if (this.checkDestroyed()) {
|
|
2245
1909
|
const primaryServerIds = spawned.filter((entry) => !isAuxiliary(entry.info)).map((entry) => entry.info.id);
|
|
@@ -2255,7 +1919,8 @@ export class LSPService {
|
|
|
2255
1919
|
return this.touchFile(filePath, content, options);
|
|
2256
1920
|
}
|
|
2257
1921
|
try {
|
|
2258
|
-
if (this.shouldSkipTouch(filePath,
|
|
1922
|
+
if (this.shouldSkipTouch(filePath, contentHash, diagnosticsMode !== "none", spawned)) {
|
|
1923
|
+
const savedServerIds = spawned.flatMap((entry) => this.saveDebouncedPush(filePath, entry, options.saved === true, contentHash) ?? []);
|
|
2259
1924
|
logLatency({
|
|
2260
1925
|
type: "phase",
|
|
2261
1926
|
phase: "lsp_touch_file",
|
|
@@ -2268,15 +1933,17 @@ export class LSPService {
|
|
|
2268
1933
|
source,
|
|
2269
1934
|
failureKind: "success",
|
|
2270
1935
|
skipped: true,
|
|
2271
|
-
reason: "debounced_unchanged_content"
|
|
1936
|
+
reason: "debounced_unchanged_content",
|
|
1937
|
+
...savedServerIds.length > 0 && { savedServerIds }
|
|
2272
1938
|
}
|
|
2273
1939
|
});
|
|
2274
1940
|
return { diags: [] };
|
|
2275
1941
|
}
|
|
2276
1942
|
const languageId = getLanguageId(filePath) ?? "plaintext";
|
|
2277
1943
|
const silent = options.silent ?? false;
|
|
2278
|
-
const notifySkippedServerIds = new Set(spawned.filter((entry) => this.shouldSkipNotify(filePath,
|
|
1944
|
+
const notifySkippedServerIds = new Set(spawned.filter((entry) => this.shouldSkipNotify(filePath, contentHash, entry.info.id, entry.client)).map((entry) => entry.info.id));
|
|
2279
1945
|
const notifySkipped = spawned.length > 0 && notifySkippedServerIds.size === spawned.length;
|
|
1946
|
+
const savedServerIds = spawned.flatMap((entry) => notifySkippedServerIds.has(entry.info.id) ? this.saveDebouncedPush(filePath, entry, options.saved === true, contentHash) ?? [] : []);
|
|
2280
1947
|
const readPathVersion = (client) => client.getDiagnosticsVersionForPath?.(filePath);
|
|
2281
1948
|
const diagnosticBaselines = new Map(spawned.map((entry) => [entry.client, readPathVersion(entry.client)]));
|
|
2282
1949
|
const markedAtMs = Date.now();
|
|
@@ -2299,6 +1966,7 @@ export class LSPService {
|
|
|
2299
1966
|
return false;
|
|
2300
1967
|
return auxPublishedThisContent.has(serverId) || bindingMatchesTouchContent(entry.client.getDiagnosticBinding?.(filePath));
|
|
2301
1968
|
};
|
|
1969
|
+
const auxPublishedCount = (client, published) => published ? client.getDiagnostics?.(filePath)?.length ?? 0 : 0;
|
|
2302
1970
|
const notifyWriteTimedOutServerIds = [];
|
|
2303
1971
|
const notifyDeferredServerIds = [];
|
|
2304
1972
|
const supersededServerIds = [];
|
|
@@ -2343,7 +2011,7 @@ export class LSPService {
|
|
|
2343
2011
|
let rejected = false;
|
|
2344
2012
|
try {
|
|
2345
2013
|
const writeStartedAt = Date.now();
|
|
2346
|
-
const writePromise = entry.client.notify.open(filePath, content, languageId, undefined, silent, options.saved === true, options.readStamp).then((sent) => sent !== false);
|
|
2014
|
+
const writePromise = entry.client.notify.open(filePath, content, languageId, undefined, silent, options.saved === true, options.readStamp, contentHash).then((sent) => sent !== false);
|
|
2347
2015
|
if (gated && clientKey) {
|
|
2348
2016
|
this.noteAuxNotifyIssued(clientKey, entry.client);
|
|
2349
2017
|
}
|
|
@@ -2370,7 +2038,7 @@ export class LSPService {
|
|
|
2370
2038
|
if (wrote === true) {
|
|
2371
2039
|
if (clientKey)
|
|
2372
2040
|
this.notifyWriteBackpressureStreak.delete(clientKey);
|
|
2373
|
-
this.markTouched(filePath,
|
|
2041
|
+
this.markTouched(filePath, entry.info.id, entry.client);
|
|
2374
2042
|
} else if (wrote === false) {
|
|
2375
2043
|
supersededServerIds.push(entry.info.id);
|
|
2376
2044
|
} else {
|
|
@@ -2646,14 +2314,16 @@ export class LSPService {
|
|
|
2646
2314
|
const outcomes = await Promise.all(auxWaits.map(async (aux) => {
|
|
2647
2315
|
const { budgetMs } = aux;
|
|
2648
2316
|
if (aux.demoted) {
|
|
2317
|
+
const demotedPublished = auxiliaryPublicationEvidence({
|
|
2318
|
+
bindingMatchesContent: auxCoversThisContent(aux.serverId),
|
|
2319
|
+
baseline: aux.baseline,
|
|
2320
|
+
currentPathVersion: readPathVersion(aux.client)
|
|
2321
|
+
});
|
|
2649
2322
|
return {
|
|
2650
2323
|
serverId: aux.serverId,
|
|
2651
2324
|
outcome: deferredResyncServerIds.has(aux.serverId) ? "deferred" : "demoted",
|
|
2652
|
-
publishedThisContent:
|
|
2653
|
-
|
|
2654
|
-
baseline: aux.baseline,
|
|
2655
|
-
currentPathVersion: readPathVersion(aux.client)
|
|
2656
|
-
}),
|
|
2325
|
+
publishedThisContent: demotedPublished,
|
|
2326
|
+
publishedCount: auxPublishedCount(aux.client, demotedPublished),
|
|
2657
2327
|
budgetMs,
|
|
2658
2328
|
elapsedMs: 0,
|
|
2659
2329
|
elapsedSinceNotifyMs: 0
|
|
@@ -2688,6 +2358,7 @@ export class LSPService {
|
|
|
2688
2358
|
serverId: aux.serverId,
|
|
2689
2359
|
outcome,
|
|
2690
2360
|
publishedThisContent: auxCoversThisContent(aux.serverId),
|
|
2361
|
+
publishedCount: auxPublishedCount(aux.client, publishedEvidence || auxCoversThisContent(aux.serverId)),
|
|
2691
2362
|
budgetMs,
|
|
2692
2363
|
elapsedMs,
|
|
2693
2364
|
elapsedSinceNotifyMs: Date.now() - waitStartedAt
|
|
@@ -2790,6 +2461,7 @@ export class LSPService {
|
|
|
2790
2461
|
serverId: entry.info.id,
|
|
2791
2462
|
outcome: deferredResyncServerIds.has(entry.info.id) ? "deferred" : publishedEvidence ? "answered" : "silent",
|
|
2792
2463
|
publishedThisContent: auxCoversThisContent(entry.info.id),
|
|
2464
|
+
publishedCount: auxPublishedCount(entry.client, publishedEvidence || auxCoversThisContent(entry.info.id)),
|
|
2793
2465
|
budgetMs: timeoutFor(entry.client.serverId),
|
|
2794
2466
|
elapsedMs: waitedMs,
|
|
2795
2467
|
elapsedSinceNotifyMs: waitedMs
|
|
@@ -2949,28 +2621,39 @@ export class LSPService {
|
|
|
2949
2621
|
} catch {}
|
|
2950
2622
|
}
|
|
2951
2623
|
const verdict = resolveTouchVerdict({
|
|
2624
|
+
unavailablePrimaryServerIds,
|
|
2625
|
+
disabledPrimaryServerIds: unanswered.disabledServerIds,
|
|
2626
|
+
primaryUnavailableCause: unanswered.cause,
|
|
2952
2627
|
primaryNotifyWriteTimedOutServerIds,
|
|
2953
2628
|
diagnosticsTimedOut,
|
|
2954
2629
|
diagnosticsUnansweredServerIds: diagnosticsUnansweredPrimaryServerIds
|
|
2955
2630
|
});
|
|
2956
2631
|
const inconclusive = verdict.inconclusive;
|
|
2957
|
-
const
|
|
2632
|
+
const skippedAuxiliaries = collected !== undefined ? await this.skippedAuxiliaryServerIds(filePath, clientScope, options, spawned) : { brokenSkippedServerIds: [], policySkippedServerIds: [] };
|
|
2633
|
+
const brokenSkippedServerIds = skippedAuxiliaries.brokenSkippedServerIds;
|
|
2634
|
+
const policySkippedServerIds = skippedAuxiliaries.policySkippedServerIds;
|
|
2958
2635
|
const auxNoAnswerServerIds = spawned.filter((entry) => isAuxiliary(entry.info) && (diagnosticsUnansweredServerIds.includes(entry.info.id) || notifyWriteTimedOutServerIds.includes(entry.info.id)) && !auxCoveredAtMerge.has(entry.info.id)).map((entry) => entry.info.id);
|
|
2959
2636
|
const unconfirmedServerIds = [
|
|
2960
2637
|
...new Set([
|
|
2961
2638
|
...auxUnconfirmedServerIds ?? [],
|
|
2962
2639
|
...auxNoAnswerServerIds,
|
|
2963
2640
|
...uncoveredDeferredServerIds,
|
|
2964
|
-
...brokenSkippedServerIds
|
|
2641
|
+
...brokenSkippedServerIds,
|
|
2642
|
+
...policySkippedServerIds
|
|
2965
2643
|
])
|
|
2966
2644
|
].filter((serverId) => !auxCoveredAtMerge.has(serverId));
|
|
2967
2645
|
const coverageGap = unconfirmedServerIds.length > 0;
|
|
2968
|
-
if (brokenSkippedServerIds.length > 0 || uncoveredDeferredServerIds.length > 0 || auxNoAnswerServerIds.length > 0) {
|
|
2646
|
+
if (brokenSkippedServerIds.length > 0 || policySkippedServerIds.length > 0 || uncoveredDeferredServerIds.length > 0 || auxNoAnswerServerIds.length > 0) {
|
|
2647
|
+
const configFailureSuffix = (serverId) => {
|
|
2648
|
+
const failure = spawned.find((entry) => entry.info.id === serverId)?.client.getConfigLoadFailure?.();
|
|
2649
|
+
return failure ? ` (server reported: ${failure})` : "";
|
|
2650
|
+
};
|
|
2969
2651
|
for (const serverId of unconfirmedServerIds) {
|
|
2970
2652
|
const reasons = [
|
|
2971
2653
|
brokenSkippedServerIds.includes(serverId) && "breaker skip",
|
|
2654
|
+
policySkippedServerIds.includes(serverId) && "root policy skip",
|
|
2972
2655
|
uncoveredDeferredServerIds.includes(serverId) && "deferred resync",
|
|
2973
|
-
auxNoAnswerServerIds.includes(serverId) &&
|
|
2656
|
+
auxNoAnswerServerIds.includes(serverId) && `no diagnostics answer${configFailureSuffix(serverId)}`
|
|
2974
2657
|
].filter(Boolean);
|
|
2975
2658
|
incrementDegradationCount({
|
|
2976
2659
|
kind: "lsp-scanner-coverage-gap",
|
|
@@ -2987,6 +2670,9 @@ export class LSPService {
|
|
|
2987
2670
|
...brokenSkippedServerIds.length > 0 && {
|
|
2988
2671
|
brokenSkippedServerIds
|
|
2989
2672
|
},
|
|
2673
|
+
...policySkippedServerIds.length > 0 && {
|
|
2674
|
+
policySkippedServerIds
|
|
2675
|
+
},
|
|
2990
2676
|
...uncoveredDeferredServerIds.length > 0 && {
|
|
2991
2677
|
deferredResyncServerIds: uncoveredDeferredServerIds
|
|
2992
2678
|
},
|
|
@@ -3028,6 +2714,12 @@ export class LSPService {
|
|
|
3028
2714
|
result.inconclusiveServerIds = verdict.inconclusiveServerIds;
|
|
3029
2715
|
}
|
|
3030
2716
|
result.inconclusiveReason = verdict.inconclusiveReason;
|
|
2717
|
+
if (verdict.disabledPrimaryServerIds) {
|
|
2718
|
+
result.disabledPrimaryServerIds = verdict.disabledPrimaryServerIds;
|
|
2719
|
+
}
|
|
2720
|
+
if (verdict.primaryUnavailableCause) {
|
|
2721
|
+
result.primaryUnavailableCause = verdict.primaryUnavailableCause;
|
|
2722
|
+
}
|
|
3031
2723
|
} else if (collected !== undefined && primaryDiagnosticsUnsupported) {
|
|
3032
2724
|
if (unconfirmedServerIds.length > 0) {
|
|
3033
2725
|
result.unconfirmedServerIds = [...unconfirmedServerIds];
|
|
@@ -3074,6 +2766,7 @@ export class LSPService {
|
|
|
3074
2766
|
notifyWriteTimedOutServerIds
|
|
3075
2767
|
},
|
|
3076
2768
|
...supersededServerIds.length > 0 && { supersededServerIds },
|
|
2769
|
+
...savedServerIds.length > 0 && { savedServerIds },
|
|
3077
2770
|
diagnosticsTimedOut,
|
|
3078
2771
|
inconclusive,
|
|
3079
2772
|
...verdict.inconclusiveServerIds && {
|
|
@@ -3090,6 +2783,7 @@ export class LSPService {
|
|
|
3090
2783
|
auxUnconfirmedServerIds
|
|
3091
2784
|
},
|
|
3092
2785
|
...brokenSkippedServerIds.length > 0 && { brokenSkippedServerIds },
|
|
2786
|
+
...policySkippedServerIds.length > 0 && { policySkippedServerIds },
|
|
3093
2787
|
...uncoveredDeferredServerIds.length > 0 && {
|
|
3094
2788
|
deferredResyncServerIds: uncoveredDeferredServerIds
|
|
3095
2789
|
},
|
|
@@ -3102,13 +2796,13 @@ export class LSPService {
|
|
|
3102
2796
|
return result;
|
|
3103
2797
|
} finally {
|
|
3104
2798
|
for (const lease of leaseKeys)
|
|
3105
|
-
this.releaseClientLease(lease.key, lease.server);
|
|
2799
|
+
this.clientRegistry.releaseClientLease(lease.key, lease.server);
|
|
3106
2800
|
}
|
|
3107
2801
|
}
|
|
3108
2802
|
async findOutsideProjectRoot(filePath) {
|
|
3109
|
-
if (!this.fileIsOutsideRegisteredRoots(filePath))
|
|
2803
|
+
if (!this.clientRegistry.fileIsOutsideRegisteredRoots(filePath))
|
|
3110
2804
|
return;
|
|
3111
|
-
if (this.analysisRootModeForFile(filePath) === "adopted")
|
|
2805
|
+
if (this.clientRegistry.analysisRootModeForFile(filePath) === "adopted")
|
|
3112
2806
|
return;
|
|
3113
2807
|
const candidates = await Promise.all(getServersForFileWithConfig(filePath).map((server) => server.root(filePath)));
|
|
3114
2808
|
return candidates.find((candidate) => Boolean(candidate));
|
|
@@ -3144,7 +2838,7 @@ export class LSPService {
|
|
|
3144
2838
|
}
|
|
3145
2839
|
return this.lastKnownDiagnostics.get(normalizedKey);
|
|
3146
2840
|
}
|
|
3147
|
-
async getDiagnostics(filePath, diagnosticsMode = "full") {
|
|
2841
|
+
async getDiagnostics(filePath, diagnosticsMode = "full", excludeServerIds) {
|
|
3148
2842
|
const normalizedPath = normalizeMapKey(filePath);
|
|
3149
2843
|
const outsideRoot = await this.findOutsideProjectRoot(filePath);
|
|
3150
2844
|
if (outsideRoot) {
|
|
@@ -3165,11 +2859,15 @@ export class LSPService {
|
|
|
3165
2859
|
return [];
|
|
3166
2860
|
}
|
|
3167
2861
|
const startedAt = Date.now();
|
|
3168
|
-
const candidateServerIds = getServersForFileWithConfig(filePath).
|
|
3169
|
-
const
|
|
2862
|
+
const candidateServerIds = getServersForFileWithConfig(filePath).flatMap((s) => excludeServerIds?.has(s.id) ? [] : [s.id]);
|
|
2863
|
+
const resolvedPrimaryRoots = new Map;
|
|
2864
|
+
const { clients: spawned, serverCountAttempted } = await this.getClientsForFile(filePath, excludeServerIds, resolvedPrimaryRoots);
|
|
3170
2865
|
if (spawned.length === 0) {
|
|
3171
|
-
const
|
|
2866
|
+
const stored = this.lastKnownDiagnostics.get(normalizedPath);
|
|
2867
|
+
const stale = excludeServerIds !== undefined && excludeServerIds.size > 0 ? stored?.filter((diagnostic) => !excludeServerIds.has(diagnostic.serverId ?? "")) : stored;
|
|
3172
2868
|
const failureKind = stale?.length ? "no_clients_stale" : "no_clients";
|
|
2869
|
+
const unanswered = unansweredPrimaries(spawned, resolvedPrimaryRoots, filePath);
|
|
2870
|
+
const unavailablePrimaryServerIds = unanswered.serverIds;
|
|
3173
2871
|
this.lastDiagnosticsHealth.set(normalizedPath, {
|
|
3174
2872
|
health: failureKind,
|
|
3175
2873
|
failureKind,
|
|
@@ -3178,7 +2876,14 @@ export class LSPService {
|
|
|
3178
2876
|
candidateServerIds,
|
|
3179
2877
|
mergedCount: stale?.length ?? 0,
|
|
3180
2878
|
dedupDroppedCount: 0,
|
|
3181
|
-
checkedAt: new Date().toISOString()
|
|
2879
|
+
checkedAt: new Date().toISOString(),
|
|
2880
|
+
unavailablePrimaryServerIds,
|
|
2881
|
+
...unanswered.disabledServerIds.length > 0 && {
|
|
2882
|
+
disabledPrimaryServerIds: unanswered.disabledServerIds
|
|
2883
|
+
},
|
|
2884
|
+
...unavailablePrimaryServerIds.length > 0 && {
|
|
2885
|
+
primaryUnavailableCause: unanswered.cause
|
|
2886
|
+
}
|
|
3182
2887
|
});
|
|
3183
2888
|
logLatency({
|
|
3184
2889
|
type: "phase",
|
|
@@ -3192,7 +2897,10 @@ export class LSPService {
|
|
|
3192
2897
|
dedupDroppedCount: 0,
|
|
3193
2898
|
failureKind,
|
|
3194
2899
|
health: failureKind,
|
|
3195
|
-
servers: []
|
|
2900
|
+
servers: [],
|
|
2901
|
+
...unavailablePrimaryServerIds.length > 0 && {
|
|
2902
|
+
unavailablePrimaryServerIds
|
|
2903
|
+
}
|
|
3196
2904
|
}
|
|
3197
2905
|
});
|
|
3198
2906
|
return stale ?? [];
|
|
@@ -3258,6 +2966,8 @@ export class LSPService {
|
|
|
3258
2966
|
const rawCount = perServerFull.reduce((sum, entry) => sum + entry.diagnosticCount, 0);
|
|
3259
2967
|
const serversWithDiagnostics = perServerFull.filter((entry) => entry.diagnosticCount > 0).length;
|
|
3260
2968
|
const failureKind = merged.length === 0 ? "ok_empty" : "success";
|
|
2969
|
+
const unanswered = unansweredPrimaries(spawned, resolvedPrimaryRoots, filePath);
|
|
2970
|
+
const unavailablePrimaryServerIds = unanswered.serverIds;
|
|
3261
2971
|
this.lastDiagnosticsHealth.set(normalizedPath, {
|
|
3262
2972
|
health: failureKind === "success" ? "ok" : "ok_empty",
|
|
3263
2973
|
failureKind,
|
|
@@ -3266,7 +2976,14 @@ export class LSPService {
|
|
|
3266
2976
|
candidateServerIds,
|
|
3267
2977
|
mergedCount: merged.length,
|
|
3268
2978
|
dedupDroppedCount: rawCount - merged.length,
|
|
3269
|
-
checkedAt: new Date().toISOString()
|
|
2979
|
+
checkedAt: new Date().toISOString(),
|
|
2980
|
+
unavailablePrimaryServerIds,
|
|
2981
|
+
...unanswered.disabledServerIds.length > 0 && {
|
|
2982
|
+
disabledPrimaryServerIds: unanswered.disabledServerIds
|
|
2983
|
+
},
|
|
2984
|
+
...unavailablePrimaryServerIds.length > 0 && {
|
|
2985
|
+
primaryUnavailableCause: unanswered.cause
|
|
2986
|
+
}
|
|
3270
2987
|
});
|
|
3271
2988
|
logLatency({
|
|
3272
2989
|
type: "phase",
|
|
@@ -3287,7 +3004,10 @@ export class LSPService {
|
|
|
3287
3004
|
id: entry.serverId,
|
|
3288
3005
|
waitMs: entry.waitMs,
|
|
3289
3006
|
diagnosticCount: entry.diagnosticCount
|
|
3290
|
-
}))
|
|
3007
|
+
})),
|
|
3008
|
+
...unavailablePrimaryServerIds.length > 0 && {
|
|
3009
|
+
unavailablePrimaryServerIds
|
|
3010
|
+
}
|
|
3291
3011
|
}
|
|
3292
3012
|
});
|
|
3293
3013
|
if (merged.length > 0) {
|
|
@@ -3451,7 +3171,7 @@ export class LSPService {
|
|
|
3451
3171
|
return { executed: false, reason: "lsp service destroyed" };
|
|
3452
3172
|
}
|
|
3453
3173
|
for (const server of getServersForFileWithConfig(filePath)) {
|
|
3454
|
-
const root = await this.resolveServerRoot(server, filePath);
|
|
3174
|
+
const root = await this.clientRegistry.resolveServerRoot(server, filePath);
|
|
3455
3175
|
if (!root)
|
|
3456
3176
|
continue;
|
|
3457
3177
|
const entry = this.state.clients.get(`${server.id}:${normalizeMapKey(root)}`);
|
|
@@ -3506,7 +3226,7 @@ export class LSPService {
|
|
|
3506
3226
|
if (filePath) {
|
|
3507
3227
|
const servers = getServersForFileWithConfig(filePath);
|
|
3508
3228
|
for (const server of servers) {
|
|
3509
|
-
const root = await this.resolveServerRoot(server, filePath);
|
|
3229
|
+
const root = await this.clientRegistry.resolveServerRoot(server, filePath);
|
|
3510
3230
|
if (!root)
|
|
3511
3231
|
continue;
|
|
3512
3232
|
const client = this.state.clients.get(`${server.id}:${normalizeMapKey(root)}`);
|
|
@@ -3619,21 +3339,24 @@ export class LSPService {
|
|
|
3619
3339
|
});
|
|
3620
3340
|
return false;
|
|
3621
3341
|
});
|
|
3622
|
-
const
|
|
3342
|
+
const renameRequestedAtMs = Date.now();
|
|
3343
|
+
const willResults = await Promise.all(willRenameClients.map(async ({ clientKey, serverId, client }) => {
|
|
3623
3344
|
try {
|
|
3624
3345
|
return {
|
|
3346
|
+
clientKey,
|
|
3625
3347
|
serverId,
|
|
3626
|
-
edit: await client.willRenameFiles(oldFilePath, newFilePath)
|
|
3348
|
+
edit: await client.willRenameFiles(oldFilePath, newFilePath),
|
|
3349
|
+
failed: false
|
|
3627
3350
|
};
|
|
3628
3351
|
} catch (err) {
|
|
3629
3352
|
willRenameFailures.push({
|
|
3630
3353
|
serverId,
|
|
3631
3354
|
error: err instanceof Error ? err.message : String(err)
|
|
3632
3355
|
});
|
|
3633
|
-
return { serverId, edit: null };
|
|
3356
|
+
return { clientKey, serverId, edit: null, failed: true };
|
|
3634
3357
|
}
|
|
3635
3358
|
}));
|
|
3636
|
-
const successfulWillResults = willResults.filter((result) => !
|
|
3359
|
+
const successfulWillResults = willResults.filter((result) => !result.failed);
|
|
3637
3360
|
if (willRenameClients.length > 0 && successfulWillResults.length === 0) {
|
|
3638
3361
|
throw new Error(`workspace/willRenameFiles failed for all active LSP servers: ${willRenameFailures.map((failure) => `${failure.serverId}: ${failure.error}`).join("; ")}`);
|
|
3639
3362
|
}
|
|
@@ -3654,7 +3377,9 @@ export class LSPService {
|
|
|
3654
3377
|
try {
|
|
3655
3378
|
applied = await applyWorkspaceEdit(merged.edit, cwd, {
|
|
3656
3379
|
mutationContext: options.mutationContext,
|
|
3657
|
-
observe: false
|
|
3380
|
+
observe: false,
|
|
3381
|
+
watchedFileSink: this,
|
|
3382
|
+
expectedContent: captureRenameExpectedContent(merged.edit, cwd, renameRequestedAtMs, (filePath, atCwd, sourceClientKeys) => sourceClientKeys === undefined ? this.getTrackedContent(filePath, atCwd) : this.getTrackedContent(filePath, atCwd, sourceClientKeys), undefined, merged.sourceClientKeys)
|
|
3658
3383
|
});
|
|
3659
3384
|
} catch (err) {
|
|
3660
3385
|
if (options.mutationContext) {
|
|
@@ -3668,7 +3393,8 @@ export class LSPService {
|
|
|
3668
3393
|
}
|
|
3669
3394
|
throw err;
|
|
3670
3395
|
}
|
|
3671
|
-
const openDocuments = activeClients.filter(({ client }) => client.isDocumentOpen(oldFilePath)).map(({ serverId, client }) => ({
|
|
3396
|
+
const openDocuments = activeClients.filter(({ client }) => client.isDocumentOpen(oldFilePath)).map(({ clientKey, serverId, client }) => ({
|
|
3397
|
+
clientKey,
|
|
3672
3398
|
serverId,
|
|
3673
3399
|
client,
|
|
3674
3400
|
oldUri: client.getDocumentUri(oldFilePath)
|
|
@@ -3737,7 +3463,7 @@ export class LSPService {
|
|
|
3737
3463
|
newUri: pathToFileURL(newFilePath).href
|
|
3738
3464
|
}
|
|
3739
3465
|
]
|
|
3740
|
-
}, cwd, { observe: false });
|
|
3466
|
+
}, cwd, { observe: false, watchedFileSink: this });
|
|
3741
3467
|
} catch (err) {
|
|
3742
3468
|
if (options.mutationContext) {
|
|
3743
3469
|
recordLspMutation(options.mutationContext, {
|
|
@@ -3750,7 +3476,7 @@ export class LSPService {
|
|
|
3750
3476
|
const relOld = path.relative(cwd, oldFilePath).replace(/\\/g, "/") || path.basename(oldFilePath);
|
|
3751
3477
|
const relNew = path.relative(cwd, newFilePath).replace(/\\/g, "/") || path.basename(newFilePath);
|
|
3752
3478
|
const renameDescription = `Renamed ${relOld} → ${relNew}`;
|
|
3753
|
-
await Promise.all(activeClients.map(async ({ serverId, client }) => {
|
|
3479
|
+
await Promise.all(activeClients.map(async ({ clientKey, serverId, client }) => {
|
|
3754
3480
|
if (client.getOperationSupport().didRenameFiles !== true) {
|
|
3755
3481
|
recordDegradationOnce({
|
|
3756
3482
|
kind: "lsp-capability-skip",
|
|
@@ -3759,7 +3485,7 @@ export class LSPService {
|
|
|
3759
3485
|
});
|
|
3760
3486
|
return;
|
|
3761
3487
|
}
|
|
3762
|
-
const opened = openDocuments.find((entry) => entry.
|
|
3488
|
+
const opened = openDocuments.find((entry) => entry.clientKey === clientKey);
|
|
3763
3489
|
const result = await runRenameNotify(() => opened?.oldUri ? client.didRenameFiles(oldFilePath, newFilePath, opened.oldUri, destinationUriPreservingSpelling(opened.oldUri, oldFilePath, newFilePath)) : client.didRenameFiles(oldFilePath, newFilePath), RENAME_NOTIFY_TIMEOUT_MS);
|
|
3764
3490
|
if (!result.ok) {
|
|
3765
3491
|
didRenameFailures.push({
|
|
@@ -4071,6 +3797,7 @@ export class LSPService {
|
|
|
4071
3797
|
}));
|
|
4072
3798
|
return !capped;
|
|
4073
3799
|
};
|
|
3800
|
+
this.announceCreatedFiles([...files, ...goPackageFilesToAnnounce(files)], await importTargetsToAnnounce(root, files.filter((filePath) => !workspaceDiagnosticsCacheCtx.servesClean(filePath, workspaceSweepScopeKey)), (filePath, scope) => workspaceDiagnosticsCacheCtx.noteImportScope(filePath, scope)));
|
|
4074
3801
|
const cachedResults = [];
|
|
4075
3802
|
const filesToTouch = [];
|
|
4076
3803
|
const writeIndexByPath = new Map;
|
|
@@ -4205,7 +3932,13 @@ export class LSPService {
|
|
|
4205
3932
|
await this.ensureWarmForSweep(filePath, { signal });
|
|
4206
3933
|
}
|
|
4207
3934
|
const touchResult = attached?.available ? {
|
|
4208
|
-
diags: attached.response.diagnostics,
|
|
3935
|
+
diags: attached.response.projectIdentity === undefined ? attached.response.diagnostics : await demoteInferredProjectDiagnostics(attached.response.diagnostics, {
|
|
3936
|
+
filePath,
|
|
3937
|
+
cwd,
|
|
3938
|
+
identityCache: new Map([
|
|
3939
|
+
[filePath, attached.response.projectIdentity]
|
|
3940
|
+
])
|
|
3941
|
+
}),
|
|
4209
3942
|
...attached.response.unconfirmedServerIds !== undefined && {
|
|
4210
3943
|
unconfirmedServerIds: attached.response.unconfirmedServerIds
|
|
4211
3944
|
}
|
|
@@ -4225,7 +3958,7 @@ export class LSPService {
|
|
|
4225
3958
|
const timedOut = touchResult === undefined || inconclusive || declinedOutsideRoot;
|
|
4226
3959
|
if (timedOut)
|
|
4227
3960
|
timedOutFiles += 1;
|
|
4228
|
-
const unconfirmedReason = touchResult === undefined ? "budget" : declinedOutsideRoot ? "outside_project_root" : inconclusive ? "inconclusive" : undefined;
|
|
3961
|
+
const unconfirmedReason = touchResult === undefined ? "budget" : declinedOutsideRoot ? "outside_project_root" : inconclusive ? touchResult?.inconclusiveReason === "primary-unavailable" ? SWEEP_REASON_FOR_CAUSE[touchResult.primaryUnavailableCause ?? "unstarted"] : "inconclusive" : undefined;
|
|
4229
3962
|
const rawBinding = touchResult?.binding;
|
|
4230
3963
|
const filteredDiagnostics = diagnostics ? applyAuxiliarySuppressions(diagnostics, content, {
|
|
4231
3964
|
fileRole: detectFileRole(filePath, content),
|
|
@@ -4326,12 +4059,13 @@ export class LSPService {
|
|
|
4326
4059
|
}
|
|
4327
4060
|
});
|
|
4328
4061
|
for (const filePath of group.files) {
|
|
4062
|
+
const { disabledServerIds, fallbackServerIds } = disabledPrimaries(filePath);
|
|
4329
4063
|
results.push({
|
|
4330
4064
|
filePath,
|
|
4331
4065
|
diagnostics: [],
|
|
4332
4066
|
count: 0,
|
|
4333
4067
|
timedOut: true,
|
|
4334
|
-
unconfirmedReason:
|
|
4068
|
+
unconfirmedReason: SWEEP_REASON_FOR_CAUSE[primaryUnavailableCause([...warmup.failedServerIds, ...disabledServerIds], disabledServerIds, fallbackServerIds)],
|
|
4335
4069
|
skippedWarmupFailure: true
|
|
4336
4070
|
});
|
|
4337
4071
|
timedOutFiles += 1;
|
|
@@ -4478,7 +4212,7 @@ export class LSPService {
|
|
|
4478
4212
|
return;
|
|
4479
4213
|
}
|
|
4480
4214
|
}
|
|
4481
|
-
async getAllDiagnostics() {
|
|
4215
|
+
async getAllDiagnostics(excludeServerIds) {
|
|
4482
4216
|
const all = new Map;
|
|
4483
4217
|
const bindingsByPath = new Map;
|
|
4484
4218
|
const now = Date.now();
|
|
@@ -4493,6 +4227,8 @@ export class LSPService {
|
|
|
4493
4227
|
return true;
|
|
4494
4228
|
}));
|
|
4495
4229
|
client.pruneDiagnostics((filePath, ts) => !existingPaths.has(filePath) || now - ts > CASCADE_DIAGNOSTICS_TTL_MS);
|
|
4230
|
+
if (excludeServerIds?.has(client.serverId))
|
|
4231
|
+
continue;
|
|
4496
4232
|
const clientDiags = client.getAllDiagnostics();
|
|
4497
4233
|
for (const [filePath, entry] of clientDiags) {
|
|
4498
4234
|
const attributed = attributeDiagnostics(client.serverId, entry.diags);
|
|
@@ -4525,13 +4261,6 @@ export class LSPService {
|
|
|
4525
4261
|
supportsLSP(filePath) {
|
|
4526
4262
|
return getServersForFileWithConfig(filePath).length > 0;
|
|
4527
4263
|
}
|
|
4528
|
-
isSpawnInFlight(_filePath, resolvedRoots = new Map) {
|
|
4529
|
-
for (const [serverId, root] of resolvedRoots) {
|
|
4530
|
-
if (this.state.inFlight.has(`${serverId}:${root}`))
|
|
4531
|
-
return true;
|
|
4532
|
-
}
|
|
4533
|
-
return false;
|
|
4534
|
-
}
|
|
4535
4264
|
describeTouchCandidates(filePath, resolvedRoots, auxiliaryRoots = new Map) {
|
|
4536
4265
|
const candidates = [];
|
|
4537
4266
|
for (const server of getServersForFileWithConfig(filePath)) {
|
|
@@ -4564,28 +4293,12 @@ export class LSPService {
|
|
|
4564
4293
|
const resetStartedAt = Date.now();
|
|
4565
4294
|
if (this.checkDestroyed())
|
|
4566
4295
|
return;
|
|
4567
|
-
this.
|
|
4296
|
+
this.clientRegistry.markDestroyed();
|
|
4568
4297
|
this.shutdownController.abort();
|
|
4569
4298
|
for (const [key, token] of this.outstandingAuxNotifyWrites) {
|
|
4570
4299
|
this.releaseOutstandingAuxNotifyWrite(key, token);
|
|
4571
4300
|
}
|
|
4572
|
-
|
|
4573
|
-
this.clearIdleEvictionTimer(key);
|
|
4574
|
-
}
|
|
4575
|
-
if (!options.processExiting && this.state.inFlight.size > 0) {
|
|
4576
|
-
const pending = Array.from(this.state.inFlight.values());
|
|
4577
|
-
this.state.inFlight.clear();
|
|
4578
|
-
const settled = await Promise.allSettled(pending);
|
|
4579
|
-
for (const result of settled) {
|
|
4580
|
-
if (result.status === "fulfilled" && result.value?.client) {
|
|
4581
|
-
result.value.client.shutdown({ fast: true }).catch(() => {});
|
|
4582
|
-
}
|
|
4583
|
-
}
|
|
4584
|
-
} else {
|
|
4585
|
-
this.state.inFlight.clear();
|
|
4586
|
-
}
|
|
4587
|
-
const aliveClients = this.getAliveClientCount();
|
|
4588
|
-
await Promise.allSettled(Array.from(this.state.clients.values(), (client) => Promise.resolve().then(() => client.shutdown(options))));
|
|
4301
|
+
const aliveClients = await this.clientRegistry.shutdownClients(options);
|
|
4589
4302
|
logLatency({
|
|
4590
4303
|
type: "phase",
|
|
4591
4304
|
phase: "lsp_service_reset",
|
|
@@ -4599,10 +4312,8 @@ export class LSPService {
|
|
|
4599
4312
|
processExiting: !!options.processExiting
|
|
4600
4313
|
}
|
|
4601
4314
|
});
|
|
4602
|
-
this.
|
|
4603
|
-
this.state.broken.clear();
|
|
4315
|
+
this.clientRegistry.clearAfterShutdown();
|
|
4604
4316
|
this.firstContactWaits.clear();
|
|
4605
|
-
this.lastSpawnVerdict.clear();
|
|
4606
4317
|
for (const [key, token] of this.outstandingAuxNotifyWrites) {
|
|
4607
4318
|
this.releaseOutstandingAuxNotifyWrite(key, token);
|
|
4608
4319
|
}
|
|
@@ -4610,76 +4321,21 @@ export class LSPService {
|
|
|
4610
4321
|
this.auxNotifyDrainLatencyEwma.clear();
|
|
4611
4322
|
this.auxNotifyInflight.clear();
|
|
4612
4323
|
this.documentDrift.clear();
|
|
4613
|
-
this.workspaceProbeLogged.clear();
|
|
4614
|
-
this.warmStartLogged.clear();
|
|
4615
4324
|
}
|
|
4616
|
-
|
|
4617
|
-
return
|
|
4618
|
-
const [serverId, root] = key.split(":");
|
|
4619
|
-
return {
|
|
4620
|
-
serverId,
|
|
4621
|
-
root,
|
|
4622
|
-
connected: client.isAlive(),
|
|
4623
|
-
pullFailureHistory: (client.getPullFailureHistory?.() ?? []).map((entry) => ({
|
|
4624
|
-
...entry,
|
|
4625
|
-
message: entry.message.slice(0, 200)
|
|
4626
|
-
}))
|
|
4627
|
-
};
|
|
4628
|
-
});
|
|
4325
|
+
isSpawnInFlight(filePath, resolvedRoots) {
|
|
4326
|
+
return this.clientRegistry.isSpawnInFlight(filePath, resolvedRoots);
|
|
4629
4327
|
}
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
return false;
|
|
4633
|
-
}
|
|
4634
|
-
const deaths = this.runtimeExitWindow.get(key) ?? [];
|
|
4635
|
-
deaths.push(exitedAt);
|
|
4636
|
-
const windowRef = Math.max(...deaths);
|
|
4637
|
-
const windowStart = windowRef - RUNTIME_EXIT_WINDOW_MS;
|
|
4638
|
-
let pruned = deaths.filter((t) => t >= windowStart);
|
|
4639
|
-
if (pruned.length > RUNTIME_EXIT_WINDOW_TRIP_COUNT) {
|
|
4640
|
-
pruned = pruned.slice(pruned.length - RUNTIME_EXIT_WINDOW_TRIP_COUNT);
|
|
4641
|
-
}
|
|
4642
|
-
this.runtimeExitWindow.set(key, pruned);
|
|
4643
|
-
return pruned.length >= RUNTIME_EXIT_WINDOW_TRIP_COUNT;
|
|
4328
|
+
getStatus() {
|
|
4329
|
+
return this.clientRegistry.getStatus();
|
|
4644
4330
|
}
|
|
4645
4331
|
getBrokenStatus() {
|
|
4646
|
-
|
|
4647
|
-
...this.state.broken.keys(),
|
|
4648
|
-
...this.permanentlyBroken
|
|
4649
|
-
]);
|
|
4650
|
-
return [...keys].map((key) => {
|
|
4651
|
-
const separator = key.indexOf(":");
|
|
4652
|
-
return {
|
|
4653
|
-
serverId: separator >= 0 ? key.slice(0, separator) : key,
|
|
4654
|
-
root: separator >= 0 ? key.slice(separator + 1) : "",
|
|
4655
|
-
failures: (this.failureCounts.get(key) ?? 0) + Math.max(this.runtimeExitCounts.get(key) ?? 0, this.runtimeExitWindow.get(key)?.length ?? 0),
|
|
4656
|
-
permanentlyBroken: this.permanentlyBroken.has(key),
|
|
4657
|
-
cooldownUntil: this.state.broken.get(key) ?? 0
|
|
4658
|
-
};
|
|
4659
|
-
});
|
|
4332
|
+
return this.clientRegistry.getBrokenStatus();
|
|
4660
4333
|
}
|
|
4661
4334
|
getAliveClientCount() {
|
|
4662
|
-
|
|
4663
|
-
for (const client of this.state.clients.values()) {
|
|
4664
|
-
if (client.isAlive())
|
|
4665
|
-
count++;
|
|
4666
|
-
}
|
|
4667
|
-
return count;
|
|
4335
|
+
return this.clientRegistry.getAliveClientCount();
|
|
4668
4336
|
}
|
|
4669
4337
|
getAliveServerIds() {
|
|
4670
|
-
|
|
4671
|
-
const aux = [];
|
|
4672
|
-
const seen = new Set;
|
|
4673
|
-
for (const client of this.state.clients.values()) {
|
|
4674
|
-
if (!client.isAlive())
|
|
4675
|
-
continue;
|
|
4676
|
-
const id = client.serverId;
|
|
4677
|
-
if (seen.has(id))
|
|
4678
|
-
continue;
|
|
4679
|
-
seen.add(id);
|
|
4680
|
-
(isAuxiliary(getServerById(id)) ? aux : primary).push(id);
|
|
4681
|
-
}
|
|
4682
|
-
return [...primary, ...aux];
|
|
4338
|
+
return this.clientRegistry.getAliveServerIds();
|
|
4683
4339
|
}
|
|
4684
4340
|
}
|
|
4685
4341
|
configureLspServiceLifecycle({
|
|
@@ -4713,6 +4369,8 @@ export function resetLSPService(options = {}) {
|
|
|
4713
4369
|
resetClassicTsRepairGuard();
|
|
4714
4370
|
clearWorkspaceSweepHoldForSessionStart();
|
|
4715
4371
|
}
|
|
4372
|
+
if (options.reason === "session_shutdown")
|
|
4373
|
+
emitCreatedImportScanRollupAtSessionEnd();
|
|
4716
4374
|
resetOwnedLspService(options);
|
|
4717
4375
|
}
|
|
4718
4376
|
export function __collectWorkspaceDiagnosticFilesForTest(root, maxFiles, signal, homeDir) {
|