@duckmind/dm-linux-x64 0.66.0 → 0.66.2
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/dm +2 -2
- package/extensions/.dm-extensions.json +12 -546
- package/extensions/dm-lens/clients/dispatch/runners/utils/runner-helpers.js +1 -1
- package/extensions/dm-mcp-adapter/mcp-keyring-helper.cjs +1 -1
- package/extensions/dm-ponytail/hooks/ponytail-activate.js +1 -1
- package/extensions/dm-ponytail/hooks/ponytail-instructions.js +1 -1
- package/extensions/dm-subagents/src/runs/background/runner-aliases.js +2 -2
- package/extensions/dm-subagents/src/runs/foreground/prompt-audit.js +4 -1
- package/extensions/dm-subagents/src/runs/shared/child-session.js +8 -6
- package/extensions/dm-subagents/src/watchdog/permission-arbiter.js +9 -1
- package/extensions/dm-subagents/src/watchdog/review.js +4 -1
- package/package.json +1 -1
- package/extensions/dm-lens/dist/clients/actionable-warnings-logger.js +0 -24
- package/extensions/dm-lens/dist/clients/actionable-warnings.js +0 -1014
- package/extensions/dm-lens/dist/clients/advisory-provenance.js +0 -385
- package/extensions/dm-lens/dist/clients/agent-behavior-client.js +0 -94
- package/extensions/dm-lens/dist/clients/agent-nudge.js +0 -151
- package/extensions/dm-lens/dist/clients/analysed-root.js +0 -1
- package/extensions/dm-lens/dist/clients/ast-grep-client.js +0 -576
- package/extensions/dm-lens/dist/clients/ast-grep-rule-manager.js +0 -114
- package/extensions/dm-lens/dist/clients/ast-grep-tool-logger.js +0 -85
- package/extensions/dm-lens/dist/clients/ast-grep-types.js +0 -1
- package/extensions/dm-lens/dist/clients/ast-grep-yaml-synth.js +0 -109
- package/extensions/dm-lens/dist/clients/atomic-write-staging.js +0 -66
- package/extensions/dm-lens/dist/clients/atomic-write.js +0 -37
- package/extensions/dm-lens/dist/clients/availability-probe-flight.js +0 -11
- package/extensions/dm-lens/dist/clients/bash-file-access.js +0 -830
- package/extensions/dm-lens/dist/clients/biome-client.js +0 -221
- package/extensions/dm-lens/dist/clients/blocker-freshness.js +0 -385
- package/extensions/dm-lens/dist/clients/blocker-past-eof.js +0 -49
- package/extensions/dm-lens/dist/clients/bootstrap.js +0 -246
- package/extensions/dm-lens/dist/clients/bounded-cache.js +0 -105
- package/extensions/dm-lens/dist/clients/bounded-pid-file-lock.js +0 -173
- package/extensions/dm-lens/dist/clients/bounded-telemetry.js +0 -104
- package/extensions/dm-lens/dist/clients/build-identity.js +0 -45
- package/extensions/dm-lens/dist/clients/bundled-resource-health.js +0 -41
- package/extensions/dm-lens/dist/clients/bus-events-logger.js +0 -48
- package/extensions/dm-lens/dist/clients/bus-publish.js +0 -117
- package/extensions/dm-lens/dist/clients/cache/rule-cache.js +0 -103
- package/extensions/dm-lens/dist/clients/cache-manager.js +0 -340
- package/extensions/dm-lens/dist/clients/cache-observability.js +0 -847
- package/extensions/dm-lens/dist/clients/call-graph.js +0 -628
- package/extensions/dm-lens/dist/clients/cargo-manifest.js +0 -151
- package/extensions/dm-lens/dist/clients/cascade-budget.js +0 -52
- package/extensions/dm-lens/dist/clients/cascade-format.js +0 -160
- package/extensions/dm-lens/dist/clients/cascade-logger.js +0 -22
- package/extensions/dm-lens/dist/clients/cascade-types.js +0 -1
- package/extensions/dm-lens/dist/clients/child-unref.js +0 -59
- package/extensions/dm-lens/dist/clients/code-quality-warnings.js +0 -192
- package/extensions/dm-lens/dist/clients/codebase-model.js +0 -110
- package/extensions/dm-lens/dist/clients/collateral-test-role.js +0 -8
- package/extensions/dm-lens/dist/clients/complexity-client.js +0 -398
- package/extensions/dm-lens/dist/clients/config-core/deny.js +0 -117
- package/extensions/dm-lens/dist/clients/config-core/index.js +0 -2
- package/extensions/dm-lens/dist/clients/config-core/merge.js +0 -228
- package/extensions/dm-lens/dist/clients/config-core/normalize.js +0 -217
- package/extensions/dm-lens/dist/clients/config-core/process-spec.js +0 -147
- package/extensions/dm-lens/dist/clients/config-core/provenance.js +0 -54
- package/extensions/dm-lens/dist/clients/config-core/records.js +0 -79
- package/extensions/dm-lens/dist/clients/config-core/resolve.js +0 -48
- package/extensions/dm-lens/dist/clients/config-core/safe-object.js +0 -22
- package/extensions/dm-lens/dist/clients/config-core/schema.js +0 -90
- package/extensions/dm-lens/dist/clients/config-diagnostic-codes.js +0 -90
- package/extensions/dm-lens/dist/clients/config-locations.js +0 -175
- package/extensions/dm-lens/dist/clients/config-resolve.js +0 -359
- package/extensions/dm-lens/dist/clients/config-schema.js +0 -128
- package/extensions/dm-lens/dist/clients/config-warn.js +0 -146
- package/extensions/dm-lens/dist/clients/console-guard-install.js +0 -4
- package/extensions/dm-lens/dist/clients/cooperative-budget.js +0 -36
- package/extensions/dm-lens/dist/clients/dead-code-client.js +0 -342
- package/extensions/dm-lens/dist/clients/dead-code-logger.js +0 -18
- package/extensions/dm-lens/dist/clients/deadline-utils.js +0 -117
- package/extensions/dm-lens/dist/clients/debug-handles.js +0 -121
- package/extensions/dm-lens/dist/clients/debug-heap.js +0 -80
- package/extensions/dm-lens/dist/clients/deferred-lsp-work.js +0 -33
- package/extensions/dm-lens/dist/clients/degradation-ledger.js +0 -272
- package/extensions/dm-lens/dist/clients/demoted-finding-render.js +0 -61
- package/extensions/dm-lens/dist/clients/dependency-checker.js +0 -525
- package/extensions/dm-lens/dist/clients/deps/ast-grep-napi.js +0 -17
- package/extensions/dm-lens/dist/clients/deps/dm-host-deps.js +0 -10
- package/extensions/dm-lens/dist/clients/deps/dm-tui-compat.js +0 -58
- package/extensions/dm-lens/dist/clients/deps/js-yaml.js +0 -7
- package/extensions/dm-lens/dist/clients/deps/minimatch.js +0 -6
- package/extensions/dm-lens/dist/clients/deps/pidusage.js +0 -5
- package/extensions/dm-lens/dist/clients/deps/typebox.js +0 -5
- package/extensions/dm-lens/dist/clients/deps/vscode-jsonrpc.js +0 -8
- package/extensions/dm-lens/dist/clients/deps/web-tree-sitter.js +0 -11
- package/extensions/dm-lens/dist/clients/diagnostic-dispositions.js +0 -318
- package/extensions/dm-lens/dist/clients/diagnostic-line-freshness.js +0 -144
- package/extensions/dm-lens/dist/clients/diagnostic-logger.js +0 -60
- package/extensions/dm-lens/dist/clients/diagnostic-tracker.js +0 -89
- package/extensions/dm-lens/dist/clients/diagnostics-publish.js +0 -134
- package/extensions/dm-lens/dist/clients/dispatch/ast-grep-catalog.js +0 -16
- package/extensions/dm-lens/dist/clients/dispatch/auxiliary-lsp.js +0 -158
- package/extensions/dm-lens/dist/clients/dispatch/collect-later-tier.js +0 -25
- package/extensions/dm-lens/dist/clients/dispatch/diagnostic-taxonomy.js +0 -58
- package/extensions/dm-lens/dist/clients/dispatch/dispatcher.js +0 -953
- package/extensions/dm-lens/dist/clients/dispatch/fact-provider-types.js +0 -1
- package/extensions/dm-lens/dist/clients/dispatch/fact-rule-runner.js +0 -17
- package/extensions/dm-lens/dist/clients/dispatch/fact-runner.js +0 -18
- package/extensions/dm-lens/dist/clients/dispatch/fact-scheduler.js +0 -52
- package/extensions/dm-lens/dist/clients/dispatch/fact-store.js +0 -199
- package/extensions/dm-lens/dist/clients/dispatch/facts/comment-facts.js +0 -20
- package/extensions/dm-lens/dist/clients/dispatch/facts/file-content.js +0 -18
- package/extensions/dm-lens/dist/clients/dispatch/facts/function-facts.js +0 -281
- package/extensions/dm-lens/dist/clients/dispatch/facts/import-facts.js +0 -169
- package/extensions/dm-lens/dist/clients/dispatch/facts/tree-sitter-facts.js +0 -19
- package/extensions/dm-lens/dist/clients/dispatch/facts/try-catch-facts.js +0 -95
- package/extensions/dm-lens/dist/clients/dispatch/finding-policy.js +0 -159
- package/extensions/dm-lens/dist/clients/dispatch/indent-detect.js +0 -227
- package/extensions/dm-lens/dist/clients/dispatch/inline-suppressions.js +0 -52
- package/extensions/dm-lens/dist/clients/dispatch/integration.js +0 -1463
- package/extensions/dm-lens/dist/clients/dispatch/lazy.js +0 -8
- package/extensions/dm-lens/dist/clients/dispatch/pending-runner-findings.js +0 -75
- package/extensions/dm-lens/dist/clients/dispatch/plan.js +0 -278
- package/extensions/dm-lens/dist/clients/dispatch/priorities.js +0 -14
- package/extensions/dm-lens/dist/clients/dispatch/rule-id-normalize.js +0 -42
- package/extensions/dm-lens/dist/clients/dispatch/rule-ignores.js +0 -21
- package/extensions/dm-lens/dist/clients/dispatch/rule-policy.js +0 -73
- package/extensions/dm-lens/dist/clients/dispatch/rules/async-noise.js +0 -31
- package/extensions/dm-lens/dist/clients/dispatch/rules/async-unnecessary-wrapper.js +0 -27
- package/extensions/dm-lens/dist/clients/dispatch/rules/cors-wildcard.js +0 -35
- package/extensions/dm-lens/dist/clients/dispatch/rules/error-obscuring.js +0 -29
- package/extensions/dm-lens/dist/clients/dispatch/rules/error-swallowing.js +0 -29
- package/extensions/dm-lens/dist/clients/dispatch/rules/framework-call-noise.js +0 -31
- package/extensions/dm-lens/dist/clients/dispatch/rules/high-complexity.js +0 -56
- package/extensions/dm-lens/dist/clients/dispatch/rules/high-fan-out.js +0 -45
- package/extensions/dm-lens/dist/clients/dispatch/rules/high-import-coupling.js +0 -31
- package/extensions/dm-lens/dist/clients/dispatch/rules/missing-error-propagation.js +0 -45
- package/extensions/dm-lens/dist/clients/dispatch/rules/no-commented-credentials.js +0 -46
- package/extensions/dm-lens/dist/clients/dispatch/rules/pass-through-wrappers.js +0 -38
- package/extensions/dm-lens/dist/clients/dispatch/rules/placeholder-comments.js +0 -40
- package/extensions/dm-lens/dist/clients/dispatch/rules/unsafe-boundary.js +0 -101
- package/extensions/dm-lens/dist/clients/dispatch/runner-context.js +0 -46
- package/extensions/dm-lens/dist/clients/dispatch/runners/actionlint.js +0 -98
- package/extensions/dm-lens/dist/clients/dispatch/runners/ast-grep-napi.js +0 -690
- package/extensions/dm-lens/dist/clients/dispatch/runners/biome-check.js +0 -202
- package/extensions/dm-lens/dist/clients/dispatch/runners/cpp-check.js +0 -190
- package/extensions/dm-lens/dist/clients/dispatch/runners/credo.js +0 -66
- package/extensions/dm-lens/dist/clients/dispatch/runners/cue-vet.js +0 -167
- package/extensions/dm-lens/dist/clients/dispatch/runners/dart-analyze.js +0 -151
- package/extensions/dm-lens/dist/clients/dispatch/runners/detekt.js +0 -157
- package/extensions/dm-lens/dist/clients/dispatch/runners/dotnet-build.js +0 -157
- package/extensions/dm-lens/dist/clients/dispatch/runners/elixir-check.js +0 -153
- package/extensions/dm-lens/dist/clients/dispatch/runners/eslint.js +0 -99
- package/extensions/dm-lens/dist/clients/dispatch/runners/fact-rules.js +0 -20
- package/extensions/dm-lens/dist/clients/dispatch/runners/fish-indent.js +0 -65
- package/extensions/dm-lens/dist/clients/dispatch/runners/gleam-check.js +0 -107
- package/extensions/dm-lens/dist/clients/dispatch/runners/go-vet.js +0 -51
- package/extensions/dm-lens/dist/clients/dispatch/runners/golangci-lint.js +0 -89
- package/extensions/dm-lens/dist/clients/dispatch/runners/hadolint.js +0 -83
- package/extensions/dm-lens/dist/clients/dispatch/runners/helm-lint.js +0 -144
- package/extensions/dm-lens/dist/clients/dispatch/runners/helm-render.js +0 -593
- package/extensions/dm-lens/dist/clients/dispatch/runners/htmlhint.js +0 -103
- package/extensions/dm-lens/dist/clients/dispatch/runners/index.js +0 -100
- package/extensions/dm-lens/dist/clients/dispatch/runners/javac.js +0 -82
- package/extensions/dm-lens/dist/clients/dispatch/runners/ktlint.js +0 -93
- package/extensions/dm-lens/dist/clients/dispatch/runners/lsp.js +0 -206
- package/extensions/dm-lens/dist/clients/dispatch/runners/markdownlint.js +0 -129
- package/extensions/dm-lens/dist/clients/dispatch/runners/mypy.js +0 -70
- package/extensions/dm-lens/dist/clients/dispatch/runners/oxlint.js +0 -305
- package/extensions/dm-lens/dist/clients/dispatch/runners/php-lint.js +0 -70
- package/extensions/dm-lens/dist/clients/dispatch/runners/phpstan.js +0 -90
- package/extensions/dm-lens/dist/clients/dispatch/runners/prisma-validate.js +0 -56
- package/extensions/dm-lens/dist/clients/dispatch/runners/psscriptanalyzer.js +0 -307
- package/extensions/dm-lens/dist/clients/dispatch/runners/pyright.js +0 -118
- package/extensions/dm-lens/dist/clients/dispatch/runners/rubocop.js +0 -79
- package/extensions/dm-lens/dist/clients/dispatch/runners/ruff.js +0 -69
- package/extensions/dm-lens/dist/clients/dispatch/runners/rust-clippy.js +0 -147
- package/extensions/dm-lens/dist/clients/dispatch/runners/shellcheck.js +0 -111
- package/extensions/dm-lens/dist/clients/dispatch/runners/shfmt.js +0 -81
- package/extensions/dm-lens/dist/clients/dispatch/runners/spellcheck.js +0 -74
- package/extensions/dm-lens/dist/clients/dispatch/runners/spotbugs.js +0 -208
- package/extensions/dm-lens/dist/clients/dispatch/runners/sqlfluff.js +0 -136
- package/extensions/dm-lens/dist/clients/dispatch/runners/stylelint.js +0 -118
- package/extensions/dm-lens/dist/clients/dispatch/runners/swiftlint.js +0 -143
- package/extensions/dm-lens/dist/clients/dispatch/runners/taplo.js +0 -97
- package/extensions/dm-lens/dist/clients/dispatch/runners/terragrunt.js +0 -110
- package/extensions/dm-lens/dist/clients/dispatch/runners/tflint.js +0 -104
- package/extensions/dm-lens/dist/clients/dispatch/runners/tree-sitter.js +0 -516
- package/extensions/dm-lens/dist/clients/dispatch/runners/trivy-config.js +0 -155
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/availability-policy.js +0 -285
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/candidate-probe.js +0 -61
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -61
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/lazy-installer.js +0 -130
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +0 -1067
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/spawn-outcome.js +0 -40
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/tool-failure.js +0 -117
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/toolchain-availability.js +0 -88
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils.js +0 -8
- package/extensions/dm-lens/dist/clients/dispatch/runners/vale.js +0 -106
- package/extensions/dm-lens/dist/clients/dispatch/runners/yaml-rule-parser.js +0 -163
- package/extensions/dm-lens/dist/clients/dispatch/runners/yamllint.js +0 -83
- package/extensions/dm-lens/dist/clients/dispatch/runners/zig-check.js +0 -72
- package/extensions/dm-lens/dist/clients/dispatch/suppress-writer.js +0 -57
- package/extensions/dm-lens/dist/clients/dispatch/tool-profile.js +0 -30
- package/extensions/dm-lens/dist/clients/dispatch/types.js +0 -7
- package/extensions/dm-lens/dist/clients/dispatch/utils/format-utils.js +0 -45
- package/extensions/dm-lens/dist/clients/dispatch/utils/lsp-diagnostics.js +0 -31
- package/extensions/dm-lens/dist/clients/disposition-logger.js +0 -19
- package/extensions/dm-lens/dist/clients/disposition-publish.js +0 -88
- package/extensions/dm-lens/dist/clients/durable-store.js +0 -77
- package/extensions/dm-lens/dist/clients/effective-config.js +0 -160
- package/extensions/dm-lens/dist/clients/env-utils.js +0 -26
- package/extensions/dm-lens/dist/clients/error-class.js +0 -3
- package/extensions/dm-lens/dist/clients/eval-timestamp.js +0 -2
- package/extensions/dm-lens/dist/clients/event-loop-hold.js +0 -119
- package/extensions/dm-lens/dist/clients/event-loop-monitor.js +0 -84
- package/extensions/dm-lens/dist/clients/extension-log.js +0 -230
- package/extensions/dm-lens/dist/clients/extension-mode.js +0 -20
- package/extensions/dm-lens/dist/clients/feature-hints.js +0 -88
- package/extensions/dm-lens/dist/clients/file-kinds.js +0 -304
- package/extensions/dm-lens/dist/clients/file-role.js +0 -50
- package/extensions/dm-lens/dist/clients/file-time.js +0 -112
- package/extensions/dm-lens/dist/clients/file-utils.js +0 -630
- package/extensions/dm-lens/dist/clients/finding-delivery-gate.js +0 -129
- package/extensions/dm-lens/dist/clients/finding-identity.js +0 -23
- package/extensions/dm-lens/dist/clients/fix-worklog.js +0 -75
- package/extensions/dm-lens/dist/clients/format-events-publish.js +0 -230
- package/extensions/dm-lens/dist/clients/format-service.js +0 -154
- package/extensions/dm-lens/dist/clients/formatters-lazy.js +0 -8
- package/extensions/dm-lens/dist/clients/formatters.js +0 -1351
- package/extensions/dm-lens/dist/clients/freshness-cadence.js +0 -1
- package/extensions/dm-lens/dist/clients/freshness.js +0 -8
- package/extensions/dm-lens/dist/clients/generated-artifacts.js +0 -209
- package/extensions/dm-lens/dist/clients/generation-guard.js +0 -105
- package/extensions/dm-lens/dist/clients/git-guard.js +0 -770
- package/extensions/dm-lens/dist/clients/git-tracked-ignore.js +0 -120
- package/extensions/dm-lens/dist/clients/gitleaks-client.js +0 -282
- package/extensions/dm-lens/dist/clients/go-client.js +0 -47
- package/extensions/dm-lens/dist/clients/govulncheck-client.js +0 -411
- package/extensions/dm-lens/dist/clients/gradle-ktfmt-style.js +0 -177
- package/extensions/dm-lens/dist/clients/grammar-source.js +0 -224
- package/extensions/dm-lens/dist/clients/gzip-stage-write.js +0 -85
- package/extensions/dm-lens/dist/clients/hashline-anchor.js +0 -222
- package/extensions/dm-lens/dist/clients/hook-budgets.js +0 -16
- package/extensions/dm-lens/dist/clients/host-edit-normalize.js +0 -87
- package/extensions/dm-lens/dist/clients/host-ports.js +0 -35
- package/extensions/dm-lens/dist/clients/indent-retarget.js +0 -102
- package/extensions/dm-lens/dist/clients/inline-blocker-dispositions.js +0 -103
- package/extensions/dm-lens/dist/clients/install-diagnostics.js +0 -123
- package/extensions/dm-lens/dist/clients/installer/index.js +0 -3770
- package/extensions/dm-lens/dist/clients/installer/managed-tool-refresh-session.js +0 -17
- package/extensions/dm-lens/dist/clients/installer/managed-tool-refresh.js +0 -522
- package/extensions/dm-lens/dist/clients/instance-reaper-state.js +0 -3
- package/extensions/dm-lens/dist/clients/instance-reaper.js +0 -577
- package/extensions/dm-lens/dist/clients/instance-registry-lock.js +0 -131
- package/extensions/dm-lens/dist/clients/instance-registry.js +0 -452
- package/extensions/dm-lens/dist/clients/jscpd-client.js +0 -252
- package/extensions/dm-lens/dist/clients/json-cache-read.js +0 -25
- package/extensions/dm-lens/dist/clients/knip-client.js +0 -472
- package/extensions/dm-lens/dist/clients/language-policy.js +0 -242
- package/extensions/dm-lens/dist/clients/language-profile.js +0 -261
- package/extensions/dm-lens/dist/clients/language-registry.js +0 -424
- package/extensions/dm-lens/dist/clients/latency-logger.js +0 -192
- package/extensions/dm-lens/dist/clients/lazy-import.js +0 -14
- package/extensions/dm-lens/dist/clients/ledger-bounds.js +0 -21
- package/extensions/dm-lens/dist/clients/lens-config.js +0 -237
- package/extensions/dm-lens/dist/clients/lens-engine.js +0 -181
- package/extensions/dm-lens/dist/clients/lens-events.js +0 -105
- package/extensions/dm-lens/dist/clients/lens-flag-registry.js +0 -302
- package/extensions/dm-lens/dist/clients/lens-map.js +0 -980
- package/extensions/dm-lens/dist/clients/live-bus-emitter.js +0 -53
- package/extensions/dm-lens/dist/clients/log-cleanup.js +0 -138
- package/extensions/dm-lens/dist/clients/lsp/aggregation.js +0 -88
- package/extensions/dm-lens/dist/clients/lsp/cascade-tier.js +0 -203
- package/extensions/dm-lens/dist/clients/lsp/client.js +0 -2709
- package/extensions/dm-lens/dist/clients/lsp/config.js +0 -252
- package/extensions/dm-lens/dist/clients/lsp/content-limits.js +0 -21
- package/extensions/dm-lens/dist/clients/lsp/diagnostic-binding.js +0 -79
- package/extensions/dm-lens/dist/clients/lsp/document-drift.js +0 -312
- package/extensions/dm-lens/dist/clients/lsp/edits.js +0 -930
- package/extensions/dm-lens/dist/clients/lsp/index.js +0 -4448
- package/extensions/dm-lens/dist/clients/lsp/inferred-project.js +0 -121
- package/extensions/dm-lens/dist/clients/lsp/jvm-runtime.js +0 -194
- package/extensions/dm-lens/dist/clients/lsp/language.js +0 -23
- package/extensions/dm-lens/dist/clients/lsp/launch.js +0 -468
- package/extensions/dm-lens/dist/clients/lsp/lombok.js +0 -146
- package/extensions/dm-lens/dist/clients/lsp/path-utils.js +0 -1
- package/extensions/dm-lens/dist/clients/lsp/pending-aux-coverage.js +0 -90
- package/extensions/dm-lens/dist/clients/lsp/position-encoding.js +0 -28
- package/extensions/dm-lens/dist/clients/lsp/ruby-drive-dirs.js +0 -42
- package/extensions/dm-lens/dist/clients/lsp/server.js +0 -2422
- package/extensions/dm-lens/dist/clients/lsp/session-roots.js +0 -52
- package/extensions/dm-lens/dist/clients/lsp/spawn-history.js +0 -15
- package/extensions/dm-lens/dist/clients/lsp/sync-kind.js +0 -30
- package/extensions/dm-lens/dist/clients/lsp/tsserver-sync.js +0 -156
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/capability-snapshot.js +0 -1
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/classification.js +0 -36
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/index.js +0 -3
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/strategies.js +0 -175
- package/extensions/dm-lens/dist/clients/lsp/watch-queue.js +0 -40
- package/extensions/dm-lens/dist/clients/lsp/workspace-diagnostics-cache.js +0 -267
- package/extensions/dm-lens/dist/clients/lsp/workspace-diagnostics-session.js +0 -7
- package/extensions/dm-lens/dist/clients/lsp/workspace-sweep-hold.js +0 -93
- package/extensions/dm-lens/dist/clients/lsp-budget.js +0 -83
- package/extensions/dm-lens/dist/clients/lsp-document-symbols.js +0 -93
- package/extensions/dm-lens/dist/clients/lsp-lazy.js +0 -8
- package/extensions/dm-lens/dist/clients/lsp-mutation.js +0 -273
- package/extensions/dm-lens/dist/clients/lsp-status.js +0 -37
- package/extensions/dm-lens/dist/clients/map-with-concurrency.js +0 -20
- package/extensions/dm-lens/dist/clients/mcp/analyze.js +0 -251
- package/extensions/dm-lens/dist/clients/mcp/host-shim.js +0 -14
- package/extensions/dm-lens/dist/clients/mcp/ipc.js +0 -302
- package/extensions/dm-lens/dist/clients/mcp/review.js +0 -137
- package/extensions/dm-lens/dist/clients/mcp/session.js +0 -305
- package/extensions/dm-lens/dist/clients/memory-sampler.js +0 -107
- package/extensions/dm-lens/dist/clients/message-end-attribution.js +0 -18
- package/extensions/dm-lens/dist/clients/metrics-client.js +0 -80
- package/extensions/dm-lens/dist/clients/metrics-history.js +0 -255
- package/extensions/dm-lens/dist/clients/middle-man-analysis.js +0 -161
- package/extensions/dm-lens/dist/clients/model-provider.js +0 -31
- package/extensions/dm-lens/dist/clients/module-report-lsp.js +0 -140
- package/extensions/dm-lens/dist/clients/module-report.js +0 -1642
- package/extensions/dm-lens/dist/clients/mutating-tool.js +0 -377
- package/extensions/dm-lens/dist/clients/mutation-attribution.js +0 -168
- package/extensions/dm-lens/dist/clients/mutation-bridge.js +0 -102
- package/extensions/dm-lens/dist/clients/ndjson-logger.js +0 -471
- package/extensions/dm-lens/dist/clients/observed-mutation-sources.js +0 -43
- package/extensions/dm-lens/dist/clients/observed-mutation.js +0 -709
- package/extensions/dm-lens/dist/clients/oldtext-autopatch.js +0 -100
- package/extensions/dm-lens/dist/clients/opaque-mutation-scan.js +0 -313
- package/extensions/dm-lens/dist/clients/opengrep-client.js +0 -216
- package/extensions/dm-lens/dist/clients/opengrep-config.js +0 -52
- package/extensions/dm-lens/dist/clients/package-manager.js +0 -303
- package/extensions/dm-lens/dist/clients/package-root.js +0 -25
- package/extensions/dm-lens/dist/clients/partial-edit-apply.js +0 -337
- package/extensions/dm-lens/dist/clients/path-attribution-telemetry.js +0 -31
- package/extensions/dm-lens/dist/clients/path-keyed-map.js +0 -57
- package/extensions/dm-lens/dist/clients/path-utils.js +0 -476
- package/extensions/dm-lens/dist/clients/performance-report.js +0 -291
- package/extensions/dm-lens/dist/clients/persist-debounce.js +0 -37
- package/extensions/dm-lens/dist/clients/persistent-reverify.js +0 -165
- package/extensions/dm-lens/dist/clients/php-cs-fixer-config.js +0 -15
- package/extensions/dm-lens/dist/clients/pipeline.js +0 -1091
- package/extensions/dm-lens/dist/clients/post-autofix-notice.js +0 -19
- package/extensions/dm-lens/dist/clients/print-mode.js +0 -3
- package/extensions/dm-lens/dist/clients/probe-home-state.js +0 -62
- package/extensions/dm-lens/dist/clients/process-bridge.js +0 -20
- package/extensions/dm-lens/dist/clients/process-singletons.js +0 -69
- package/extensions/dm-lens/dist/clients/process-snapshot.js +0 -22
- package/extensions/dm-lens/dist/clients/project-changes.js +0 -112
- package/extensions/dm-lens/dist/clients/project-conventions.js +0 -152
- package/extensions/dm-lens/dist/clients/project-diagnostics/cache.js +0 -91
- package/extensions/dm-lens/dist/clients/project-diagnostics/extractors.js +0 -53
- package/extensions/dm-lens/dist/clients/project-diagnostics/fresh-fetch.js +0 -408
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js +0 -64
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/dead-code.js +0 -38
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/gitleaks.js +0 -21
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/govulncheck.js +0 -23
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/jscpd.js +0 -28
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/knip.js +0 -45
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/madge.js +0 -34
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/opengrep.js +0 -32
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +0 -79
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/trivy.js +0 -41
- package/extensions/dm-lens/dist/clients/project-diagnostics/scanner.js +0 -349
- package/extensions/dm-lens/dist/clients/project-diagnostics/types.js +0 -1
- package/extensions/dm-lens/dist/clients/project-lens-config.js +0 -437
- package/extensions/dm-lens/dist/clients/project-report.js +0 -527
- package/extensions/dm-lens/dist/clients/project-scale.js +0 -60
- package/extensions/dm-lens/dist/clients/project-scan-policy.js +0 -4
- package/extensions/dm-lens/dist/clients/project-snapshot-fingerprint.js +0 -39
- package/extensions/dm-lens/dist/clients/project-snapshot-persist-worker.js +0 -14
- package/extensions/dm-lens/dist/clients/project-snapshot.js +0 -1178
- package/extensions/dm-lens/dist/clients/project-trust.js +0 -104
- package/extensions/dm-lens/dist/clients/python-environment.js +0 -120
- package/extensions/dm-lens/dist/clients/python-provenance.js +0 -551
- package/extensions/dm-lens/dist/clients/quiet-window-config.js +0 -16
- package/extensions/dm-lens/dist/clients/quiet-window.js +0 -126
- package/extensions/dm-lens/dist/clients/read-bridge.js +0 -46
- package/extensions/dm-lens/dist/clients/read-expansion.js +0 -218
- package/extensions/dm-lens/dist/clients/read-guard-logger.js +0 -178
- package/extensions/dm-lens/dist/clients/read-guard-tool-lines.js +0 -1042
- package/extensions/dm-lens/dist/clients/read-guard.js +0 -1096
- package/extensions/dm-lens/dist/clients/recent-touches.js +0 -126
- package/extensions/dm-lens/dist/clients/redact/secrets.js +0 -386
- package/extensions/dm-lens/dist/clients/resource-sampler.js +0 -344
- package/extensions/dm-lens/dist/clients/reverse-deps.js +0 -227
- package/extensions/dm-lens/dist/clients/review-graph/builder.js +0 -3635
- package/extensions/dm-lens/dist/clients/review-graph/format.js +0 -30
- package/extensions/dm-lens/dist/clients/review-graph/git-identity.js +0 -115
- package/extensions/dm-lens/dist/clients/review-graph/import-resolvers.js +0 -325
- package/extensions/dm-lens/dist/clients/review-graph/persist-worker.js +0 -8
- package/extensions/dm-lens/dist/clients/review-graph/query.js +0 -195
- package/extensions/dm-lens/dist/clients/review-graph/revision-drift.js +0 -3
- package/extensions/dm-lens/dist/clients/review-graph/service.js +0 -60
- package/extensions/dm-lens/dist/clients/review-graph/shared-extraction-ir.js +0 -54
- package/extensions/dm-lens/dist/clients/review-graph/symbol-id.js +0 -29
- package/extensions/dm-lens/dist/clients/review-graph/tsconfig-paths.js +0 -253
- package/extensions/dm-lens/dist/clients/review-graph/types.js +0 -1
- package/extensions/dm-lens/dist/clients/review-graph/workspace-modules.js +0 -374
- package/extensions/dm-lens/dist/clients/review-graph-logger.js +0 -51
- package/extensions/dm-lens/dist/clients/ruff-client.js +0 -109
- package/extensions/dm-lens/dist/clients/rules-scanner.js +0 -113
- package/extensions/dm-lens/dist/clients/run-duration.js +0 -9
- package/extensions/dm-lens/dist/clients/runtime-agent-end.js +0 -608
- package/extensions/dm-lens/dist/clients/runtime-config.js +0 -39
- package/extensions/dm-lens/dist/clients/runtime-context.js +0 -155
- package/extensions/dm-lens/dist/clients/runtime-coordinator.js +0 -817
- package/extensions/dm-lens/dist/clients/runtime-session.js +0 -1625
- package/extensions/dm-lens/dist/clients/runtime-tool-call.js +0 -868
- package/extensions/dm-lens/dist/clients/runtime-tool-result.js +0 -1317
- package/extensions/dm-lens/dist/clients/runtime-turn.js +0 -2333
- package/extensions/dm-lens/dist/clients/rust-client.js +0 -48
- package/extensions/dm-lens/dist/clients/safe-spawn.js +0 -1267
- package/extensions/dm-lens/dist/clients/sanitize.js +0 -174
- package/extensions/dm-lens/dist/clients/scan-utils.js +0 -7
- package/extensions/dm-lens/dist/clients/scratch-tree-policy.js +0 -57
- package/extensions/dm-lens/dist/clients/search-read-registration.js +0 -59
- package/extensions/dm-lens/dist/clients/secret-findings.js +0 -69
- package/extensions/dm-lens/dist/clients/security-scan-client.js +0 -208
- package/extensions/dm-lens/dist/clients/session-event-guard.js +0 -111
- package/extensions/dm-lens/dist/clients/session-lifecycle.js +0 -173
- package/extensions/dm-lens/dist/clients/session-start-observability.js +0 -47
- package/extensions/dm-lens/dist/clients/session-state-store.js +0 -63
- package/extensions/dm-lens/dist/clients/session-summary.js +0 -8
- package/extensions/dm-lens/dist/clients/sessionstart-logger.js +0 -22
- package/extensions/dm-lens/dist/clients/sg-runner.js +0 -627
- package/extensions/dm-lens/dist/clients/sgconfig.js +0 -280
- package/extensions/dm-lens/dist/clients/shared-checkout-guard.js +0 -177
- package/extensions/dm-lens/dist/clients/single-flight.js +0 -52
- package/extensions/dm-lens/dist/clients/situational-tool-telemetry.js +0 -85
- package/extensions/dm-lens/dist/clients/skills-resolver.js +0 -38
- package/extensions/dm-lens/dist/clients/slow-fs.js +0 -77
- package/extensions/dm-lens/dist/clients/smells-rollup.js +0 -118
- package/extensions/dm-lens/dist/clients/source-filter.js +0 -320
- package/extensions/dm-lens/dist/clients/source-walker.js +0 -96
- package/extensions/dm-lens/dist/clients/spawn-output-cap.js +0 -35
- package/extensions/dm-lens/dist/clients/spawn-timeout-cooldown.js +0 -51
- package/extensions/dm-lens/dist/clients/stale-marker.js +0 -1
- package/extensions/dm-lens/dist/clients/startup-scan.js +0 -222
- package/extensions/dm-lens/dist/clients/startup-timing.js +0 -67
- package/extensions/dm-lens/dist/clients/string-utils.js +0 -6
- package/extensions/dm-lens/dist/clients/subagent-mode.js +0 -40
- package/extensions/dm-lens/dist/clients/symbol-containment.js +0 -16
- package/extensions/dm-lens/dist/clients/symbol-types.js +0 -1
- package/extensions/dm-lens/dist/clients/test-runner-client.js +0 -1504
- package/extensions/dm-lens/dist/clients/test-runner-delivery.js +0 -260
- package/extensions/dm-lens/dist/clients/todo-scanner.js +0 -164
- package/extensions/dm-lens/dist/clients/tool-agreement.js +0 -377
- package/extensions/dm-lens/dist/clients/tool-config.js +0 -218
- package/extensions/dm-lens/dist/clients/tool-cwd.js +0 -235
- package/extensions/dm-lens/dist/clients/tool-definition.js +0 -22
- package/extensions/dm-lens/dist/clients/tool-event.js +0 -18
- package/extensions/dm-lens/dist/clients/tool-policy.js +0 -2393
- package/extensions/dm-lens/dist/clients/tool-probe.js +0 -5
- package/extensions/dm-lens/dist/clients/tool-render.js +0 -79
- package/extensions/dm-lens/dist/clients/tool-set-policy.js +0 -70
- package/extensions/dm-lens/dist/clients/tree-sitter-cache.js +0 -206
- package/extensions/dm-lens/dist/clients/tree-sitter-client.js +0 -2787
- package/extensions/dm-lens/dist/clients/tree-sitter-logger.js +0 -77
- package/extensions/dm-lens/dist/clients/tree-sitter-navigator.js +0 -198
- package/extensions/dm-lens/dist/clients/tree-sitter-query-loader.js +0 -318
- package/extensions/dm-lens/dist/clients/tree-sitter-shared.js +0 -87
- package/extensions/dm-lens/dist/clients/tree-sitter-symbol-extractor.js +0 -957
- package/extensions/dm-lens/dist/clients/trivy-client.js +0 -305
- package/extensions/dm-lens/dist/clients/tui-fit.js +0 -26
- package/extensions/dm-lens/dist/clients/turn-context.js +0 -48
- package/extensions/dm-lens/dist/clients/turn-end/lane.js +0 -1
- package/extensions/dm-lens/dist/clients/turn-end/lanes/govulncheck.js +0 -54
- package/extensions/dm-lens/dist/clients/turn-end/lanes/secrets.js +0 -131
- package/extensions/dm-lens/dist/clients/turn-summary-render.js +0 -56
- package/extensions/dm-lens/dist/clients/turn-summary.js +0 -84
- package/extensions/dm-lens/dist/clients/typos-config.js +0 -9
- package/extensions/dm-lens/dist/clients/user-notify.js +0 -15
- package/extensions/dm-lens/dist/clients/vanished-instance-marker.js +0 -18
- package/extensions/dm-lens/dist/clients/warm-attach.js +0 -210
- package/extensions/dm-lens/dist/clients/widget-state.js +0 -963
- package/extensions/dm-lens/dist/clients/word-index-logger.js +0 -21
- package/extensions/dm-lens/dist/clients/word-index-store.js +0 -222
- package/extensions/dm-lens/dist/clients/word-index.js +0 -1426
- package/extensions/dm-lens/dist/clients/workspace-topology.js +0 -261
- package/extensions/dm-lens/dist/clients/write-ordering-guard.js +0 -24
- package/extensions/dm-lens/dist/clients/zizmor-config.js +0 -160
- package/extensions/dm-lens/dist/i18n.js +0 -67
- package/extensions/dm-lens/dist/index.js +0 -1782
- package/extensions/dm-lens/dist/mcp/analyze-cli.js +0 -178
- package/extensions/dm-lens/dist/mcp/build-staleness.js +0 -55
- package/extensions/dm-lens/dist/mcp/cli.js +0 -78
- package/extensions/dm-lens/dist/mcp/server.js +0 -1208
- package/extensions/dm-lens/dist/mcp/worker.js +0 -33
- package/extensions/dm-lens/dist/scripts/lib/process-scan.mjs +0 -256
- package/extensions/dm-lens/dist/scripts/lib/skills-predicate.mjs +0 -53
- package/extensions/dm-lens/dist/scripts/lib/web-tree-sitter-dir.mjs +0 -45
- package/extensions/dm-lens/dist/tools/activate-tools.js +0 -61
- package/extensions/dm-lens/dist/tools/ast-grep-outline.js +0 -127
- package/extensions/dm-lens/dist/tools/ast-grep-replace.js +0 -226
- package/extensions/dm-lens/dist/tools/ast-grep-search.js +0 -687
- package/extensions/dm-lens/dist/tools/effective-config.js +0 -59
- package/extensions/dm-lens/dist/tools/lens-diagnostic-mark.js +0 -240
- package/extensions/dm-lens/dist/tools/lens-diagnostics.js +0 -1484
- package/extensions/dm-lens/dist/tools/lsp-diagnostics.js +0 -1088
- package/extensions/dm-lens/dist/tools/lsp-navigation.js +0 -1194
- package/extensions/dm-lens/dist/tools/lsp-structured-output.js +0 -277
- package/extensions/dm-lens/dist/tools/module-report.js +0 -332
- package/extensions/dm-lens/dist/tools/project-report.js +0 -72
- package/extensions/dm-lens/dist/tools/render-compact.js +0 -272
- package/extensions/dm-lens/dist/tools/scan-progress.js +0 -31
- package/extensions/dm-lens/dist/tools/shared.js +0 -26
- package/extensions/dm-lens/dist/tools/symbol-search.js +0 -133
- package/extensions/dm-mcp-adapter/dist/abort.js +0 -35
- package/extensions/dm-mcp-adapter/dist/agent-dir.js +0 -45
- package/extensions/dm-mcp-adapter/dist/agent-plugin-loader.js +0 -392
- package/extensions/dm-mcp-adapter/dist/agent-plugin-provenance.js +0 -26
- package/extensions/dm-mcp-adapter/dist/bearer-command-resolver.js +0 -182
- package/extensions/dm-mcp-adapter/dist/claude-plugin-loader.js +0 -350
- package/extensions/dm-mcp-adapter/dist/config.js +0 -1310
- package/extensions/dm-mcp-adapter/dist/consent-manager.js +0 -84
- package/extensions/dm-mcp-adapter/dist/elicitation-handler.js +0 -308
- package/extensions/dm-mcp-adapter/dist/errors.js +0 -225
- package/extensions/dm-mcp-adapter/dist/http-ca.js +0 -71
- package/extensions/dm-mcp-adapter/dist/jev-client.js +0 -359
- package/extensions/dm-mcp-adapter/dist/jev-contracts.js +0 -1
- package/extensions/dm-mcp-adapter/dist/jev-key-store.js +0 -176
- package/extensions/dm-mcp-adapter/dist/json-schema-validator.js +0 -70
- package/extensions/dm-mcp-adapter/dist/lifecycle.js +0 -387
- package/extensions/dm-mcp-adapter/dist/logger.js +0 -115
- package/extensions/dm-mcp-adapter/dist/mcp-auth-fetch.js +0 -86
- package/extensions/dm-mcp-adapter/dist/mcp-auth-flow.js +0 -949
- package/extensions/dm-mcp-adapter/dist/mcp-auth.js +0 -997
- package/extensions/dm-mcp-adapter/dist/mcp-bearer-store.js +0 -182
- package/extensions/dm-mcp-adapter/dist/mcp-callback-server.js +0 -381
- package/extensions/dm-mcp-adapter/dist/mcp-oauth-provider.js +0 -524
- package/extensions/dm-mcp-adapter/dist/mcp-probe.js +0 -151
- package/extensions/dm-mcp-adapter/dist/mcp-tasks.js +0 -300
- package/extensions/dm-mcp-adapter/dist/mcp-trace.js +0 -215
- package/extensions/dm-mcp-adapter/dist/metadata-cache.js +0 -267
- package/extensions/dm-mcp-adapter/dist/npx-resolver.js +0 -465
- package/extensions/dm-mcp-adapter/dist/package-mcp-loader.js +0 -135
- package/extensions/dm-mcp-adapter/dist/request-headers-command.js +0 -294
- package/extensions/dm-mcp-adapter/dist/resource-tools.js +0 -7
- package/extensions/dm-mcp-adapter/dist/runtime-owner.js +0 -94
- package/extensions/dm-mcp-adapter/dist/sampling-handler.js +0 -213
- package/extensions/dm-mcp-adapter/dist/secure-keyring.js +0 -191
- package/extensions/dm-mcp-adapter/dist/server-manager.js +0 -1514
- package/extensions/dm-mcp-adapter/dist/session-approvals.js +0 -127
- package/extensions/dm-mcp-adapter/dist/session-recovery.js +0 -82
- package/extensions/dm-mcp-adapter/dist/state.js +0 -1
- package/extensions/dm-mcp-adapter/dist/types.js +0 -286
- package/extensions/dm-mcp-adapter/dist/ui-app-bridge-helpers.js +0 -36
- package/extensions/dm-mcp-adapter/dist/ui-resource-handler.js +0 -204
- package/extensions/dm-mcp-adapter/dist/ui-stream-types.js +0 -58
- package/extensions/dm-mcp-adapter/dist/ui-tool-visibility.js +0 -26
- package/extensions/dm-mcp-adapter/dist/unix-socket-transport.js +0 -83
- package/extensions/dm-mcp-adapter/dist/utils.js +0 -382
|
@@ -1,1625 +0,0 @@
|
|
|
1
|
-
import * as nodeFs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import { resetBoundedTelemetry } from "./bounded-telemetry.js";
|
|
4
|
-
import { rotateMessageEndAttribution } from "./message-end-attribution.js";
|
|
5
|
-
import { createDeadline, yieldIfOverBudget } from "./cooperative-budget.js";
|
|
6
|
-
import { deadCodeIssueCount } from "./dead-code-client.js";
|
|
7
|
-
import { logDeadCodeScan } from "./dead-code-logger.js";
|
|
8
|
-
import { incrementDegradationCount, recordDegradationOnce, resetDegradationLedger } from "./degradation-ledger.js";
|
|
9
|
-
import { getDiagnosticTracker } from "./diagnostic-tracker.js";
|
|
10
|
-
import { resetPsScriptAnalyzerAvailability } from "./dispatch/runners/psscriptanalyzer.js";
|
|
11
|
-
import { resetInstallRetryLatches } from "./dispatch/runners/utils/availability-policy.js";
|
|
12
|
-
import { resetLazyInstallAttempts } from "./dispatch/runners/utils/lazy-installer.js";
|
|
13
|
-
import { resetDispatchAvailabilityState } from "./dispatch/runners/utils/runner-helpers.js";
|
|
14
|
-
import { resetObservedRunnerLatency } from "./dispatch/collect-later-tier.js";
|
|
15
|
-
import { resetPendingRunnerFindings } from "./dispatch/pending-runner-findings.js";
|
|
16
|
-
import { clearAllSessions as clearFileTimeSessions } from "./file-time.js";
|
|
17
|
-
import { drainProjectDataDirMigrations, getGlobalDmLensDir, getKnipIgnorePatterns, getProjectDataDir, resetProjectDataDirSessionState } from "./file-utils.js";
|
|
18
|
-
import { GitleaksClient } from "./gitleaks-client.js";
|
|
19
|
-
import { resetGoAvailability } from "./go-client.js";
|
|
20
|
-
import { GovulncheckClient } from "./govulncheck-client.js";
|
|
21
|
-
import { sweepAtomicWriteStages } from "./instance-reaper.js";
|
|
22
|
-
import { canRunStartupHeavyScans } from "./language-policy.js";
|
|
23
|
-
import { detectProjectLanguageProfile, getDefaultStartupTools } from "./language-profile.js";
|
|
24
|
-
import { logLatency } from "./latency-logger.js";
|
|
25
|
-
import { runLogCleanup } from "./log-cleanup.js";
|
|
26
|
-
import { resetCascadeTierSessionState } from "./lsp/cascade-tier.js";
|
|
27
|
-
import { initLSPConfig, loadLSPConfig } from "./lsp/config.js";
|
|
28
|
-
import { resetWorkspaceDiagnosticsCacheSession } from "./lsp/workspace-diagnostics-session.js";
|
|
29
|
-
import { resetDirectLspCommandAvailability, resetLSPCaseSensitivityState } from "./lsp/server.js";
|
|
30
|
-
import { loadLspService } from "./lsp-lazy.js";
|
|
31
|
-
import { resetManagedToolRefreshSession } from "./installer/managed-tool-refresh-session.js";
|
|
32
|
-
import { resetResolvedPathCache } from "./installer/index.js";
|
|
33
|
-
import { _resetPackageManagerCache } from "./package-manager.js";
|
|
34
|
-
import { clearFormatterCache } from "./formatters.js";
|
|
35
|
-
import { isAtOrAboveHomeDir } from "./path-utils.js";
|
|
36
|
-
import { isPrintMode } from "./print-mode.js";
|
|
37
|
-
import { readLatestProjectSequence, readLatestProjectSequenceAsync } from "./project-changes.js";
|
|
38
|
-
import { getProjectSnapshotPath, getProjectSnapshotLegacyPath, hydrateRuntimeFromProjectSnapshot, hydrateRuntimeFromProjectSnapshotIfIdle, isProjectSnapshotFresh, isProjectSnapshotMetaStale, loadProjectSnapshot, loadProjectSnapshotExportsAndRules, PROJECT_SNAPSHOT_VERSION, readProjectSnapshotMeta, saveRuntimeProjectSnapshot } from "./project-snapshot.js";
|
|
39
|
-
import { scanProjectRules } from "./rules-scanner.js";
|
|
40
|
-
import { resetRustAvailability } from "./rust-client.js";
|
|
41
|
-
import { resetSafeSpawnWindowsCommandCache } from "./safe-spawn.js";
|
|
42
|
-
import { resetAnalyzerBootstrapSessionState } from "./bootstrap.js";
|
|
43
|
-
import { getSlowFsVerdict, isSlowFs, slowFsDegradationNotice } from "./slow-fs.js";
|
|
44
|
-
import { countRecentSmells, formatSmellsSessionStartLine, resetSmellsSessionState } from "./smells-rollup.js";
|
|
45
|
-
import { resetSituationalToolTelemetry } from "./situational-tool-telemetry.js";
|
|
46
|
-
import { findNearestProjectRoot, getStartupScanMaxEntries, isStartupScanVerdictFresh, resolveStartupScanContext } from "./startup-scan.js";
|
|
47
|
-
import { getSubagentIdentity, isSubagentSession, subagentLightModeNotice } from "./subagent-mode.js";
|
|
48
|
-
import { TrivyClient } from "./trivy-client.js";
|
|
49
|
-
import { isWarmAttached } from "./warm-attach.js";
|
|
50
|
-
import { setSessionLanguages } from "./widget-state.js";
|
|
51
|
-
import { logWordIndex } from "./word-index-logger.js";
|
|
52
|
-
import { resetOpaqueMutationState } from "./opaque-mutation-scan.js";
|
|
53
|
-
import { primePersistedMutationAttribution, resetMutationAttribution } from "./mutation-attribution.js";
|
|
54
|
-
import { resetObservedMutationNet } from "./observed-mutation.js";
|
|
55
|
-
import { resetPendingAuxiliaryCoverage } from "./lsp/pending-aux-coverage.js";
|
|
56
|
-
import { resetWorkspaceTopology } from "./workspace-topology.js";
|
|
57
|
-
import { resetZizmorTokenAvailability } from "./zizmor-config.js";
|
|
58
|
-
import { resetSpawnTimeoutCooldowns } from "./spawn-timeout-cooldown.js";
|
|
59
|
-
import { resetTestRunnerDelivery } from "./test-runner-delivery.js";
|
|
60
|
-
import { resetLspMutationNoBridgeDbgLatch } from "./lsp-mutation.js";
|
|
61
|
-
async function demandBootstrapDeps(deps, reason) {
|
|
62
|
-
const clients = await deps.bootstrap.request(reason);
|
|
63
|
-
if (!clients)
|
|
64
|
-
return null;
|
|
65
|
-
return { ...deps, ...clients };
|
|
66
|
-
}
|
|
67
|
-
const HOST_STALL_THRESHOLD_MS = 30000;
|
|
68
|
-
function logHostReadyDelay(deps, cwd) {
|
|
69
|
-
if (!deps.emitHostReadyDelay || deps.sessionStartMonotonicAt === undefined || deps.extensionLoadedAt === undefined) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const durationMs = Math.max(0, deps.sessionStartMonotonicAt - deps.extensionLoadedAt);
|
|
73
|
-
logLatency({
|
|
74
|
-
type: "phase",
|
|
75
|
-
filePath: cwd,
|
|
76
|
-
phase: "host_ready_delay",
|
|
77
|
-
durationMs,
|
|
78
|
-
metadata: {
|
|
79
|
-
hostStallSuspected: durationMs > HOST_STALL_THRESHOLD_MS,
|
|
80
|
-
sessionStart: "first-process-session",
|
|
81
|
-
reason: deps.sessionReason
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
function resolveSnapshotRoot(cwd) {
|
|
86
|
-
const resolvedCwd = path.resolve(cwd);
|
|
87
|
-
const nearest = findNearestProjectRoot(resolvedCwd);
|
|
88
|
-
if (!nearest || isAtOrAboveHomeDir(nearest)) {
|
|
89
|
-
return resolvedCwd;
|
|
90
|
-
}
|
|
91
|
-
return nearest;
|
|
92
|
-
}
|
|
93
|
-
function snapshotSequenceBase(root) {
|
|
94
|
-
const meta = readProjectSnapshotMeta(root);
|
|
95
|
-
if (!meta || meta.version !== PROJECT_SNAPSHOT_VERSION)
|
|
96
|
-
return;
|
|
97
|
-
const index = meta.sequenceIndex;
|
|
98
|
-
if (!index)
|
|
99
|
-
return;
|
|
100
|
-
return {
|
|
101
|
-
projectSeq: index.projectSeq,
|
|
102
|
-
fileSeqByPath: index.fileSeqByPath,
|
|
103
|
-
sinceSeq: meta.seq
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function recordSnapshotSequenceTimeout(args) {
|
|
107
|
-
let reason = "sequence read timed out; no snapshot on disk";
|
|
108
|
-
try {
|
|
109
|
-
const stat = nodeFs.statSync(args.snapshotPath);
|
|
110
|
-
reason = `sequence read timed out; snapshot age=${Math.round(Date.now() - stat.mtimeMs)}ms size=${stat.size}b`;
|
|
111
|
-
} catch {}
|
|
112
|
-
incrementDegradationCount({
|
|
113
|
-
kind: "snapshot-sequence-read-timeout",
|
|
114
|
-
subject: args.snapshotRoot,
|
|
115
|
-
reason
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
function retroactivelyHydrateAfterDeferredSequence(args) {
|
|
119
|
-
return (latestSeq) => {
|
|
120
|
-
const published = args.getWarmupOwnSnapshotRead();
|
|
121
|
-
const snapshot = published !== undefined ? published : loadProjectSnapshotExportsAndRules(args.snapshotRoot);
|
|
122
|
-
if (!snapshot || snapshot.version !== PROJECT_SNAPSHOT_VERSION || snapshot.seq !== latestSeq.projectSeq) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const hydrated = hydrateRuntimeFromProjectSnapshotIfIdle(args.runtime, snapshot);
|
|
126
|
-
if (hydrated) {
|
|
127
|
-
args.dbg(`session_start: deferred sequence read confirmed snapshot freshness — hydrating cachedExports/projectRulesScan late (seq=${snapshot.seq})`);
|
|
128
|
-
} else {
|
|
129
|
-
args.dbg(`session_start: deferred sequence read confirmed snapshot freshness (seq=${snapshot.seq}), but the runtime already has live state (warmup or another task got there first) — skipping late hydration to avoid clobbering it`);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function loadSnapshotBodyUnlessStale(args) {
|
|
134
|
-
const meta = readProjectSnapshotMeta(args.root);
|
|
135
|
-
if (meta && isProjectSnapshotMetaStale(meta, args.currentProjectSeq)) {
|
|
136
|
-
args.dbg(`project_snapshot: meta gate stale (metaSeq=${meta.seq} metaVersion=${meta.version} current=${args.currentProjectSeq}) — skipping body parse`);
|
|
137
|
-
return { snapshot: null, skippedStale: true };
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
snapshot: loadProjectSnapshot(args.root),
|
|
141
|
-
skippedStale: false
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
function describeSnapshotMiss(snapshot, currentProjectSeq, args) {
|
|
145
|
-
if (args.skippedStale)
|
|
146
|
-
return "stale-meta-gate";
|
|
147
|
-
if (!snapshot)
|
|
148
|
-
return args.bodyPresent ? "invalid-body" : "missing";
|
|
149
|
-
if (snapshot.seq !== currentProjectSeq) {
|
|
150
|
-
return `stale(seq=${snapshot.seq}, current=${currentProjectSeq})`;
|
|
151
|
-
}
|
|
152
|
-
return "incompatible";
|
|
153
|
-
}
|
|
154
|
-
function logProjectSnapshotProbe(args) {
|
|
155
|
-
args.dbg(`project_snapshot: probe root=${args.root} path=${getProjectSnapshotPath(args.root)} currentSeq=${args.currentProjectSeq}`);
|
|
156
|
-
if (isProjectSnapshotFresh(args.snapshot, args.currentProjectSeq)) {
|
|
157
|
-
args.dbg(`project_snapshot: loaded seq=${args.snapshot.seq} exports=${args.snapshot.cachedExports.length} files=${Object.keys(args.snapshot.files ?? {}).length} reverseDeps=${Object.keys(args.snapshot.reverseDeps ?? {}).length} startupScan=${Boolean(args.snapshot.startupScan)} languageProfile=${Boolean(args.snapshot.languageProfile)}`);
|
|
158
|
-
} else {
|
|
159
|
-
args.dbg(`project_snapshot: miss reason=${args.missReason}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function resolveStartupMode(projectConfig, globalConfig) {
|
|
163
|
-
const envMode = (process.env.DM_LENS_STARTUP_MODE ?? "").trim().toLowerCase();
|
|
164
|
-
if (envMode === "full" || envMode === "minimal" || envMode === "quick") {
|
|
165
|
-
return envMode;
|
|
166
|
-
}
|
|
167
|
-
const configMode = projectConfig?.startup?.mode ?? globalConfig?.startup?.mode;
|
|
168
|
-
if (configMode)
|
|
169
|
-
return configMode;
|
|
170
|
-
if (isPrintMode()) {
|
|
171
|
-
return "quick";
|
|
172
|
-
}
|
|
173
|
-
return "full";
|
|
174
|
-
}
|
|
175
|
-
function sequenceReadBudgetMs() {
|
|
176
|
-
const raw = Number(process.env.DM_LENS_SEQUENCE_READ_BUDGET_MS ?? 250);
|
|
177
|
-
return Number.isFinite(raw) && raw > 0 ? raw : 250;
|
|
178
|
-
}
|
|
179
|
-
const UNKNOWN_PROJECT_SEQ = -1;
|
|
180
|
-
async function readSequenceWithBudget(args) {
|
|
181
|
-
const { snapshotRoot, base, cwd, runtime, sessionGeneration, dbg, onDeferredSequenceResolved } = args;
|
|
182
|
-
const readPromise = readLatestProjectSequenceAsync(snapshotRoot, base);
|
|
183
|
-
let timeoutHandle;
|
|
184
|
-
const timeoutPromise = new Promise((resolve) => {
|
|
185
|
-
timeoutHandle = setTimeout(() => resolve({ timedOut: true }), sequenceReadBudgetMs());
|
|
186
|
-
timeoutHandle.unref();
|
|
187
|
-
});
|
|
188
|
-
const raced = await Promise.race([
|
|
189
|
-
readPromise.then((latestSeq) => ({ timedOut: false, latestSeq })),
|
|
190
|
-
timeoutPromise
|
|
191
|
-
]);
|
|
192
|
-
if (timeoutHandle)
|
|
193
|
-
clearTimeout(timeoutHandle);
|
|
194
|
-
if (!raced.timedOut) {
|
|
195
|
-
return { latestSeq: raced.latestSeq, timedOut: false };
|
|
196
|
-
}
|
|
197
|
-
dbg(`session_start: sequence read exceeded ${sequenceReadBudgetMs()}ms budget — falling back to cold-start sequence`);
|
|
198
|
-
if (!isPrintMode()) {
|
|
199
|
-
readPromise.then((latestSeq) => {
|
|
200
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
201
|
-
return;
|
|
202
|
-
if (runtime.projectSeq > 0) {
|
|
203
|
-
dbg("session_start: deferred sequence read completed, but the session already advanced (in-window edit) — skipping reseed to avoid clobbering it");
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
const reseedStartedAt = Date.now();
|
|
207
|
-
runtime.seedProjectSequence?.(latestSeq.projectSeq, latestSeq.fileSeqByPath);
|
|
208
|
-
logLatency({
|
|
209
|
-
type: "phase",
|
|
210
|
-
phase: "session_start_sequence_read_deferred_reseed",
|
|
211
|
-
filePath: cwd,
|
|
212
|
-
startedAt: new Date(reseedStartedAt).toISOString(),
|
|
213
|
-
durationMs: Date.now() - reseedStartedAt,
|
|
214
|
-
metadata: { entries: latestSeq.fileSeqByPath.size, deferred: true }
|
|
215
|
-
});
|
|
216
|
-
dbg(`session_start: deferred sequence read completed — reseeded projectSeq=${latestSeq.projectSeq} fileSeqEntries=${latestSeq.fileSeqByPath.size}`);
|
|
217
|
-
onDeferredSequenceResolved?.(latestSeq);
|
|
218
|
-
}).catch((err) => {
|
|
219
|
-
dbg(`session_start: deferred sequence read failed: ${err}`);
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
return {
|
|
223
|
-
latestSeq: { projectSeq: 0, fileSeqByPath: new Map },
|
|
224
|
-
timedOut: true
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
async function igniteWarmFiles(cwd, warmFiles, runtime, sessionGeneration, dbg) {
|
|
228
|
-
try {
|
|
229
|
-
dbg(`session_start lsp-warm: ${warmFiles.length} warm file(s) configured`);
|
|
230
|
-
await initLSPConfig(cwd);
|
|
231
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
232
|
-
return;
|
|
233
|
-
const lspService = (await loadLspService()).getLSPService();
|
|
234
|
-
const total = warmFiles.length;
|
|
235
|
-
let loaded = 0;
|
|
236
|
-
let errors = 0;
|
|
237
|
-
for (const relPath of warmFiles) {
|
|
238
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
239
|
-
return;
|
|
240
|
-
const filePath = path.isAbsolute(relPath) ? relPath : path.resolve(cwd, relPath);
|
|
241
|
-
if (!nodeFs.existsSync(filePath)) {
|
|
242
|
-
dbg(`session_start lsp-warm: not found: ${relPath}`);
|
|
243
|
-
errors++;
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
try {
|
|
247
|
-
const content = nodeFs.readFileSync(filePath, "utf-8");
|
|
248
|
-
await lspService.touchFile(filePath, content, {
|
|
249
|
-
diagnostics: "none",
|
|
250
|
-
source: "startup-warm",
|
|
251
|
-
clientScope: "primary",
|
|
252
|
-
maxClientWaitMs: 2000
|
|
253
|
-
});
|
|
254
|
-
loaded++;
|
|
255
|
-
} catch (err) {
|
|
256
|
-
dbg(`session_start lsp-warm: error ${relPath}: ${err}`);
|
|
257
|
-
errors++;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
dbg(`session_start lsp-warm: ${loaded}/${total} opened (${errors} err)`);
|
|
261
|
-
} catch (err) {
|
|
262
|
-
dbg(`session_start lsp-warm: config/init error: ${err}`);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
async function igniteDominantLanguageWarm(cwd, runtime, sessionGeneration, dbg) {
|
|
266
|
-
try {
|
|
267
|
-
await initLSPConfig(cwd);
|
|
268
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
269
|
-
return;
|
|
270
|
-
const lspService = (await loadLspService()).getLSPService();
|
|
271
|
-
const { collectSourceFilesAsync } = await import("./source-filter.js");
|
|
272
|
-
const { CODE_KINDS, detectFileKind } = await import("./file-kinds.js");
|
|
273
|
-
const files = await collectSourceFilesAsync(cwd, {
|
|
274
|
-
inspectGeneratedHeaders: false
|
|
275
|
-
});
|
|
276
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
277
|
-
return;
|
|
278
|
-
const counts = new Map;
|
|
279
|
-
for (const f of files) {
|
|
280
|
-
const kind = detectFileKind(f);
|
|
281
|
-
if (kind)
|
|
282
|
-
counts.set(kind, (counts.get(kind) ?? 0) + 1);
|
|
283
|
-
}
|
|
284
|
-
if (counts.size === 0) {
|
|
285
|
-
dbg("session_start lsp-warm: no detected languages to auto-warm");
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const ranked = [...counts.entries()].sort((a, b) => b[1] - a[1]);
|
|
289
|
-
const warmOrder = [
|
|
290
|
-
...ranked.filter(([kind]) => CODE_KINDS.has(kind)),
|
|
291
|
-
...ranked.filter(([kind]) => !CODE_KINDS.has(kind))
|
|
292
|
-
];
|
|
293
|
-
for (const [kind] of warmOrder) {
|
|
294
|
-
const sample = files.find((f) => detectFileKind(f) === kind && lspService.supportsLSP(f));
|
|
295
|
-
if (!sample)
|
|
296
|
-
continue;
|
|
297
|
-
const content = await nodeFs.promises.readFile(sample, "utf-8");
|
|
298
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
299
|
-
return;
|
|
300
|
-
await lspService.touchFile(sample, content, {
|
|
301
|
-
diagnostics: "none",
|
|
302
|
-
source: "startup-warm-dominant",
|
|
303
|
-
clientScope: "primary",
|
|
304
|
-
maxClientWaitMs: 2000
|
|
305
|
-
});
|
|
306
|
-
dbg(`session_start lsp-warm: dominant=${kind} via ${path.basename(sample)}`);
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
dbg("session_start lsp-warm: no dominant-language LSP file found to warm");
|
|
310
|
-
} catch (err) {
|
|
311
|
-
dbg(`session_start lsp-warm: dominant warm error: ${err}`);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
function firePreinstallDefaults(ensureTool, dbg, startupDefaults) {
|
|
315
|
-
for (const tool of startupDefaults) {
|
|
316
|
-
const startedAt = Date.now();
|
|
317
|
-
dbg(`session_start preinstall ${tool}: start`);
|
|
318
|
-
ensureTool(tool).then((toolPath) => {
|
|
319
|
-
if (toolPath) {
|
|
320
|
-
dbg(`session_start: ${tool} ready at ${toolPath}`);
|
|
321
|
-
dbg(`session_start preinstall ${tool}: success (${Date.now() - startedAt}ms)`);
|
|
322
|
-
} else {
|
|
323
|
-
dbg(`session_start: ${tool} installation unavailable`);
|
|
324
|
-
dbg(`session_start preinstall ${tool}: unavailable (${Date.now() - startedAt}ms)`);
|
|
325
|
-
}
|
|
326
|
-
}).catch((err) => {
|
|
327
|
-
dbg(`session_start: ${tool} pre-install error: ${err}`);
|
|
328
|
-
dbg(`session_start preinstall ${tool}: error (${Date.now() - startedAt}ms)`);
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
const MANAGED_TOOL_REFRESH_DELAY_MS = 30000;
|
|
333
|
-
function scheduleManagedToolRefresh(dbg) {
|
|
334
|
-
const delayMs = Number(process.env.DM_LENS_TOOL_REFRESH_DELAY_MS ?? MANAGED_TOOL_REFRESH_DELAY_MS);
|
|
335
|
-
const timer = setTimeout(() => {
|
|
336
|
-
(async () => {
|
|
337
|
-
try {
|
|
338
|
-
const refresh = await import("./installer/managed-tool-refresh.js");
|
|
339
|
-
const outcome = await refresh.runManagedToolRefresh();
|
|
340
|
-
if (outcome.skipped) {
|
|
341
|
-
dbg(`session_start tool-refresh: skipped (${outcome.skipped})`);
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
for (const result of outcome.refreshed) {
|
|
345
|
-
dbg(`session_start tool-refresh: ${result.toolId} ${result.ok ? "ok" : "failed"}${result.changed ? ` ${result.previousVersion ?? "unknown"} → ${result.currentVersion}` : " (unchanged)"}`);
|
|
346
|
-
}
|
|
347
|
-
} catch (err) {
|
|
348
|
-
dbg(`session_start tool-refresh: error ${err}`);
|
|
349
|
-
}
|
|
350
|
-
})();
|
|
351
|
-
}, Number.isFinite(delayMs) ? delayMs : MANAGED_TOOL_REFRESH_DELAY_MS);
|
|
352
|
-
timer.unref?.();
|
|
353
|
-
}
|
|
354
|
-
async function probePrettierInstall(ensureTool, dbg, analysisRoot) {
|
|
355
|
-
const pkgPath = path.join(analysisRoot, "package.json");
|
|
356
|
-
try {
|
|
357
|
-
const raw = await nodeFs.promises.readFile(pkgPath, "utf-8");
|
|
358
|
-
const pkg = JSON.parse(raw);
|
|
359
|
-
const usesPrettier = !!pkg.devDependencies?.prettier || !!pkg.dependencies?.prettier || pkg.prettier !== undefined;
|
|
360
|
-
if (usesPrettier) {
|
|
361
|
-
dbg("session_start: project uses prettier, ensuring install...");
|
|
362
|
-
ensureTool("prettier").then((p) => {
|
|
363
|
-
if (p)
|
|
364
|
-
dbg(`session_start: prettier ready at ${p}`);
|
|
365
|
-
else
|
|
366
|
-
dbg("session_start: prettier install failed silently");
|
|
367
|
-
}).catch((err) => dbg(`session_start: prettier install error: ${err}`));
|
|
368
|
-
}
|
|
369
|
-
} catch {}
|
|
370
|
-
}
|
|
371
|
-
function scanOneTodoFile(scanner, filePath, items) {
|
|
372
|
-
if (typeof scanner.scanFile !== "function")
|
|
373
|
-
return;
|
|
374
|
-
try {
|
|
375
|
-
const result = scanner.scanFile(filePath);
|
|
376
|
-
if (Array.isArray(result))
|
|
377
|
-
items.push(...result);
|
|
378
|
-
} catch {}
|
|
379
|
-
}
|
|
380
|
-
async function collectTodoBaselineItems(scanner, analysisRoot, stillCurrent) {
|
|
381
|
-
const items = [];
|
|
382
|
-
try {
|
|
383
|
-
const { getSourceFilesAsync } = await import("./scan-utils.js");
|
|
384
|
-
const files = await getSourceFilesAsync(analysisRoot, true);
|
|
385
|
-
if (!stillCurrent())
|
|
386
|
-
return items;
|
|
387
|
-
const deadline = createDeadline(8);
|
|
388
|
-
for (const file of files) {
|
|
389
|
-
if (!stillCurrent())
|
|
390
|
-
return items;
|
|
391
|
-
scanOneTodoFile(scanner, file, items);
|
|
392
|
-
await yieldIfOverBudget(deadline);
|
|
393
|
-
}
|
|
394
|
-
} catch {
|
|
395
|
-
const todoResult = scanner.scanDirectory(analysisRoot);
|
|
396
|
-
items.push(...todoResult.items);
|
|
397
|
-
}
|
|
398
|
-
return items;
|
|
399
|
-
}
|
|
400
|
-
async function buildOrRefreshWordIndex(args) {
|
|
401
|
-
const { runtime, sessionGeneration, analysisRoot, snapshotRoot, dbg } = args;
|
|
402
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
403
|
-
return;
|
|
404
|
-
const startMs = Date.now();
|
|
405
|
-
let rebuildPreflightFiles;
|
|
406
|
-
const latestSeq = readLatestProjectSequence(snapshotRoot, snapshotSequenceBase(snapshotRoot));
|
|
407
|
-
const effectiveSeq = runtime.projectSeq ?? latestSeq.projectSeq;
|
|
408
|
-
const snapshotLoadStartMs = Date.now();
|
|
409
|
-
const snapshot = loadProjectSnapshot(snapshotRoot);
|
|
410
|
-
const snapshotLoadMs = Date.now() - snapshotLoadStartMs;
|
|
411
|
-
if (snapshot?.wordIndex) {
|
|
412
|
-
const { deserializeWordIndex, refreshWordIndexIncrementally, countWordIndexPostingEntries, estimateWordIndexResidentBytes } = await import("./word-index.js");
|
|
413
|
-
const deserializeStartMs = Date.now();
|
|
414
|
-
const index = deserializeWordIndex(snapshot.wordIndex);
|
|
415
|
-
const deserializeMs = Date.now() - deserializeStartMs;
|
|
416
|
-
if (index) {
|
|
417
|
-
try {
|
|
418
|
-
const result = await refreshWordIndexIncrementally(index, analysisRoot, () => runtime.isCurrentSession(sessionGeneration));
|
|
419
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
420
|
-
return;
|
|
421
|
-
if (result.mode === "full-required") {
|
|
422
|
-
rebuildPreflightFiles = result.preflightFiles;
|
|
423
|
-
dbg(`session_start word-index: incremental preflight selected full rebuild (${result.reason})`);
|
|
424
|
-
logWordIndex({
|
|
425
|
-
phase: "incremental_fallback",
|
|
426
|
-
cwd: snapshotRoot,
|
|
427
|
-
trigger: "session_start",
|
|
428
|
-
reason: result.reason,
|
|
429
|
-
phaseDurationsMs: {
|
|
430
|
-
snapshotLoadMs,
|
|
431
|
-
deserializeMs,
|
|
432
|
-
...result.timings
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
} else {
|
|
436
|
-
runtime.wordIndex = index;
|
|
437
|
-
let snapshotSaveSyncMs = 0;
|
|
438
|
-
if (!isProjectSnapshotFresh(snapshot, effectiveSeq) || result.refreshed > 0 || result.dropped > 0 || snapshot.wordIndex.truncated !== index.truncated) {
|
|
439
|
-
const serializeSaveEnqueueStartMs = Date.now();
|
|
440
|
-
saveRuntimeProjectSnapshot({ cwd: snapshotRoot, runtime, dbg });
|
|
441
|
-
snapshotSaveSyncMs = Date.now() - serializeSaveEnqueueStartMs;
|
|
442
|
-
}
|
|
443
|
-
const phases = `snapshot-load=${snapshotLoadMs}ms, deserialize=${deserializeMs}ms, source-walk=${result.timings.sourceWalkMs}ms, stat-walk=${result.timings.statWalkMs}ms, refresh-reads=${result.timings.refreshReadsMs}ms, snapshot-save-sync=${snapshotSaveSyncMs}ms`;
|
|
444
|
-
dbg(`session_start word-index: incremental (seq=${effectiveSeq}, refreshed=${result.refreshed}, dropped=${result.dropped}, skipped=${result.skipped}, reused=${result.reused}, ${Date.now() - startMs}ms, phases: ${phases})`);
|
|
445
|
-
logWordIndex({
|
|
446
|
-
phase: "incremental_refresh",
|
|
447
|
-
cwd: snapshotRoot,
|
|
448
|
-
trigger: "session_start",
|
|
449
|
-
durationMs: Date.now() - startMs,
|
|
450
|
-
indexedFileCount: index.docCount,
|
|
451
|
-
tokens: index.postings.size,
|
|
452
|
-
postingEntries: countWordIndexPostingEntries(index),
|
|
453
|
-
residentBytes: estimateWordIndexResidentBytes(index),
|
|
454
|
-
truncated: index.truncated,
|
|
455
|
-
phaseDurationsMs: {
|
|
456
|
-
snapshotLoadMs,
|
|
457
|
-
deserializeMs,
|
|
458
|
-
...result.timings,
|
|
459
|
-
snapshotSaveSyncMs
|
|
460
|
-
},
|
|
461
|
-
refreshed: result.refreshed,
|
|
462
|
-
dropped: result.dropped,
|
|
463
|
-
skipped: result.skipped,
|
|
464
|
-
reused: result.reused
|
|
465
|
-
});
|
|
466
|
-
return result;
|
|
467
|
-
}
|
|
468
|
-
} catch (err) {
|
|
469
|
-
if (!runtime.isCurrentSession(sessionGeneration)) {
|
|
470
|
-
dbg("session_start word-index: incremental refresh superseded");
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
dbg(`session_start word-index: incremental refresh failed; falling back to full rebuild (${err})`);
|
|
474
|
-
logWordIndex({
|
|
475
|
-
phase: "incremental_fallback",
|
|
476
|
-
cwd: snapshotRoot,
|
|
477
|
-
trigger: "session_start",
|
|
478
|
-
reason: err instanceof Error ? err.message : String(err),
|
|
479
|
-
phaseDurationsMs: { snapshotLoadMs, deserializeMs }
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
const { buildWordIndexAsync, collectWordIndexDocs, countWordIndexPostingEntries, estimateWordIndexResidentBytes } = await import("./word-index.js");
|
|
485
|
-
const docs = await collectWordIndexDocs(analysisRoot, () => runtime.isCurrentSession(sessionGeneration), rebuildPreflightFiles);
|
|
486
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
487
|
-
return;
|
|
488
|
-
let rebuiltIndex;
|
|
489
|
-
try {
|
|
490
|
-
rebuiltIndex = await buildWordIndexAsync(docs, () => runtime.isCurrentSession(sessionGeneration));
|
|
491
|
-
} catch (err) {
|
|
492
|
-
if (!runtime.isCurrentSession(sessionGeneration)) {
|
|
493
|
-
dbg("session_start word-index: rebuild superseded");
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
throw err;
|
|
497
|
-
}
|
|
498
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
499
|
-
return;
|
|
500
|
-
runtime.wordIndex = rebuiltIndex;
|
|
501
|
-
saveRuntimeProjectSnapshot({ cwd: snapshotRoot, runtime, dbg });
|
|
502
|
-
dbg(`session_start word-index: rebuilt (absent/stale, seq=${effectiveSeq}) ${runtime.wordIndex.docCount} files, ${runtime.wordIndex.postings.size} tokens (${Date.now() - startMs}ms)`);
|
|
503
|
-
logWordIndex({
|
|
504
|
-
phase: "full_rebuild",
|
|
505
|
-
cwd: snapshotRoot,
|
|
506
|
-
trigger: "session_start",
|
|
507
|
-
durationMs: Date.now() - startMs,
|
|
508
|
-
indexedFileCount: runtime.wordIndex.docCount,
|
|
509
|
-
tokens: runtime.wordIndex.postings.size,
|
|
510
|
-
postingEntries: countWordIndexPostingEntries(runtime.wordIndex),
|
|
511
|
-
residentBytes: estimateWordIndexResidentBytes(runtime.wordIndex),
|
|
512
|
-
truncated: runtime.wordIndex.truncated,
|
|
513
|
-
skipped: docs.skipped
|
|
514
|
-
});
|
|
515
|
-
return {
|
|
516
|
-
mode: "full",
|
|
517
|
-
refreshed: runtime.wordIndex.docCount,
|
|
518
|
-
dropped: 0,
|
|
519
|
-
skipped: docs.skipped,
|
|
520
|
-
reused: 0
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
function scheduleStartupScans(deps, runtime, sessionGeneration, analysisRoot, snapshotRoot, languageProfile, dbg) {
|
|
524
|
-
(async () => {
|
|
525
|
-
const resolved = await demandBootstrapDeps(deps, "session-start-scans");
|
|
526
|
-
if (!resolved) {
|
|
527
|
-
dbg("session_start scans: analyzer bootstrap unavailable — skipped");
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
scheduleStartupScansWithClients(resolved, runtime, sessionGeneration, analysisRoot, snapshotRoot, languageProfile, dbg);
|
|
531
|
-
})();
|
|
532
|
-
}
|
|
533
|
-
function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analysisRoot, snapshotRoot, languageProfile, dbg) {
|
|
534
|
-
const { todoScanner, cacheManager, knipClient, jscpdClient, deadCodeClients, govulncheckClient, gitleaksClient, trivyClient, opengrepClient, astGrepClient, depChecker } = deps;
|
|
535
|
-
const analyzerEnabled = (flag) => !deps.getFlag(flag);
|
|
536
|
-
if (!analyzerEnabled("no-complexity")) {
|
|
537
|
-
dbg("session_start complexity: skipped (disabled by config)");
|
|
538
|
-
recordDegradationOnce({
|
|
539
|
-
kind: "startup-analyzer-disabled",
|
|
540
|
-
subject: "complexity",
|
|
541
|
-
reason: "skipped (disabled by config)"
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
const taskDeferMsByName = {
|
|
545
|
-
"call-graph": 5000,
|
|
546
|
-
"codebase-model": 5200,
|
|
547
|
-
"ast-grep exports": 5400,
|
|
548
|
-
"project index": 5400
|
|
549
|
-
};
|
|
550
|
-
const runTask = (name, task) => {
|
|
551
|
-
const queuedAt = Date.now();
|
|
552
|
-
dbg(`session_start task ${name}: scheduled`);
|
|
553
|
-
runtime.markStartupScanInFlight(name, sessionGeneration);
|
|
554
|
-
const completion = new Promise((resolve) => {
|
|
555
|
-
const fire = () => {
|
|
556
|
-
const startedAt = Date.now();
|
|
557
|
-
dbg(`session_start task ${name}: start queuedMs=${startedAt - queuedAt}`);
|
|
558
|
-
task().then(() => {
|
|
559
|
-
dbg(`session_start task ${name}: success runMs=${Date.now() - startedAt} queuedMs=${startedAt - queuedAt}`);
|
|
560
|
-
}).catch((err) => {
|
|
561
|
-
dbg(`session_start: ${name} background scan failed: ${err}`);
|
|
562
|
-
dbg(`session_start task ${name}: failed runMs=${Date.now() - startedAt} queuedMs=${startedAt - queuedAt}`);
|
|
563
|
-
}).finally(() => {
|
|
564
|
-
runtime.clearStartupScanInFlight(name, sessionGeneration);
|
|
565
|
-
dbg(`session_start task ${name}: end`);
|
|
566
|
-
resolve();
|
|
567
|
-
});
|
|
568
|
-
};
|
|
569
|
-
const delay = taskDeferMsByName[name] ?? 0;
|
|
570
|
-
if (delay > 0) {
|
|
571
|
-
setTimeout(fire, delay).unref?.();
|
|
572
|
-
} else {
|
|
573
|
-
setImmediate(fire);
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
return completion;
|
|
577
|
-
};
|
|
578
|
-
const canRunJsTsHeavyScans = canRunStartupHeavyScans(languageProfile, "jsts");
|
|
579
|
-
const scanNames = ["todo", "dead-code"];
|
|
580
|
-
if (canRunJsTsHeavyScans) {
|
|
581
|
-
scanNames.push("knip", "jscpd", "ast-grep exports", "project index");
|
|
582
|
-
}
|
|
583
|
-
dbg(`session_start: launching background scans (${scanNames.join(", ")})`);
|
|
584
|
-
runTask("todo", async () => {
|
|
585
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
586
|
-
return;
|
|
587
|
-
const items = await collectTodoBaselineItems(todoScanner, analysisRoot, () => runtime.isCurrentSession(sessionGeneration));
|
|
588
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
589
|
-
return;
|
|
590
|
-
dbg(`session_start TODO scan: ${items.length} items (baseline stored)`);
|
|
591
|
-
cacheManager.writeCache("todo-baseline", { items }, analysisRoot);
|
|
592
|
-
});
|
|
593
|
-
if (!canRunJsTsHeavyScans) {
|
|
594
|
-
dbg("session_start: skipping JS/TS startup scans (requires JS/TS language + project config)");
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
const isSubagent = isSubagentSession();
|
|
598
|
-
const skipHeavyweightScans = isSlowFs(analysisRoot) || isSubagent;
|
|
599
|
-
const runHeavyweightTask = (name, task) => {
|
|
600
|
-
const flag = `no-${name}`;
|
|
601
|
-
if (name !== "opengrep" && name !== "trivy" && !analyzerEnabled(flag)) {
|
|
602
|
-
dbg(`session_start ${name}: skipped (disabled by config)`);
|
|
603
|
-
recordDegradationOnce({
|
|
604
|
-
kind: "startup-analyzer-disabled",
|
|
605
|
-
subject: name,
|
|
606
|
-
reason: "skipped (disabled by config)"
|
|
607
|
-
});
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
if (skipHeavyweightScans)
|
|
611
|
-
return;
|
|
612
|
-
runTask(name, task);
|
|
613
|
-
};
|
|
614
|
-
if (skipHeavyweightScans) {
|
|
615
|
-
dbg(`session_start: skipping knip/jscpd/madge/dead-code/govulncheck/gitleaks/trivy/opengrep (${isSubagent ? "subagent" : "slow-fs"})`);
|
|
616
|
-
deps.notify(`⏭️ Skipped background code-quality scans (knip/jscpd/madge/dead-code/govulncheck/gitleaks/trivy/opengrep): ${isSubagent ? subagentLightModeNotice() : slowFsDegradationNotice()}`, "info");
|
|
617
|
-
}
|
|
618
|
-
runHeavyweightTask("knip", async () => {
|
|
619
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
620
|
-
return;
|
|
621
|
-
const cached = cacheManager.readCache("knip", analysisRoot);
|
|
622
|
-
if (cached) {
|
|
623
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
624
|
-
return;
|
|
625
|
-
dbg(`session_start Knip: cache hit (${Math.round((Date.now() - new Date(cached.meta.timestamp).getTime()) / 1000)}s ago)`);
|
|
626
|
-
} else {
|
|
627
|
-
const startMs = Date.now();
|
|
628
|
-
const knipResult = await knipClient.analyze(analysisRoot, getKnipIgnorePatterns(), { projectSeq: runtime.projectSeq });
|
|
629
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
630
|
-
return;
|
|
631
|
-
if (knipResult.success) {
|
|
632
|
-
cacheManager.writeCache("knip", knipResult, analysisRoot, {
|
|
633
|
-
scanDurationMs: Date.now() - startMs
|
|
634
|
-
});
|
|
635
|
-
}
|
|
636
|
-
dbg(`session_start Knip scan done (${Date.now() - startMs}ms)`);
|
|
637
|
-
}
|
|
638
|
-
});
|
|
639
|
-
runHeavyweightTask("jscpd", async () => {
|
|
640
|
-
if (await jscpdClient.ensureAvailable()) {
|
|
641
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
642
|
-
return;
|
|
643
|
-
const isTsProject = nodeFs.existsSync(path.join(analysisRoot, "tsconfig.json"));
|
|
644
|
-
const scannerKey = isTsProject ? "jscpd-ts" : "jscpd";
|
|
645
|
-
const cached = cacheManager.readCache(scannerKey, analysisRoot);
|
|
646
|
-
if (cached) {
|
|
647
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
648
|
-
return;
|
|
649
|
-
dbg(`session_start jscpd: cache hit (${scannerKey})`);
|
|
650
|
-
} else {
|
|
651
|
-
const startMs = Date.now();
|
|
652
|
-
const jscpdResult = await jscpdClient.scan(analysisRoot, undefined, undefined, isTsProject);
|
|
653
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
654
|
-
return;
|
|
655
|
-
if (jscpdResult.success) {
|
|
656
|
-
cacheManager.writeCache(scannerKey, jscpdResult, analysisRoot, {
|
|
657
|
-
scanDurationMs: Date.now() - startMs
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
dbg(`session_start jscpd scan done (${Date.now() - startMs}ms, isTsProject=${isTsProject})`);
|
|
661
|
-
}
|
|
662
|
-
} else {
|
|
663
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
664
|
-
return;
|
|
665
|
-
dbg("session_start jscpd: not available");
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
runHeavyweightTask("dead-code", async () => {
|
|
669
|
-
const applicable = deadCodeClients.filter((c) => c.detect(analysisRoot));
|
|
670
|
-
if (applicable.length === 0)
|
|
671
|
-
return;
|
|
672
|
-
await Promise.all(applicable.map(async (client) => {
|
|
673
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
674
|
-
return;
|
|
675
|
-
const cacheKey = `dead-code-${client.id}`;
|
|
676
|
-
const cached = cacheManager.readCache(cacheKey, analysisRoot);
|
|
677
|
-
if (cached) {
|
|
678
|
-
dbg(`session_start dead-code(${client.id}): cache hit`);
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
const startMs = Date.now();
|
|
682
|
-
const result = await client.analyze(analysisRoot);
|
|
683
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
684
|
-
return;
|
|
685
|
-
if (result.success) {
|
|
686
|
-
cacheManager.writeCache(cacheKey, result, analysisRoot, {
|
|
687
|
-
scanDurationMs: Date.now() - startMs
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
logDeadCodeScan({
|
|
691
|
-
language: client.language,
|
|
692
|
-
success: result.success,
|
|
693
|
-
cached: false,
|
|
694
|
-
unusedExports: result.unusedExports.length,
|
|
695
|
-
unusedFiles: result.unusedFiles.length,
|
|
696
|
-
unusedDeps: result.unusedDeps.length,
|
|
697
|
-
unlistedDeps: result.unlistedDeps.length,
|
|
698
|
-
durationMs: result.durationMs ?? Date.now() - startMs,
|
|
699
|
-
...!result.success && { reason: result.summary }
|
|
700
|
-
});
|
|
701
|
-
dbg(`session_start dead-code(${client.id}) done (${Date.now() - startMs}ms, ${deadCodeIssueCount(result)} issues)`);
|
|
702
|
-
}));
|
|
703
|
-
});
|
|
704
|
-
runHeavyweightTask("govulncheck", async () => {
|
|
705
|
-
if (!GovulncheckClient.hasGoModule(analysisRoot)) {
|
|
706
|
-
dbg("session_start govulncheck: no go.mod — skipped");
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
if (!await govulncheckClient.ensureAvailable()) {
|
|
710
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
711
|
-
return;
|
|
712
|
-
dbg("session_start govulncheck: not installed (go install golang.org/x/vuln/cmd/govulncheck@latest)");
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
716
|
-
return;
|
|
717
|
-
const cached = cacheManager.readCache("govulncheck", analysisRoot);
|
|
718
|
-
if (cached) {
|
|
719
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
720
|
-
return;
|
|
721
|
-
dbg(`session_start govulncheck: cache hit (${cached.data.findings.length} findings)`);
|
|
722
|
-
return;
|
|
723
|
-
}
|
|
724
|
-
const startMs = Date.now();
|
|
725
|
-
const result = await govulncheckClient.analyze(analysisRoot);
|
|
726
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
727
|
-
return;
|
|
728
|
-
if (result.success) {
|
|
729
|
-
cacheManager.writeCache("govulncheck", result, analysisRoot, {
|
|
730
|
-
scanDurationMs: Date.now() - startMs
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
dbg(`session_start govulncheck: ${result.findings.length} reachable findings (${Date.now() - startMs}ms)`);
|
|
734
|
-
});
|
|
735
|
-
runHeavyweightTask("gitleaks", async () => {
|
|
736
|
-
if (!GitleaksClient.hasGitleaksSignal(analysisRoot)) {
|
|
737
|
-
dbg("session_start gitleaks: no opt-in signal — skipped");
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
if (!await gitleaksClient.ensureAvailable()) {
|
|
741
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
742
|
-
return;
|
|
743
|
-
dbg("session_start gitleaks: not available (install failed?)");
|
|
744
|
-
return;
|
|
745
|
-
}
|
|
746
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
747
|
-
return;
|
|
748
|
-
const cached = cacheManager.readCache("gitleaks", analysisRoot);
|
|
749
|
-
if (cached) {
|
|
750
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
751
|
-
return;
|
|
752
|
-
dbg(`session_start gitleaks: cache hit (${cached.data.findings.length} findings)`);
|
|
753
|
-
return;
|
|
754
|
-
}
|
|
755
|
-
const startMs = Date.now();
|
|
756
|
-
const result = await gitleaksClient.scan(analysisRoot);
|
|
757
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
758
|
-
return;
|
|
759
|
-
if (result.success) {
|
|
760
|
-
cacheManager.writeCache("gitleaks", result, analysisRoot, {
|
|
761
|
-
scanDurationMs: Date.now() - startMs
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
dbg(`session_start gitleaks: ${result.findings.length} findings (${Date.now() - startMs}ms)`);
|
|
765
|
-
});
|
|
766
|
-
runHeavyweightTask("opengrep", async () => {
|
|
767
|
-
if (!await opengrepClient.ensureAvailable()) {
|
|
768
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
769
|
-
return;
|
|
770
|
-
dbg("session_start opengrep: not available (install failed?)");
|
|
771
|
-
return;
|
|
772
|
-
}
|
|
773
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
774
|
-
return;
|
|
775
|
-
const cached = cacheManager.readCache("opengrep", analysisRoot);
|
|
776
|
-
if (cached) {
|
|
777
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
778
|
-
return;
|
|
779
|
-
dbg(`session_start opengrep: cache hit (${cached.data.findings.length} findings)`);
|
|
780
|
-
return;
|
|
781
|
-
}
|
|
782
|
-
const startMs = Date.now();
|
|
783
|
-
const result = await opengrepClient.scan(analysisRoot);
|
|
784
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
785
|
-
return;
|
|
786
|
-
if (result.success) {
|
|
787
|
-
cacheManager.writeCache("opengrep", result, analysisRoot, {
|
|
788
|
-
scanDurationMs: Date.now() - startMs
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
dbg(`session_start opengrep: ${result.findings.length} findings (${Date.now() - startMs}ms)`);
|
|
792
|
-
});
|
|
793
|
-
runHeavyweightTask("madge", async () => {
|
|
794
|
-
if (!await depChecker.ensureAvailable()) {
|
|
795
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
796
|
-
return;
|
|
797
|
-
dbg("session_start madge: not available");
|
|
798
|
-
return;
|
|
799
|
-
}
|
|
800
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
801
|
-
return;
|
|
802
|
-
const cached = cacheManager.readCache("madge", analysisRoot);
|
|
803
|
-
if (cached) {
|
|
804
|
-
dbg(`session_start madge: cache hit (${cached.data.circular.length} cycles)`);
|
|
805
|
-
return;
|
|
806
|
-
}
|
|
807
|
-
const startMs = Date.now();
|
|
808
|
-
const result = await depChecker.scanProject(analysisRoot);
|
|
809
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
810
|
-
return;
|
|
811
|
-
cacheManager.writeCache("madge", result, analysisRoot, {
|
|
812
|
-
scanDurationMs: Date.now() - startMs
|
|
813
|
-
});
|
|
814
|
-
dbg(`session_start madge: ${result.circular.length} circular dependency chain(s) (${Date.now() - startMs}ms)`);
|
|
815
|
-
});
|
|
816
|
-
runHeavyweightTask("trivy", async () => {
|
|
817
|
-
if (!TrivyClient.shouldScan(analysisRoot)) {
|
|
818
|
-
dbg("session_start trivy: not enabled / no dependency manifest — skipped");
|
|
819
|
-
return;
|
|
820
|
-
}
|
|
821
|
-
if (!await trivyClient.ensureAvailable()) {
|
|
822
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
823
|
-
return;
|
|
824
|
-
dbg("session_start trivy: not available (install failed?)");
|
|
825
|
-
return;
|
|
826
|
-
}
|
|
827
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
828
|
-
return;
|
|
829
|
-
const cached = cacheManager.readCache("trivy", analysisRoot);
|
|
830
|
-
if (cached) {
|
|
831
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
832
|
-
return;
|
|
833
|
-
dbg(`session_start trivy: cache hit (${cached.data.findings.length} findings)`);
|
|
834
|
-
return;
|
|
835
|
-
}
|
|
836
|
-
const startMs = Date.now();
|
|
837
|
-
const result = await trivyClient.scan(analysisRoot);
|
|
838
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
839
|
-
return;
|
|
840
|
-
if (result.success) {
|
|
841
|
-
cacheManager.writeCache("trivy", result, analysisRoot, {
|
|
842
|
-
scanDurationMs: Date.now() - startMs
|
|
843
|
-
});
|
|
844
|
-
}
|
|
845
|
-
dbg(`session_start trivy: ${result.findings.length} CVE findings (${Date.now() - startMs}ms)`);
|
|
846
|
-
});
|
|
847
|
-
let callGraphIdentity;
|
|
848
|
-
const callGraphTask = runTask("call-graph", async () => {
|
|
849
|
-
const { FactStore } = await import("./dispatch/fact-store.js");
|
|
850
|
-
const { buildOrUpdateGraph, extractSymbolsAndRefsFromGraph, getReviewGraphCacheIdentity } = await import("./review-graph/builder.js");
|
|
851
|
-
const { buildCallGraph, saveCallGraph, loadCallGraph } = await import("./call-graph.js");
|
|
852
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
853
|
-
return;
|
|
854
|
-
const startMs = Date.now();
|
|
855
|
-
const sessionFacts = new FactStore("runtime-session-call-graph");
|
|
856
|
-
const graph = await buildOrUpdateGraph(analysisRoot, [], sessionFacts);
|
|
857
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
858
|
-
return;
|
|
859
|
-
const identity = getReviewGraphCacheIdentity(analysisRoot, graph);
|
|
860
|
-
if (!identity) {
|
|
861
|
-
dbg("session_start call-graph: canonical review-graph identity unavailable");
|
|
862
|
-
return;
|
|
863
|
-
}
|
|
864
|
-
callGraphIdentity = {
|
|
865
|
-
reviewGraphVersion: identity.version,
|
|
866
|
-
reviewGraphSignature: identity.signature
|
|
867
|
-
};
|
|
868
|
-
const cached = loadCallGraph(snapshotRoot, {
|
|
869
|
-
reviewGraphVersion: identity.version,
|
|
870
|
-
reviewGraphSignature: identity.signature
|
|
871
|
-
});
|
|
872
|
-
if (cached) {
|
|
873
|
-
runtime.callGraph = cached.graph;
|
|
874
|
-
dbg(`session_start call-graph: loaded from cache (${cached.graph.edges.length} edges, ${cached.graph.callers.size} callee entries, ${Date.now() - startMs}ms)`);
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
877
|
-
const { allSymbols, allRefs, coverage } = extractSymbolsAndRefsFromGraph(graph);
|
|
878
|
-
const callGraph = buildCallGraph(allSymbols, allRefs, coverage);
|
|
879
|
-
runtime.callGraph = callGraph;
|
|
880
|
-
saveCallGraph(snapshotRoot, callGraph, {
|
|
881
|
-
reviewGraphVersion: identity.version,
|
|
882
|
-
reviewGraphSignature: identity.signature
|
|
883
|
-
});
|
|
884
|
-
dbg(`session_start call-graph: built ${callGraph.edges.length} edges, ${callGraph.callers.size} callee entries (${Date.now() - startMs}ms)`);
|
|
885
|
-
});
|
|
886
|
-
runTask("codebase-model", async () => {
|
|
887
|
-
await callGraphTask;
|
|
888
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
889
|
-
return;
|
|
890
|
-
if (!runtime.callGraph)
|
|
891
|
-
return;
|
|
892
|
-
const { buildCodebaseModel, saveCodebaseModel, DEFAULT_CODEBASE_MODEL_TOKEN_BUDGET } = await import("./codebase-model.js");
|
|
893
|
-
if (!callGraphIdentity)
|
|
894
|
-
return;
|
|
895
|
-
const model = buildCodebaseModel(runtime.callGraph, analysisRoot, DEFAULT_CODEBASE_MODEL_TOKEN_BUDGET, callGraphIdentity);
|
|
896
|
-
saveCodebaseModel(snapshotRoot, model);
|
|
897
|
-
const top3 = model.entries.slice(0, 3).map((e) => e.name).join(", ");
|
|
898
|
-
dbg(`session_start codebase-model: ${model.entries.length} entries, ${model.totalTokens} tokens, top symbols: ${top3 || "(none)"}`);
|
|
899
|
-
});
|
|
900
|
-
runTask("ast-grep-exports", async () => {
|
|
901
|
-
if (await astGrepClient.ensureAvailable()) {
|
|
902
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
903
|
-
return;
|
|
904
|
-
const exports = await astGrepClient.scanExports(analysisRoot, "typescript");
|
|
905
|
-
if (!runtime.isCurrentSession(sessionGeneration))
|
|
906
|
-
return;
|
|
907
|
-
dbg(`session_start exports scan: ${exports.size} functions found`);
|
|
908
|
-
for (const [name, file] of exports) {
|
|
909
|
-
runtime.cachedExports.set(name, file);
|
|
910
|
-
}
|
|
911
|
-
saveRuntimeProjectSnapshot({ cwd: snapshotRoot, runtime, dbg });
|
|
912
|
-
}
|
|
913
|
-
});
|
|
914
|
-
runTask("word-index", async () => {
|
|
915
|
-
await buildOrRefreshWordIndex({
|
|
916
|
-
runtime,
|
|
917
|
-
sessionGeneration,
|
|
918
|
-
analysisRoot,
|
|
919
|
-
snapshotRoot,
|
|
920
|
-
dbg
|
|
921
|
-
});
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
|
-
function scheduleDeferredToolProbes(deps, languageProfile, startupDefaults, startupScansWillRun, dbg) {
|
|
925
|
-
(async () => {
|
|
926
|
-
const resolved = await demandBootstrapDeps(deps, "session-start-tool-probes");
|
|
927
|
-
if (!resolved) {
|
|
928
|
-
dbg("session_start tools: analyzer bootstrap unavailable — no probes");
|
|
929
|
-
return;
|
|
930
|
-
}
|
|
931
|
-
scheduleDeferredToolProbesWithClients(resolved, languageProfile, startupDefaults, startupScansWillRun, dbg);
|
|
932
|
-
})();
|
|
933
|
-
}
|
|
934
|
-
function scheduleDeferredToolProbesWithClients(deps, languageProfile, startupDefaults, startupScansWillRun, dbg) {
|
|
935
|
-
const { biomeClient, ruffClient, depChecker } = deps;
|
|
936
|
-
const defaultTools = new Set(startupDefaults);
|
|
937
|
-
const probes = [];
|
|
938
|
-
if (languageProfile.present.jsts && !defaultTools.has("biome")) {
|
|
939
|
-
probes.push(["biome", () => biomeClient.ensureAvailable()]);
|
|
940
|
-
}
|
|
941
|
-
if (languageProfile.present.python && !defaultTools.has("ruff")) {
|
|
942
|
-
probes.push(["ruff", () => ruffClient.ensureAvailable()]);
|
|
943
|
-
}
|
|
944
|
-
if (startupScansWillRun) {
|
|
945
|
-
probes.push(["madge", () => depChecker.ensureAvailable()]);
|
|
946
|
-
}
|
|
947
|
-
if (probes.length === 0) {
|
|
948
|
-
dbg("session_start tools: no deferred availability probes needed");
|
|
949
|
-
return;
|
|
950
|
-
}
|
|
951
|
-
(async () => {
|
|
952
|
-
const warmStart = Date.now();
|
|
953
|
-
const results = await Promise.all(probes.map(async ([name, run]) => {
|
|
954
|
-
try {
|
|
955
|
-
return [name, await run()];
|
|
956
|
-
} catch (err) {
|
|
957
|
-
dbg(`session_start: ${name} availability check failed: ${err}`);
|
|
958
|
-
return [name, false];
|
|
959
|
-
}
|
|
960
|
-
}));
|
|
961
|
-
const summary = results.map(([name, ready]) => `${name}=${ready}`).join(" ");
|
|
962
|
-
dbg(`session_start tools (deferred probes complete, ${Date.now() - warmStart}ms): ${summary}`);
|
|
963
|
-
})();
|
|
964
|
-
}
|
|
965
|
-
export const SESSION_START_GUIDANCE = [
|
|
966
|
-
`\uD83D\uDCCC dm-lens active — automated checks run on every edit/write; blocking errors (including pre-existing) show inline and must be fixed.
|
|
967
|
-
` + `Key tools (see each tool's own description for args):
|
|
968
|
-
` + `• lens_diagnostics — source=session reads cache; empty cache ≠ clean; use source=lsp scope=paths for changed files with absent or stale findings (aggregate hosts: lens(action=diagnostics)).
|
|
969
|
-
` + `• symbol_search → module_report → read_symbol/read_enclosing — ranked identifier search, then navigable outline/callback handles + exact body reads; cheaper than reading a whole file before editing.
|
|
970
|
-
` + "• Situational (activate via dm_lens_activate_tools): lsp_navigation, ast_grep_search, ast_grep_replace. Use ast_grep_search with dump=true to inspect AST nodes."
|
|
971
|
-
];
|
|
972
|
-
export async function handleSessionStart(deps) {
|
|
973
|
-
resetDegradationLedger();
|
|
974
|
-
resetAnalyzerBootstrapSessionState();
|
|
975
|
-
resetProjectDataDirSessionState();
|
|
976
|
-
resetTestRunnerDelivery();
|
|
977
|
-
resetLspMutationNoBridgeDbgLatch();
|
|
978
|
-
resetBoundedTelemetry();
|
|
979
|
-
rotateMessageEndAttribution();
|
|
980
|
-
const handlerEnteredAt = Date.now();
|
|
981
|
-
const sessionStartMs = deps.sessionStartFiredAt ?? handlerEnteredAt;
|
|
982
|
-
const cwdForTelemetry = deps.ctxCwd ?? process.cwd();
|
|
983
|
-
if (deps.sessionStartFiredAt !== undefined) {
|
|
984
|
-
logLatency({
|
|
985
|
-
type: "phase",
|
|
986
|
-
filePath: cwdForTelemetry,
|
|
987
|
-
phase: "session_start_prehandler",
|
|
988
|
-
startedAt: new Date(deps.sessionStartFiredAt).toISOString(),
|
|
989
|
-
durationMs: (deps.handlerEnteredAt ?? handlerEnteredAt) - deps.sessionStartFiredAt,
|
|
990
|
-
metadata: { reason: deps.sessionReason }
|
|
991
|
-
});
|
|
992
|
-
}
|
|
993
|
-
let startupMode = resolveStartupMode(deps.projectConfig, deps.globalConfig);
|
|
994
|
-
const processGlobals = globalThis;
|
|
995
|
-
const isFirstSessionOfProcess = !processGlobals.__piLensFirstSessionDone;
|
|
996
|
-
if (isFirstSessionOfProcess && process.env.DM_LENS_COLD_START_QUICK !== "0" && !process.env.DM_LENS_STARTUP_MODE && !deps.projectConfig?.startup?.mode && !deps.globalConfig?.startup?.mode) {
|
|
997
|
-
startupMode = deps.startupModeOverride ?? "quick";
|
|
998
|
-
}
|
|
999
|
-
processGlobals.__piLensFirstSessionDone = true;
|
|
1000
|
-
let warmupOwnSnapshotRead;
|
|
1001
|
-
if (startupMode === "quick" && !isPrintMode() && process.env.DM_LENS_COLD_START_QUICK !== "0" && !processGlobals.__piLensWarmupScheduled) {
|
|
1002
|
-
processGlobals.__piLensWarmupScheduled = true;
|
|
1003
|
-
const warmupDelayMs = Number(process.env.DM_LENS_WARMUP_DELAY_MS ?? 2000);
|
|
1004
|
-
const warmupCwd = deps.ctxCwd ?? process.cwd();
|
|
1005
|
-
const warmupDbg = deps.dbg;
|
|
1006
|
-
const warmupTimer = setTimeout(() => {
|
|
1007
|
-
const warmupStartedAt = Date.now();
|
|
1008
|
-
(async () => {
|
|
1009
|
-
try {
|
|
1010
|
-
warmupDbg("warmup: starting background warmup");
|
|
1011
|
-
const scanContextStartedAt = Date.now();
|
|
1012
|
-
const startupScanModule = await import("./startup-scan.js");
|
|
1013
|
-
const languageProfileModule = await import("./language-profile.js");
|
|
1014
|
-
const warmupSnapshotRoot = resolveSnapshotRoot(warmupCwd);
|
|
1015
|
-
const cachedSnapshot = loadProjectSnapshot(warmupSnapshotRoot);
|
|
1016
|
-
warmupOwnSnapshotRead = cachedSnapshot ? {
|
|
1017
|
-
version: cachedSnapshot.version,
|
|
1018
|
-
seq: cachedSnapshot.seq,
|
|
1019
|
-
cachedExports: cachedSnapshot.cachedExports,
|
|
1020
|
-
projectRulesScan: cachedSnapshot.projectRulesScan
|
|
1021
|
-
} : null;
|
|
1022
|
-
const cachedVerdict = cachedSnapshot?.startupScan;
|
|
1023
|
-
let scan;
|
|
1024
|
-
if (cachedVerdict && startupScanModule.isStartupScanVerdictFresh(cachedVerdict)) {
|
|
1025
|
-
scan = { ...cachedVerdict, cwd: path.resolve(warmupCwd) };
|
|
1026
|
-
warmupDbg(`warmup: scan-context reused from cache (canWarm=${scan.canWarmCaches}${scan.reason ? `, reason=${scan.reason}` : ""})`);
|
|
1027
|
-
} else {
|
|
1028
|
-
scan = await startupScanModule.resolveStartupScanContextAsync(warmupCwd);
|
|
1029
|
-
logLatency({
|
|
1030
|
-
type: "phase",
|
|
1031
|
-
phase: "session_start_scan_context_compute",
|
|
1032
|
-
filePath: warmupCwd,
|
|
1033
|
-
startedAt: new Date(scanContextStartedAt).toISOString(),
|
|
1034
|
-
durationMs: Date.now() - scanContextStartedAt,
|
|
1035
|
-
metadata: { mode: "quick-background" }
|
|
1036
|
-
});
|
|
1037
|
-
warmupDbg(`warmup: scan-context done in ${Date.now() - warmupStartedAt}ms (canWarm=${scan.canWarmCaches})`);
|
|
1038
|
-
saveRuntimeProjectSnapshot({
|
|
1039
|
-
cwd: warmupSnapshotRoot,
|
|
1040
|
-
runtime: deps.runtime,
|
|
1041
|
-
startupScan: scan,
|
|
1042
|
-
dbg: warmupDbg
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
logLatency({
|
|
1046
|
-
type: "phase",
|
|
1047
|
-
phase: "warmup_scan_context",
|
|
1048
|
-
filePath: warmupCwd,
|
|
1049
|
-
startedAt: new Date(scanContextStartedAt).toISOString(),
|
|
1050
|
-
durationMs: Date.now() - scanContextStartedAt
|
|
1051
|
-
});
|
|
1052
|
-
if (!scan.canWarmCaches) {
|
|
1053
|
-
warmupDbg(`warmup: skipping language-profile (canWarm=false, reason=${scan.reason ?? "unknown"})`);
|
|
1054
|
-
return;
|
|
1055
|
-
}
|
|
1056
|
-
const languageRoot = scan.projectRoot ?? warmupCwd;
|
|
1057
|
-
const languageProfileStartedAt = Date.now();
|
|
1058
|
-
await languageProfileModule.detectProjectLanguageProfileAsync(languageRoot);
|
|
1059
|
-
warmupDbg(`warmup: language-profile done in ${Date.now() - languageProfileStartedAt}ms`);
|
|
1060
|
-
logLatency({
|
|
1061
|
-
type: "phase",
|
|
1062
|
-
phase: "warmup_language_profile",
|
|
1063
|
-
filePath: warmupCwd,
|
|
1064
|
-
startedAt: new Date(languageProfileStartedAt).toISOString(),
|
|
1065
|
-
durationMs: Date.now() - languageProfileStartedAt
|
|
1066
|
-
});
|
|
1067
|
-
const wordIndexStartedAt = Date.now();
|
|
1068
|
-
const wordIndexResult = await buildOrRefreshWordIndex({
|
|
1069
|
-
runtime: deps.runtime,
|
|
1070
|
-
sessionGeneration: deps.runtime.sessionGeneration,
|
|
1071
|
-
analysisRoot: languageRoot,
|
|
1072
|
-
snapshotRoot: warmupSnapshotRoot,
|
|
1073
|
-
dbg: warmupDbg
|
|
1074
|
-
});
|
|
1075
|
-
warmupDbg(`warmup: word-index done in ${Date.now() - wordIndexStartedAt}ms`);
|
|
1076
|
-
logLatency({
|
|
1077
|
-
type: "phase",
|
|
1078
|
-
phase: "warmup_word_index",
|
|
1079
|
-
filePath: warmupCwd,
|
|
1080
|
-
startedAt: new Date(wordIndexStartedAt).toISOString(),
|
|
1081
|
-
durationMs: Date.now() - wordIndexStartedAt,
|
|
1082
|
-
metadata: wordIndexResult ? { ...wordIndexResult } : undefined
|
|
1083
|
-
});
|
|
1084
|
-
const lspPrewarmStartedAt = Date.now();
|
|
1085
|
-
if (deps.getFlag("no-lsp")) {
|
|
1086
|
-
warmupDbg("warmup: skipping LSP pre-warm (no-lsp)");
|
|
1087
|
-
} else if (isSubagentSession()) {
|
|
1088
|
-
warmupDbg("warmup: skipping LSP pre-warm (subagent session)");
|
|
1089
|
-
} else if (isWarmAttached()) {
|
|
1090
|
-
warmupDbg("warmup: skipping LSP pre-warm (attached to incumbent)");
|
|
1091
|
-
} else {
|
|
1092
|
-
const lspConfig = await loadLSPConfig(warmupCwd).catch(() => ({
|
|
1093
|
-
warmFiles: []
|
|
1094
|
-
}));
|
|
1095
|
-
const warmFiles = lspConfig.warmFiles ?? [];
|
|
1096
|
-
if (warmFiles.length > 0) {
|
|
1097
|
-
await igniteWarmFiles(warmupCwd, warmFiles, deps.runtime, deps.runtime.sessionGeneration, warmupDbg);
|
|
1098
|
-
} else {
|
|
1099
|
-
await igniteDominantLanguageWarm(languageRoot, deps.runtime, deps.runtime.sessionGeneration, warmupDbg);
|
|
1100
|
-
}
|
|
1101
|
-
logLatency({
|
|
1102
|
-
type: "phase",
|
|
1103
|
-
phase: "warmup_lsp_prewarm",
|
|
1104
|
-
filePath: warmupCwd,
|
|
1105
|
-
startedAt: new Date(lspPrewarmStartedAt).toISOString(),
|
|
1106
|
-
durationMs: Date.now() - lspPrewarmStartedAt
|
|
1107
|
-
});
|
|
1108
|
-
warmupDbg(`warmup: lsp-prewarm done in ${Date.now() - lspPrewarmStartedAt}ms`);
|
|
1109
|
-
}
|
|
1110
|
-
warmupDbg(`warmup: total ${Date.now() - warmupStartedAt}ms`);
|
|
1111
|
-
} catch (err) {
|
|
1112
|
-
warmupDbg(`warmup: error ${err}`);
|
|
1113
|
-
processGlobals.__piLensWarmupScheduled = false;
|
|
1114
|
-
} finally {
|
|
1115
|
-
logLatency({
|
|
1116
|
-
type: "phase",
|
|
1117
|
-
phase: "warmup_total",
|
|
1118
|
-
filePath: warmupCwd,
|
|
1119
|
-
startedAt: new Date(warmupStartedAt).toISOString(),
|
|
1120
|
-
durationMs: Date.now() - warmupStartedAt
|
|
1121
|
-
});
|
|
1122
|
-
}
|
|
1123
|
-
})();
|
|
1124
|
-
}, warmupDelayMs);
|
|
1125
|
-
warmupTimer.unref?.();
|
|
1126
|
-
}
|
|
1127
|
-
const allowBootstrapTasks = startupMode === "full";
|
|
1128
|
-
const quickMode = startupMode === "quick";
|
|
1129
|
-
const { ctxCwd, getFlag, notify, dbg, log, runtime, cacheManager, ensureTool, cleanStaleTsBuildInfo, resetDispatchBaselines, resetLSPService } = deps;
|
|
1130
|
-
let _phaseT = Date.now();
|
|
1131
|
-
const phase = (name) => {
|
|
1132
|
-
dbg(`session_start phase ${name}: ${Date.now() - _phaseT}ms`);
|
|
1133
|
-
_phaseT = Date.now();
|
|
1134
|
-
};
|
|
1135
|
-
deps.bootstrap.peek()?.metricsClient.reset();
|
|
1136
|
-
getDiagnosticTracker().reset();
|
|
1137
|
-
clearFileTimeSessions();
|
|
1138
|
-
runtime.complexityBaselines.clear();
|
|
1139
|
-
resetDispatchBaselines(ctxCwd);
|
|
1140
|
-
resetWorkspaceTopology();
|
|
1141
|
-
resetOpaqueMutationState();
|
|
1142
|
-
resetObservedMutationNet();
|
|
1143
|
-
resetMutationAttribution();
|
|
1144
|
-
primePersistedMutationAttribution(ctxCwd);
|
|
1145
|
-
resetPendingAuxiliaryCoverage();
|
|
1146
|
-
resetSafeSpawnWindowsCommandCache();
|
|
1147
|
-
resetDispatchAvailabilityState();
|
|
1148
|
-
resetObservedRunnerLatency();
|
|
1149
|
-
resetPendingRunnerFindings();
|
|
1150
|
-
resetSpawnTimeoutCooldowns();
|
|
1151
|
-
clearFormatterCache();
|
|
1152
|
-
resetZizmorTokenAvailability();
|
|
1153
|
-
resetGoAvailability();
|
|
1154
|
-
resetRustAvailability();
|
|
1155
|
-
resetPsScriptAnalyzerAvailability();
|
|
1156
|
-
resetInstallRetryLatches();
|
|
1157
|
-
resetLazyInstallAttempts();
|
|
1158
|
-
resetDirectLspCommandAvailability();
|
|
1159
|
-
resetLSPCaseSensitivityState();
|
|
1160
|
-
resetResolvedPathCache();
|
|
1161
|
-
_resetPackageManagerCache();
|
|
1162
|
-
resetManagedToolRefreshSession();
|
|
1163
|
-
resetSmellsSessionState();
|
|
1164
|
-
resetSituationalToolTelemetry();
|
|
1165
|
-
resetWorkspaceDiagnosticsCacheSession(sessionStartMs);
|
|
1166
|
-
deps.bootstrap.peek()?.knipClient.resetSessionState?.();
|
|
1167
|
-
resetCascadeTierSessionState();
|
|
1168
|
-
runtime.resetForSession(sessionStartMs);
|
|
1169
|
-
logLatency({
|
|
1170
|
-
type: "phase",
|
|
1171
|
-
phase: "session_start_runtime_reset",
|
|
1172
|
-
filePath: ctxCwd ?? process.cwd(),
|
|
1173
|
-
startedAt: new Date(handlerEnteredAt).toISOString(),
|
|
1174
|
-
durationMs: Date.now() - handlerEnteredAt,
|
|
1175
|
-
metadata: { mode: startupMode, reason: deps.sessionReason }
|
|
1176
|
-
});
|
|
1177
|
-
const cleanupCwd = ctxCwd ?? process.cwd();
|
|
1178
|
-
setImmediate(() => {
|
|
1179
|
-
const logCleanupStartedAt = Date.now();
|
|
1180
|
-
try {
|
|
1181
|
-
const logCleanup = runLogCleanup(dbg);
|
|
1182
|
-
logLatency({
|
|
1183
|
-
type: "phase",
|
|
1184
|
-
phase: "session_start_log_cleanup",
|
|
1185
|
-
filePath: cleanupCwd,
|
|
1186
|
-
startedAt: new Date(logCleanupStartedAt).toISOString(),
|
|
1187
|
-
durationMs: Date.now() - logCleanupStartedAt,
|
|
1188
|
-
metadata: {
|
|
1189
|
-
mode: startupMode,
|
|
1190
|
-
reason: deps.sessionReason,
|
|
1191
|
-
deferred: true
|
|
1192
|
-
}
|
|
1193
|
-
});
|
|
1194
|
-
if (logCleanup.cleaned > 0 || logCleanup.rotated > 0) {
|
|
1195
|
-
notify(`\uD83E\uDDF9 ${logCleanup.report}`, "info");
|
|
1196
|
-
}
|
|
1197
|
-
} catch (err) {
|
|
1198
|
-
dbg(`session_start: deferred log cleanup failed: ${err}`);
|
|
1199
|
-
}
|
|
1200
|
-
});
|
|
1201
|
-
dbg(`session_start startup mode: ${startupMode}`);
|
|
1202
|
-
if (!getFlag("no-lsp")) {
|
|
1203
|
-
resetLSPService({ fast: true, reason: "session_start" });
|
|
1204
|
-
dbg("session_start: LSP service reset");
|
|
1205
|
-
dbg("session_start: phase0 workspace diagnostics observation enabled (capability probe only)");
|
|
1206
|
-
}
|
|
1207
|
-
const hasWorkspaceCwd = typeof ctxCwd === "string" && ctxCwd.length > 0;
|
|
1208
|
-
const cwd = ctxCwd ?? process.cwd();
|
|
1209
|
-
const projectDataDir = getProjectDataDir(cwd);
|
|
1210
|
-
for (const migration of drainProjectDataDirMigrations()) {
|
|
1211
|
-
const targetName = path.basename(migration.to);
|
|
1212
|
-
const hash = targetName.match(/([0-9a-f]{8})$/)?.[1] ?? "unknown";
|
|
1213
|
-
recordDegradationOnce({
|
|
1214
|
-
kind: "data_dir_migrated",
|
|
1215
|
-
subject: hash,
|
|
1216
|
-
reason: migration.outcome === "renamed" ? "using hashed directory after renaming legacy directory" : migration.outcome === "coexisting" ? "using hashed directory because legacy and hashed directories both exist" : migration.outcome === "rename-failed" ? "using legacy directory after hashed-directory rename failure" : "using resolved directory after realpath fallback"
|
|
1217
|
-
});
|
|
1218
|
-
}
|
|
1219
|
-
const globalDir = getGlobalDmLensDir();
|
|
1220
|
-
sweepAtomicWriteStages([
|
|
1221
|
-
projectDataDir,
|
|
1222
|
-
path.join(projectDataDir, "cache"),
|
|
1223
|
-
path.join(projectDataDir, "sessions"),
|
|
1224
|
-
globalDir,
|
|
1225
|
-
path.join(globalDir, "bin"),
|
|
1226
|
-
path.join(globalDir, "tools")
|
|
1227
|
-
]).catch(() => {});
|
|
1228
|
-
if (quickMode) {
|
|
1229
|
-
runtime.projectRoot = cwd;
|
|
1230
|
-
const sequenceReadStartedAt = Date.now();
|
|
1231
|
-
const snapshotRoot = resolveSnapshotRoot(cwd);
|
|
1232
|
-
const { latestSeq, timedOut } = await readSequenceWithBudget({
|
|
1233
|
-
snapshotRoot,
|
|
1234
|
-
base: snapshotSequenceBase(snapshotRoot),
|
|
1235
|
-
cwd,
|
|
1236
|
-
runtime,
|
|
1237
|
-
sessionGeneration: runtime.sessionGeneration,
|
|
1238
|
-
dbg,
|
|
1239
|
-
onDeferredSequenceResolved: retroactivelyHydrateAfterDeferredSequence({
|
|
1240
|
-
getWarmupOwnSnapshotRead: () => warmupOwnSnapshotRead,
|
|
1241
|
-
snapshotRoot,
|
|
1242
|
-
runtime,
|
|
1243
|
-
dbg
|
|
1244
|
-
})
|
|
1245
|
-
});
|
|
1246
|
-
logLatency({
|
|
1247
|
-
type: "phase",
|
|
1248
|
-
phase: "session_start_sequence_read",
|
|
1249
|
-
filePath: cwd,
|
|
1250
|
-
startedAt: new Date(sequenceReadStartedAt).toISOString(),
|
|
1251
|
-
durationMs: Date.now() - sequenceReadStartedAt,
|
|
1252
|
-
metadata: { entries: latestSeq.fileSeqByPath.size, timedOut }
|
|
1253
|
-
});
|
|
1254
|
-
if (timedOut) {
|
|
1255
|
-
recordSnapshotSequenceTimeout({
|
|
1256
|
-
snapshotRoot,
|
|
1257
|
-
snapshotPath: getProjectSnapshotPath(snapshotRoot)
|
|
1258
|
-
});
|
|
1259
|
-
}
|
|
1260
|
-
runtime.seedProjectSequence?.(latestSeq.projectSeq, latestSeq.fileSeqByPath);
|
|
1261
|
-
const effectiveSeq = runtime.projectSeq ?? latestSeq.projectSeq;
|
|
1262
|
-
dbg(`session_start sequence: projectSeq=${effectiveSeq} fileSeqEntries=${latestSeq.fileSeqByPath.size}`);
|
|
1263
|
-
const freshnessSeq = timedOut ? UNKNOWN_PROJECT_SEQ : effectiveSeq;
|
|
1264
|
-
const snapshotLoadStartedAt = Date.now();
|
|
1265
|
-
const snapshotPath = getProjectSnapshotPath(snapshotRoot);
|
|
1266
|
-
let snapshotBytes = 0;
|
|
1267
|
-
try {
|
|
1268
|
-
snapshotBytes = nodeFs.statSync(snapshotPath).size;
|
|
1269
|
-
} catch {}
|
|
1270
|
-
const snapshotBodyPresent = nodeFs.existsSync(snapshotPath) || nodeFs.existsSync(getProjectSnapshotLegacyPath(snapshotRoot));
|
|
1271
|
-
const snapshotGate = loadSnapshotBodyUnlessStale({
|
|
1272
|
-
root: snapshotRoot,
|
|
1273
|
-
currentProjectSeq: freshnessSeq,
|
|
1274
|
-
dbg
|
|
1275
|
-
});
|
|
1276
|
-
const snapshot = snapshotGate.snapshot;
|
|
1277
|
-
const snapshotFresh = isProjectSnapshotFresh(snapshot, freshnessSeq);
|
|
1278
|
-
const snapshotMissReason = describeSnapshotMiss(snapshot, freshnessSeq, {
|
|
1279
|
-
skippedStale: snapshotGate.skippedStale,
|
|
1280
|
-
bodyPresent: snapshotBodyPresent
|
|
1281
|
-
});
|
|
1282
|
-
logLatency({
|
|
1283
|
-
type: "phase",
|
|
1284
|
-
phase: "session_start_snapshot_load",
|
|
1285
|
-
filePath: cwd,
|
|
1286
|
-
startedAt: new Date(snapshotLoadStartedAt).toISOString(),
|
|
1287
|
-
durationMs: Date.now() - snapshotLoadStartedAt,
|
|
1288
|
-
metadata: {
|
|
1289
|
-
bytes: snapshotBytes,
|
|
1290
|
-
fresh: snapshotFresh,
|
|
1291
|
-
seq: snapshot?.seq ?? null,
|
|
1292
|
-
reason: snapshotFresh ? undefined : snapshotMissReason,
|
|
1293
|
-
...snapshotGate.skippedStale ? { skippedStale: true } : {},
|
|
1294
|
-
...timedOut ? { sequenceUnknown: true } : {}
|
|
1295
|
-
}
|
|
1296
|
-
});
|
|
1297
|
-
logProjectSnapshotProbe({
|
|
1298
|
-
dbg,
|
|
1299
|
-
root: snapshotRoot,
|
|
1300
|
-
currentProjectSeq: freshnessSeq,
|
|
1301
|
-
snapshot,
|
|
1302
|
-
missReason: snapshotMissReason
|
|
1303
|
-
});
|
|
1304
|
-
if (snapshotFresh) {
|
|
1305
|
-
hydrateRuntimeFromProjectSnapshot(runtime, snapshot);
|
|
1306
|
-
}
|
|
1307
|
-
const quickTools = [];
|
|
1308
|
-
if (!getFlag("no-lsp")) {
|
|
1309
|
-
quickTools.push("LSP Service");
|
|
1310
|
-
}
|
|
1311
|
-
log(`Active tools: ${quickTools.join(", ")}`);
|
|
1312
|
-
dbg(`session_start tools: ${quickTools.join(", ") || "deferred (quick mode)"}`);
|
|
1313
|
-
dbg("session_start: quick mode active - skipping slow tool probes, language profiling, preinstall, scans, and error debt baseline");
|
|
1314
|
-
logLatency({
|
|
1315
|
-
type: "phase",
|
|
1316
|
-
phase: "session_start_skipped_steps",
|
|
1317
|
-
filePath: cwd,
|
|
1318
|
-
durationMs: 0,
|
|
1319
|
-
metadata: {
|
|
1320
|
-
mode: startupMode,
|
|
1321
|
-
reason: deps.sessionReason,
|
|
1322
|
-
steps: [
|
|
1323
|
-
"slow_tool_probes",
|
|
1324
|
-
"language_profiling",
|
|
1325
|
-
"tool_preinstall",
|
|
1326
|
-
"startup_scans",
|
|
1327
|
-
"error_debt_baseline"
|
|
1328
|
-
]
|
|
1329
|
-
}
|
|
1330
|
-
});
|
|
1331
|
-
const totalDurationMs = Date.now() - sessionStartMs;
|
|
1332
|
-
dbg(`session_start total: ${totalDurationMs}ms (interactive path)`);
|
|
1333
|
-
logLatency({
|
|
1334
|
-
type: "phase",
|
|
1335
|
-
phase: "session_start_total",
|
|
1336
|
-
filePath: cwd,
|
|
1337
|
-
startedAt: new Date(sessionStartMs).toISOString(),
|
|
1338
|
-
durationMs: totalDurationMs,
|
|
1339
|
-
metadata: {
|
|
1340
|
-
mode: startupMode,
|
|
1341
|
-
reason: deps.sessionReason,
|
|
1342
|
-
classification: deps.sessionStartClassification,
|
|
1343
|
-
sameRoot: deps.sessionStartSameRoot ?? "unknown"
|
|
1344
|
-
}
|
|
1345
|
-
});
|
|
1346
|
-
logHostReadyDelay(deps, cwd);
|
|
1347
|
-
emitSmellsSessionStartLine(dbg, sessionStartMs);
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
const tools = [];
|
|
1351
|
-
if (!getFlag("no-lsp"))
|
|
1352
|
-
tools.push("LSP Service");
|
|
1353
|
-
if (allowBootstrapTasks && !getFlag("no-lsp")) {
|
|
1354
|
-
const cleaned = cleanStaleTsBuildInfo(ctxCwd ?? process.cwd());
|
|
1355
|
-
if (cleaned.length > 0) {
|
|
1356
|
-
notify(`\uD83E\uDDF9 Deleted stale TypeScript build cache (${cleaned.map((f) => path.basename(f)).join(", ")}) — phantom errors suppressed.`, "warning");
|
|
1357
|
-
dbg(`session_start: cleaned stale tsbuildinfo: ${cleaned.join(", ")}`);
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
const sessionGeneration = runtime.sessionGeneration;
|
|
1361
|
-
const sequenceReadStartedAt = Date.now();
|
|
1362
|
-
const snapshotRoot = resolveSnapshotRoot(cwd);
|
|
1363
|
-
const { latestSeq, timedOut } = await readSequenceWithBudget({
|
|
1364
|
-
snapshotRoot,
|
|
1365
|
-
base: snapshotSequenceBase(snapshotRoot),
|
|
1366
|
-
cwd,
|
|
1367
|
-
runtime,
|
|
1368
|
-
sessionGeneration,
|
|
1369
|
-
dbg
|
|
1370
|
-
});
|
|
1371
|
-
logLatency({
|
|
1372
|
-
type: "phase",
|
|
1373
|
-
phase: "session_start_sequence_read",
|
|
1374
|
-
filePath: cwd,
|
|
1375
|
-
startedAt: new Date(sequenceReadStartedAt).toISOString(),
|
|
1376
|
-
durationMs: Date.now() - sequenceReadStartedAt,
|
|
1377
|
-
metadata: { entries: latestSeq.fileSeqByPath.size, timedOut }
|
|
1378
|
-
});
|
|
1379
|
-
if (timedOut) {
|
|
1380
|
-
recordSnapshotSequenceTimeout({
|
|
1381
|
-
snapshotRoot,
|
|
1382
|
-
snapshotPath: getProjectSnapshotPath(snapshotRoot)
|
|
1383
|
-
});
|
|
1384
|
-
}
|
|
1385
|
-
runtime.seedProjectSequence?.(latestSeq.projectSeq, latestSeq.fileSeqByPath);
|
|
1386
|
-
const effectiveSeq = runtime.projectSeq ?? latestSeq.projectSeq;
|
|
1387
|
-
dbg(`session_start sequence: projectSeq=${effectiveSeq} fileSeqEntries=${latestSeq.fileSeqByPath.size}`);
|
|
1388
|
-
const freshnessSeq = timedOut ? UNKNOWN_PROJECT_SEQ : effectiveSeq;
|
|
1389
|
-
const snapshotLoadStartedAt = Date.now();
|
|
1390
|
-
const snapshotPath = getProjectSnapshotPath(snapshotRoot);
|
|
1391
|
-
let snapshotBytes = 0;
|
|
1392
|
-
try {
|
|
1393
|
-
snapshotBytes = nodeFs.statSync(snapshotPath).size;
|
|
1394
|
-
} catch {}
|
|
1395
|
-
const snapshotBodyPresent = nodeFs.existsSync(snapshotPath) || nodeFs.existsSync(getProjectSnapshotLegacyPath(snapshotRoot));
|
|
1396
|
-
const snapshotGate = loadSnapshotBodyUnlessStale({
|
|
1397
|
-
root: snapshotRoot,
|
|
1398
|
-
currentProjectSeq: freshnessSeq,
|
|
1399
|
-
dbg
|
|
1400
|
-
});
|
|
1401
|
-
const snapshot = snapshotGate.snapshot;
|
|
1402
|
-
const snapshotFresh = isProjectSnapshotFresh(snapshot, freshnessSeq);
|
|
1403
|
-
const snapshotMissReason = describeSnapshotMiss(snapshot, freshnessSeq, {
|
|
1404
|
-
skippedStale: snapshotGate.skippedStale,
|
|
1405
|
-
bodyPresent: snapshotBodyPresent
|
|
1406
|
-
});
|
|
1407
|
-
logLatency({
|
|
1408
|
-
type: "phase",
|
|
1409
|
-
phase: "session_start_snapshot_load",
|
|
1410
|
-
filePath: cwd,
|
|
1411
|
-
startedAt: new Date(snapshotLoadStartedAt).toISOString(),
|
|
1412
|
-
durationMs: Date.now() - snapshotLoadStartedAt,
|
|
1413
|
-
metadata: {
|
|
1414
|
-
bytes: snapshotBytes,
|
|
1415
|
-
fresh: snapshotFresh,
|
|
1416
|
-
seq: snapshot?.seq ?? null,
|
|
1417
|
-
reason: snapshotFresh ? undefined : snapshotMissReason,
|
|
1418
|
-
...snapshotGate.skippedStale ? { skippedStale: true } : {},
|
|
1419
|
-
...timedOut ? { sequenceUnknown: true } : {}
|
|
1420
|
-
}
|
|
1421
|
-
});
|
|
1422
|
-
logProjectSnapshotProbe({
|
|
1423
|
-
dbg,
|
|
1424
|
-
root: snapshotRoot,
|
|
1425
|
-
currentProjectSeq: freshnessSeq,
|
|
1426
|
-
snapshot,
|
|
1427
|
-
missReason: snapshotMissReason
|
|
1428
|
-
});
|
|
1429
|
-
const freshSnapshot = snapshotFresh ? snapshot : null;
|
|
1430
|
-
if (freshSnapshot) {
|
|
1431
|
-
hydrateRuntimeFromProjectSnapshot(runtime, freshSnapshot);
|
|
1432
|
-
}
|
|
1433
|
-
const cachedStartupScan = freshSnapshot?.startupScan && isStartupScanVerdictFresh(freshSnapshot.startupScan) ? freshSnapshot.startupScan : undefined;
|
|
1434
|
-
const startupScanSource = cachedStartupScan ? "snapshot" : "computed";
|
|
1435
|
-
let startupScan;
|
|
1436
|
-
if (cachedStartupScan) {
|
|
1437
|
-
startupScan = { ...cachedStartupScan, cwd: path.resolve(cwd) };
|
|
1438
|
-
} else {
|
|
1439
|
-
const scanContextStartedAt = Date.now();
|
|
1440
|
-
startupScan = resolveStartupScanContext(cwd);
|
|
1441
|
-
logLatency({
|
|
1442
|
-
type: "phase",
|
|
1443
|
-
phase: "session_start_scan_context_compute",
|
|
1444
|
-
filePath: cwd,
|
|
1445
|
-
startedAt: new Date(scanContextStartedAt).toISOString(),
|
|
1446
|
-
durationMs: Date.now() - scanContextStartedAt,
|
|
1447
|
-
metadata: { mode: startupMode }
|
|
1448
|
-
});
|
|
1449
|
-
}
|
|
1450
|
-
phase("scan-context");
|
|
1451
|
-
dbg(`session_start scan-context source=${startupScanSource}`);
|
|
1452
|
-
const scanRoot = startupScan.projectRoot ?? cwd;
|
|
1453
|
-
const useScanRootForSignals = startupScan.canWarmCaches || startupScan.reason === "too-many-source-files" || startupScan.reason === "too-many-entries";
|
|
1454
|
-
const analysisRoot = useScanRootForSignals ? scanRoot : cwd;
|
|
1455
|
-
runtime.projectRoot = cwd;
|
|
1456
|
-
const languageProfileSource = freshSnapshot?.languageProfile ? "snapshot" : "computed";
|
|
1457
|
-
const languageProfile = freshSnapshot?.languageProfile ? freshSnapshot.languageProfile : detectProjectLanguageProfile(analysisRoot, startupScan.canWarmCaches ? undefined : []);
|
|
1458
|
-
phase("language-profile");
|
|
1459
|
-
dbg(`session_start language-profile source=${languageProfileSource}`);
|
|
1460
|
-
dbg(`session_start cwd: ${cwd}`);
|
|
1461
|
-
dbg(`session_start scan root: ${scanRoot} (warmCaches=${startupScan.canWarmCaches}${startupScan.reason ? `, reason=${startupScan.reason}` : ""})`);
|
|
1462
|
-
dbg(`session_start analysis root: ${analysisRoot}`);
|
|
1463
|
-
dbg(`session_start workspace root: ${runtime.projectRoot}`);
|
|
1464
|
-
dbg(`session_start language profile: ${languageProfile.detectedKinds.join(", ") || "none"}`);
|
|
1465
|
-
dbg(`session_start language counts: ${JSON.stringify(languageProfile.counts)} configured=${JSON.stringify(languageProfile.configured)}`);
|
|
1466
|
-
dbg(`session_start workspace cwd available: ${hasWorkspaceCwd}`);
|
|
1467
|
-
if (useScanRootForSignals && analysisRoot !== cwd) {
|
|
1468
|
-
dbg(`session_start: monorepo analysis root override -> ${analysisRoot}`);
|
|
1469
|
-
}
|
|
1470
|
-
const slowFsVerdict = getSlowFsVerdict(analysisRoot);
|
|
1471
|
-
logLatency({
|
|
1472
|
-
type: "phase",
|
|
1473
|
-
phase: "slow_fs_probe",
|
|
1474
|
-
filePath: analysisRoot,
|
|
1475
|
-
durationMs: 0,
|
|
1476
|
-
metadata: {
|
|
1477
|
-
slow: slowFsVerdict.slow,
|
|
1478
|
-
medianStatMicros: slowFsVerdict.medianStatMicros,
|
|
1479
|
-
samples: slowFsVerdict.samples
|
|
1480
|
-
}
|
|
1481
|
-
});
|
|
1482
|
-
dbg(`session_start slow-fs probe: slow=${slowFsVerdict.slow} medianStatMicros=${slowFsVerdict.medianStatMicros.toFixed(1)} samples=${slowFsVerdict.samples}`);
|
|
1483
|
-
if (slowFsVerdict.slow) {
|
|
1484
|
-
notify(`\uD83D\uDC22 Slow filesystem detected (median ${slowFsVerdict.medianStatMicros.toFixed(0)}µs/stat) — reduced-scan mode engaged (set DM_LENS_ALLOW_SLOW_FS_SCAN=1 to override).`, "warning");
|
|
1485
|
-
}
|
|
1486
|
-
const subagentSession = isSubagentSession();
|
|
1487
|
-
if (isWarmAttached()) {
|
|
1488
|
-
dbg("session_start lsp-warm: skipping pre-warm (attached to incumbent)");
|
|
1489
|
-
} else if (subagentSession) {
|
|
1490
|
-
const identity = getSubagentIdentity();
|
|
1491
|
-
logLatency({
|
|
1492
|
-
type: "phase",
|
|
1493
|
-
phase: "subagent_light_mode",
|
|
1494
|
-
filePath: analysisRoot,
|
|
1495
|
-
durationMs: 0,
|
|
1496
|
-
metadata: {
|
|
1497
|
-
runId: identity?.runId,
|
|
1498
|
-
agentName: identity?.agentName,
|
|
1499
|
-
marker: identity?.marker
|
|
1500
|
-
}
|
|
1501
|
-
});
|
|
1502
|
-
dbg(`session_start subagent light mode: engaged (marker=${identity?.marker ?? "unknown"} runId=${identity?.runId ?? "unknown"} agentName=${identity?.agentName ?? "unknown"})`);
|
|
1503
|
-
}
|
|
1504
|
-
const lensLspEnabled = !getFlag("no-lsp");
|
|
1505
|
-
const startupDefaults = getDefaultStartupTools(languageProfile).filter((tool) => {
|
|
1506
|
-
if ((tool === "typescript-language-server" || tool === "pyright") && !lensLspEnabled) {
|
|
1507
|
-
return false;
|
|
1508
|
-
}
|
|
1509
|
-
return true;
|
|
1510
|
-
});
|
|
1511
|
-
if (!allowBootstrapTasks) {
|
|
1512
|
-
dbg("session_start: skipping tool preinstall (startup mode)");
|
|
1513
|
-
} else if (startupDefaults.length > 0) {
|
|
1514
|
-
dbg(`session_start: pre-install defaults -> ${startupDefaults.join(", ")}`);
|
|
1515
|
-
firePreinstallDefaults(ensureTool, dbg, startupDefaults);
|
|
1516
|
-
} else {
|
|
1517
|
-
dbg("session_start: no language defaults selected for pre-install");
|
|
1518
|
-
}
|
|
1519
|
-
const startupScansEnabled = deps.projectConfig?.startup?.scans?.enabled ?? deps.globalConfig?.startup?.scans?.enabled ?? true;
|
|
1520
|
-
const startupScansWillRun = allowBootstrapTasks && startupScan.canWarmCaches && startupScansEnabled;
|
|
1521
|
-
const jstsHeavyScansWillRun = startupScansWillRun && canRunStartupHeavyScans(languageProfile, "jsts");
|
|
1522
|
-
if (allowBootstrapTasks) {
|
|
1523
|
-
scheduleDeferredToolProbes(deps, languageProfile, startupDefaults, jstsHeavyScansWillRun, dbg);
|
|
1524
|
-
scheduleManagedToolRefresh(dbg);
|
|
1525
|
-
}
|
|
1526
|
-
if (allowBootstrapTasks) {
|
|
1527
|
-
probePrettierInstall(ensureTool, dbg, analysisRoot);
|
|
1528
|
-
} else {
|
|
1529
|
-
dbg("session_start: skipping prettier preinstall probe (startup mode)");
|
|
1530
|
-
}
|
|
1531
|
-
const summaryClients = await deps.bootstrap.request("session-start-tools");
|
|
1532
|
-
const detectedRunner = summaryClients?.testRunnerClient.detectRunner(analysisRoot);
|
|
1533
|
-
phase("test-runner-detect");
|
|
1534
|
-
if (detectedRunner)
|
|
1535
|
-
tools.push(`Test runner (${detectedRunner.runner})`);
|
|
1536
|
-
if (await summaryClients?.goClient.isGoAvailableAsync())
|
|
1537
|
-
tools.push("Go (go vet)");
|
|
1538
|
-
if (await summaryClients?.rustClient.isAvailableAsync())
|
|
1539
|
-
tools.push("Rust (cargo)");
|
|
1540
|
-
log(`Active tools: ${tools.join(", ")}`);
|
|
1541
|
-
dbg(`session_start tools: ${tools.join(", ")}`);
|
|
1542
|
-
const agentStartupGuidance = SESSION_START_GUIDANCE;
|
|
1543
|
-
runtime.projectRulesScan = scanProjectRules(analysisRoot);
|
|
1544
|
-
saveRuntimeProjectSnapshot({
|
|
1545
|
-
cwd: snapshotRoot,
|
|
1546
|
-
runtime,
|
|
1547
|
-
startupScan,
|
|
1548
|
-
languageProfile,
|
|
1549
|
-
dbg
|
|
1550
|
-
});
|
|
1551
|
-
phase("project-rules");
|
|
1552
|
-
if (runtime.projectRulesScan.hasCustomRules) {
|
|
1553
|
-
const ruleCount = runtime.projectRulesScan.rules.length;
|
|
1554
|
-
const sources = [
|
|
1555
|
-
...new Set(runtime.projectRulesScan.rules.map((r) => r.source))
|
|
1556
|
-
];
|
|
1557
|
-
dbg(`session_start: found ${ruleCount} project rule(s) from ${sources.join(", ")}`);
|
|
1558
|
-
} else {
|
|
1559
|
-
dbg("session_start: no project rules found");
|
|
1560
|
-
}
|
|
1561
|
-
cacheManager.writeCache("session-start-guidance", { content: agentStartupGuidance.join(`
|
|
1562
|
-
`) }, analysisRoot);
|
|
1563
|
-
if (!allowBootstrapTasks) {
|
|
1564
|
-
dbg("session_start: skipping startup background scans (startup mode)");
|
|
1565
|
-
} else if (!startupScansEnabled) {
|
|
1566
|
-
dbg("session_start: skipping startup background scans (disabled by config)");
|
|
1567
|
-
recordDegradationOnce({
|
|
1568
|
-
kind: "startup-analyzer-disabled",
|
|
1569
|
-
subject: "startup-scans",
|
|
1570
|
-
reason: "skipped (disabled by config)"
|
|
1571
|
-
});
|
|
1572
|
-
} else if (!startupScan.canWarmCaches) {
|
|
1573
|
-
dbg(`session_start: skipping heavy scans (${startupScan.reason ?? "unknown"})`);
|
|
1574
|
-
dbg(`session_start: skipping TODO scan (${startupScan.reason ?? "unknown"})`);
|
|
1575
|
-
if (startupScan.reason === "too-many-source-files" || startupScan.reason === "too-many-entries") {
|
|
1576
|
-
const overrideHint = startupScan.reason === "too-many-entries" ? ` (set DM_LENS_STARTUP_SCAN_MAX_ENTRIES=<n> to override the ${getStartupScanMaxEntries()}-entry cap)` : "";
|
|
1577
|
-
notify(`\uD83D\uDCE6 Project-size limits disabled background warm scans (heavy scans, TODO scan, LSP pre-warm)${overrideHint}.`, "warning");
|
|
1578
|
-
}
|
|
1579
|
-
} else {
|
|
1580
|
-
scheduleStartupScans(deps, runtime, sessionGeneration, analysisRoot, snapshotRoot, languageProfile, dbg);
|
|
1581
|
-
}
|
|
1582
|
-
if (subagentSession) {
|
|
1583
|
-
dbg("session_start lsp-warm: skipping pre-warm (subagent session)");
|
|
1584
|
-
} else if (!getFlag("no-lsp") && allowBootstrapTasks) {
|
|
1585
|
-
setImmediate(() => {
|
|
1586
|
-
loadLSPConfig(cwd).then((lspConfig) => {
|
|
1587
|
-
const warmFiles = lspConfig.warmFiles ?? [];
|
|
1588
|
-
dbg(`session_start lsp-config: loaded (${warmFiles.length} warm file(s) configured)`);
|
|
1589
|
-
if (warmFiles.length > 0) {
|
|
1590
|
-
igniteWarmFiles(cwd, warmFiles, runtime, sessionGeneration, dbg).catch((err) => dbg(`session_start lsp-warm: unhandled error: ${err}`));
|
|
1591
|
-
} else if (startupScan.canWarmCaches) {
|
|
1592
|
-
igniteDominantLanguageWarm(analysisRoot, runtime, sessionGeneration, dbg).catch((err) => dbg(`session_start lsp-warm: unhandled dominant error: ${err}`));
|
|
1593
|
-
} else {
|
|
1594
|
-
dbg(`session_start lsp-warm: skipping dominant-language auto-warm (${startupScan.reason ?? "unknown"})`);
|
|
1595
|
-
}
|
|
1596
|
-
});
|
|
1597
|
-
});
|
|
1598
|
-
phase("lsp-config");
|
|
1599
|
-
}
|
|
1600
|
-
setSessionLanguages(languageProfile.detectedKinds);
|
|
1601
|
-
const totalDurationMs = Date.now() - sessionStartMs;
|
|
1602
|
-
dbg(`session_start total: ${totalDurationMs}ms (interactive path; background tasks may continue)`);
|
|
1603
|
-
logLatency({
|
|
1604
|
-
type: "phase",
|
|
1605
|
-
phase: "session_start_total",
|
|
1606
|
-
filePath: cwd,
|
|
1607
|
-
startedAt: new Date(sessionStartMs).toISOString(),
|
|
1608
|
-
durationMs: totalDurationMs,
|
|
1609
|
-
metadata: {
|
|
1610
|
-
mode: startupMode,
|
|
1611
|
-
reason: deps.sessionReason,
|
|
1612
|
-
classification: deps.sessionStartClassification,
|
|
1613
|
-
sameRoot: deps.sessionStartSameRoot ?? "unknown"
|
|
1614
|
-
}
|
|
1615
|
-
});
|
|
1616
|
-
logHostReadyDelay(deps, cwd);
|
|
1617
|
-
emitSmellsSessionStartLine(dbg, sessionStartMs);
|
|
1618
|
-
}
|
|
1619
|
-
function emitSmellsSessionStartLine(dbg, sessionStartMs) {
|
|
1620
|
-
try {
|
|
1621
|
-
const line = formatSmellsSessionStartLine(countRecentSmells(undefined, sessionStartMs));
|
|
1622
|
-
if (line)
|
|
1623
|
-
dbg(line);
|
|
1624
|
-
} catch {}
|
|
1625
|
-
}
|