@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,1782 +0,0 @@
|
|
|
1
|
-
import"./clients/console-guard-install.js";
|
|
2
|
-
import { BoundedSet } from "./clients/bounded-cache.js";
|
|
3
|
-
import { bounded } from "./clients/deadline-utils.js";
|
|
4
|
-
import { HOOK_WALL_BUDGET_MS } from "./clients/hook-budgets.js";
|
|
5
|
-
import { closeModuleLoadConsoleWindow, installConsoleGuard, logExtension, runInConsoleCaptureWindow, withConsoleCaptureWindows } from "./clients/extension-log.js";
|
|
6
|
-
import { wireUserNotifier } from "./clients/user-notify.js";
|
|
7
|
-
import { getDegradationSummary, incrementDegradationCount, recordDegradation, renderDegradationLines } from "./clients/degradation-ledger.js";
|
|
8
|
-
import { TOOL_REGISTRY, toolRegistryEntryForPi } from "./clients/tool-config.js";
|
|
9
|
-
import { adoptProjectTrustFromPorts, assertInstallAllowed, readProjectTrustFromContext } from "./clients/project-trust.js";
|
|
10
|
-
import { modeSuppressionNote, readExtensionMode, suppressesUserNotify, supportsTuiWidget } from "./clients/extension-mode.js";
|
|
11
|
-
import * as nodeFs from "node:fs";
|
|
12
|
-
import * as path from "node:path";
|
|
13
|
-
import { performance } from "node:perf_hooks";
|
|
14
|
-
import { createDefaultHostPorts } from "./clients/host-ports.js";
|
|
15
|
-
import { AstGrepClient } from "./clients/ast-grep-client.js";
|
|
16
|
-
import { loadBootstrapClients, markAnalyzerBootstrapShutdown, peekBootstrapClients, requestBootstrapClients, getAgentBehaviorClient } from "./clients/bootstrap.js";
|
|
17
|
-
import { CacheManager } from "./clients/cache-manager.js";
|
|
18
|
-
import { resolveSkillPaths } from "./clients/skills-resolver.js";
|
|
19
|
-
import { clearWidgetState, exportWidgetState, getFailedLspServerIds, getSessionLanguages, importWidgetState, reconcileCascadeNeighborLspErrors, renderWidget, scheduleStaleReconcile, setRenderCallback, wireWidgetDispositionSubscriber } from "./clients/widget-state.js";
|
|
20
|
-
import { selectLspStatus } from "./clients/lsp-status.js";
|
|
21
|
-
import { registerMutationBridge } from "./clients/mutation-bridge.js";
|
|
22
|
-
import { OBSERVED_TRACKED_MAX_FILES, refreshObservedMutationLedger, runObservedSettledSweep } from "./clients/observed-mutation.js";
|
|
23
|
-
import { collectTrackedPaths, replayThroughMutationBridge, storedLineHashesFor } from "./clients/observed-mutation-sources.js";
|
|
24
|
-
import { classifyMutatingTool } from "./clients/mutating-tool.js";
|
|
25
|
-
import { isEditClassToolResult } from "./clients/bash-file-access.js";
|
|
26
|
-
import { resolveLanguageRootForFile } from "./clients/language-profile.js";
|
|
27
|
-
import { countFileLines } from "./clients/read-guard-tool-lines.js";
|
|
28
|
-
import { registerReadBridge } from "./clients/read-bridge.js";
|
|
29
|
-
import { normalizeFilePath } from "./clients/path-utils.js";
|
|
30
|
-
import { isRecordableProjectPath } from "./clients/file-utils.js";
|
|
31
|
-
import { dropStaleFiles, loadSessionState, saveSessionState, sessionStartMode } from "./clients/session-state-store.js";
|
|
32
|
-
import { getDiagnosticTracker } from "./clients/diagnostic-tracker.js";
|
|
33
|
-
import { warmDispatchIntegration, loadDispatchIntegration } from "./clients/dispatch/lazy.js";
|
|
34
|
-
import { getFormatService, resetFormatService } from "./clients/format-service.js";
|
|
35
|
-
import { getAllToolStatuses } from "./clients/installer/index.js";
|
|
36
|
-
import { loadDmLensGlobalConfig, resolveDmLensFlag, resolveDmLensFlagWithSource } from "./clients/lens-config.js";
|
|
37
|
-
import { LENS_FLAGS } from "./clients/lens-flag-registry.js";
|
|
38
|
-
import { LENS_TOOL_NAMES, resolveLensToolEnabled } from "./clients/tool-config.js";
|
|
39
|
-
import { recordDegradationOnce } from "./clients/degradation-ledger.js";
|
|
40
|
-
import { wrapToolsForCompactLine } from "./clients/tool-render.js";
|
|
41
|
-
import { finalizeToolResultWithDelivery, renderToolText } from "./tools/render-compact.js";
|
|
42
|
-
import { loadDmLensProjectConfig } from "./clients/project-lens-config.js";
|
|
43
|
-
import { initLensEventsGetter } from "./clients/lens-events.js";
|
|
44
|
-
import { wireBusEmitterGetter } from "./clients/bus-publish.js";
|
|
45
|
-
import { wireDiagnosticsBusEmitterGetter } from "./clients/diagnostics-publish.js";
|
|
46
|
-
import { wireDispositionBusEmitterGetter } from "./clients/disposition-publish.js";
|
|
47
|
-
import { wireFormatEventsBusEmitterGetter } from "./clients/format-events-publish.js";
|
|
48
|
-
import { emitBusEventRollupAtSessionEnd } from "./clients/bus-events-logger.js";
|
|
49
|
-
import { emitVerifiedPathAttributionRollup, resetVerifiedPathAttributionGuessCount } from "./clients/path-attribution-telemetry.js";
|
|
50
|
-
import { consumeAgentNudge, recordCrossProcessTouches, wireAgentNudgeSubscriber } from "./clients/agent-nudge.js";
|
|
51
|
-
import { readCrossProcessTouchesForSessionStart, readCrossProcessTouchesForTurnStart } from "./clients/recent-touches.js";
|
|
52
|
-
import { registerCascadeTierReconcileTask } from "./clients/lsp/cascade-tier.js";
|
|
53
|
-
import { buildResolvedFoundCascadeRun } from "./clients/cascade-format.js";
|
|
54
|
-
import { initLSPConfig } from "./clients/lsp/config.js";
|
|
55
|
-
import { getLSPService, resetLSPService } from "./clients/lsp/index.js";
|
|
56
|
-
import { shouldInitializeSessionRoot } from "./clients/lsp/session-roots.js";
|
|
57
|
-
import { warmLspService } from "./clients/lsp-lazy.js";
|
|
58
|
-
import { sweepOrphans, scheduleUntrackedOrphanSweep } from "./clients/instance-reaper.js";
|
|
59
|
-
import { deregisterInstance, deregisterInstanceRoot, readInstanceRegistry, registerInstance, registerInstanceRoot } from "./clients/instance-registry.js";
|
|
60
|
-
import { logVanishedInstances } from "./clients/vanished-instance-marker.js";
|
|
61
|
-
import { buildMemorySample, formatMemoryHealthLine, recordMemorySampleOutcome, resetMemorySamplerCadence, shouldEmitMemorySampleAdaptive } from "./clients/memory-sampler.js";
|
|
62
|
-
import { dumpActiveHandles } from "./clients/debug-handles.js";
|
|
63
|
-
import { isDebugHeapEnabled, writeHeapSnapshotNow } from "./clients/debug-heap.js";
|
|
64
|
-
import { checkSmellsAndNoteOnce, countRecentSmells, formatSmellsHealthLine, shouldCheckSmellsThisTurn } from "./clients/smells-rollup.js";
|
|
65
|
-
import { configureWarmAttach } from "./clients/warm-attach.js";
|
|
66
|
-
import { checkCrossProcessLspBudget } from "./clients/lsp-budget.js";
|
|
67
|
-
import { handleAgentEnd } from "./clients/runtime-agent-end.js";
|
|
68
|
-
import { consumeSessionStartGuidance, consumeTurnEndFindings } from "./clients/runtime-context.js";
|
|
69
|
-
import { consumeStagedTestRunnerFindings, deliverStagedTestRunnerFindings, stageTestRunnerDelivery } from "./clients/test-runner-delivery.js";
|
|
70
|
-
import { readHostModelIdentity, RuntimeCoordinator } from "./clients/runtime-coordinator.js";
|
|
71
|
-
import { handleSessionStart } from "./clients/runtime-session.js";
|
|
72
|
-
import { resetTurnContext } from "./clients/turn-context.js";
|
|
73
|
-
import { handleToolCall } from "./clients/runtime-tool-call.js";
|
|
74
|
-
import { isStaleExtensionCtxError, surfaceHandlerCrash, wrapSessionEventHandler, wrapSessionEventHandlerWithResult } from "./clients/session-event-guard.js";
|
|
75
|
-
import { classifyCurrentSessionEmission, decideSessionStart, decrementSecondarySessionCount, getActivePrimaryRoot, noteSessionShutdown, releasePrimarySession, probeCtxActive } from "./clients/session-lifecycle.js";
|
|
76
|
-
import { clearLastAnalyzedStateCache, flushDebouncedToolResults, handleToolResult } from "./clients/runtime-tool-result.js";
|
|
77
|
-
import { cancelLSPIdleReset, handleTurnEnd } from "./clients/runtime-turn.js";
|
|
78
|
-
import { registerBuiltinQuietWindowTasks, registerQuietWindowTask, runQuietWindow } from "./clients/quiet-window.js";
|
|
79
|
-
import { setAmbientAbortSignal } from "./clients/safe-spawn.js";
|
|
80
|
-
import { initI18n, t } from "./i18n.js";
|
|
81
|
-
import { createActivateToolsTool } from "./tools/activate-tools.js";
|
|
82
|
-
import { createLensDiagnosticsTool } from "./tools/lens-diagnostics.js";
|
|
83
|
-
import { createLensDiagnosticMarkTool } from "./tools/lens-diagnostic-mark.js";
|
|
84
|
-
import { createAstGrepReplaceTool } from "./tools/ast-grep-replace.js";
|
|
85
|
-
import { createAstGrepSearchTool } from "./tools/ast-grep-search.js";
|
|
86
|
-
import { createAstGrepOutlineTool } from "./tools/ast-grep-outline.js";
|
|
87
|
-
import { createLspNavigationTool } from "./tools/lsp-navigation.js";
|
|
88
|
-
import { createModuleReportTool, createReadEnclosingTool, createReadSymbolTool } from "./tools/module-report.js";
|
|
89
|
-
import { createProjectReportTool } from "./tools/project-report.js";
|
|
90
|
-
import { createEffectiveConfigTool } from "./tools/effective-config.js";
|
|
91
|
-
import { createSymbolSearchTool } from "./tools/symbol-search.js";
|
|
92
|
-
import { getLastLoggedPhase, getPhaseForWindow, getRecentLoggedPhases, logLatency, resetCurrentPhaseForSession, resetOncePerSessionPhases } from "./clients/latency-logger.js";
|
|
93
|
-
import { emitBounded } from "./clients/bounded-telemetry.js";
|
|
94
|
-
import { getLastLiveMessageEndSessionId, noteLiveMessageEndSessionId } from "./clients/message-end-attribution.js";
|
|
95
|
-
const LOOP_BLOCK_IDENTITY = "<dm-lens>";
|
|
96
|
-
import { isFreshSessionStart, clearRememberedLazyTools, getRememberedLazyTools, inheritRememberedLazyTools, planToolSet, recordToolSetMutation, rememberLazyTools, supportsDeferredTools } from "./clients/tool-set-policy.js";
|
|
97
|
-
import { endSituationalToolTelemetry, observeSituationalToolActivation, observeSituationalToolCall, startSituationalToolTelemetrySession } from "./clients/situational-tool-telemetry.js";
|
|
98
|
-
import { clearCachePrefixSession, emitCacheUsageSummaryAtSessionEnd, logCacheUsage, observeCacheContext, observeCachePrefix, recordToolResultDelivery, resetCacheFindingIdentitiesSession, recordTurnEndAdvisoryBytes } from "./clients/cache-observability.js";
|
|
99
|
-
import { buildStartupTimingRecords, getDmLensEvalMs, markDmLensLoaded, getDmLensLoadedAtMs, consumeHostReadyDelayAnchor, DM_LENS_LOADED_FROM } from "./clients/startup-timing.js";
|
|
100
|
-
import { toRunnerDisplayPath } from "./clients/dispatch/runner-context.js";
|
|
101
|
-
import { formatTurnSummaryLine, TURN_SUMMARY_CUSTOM_TYPE } from "./clients/turn-summary.js";
|
|
102
|
-
import { renderTurnSummaryMessage } from "./clients/turn-summary-render.js";
|
|
103
|
-
import { getEventLoopStats, resetEventLoopMonitor, shouldLogLoopBlock, shouldLogWorstBlock, startEventLoopMonitor } from "./clients/event-loop-monitor.js";
|
|
104
|
-
import { formatBuildIdentity, getBuildIdentity } from "./clients/build-identity.js";
|
|
105
|
-
import { logSessionStart } from "./clients/sessionstart-logger.js";
|
|
106
|
-
import { emitConcurrentSessionBindRollupAtSessionEnd, logConcurrentSessionBind, resetConcurrentSessionBindRollupCounts } from "./clients/session-start-observability.js";
|
|
107
|
-
import { normalizeToolDefinition } from "./clients/tool-definition.js";
|
|
108
|
-
import { warmFormatters } from "./clients/formatters-lazy.js";
|
|
109
|
-
let loadedDispatchIntegration;
|
|
110
|
-
const sessionBootstrapAccess = {
|
|
111
|
-
peek: () => peekBootstrapClients(),
|
|
112
|
-
request: (reason) => requestBootstrapClients({ reason, hook: "session_start" })
|
|
113
|
-
};
|
|
114
|
-
function warmDispatchAtSessionStart() {
|
|
115
|
-
warmDispatchIntegration().then((integration) => {
|
|
116
|
-
loadedDispatchIntegration = integration;
|
|
117
|
-
}).catch((err) => {
|
|
118
|
-
logExtension({
|
|
119
|
-
subsystem: "dispatch",
|
|
120
|
-
level: "warn",
|
|
121
|
-
message: `dispatch warm failed: ${err}`
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
function resetDispatchBaselines(cwd) {
|
|
126
|
-
loadDispatchIntegration().then(({ resetDispatchBaselines }) => {
|
|
127
|
-
resetDispatchBaselines(cwd);
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
const DM_LENS_LOAD_MS = markDmLensLoaded();
|
|
131
|
-
const DM_LENS_LOADED_AT_MS = getDmLensLoadedAtMs();
|
|
132
|
-
const DM_LENS_EVAL_MS = getDmLensEvalMs() ?? 0;
|
|
133
|
-
startEventLoopMonitor();
|
|
134
|
-
let lastLoggedLoopWorstMs = 0;
|
|
135
|
-
let sessionWorstRealBlockMs = 0;
|
|
136
|
-
let sessionSuspectedStalls = 0;
|
|
137
|
-
function dbg(msg) {
|
|
138
|
-
logSessionStart(msg);
|
|
139
|
-
}
|
|
140
|
-
let latestEventCtx;
|
|
141
|
-
function rememberEventCtx(ctx) {
|
|
142
|
-
if (ctx)
|
|
143
|
-
latestEventCtx = ctx;
|
|
144
|
-
}
|
|
145
|
-
function notifyUi(ctx, message, level = "info") {
|
|
146
|
-
const mode = readExtensionMode(ctx);
|
|
147
|
-
if (suppressesUserNotify(mode)) {
|
|
148
|
-
recordDegradation({
|
|
149
|
-
kind: "mode-suppression",
|
|
150
|
-
subject: "ctx.ui.notify",
|
|
151
|
-
reason: modeSuppressionNote(mode)
|
|
152
|
-
});
|
|
153
|
-
dbg(`notify ${modeSuppressionNote(mode)}: ${message.split(`
|
|
154
|
-
`)[0]}`);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
ctx?.ui?.notify?.(message, level);
|
|
158
|
-
}
|
|
159
|
-
function getStableSessionId(ctx) {
|
|
160
|
-
try {
|
|
161
|
-
return ctx?.sessionManager?.getSessionId?.();
|
|
162
|
-
} catch {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
export function createHostPorts(pi, options) {
|
|
167
|
-
const context = () => options.getContext();
|
|
168
|
-
const currentMode = () => readExtensionMode(context());
|
|
169
|
-
const emit = (channel, payload) => {
|
|
170
|
-
const bus = pi.events;
|
|
171
|
-
bus?.emit?.call(bus, channel, payload);
|
|
172
|
-
};
|
|
173
|
-
const activeTools = pi;
|
|
174
|
-
return createDefaultHostPorts({
|
|
175
|
-
notify: {
|
|
176
|
-
user(message, level) {
|
|
177
|
-
const mode = currentMode();
|
|
178
|
-
if (mode === "print" || mode === "json") {
|
|
179
|
-
recordDegradation({
|
|
180
|
-
kind: "mode-suppression",
|
|
181
|
-
subject: "user degradation notice",
|
|
182
|
-
reason: modeSuppressionNote(mode)
|
|
183
|
-
});
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
context()?.ui?.notify?.(message, level ?? "warning");
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
trust: { isProjectTrusted: () => readProjectTrustFromContext(context()) },
|
|
190
|
-
mode: {
|
|
191
|
-
current: currentMode,
|
|
192
|
-
supportsTuiWidget: () => supportsTuiWidget(currentMode()),
|
|
193
|
-
suppressesUserNotify: () => suppressesUserNotify(currentMode())
|
|
194
|
-
},
|
|
195
|
-
log: {
|
|
196
|
-
extension: logExtension,
|
|
197
|
-
debug: (message, metadata) => logExtension({ subsystem: "host", level: "debug", message, metadata }),
|
|
198
|
-
sink: (subsystem) => (entry) => logExtension({
|
|
199
|
-
subsystem,
|
|
200
|
-
level: "debug",
|
|
201
|
-
message: "host sink entry",
|
|
202
|
-
metadata: { entry }
|
|
203
|
-
})
|
|
204
|
-
},
|
|
205
|
-
emit: { bus: emit },
|
|
206
|
-
status: { set: (name, value) => context()?.ui?.setStatus?.(name, value) },
|
|
207
|
-
spawn: {
|
|
208
|
-
abortSignal: () => context()?.signal,
|
|
209
|
-
isAllowed: assertInstallAllowed
|
|
210
|
-
},
|
|
211
|
-
render: { invalidate: () => options.getRenderInvalidator?.()?.() },
|
|
212
|
-
session: { id: () => getStableSessionId(context()) },
|
|
213
|
-
workspace: {
|
|
214
|
-
cwd: () => context()?.cwd,
|
|
215
|
-
projectRoot: () => options.getProjectRoot?.()
|
|
216
|
-
},
|
|
217
|
-
flags: { get: (name) => pi.getFlag(name) },
|
|
218
|
-
tools: {
|
|
219
|
-
has: async (name) => typeof pi.getTool?.(name) !== "undefined",
|
|
220
|
-
getActive: () => activeTools.getActiveTools?.() ?? [],
|
|
221
|
-
setActive: (names) => activeTools.setActiveTools?.(names)
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
dbg(`dm-lens loaded: ${DM_LENS_LOAD_MS}ms after process start (from ${DM_LENS_LOADED_FROM})`);
|
|
226
|
-
for (const record of buildStartupTimingRecords({
|
|
227
|
-
loadMs: DM_LENS_LOAD_MS,
|
|
228
|
-
evalMs: DM_LENS_EVAL_MS
|
|
229
|
-
})) {
|
|
230
|
-
logLatency(record);
|
|
231
|
-
}
|
|
232
|
-
function log(_msg) {}
|
|
233
|
-
const runtime = new RuntimeCoordinator;
|
|
234
|
-
const cacheManager = new CacheManager;
|
|
235
|
-
let _readBridgeRegistered = false;
|
|
236
|
-
let _bridgeGetFlag;
|
|
237
|
-
let _mutationBridgeRegistered = false;
|
|
238
|
-
function getBridgeFlag(getter, bridge) {
|
|
239
|
-
try {
|
|
240
|
-
return getter?.("no-read-guard");
|
|
241
|
-
} catch (err) {
|
|
242
|
-
if (!isStaleExtensionCtxError(err))
|
|
243
|
-
throw err;
|
|
244
|
-
recordDegradationOnce({
|
|
245
|
-
kind: "extension-ctx-stale",
|
|
246
|
-
subject: `${bridge}-bridge`,
|
|
247
|
-
reason: `${bridge}-bridge flag read met a stale extension ctx; treating the flag as unset`
|
|
248
|
-
});
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
let _turnSummaryEmitRegistered = false;
|
|
253
|
-
let _turnSummaryEmitCtx;
|
|
254
|
-
let _testRunnerDeliveryRegistered = false;
|
|
255
|
-
let _nextTestRunnerDeliveryOwnerId = 0;
|
|
256
|
-
const LSP_CONFIG_CWD_CAP = 128;
|
|
257
|
-
const _lspConfigInitializedCwds = new BoundedSet(LSP_CONFIG_CWD_CAP);
|
|
258
|
-
async function ensureLSPConfigInitialized(cwd) {
|
|
259
|
-
const normalizedCwd = path.resolve(cwd);
|
|
260
|
-
if (!shouldInitializeSessionRoot(normalizedCwd, _lspConfigInitializedCwds)) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
await initLSPConfig(normalizedCwd);
|
|
264
|
-
_lspConfigInitializedCwds.add(normalizedCwd);
|
|
265
|
-
}
|
|
266
|
-
function updateRuntimeIdentityFromCtx(ctx) {
|
|
267
|
-
runtime.setTelemetryIdentity(readHostModelIdentity(ctx));
|
|
268
|
-
}
|
|
269
|
-
function normalizeCommandArgs(args) {
|
|
270
|
-
if (Array.isArray(args)) {
|
|
271
|
-
return args.filter((arg) => typeof arg === "string");
|
|
272
|
-
}
|
|
273
|
-
if (typeof args === "string") {
|
|
274
|
-
return args.trim().split(/\s+/).filter(Boolean);
|
|
275
|
-
}
|
|
276
|
-
return [];
|
|
277
|
-
}
|
|
278
|
-
function cleanStaleTsBuildInfo(cwd) {
|
|
279
|
-
const cleaned = [];
|
|
280
|
-
try {
|
|
281
|
-
const candidates = nodeFs.readdirSync(cwd).filter((f) => f.endsWith(".tsbuildinfo")).map((f) => path.join(cwd, f));
|
|
282
|
-
for (const infoPath of candidates) {
|
|
283
|
-
try {
|
|
284
|
-
const data = JSON.parse(nodeFs.readFileSync(infoPath, "utf-8"));
|
|
285
|
-
const root = data.root ?? [];
|
|
286
|
-
const dir = path.dirname(infoPath);
|
|
287
|
-
const isStale = root.some((f) => !nodeFs.existsSync(path.resolve(dir, f)));
|
|
288
|
-
if (isStale) {
|
|
289
|
-
nodeFs.unlinkSync(infoPath);
|
|
290
|
-
cleaned.push(infoPath);
|
|
291
|
-
}
|
|
292
|
-
} catch {}
|
|
293
|
-
}
|
|
294
|
-
} catch {}
|
|
295
|
-
return cleaned;
|
|
296
|
-
}
|
|
297
|
-
function activateExtension(hostPi) {
|
|
298
|
-
const pi = withConsoleCaptureWindows(hostPi);
|
|
299
|
-
const testRunnerDeliveryOwnerId = `activation-${++_nextTestRunnerDeliveryOwnerId}`;
|
|
300
|
-
let ownEventCtx;
|
|
301
|
-
let ownedSessionRole;
|
|
302
|
-
const classifyOwnedSessionEmission = (ctx, sessionId) => ownedSessionRole ?? classifyCurrentSessionEmission(ctx, sessionId);
|
|
303
|
-
const classifyOwnedSessionShutdown = (ctx, sessionId, root) => ownedSessionRole === "concurrent-secondary" ? "secondary" : ownedSessionRole === "primary" ? "primary" : noteSessionShutdown(ctx, sessionId, root);
|
|
304
|
-
const rememberOwnEventCtx = (ctx) => {
|
|
305
|
-
if (!ctx)
|
|
306
|
-
return;
|
|
307
|
-
ownEventCtx = ctx;
|
|
308
|
-
rememberEventCtx(ctx);
|
|
309
|
-
};
|
|
310
|
-
let renderInvalidator;
|
|
311
|
-
const hostPorts = createHostPorts(pi, {
|
|
312
|
-
getContext: () => latestEventCtx,
|
|
313
|
-
getProjectRoot: () => runtime.projectRoot,
|
|
314
|
-
getRenderInvalidator: () => renderInvalidator
|
|
315
|
-
});
|
|
316
|
-
installConsoleGuard();
|
|
317
|
-
initI18n(pi);
|
|
318
|
-
const refreshCtxDerivedPlumbing = () => {
|
|
319
|
-
wireUserNotifier(hostPorts);
|
|
320
|
-
const getLiveEmit = () => ({
|
|
321
|
-
emit: hostPorts.emit.bus,
|
|
322
|
-
ctx: ownEventCtx
|
|
323
|
-
});
|
|
324
|
-
initLensEventsGetter(getLiveEmit);
|
|
325
|
-
wireBusEmitterGetter(getLiveEmit);
|
|
326
|
-
wireDiagnosticsBusEmitterGetter(getLiveEmit);
|
|
327
|
-
wireDispositionBusEmitterGetter(getLiveEmit);
|
|
328
|
-
wireFormatEventsBusEmitterGetter(getLiveEmit);
|
|
329
|
-
setRenderCallback(() => hostPorts.render.invalidate());
|
|
330
|
-
};
|
|
331
|
-
refreshCtxDerivedPlumbing();
|
|
332
|
-
wireAgentNudgeSubscriber({
|
|
333
|
-
events: pi.events,
|
|
334
|
-
getReadGuard: () => runtime.readGuard,
|
|
335
|
-
dbg
|
|
336
|
-
});
|
|
337
|
-
wireWidgetDispositionSubscriber({ events: pi.events });
|
|
338
|
-
const astGrepClient = new AstGrepClient;
|
|
339
|
-
function updateLspStatus(setStatus, theme) {
|
|
340
|
-
try {
|
|
341
|
-
if (getLensFlag("lens-hide-lsp-status") === true) {
|
|
342
|
-
setStatus("dm-lens-lsp", undefined);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
const { activeIds, failedIds } = selectLspStatus(getLSPService().getAliveServerIds(), getFailedLspServerIds(), getSessionLanguages());
|
|
346
|
-
const parts = [];
|
|
347
|
-
const compact = getLensFlag("lens-compact-lsp-status") === true;
|
|
348
|
-
const activeText = compact ? "LSP ✓" : `LSP Active: ${activeIds.join(", ")}`;
|
|
349
|
-
const failedText = compact ? "LSP ✗" : `LSP Failed: ${failedIds.join(", ")}`;
|
|
350
|
-
const inactiveText = compact ? "LSP ✗" : "LSP Inactive";
|
|
351
|
-
if (activeIds.length > 0) {
|
|
352
|
-
parts.push(theme.fg("success", activeText));
|
|
353
|
-
}
|
|
354
|
-
if (failedIds.length > 0) {
|
|
355
|
-
parts.push(theme.fg("error", failedText));
|
|
356
|
-
}
|
|
357
|
-
setStatus("dm-lens-lsp", parts.length > 0 ? parts.join(" · ") : theme.fg("dim", inactiveText));
|
|
358
|
-
} catch (err) {
|
|
359
|
-
dbg(`lsp status update skipped: ${err}`);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
function captureLspStatusRepaint(ctx) {
|
|
363
|
-
let ui;
|
|
364
|
-
try {
|
|
365
|
-
ui = ctx.ui;
|
|
366
|
-
} catch (err) {
|
|
367
|
-
dbg(`lsp status repaint capture skipped: ${err}`);
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
if (!ui || typeof ui.setStatus !== "function" || !ui.theme) {
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
const { setStatus, theme } = ui;
|
|
374
|
-
return () => updateLspStatus(setStatus, theme);
|
|
375
|
-
}
|
|
376
|
-
for (const spec of LENS_FLAGS) {
|
|
377
|
-
pi.registerFlag(spec.name, {
|
|
378
|
-
description: spec.description,
|
|
379
|
-
type: "boolean",
|
|
380
|
-
default: spec.default
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
pi.registerFlag("no-tool", {
|
|
384
|
-
description: "Disable a lens tool for this session (repeatable).",
|
|
385
|
-
type: "string"
|
|
386
|
-
});
|
|
387
|
-
const globalConfig = loadDmLensGlobalConfig();
|
|
388
|
-
function getLensFlag(name, editedFilePath) {
|
|
389
|
-
const projectConfig = loadDmLensProjectConfig(runtime.projectRoot);
|
|
390
|
-
return resolveDmLensFlag(name, pi.getFlag(name), globalConfig, projectConfig, editedFilePath, runtime.projectRoot);
|
|
391
|
-
}
|
|
392
|
-
function getLensFlagSource(name, editedFilePath) {
|
|
393
|
-
const projectConfig = loadDmLensProjectConfig(runtime.projectRoot);
|
|
394
|
-
return resolveDmLensFlagWithSource(name, pi.getFlag(name), globalConfig, projectConfig, editedFilePath, runtime.projectRoot).source;
|
|
395
|
-
}
|
|
396
|
-
const noToolFlag = () => {
|
|
397
|
-
const value = pi.getFlag("no-tool");
|
|
398
|
-
const cliValues = process.argv.filter((arg) => arg.startsWith("--no-tool=")).map((arg) => arg.slice("--no-tool=".length));
|
|
399
|
-
if (typeof value === "string")
|
|
400
|
-
cliValues.unshift(value);
|
|
401
|
-
return cliValues.length > 0 ? cliValues.join(",") : undefined;
|
|
402
|
-
};
|
|
403
|
-
const isToolEnabled = (name) => resolveLensToolEnabled(name, globalConfig, loadDmLensProjectConfig(runtime.projectRoot).raw, noToolFlag());
|
|
404
|
-
const disabledToolNames = LENS_TOOL_NAMES.filter((name) => !isToolEnabled(name));
|
|
405
|
-
let lensEnabled = !getLensFlag("no-lens");
|
|
406
|
-
_bridgeGetFlag = getLensFlag;
|
|
407
|
-
if (!_readBridgeRegistered) {
|
|
408
|
-
_readBridgeRegistered = true;
|
|
409
|
-
registerReadBridge({
|
|
410
|
-
getReadGuard: () => runtime.readGuard,
|
|
411
|
-
getTurnIndex: () => runtime.turnIndex,
|
|
412
|
-
peekWriteIndex: () => runtime.peekWriteIndex(),
|
|
413
|
-
isRecordable(filePath) {
|
|
414
|
-
if (getBridgeFlag(_bridgeGetFlag, "read"))
|
|
415
|
-
return false;
|
|
416
|
-
return isRecordableProjectPath(filePath, runtime.projectRoot);
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
if (!_mutationBridgeRegistered) {
|
|
421
|
-
_mutationBridgeRegistered = true;
|
|
422
|
-
registerMutationBridge({
|
|
423
|
-
getRuntime: () => runtime,
|
|
424
|
-
getCacheManager: () => cacheManager,
|
|
425
|
-
getProjectRoot: () => runtime.projectRoot || process.cwd(),
|
|
426
|
-
getDispatchCwd: (filePath) => resolveLanguageRootForFile(filePath, runtime.projectRoot || process.cwd()),
|
|
427
|
-
countFileLines,
|
|
428
|
-
isRecordable(filePath) {
|
|
429
|
-
return isRecordableProjectPath(filePath, runtime.projectRoot);
|
|
430
|
-
},
|
|
431
|
-
shouldStampReadGuard() {
|
|
432
|
-
return !getBridgeFlag(_bridgeGetFlag, "mutation");
|
|
433
|
-
},
|
|
434
|
-
dbg
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
let contextInjectionEnabled = !getLensFlag("no-lens-context");
|
|
438
|
-
let lensWidgetVisible = globalConfig?.widget?.visible !== false;
|
|
439
|
-
let mountedLensWidgetUi;
|
|
440
|
-
let widgetMountFailureLogged = false;
|
|
441
|
-
let pendingForkSnapshot;
|
|
442
|
-
let pendingForkReadGuard;
|
|
443
|
-
function mountLensWidget(ui, mode) {
|
|
444
|
-
if (!supportsTuiWidget(mode)) {
|
|
445
|
-
dbg(`widget mount ${modeSuppressionNote(mode)}`);
|
|
446
|
-
return false;
|
|
447
|
-
}
|
|
448
|
-
if (typeof ui?.setWidget !== "function") {
|
|
449
|
-
if (!widgetMountFailureLogged) {
|
|
450
|
-
widgetMountFailureLogged = true;
|
|
451
|
-
logExtension({
|
|
452
|
-
subsystem: "widget",
|
|
453
|
-
level: "debug",
|
|
454
|
-
message: "widget mount unavailable: host ui.setWidget is missing"
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
return false;
|
|
458
|
-
}
|
|
459
|
-
const setWidget = ui.setWidget;
|
|
460
|
-
setWidget("dm-lens", (tui, theme) => {
|
|
461
|
-
renderInvalidator = () => tui.requestRender();
|
|
462
|
-
setRenderCallback(() => {
|
|
463
|
-
scheduleStaleReconcile();
|
|
464
|
-
hostPorts.render.invalidate();
|
|
465
|
-
});
|
|
466
|
-
return {
|
|
467
|
-
render: (width) => {
|
|
468
|
-
scheduleStaleReconcile();
|
|
469
|
-
return renderWidget(width, theme);
|
|
470
|
-
},
|
|
471
|
-
invalidate: () => {
|
|
472
|
-
renderInvalidator = undefined;
|
|
473
|
-
setRenderCallback(() => {});
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
}, { placement: "belowEditor" });
|
|
477
|
-
mountedLensWidgetUi = ui;
|
|
478
|
-
return true;
|
|
479
|
-
}
|
|
480
|
-
function unmountLensWidget(ui) {
|
|
481
|
-
renderInvalidator = undefined;
|
|
482
|
-
setRenderCallback(() => {});
|
|
483
|
-
if (typeof ui?.setWidget !== "function")
|
|
484
|
-
return false;
|
|
485
|
-
const setWidget = ui.setWidget;
|
|
486
|
-
setWidget("dm-lens", undefined);
|
|
487
|
-
mountedLensWidgetUi = undefined;
|
|
488
|
-
return true;
|
|
489
|
-
}
|
|
490
|
-
if (typeof pi.registerMessageRenderer === "function") {
|
|
491
|
-
try {
|
|
492
|
-
pi.registerMessageRenderer(TURN_SUMMARY_CUSTOM_TYPE, renderTurnSummaryMessage);
|
|
493
|
-
} catch (registerRendererErr) {
|
|
494
|
-
dbg(`turn-summary renderer registration failed: ${registerRendererErr}`);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
pi.registerCommand("lens-toggle", {
|
|
498
|
-
description: "Toggle dm-lens on/off for the current session. Usage: /lens-toggle",
|
|
499
|
-
handler: async (_args, ctx) => {
|
|
500
|
-
lensEnabled = !lensEnabled;
|
|
501
|
-
notifyUi(ctx, lensEnabled ? "dm-lens enabled for this session." : "dm-lens disabled for this session. Run /lens-toggle again to resume.", lensEnabled ? "info" : "warning");
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
pi.registerCommand("lens-context-toggle", {
|
|
505
|
-
description: "Toggle automatic context injection on/off for the current session (tools/LSP/read-guard/formatting stay active). Usage: /lens-context-toggle",
|
|
506
|
-
handler: async (_args, ctx) => {
|
|
507
|
-
contextInjectionEnabled = !contextInjectionEnabled;
|
|
508
|
-
notifyUi(ctx, contextInjectionEnabled ? "dm-lens context injection enabled — findings will be added to the next turn." : "dm-lens context injection disabled — findings are still cached (lens_diagnostics, /lens-health) but not added to model context.", contextInjectionEnabled ? "info" : "warning");
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
|
-
pi.registerCommand("lens-widget-toggle", {
|
|
512
|
-
description: "Show or hide the dm-lens diagnostics widget below the editor. Usage: /lens-widget-toggle",
|
|
513
|
-
handler: async (_args, ctx) => {
|
|
514
|
-
const nextVisible = !lensWidgetVisible;
|
|
515
|
-
const mode = readExtensionMode(ctx);
|
|
516
|
-
if (nextVisible && !supportsTuiWidget(mode)) {
|
|
517
|
-
notifyUi(ctx, `dm-lens widget needs an interactive TUI — unavailable in "${mode}" mode.`, "warning");
|
|
518
|
-
return;
|
|
519
|
-
}
|
|
520
|
-
const changed = nextVisible ? mountLensWidget(ctx.ui, mode) : unmountLensWidget(ctx.ui);
|
|
521
|
-
if (!changed) {
|
|
522
|
-
notifyUi(ctx, "dm-lens widget is not supported by this pi version.", "warning");
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
lensWidgetVisible = nextVisible;
|
|
526
|
-
notifyUi(ctx, lensWidgetVisible ? "dm-lens widget shown. Run /lens-widget-toggle to hide it." : "dm-lens widget hidden. Run /lens-widget-toggle to show it.", "info");
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
pi.registerCommand("lens-tdi", {
|
|
530
|
-
description: "Show Technical Debt Index (TDI) and project health trend. Usage: /lens-tdi",
|
|
531
|
-
handler: async (_args, ctx) => {
|
|
532
|
-
const { loadHistory, computeTDI } = await import("./clients/metrics-history.js");
|
|
533
|
-
const history = loadHistory();
|
|
534
|
-
const tdi = computeTDI(history);
|
|
535
|
-
let summary = "\uD83D\uDD34 High debt - run lens_diagnostics mode=full for details";
|
|
536
|
-
if (tdi.score <= 30) {
|
|
537
|
-
summary = "✅ Codebase is healthy!";
|
|
538
|
-
} else if (tdi.score <= 60) {
|
|
539
|
-
summary = "⚠️ Moderate debt - consider refactoring";
|
|
540
|
-
}
|
|
541
|
-
const lines = [
|
|
542
|
-
`\uD83D\uDCCA TECHNICAL DEBT INDEX: ${tdi.score}/100 (${tdi.grade})`,
|
|
543
|
-
``,
|
|
544
|
-
`Files analyzed: ${tdi.filesAnalyzed}`,
|
|
545
|
-
`Files with debt: ${tdi.filesWithDebt}`,
|
|
546
|
-
`Avg MI: ${tdi.avgMI}`,
|
|
547
|
-
`Total cognitive complexity: ${tdi.totalCognitive}`,
|
|
548
|
-
``,
|
|
549
|
-
`Debt breakdown:`,
|
|
550
|
-
` Maintainability: ${tdi.byCategory.maintainability}% (MI-based)`,
|
|
551
|
-
` Cognitive: ${tdi.byCategory.cognitive}%`,
|
|
552
|
-
` Nesting: ${tdi.byCategory.nesting}%`,
|
|
553
|
-
` Max Cyclomatic: ${tdi.byCategory.maxCyclomatic}% (worst function)`,
|
|
554
|
-
` Entropy: ${tdi.byCategory.entropy}% (code unpredictability)`,
|
|
555
|
-
``,
|
|
556
|
-
summary
|
|
557
|
-
];
|
|
558
|
-
notifyUi(ctx, lines.join(`
|
|
559
|
-
`), "info");
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
pi.registerCommand("lens-map", {
|
|
563
|
-
description: "Render the review graph as a self-contained interactive HTML project map (pan/zoom/hover/click) and write it to disk. Usage: /lens-map",
|
|
564
|
-
handler: async (_args, ctx) => {
|
|
565
|
-
const cwd = ctx.cwd ?? process.cwd();
|
|
566
|
-
try {
|
|
567
|
-
const { generateLensMap } = await import("./clients/lens-map.js");
|
|
568
|
-
const result = await generateLensMap(cwd);
|
|
569
|
-
const testNote = result.testFileCount > 0 ? `, ${result.testFileCount} test files excluded` : "";
|
|
570
|
-
const twinNote = result.compiledTwinCount > 0 ? `, ${result.compiledTwinCount} compiled twins merged` : "";
|
|
571
|
-
const ignoredNote = result.ignoredFileCount > 0 ? `, ${result.ignoredFileCount} gitignored files excluded` : "";
|
|
572
|
-
const lines = [
|
|
573
|
-
`\uD83D\uDDFA️ Project map written to ${result.filePath}`,
|
|
574
|
-
`${result.fileCount} files, ${result.edgeCount} edges, ${result.externalCount} external deps excluded${testNote}${twinNote}${ignoredNote}.`
|
|
575
|
-
];
|
|
576
|
-
if (result.truncated) {
|
|
577
|
-
lines.push("Graph exceeded the map's node cap — showing the highest-degree files only (see the in-page note).");
|
|
578
|
-
}
|
|
579
|
-
notifyUi(ctx, lines.join(`
|
|
580
|
-
`), "info");
|
|
581
|
-
} catch (err) {
|
|
582
|
-
notifyUi(ctx, `Failed to generate the project map: ${err instanceof Error ? err.message : String(err)}`, "error");
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
});
|
|
586
|
-
pi.registerCommand("lens-health", {
|
|
587
|
-
description: "Show dm-lens runtime health: pipeline crashes, slow runners, and last dispatch latency. Usage: /lens-health",
|
|
588
|
-
handler: async (_args, ctx) => {
|
|
589
|
-
const crashEntries = runtime.getCrashEntries().sort((a, b) => b[1] - a[1]);
|
|
590
|
-
const totalCrashes = crashEntries.reduce((sum, [, count]) => sum + count, 0);
|
|
591
|
-
const dispatchIntegration = loadedDispatchIntegration ?? await loadDispatchIntegration();
|
|
592
|
-
loadedDispatchIntegration = dispatchIntegration;
|
|
593
|
-
const reports = dispatchIntegration.getLatencyReports();
|
|
594
|
-
const last = reports.length > 0 ? reports[reports.length - 1] : undefined;
|
|
595
|
-
const diagStats = getDiagnosticTracker().getStats();
|
|
596
|
-
const slowRunners = last ? [...last.runners].sort((a, b) => b.durationMs - a.durationMs).slice(0, 3) : [];
|
|
597
|
-
const sessionAge = Date.now() - runtime.sessionStartedAt;
|
|
598
|
-
const sessionMins = Math.floor(sessionAge / 60000);
|
|
599
|
-
const sessionHrs = Math.floor(sessionMins / 60);
|
|
600
|
-
const sessionAgeStr = sessionHrs > 0 ? `${sessionHrs}h ${sessionMins % 60}m` : `${sessionMins}m`;
|
|
601
|
-
const startedAt = new Date(runtime.sessionStartedAt).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
602
|
-
const lines = [
|
|
603
|
-
t("lens.health.title", "\uD83E\uDE7A PI-LENS HEALTH"),
|
|
604
|
-
`Session started: ${startedAt} (${sessionAgeStr} ago)`,
|
|
605
|
-
"",
|
|
606
|
-
t("lens.health.crashes", "Pipeline crashes (session): {count}", {
|
|
607
|
-
count: totalCrashes
|
|
608
|
-
}),
|
|
609
|
-
t("lens.health.files", "Files affected: {count}", {
|
|
610
|
-
count: crashEntries.length
|
|
611
|
-
})
|
|
612
|
-
];
|
|
613
|
-
const slopScoreLine = dispatchIntegration.getDispatchSlopScoreLine();
|
|
614
|
-
if (crashEntries.length > 0) {
|
|
615
|
-
lines.push("", t("lens.health.topCrashFiles", "Top crash files:"));
|
|
616
|
-
for (const [file, count] of crashEntries.slice(0, 5)) {
|
|
617
|
-
lines.push(` ${path.basename(file)}: ${count}`);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
if (last) {
|
|
621
|
-
lines.push("", `Last dispatch: ${path.basename(last.filePath)} (${last.totalDurationMs}ms, ${last.totalDiagnostics} diagnostics)`);
|
|
622
|
-
if (slowRunners.length > 0) {
|
|
623
|
-
lines.push("Top runners (last dispatch):");
|
|
624
|
-
for (const runner of slowRunners) {
|
|
625
|
-
lines.push(` ${runner.runnerId}: ${runner.durationMs}ms (${runner.status})`);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
} else {
|
|
629
|
-
lines.push("", t("lens.health.noLatency", "No dispatch latency reports yet."));
|
|
630
|
-
}
|
|
631
|
-
lines.push("", t("lens.health.diagnosticsShown", "Diagnostics shown: {count}", {
|
|
632
|
-
count: diagStats.totalShown
|
|
633
|
-
}), t("lens.health.autoFixed", "Auto-fixed: {count}", {
|
|
634
|
-
count: diagStats.totalAutoFixed
|
|
635
|
-
}), t("lens.health.agentFixed", "Agent-fixed: {count}", {
|
|
636
|
-
count: diagStats.totalAgentFixed
|
|
637
|
-
}), t("lens.health.unresolved", "Unresolved carryover: {count}", {
|
|
638
|
-
count: diagStats.totalUnresolved
|
|
639
|
-
}));
|
|
640
|
-
const elStats = getEventLoopStats();
|
|
641
|
-
if (elStats) {
|
|
642
|
-
lines.push("", `Event loop: worst genuine block ${sessionWorstRealBlockMs}ms (session) · p99 ${elStats.p99Ms}ms · mean ${elStats.meanMs}ms (turn)`);
|
|
643
|
-
if (sessionWorstRealBlockMs > 100) {
|
|
644
|
-
lines.push(" ⚠ a >100ms synchronous block can stutter the TUI — check latency.log (#192)");
|
|
645
|
-
}
|
|
646
|
-
if (sessionSuspectedStalls > 0) {
|
|
647
|
-
lines.push(` ${sessionSuspectedStalls} suspected system stall(s) (sleep/paging) this session — excluded from the block figure above (#1122)`);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
try {
|
|
651
|
-
lines.push("", formatMemoryHealthLine(buildMemorySample(runtime.wordIndex)));
|
|
652
|
-
} catch {}
|
|
653
|
-
if (isDebugHeapEnabled()) {
|
|
654
|
-
try {
|
|
655
|
-
const snap = writeHeapSnapshotNow("lens_health");
|
|
656
|
-
if (snap) {
|
|
657
|
-
lines.push(`Heap snapshot written: ${snap.path} (RSS ${Math.round(snap.rssBytes / (1024 * 1024))}MB, ${snap.durationMs}ms) — open in Chrome DevTools › Memory`);
|
|
658
|
-
}
|
|
659
|
-
} catch {}
|
|
660
|
-
}
|
|
661
|
-
try {
|
|
662
|
-
lines.push(formatSmellsHealthLine(countRecentSmells()));
|
|
663
|
-
} catch {}
|
|
664
|
-
if (diagStats.repeatOffenders.length > 0) {
|
|
665
|
-
lines.push(t("lens.health.repeatOffenders", "Repeat offenders:"));
|
|
666
|
-
for (const offender of diagStats.repeatOffenders.slice(0, 5)) {
|
|
667
|
-
lines.push(` ${path.basename(offender.filePath)}:${offender.line} ${offender.ruleId} (${offender.count}x)`);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
if (diagStats.topViolations.length > 0) {
|
|
671
|
-
lines.push(t("lens.health.topNoisyRules", "Top noisy rules:"));
|
|
672
|
-
for (const v of diagStats.topViolations.slice(0, 5)) {
|
|
673
|
-
const samplePath = v.samplePaths.length > 0 ? path.relative(runtime.projectRoot, v.samplePaths[0]).replace(/\\/g, "/") : "";
|
|
674
|
-
const pathSuffix = samplePath ? ` (e.g. ${samplePath})` : "";
|
|
675
|
-
lines.push(` ${v.ruleId}: ${v.count}${pathSuffix}`);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
try {
|
|
679
|
-
lines.push(...renderDegradationLines(getDegradationSummary().filter((group) => group.kind === "warm-ipc-endpoint-missing")));
|
|
680
|
-
} catch {}
|
|
681
|
-
const lspClients = getLSPService().getStatus();
|
|
682
|
-
if (lspClients.length > 0) {
|
|
683
|
-
lines.push("", "LSP servers:");
|
|
684
|
-
for (const { serverId, root, connected } of lspClients) {
|
|
685
|
-
const state = connected ? "✓" : "✗";
|
|
686
|
-
const rootLabel = path.relative(runtime.projectRoot, root) || ".";
|
|
687
|
-
lines.push(` ${state} ${serverId} (${rootLabel})`);
|
|
688
|
-
}
|
|
689
|
-
} else {
|
|
690
|
-
lines.push("", "LSP servers: none started");
|
|
691
|
-
}
|
|
692
|
-
const cascadeStats = dispatchIntegration.getCascadeSessionStats();
|
|
693
|
-
if (cascadeStats.runs > 0) {
|
|
694
|
-
lines.push("", `Cascade runs: ${cascadeStats.runs}`, `Cascade diagnostics surfaced: ${cascadeStats.diagnosticsSurfaced}`);
|
|
695
|
-
if (cascadeStats.coldSnapshotTouches > 0) {
|
|
696
|
-
lines.push(`Cold-snapshot touches: ${cascadeStats.coldSnapshotTouches}`);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
if (slopScoreLine) {
|
|
700
|
-
lines.push("", slopScoreLine);
|
|
701
|
-
}
|
|
702
|
-
notifyUi(ctx, lines.join(`
|
|
703
|
-
`), "info");
|
|
704
|
-
}
|
|
705
|
-
});
|
|
706
|
-
pi.registerCommand("lens-perf", {
|
|
707
|
-
description: "Show the slowest latency-log phases by p50 and p99 for the current process session and machine-wide active log window. Usage: /lens-perf",
|
|
708
|
-
handler: async (_args, ctx) => {
|
|
709
|
-
try {
|
|
710
|
-
const { collectLatencyPerformance, renderLatencyPerformanceReport } = await import("./clients/performance-report.js");
|
|
711
|
-
const report = await collectLatencyPerformance({
|
|
712
|
-
sessionStartedAt: runtime.sessionStartedAt
|
|
713
|
-
});
|
|
714
|
-
const degradationLines = renderDegradationLines(getDegradationSummary());
|
|
715
|
-
const degradationText = degradationLines.length ? `
|
|
716
|
-
|
|
717
|
-
${degradationLines.join(`
|
|
718
|
-
`)}` : "";
|
|
719
|
-
notifyUi(ctx, `${renderLatencyPerformanceReport(report)}${degradationText}`, "info");
|
|
720
|
-
} catch (err) {
|
|
721
|
-
notifyUi(ctx, `Failed to read performance telemetry: ${err instanceof Error ? err.message : String(err)}`, "error");
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
});
|
|
725
|
-
pi.registerCommand("lens-tools", {
|
|
726
|
-
description: "Show dm-lens tool installation status: globally installed, auto-installed, or npx fallback. Usage: /lens-tools",
|
|
727
|
-
handler: async (_args, ctx) => {
|
|
728
|
-
const statuses = await getAllToolStatuses();
|
|
729
|
-
const bySource = {
|
|
730
|
-
"global-path": statuses.filter((s) => s.source === "global-path"),
|
|
731
|
-
"npm-global": statuses.filter((s) => s.source === "npm-global"),
|
|
732
|
-
"pip-user": statuses.filter((s) => s.source === "pip-user"),
|
|
733
|
-
"dm-lens-auto": statuses.filter((s) => s.source === "dm-lens-auto"),
|
|
734
|
-
"github-release": statuses.filter((s) => s.source === "github-release"),
|
|
735
|
-
"npx-fallback": statuses.filter((s) => s.source === "npx-fallback"),
|
|
736
|
-
"not-installed": statuses.filter((s) => s.source === "not-installed")
|
|
737
|
-
};
|
|
738
|
-
const lines = [
|
|
739
|
-
"\uD83D\uDD27 PI-LENS TOOLS STATUS",
|
|
740
|
-
"",
|
|
741
|
-
`Installed: ${statuses.filter((s) => s.installed).length}/${statuses.length}`
|
|
742
|
-
];
|
|
743
|
-
if (bySource["global-path"].length > 0) {
|
|
744
|
-
lines.push("", `\uD83D\uDCCD Global PATH (${bySource["global-path"].length}):`);
|
|
745
|
-
for (const tool of bySource["global-path"]) {
|
|
746
|
-
const version = tool.version ? ` (${tool.version})` : "";
|
|
747
|
-
lines.push(` ✓ ${tool.name}${version}`);
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
if (bySource["npm-global"].length > 0) {
|
|
751
|
-
lines.push("", `\uD83D\uDCE6 npm global (${bySource["npm-global"].length}):`);
|
|
752
|
-
for (const tool of bySource["npm-global"]) {
|
|
753
|
-
lines.push(` ✓ ${tool.name}`);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
if (bySource["pip-user"].length > 0) {
|
|
757
|
-
lines.push("", `\uD83D\uDC0D pip user (${bySource["pip-user"].length}):`);
|
|
758
|
-
for (const tool of bySource["pip-user"]) {
|
|
759
|
-
lines.push(` ✓ ${tool.name}`);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
if (bySource["github-release"].length > 0) {
|
|
763
|
-
lines.push("", `⬇️ GitHub releases (${bySource["github-release"].length}):`);
|
|
764
|
-
for (const tool of bySource["github-release"]) {
|
|
765
|
-
lines.push(` ✓ ${tool.name}`);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
if (bySource["dm-lens-auto"].length > 0) {
|
|
769
|
-
lines.push("", `\uD83E\uDD16 Auto-installed (${bySource["dm-lens-auto"].length}):`);
|
|
770
|
-
for (const tool of bySource["dm-lens-auto"]) {
|
|
771
|
-
lines.push(` ✓ ${tool.name}`);
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
if (bySource["npx-fallback"].length > 0) {
|
|
775
|
-
lines.push("", `\uD83D\uDCE6 npx fallback (${bySource["npx-fallback"].length} - on-demand install):`);
|
|
776
|
-
for (const tool of bySource["npx-fallback"]) {
|
|
777
|
-
lines.push(` ⬜ ${tool.name}`);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
const trulyMissing = bySource["not-installed"].filter((s) => s.strategy !== "npm");
|
|
781
|
-
if (trulyMissing.length > 0) {
|
|
782
|
-
lines.push("", `❌ Missing (${trulyMissing.length}):`);
|
|
783
|
-
for (const tool of trulyMissing) {
|
|
784
|
-
lines.push(` ✗ ${tool.name} (${tool.strategy})`);
|
|
785
|
-
}
|
|
786
|
-
lines.push("", "Note: GitHub-release tools auto-install when you open files of those languages");
|
|
787
|
-
}
|
|
788
|
-
notifyUi(ctx, lines.join(`
|
|
789
|
-
`), "info");
|
|
790
|
-
}
|
|
791
|
-
});
|
|
792
|
-
pi.registerCommand("lens-allow-edit", {
|
|
793
|
-
description: "Allow one edit to a file without a prior read. Usage: /lens-allow-edit <path>",
|
|
794
|
-
handler: async (args, ctx) => {
|
|
795
|
-
const [rawTarget] = normalizeCommandArgs(args);
|
|
796
|
-
if (!rawTarget) {
|
|
797
|
-
notifyUi(ctx, "Usage: /lens-allow-edit <path>", "warning");
|
|
798
|
-
return;
|
|
799
|
-
}
|
|
800
|
-
const targetPath = path.isAbsolute(rawTarget) ? rawTarget : path.resolve(ctx.cwd ?? runtime.projectRoot, rawTarget);
|
|
801
|
-
runtime.readGuard.addExemption(targetPath);
|
|
802
|
-
notifyUi(ctx, `Read guard override armed for next edit: ${targetPath}`, "info");
|
|
803
|
-
}
|
|
804
|
-
});
|
|
805
|
-
const alwaysActiveTools = [
|
|
806
|
-
createLensDiagnosticsTool(cacheManager, () => runtime.projectRoot, undefined, () => flushDebouncedToolResults(), () => runtime.nextWriteIndex(), captureLspStatusRepaint, () => runtime, () => Boolean(getLensFlag("lens-guard"))),
|
|
807
|
-
createSymbolSearchTool(() => runtime.projectRoot),
|
|
808
|
-
createEffectiveConfigTool(() => runtime.projectRoot, noToolFlag),
|
|
809
|
-
createProjectReportTool(() => runtime.projectRoot),
|
|
810
|
-
createModuleReportTool(() => runtime.projectRoot),
|
|
811
|
-
createReadSymbolTool(() => runtime.projectRoot, (filePath, symbol) => runtime.readGuard.recordSymbolRead(filePath, symbol, runtime.turnIndex, runtime.peekWriteIndex())),
|
|
812
|
-
createReadEnclosingTool(() => runtime.projectRoot, (filePath, symbol) => runtime.readGuard.recordSymbolRead(filePath, symbol, runtime.turnIndex, runtime.peekWriteIndex()))
|
|
813
|
-
];
|
|
814
|
-
const lazyTools = [
|
|
815
|
-
createAstGrepSearchTool(astGrepClient),
|
|
816
|
-
createAstGrepReplaceTool(astGrepClient),
|
|
817
|
-
createAstGrepOutlineTool(astGrepClient),
|
|
818
|
-
createLspNavigationTool((name, cwd) => getLensFlag(name, cwd), {
|
|
819
|
-
runtime,
|
|
820
|
-
cacheManager,
|
|
821
|
-
readGuard: runtime.readGuard,
|
|
822
|
-
dbg
|
|
823
|
-
}),
|
|
824
|
-
createLensDiagnosticMarkTool(() => runtime.projectRoot, () => ({
|
|
825
|
-
model: runtime.telemetryModelId,
|
|
826
|
-
provider: runtime.telemetryProviderId
|
|
827
|
-
}))
|
|
828
|
-
];
|
|
829
|
-
const LAZY_TOOL_CATALOG = TOOL_REGISTRY.filter((entry) => ("situational" in entry) && entry.situational === true).map(({ name, summary }) => ({ name, summary }));
|
|
830
|
-
const enabledLazyTools = new Set(LAZY_TOOL_CATALOG.filter((tool) => isToolEnabled(tool.name)).map((tool) => tool.name));
|
|
831
|
-
const filteredLazyTools = lazyTools.filter((tool) => enabledLazyTools.has(tool.name));
|
|
832
|
-
const filteredLazyCatalog = LAZY_TOOL_CATALOG.filter((tool) => enabledLazyTools.has(tool.name));
|
|
833
|
-
const getSessionFile = (ctx) => {
|
|
834
|
-
try {
|
|
835
|
-
return ctx?.sessionManager?.getSessionFile?.();
|
|
836
|
-
} catch {
|
|
837
|
-
return;
|
|
838
|
-
}
|
|
839
|
-
};
|
|
840
|
-
let lastSessionStartIdentity;
|
|
841
|
-
const activateToolsTool = createActivateToolsTool(pi, filteredLazyCatalog, {
|
|
842
|
-
onActivated: (names, ctx) => {
|
|
843
|
-
observeSituationalToolActivation(names);
|
|
844
|
-
rememberLazyTools(getSessionFile(ctx), names);
|
|
845
|
-
},
|
|
846
|
-
onRejected: (name) => {
|
|
847
|
-
if (LENS_TOOL_NAMES.includes(name)) {
|
|
848
|
-
recordDegradationOnce({
|
|
849
|
-
kind: "tool-disabled",
|
|
850
|
-
subject: name,
|
|
851
|
-
reason: `disabled by tools.${name}.enabled`
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
},
|
|
855
|
-
deferredToolSupport: (ctx) => {
|
|
856
|
-
try {
|
|
857
|
-
return supportsDeferredTools(ctx?.model);
|
|
858
|
-
} catch {
|
|
859
|
-
return false;
|
|
860
|
-
}
|
|
861
|
-
},
|
|
862
|
-
onMutation: recordToolSetMutation
|
|
863
|
-
});
|
|
864
|
-
const compactToolLineEnabled = getLensFlag("lens-compact-tool-line") === true;
|
|
865
|
-
const toolsToRegister = [
|
|
866
|
-
...alwaysActiveTools,
|
|
867
|
-
activateToolsTool,
|
|
868
|
-
...filteredLazyTools
|
|
869
|
-
].filter((tool) => tool.name === "dm_lens_activate_tools" || isToolEnabled(tool.name));
|
|
870
|
-
for (const tool of compactToolLineEnabled ? wrapToolsForCompactLine(toolsToRegister) : toolsToRegister) {
|
|
871
|
-
try {
|
|
872
|
-
const normalized = normalizeToolDefinition(tool);
|
|
873
|
-
const execute = normalized.execute;
|
|
874
|
-
if (typeof execute === "function") {
|
|
875
|
-
const recordDelivery = (delivery, args) => {
|
|
876
|
-
if (!lensEnabled)
|
|
877
|
-
return;
|
|
878
|
-
try {
|
|
879
|
-
const ctx = args[4];
|
|
880
|
-
const sessionId = getStableSessionId(ctx);
|
|
881
|
-
recordToolResultDelivery({
|
|
882
|
-
sessionId,
|
|
883
|
-
sessionRole: classifyOwnedSessionEmission(ctx, sessionId),
|
|
884
|
-
bytes: delivery.deliveredBytes,
|
|
885
|
-
truncated: delivery.truncated
|
|
886
|
-
});
|
|
887
|
-
} catch {}
|
|
888
|
-
};
|
|
889
|
-
normalized.execute = (...args) => Promise.resolve(execute(...args)).then((result) => {
|
|
890
|
-
const delivery = finalizeToolResultWithDelivery(result);
|
|
891
|
-
recordDelivery(delivery, args);
|
|
892
|
-
return delivery.result;
|
|
893
|
-
}, (err) => {
|
|
894
|
-
const text = err instanceof Error ? err.message : String(err);
|
|
895
|
-
const delivery = finalizeToolResultWithDelivery({
|
|
896
|
-
...renderToolText(text),
|
|
897
|
-
isError: true
|
|
898
|
-
});
|
|
899
|
-
recordDelivery(delivery, args);
|
|
900
|
-
return delivery.result;
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
pi.registerTool(normalized);
|
|
904
|
-
} catch {}
|
|
905
|
-
}
|
|
906
|
-
pi.on("resources_discover", async (_event, _ctx) => {
|
|
907
|
-
return {
|
|
908
|
-
skillPaths: resolveSkillPaths(import.meta.url)
|
|
909
|
-
};
|
|
910
|
-
});
|
|
911
|
-
pi.on("session_start", wrapSessionEventHandler("session_start", async (event, ctx) => {
|
|
912
|
-
const sessionStartReason = event.reason;
|
|
913
|
-
const previousSessionFile = event.previousSessionFile;
|
|
914
|
-
const sessionIdentityParts = (() => {
|
|
915
|
-
try {
|
|
916
|
-
const sessionManager = ctx?.sessionManager;
|
|
917
|
-
return {
|
|
918
|
-
sessionId: sessionManager?.getSessionId?.(),
|
|
919
|
-
sessionFile: getSessionFile(ctx)
|
|
920
|
-
};
|
|
921
|
-
} catch {
|
|
922
|
-
return { sessionId: undefined, sessionFile: undefined };
|
|
923
|
-
}
|
|
924
|
-
})();
|
|
925
|
-
const sessionStartKey = sessionIdentityParts.sessionId ?? sessionIdentityParts.sessionFile;
|
|
926
|
-
const sessionStartIdentity = sessionStartKey === undefined ? undefined : `${sessionStartReason ?? ""}\x00${sessionStartKey}`;
|
|
927
|
-
const liveToolPlan = (() => {
|
|
928
|
-
if (getLensFlag("no-lazy-tools") === true || typeof pi.getActiveTools !== "function") {
|
|
929
|
-
return;
|
|
930
|
-
}
|
|
931
|
-
try {
|
|
932
|
-
const piWithActiveTools = pi;
|
|
933
|
-
const lazyNames = new Set(LAZY_TOOL_CATALOG.map((tool) => tool.name));
|
|
934
|
-
return planToolSet(piWithActiveTools.getActiveTools(), lazyNames, isFreshSessionStart(sessionStartReason) ? new Set : getRememberedLazyTools(getSessionFile(ctx)));
|
|
935
|
-
} catch {
|
|
936
|
-
return;
|
|
937
|
-
}
|
|
938
|
-
})();
|
|
939
|
-
if (sessionStartIdentity !== undefined && lastSessionStartIdentity === sessionStartIdentity && liveToolPlan?.changed !== true) {
|
|
940
|
-
emitBounded("session_start_duplicate_suppressed", sessionStartIdentity, {
|
|
941
|
-
durationMs: 0,
|
|
942
|
-
metadata: { reason: "duplicate start suppressed" }
|
|
943
|
-
}, {
|
|
944
|
-
ledgerKind: "session-start-duplicate",
|
|
945
|
-
risingEdgePer: "identity",
|
|
946
|
-
reason: "duplicate start suppressed"
|
|
947
|
-
});
|
|
948
|
-
return;
|
|
949
|
-
}
|
|
950
|
-
lastSessionStartIdentity = sessionStartIdentity;
|
|
951
|
-
const sessionStartMonotonicAt = performance.now();
|
|
952
|
-
warmDispatchAtSessionStart();
|
|
953
|
-
warmLspService().catch((err) => logExtension({
|
|
954
|
-
subsystem: "lsp",
|
|
955
|
-
level: "warn",
|
|
956
|
-
message: `LSP warm failed: ${err}`
|
|
957
|
-
}));
|
|
958
|
-
warmFormatters().catch((err) => logExtension({
|
|
959
|
-
subsystem: "format",
|
|
960
|
-
level: "warn",
|
|
961
|
-
message: `formatter warm failed: ${err}`
|
|
962
|
-
}));
|
|
963
|
-
rememberOwnEventCtx(ctx);
|
|
964
|
-
refreshCtxDerivedPlumbing();
|
|
965
|
-
const sessionStartFiredAt = Date.now();
|
|
966
|
-
try {
|
|
967
|
-
dbg("session_start fired");
|
|
968
|
-
const buildIdentity = getBuildIdentity(import.meta.url);
|
|
969
|
-
if (buildIdentity)
|
|
970
|
-
dbg(formatBuildIdentity(buildIdentity));
|
|
971
|
-
const sessionReason = sessionStartReason;
|
|
972
|
-
dbg(`session_start: disabled tools = ${disabledToolNames.join(",") || "none"}`);
|
|
973
|
-
const trustState = adoptProjectTrustFromPorts(hostPorts);
|
|
974
|
-
if (trustState !== "unknown") {
|
|
975
|
-
dbg(`session_start: project trust = ${trustState}`);
|
|
976
|
-
}
|
|
977
|
-
if (trustState === "untrusted") {
|
|
978
|
-
dbg("session_start: untrusted project — tool auto-install and LSP spawns are disabled for this session");
|
|
979
|
-
}
|
|
980
|
-
const stableSessionId = (() => {
|
|
981
|
-
try {
|
|
982
|
-
return ctx?.sessionManager?.getSessionId?.();
|
|
983
|
-
} catch {
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
986
|
-
})();
|
|
987
|
-
const sessionStartCwd = (() => {
|
|
988
|
-
try {
|
|
989
|
-
return ctx?.cwd;
|
|
990
|
-
} catch {
|
|
991
|
-
return;
|
|
992
|
-
}
|
|
993
|
-
})();
|
|
994
|
-
const sessionStartDecision = decideSessionStart(ctx, stableSessionId, sessionStartCwd);
|
|
995
|
-
ownedSessionRole = sessionStartDecision.runFullSessionStart ? "primary" : "concurrent-secondary";
|
|
996
|
-
if (!sessionStartDecision.runFullSessionStart) {
|
|
997
|
-
dbg(`session_start: ${sessionStartDecision.classification} detected (count=${sessionStartDecision.secondaryCount}, sameRoot=${sessionStartDecision.sameRoot}) — skipping handleSessionStart`);
|
|
998
|
-
logConcurrentSessionBind({
|
|
999
|
-
secondaryCount: sessionStartDecision.secondaryCount,
|
|
1000
|
-
sessionReason,
|
|
1001
|
-
sameCwd: ctx?.cwd === process.cwd(),
|
|
1002
|
-
classification: sessionStartDecision.classification,
|
|
1003
|
-
sameRoot: sessionStartDecision.sameRoot,
|
|
1004
|
-
primaryRoot: sessionStartDecision.primaryRoot
|
|
1005
|
-
});
|
|
1006
|
-
if (sessionStartDecision.sameRoot === false && typeof sessionStartCwd === "string") {
|
|
1007
|
-
registerInstanceRoot(sessionStartCwd).catch(() => {});
|
|
1008
|
-
}
|
|
1009
|
-
return;
|
|
1010
|
-
}
|
|
1011
|
-
resetVerifiedPathAttributionGuessCount();
|
|
1012
|
-
resetCurrentPhaseForSession();
|
|
1013
|
-
resetCacheFindingIdentitiesSession(stableSessionId, ownedSessionRole);
|
|
1014
|
-
resetOncePerSessionPhases();
|
|
1015
|
-
startSituationalToolTelemetrySession("pi");
|
|
1016
|
-
emitConcurrentSessionBindRollupAtSessionEnd(runtime.projectRoot);
|
|
1017
|
-
resetConcurrentSessionBindRollupCounts();
|
|
1018
|
-
try {
|
|
1019
|
-
const piWithActiveTools = pi;
|
|
1020
|
-
const sessionFile = getSessionFile(ctx);
|
|
1021
|
-
if (sessionStartReason === "fork") {
|
|
1022
|
-
inheritRememberedLazyTools(previousSessionFile, sessionFile);
|
|
1023
|
-
}
|
|
1024
|
-
if (isFreshSessionStart(sessionReason)) {
|
|
1025
|
-
clearRememberedLazyTools(sessionFile);
|
|
1026
|
-
}
|
|
1027
|
-
if (getLensFlag("no-lazy-tools") !== true && typeof piWithActiveTools.getActiveTools === "function" && typeof piWithActiveTools.setActiveTools === "function") {
|
|
1028
|
-
const lazyNames = new Set(LAZY_TOOL_CATALOG.map((t) => t.name));
|
|
1029
|
-
const plan = planToolSet(piWithActiveTools.getActiveTools(), lazyNames, getRememberedLazyTools(sessionFile));
|
|
1030
|
-
if (plan.changed) {
|
|
1031
|
-
piWithActiveTools.setActiveTools(plan.desired);
|
|
1032
|
-
recordToolSetMutation({
|
|
1033
|
-
addedCount: plan.addedCount,
|
|
1034
|
-
removedCount: plan.removedCount,
|
|
1035
|
-
reason: isFreshSessionStart(sessionReason) ? "fresh_session_lazy_deactivation" : "session_rebuild_restore",
|
|
1036
|
-
deferralApplies: supportsDeferredTools(ctx?.model)
|
|
1037
|
-
});
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
} catch (toolSetErr) {
|
|
1041
|
-
dbg(`dynamic tool set restore failed (older pi host lacking getActiveTools/setActiveTools, or a genuine host error): ${toolSetErr}`);
|
|
1042
|
-
}
|
|
1043
|
-
await configureWarmAttach(ctx.cwd ?? process.cwd());
|
|
1044
|
-
registerInstance(ctx.cwd ?? process.cwd()).catch(() => {});
|
|
1045
|
-
readInstanceRegistry().then((registry) => logVanishedInstances(registry)).catch(() => {}).finally(() => {
|
|
1046
|
-
sweepOrphans();
|
|
1047
|
-
});
|
|
1048
|
-
scheduleUntrackedOrphanSweep();
|
|
1049
|
-
checkCrossProcessLspBudget();
|
|
1050
|
-
readCrossProcessTouchesForSessionStart({
|
|
1051
|
-
cwd: ctx.cwd ?? process.cwd()
|
|
1052
|
-
}).then((entries) => {
|
|
1053
|
-
if (entries.length === 0)
|
|
1054
|
-
return;
|
|
1055
|
-
recordCrossProcessTouches(entries.map((e) => ({ path: e.path, reason: e.reason })));
|
|
1056
|
-
dbg(`session_start: cross-process nudge — ${entries.length} file(s) from other instance(s)`);
|
|
1057
|
-
}).catch((err) => {
|
|
1058
|
-
dbg(`session_start: cross-process nudge read failed: ${err}`);
|
|
1059
|
-
});
|
|
1060
|
-
updateRuntimeIdentityFromCtx(ctx);
|
|
1061
|
-
try {
|
|
1062
|
-
await ensureLSPConfigInitialized(ctx.cwd ?? process.cwd());
|
|
1063
|
-
} catch (cfgErr) {
|
|
1064
|
-
dbg(`lsp config init failed: ${cfgErr}`);
|
|
1065
|
-
}
|
|
1066
|
-
const handlerEnteredAt = Date.now();
|
|
1067
|
-
const emitHostReadyDelay = consumeHostReadyDelayAnchor();
|
|
1068
|
-
resetMemorySamplerCadence();
|
|
1069
|
-
resetTurnContext(stableSessionId);
|
|
1070
|
-
await bounded(handleSessionStart({
|
|
1071
|
-
ctxCwd: ctx.cwd,
|
|
1072
|
-
sessionStartFiredAt,
|
|
1073
|
-
sessionStartMonotonicAt,
|
|
1074
|
-
extensionLoadedAt: DM_LENS_LOADED_AT_MS,
|
|
1075
|
-
emitHostReadyDelay,
|
|
1076
|
-
sessionReason,
|
|
1077
|
-
handlerEnteredAt,
|
|
1078
|
-
globalConfig,
|
|
1079
|
-
projectConfig: loadDmLensProjectConfig(runtime.projectRoot),
|
|
1080
|
-
sessionStartClassification: sessionStartDecision.classification,
|
|
1081
|
-
sessionStartSameRoot: sessionStartDecision.sameRoot,
|
|
1082
|
-
getFlag: (name) => getLensFlag(name),
|
|
1083
|
-
notify: (msg, level) => notifyUi(ctx, msg, level),
|
|
1084
|
-
dbg,
|
|
1085
|
-
log,
|
|
1086
|
-
runtime,
|
|
1087
|
-
cacheManager,
|
|
1088
|
-
astGrepClient,
|
|
1089
|
-
bootstrap: sessionBootstrapAccess,
|
|
1090
|
-
ensureTool: async (name) => (await import("./clients/installer/index.js")).ensureTool(name),
|
|
1091
|
-
cleanStaleTsBuildInfo,
|
|
1092
|
-
resetDispatchBaselines,
|
|
1093
|
-
resetLSPService
|
|
1094
|
-
}), {
|
|
1095
|
-
ms: HOOK_WALL_BUDGET_MS.session_start,
|
|
1096
|
-
signal: ctx.signal,
|
|
1097
|
-
hook: "session_start",
|
|
1098
|
-
label: "handleSessionStart"
|
|
1099
|
-
});
|
|
1100
|
-
if (ctx.ui)
|
|
1101
|
-
updateLspStatus(ctx.ui.setStatus, ctx.ui.theme);
|
|
1102
|
-
runtime.setSessionLifecycle({
|
|
1103
|
-
sessionId: stableSessionId,
|
|
1104
|
-
reason: sessionReason
|
|
1105
|
-
});
|
|
1106
|
-
const reasonLabel = sessionReason ?? "startup";
|
|
1107
|
-
const startMode = sessionStartMode(sessionReason, !!pendingForkSnapshot);
|
|
1108
|
-
if (startMode === "fork" && pendingForkSnapshot) {
|
|
1109
|
-
clearWidgetState();
|
|
1110
|
-
importWidgetState(pendingForkSnapshot);
|
|
1111
|
-
const forkedFileCount = pendingForkSnapshot.files.length;
|
|
1112
|
-
pendingForkSnapshot = undefined;
|
|
1113
|
-
let forkReadImport;
|
|
1114
|
-
if (pendingForkReadGuard) {
|
|
1115
|
-
forkReadImport = runtime.readGuard.importState(pendingForkReadGuard);
|
|
1116
|
-
pendingForkReadGuard = undefined;
|
|
1117
|
-
}
|
|
1118
|
-
if (stableSessionId) {
|
|
1119
|
-
saveSessionState(ctx.cwd ?? process.cwd(), stableSessionId, exportWidgetState(), runtime.readGuard.exportState());
|
|
1120
|
-
}
|
|
1121
|
-
dbg(`session_start: fork — branched ${forkedFileCount} file(s) from source` + (forkReadImport ? `, read-guard +${forkReadImport.imported} (dropped ${forkReadImport.dropped})` : ""));
|
|
1122
|
-
} else if (startMode === "keep") {
|
|
1123
|
-
dbg("session_start: reload — keeping widget state");
|
|
1124
|
-
} else if (startMode === "clean") {
|
|
1125
|
-
pendingForkSnapshot = undefined;
|
|
1126
|
-
pendingForkReadGuard = undefined;
|
|
1127
|
-
clearWidgetState();
|
|
1128
|
-
dbg("session_start: new — clean widget");
|
|
1129
|
-
} else {
|
|
1130
|
-
pendingForkSnapshot = undefined;
|
|
1131
|
-
pendingForkReadGuard = undefined;
|
|
1132
|
-
clearWidgetState();
|
|
1133
|
-
if (stableSessionId) {
|
|
1134
|
-
const persisted = await loadSessionState(ctx.cwd ?? process.cwd(), stableSessionId);
|
|
1135
|
-
if (persisted?.widget) {
|
|
1136
|
-
const fresh = await dropStaleFiles(persisted.widget, persisted.savedAt);
|
|
1137
|
-
const dropped = persisted.widget.files.length - fresh.files.length;
|
|
1138
|
-
importWidgetState(fresh);
|
|
1139
|
-
const readImport = runtime.readGuard.importState(persisted.readGuard);
|
|
1140
|
-
dbg(`session_start: ${reasonLabel} ${stableSessionId} — rehydrated ${fresh.files.length} file(s)` + (dropped > 0 ? `, dropped ${dropped} stale` : "") + (readImport.imported > 0 || readImport.dropped > 0 ? `; read-guard +${readImport.imported} read(s) (dropped ${readImport.dropped} stale)` : ""));
|
|
1141
|
-
} else {
|
|
1142
|
-
dbg(`session_start: ${reasonLabel} ${stableSessionId} — no persisted state (clean)`);
|
|
1143
|
-
}
|
|
1144
|
-
} else {
|
|
1145
|
-
dbg(`session_start: ${reasonLabel} — no stable session id (clean)`);
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
if (lensWidgetVisible) {
|
|
1149
|
-
mountLensWidget(ctx.ui, readExtensionMode(ctx));
|
|
1150
|
-
}
|
|
1151
|
-
} catch (sessionErr) {
|
|
1152
|
-
if (isStaleExtensionCtxError(sessionErr))
|
|
1153
|
-
throw sessionErr;
|
|
1154
|
-
surfaceHandlerCrash("session_start", sessionErr, { dbg });
|
|
1155
|
-
}
|
|
1156
|
-
}, { dbg }));
|
|
1157
|
-
pi.on("session_before_fork", () => {
|
|
1158
|
-
try {
|
|
1159
|
-
pendingForkSnapshot = exportWidgetState();
|
|
1160
|
-
pendingForkReadGuard = runtime.readGuard.exportState();
|
|
1161
|
-
dbg(`session_before_fork: stashed ${pendingForkSnapshot.files.length} file(s) + ${pendingForkReadGuard.reads.length} read-guard file(s) for the fork`);
|
|
1162
|
-
} catch (forkErr) {
|
|
1163
|
-
surfaceHandlerCrash("session_before_fork", forkErr, { dbg });
|
|
1164
|
-
}
|
|
1165
|
-
});
|
|
1166
|
-
pi.on("tool_call", async (event, ctx) => {
|
|
1167
|
-
const toolEntry = toolRegistryEntryForPi(event.toolName ?? "");
|
|
1168
|
-
if (toolEntry && "situational" in toolEntry && toolEntry.situational) {
|
|
1169
|
-
observeSituationalToolCall(toolEntry.name);
|
|
1170
|
-
}
|
|
1171
|
-
return handleToolCall({
|
|
1172
|
-
event,
|
|
1173
|
-
ctx,
|
|
1174
|
-
lensEnabled,
|
|
1175
|
-
getFlag: (name) => getLensFlag(name),
|
|
1176
|
-
dbg,
|
|
1177
|
-
runtime,
|
|
1178
|
-
cacheManager,
|
|
1179
|
-
ensureLSPConfigInitialized,
|
|
1180
|
-
updateLspStatus,
|
|
1181
|
-
resetLSPService
|
|
1182
|
-
});
|
|
1183
|
-
});
|
|
1184
|
-
const onToolResult = async (event, ctx) => {
|
|
1185
|
-
rememberOwnEventCtx(ctx);
|
|
1186
|
-
if (!lensEnabled)
|
|
1187
|
-
return;
|
|
1188
|
-
updateRuntimeIdentityFromCtx(ctx);
|
|
1189
|
-
setAmbientAbortSignal(ctx?.signal);
|
|
1190
|
-
const rtToolName = event?.toolName;
|
|
1191
|
-
const rtMutation = classifyMutatingTool(event, { recognizeOnly: true });
|
|
1192
|
-
const editClass = isEditClassToolResult(event, ctx?.cwd ?? runtime.projectRoot ?? process.cwd());
|
|
1193
|
-
if (rtMutation) {
|
|
1194
|
-
logLatency({
|
|
1195
|
-
type: "phase",
|
|
1196
|
-
phase: "tool_result_received",
|
|
1197
|
-
filePath: rtMutation.path ?? event?.input?.path ?? "<unknown>",
|
|
1198
|
-
durationMs: 0,
|
|
1199
|
-
metadata: {
|
|
1200
|
-
toolName: rtToolName,
|
|
1201
|
-
mutationKind: rtMutation.kind,
|
|
1202
|
-
mutationProvenance: rtMutation.provenance
|
|
1203
|
-
}
|
|
1204
|
-
});
|
|
1205
|
-
}
|
|
1206
|
-
try {
|
|
1207
|
-
const resident = editClass ? await bounded(loadBootstrapClients(), {
|
|
1208
|
-
ms: HOOK_WALL_BUDGET_MS.tool_result_edit,
|
|
1209
|
-
signal: ctx.signal,
|
|
1210
|
-
hook: "tool_result_edit",
|
|
1211
|
-
label: "tool-result-bootstrap"
|
|
1212
|
-
}) : peekBootstrapClients();
|
|
1213
|
-
return await bounded(handleToolResult({
|
|
1214
|
-
signal: ctx.signal,
|
|
1215
|
-
event,
|
|
1216
|
-
getFlag: (name, filePath) => getLensFlag(name, filePath),
|
|
1217
|
-
getFlagSource: (name, filePath) => getLensFlagSource(name, filePath),
|
|
1218
|
-
dbg,
|
|
1219
|
-
runtime,
|
|
1220
|
-
cacheManager,
|
|
1221
|
-
biomeClient: resident?.biomeClient,
|
|
1222
|
-
ruffClient: resident?.ruffClient,
|
|
1223
|
-
metricsClient: resident?.metricsClient,
|
|
1224
|
-
resetLSPService,
|
|
1225
|
-
readGuard: runtime.readGuard,
|
|
1226
|
-
agentBehaviorRecord: (toolName, filePath) => (resident?.agentBehaviorClient ?? getAgentBehaviorClient()).recordToolCall(toolName, filePath),
|
|
1227
|
-
formatBehaviorWarnings: (warnings) => (resident?.agentBehaviorClient ?? getAgentBehaviorClient()).formatWarnings(warnings),
|
|
1228
|
-
sessionId: getStableSessionId(ctx)
|
|
1229
|
-
}), {
|
|
1230
|
-
ms: editClass ? HOOK_WALL_BUDGET_MS.tool_result_edit : HOOK_WALL_BUDGET_MS.tool_result_read_only,
|
|
1231
|
-
signal: ctx.signal,
|
|
1232
|
-
hook: editClass ? "tool_result_edit" : "tool_result_read_only",
|
|
1233
|
-
label: "handleToolResult"
|
|
1234
|
-
});
|
|
1235
|
-
} finally {
|
|
1236
|
-
setAmbientAbortSignal(undefined);
|
|
1237
|
-
}
|
|
1238
|
-
};
|
|
1239
|
-
pi.on("tool_result", wrapSessionEventHandler("tool_result", onToolResult, {
|
|
1240
|
-
dbg,
|
|
1241
|
-
budgetKey: (event, _ctx) => {
|
|
1242
|
-
try {
|
|
1243
|
-
return isEditClassToolResult(event, _ctx?.cwd ?? runtime.projectRoot ?? process.cwd()) ? "tool_result_edit" : "tool_result_read_only";
|
|
1244
|
-
} catch {
|
|
1245
|
-
return "tool_result_read_only";
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
}));
|
|
1249
|
-
const onTurnStart = (_event, ctx) => {
|
|
1250
|
-
rememberOwnEventCtx(ctx);
|
|
1251
|
-
adoptProjectTrustFromPorts(hostPorts);
|
|
1252
|
-
if (lensWidgetVisible && ctx?.ui && (mountedLensWidgetUi === undefined || mountedLensWidgetUi !== ctx.ui)) {
|
|
1253
|
-
mountLensWidget(ctx.ui, readExtensionMode(ctx));
|
|
1254
|
-
}
|
|
1255
|
-
runtime.beginTurn();
|
|
1256
|
-
clearLastAnalyzedStateCache();
|
|
1257
|
-
const cwd = ctx?.cwd ?? process.cwd();
|
|
1258
|
-
readCrossProcessTouchesForTurnStart({ cwd }).then((entries) => {
|
|
1259
|
-
if (entries.length === 0)
|
|
1260
|
-
return;
|
|
1261
|
-
recordCrossProcessTouches(entries.map((e) => ({ path: e.path, reason: e.reason })));
|
|
1262
|
-
dbg(`turn_start: cross-process nudge — ${entries.length} file(s) from other instance(s)`);
|
|
1263
|
-
}).catch((err) => {
|
|
1264
|
-
dbg(`turn_start: cross-process nudge read failed: ${err}`);
|
|
1265
|
-
});
|
|
1266
|
-
};
|
|
1267
|
-
pi.on("turn_start", wrapSessionEventHandler("turn_start", onTurnStart, { dbg }));
|
|
1268
|
-
async function runObservedSettledSweepSafely(ctx) {
|
|
1269
|
-
const cwd = ctx.cwd ?? runtime.projectRoot;
|
|
1270
|
-
try {
|
|
1271
|
-
const result = await runObservedSettledSweep({
|
|
1272
|
-
turnIndex: runtime.turnIndex,
|
|
1273
|
-
getTrackedPaths: () => collectTrackedPaths({
|
|
1274
|
-
readGuard: runtime.readGuard,
|
|
1275
|
-
cwd,
|
|
1276
|
-
limit: OBSERVED_TRACKED_MAX_FILES
|
|
1277
|
-
}),
|
|
1278
|
-
record: replayThroughMutationBridge,
|
|
1279
|
-
getStoredLineHashes: (candidate) => storedLineHashesFor(runtime.readGuard, candidate),
|
|
1280
|
-
isRecordable: (candidate) => isRecordableProjectPath(candidate, runtime.projectRoot),
|
|
1281
|
-
signal: ctx?.signal,
|
|
1282
|
-
dbg
|
|
1283
|
-
});
|
|
1284
|
-
if (result.drifted.length > 0 || result.unverifiable.length > 0) {
|
|
1285
|
-
dbg(`observed_settled_sweep: ${result.drifted.length} drifted file(s), ${result.replayed} replayed, ` + `${result.unverifiable.length} unverifiable; scanned ${result.scanned}, ${result.notReachedThisPass} not reached this pass (cursor ${result.cursor})`);
|
|
1286
|
-
}
|
|
1287
|
-
} catch (sweepErr) {
|
|
1288
|
-
surfaceHandlerCrash("observed_settled_sweep", sweepErr, { dbg });
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
async function refreshObservedLedgerSafely(ctx) {
|
|
1292
|
-
const signal = ctx?.signal;
|
|
1293
|
-
try {
|
|
1294
|
-
await refreshObservedMutationLedger({
|
|
1295
|
-
turnIndex: runtime.turnIndex,
|
|
1296
|
-
getStoredLineHashes: (candidate) => storedLineHashesFor(runtime.readGuard, candidate),
|
|
1297
|
-
signal
|
|
1298
|
-
});
|
|
1299
|
-
} catch (refreshErr) {
|
|
1300
|
-
surfaceHandlerCrash("observed_ledger_refresh", refreshErr, { dbg });
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
async function runDeferredMutationDrain(ctx) {
|
|
1304
|
-
const currentSessionId = getStableSessionId(ctx);
|
|
1305
|
-
const emission = classifyOwnedSessionEmission(ctx, currentSessionId);
|
|
1306
|
-
if (emission === "concurrent-secondary") {
|
|
1307
|
-
dbg(`deferred_mutation_drain: concurrent secondary session detected — skipping (sessionId=${currentSessionId})`);
|
|
1308
|
-
logLatency({
|
|
1309
|
-
type: "phase",
|
|
1310
|
-
filePath: ctx.cwd ?? "<dm-lens>",
|
|
1311
|
-
phase: "agent_end_concurrent_secondary_skip",
|
|
1312
|
-
durationMs: 0,
|
|
1313
|
-
metadata: { sessionId: currentSessionId }
|
|
1314
|
-
});
|
|
1315
|
-
return;
|
|
1316
|
-
}
|
|
1317
|
-
await handleAgentEnd({
|
|
1318
|
-
signal: ctx.signal,
|
|
1319
|
-
ctxCwd: ctx.cwd,
|
|
1320
|
-
getFlag: (name, filePath) => getLensFlag(name, filePath),
|
|
1321
|
-
getFlagSource: (name, filePath) => getLensFlagSource(name, filePath),
|
|
1322
|
-
notify: (msg, level) => notifyUi(ctx, msg, level),
|
|
1323
|
-
dbg,
|
|
1324
|
-
runtime,
|
|
1325
|
-
cacheManager,
|
|
1326
|
-
getFormatService: () => getFormatService(runtime.telemetrySessionId, true),
|
|
1327
|
-
getAutofixClients: async () => {
|
|
1328
|
-
const { biomeClient, ruffClient } = await loadBootstrapClients();
|
|
1329
|
-
return { biomeClient, ruffClient };
|
|
1330
|
-
},
|
|
1331
|
-
currentSessionId
|
|
1332
|
-
});
|
|
1333
|
-
if (ctx.ui?.setStatus && ctx.ui.theme) {
|
|
1334
|
-
updateLspStatus(ctx.ui.setStatus, ctx.ui.theme);
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
const onAgentEnd = async (_event, ctx) => {
|
|
1338
|
-
if (!lensEnabled)
|
|
1339
|
-
return;
|
|
1340
|
-
try {
|
|
1341
|
-
setAmbientAbortSignal(ctx?.signal);
|
|
1342
|
-
await flushDebouncedToolResults();
|
|
1343
|
-
if (ctx.ui)
|
|
1344
|
-
updateLspStatus(ctx.ui.setStatus, ctx.ui.theme);
|
|
1345
|
-
} catch (agentEndErr) {
|
|
1346
|
-
if (isStaleExtensionCtxError(agentEndErr))
|
|
1347
|
-
throw agentEndErr;
|
|
1348
|
-
surfaceHandlerCrash("agent_end", agentEndErr, { dbg });
|
|
1349
|
-
} finally {
|
|
1350
|
-
setAmbientAbortSignal(undefined);
|
|
1351
|
-
}
|
|
1352
|
-
};
|
|
1353
|
-
pi.on("agent_end", wrapSessionEventHandler("agent_end", onAgentEnd, { dbg }));
|
|
1354
|
-
const onTurnEnd = async (_event, ctx) => {
|
|
1355
|
-
if (!lensEnabled)
|
|
1356
|
-
return;
|
|
1357
|
-
try {
|
|
1358
|
-
setAmbientAbortSignal(ctx?.signal);
|
|
1359
|
-
const repaintLspStatus = captureLspStatusRepaint(ctx);
|
|
1360
|
-
const elStats = getEventLoopStats();
|
|
1361
|
-
const loopMaxMs = elStats?.maxMs ?? 0;
|
|
1362
|
-
const suspectSystemStall = elStats?.suspectSystemStall ?? false;
|
|
1363
|
-
if (shouldLogLoopBlock(loopMaxMs)) {
|
|
1364
|
-
const lastPhase = getLastLoggedPhase();
|
|
1365
|
-
const recentPhases = getRecentLoggedPhases(3);
|
|
1366
|
-
const blockSampledAtMs = Date.now();
|
|
1367
|
-
const inFlight = getPhaseForWindow(blockSampledAtMs - loopMaxMs, blockSampledAtMs);
|
|
1368
|
-
const isNewSessionWorst = shouldLogWorstBlock(loopMaxMs, lastLoggedLoopWorstMs);
|
|
1369
|
-
emitBounded("loop_block", LOOP_BLOCK_IDENTITY, {
|
|
1370
|
-
type: "phase",
|
|
1371
|
-
durationMs: Math.round(loopMaxMs),
|
|
1372
|
-
metadata: {
|
|
1373
|
-
worstSoFar: isNewSessionWorst,
|
|
1374
|
-
turnIndex: runtime.turnIndex,
|
|
1375
|
-
suspectSystemStall,
|
|
1376
|
-
stallClass: elStats?.stallClass,
|
|
1377
|
-
cpuCoverageRatio: elStats?.cpuCoverageRatio,
|
|
1378
|
-
windowCpuMs: elStats?.windowCpuMs,
|
|
1379
|
-
windowWallMs: elStats?.windowWallMs,
|
|
1380
|
-
lastPhase: lastPhase?.phase,
|
|
1381
|
-
lastPhaseAt: lastPhase?.ts,
|
|
1382
|
-
recentPhases,
|
|
1383
|
-
inFlightPhase: inFlight?.phase,
|
|
1384
|
-
inFlightPhaseStartedAt: inFlight?.startedAt,
|
|
1385
|
-
inFlightPhaseElapsedMs: inFlight?.elapsedMs,
|
|
1386
|
-
inFlightPhaseStillRunning: inFlight?.stillRunning
|
|
1387
|
-
}
|
|
1388
|
-
});
|
|
1389
|
-
if (suspectSystemStall) {
|
|
1390
|
-
sessionSuspectedStalls += 1;
|
|
1391
|
-
} else if (isNewSessionWorst) {
|
|
1392
|
-
lastLoggedLoopWorstMs = loopMaxMs;
|
|
1393
|
-
sessionWorstRealBlockMs = Math.max(sessionWorstRealBlockMs, loopMaxMs);
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
resetEventLoopMonitor();
|
|
1397
|
-
if (shouldEmitMemorySampleAdaptive(runtime.turnIndex)) {
|
|
1398
|
-
try {
|
|
1399
|
-
const sample = buildMemorySample(runtime.wordIndex, undefined, undefined, {
|
|
1400
|
-
sessionAgeMs: Math.max(0, Date.now() - runtime.sessionStartedAt),
|
|
1401
|
-
sessionStartedAt: runtime.sessionStartedAt,
|
|
1402
|
-
turnCount: runtime.turnIndex,
|
|
1403
|
-
root: getActivePrimaryRoot()
|
|
1404
|
-
});
|
|
1405
|
-
logLatency({
|
|
1406
|
-
type: "phase",
|
|
1407
|
-
filePath: "<dm-lens>",
|
|
1408
|
-
phase: "memory_sample",
|
|
1409
|
-
durationMs: 0,
|
|
1410
|
-
metadata: { turnIndex: runtime.turnIndex, ...sample }
|
|
1411
|
-
});
|
|
1412
|
-
recordMemorySampleOutcome(sample.process.heapUsedBytes, runtime.turnIndex);
|
|
1413
|
-
} catch {}
|
|
1414
|
-
}
|
|
1415
|
-
if (shouldCheckSmellsThisTurn(runtime.turnIndex)) {
|
|
1416
|
-
try {
|
|
1417
|
-
for (const note of checkSmellsAndNoteOnce(countRecentSmells(undefined, runtime.sessionStartedAt))) {
|
|
1418
|
-
notifyUi(ctx, note, "warning");
|
|
1419
|
-
}
|
|
1420
|
-
} catch {}
|
|
1421
|
-
}
|
|
1422
|
-
await flushDebouncedToolResults();
|
|
1423
|
-
const { knipClient, deadCodeClients, depChecker, testRunnerClient } = await loadBootstrapClients();
|
|
1424
|
-
await handleTurnEnd({
|
|
1425
|
-
ctxCwd: ctx.cwd,
|
|
1426
|
-
getFlag: (name) => getLensFlag(name),
|
|
1427
|
-
dbg,
|
|
1428
|
-
runtime,
|
|
1429
|
-
cacheManager,
|
|
1430
|
-
knipClient,
|
|
1431
|
-
deadCodeClients,
|
|
1432
|
-
depChecker,
|
|
1433
|
-
testRunnerClient,
|
|
1434
|
-
sessionId: getStableSessionId(ctx),
|
|
1435
|
-
signal: ctx.signal,
|
|
1436
|
-
onTestRunnerComplete: (delivery) => stageTestRunnerDelivery({
|
|
1437
|
-
...delivery,
|
|
1438
|
-
owner: {
|
|
1439
|
-
ownerId: testRunnerDeliveryOwnerId,
|
|
1440
|
-
cacheManager,
|
|
1441
|
-
runtime,
|
|
1442
|
-
getCtx: () => ownEventCtx ?? {}
|
|
1443
|
-
}
|
|
1444
|
-
}),
|
|
1445
|
-
resetLSPService: () => {
|
|
1446
|
-
try {
|
|
1447
|
-
resetLSPService({ reason: "idle" });
|
|
1448
|
-
} finally {
|
|
1449
|
-
repaintLspStatus?.();
|
|
1450
|
-
}
|
|
1451
|
-
},
|
|
1452
|
-
resetFormatService
|
|
1453
|
-
});
|
|
1454
|
-
repaintLspStatus?.();
|
|
1455
|
-
if (runtime.hasStableSessionId) {
|
|
1456
|
-
saveSessionState(ctx.cwd ?? process.cwd(), runtime.telemetrySessionId, exportWidgetState(), runtime.readGuard.exportState());
|
|
1457
|
-
}
|
|
1458
|
-
} catch (turnEndErr) {
|
|
1459
|
-
if (isStaleExtensionCtxError(turnEndErr))
|
|
1460
|
-
throw turnEndErr;
|
|
1461
|
-
surfaceHandlerCrash("turn_end", turnEndErr, { dbg });
|
|
1462
|
-
} finally {
|
|
1463
|
-
setAmbientAbortSignal(undefined);
|
|
1464
|
-
}
|
|
1465
|
-
};
|
|
1466
|
-
pi.on("turn_end", wrapSessionEventHandler("turn_end", onTurnEnd, { dbg }));
|
|
1467
|
-
registerBuiltinQuietWindowTasks(() => runtime);
|
|
1468
|
-
if (!_testRunnerDeliveryRegistered) {
|
|
1469
|
-
_testRunnerDeliveryRegistered = true;
|
|
1470
|
-
registerQuietWindowTask("test_runner_delivery", (quietContext) => {
|
|
1471
|
-
deliverStagedTestRunnerFindings(quietContext);
|
|
1472
|
-
});
|
|
1473
|
-
}
|
|
1474
|
-
registerCascadeTierReconcileTask(() => getLSPService(), {
|
|
1475
|
-
onResolvedFound: ({ filePath, diagnostics, publishedAt }) => {
|
|
1476
|
-
const run = buildResolvedFoundCascadeRun(runtime.projectRoot, {
|
|
1477
|
-
filePath,
|
|
1478
|
-
diagnostics,
|
|
1479
|
-
publishedAt
|
|
1480
|
-
});
|
|
1481
|
-
if (run)
|
|
1482
|
-
runtime.appendCascadeRun(run);
|
|
1483
|
-
},
|
|
1484
|
-
onResolvedClean: ({ filePath, publishedAt }) => {
|
|
1485
|
-
reconcileCascadeNeighborLspErrors(filePath, [], undefined, publishedAt);
|
|
1486
|
-
}
|
|
1487
|
-
});
|
|
1488
|
-
_turnSummaryEmitCtx = {
|
|
1489
|
-
pi,
|
|
1490
|
-
getLensFlag: (name) => getLensFlag(name),
|
|
1491
|
-
isLensEnabled: () => lensEnabled
|
|
1492
|
-
};
|
|
1493
|
-
if (!_turnSummaryEmitRegistered) {
|
|
1494
|
-
_turnSummaryEmitRegistered = true;
|
|
1495
|
-
registerQuietWindowTask("turn_summary_emit", () => {
|
|
1496
|
-
const emitCtx = _turnSummaryEmitCtx;
|
|
1497
|
-
if (!emitCtx || !emitCtx.isLensEnabled())
|
|
1498
|
-
return;
|
|
1499
|
-
let turnSummaryEnabled;
|
|
1500
|
-
try {
|
|
1501
|
-
turnSummaryEnabled = emitCtx.getLensFlag("lens-turn-summary");
|
|
1502
|
-
} catch (err) {
|
|
1503
|
-
if (isStaleExtensionCtxError(err)) {
|
|
1504
|
-
dbg("turn_summary_emit: skipped — captured pi ctx is stale (session replaced/reloaded before the quiet window ran)");
|
|
1505
|
-
return;
|
|
1506
|
-
}
|
|
1507
|
-
throw err;
|
|
1508
|
-
}
|
|
1509
|
-
if (!turnSummaryEnabled)
|
|
1510
|
-
return;
|
|
1511
|
-
if (runtime.turnSummary.isEmpty())
|
|
1512
|
-
return;
|
|
1513
|
-
const summaryStart = Date.now();
|
|
1514
|
-
const cwd = runtime.projectRoot || process.cwd();
|
|
1515
|
-
const details = runtime.turnSummary.consume(runtime.turnIndex, (fp) => toRunnerDisplayPath(cwd, fp));
|
|
1516
|
-
const line = formatTurnSummaryLine(details);
|
|
1517
|
-
const sendMessage = emitCtx.pi.sendMessage;
|
|
1518
|
-
if (typeof sendMessage === "function") {
|
|
1519
|
-
try {
|
|
1520
|
-
sendMessage.call(emitCtx.pi, {
|
|
1521
|
-
customType: TURN_SUMMARY_CUSTOM_TYPE,
|
|
1522
|
-
content: line,
|
|
1523
|
-
display: true,
|
|
1524
|
-
details
|
|
1525
|
-
});
|
|
1526
|
-
recordTurnEndAdvisoryBytes(runtime.telemetrySessionId, Buffer.byteLength(line, "utf8"));
|
|
1527
|
-
} catch (sendErr) {
|
|
1528
|
-
if (isStaleExtensionCtxError(sendErr)) {
|
|
1529
|
-
dbg("turn_summary_emit: skipped emit — pi ctx went stale (session replaced/reloaded)");
|
|
1530
|
-
return;
|
|
1531
|
-
}
|
|
1532
|
-
dbg(`turn-summary sendMessage failed: ${sendErr}`);
|
|
1533
|
-
}
|
|
1534
|
-
} else {
|
|
1535
|
-
dbg("turn-summary: pi.sendMessage unavailable on this host, skipping emit");
|
|
1536
|
-
}
|
|
1537
|
-
logLatency({
|
|
1538
|
-
type: "phase",
|
|
1539
|
-
toolName: "agent_settled",
|
|
1540
|
-
filePath: cwd,
|
|
1541
|
-
phase: "turn_summary",
|
|
1542
|
-
durationMs: Date.now() - summaryStart,
|
|
1543
|
-
metadata: {
|
|
1544
|
-
files: details.files.length,
|
|
1545
|
-
diagnostics: details.counts.diagnostics,
|
|
1546
|
-
autofixes: details.counts.autofixes,
|
|
1547
|
-
formats: details.counts.formats
|
|
1548
|
-
}
|
|
1549
|
-
});
|
|
1550
|
-
});
|
|
1551
|
-
}
|
|
1552
|
-
const onAgentSettled = async (_event, ctx) => {
|
|
1553
|
-
if (!lensEnabled)
|
|
1554
|
-
return;
|
|
1555
|
-
rememberOwnEventCtx(ctx);
|
|
1556
|
-
try {
|
|
1557
|
-
setAmbientAbortSignal(ctx?.signal);
|
|
1558
|
-
try {
|
|
1559
|
-
await runObservedSettledSweepSafely(ctx);
|
|
1560
|
-
await runDeferredMutationDrain(ctx);
|
|
1561
|
-
await refreshObservedLedgerSafely(ctx);
|
|
1562
|
-
} catch (drainErr) {
|
|
1563
|
-
if (isStaleExtensionCtxError(drainErr))
|
|
1564
|
-
throw drainErr;
|
|
1565
|
-
surfaceHandlerCrash("agent_settled deferred_mutation_drain", drainErr, {
|
|
1566
|
-
dbg
|
|
1567
|
-
});
|
|
1568
|
-
} finally {
|
|
1569
|
-
setAmbientAbortSignal(undefined);
|
|
1570
|
-
}
|
|
1571
|
-
const cwd = ctx?.cwd;
|
|
1572
|
-
runQuietWindow({
|
|
1573
|
-
runtime,
|
|
1574
|
-
dbg,
|
|
1575
|
-
cwd,
|
|
1576
|
-
sessionId: getStableSessionId(ctx),
|
|
1577
|
-
ownerId: testRunnerDeliveryOwnerId
|
|
1578
|
-
}).catch((err) => {
|
|
1579
|
-
surfaceHandlerCrash("quiet_window", err, { dbg, rethrow: false });
|
|
1580
|
-
});
|
|
1581
|
-
dumpActiveHandles("agent_settled");
|
|
1582
|
-
} catch (settledErr) {
|
|
1583
|
-
setAmbientAbortSignal(undefined);
|
|
1584
|
-
throw settledErr;
|
|
1585
|
-
}
|
|
1586
|
-
};
|
|
1587
|
-
try {
|
|
1588
|
-
pi.on("agent_settled", wrapSessionEventHandler("agent_settled", onAgentSettled, { dbg }));
|
|
1589
|
-
} catch (registerErr) {
|
|
1590
|
-
dbg(`agent_settled registration failed (older pi host?): ${registerErr}`);
|
|
1591
|
-
}
|
|
1592
|
-
pi.on("session_shutdown", (event, ctx) => {
|
|
1593
|
-
const stableSessionId = (() => {
|
|
1594
|
-
try {
|
|
1595
|
-
return ctx?.sessionManager?.getSessionId?.();
|
|
1596
|
-
} catch {
|
|
1597
|
-
return;
|
|
1598
|
-
}
|
|
1599
|
-
})();
|
|
1600
|
-
const shutdownCwd = (() => {
|
|
1601
|
-
try {
|
|
1602
|
-
return ctx?.cwd;
|
|
1603
|
-
} catch {
|
|
1604
|
-
return;
|
|
1605
|
-
}
|
|
1606
|
-
})();
|
|
1607
|
-
const shutdownClassification = classifyOwnedSessionShutdown(ctx, stableSessionId, shutdownCwd);
|
|
1608
|
-
if (shutdownClassification === "secondary") {
|
|
1609
|
-
emitCacheUsageSummaryAtSessionEnd(stableSessionId, "concurrent-secondary");
|
|
1610
|
-
clearCachePrefixSession(stableSessionId, "concurrent-secondary");
|
|
1611
|
-
decrementSecondarySessionCount();
|
|
1612
|
-
try {
|
|
1613
|
-
const secondaryRoot = shutdownCwd;
|
|
1614
|
-
const primaryRoot = getActivePrimaryRoot();
|
|
1615
|
-
if (typeof secondaryRoot === "string" && secondaryRoot.length > 0 && primaryRoot !== undefined && normalizeFilePath(secondaryRoot) !== primaryRoot) {
|
|
1616
|
-
deregisterInstanceRoot(secondaryRoot).catch(() => {});
|
|
1617
|
-
}
|
|
1618
|
-
} catch {}
|
|
1619
|
-
dbg("session_shutdown: concurrent secondary — skipping shared-infra teardown");
|
|
1620
|
-
return;
|
|
1621
|
-
}
|
|
1622
|
-
const shutdownEvent = event;
|
|
1623
|
-
const shutdownReason = shutdownEvent?.reason;
|
|
1624
|
-
const switchesSessionFile = typeof shutdownEvent?.targetSessionFile === "string" && shutdownEvent.targetSessionFile.length > 0;
|
|
1625
|
-
if (switchesSessionFile || shutdownReason === "quit" || shutdownReason === undefined) {
|
|
1626
|
-
endSituationalToolTelemetry();
|
|
1627
|
-
}
|
|
1628
|
-
emitCacheUsageSummaryAtSessionEnd(stableSessionId, "primary");
|
|
1629
|
-
clearCachePrefixSession(stableSessionId, "primary");
|
|
1630
|
-
cancelLSPIdleReset();
|
|
1631
|
-
deregisterInstance();
|
|
1632
|
-
releasePrimarySession();
|
|
1633
|
-
markAnalyzerBootstrapShutdown();
|
|
1634
|
-
resetLSPService({
|
|
1635
|
-
fast: true,
|
|
1636
|
-
processExiting: true,
|
|
1637
|
-
reason: "session_shutdown"
|
|
1638
|
-
});
|
|
1639
|
-
emitBusEventRollupAtSessionEnd(runtime.projectRoot);
|
|
1640
|
-
emitVerifiedPathAttributionRollup(runtime.projectRoot);
|
|
1641
|
-
emitConcurrentSessionBindRollupAtSessionEnd(runtime.projectRoot);
|
|
1642
|
-
dumpActiveHandles("session_shutdown");
|
|
1643
|
-
});
|
|
1644
|
-
try {
|
|
1645
|
-
pi.on?.("message_end", (event, ctx) => {
|
|
1646
|
-
if (!lensEnabled)
|
|
1647
|
-
return;
|
|
1648
|
-
try {
|
|
1649
|
-
const sessionId = getStableSessionId(ctx);
|
|
1650
|
-
const ctxActive = probeCtxActive(ctx);
|
|
1651
|
-
const staleCtx = ctxActive === false;
|
|
1652
|
-
if (ctxActive === true) {
|
|
1653
|
-
noteLiveMessageEndSessionId(sessionId);
|
|
1654
|
-
}
|
|
1655
|
-
logCacheUsage(event?.message, dbg, {
|
|
1656
|
-
sessionId,
|
|
1657
|
-
sessionRole: classifyOwnedSessionEmission(ctx, sessionId),
|
|
1658
|
-
turnIndex: runtime.turnIndex
|
|
1659
|
-
});
|
|
1660
|
-
if (staleCtx) {
|
|
1661
|
-
const degradation = {
|
|
1662
|
-
kind: "cache-usage-attribution-stale",
|
|
1663
|
-
subject: "message_end",
|
|
1664
|
-
reason: "message_end met a stale extension ctx; cache_usage row wrote without a stable session id",
|
|
1665
|
-
metadata: {
|
|
1666
|
-
sessionId: getLastLiveMessageEndSessionId() ?? "unknown"
|
|
1667
|
-
}
|
|
1668
|
-
};
|
|
1669
|
-
incrementDegradationCount(degradation);
|
|
1670
|
-
}
|
|
1671
|
-
} catch (err) {
|
|
1672
|
-
surfaceHandlerCrash("message_end", err, { dbg });
|
|
1673
|
-
}
|
|
1674
|
-
});
|
|
1675
|
-
} catch (err) {
|
|
1676
|
-
dbg(`message_end subscribe failed (older pi host?): ${err}`);
|
|
1677
|
-
}
|
|
1678
|
-
const isPlainUserPrompt = (msg) => {
|
|
1679
|
-
if (msg.role !== "user")
|
|
1680
|
-
return false;
|
|
1681
|
-
if (!Array.isArray(msg.content))
|
|
1682
|
-
return true;
|
|
1683
|
-
return !msg.content.some((block) => typeof block === "object" && block !== null && block.type === "tool_result");
|
|
1684
|
-
};
|
|
1685
|
-
pi.on("context", wrapSessionEventHandlerWithResult("context", async (event, ctx) => {
|
|
1686
|
-
const existingMessages = event?.messages ?? [];
|
|
1687
|
-
const prefixSessionId = getStableSessionId(ctx);
|
|
1688
|
-
const sessionRole = classifyOwnedSessionEmission(ctx, prefixSessionId);
|
|
1689
|
-
observeCachePrefix(existingMessages, runtime.turnIndex, prefixSessionId, sessionRole, dbg);
|
|
1690
|
-
const effectiveInjectionEnabled = lensEnabled && contextInjectionEnabled;
|
|
1691
|
-
let telemetryLogged = false;
|
|
1692
|
-
const logContextObservation = (resultMessages, placement, injectionSlices) => {
|
|
1693
|
-
if (telemetryLogged)
|
|
1694
|
-
return;
|
|
1695
|
-
telemetryLogged = true;
|
|
1696
|
-
observeCacheContext({
|
|
1697
|
-
existingMessages,
|
|
1698
|
-
resultMessages,
|
|
1699
|
-
sessionId: prefixSessionId,
|
|
1700
|
-
sessionRole,
|
|
1701
|
-
turnIndex: runtime.turnIndex,
|
|
1702
|
-
injectionEnabled: effectiveInjectionEnabled,
|
|
1703
|
-
injectionSlices,
|
|
1704
|
-
placement,
|
|
1705
|
-
dbg
|
|
1706
|
-
});
|
|
1707
|
-
};
|
|
1708
|
-
try {
|
|
1709
|
-
const cwd = ctx.cwd ?? process.cwd();
|
|
1710
|
-
if (!effectiveInjectionEnabled) {
|
|
1711
|
-
logContextObservation(existingMessages, "none", []);
|
|
1712
|
-
return;
|
|
1713
|
-
}
|
|
1714
|
-
const turnEndFindings = consumeTurnEndFindings(cacheManager, cwd, runtime);
|
|
1715
|
-
const sessionGuidance = consumeSessionStartGuidance(cacheManager, cwd);
|
|
1716
|
-
const testFindings = consumeStagedTestRunnerFindings({
|
|
1717
|
-
cwd,
|
|
1718
|
-
sessionId: runtime.telemetrySessionId,
|
|
1719
|
-
ownerId: testRunnerDeliveryOwnerId,
|
|
1720
|
-
cacheManager,
|
|
1721
|
-
runtime
|
|
1722
|
-
});
|
|
1723
|
-
const agentNudge = consumeAgentNudge(dbg);
|
|
1724
|
-
const sourceMessages = [
|
|
1725
|
-
{
|
|
1726
|
-
source: "session-guidance",
|
|
1727
|
-
messages: sessionGuidance?.messages ?? []
|
|
1728
|
-
},
|
|
1729
|
-
{
|
|
1730
|
-
source: "turn-findings",
|
|
1731
|
-
messages: turnEndFindings?.messages ?? []
|
|
1732
|
-
},
|
|
1733
|
-
{
|
|
1734
|
-
source: "test-findings",
|
|
1735
|
-
messages: testFindings?.messages ?? []
|
|
1736
|
-
},
|
|
1737
|
-
{
|
|
1738
|
-
source: "agent-nudge",
|
|
1739
|
-
messages: agentNudge?.messages ?? []
|
|
1740
|
-
}
|
|
1741
|
-
].filter((source) => source.messages.length > 0);
|
|
1742
|
-
const injectedMessages = sourceMessages.flatMap((source) => source.messages);
|
|
1743
|
-
if (injectedMessages.length === 0) {
|
|
1744
|
-
logContextObservation(existingMessages, "none", []);
|
|
1745
|
-
return;
|
|
1746
|
-
}
|
|
1747
|
-
if (existingMessages.length === 0) {
|
|
1748
|
-
const resultMessages = [...injectedMessages];
|
|
1749
|
-
logContextObservation(resultMessages, "prepend", sourceMessages);
|
|
1750
|
-
return { messages: resultMessages };
|
|
1751
|
-
}
|
|
1752
|
-
const lastMessage = existingMessages[existingMessages.length - 1];
|
|
1753
|
-
if (!isPlainUserPrompt(lastMessage)) {
|
|
1754
|
-
const resultMessages = [...existingMessages, ...injectedMessages];
|
|
1755
|
-
logContextObservation(resultMessages, "append", sourceMessages);
|
|
1756
|
-
return { messages: resultMessages };
|
|
1757
|
-
}
|
|
1758
|
-
const resultMessages = [
|
|
1759
|
-
...existingMessages.slice(0, -1),
|
|
1760
|
-
...injectedMessages,
|
|
1761
|
-
lastMessage
|
|
1762
|
-
];
|
|
1763
|
-
logContextObservation(resultMessages, "insert-before-final", sourceMessages);
|
|
1764
|
-
return { messages: resultMessages };
|
|
1765
|
-
} catch (err) {
|
|
1766
|
-
if (isStaleExtensionCtxError(err))
|
|
1767
|
-
throw err;
|
|
1768
|
-
if (!telemetryLogged)
|
|
1769
|
-
logContextObservation(existingMessages, "none", []);
|
|
1770
|
-
dbg(`context event error: ${err}`);
|
|
1771
|
-
}
|
|
1772
|
-
}, {
|
|
1773
|
-
dbg,
|
|
1774
|
-
onStaleResult: () => {
|
|
1775
|
-
return;
|
|
1776
|
-
}
|
|
1777
|
-
}));
|
|
1778
|
-
}
|
|
1779
|
-
export default function dist_default(pi) {
|
|
1780
|
-
return runInConsoleCaptureWindow(() => activateExtension(pi));
|
|
1781
|
-
}
|
|
1782
|
-
closeModuleLoadConsoleWindow();
|