@duckmind/dm-darwin-x64 0.67.2 → 0.67.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dm +1 -1
- package/extensions/.dm-extensions.json +613 -15
- package/extensions/dm-lens/clients/dispatch/runners/utils/runner-helpers.js +1 -1
- package/extensions/dm-lens/dist/clients/actionable-warnings-logger.js +24 -0
- package/extensions/dm-lens/dist/clients/actionable-warnings.js +1066 -0
- package/extensions/dm-lens/dist/clients/advisory-provenance.js +388 -0
- package/extensions/dm-lens/dist/clients/agent-behavior-client.js +94 -0
- package/extensions/dm-lens/dist/clients/agent-nudge.js +253 -0
- package/extensions/dm-lens/dist/clients/analysed-root.js +1 -0
- package/extensions/dm-lens/dist/clients/analysis-root.js +133 -0
- package/extensions/dm-lens/dist/clients/ast-grep-client.js +587 -0
- package/extensions/dm-lens/dist/clients/ast-grep-rule-manager.js +137 -0
- package/extensions/dm-lens/dist/clients/ast-grep-tool-logger.js +85 -0
- package/extensions/dm-lens/dist/clients/ast-grep-types.js +1 -0
- package/extensions/dm-lens/dist/clients/ast-grep-yaml-synth.js +109 -0
- package/extensions/dm-lens/dist/clients/atomic-write-staging.js +66 -0
- package/extensions/dm-lens/dist/clients/atomic-write.js +37 -0
- package/extensions/dm-lens/dist/clients/availability-probe-flight.js +11 -0
- package/extensions/dm-lens/dist/clients/bash-file-access.js +1257 -0
- package/extensions/dm-lens/dist/clients/biome-client.js +223 -0
- package/extensions/dm-lens/dist/clients/blocker-freshness.js +553 -0
- package/extensions/dm-lens/dist/clients/blocker-past-eof.js +51 -0
- package/extensions/dm-lens/dist/clients/bootstrap.js +246 -0
- package/extensions/dm-lens/dist/clients/bounded-cache.js +105 -0
- package/extensions/dm-lens/dist/clients/bounded-pid-file-lock.js +275 -0
- package/extensions/dm-lens/dist/clients/bounded-telemetry.js +110 -0
- package/extensions/dm-lens/dist/clients/build-identity.js +45 -0
- package/extensions/dm-lens/dist/clients/bundled-resource-health.js +41 -0
- package/extensions/dm-lens/dist/clients/bus-events-logger.js +48 -0
- package/extensions/dm-lens/dist/clients/bus-publish.js +117 -0
- package/extensions/dm-lens/dist/clients/cache/rule-cache.js +87 -0
- package/extensions/dm-lens/dist/clients/cache-manager.js +449 -0
- package/extensions/dm-lens/dist/clients/cache-observability.js +1105 -0
- package/extensions/dm-lens/dist/clients/call-graph.js +628 -0
- package/extensions/dm-lens/dist/clients/cargo-manifest.js +167 -0
- package/extensions/dm-lens/dist/clients/cascade-budget.js +52 -0
- package/extensions/dm-lens/dist/clients/cascade-format.js +301 -0
- package/extensions/dm-lens/dist/clients/cascade-logger.js +22 -0
- package/extensions/dm-lens/dist/clients/cascade-types.js +1 -0
- package/extensions/dm-lens/dist/clients/child-unref.js +59 -0
- package/extensions/dm-lens/dist/clients/code-quality-warnings.js +192 -0
- package/extensions/dm-lens/dist/clients/codebase-model.js +110 -0
- package/extensions/dm-lens/dist/clients/collateral-test-role.js +8 -0
- package/extensions/dm-lens/dist/clients/complexity-client.js +398 -0
- package/extensions/dm-lens/dist/clients/config-core/deny.js +117 -0
- package/extensions/dm-lens/dist/clients/config-core/index.js +2 -0
- package/extensions/dm-lens/dist/clients/config-core/merge.js +228 -0
- package/extensions/dm-lens/dist/clients/config-core/normalize.js +226 -0
- package/extensions/dm-lens/dist/clients/config-core/process-spec.js +147 -0
- package/extensions/dm-lens/dist/clients/config-core/provenance.js +54 -0
- package/extensions/dm-lens/dist/clients/config-core/records.js +79 -0
- package/extensions/dm-lens/dist/clients/config-core/resolve.js +48 -0
- package/extensions/dm-lens/dist/clients/config-core/safe-object.js +22 -0
- package/extensions/dm-lens/dist/clients/config-core/schema.js +93 -0
- package/extensions/dm-lens/dist/clients/config-diagnostic-codes.js +90 -0
- package/extensions/dm-lens/dist/clients/config-locations.js +169 -0
- package/extensions/dm-lens/dist/clients/config-resolve.js +359 -0
- package/extensions/dm-lens/dist/clients/config-schema.js +230 -0
- package/extensions/dm-lens/dist/clients/config-warn.js +146 -0
- package/extensions/dm-lens/dist/clients/confirmed-delete.js +11 -0
- package/extensions/dm-lens/dist/clients/console-guard-install.js +4 -0
- package/extensions/dm-lens/dist/clients/content-stamp.js +16 -0
- package/extensions/dm-lens/dist/clients/context-injection-ledger.js +157 -0
- package/extensions/dm-lens/dist/clients/cooperative-budget.js +36 -0
- package/extensions/dm-lens/dist/clients/custom-rule-locations.js +28 -0
- package/extensions/dm-lens/dist/clients/dead-code-client.js +408 -0
- package/extensions/dm-lens/dist/clients/dead-code-logger.js +18 -0
- package/extensions/dm-lens/dist/clients/deadline-utils.js +117 -0
- package/extensions/dm-lens/dist/clients/debug-handles.js +121 -0
- package/extensions/dm-lens/dist/clients/debug-heap.js +80 -0
- package/extensions/dm-lens/dist/clients/deferred-lsp-work.js +33 -0
- package/extensions/dm-lens/dist/clients/deferred-runner-blockers.js +146 -0
- package/extensions/dm-lens/dist/clients/deferred-test-targets.js +31 -0
- package/extensions/dm-lens/dist/clients/degradation-ledger.js +306 -0
- package/extensions/dm-lens/dist/clients/demoted-finding-render.js +64 -0
- package/extensions/dm-lens/dist/clients/dependency-checker.js +534 -0
- package/extensions/dm-lens/dist/clients/deps/ast-grep-napi.js +27 -0
- package/extensions/dm-lens/dist/clients/deps/dm-host-deps.js +10 -0
- package/extensions/dm-lens/dist/clients/deps/dm-tui-compat.js +58 -0
- package/extensions/dm-lens/dist/clients/deps/js-yaml.js +7 -0
- package/extensions/dm-lens/dist/clients/deps/minimatch.js +6 -0
- package/extensions/dm-lens/dist/clients/deps/pidusage.js +5 -0
- package/extensions/dm-lens/dist/clients/deps/typebox.js +5 -0
- package/extensions/dm-lens/dist/clients/deps/vscode-jsonrpc.js +8 -0
- package/extensions/dm-lens/dist/clients/deps/web-tree-sitter.js +11 -0
- package/extensions/dm-lens/dist/clients/diagnostic-dispositions.js +334 -0
- package/extensions/dm-lens/dist/clients/diagnostic-line-freshness.js +142 -0
- package/extensions/dm-lens/dist/clients/diagnostic-logger.js +60 -0
- package/extensions/dm-lens/dist/clients/diagnostic-tracker.js +89 -0
- package/extensions/dm-lens/dist/clients/diagnostics-publish.js +134 -0
- package/extensions/dm-lens/dist/clients/disk-change-consumers.js +312 -0
- package/extensions/dm-lens/dist/clients/disk-change-subscribers.js +191 -0
- package/extensions/dm-lens/dist/clients/disk-changes.js +165 -0
- package/extensions/dm-lens/dist/clients/dispatch/adopted-root-runners.js +22 -0
- package/extensions/dm-lens/dist/clients/dispatch/ast-grep-catalog.js +16 -0
- package/extensions/dm-lens/dist/clients/dispatch/auxiliary-lsp.js +162 -0
- package/extensions/dm-lens/dist/clients/dispatch/collect-later-tier.js +25 -0
- package/extensions/dm-lens/dist/clients/dispatch/diagnostic-taxonomy.js +58 -0
- package/extensions/dm-lens/dist/clients/dispatch/dispatcher.js +1240 -0
- package/extensions/dm-lens/dist/clients/dispatch/fact-provider-types.js +1 -0
- package/extensions/dm-lens/dist/clients/dispatch/fact-rule-runner.js +17 -0
- package/extensions/dm-lens/dist/clients/dispatch/fact-runner.js +18 -0
- package/extensions/dm-lens/dist/clients/dispatch/fact-scheduler.js +52 -0
- package/extensions/dm-lens/dist/clients/dispatch/fact-store.js +193 -0
- package/extensions/dm-lens/dist/clients/dispatch/facts/comment-facts.js +23 -0
- package/extensions/dm-lens/dist/clients/dispatch/facts/file-content.js +18 -0
- package/extensions/dm-lens/dist/clients/dispatch/facts/function-facts.js +274 -0
- package/extensions/dm-lens/dist/clients/dispatch/facts/import-facts.js +169 -0
- package/extensions/dm-lens/dist/clients/dispatch/facts/tree-sitter-facts.js +19 -0
- package/extensions/dm-lens/dist/clients/dispatch/facts/try-catch-facts.js +95 -0
- package/extensions/dm-lens/dist/clients/dispatch/finding-policy.js +188 -0
- package/extensions/dm-lens/dist/clients/dispatch/indent-detect.js +227 -0
- package/extensions/dm-lens/dist/clients/dispatch/inline-suppressions.js +52 -0
- package/extensions/dm-lens/dist/clients/dispatch/integration.js +1698 -0
- package/extensions/dm-lens/dist/clients/dispatch/known-runner-ids.js +13 -0
- package/extensions/dm-lens/dist/clients/dispatch/lane-copies.js +23 -0
- package/extensions/dm-lens/dist/clients/dispatch/lazy.js +8 -0
- package/extensions/dm-lens/dist/clients/dispatch/pending-runner-findings.js +133 -0
- package/extensions/dm-lens/dist/clients/dispatch/plan.js +284 -0
- package/extensions/dm-lens/dist/clients/dispatch/pre-edit-seed.js +57 -0
- package/extensions/dm-lens/dist/clients/dispatch/priorities.js +14 -0
- package/extensions/dm-lens/dist/clients/dispatch/rule-id-normalize.js +54 -0
- package/extensions/dm-lens/dist/clients/dispatch/rule-ignores.js +21 -0
- package/extensions/dm-lens/dist/clients/dispatch/rule-policy.js +102 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/async-noise.js +31 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/async-unnecessary-wrapper.js +27 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/cors-wildcard.js +35 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/error-obscuring.js +29 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/error-swallowing.js +29 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/framework-call-noise.js +31 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/high-complexity.js +41 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/high-fan-out.js +37 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/high-import-coupling.js +31 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/missing-error-propagation.js +45 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/no-commented-credentials.js +46 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/pass-through-wrappers.js +38 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/placeholder-comments.js +40 -0
- package/extensions/dm-lens/dist/clients/dispatch/rules/unsafe-boundary.js +101 -0
- package/extensions/dm-lens/dist/clients/dispatch/runner-context.js +41 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/actionlint.js +98 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/ast-grep-literal-anchors.js +58 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/ast-grep-napi.js +739 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/biome-check.js +196 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/cpp-check.js +190 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/credo.js +66 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/cue-vet.js +161 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/dart-analyze.js +151 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/detekt.js +158 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/dotnet-build.js +163 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/elixir-check.js +153 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/eslint.js +99 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/fact-rules.js +20 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/fish-indent.js +120 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/gleam-check.js +100 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/go-vet.js +52 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/golangci-lint.js +105 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/hadolint.js +83 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/helm-lint.js +147 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/helm-render.js +593 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/htmlhint.js +103 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/index.js +100 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/javac.js +82 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/ktlint.js +115 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/lsp.js +275 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/markdownlint.js +129 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/mypy.js +70 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/oxlint.js +296 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/php-lint.js +66 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/phpstan.js +90 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/prisma-validate.js +66 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/psscriptanalyzer.js +307 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/pyright.js +118 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/rubocop.js +79 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/ruff.js +69 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/rust-clippy.js +166 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/shellcheck.js +168 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/shfmt.js +92 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/spellcheck.js +74 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/spotbugs.js +208 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/sqlfluff.js +136 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/stylelint.js +118 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/swiftlint.js +143 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/taplo.js +109 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/terragrunt.js +110 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/tflint.js +104 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/tree-sitter.js +534 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/trivy-config.js +155 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/availability-policy.js +313 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/candidate-probe.js +66 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +62 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/lazy-installer.js +130 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +1143 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/spawn-outcome.js +40 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/tool-failure.js +110 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/toolchain-availability.js +88 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils.js +8 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/vale.js +92 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/yaml-rule-parser.js +170 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/yamllint.js +83 -0
- package/extensions/dm-lens/dist/clients/dispatch/runners/zig-check.js +72 -0
- package/extensions/dm-lens/dist/clients/dispatch/suppress-writer.js +57 -0
- package/extensions/dm-lens/dist/clients/dispatch/tool-profile.js +30 -0
- package/extensions/dm-lens/dist/clients/dispatch/types.js +72 -0
- package/extensions/dm-lens/dist/clients/dispatch/utils/format-utils.js +58 -0
- package/extensions/dm-lens/dist/clients/dispatch/utils/lsp-diagnostics.js +32 -0
- package/extensions/dm-lens/dist/clients/disposition-logger.js +19 -0
- package/extensions/dm-lens/dist/clients/disposition-publish.js +88 -0
- package/extensions/dm-lens/dist/clients/durable-store.js +77 -0
- package/extensions/dm-lens/dist/clients/effective-config.js +170 -0
- package/extensions/dm-lens/dist/clients/env-utils.js +26 -0
- package/extensions/dm-lens/dist/clients/ephemeral-root.js +55 -0
- package/extensions/dm-lens/dist/clients/error-class.js +3 -0
- package/extensions/dm-lens/dist/clients/eval-timestamp.js +2 -0
- package/extensions/dm-lens/dist/clients/event-loop-hold.js +119 -0
- package/extensions/dm-lens/dist/clients/event-loop-monitor.js +84 -0
- package/extensions/dm-lens/dist/clients/extension-log.js +230 -0
- package/extensions/dm-lens/dist/clients/extension-mode.js +20 -0
- package/extensions/dm-lens/dist/clients/feature-hints.js +88 -0
- package/extensions/dm-lens/dist/clients/file-kinds.js +317 -0
- package/extensions/dm-lens/dist/clients/file-mutation-queue.js +91 -0
- package/extensions/dm-lens/dist/clients/file-role.js +50 -0
- package/extensions/dm-lens/dist/clients/file-time.js +112 -0
- package/extensions/dm-lens/dist/clients/file-utils.js +840 -0
- package/extensions/dm-lens/dist/clients/finding-delivery-gate.js +146 -0
- package/extensions/dm-lens/dist/clients/finding-identity.js +79 -0
- package/extensions/dm-lens/dist/clients/fix-run-restore.js +423 -0
- package/extensions/dm-lens/dist/clients/fix-worklog.js +75 -0
- package/extensions/dm-lens/dist/clients/format-events-publish.js +310 -0
- package/extensions/dm-lens/dist/clients/format-service.js +177 -0
- package/extensions/dm-lens/dist/clients/formatters-lazy.js +8 -0
- package/extensions/dm-lens/dist/clients/formatters.js +1367 -0
- package/extensions/dm-lens/dist/clients/freshness-cadence.js +1 -0
- package/extensions/dm-lens/dist/clients/freshness.js +8 -0
- package/extensions/dm-lens/dist/clients/generated-artifacts.js +209 -0
- package/extensions/dm-lens/dist/clients/generation-guard.js +147 -0
- package/extensions/dm-lens/dist/clients/generation-lock.js +181 -0
- package/extensions/dm-lens/dist/clients/git-guard.js +1208 -0
- package/extensions/dm-lens/dist/clients/git-tracked-ignore.js +120 -0
- package/extensions/dm-lens/dist/clients/gitleaks-client.js +290 -0
- package/extensions/dm-lens/dist/clients/go-client.js +47 -0
- package/extensions/dm-lens/dist/clients/govulncheck-client.js +416 -0
- package/extensions/dm-lens/dist/clients/gradle-ktfmt-style.js +177 -0
- package/extensions/dm-lens/dist/clients/grammar-source.js +263 -0
- package/extensions/dm-lens/dist/clients/grammar-wasm-imports.js +48 -0
- package/extensions/dm-lens/dist/clients/gzip-stage-write.js +174 -0
- package/extensions/dm-lens/dist/clients/hard-failure-summary.js +28 -0
- package/extensions/dm-lens/dist/clients/hashline-anchor.js +222 -0
- package/extensions/dm-lens/dist/clients/hook-budgets.js +17 -0
- package/extensions/dm-lens/dist/clients/host-edit-normalize.js +87 -0
- package/extensions/dm-lens/dist/clients/host-ports.js +35 -0
- package/extensions/dm-lens/dist/clients/indent-retarget.js +102 -0
- package/extensions/dm-lens/dist/clients/inline-blocker-dispositions.js +103 -0
- package/extensions/dm-lens/dist/clients/inline-blocker-fields.js +8 -0
- package/extensions/dm-lens/dist/clients/install-diagnostics.js +135 -0
- package/extensions/dm-lens/dist/clients/installer/index.js +3928 -0
- package/extensions/dm-lens/dist/clients/installer/managed-tool-refresh-session.js +17 -0
- package/extensions/dm-lens/dist/clients/installer/managed-tool-refresh.js +721 -0
- package/extensions/dm-lens/dist/clients/instance-reaper-state.js +3 -0
- package/extensions/dm-lens/dist/clients/instance-reaper.js +693 -0
- package/extensions/dm-lens/dist/clients/instance-registry-lock.js +166 -0
- package/extensions/dm-lens/dist/clients/instance-registry-tail.js +17 -0
- package/extensions/dm-lens/dist/clients/instance-registry.js +607 -0
- package/extensions/dm-lens/dist/clients/io-bridge-contract.js +7 -0
- package/extensions/dm-lens/dist/clients/io-bridge.js +357 -0
- package/extensions/dm-lens/dist/clients/jscpd-client.js +311 -0
- package/extensions/dm-lens/dist/clients/json-cache-read.js +25 -0
- package/extensions/dm-lens/dist/clients/knip-client.js +534 -0
- package/extensions/dm-lens/dist/clients/knip-scan-roots.js +26 -0
- package/extensions/dm-lens/dist/clients/language-policy.js +244 -0
- package/extensions/dm-lens/dist/clients/language-profile.js +259 -0
- package/extensions/dm-lens/dist/clients/language-registry.js +468 -0
- package/extensions/dm-lens/dist/clients/latency-logger.js +210 -0
- package/extensions/dm-lens/dist/clients/lazy-import.js +14 -0
- package/extensions/dm-lens/dist/clients/ledger-bounds.js +21 -0
- package/extensions/dm-lens/dist/clients/lens-config.js +254 -0
- package/extensions/dm-lens/dist/clients/lens-engine.js +188 -0
- package/extensions/dm-lens/dist/clients/lens-events.js +105 -0
- package/extensions/dm-lens/dist/clients/lens-flag-registry.js +308 -0
- package/extensions/dm-lens/dist/clients/lens-map.js +980 -0
- package/extensions/dm-lens/dist/clients/line-alignment.js +200 -0
- package/extensions/dm-lens/dist/clients/live-bus-emitter.js +53 -0
- package/extensions/dm-lens/dist/clients/log-cleanup.js +138 -0
- package/extensions/dm-lens/dist/clients/lsp/aggregation.js +89 -0
- package/extensions/dm-lens/dist/clients/lsp/auxiliary-lifecycle.js +23 -0
- package/extensions/dm-lens/dist/clients/lsp/capabilities.js +94 -0
- package/extensions/dm-lens/dist/clients/lsp/cascade-tier.js +318 -0
- package/extensions/dm-lens/dist/clients/lsp/client-registry.js +877 -0
- package/extensions/dm-lens/dist/clients/lsp/client.js +3232 -0
- package/extensions/dm-lens/dist/clients/lsp/config.js +571 -0
- package/extensions/dm-lens/dist/clients/lsp/content-limits.js +21 -0
- package/extensions/dm-lens/dist/clients/lsp/content-scan.js +69 -0
- package/extensions/dm-lens/dist/clients/lsp/created-import-targets.js +134 -0
- package/extensions/dm-lens/dist/clients/lsp/diagnostic-binding.js +113 -0
- package/extensions/dm-lens/dist/clients/lsp/document-drift.js +372 -0
- package/extensions/dm-lens/dist/clients/lsp/edits.js +1060 -0
- package/extensions/dm-lens/dist/clients/lsp/environment-gap.js +186 -0
- package/extensions/dm-lens/dist/clients/lsp/file-server-match.js +26 -0
- package/extensions/dm-lens/dist/clients/lsp/grouping.js +38 -0
- package/extensions/dm-lens/dist/clients/lsp/implicit-scope.js +205 -0
- package/extensions/dm-lens/dist/clients/lsp/index.js +4292 -0
- package/extensions/dm-lens/dist/clients/lsp/inferred-project.js +140 -0
- package/extensions/dm-lens/dist/clients/lsp/jvm-runtime.js +200 -0
- package/extensions/dm-lens/dist/clients/lsp/language.js +26 -0
- package/extensions/dm-lens/dist/clients/lsp/launch.js +606 -0
- package/extensions/dm-lens/dist/clients/lsp/lombok.js +133 -0
- package/extensions/dm-lens/dist/clients/lsp/path-utils.js +1 -0
- package/extensions/dm-lens/dist/clients/lsp/pending-aux-coverage.js +120 -0
- package/extensions/dm-lens/dist/clients/lsp/position-encoding.js +21 -0
- package/extensions/dm-lens/dist/clients/lsp/resolved-config.js +183 -0
- package/extensions/dm-lens/dist/clients/lsp/ruby-drive-dirs.js +42 -0
- package/extensions/dm-lens/dist/clients/lsp/server-config-files.js +11 -0
- package/extensions/dm-lens/dist/clients/lsp/server-covers.js +8 -0
- package/extensions/dm-lens/dist/clients/lsp/server-traits.js +45 -0
- package/extensions/dm-lens/dist/clients/lsp/server.js +2827 -0
- package/extensions/dm-lens/dist/clients/lsp/service-singleton.js +59 -0
- package/extensions/dm-lens/dist/clients/lsp/session-roots.js +83 -0
- package/extensions/dm-lens/dist/clients/lsp/spawn-history.js +15 -0
- package/extensions/dm-lens/dist/clients/lsp/sync-kind.js +30 -0
- package/extensions/dm-lens/dist/clients/lsp/tsserver-sync.js +156 -0
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/capability-snapshot.js +1 -0
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/classification.js +37 -0
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/index.js +3 -0
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/strategies.js +276 -0
- package/extensions/dm-lens/dist/clients/lsp/watch-queue.js +61 -0
- package/extensions/dm-lens/dist/clients/lsp/workspace-diagnostics-cache.js +395 -0
- package/extensions/dm-lens/dist/clients/lsp/workspace-diagnostics-session.js +42 -0
- package/extensions/dm-lens/dist/clients/lsp/workspace-sweep-hold.js +93 -0
- package/extensions/dm-lens/dist/clients/lsp-budget.js +87 -0
- package/extensions/dm-lens/dist/clients/lsp-document-symbols.js +93 -0
- package/extensions/dm-lens/dist/clients/lsp-lazy.js +8 -0
- package/extensions/dm-lens/dist/clients/lsp-mutation.js +309 -0
- package/extensions/dm-lens/dist/clients/lsp-status.js +35 -0
- package/extensions/dm-lens/dist/clients/map-with-concurrency.js +20 -0
- package/extensions/dm-lens/dist/clients/mcp/analyze.js +302 -0
- package/extensions/dm-lens/dist/clients/mcp/host-shim.js +14 -0
- package/extensions/dm-lens/dist/clients/mcp/ipc.js +344 -0
- package/extensions/dm-lens/dist/clients/mcp/review.js +137 -0
- package/extensions/dm-lens/dist/clients/mcp/session.js +300 -0
- package/extensions/dm-lens/dist/clients/memory-sampler.js +163 -0
- package/extensions/dm-lens/dist/clients/message-end-attribution.js +18 -0
- package/extensions/dm-lens/dist/clients/metrics-client.js +80 -0
- package/extensions/dm-lens/dist/clients/metrics-history.js +242 -0
- package/extensions/dm-lens/dist/clients/middle-man-analysis.js +161 -0
- package/extensions/dm-lens/dist/clients/model-provider.js +31 -0
- package/extensions/dm-lens/dist/clients/module-report-lsp.js +140 -0
- package/extensions/dm-lens/dist/clients/module-report.js +1648 -0
- package/extensions/dm-lens/dist/clients/mutating-tool.js +388 -0
- package/extensions/dm-lens/dist/clients/mutation-attribution.js +173 -0
- package/extensions/dm-lens/dist/clients/mutation-bridge.js +231 -0
- package/extensions/dm-lens/dist/clients/ndjson-logger.js +504 -0
- package/extensions/dm-lens/dist/clients/observed-mutation-sources.js +43 -0
- package/extensions/dm-lens/dist/clients/observed-mutation.js +735 -0
- package/extensions/dm-lens/dist/clients/oldtext-autopatch.js +100 -0
- package/extensions/dm-lens/dist/clients/opaque-mutation-scan.js +541 -0
- package/extensions/dm-lens/dist/clients/opengrep-client.js +224 -0
- package/extensions/dm-lens/dist/clients/opengrep-config.js +57 -0
- package/extensions/dm-lens/dist/clients/opengrep-rule-pack.js +19 -0
- package/extensions/dm-lens/dist/clients/out-of-band-changes.js +329 -0
- package/extensions/dm-lens/dist/clients/package-manager.js +332 -0
- package/extensions/dm-lens/dist/clients/package-root.js +21 -0
- package/extensions/dm-lens/dist/clients/partial-edit-apply.js +341 -0
- package/extensions/dm-lens/dist/clients/path-attribution-telemetry.js +31 -0
- package/extensions/dm-lens/dist/clients/path-birth.js +58 -0
- package/extensions/dm-lens/dist/clients/path-keyed-map.js +57 -0
- package/extensions/dm-lens/dist/clients/path-utils.js +654 -0
- package/extensions/dm-lens/dist/clients/performance-report.js +291 -0
- package/extensions/dm-lens/dist/clients/persist-debounce.js +37 -0
- package/extensions/dm-lens/dist/clients/persist-worker-stats.js +16 -0
- package/extensions/dm-lens/dist/clients/persistent-reverify.js +167 -0
- package/extensions/dm-lens/dist/clients/php-cs-fixer-config.js +15 -0
- package/extensions/dm-lens/dist/clients/pipeline.js +1473 -0
- package/extensions/dm-lens/dist/clients/post-autofix-notice.js +19 -0
- package/extensions/dm-lens/dist/clients/print-mode.js +3 -0
- package/extensions/dm-lens/dist/clients/probe-home-state.js +73 -0
- package/extensions/dm-lens/dist/clients/process-bridge.js +48 -0
- package/extensions/dm-lens/dist/clients/process-singletons.js +69 -0
- package/extensions/dm-lens/dist/clients/process-snapshot.js +130 -0
- package/extensions/dm-lens/dist/clients/project-changes.js +180 -0
- package/extensions/dm-lens/dist/clients/project-conventions.js +152 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/cache.js +91 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/extractors.js +53 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/fresh-fetch.js +413 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js +64 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/dead-code.js +38 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/gitleaks.js +21 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/govulncheck.js +23 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/jscpd.js +28 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/knip.js +45 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/madge.js +34 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/opengrep.js +32 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +79 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/trivy.js +41 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/scanner.js +351 -0
- package/extensions/dm-lens/dist/clients/project-diagnostics/types.js +1 -0
- package/extensions/dm-lens/dist/clients/project-lens-config.js +462 -0
- package/extensions/dm-lens/dist/clients/project-report.js +527 -0
- package/extensions/dm-lens/dist/clients/project-root-markers.js +8 -0
- package/extensions/dm-lens/dist/clients/project-scale.js +60 -0
- package/extensions/dm-lens/dist/clients/project-scan-policy.js +4 -0
- package/extensions/dm-lens/dist/clients/project-snapshot-fingerprint.js +44 -0
- package/extensions/dm-lens/dist/clients/project-snapshot-persist-worker.js +31 -0
- package/extensions/dm-lens/dist/clients/project-snapshot.js +1355 -0
- package/extensions/dm-lens/dist/clients/project-trust.js +104 -0
- package/extensions/dm-lens/dist/clients/python-environment.js +388 -0
- package/extensions/dm-lens/dist/clients/python-provenance.js +551 -0
- package/extensions/dm-lens/dist/clients/quiet-window-config.js +16 -0
- package/extensions/dm-lens/dist/clients/quiet-window.js +129 -0
- package/extensions/dm-lens/dist/clients/read-bridge.js +53 -0
- package/extensions/dm-lens/dist/clients/read-expansion.js +218 -0
- package/extensions/dm-lens/dist/clients/read-guard-branch.js +126 -0
- package/extensions/dm-lens/dist/clients/read-guard-logger.js +186 -0
- package/extensions/dm-lens/dist/clients/read-guard-tool-lines.js +1044 -0
- package/extensions/dm-lens/dist/clients/read-guard.js +1517 -0
- package/extensions/dm-lens/dist/clients/recent-touches.js +126 -0
- package/extensions/dm-lens/dist/clients/redact/secrets.js +386 -0
- package/extensions/dm-lens/dist/clients/resource-sampler.js +344 -0
- package/extensions/dm-lens/dist/clients/reverse-deps.js +227 -0
- package/extensions/dm-lens/dist/clients/review-graph/builder.js +3780 -0
- package/extensions/dm-lens/dist/clients/review-graph/format.js +30 -0
- package/extensions/dm-lens/dist/clients/review-graph/git-identity.js +173 -0
- package/extensions/dm-lens/dist/clients/review-graph/import-resolvers.js +332 -0
- package/extensions/dm-lens/dist/clients/review-graph/persist-worker.js +8 -0
- package/extensions/dm-lens/dist/clients/review-graph/query.js +195 -0
- package/extensions/dm-lens/dist/clients/review-graph/revision-drift.js +3 -0
- package/extensions/dm-lens/dist/clients/review-graph/service.js +60 -0
- package/extensions/dm-lens/dist/clients/review-graph/shared-extraction-ir.js +54 -0
- package/extensions/dm-lens/dist/clients/review-graph/symbol-id.js +29 -0
- package/extensions/dm-lens/dist/clients/review-graph/tsconfig-paths.js +286 -0
- package/extensions/dm-lens/dist/clients/review-graph/types.js +1 -0
- package/extensions/dm-lens/dist/clients/review-graph/workspace-modules.js +374 -0
- package/extensions/dm-lens/dist/clients/review-graph-logger.js +51 -0
- package/extensions/dm-lens/dist/clients/ruff-client.js +107 -0
- package/extensions/dm-lens/dist/clients/rules-scanner.js +70 -0
- package/extensions/dm-lens/dist/clients/run-duration.js +9 -0
- package/extensions/dm-lens/dist/clients/runtime-agent-end.js +831 -0
- package/extensions/dm-lens/dist/clients/runtime-config.js +39 -0
- package/extensions/dm-lens/dist/clients/runtime-context.js +155 -0
- package/extensions/dm-lens/dist/clients/runtime-coordinator.js +1254 -0
- package/extensions/dm-lens/dist/clients/runtime-session.js +1806 -0
- package/extensions/dm-lens/dist/clients/runtime-tool-call.js +1026 -0
- package/extensions/dm-lens/dist/clients/runtime-tool-result.js +2068 -0
- package/extensions/dm-lens/dist/clients/runtime-turn.js +3198 -0
- package/extensions/dm-lens/dist/clients/rust-client.js +46 -0
- package/extensions/dm-lens/dist/clients/safe-spawn.js +1402 -0
- package/extensions/dm-lens/dist/clients/sanitize.js +5 -0
- package/extensions/dm-lens/dist/clients/scan-utils.js +7 -0
- package/extensions/dm-lens/dist/clients/scanner-temp-root.js +8 -0
- package/extensions/dm-lens/dist/clients/scratch-tree-policy.js +63 -0
- package/extensions/dm-lens/dist/clients/search-read-registration.js +76 -0
- package/extensions/dm-lens/dist/clients/secret-findings.js +69 -0
- package/extensions/dm-lens/dist/clients/security-scan-client.js +208 -0
- package/extensions/dm-lens/dist/clients/session-event-guard.js +111 -0
- package/extensions/dm-lens/dist/clients/session-lifecycle.js +309 -0
- package/extensions/dm-lens/dist/clients/session-repository.js +113 -0
- package/extensions/dm-lens/dist/clients/session-scope.js +451 -0
- package/extensions/dm-lens/dist/clients/session-start-observability.js +59 -0
- package/extensions/dm-lens/dist/clients/session-state-store.js +71 -0
- package/extensions/dm-lens/dist/clients/session-summary.js +8 -0
- package/extensions/dm-lens/dist/clients/sessionstart-logger.js +22 -0
- package/extensions/dm-lens/dist/clients/sg-runner.js +642 -0
- package/extensions/dm-lens/dist/clients/sgconfig.js +299 -0
- package/extensions/dm-lens/dist/clients/shared-checkout-guard.js +177 -0
- package/extensions/dm-lens/dist/clients/single-flight.js +53 -0
- package/extensions/dm-lens/dist/clients/situational-tool-telemetry.js +85 -0
- package/extensions/dm-lens/dist/clients/skills-resolver.js +38 -0
- package/extensions/dm-lens/dist/clients/slow-fs.js +77 -0
- package/extensions/dm-lens/dist/clients/smells-rollup.js +118 -0
- package/extensions/dm-lens/dist/clients/source-filter.js +323 -0
- package/extensions/dm-lens/dist/clients/source-walker.js +114 -0
- package/extensions/dm-lens/dist/clients/spawn-output-cap.js +35 -0
- package/extensions/dm-lens/dist/clients/spawn-timeout-cooldown.js +51 -0
- package/extensions/dm-lens/dist/clients/stale-marker.js +1 -0
- package/extensions/dm-lens/dist/clients/startup-scan.js +221 -0
- package/extensions/dm-lens/dist/clients/startup-timing.js +67 -0
- package/extensions/dm-lens/dist/clients/string-utils.js +6 -0
- package/extensions/dm-lens/dist/clients/subagent-mode.js +40 -0
- package/extensions/dm-lens/dist/clients/symbol-containment.js +16 -0
- package/extensions/dm-lens/dist/clients/symbol-types.js +1 -0
- package/extensions/dm-lens/dist/clients/test-runner-client.js +1686 -0
- package/extensions/dm-lens/dist/clients/test-runner-delivery.js +285 -0
- package/extensions/dm-lens/dist/clients/test-target-roots.js +17 -0
- package/extensions/dm-lens/dist/clients/todo-scanner.js +164 -0
- package/extensions/dm-lens/dist/clients/tool-agreement.js +640 -0
- package/extensions/dm-lens/dist/clients/tool-config.js +239 -0
- package/extensions/dm-lens/dist/clients/tool-cwd.js +236 -0
- package/extensions/dm-lens/dist/clients/tool-definition.js +22 -0
- package/extensions/dm-lens/dist/clients/tool-event.js +24 -0
- package/extensions/dm-lens/dist/clients/tool-policy.js +2386 -0
- package/extensions/dm-lens/dist/clients/tool-probe.js +13 -0
- package/extensions/dm-lens/dist/clients/tool-render.js +79 -0
- package/extensions/dm-lens/dist/clients/tool-set-policy.js +106 -0
- package/extensions/dm-lens/dist/clients/tree-sitter-cache.js +206 -0
- package/extensions/dm-lens/dist/clients/tree-sitter-client.js +3101 -0
- package/extensions/dm-lens/dist/clients/tree-sitter-logger.js +77 -0
- package/extensions/dm-lens/dist/clients/tree-sitter-navigator.js +198 -0
- package/extensions/dm-lens/dist/clients/tree-sitter-query-loader.js +401 -0
- package/extensions/dm-lens/dist/clients/tree-sitter-shared.js +87 -0
- package/extensions/dm-lens/dist/clients/tree-sitter-symbol-extractor.js +984 -0
- package/extensions/dm-lens/dist/clients/trivy-client.js +335 -0
- package/extensions/dm-lens/dist/clients/tui-fit.js +26 -0
- package/extensions/dm-lens/dist/clients/turn-context.js +48 -0
- package/extensions/dm-lens/dist/clients/turn-end/delivery-holds.js +59 -0
- package/extensions/dm-lens/dist/clients/turn-end/lane.js +1 -0
- package/extensions/dm-lens/dist/clients/turn-end/lanes/govulncheck.js +54 -0
- package/extensions/dm-lens/dist/clients/turn-end/lanes/secrets.js +131 -0
- package/extensions/dm-lens/dist/clients/turn-summary-render.js +56 -0
- package/extensions/dm-lens/dist/clients/turn-summary.js +84 -0
- package/extensions/dm-lens/dist/clients/typos-config.js +9 -0
- package/extensions/dm-lens/dist/clients/user-notify.js +15 -0
- package/extensions/dm-lens/dist/clients/vanished-instance-marker.js +18 -0
- package/extensions/dm-lens/dist/clients/warm-attach.js +232 -0
- package/extensions/dm-lens/dist/clients/widget-state.js +1014 -0
- package/extensions/dm-lens/dist/clients/word-index-logger.js +24 -0
- package/extensions/dm-lens/dist/clients/word-index-store.js +222 -0
- package/extensions/dm-lens/dist/clients/word-index.js +1503 -0
- package/extensions/dm-lens/dist/clients/workspace-topology.js +274 -0
- package/extensions/dm-lens/dist/clients/write-ordering-guard.js +28 -0
- package/extensions/dm-lens/dist/clients/zizmor-config.js +160 -0
- package/extensions/dm-lens/dist/i18n.js +67 -0
- package/extensions/dm-lens/dist/index.js +2144 -0
- package/extensions/dm-lens/dist/mcp/analyze-cli.js +205 -0
- package/extensions/dm-lens/dist/mcp/build-staleness.js +55 -0
- package/extensions/dm-lens/dist/mcp/cli.js +96 -0
- package/extensions/dm-lens/dist/mcp/server.js +1241 -0
- package/extensions/dm-lens/dist/mcp/tool-arguments.js +134 -0
- package/extensions/dm-lens/dist/mcp/worker.js +41 -0
- package/extensions/dm-lens/dist/scripts/lib/process-scan.mjs +375 -0
- package/extensions/dm-lens/dist/scripts/lib/skills-predicate.mjs +53 -0
- package/extensions/dm-lens/dist/scripts/lib/web-tree-sitter-dir.mjs +51 -0
- package/extensions/dm-lens/dist/tools/activate-tools.js +63 -0
- package/extensions/dm-lens/dist/tools/ast-grep-outline.js +128 -0
- package/extensions/dm-lens/dist/tools/ast-grep-replace.js +234 -0
- package/extensions/dm-lens/dist/tools/ast-grep-search.js +690 -0
- package/extensions/dm-lens/dist/tools/effective-config.js +59 -0
- package/extensions/dm-lens/dist/tools/lens-diagnostic-mark.js +251 -0
- package/extensions/dm-lens/dist/tools/lens-diagnostics.js +1693 -0
- package/extensions/dm-lens/dist/tools/lsp-diagnostics.js +1397 -0
- package/extensions/dm-lens/dist/tools/lsp-navigation.js +1301 -0
- package/extensions/dm-lens/dist/tools/lsp-structured-output.js +277 -0
- package/extensions/dm-lens/dist/tools/module-report.js +333 -0
- package/extensions/dm-lens/dist/tools/project-report.js +72 -0
- package/extensions/dm-lens/dist/tools/render-compact.js +272 -0
- package/extensions/dm-lens/dist/tools/scan-progress.js +31 -0
- package/extensions/dm-lens/dist/tools/shared.js +46 -0
- package/extensions/dm-lens/dist/tools/symbol-search.js +133 -0
- package/extensions/dm-mcp-adapter/dist/abort.js +35 -0
- package/extensions/dm-mcp-adapter/dist/agent-dir.js +45 -0
- package/extensions/dm-mcp-adapter/dist/agent-plugin-loader.js +392 -0
- package/extensions/dm-mcp-adapter/dist/agent-plugin-provenance.js +26 -0
- package/extensions/dm-mcp-adapter/dist/bearer-command-resolver.js +184 -0
- package/extensions/dm-mcp-adapter/dist/claude-plugin-loader.js +350 -0
- package/extensions/dm-mcp-adapter/dist/config.js +1984 -0
- package/extensions/dm-mcp-adapter/dist/consent-manager.js +84 -0
- package/extensions/dm-mcp-adapter/dist/elicitation-handler.js +374 -0
- package/extensions/dm-mcp-adapter/dist/errors.js +225 -0
- package/extensions/dm-mcp-adapter/dist/extraction-settings.js +43 -0
- package/extensions/dm-mcp-adapter/dist/http-ca.js +75 -0
- package/extensions/dm-mcp-adapter/dist/jev-client.js +359 -0
- package/extensions/dm-mcp-adapter/dist/jev-contracts.js +1 -0
- package/extensions/dm-mcp-adapter/dist/jev-key-store.js +189 -0
- package/extensions/dm-mcp-adapter/dist/json-schema-validator.js +70 -0
- package/extensions/dm-mcp-adapter/dist/lifecycle.js +387 -0
- package/extensions/dm-mcp-adapter/dist/logger.js +115 -0
- package/extensions/dm-mcp-adapter/dist/mcp-auth-fetch.js +86 -0
- package/extensions/dm-mcp-adapter/dist/mcp-auth-flow.js +956 -0
- package/extensions/dm-mcp-adapter/dist/mcp-auth.js +998 -0
- package/extensions/dm-mcp-adapter/dist/mcp-bearer-store.js +182 -0
- package/extensions/dm-mcp-adapter/dist/mcp-callback-server.js +380 -0
- package/extensions/dm-mcp-adapter/dist/mcp-oauth-provider.js +525 -0
- package/extensions/dm-mcp-adapter/dist/mcp-probe.js +151 -0
- package/extensions/dm-mcp-adapter/dist/mcp-tasks.js +339 -0
- package/extensions/dm-mcp-adapter/dist/mcp-trace.js +220 -0
- package/extensions/dm-mcp-adapter/dist/metadata-cache.js +411 -0
- package/extensions/dm-mcp-adapter/dist/npx-resolver.js +465 -0
- package/extensions/dm-mcp-adapter/dist/output-shape.js +312 -0
- package/extensions/dm-mcp-adapter/dist/package-mcp-loader.js +144 -0
- package/extensions/dm-mcp-adapter/dist/project-server-trust.js +274 -0
- package/extensions/dm-mcp-adapter/dist/request-headers-command.js +310 -0
- package/extensions/dm-mcp-adapter/dist/resource-tools.js +7 -0
- package/extensions/dm-mcp-adapter/dist/runtime-owner.js +95 -0
- package/extensions/dm-mcp-adapter/dist/sampling-handler.js +219 -0
- package/extensions/dm-mcp-adapter/dist/script-tools.js +72 -0
- package/extensions/dm-mcp-adapter/dist/secure-keyring.js +191 -0
- package/extensions/dm-mcp-adapter/dist/semantic-settings.js +51 -0
- package/extensions/dm-mcp-adapter/dist/server-log.js +19 -0
- package/extensions/dm-mcp-adapter/dist/server-manager.js +1635 -0
- package/extensions/dm-mcp-adapter/dist/session-approvals.js +127 -0
- package/extensions/dm-mcp-adapter/dist/session-recovery.js +83 -0
- package/extensions/dm-mcp-adapter/dist/state.js +1 -0
- package/extensions/dm-mcp-adapter/dist/task-entries.js +60 -0
- package/extensions/dm-mcp-adapter/dist/task-jobs.js +259 -0
- package/extensions/dm-mcp-adapter/dist/ts-shape.js +157 -0
- package/extensions/dm-mcp-adapter/dist/types.js +293 -0
- package/extensions/dm-mcp-adapter/dist/ui-app-bridge-helpers.js +36 -0
- package/extensions/dm-mcp-adapter/dist/ui-resource-handler.js +204 -0
- package/extensions/dm-mcp-adapter/dist/ui-stream-types.js +58 -0
- package/extensions/dm-mcp-adapter/dist/ui-tool-visibility.js +26 -0
- package/extensions/dm-mcp-adapter/dist/unix-socket-transport.js +83 -0
- package/extensions/dm-mcp-adapter/dist/utils.js +444 -0
- 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-ponytail/hooks/ponytail-mode-tracker.js +1 -1
- package/extensions/dm-subagents/src/runs/shared/child-session.js +5 -3
- package/package.json +1 -1
|
@@ -0,0 +1,1208 @@
|
|
|
1
|
+
import * as nodeFs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { DEFAULT_MAX_AGE_MS } from "./cache-manager.js";
|
|
4
|
+
import { isPathIgnoredByProject } from "./file-utils.js";
|
|
5
|
+
import { isOutsideProjectRoot, toProjectRelativePath } from "./path-utils.js";
|
|
6
|
+
import { decodeShellWords } from "./bash-file-access.js";
|
|
7
|
+
import { incrementDegradationCount, recordDegradationOnce } from "./degradation-ledger.js";
|
|
8
|
+
import { absorbSettledRunnerBlockers } from "./deferred-runner-blockers.js";
|
|
9
|
+
import { logLatency } from "./latency-logger.js";
|
|
10
|
+
import { resolveLensToolName } from "./tool-config.js";
|
|
11
|
+
import { canWriteAnalysisRoot } from "./analysis-root.js";
|
|
12
|
+
import { advisoryFileHash, advisoryPathKey, MAX_ADVISORY_AFFECTED_FILES, snapshotAdvisoryProvenance } from "./advisory-provenance.js";
|
|
13
|
+
function resolveGuardPath(filePath, cwd) {
|
|
14
|
+
return path.resolve(cwd, filePath);
|
|
15
|
+
}
|
|
16
|
+
function guardPathKey(filePath, cwd) {
|
|
17
|
+
return advisoryPathKey(filePath, cwd);
|
|
18
|
+
}
|
|
19
|
+
function fileFingerprint(filePath) {
|
|
20
|
+
return advisoryFileHash(filePath);
|
|
21
|
+
}
|
|
22
|
+
function currentFileFingerprint(filePath) {
|
|
23
|
+
try {
|
|
24
|
+
nodeFs.statSync(filePath);
|
|
25
|
+
return fileFingerprint(filePath);
|
|
26
|
+
} catch (err) {
|
|
27
|
+
return err.code === "ENOENT" ? "missing" : `unreadable:${err.code ?? "unknown"}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function capAffectedFiles(files, cwd) {
|
|
31
|
+
const unique = [...new Set(files.map((file) => resolveGuardPath(file, cwd)))];
|
|
32
|
+
return {
|
|
33
|
+
files: unique.slice(0, MAX_ADVISORY_AFFECTED_FILES),
|
|
34
|
+
truncated: unique.length > MAX_ADVISORY_AFFECTED_FILES
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const TURN_END_BLOCKER_SECTION = /^Unresolved from this turn — ([^\s].*?)(?: \(suppressed by disposition: \d+ finding\(s\)\))?:$/;
|
|
38
|
+
function blockerSectionFile(line) {
|
|
39
|
+
const turnEndSection = TURN_END_BLOCKER_SECTION.exec(line);
|
|
40
|
+
if (turnEndSection)
|
|
41
|
+
return turnEndSection[1];
|
|
42
|
+
if (/^\s/.test(line))
|
|
43
|
+
return;
|
|
44
|
+
const separator = line.indexOf(": ");
|
|
45
|
+
if (separator <= 0)
|
|
46
|
+
return;
|
|
47
|
+
return line.slice(0, separator);
|
|
48
|
+
}
|
|
49
|
+
function blockingProvenance(blockerContent, blockingFiles, cwd) {
|
|
50
|
+
if (typeof blockerContent !== "string" || blockerContent.length === 0)
|
|
51
|
+
return;
|
|
52
|
+
if (!Array.isArray(blockingFiles))
|
|
53
|
+
return;
|
|
54
|
+
if (blockingFiles.some((file) => typeof file !== "string" || file.trim().length === 0)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const { sections, unowned } = splitBlockerSections(blockerContent, blockingFiles, cwd);
|
|
58
|
+
if (unowned || sections.length === 0)
|
|
59
|
+
return;
|
|
60
|
+
return sections;
|
|
61
|
+
}
|
|
62
|
+
function splitBlockerSections(blockerContent, blockingFiles, cwd) {
|
|
63
|
+
const provenanceKeys = new Set(blockingFiles.map((file) => guardPathKey(file, cwd)));
|
|
64
|
+
const sections = [];
|
|
65
|
+
let unowned = false;
|
|
66
|
+
let open;
|
|
67
|
+
for (const line of blockerContent.split(`
|
|
68
|
+
`)) {
|
|
69
|
+
if (line.length === 0) {
|
|
70
|
+
open = undefined;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const file = blockerSectionFile(line);
|
|
74
|
+
if (file === undefined) {
|
|
75
|
+
if (open)
|
|
76
|
+
open.lines.push(line);
|
|
77
|
+
else
|
|
78
|
+
unowned = true;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
open = { key: guardPathKey(file, cwd), file, lines: [line] };
|
|
82
|
+
if (provenanceKeys.has(open.key))
|
|
83
|
+
sections.push(open);
|
|
84
|
+
else
|
|
85
|
+
unowned = true;
|
|
86
|
+
}
|
|
87
|
+
return { sections, unowned };
|
|
88
|
+
}
|
|
89
|
+
function getShellCommand(input) {
|
|
90
|
+
if (!input || typeof input !== "object")
|
|
91
|
+
return "";
|
|
92
|
+
const raw = input;
|
|
93
|
+
if (typeof raw.command === "string" && raw.command.trim())
|
|
94
|
+
return raw.command;
|
|
95
|
+
if (typeof raw.cmd === "string" && raw.cmd.trim())
|
|
96
|
+
return raw.cmd;
|
|
97
|
+
if (typeof raw.command === "string")
|
|
98
|
+
return raw.command;
|
|
99
|
+
return "";
|
|
100
|
+
}
|
|
101
|
+
function executableName(value) {
|
|
102
|
+
const normalized = value.replace(/\\/g, "/");
|
|
103
|
+
let name = (normalized.slice(normalized.lastIndexOf("/") + 1) ?? "").toLowerCase();
|
|
104
|
+
return name.replace(/\.(?:exe|com|bat|cmd)$/i, "");
|
|
105
|
+
}
|
|
106
|
+
function isShellWrapper(value) {
|
|
107
|
+
return new Set([
|
|
108
|
+
"sh",
|
|
109
|
+
"bash",
|
|
110
|
+
"dash",
|
|
111
|
+
"zsh",
|
|
112
|
+
"ash",
|
|
113
|
+
"cmd",
|
|
114
|
+
"pwsh",
|
|
115
|
+
"powershell"
|
|
116
|
+
]).has(executableName(value));
|
|
117
|
+
}
|
|
118
|
+
function isGitExecutable(value) {
|
|
119
|
+
const names = new Set(["git", "git.exe", "git.cmd", "git.bat"]);
|
|
120
|
+
return [value, normalizeGuardVerbToken(value)].some((reading) => names.has(executableName(reading)));
|
|
121
|
+
}
|
|
122
|
+
const COMMAND_STRING_WRAPPERS = new Set(["busybox", "toybox", "nix-shell"]);
|
|
123
|
+
function isCommandStringWrapper(value) {
|
|
124
|
+
return COMMAND_STRING_WRAPPERS.has(executableName(value));
|
|
125
|
+
}
|
|
126
|
+
function opensAnsiC(command, index) {
|
|
127
|
+
if (command[index - 1] !== "$")
|
|
128
|
+
return false;
|
|
129
|
+
let backslashes = 0;
|
|
130
|
+
for (let i = index - 2;i >= 0 && command[i] === "\\"; i--)
|
|
131
|
+
backslashes++;
|
|
132
|
+
return backslashes % 2 === 0;
|
|
133
|
+
}
|
|
134
|
+
function canonicalizeGuardCommand(command) {
|
|
135
|
+
let result = "";
|
|
136
|
+
let quote;
|
|
137
|
+
let ansiC = false;
|
|
138
|
+
let escaped = false;
|
|
139
|
+
for (let i = 0;i < command.length; i++) {
|
|
140
|
+
const ch = command[i];
|
|
141
|
+
if (quote === "single") {
|
|
142
|
+
result += ch;
|
|
143
|
+
if (ansiC && ch === "\\") {
|
|
144
|
+
result += command[i + 1] ?? "";
|
|
145
|
+
i += 1;
|
|
146
|
+
} else if (ch === "'")
|
|
147
|
+
quote = undefined;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (quote === "double") {
|
|
151
|
+
result += ch;
|
|
152
|
+
if (escaped)
|
|
153
|
+
escaped = false;
|
|
154
|
+
else if (ch === "\\")
|
|
155
|
+
escaped = true;
|
|
156
|
+
else if (ch === '"')
|
|
157
|
+
quote = undefined;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (ch === "'" || ch === '"') {
|
|
161
|
+
quote = ch === "'" ? "single" : "double";
|
|
162
|
+
ansiC = ch === "'" && opensAnsiC(command, i);
|
|
163
|
+
result += ch;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const parameter = command.slice(i).match(/^\$\{IFS[^}]*\}/)?.[0];
|
|
167
|
+
const positional = command.slice(i).match(/^\$IFS(?:\$[0-9]+)?/)?.[0];
|
|
168
|
+
if (parameter || positional) {
|
|
169
|
+
result += " ";
|
|
170
|
+
i += (parameter ?? positional ?? "").length - 1;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
result += ch;
|
|
174
|
+
}
|
|
175
|
+
let collapsed = "";
|
|
176
|
+
let pendingSpace = false;
|
|
177
|
+
quote = undefined;
|
|
178
|
+
for (const ch of result) {
|
|
179
|
+
if (!quote && ch === `
|
|
180
|
+
`) {
|
|
181
|
+
collapsed += ch;
|
|
182
|
+
pendingSpace = false;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (!quote && /\s/.test(ch)) {
|
|
186
|
+
pendingSpace = collapsed.length > 0;
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (pendingSpace)
|
|
190
|
+
collapsed += " ";
|
|
191
|
+
pendingSpace = false;
|
|
192
|
+
collapsed += ch;
|
|
193
|
+
if (!quote && (ch === "'" || ch === '"')) {
|
|
194
|
+
quote = ch === "'" ? "single" : "double";
|
|
195
|
+
} else if (quote === "single" && ch === "'" || quote === "double" && ch === '"') {
|
|
196
|
+
quote = undefined;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return collapsed.trimStart();
|
|
200
|
+
}
|
|
201
|
+
function normalizeGuardVerbToken(value) {
|
|
202
|
+
return value.replace(/\\(?=[A-Za-z0-9_])/g, "").replace(/`(?=.)/g, "").replace(/\^(?=.)/g, "");
|
|
203
|
+
}
|
|
204
|
+
function expandGuardVerbToken(value) {
|
|
205
|
+
return normalizeGuardVerbToken(value).trim().split(/\s+/).filter(Boolean);
|
|
206
|
+
}
|
|
207
|
+
function delimitedSubstitutionBody(command, start, opener, closer) {
|
|
208
|
+
let depth = 1;
|
|
209
|
+
let quote;
|
|
210
|
+
let ansiC = false;
|
|
211
|
+
let escaped = false;
|
|
212
|
+
for (let i = start + opener.length;i < command.length; i++) {
|
|
213
|
+
const ch = command[i];
|
|
214
|
+
if (quote === "single") {
|
|
215
|
+
if (ansiC && ch === "\\")
|
|
216
|
+
i += 1;
|
|
217
|
+
else if (ch === "'")
|
|
218
|
+
quote = undefined;
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (quote === "double" && ch === '"') {
|
|
222
|
+
quote = undefined;
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (escaped) {
|
|
226
|
+
escaped = false;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (ch === "\\") {
|
|
230
|
+
escaped = true;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (ch === "'" || ch === '"') {
|
|
234
|
+
quote = ch === "'" ? "single" : "double";
|
|
235
|
+
ansiC = ch === "'" && opensAnsiC(command, i);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
if (command.startsWith(opener, i)) {
|
|
239
|
+
depth += 1;
|
|
240
|
+
i += opener.length - 1;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (command.startsWith(closer, i) && --depth === 0) {
|
|
244
|
+
return { body: command.slice(start + opener.length, i), end: i };
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const COMMIT_PUSH_MATCHER = {
|
|
250
|
+
id: "commit-push",
|
|
251
|
+
matchesVerb: (verb) => verb === "commit" || verb === "push",
|
|
252
|
+
indirectAlwaysMatches: true,
|
|
253
|
+
suppressPostVerbHelp: false
|
|
254
|
+
};
|
|
255
|
+
function containsGuardedSubstitution(command, depth, matcher) {
|
|
256
|
+
if (depth > 3)
|
|
257
|
+
return false;
|
|
258
|
+
let quote;
|
|
259
|
+
let ansiC = false;
|
|
260
|
+
let escaped = false;
|
|
261
|
+
for (let i = 0;i < command.length; i++) {
|
|
262
|
+
const ch = command[i];
|
|
263
|
+
if (quote === "single") {
|
|
264
|
+
if (ansiC && ch === "\\")
|
|
265
|
+
i += 1;
|
|
266
|
+
else if (ch === "'")
|
|
267
|
+
quote = undefined;
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (quote === "double" && ch === '"') {
|
|
271
|
+
quote = undefined;
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (escaped) {
|
|
275
|
+
escaped = false;
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (ch === "\\") {
|
|
279
|
+
escaped = true;
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (ch === '"' || ch === "'") {
|
|
283
|
+
quote = ch === "'" ? "single" : "double";
|
|
284
|
+
ansiC = ch === "'" && opensAnsiC(command, i);
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const substitution = command.startsWith("$(", i) ? delimitedSubstitutionBody(command, i, "$(", ")") : command.startsWith("<(", i) ? delimitedSubstitutionBody(command, i, "<(", ")") : command.startsWith(">(", i) ? delimitedSubstitutionBody(command, i, ">(", ")") : ch === "`" ? {
|
|
288
|
+
body: command.slice(i + 1, command.indexOf("`", i + 1)),
|
|
289
|
+
end: command.indexOf("`", i + 1)
|
|
290
|
+
} : undefined;
|
|
291
|
+
if (substitution && substitution.end >= 0) {
|
|
292
|
+
const nested = canonicalizeGuardCommand(substitution.body);
|
|
293
|
+
if (containsGuardedSubstitution(nested, depth + 1, matcher) || decodeShellWords(nested).some((segment) => containsGuardedGitVerb(segment.words, depth + 1, matcher))) {
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
i = substitution.end;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
const GIT_GLOBAL_OPTIONS_WITH_VALUE = new Set([
|
|
302
|
+
"-C",
|
|
303
|
+
"-c",
|
|
304
|
+
"--config-env",
|
|
305
|
+
"--git-dir",
|
|
306
|
+
"--work-tree",
|
|
307
|
+
"--exec-path",
|
|
308
|
+
"--namespace"
|
|
309
|
+
]);
|
|
310
|
+
const GIT_GLOBAL_OPTIONS_WITH_INLINE_VALUE = [
|
|
311
|
+
"--config-env",
|
|
312
|
+
"--git-dir",
|
|
313
|
+
"--work-tree",
|
|
314
|
+
"--exec-path",
|
|
315
|
+
"--namespace"
|
|
316
|
+
];
|
|
317
|
+
function gitVerbIndex(gitTokens) {
|
|
318
|
+
let i = 1;
|
|
319
|
+
while (i < gitTokens.length && gitTokens[i].startsWith("-")) {
|
|
320
|
+
const option = gitTokens[i];
|
|
321
|
+
if (["--help", "-h", "--version", "-v", "-V"].includes(option)) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (option === "--")
|
|
325
|
+
return i + 1 < gitTokens.length ? i + 1 : undefined;
|
|
326
|
+
if (["-C", "-c"].some((prefix) => option.startsWith(prefix) && option.length > prefix.length)) {
|
|
327
|
+
i += 1;
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
if (GIT_GLOBAL_OPTIONS_WITH_INLINE_VALUE.some((prefix) => option.startsWith(`${prefix}=`))) {
|
|
331
|
+
i += 1;
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
i += GIT_GLOBAL_OPTIONS_WITH_VALUE.has(option) ? 2 : 1;
|
|
335
|
+
}
|
|
336
|
+
return i < gitTokens.length ? i : undefined;
|
|
337
|
+
}
|
|
338
|
+
export function matchGitVerbAtCommandPosition(gitTokens, matcher) {
|
|
339
|
+
const index = gitVerbIndex(gitTokens);
|
|
340
|
+
if (index === undefined)
|
|
341
|
+
return false;
|
|
342
|
+
const argsAfterVerb = gitTokens.slice(index + 1);
|
|
343
|
+
if (matcher.suppressPostVerbHelp && (argsAfterVerb[0] === "--help" || argsAfterVerb[0] === "-h")) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
const verbs = expandGuardVerbToken(gitTokens[index] ?? "");
|
|
347
|
+
return verbs.length === 1 && matcher.matchesVerb(verbs[0], argsAfterVerb);
|
|
348
|
+
}
|
|
349
|
+
function unquoteGuardValue(value) {
|
|
350
|
+
const trimmed = value.trim();
|
|
351
|
+
if (trimmed.length >= 2) {
|
|
352
|
+
const first = trimmed[0];
|
|
353
|
+
const last = trimmed[trimmed.length - 1];
|
|
354
|
+
if ((first === '"' || first === "'") && first === last) {
|
|
355
|
+
return trimmed.slice(1, -1);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return trimmed;
|
|
359
|
+
}
|
|
360
|
+
export function resolveGitTargetDirectory(gitTokens, cwd) {
|
|
361
|
+
let base = cwd;
|
|
362
|
+
let workTree;
|
|
363
|
+
let i = 1;
|
|
364
|
+
while (i < gitTokens.length && gitTokens[i].startsWith("-")) {
|
|
365
|
+
const option = gitTokens[i];
|
|
366
|
+
if (["--help", "-h", "--version", "-v", "-V"].includes(option))
|
|
367
|
+
break;
|
|
368
|
+
if (option === "--")
|
|
369
|
+
break;
|
|
370
|
+
if (option === "-C" && i + 1 < gitTokens.length) {
|
|
371
|
+
base = path.resolve(base, unquoteGuardValue(gitTokens[i + 1]));
|
|
372
|
+
i += 2;
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
if (option.startsWith("-C") && option.length > 2) {
|
|
376
|
+
base = path.resolve(base, unquoteGuardValue(option.slice(2)));
|
|
377
|
+
i += 1;
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
if (option === "--work-tree" && i + 1 < gitTokens.length) {
|
|
381
|
+
workTree = unquoteGuardValue(gitTokens[i + 1]);
|
|
382
|
+
i += 2;
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
if (option.startsWith("--work-tree=")) {
|
|
386
|
+
workTree = unquoteGuardValue(option.slice("--work-tree=".length));
|
|
387
|
+
i += 1;
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
if (option.startsWith("-c") && option.length > 2 && !option.startsWith("--")) {
|
|
391
|
+
i += 1;
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if (GIT_GLOBAL_OPTIONS_WITH_INLINE_VALUE.some((prefix) => option.startsWith(`${prefix}=`))) {
|
|
395
|
+
i += 1;
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
i += GIT_GLOBAL_OPTIONS_WITH_VALUE.has(option) ? 2 : 1;
|
|
399
|
+
}
|
|
400
|
+
return workTree === undefined ? base : path.resolve(base, workTree);
|
|
401
|
+
}
|
|
402
|
+
export function collectGitInvocations(toolName, input) {
|
|
403
|
+
if (toolName !== "bash")
|
|
404
|
+
return [];
|
|
405
|
+
const command = getShellCommand(input);
|
|
406
|
+
if (!command)
|
|
407
|
+
return [];
|
|
408
|
+
const invocations = [];
|
|
409
|
+
for (const segment of decodeShellWords(canonicalizeGuardCommand(command))) {
|
|
410
|
+
const tokens = segment.words.map((word) => word.text);
|
|
411
|
+
const gitIndex = tokens.findIndex((token) => isGitExecutable(token));
|
|
412
|
+
if (gitIndex >= 0)
|
|
413
|
+
invocations.push(tokens.slice(gitIndex));
|
|
414
|
+
}
|
|
415
|
+
return invocations;
|
|
416
|
+
}
|
|
417
|
+
function commandStringHasGuardedVerb(words, depth, matcher) {
|
|
418
|
+
return decodeShellWords(canonicalizeGuardCommand(words.map((word) => word.text).join(" "))).some((segment) => containsGuardedGitVerb(segment.words, depth, matcher));
|
|
419
|
+
}
|
|
420
|
+
function hidesGuardedVerb(words, depth, matcher) {
|
|
421
|
+
if (!matcher.indirectAlwaysMatches)
|
|
422
|
+
return false;
|
|
423
|
+
const firstHidden = words.findIndex((word) => word.hidden);
|
|
424
|
+
return firstHidden >= 0 && words.slice(firstHidden + 1).some((word) => firstHidden === 0 && word.hidden || matcher.matchesVerb(word.text, []) || commandStringHasGuardedVerb([word], depth + 1, matcher));
|
|
425
|
+
}
|
|
426
|
+
function containsGuardedGitVerb(words, depth, matcher) {
|
|
427
|
+
if (depth > 3 || words.length === 0)
|
|
428
|
+
return false;
|
|
429
|
+
let commandWords = words;
|
|
430
|
+
while (/^[A-Za-z_][A-Za-z0-9_]*=/.test(commandWords[0]?.text ?? "")) {
|
|
431
|
+
commandWords = commandWords.slice(1);
|
|
432
|
+
}
|
|
433
|
+
if (commandWords.length === 0)
|
|
434
|
+
return false;
|
|
435
|
+
const expandedHead = expandGuardVerbToken(commandWords[0]?.text ?? "");
|
|
436
|
+
if (expandedHead.length > 1) {
|
|
437
|
+
commandWords = [
|
|
438
|
+
...expandedHead.map((text) => ({ text })),
|
|
439
|
+
...commandWords.slice(1)
|
|
440
|
+
];
|
|
441
|
+
}
|
|
442
|
+
const commandTokens = commandWords.map((word) => word.text);
|
|
443
|
+
if (isCommandStringWrapper(commandTokens[0] ?? "")) {
|
|
444
|
+
const lower = commandTokens.slice(1).map((token) => token.toLowerCase());
|
|
445
|
+
const runIndex = lower.findIndex((token) => token === "--run" || token === "--command");
|
|
446
|
+
if (runIndex >= 0 && runIndex + 1 < commandTokens.length) {
|
|
447
|
+
return commandStringHasGuardedVerb(commandWords.slice(runIndex + 2), depth + 1, matcher);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (["echo", "printf", "grep"].includes(executableName(commandTokens[0] ?? ""))) {
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
const evalIndex = commandTokens.findIndex((token) => executableName(token) === "eval");
|
|
454
|
+
if (evalIndex >= 0 && commandStringHasGuardedVerb(commandWords.slice(evalIndex + 1), depth + 1, matcher)) {
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
if (hidesGuardedVerb(commandWords, depth, matcher))
|
|
458
|
+
return true;
|
|
459
|
+
const gitIndex = commandTokens.findIndex((token) => isGitExecutable(token));
|
|
460
|
+
if (gitIndex >= 0) {
|
|
461
|
+
if (gitIndex > 0 && matcher.indirectAlwaysMatches)
|
|
462
|
+
return true;
|
|
463
|
+
const gitTokens = commandTokens.slice(gitIndex);
|
|
464
|
+
const verbAt = gitVerbIndex(gitTokens);
|
|
465
|
+
if (matcher.indirectAlwaysMatches && verbAt !== undefined && commandWords[gitIndex + verbAt]?.hidden) {
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
return matchGitVerbAtCommandPosition(gitTokens, matcher);
|
|
469
|
+
}
|
|
470
|
+
const leadingExecutable = commandTokens[0] ?? "";
|
|
471
|
+
const knownCommandStringWrapper = isShellWrapper(leadingExecutable) || isCommandStringWrapper(leadingExecutable);
|
|
472
|
+
if (!knownCommandStringWrapper) {
|
|
473
|
+
const unknownSwitchIndex = commandTokens.slice(1).findIndex((token) => (token.startsWith("-") || token.startsWith("/")) && token.length > 1);
|
|
474
|
+
if (unknownSwitchIndex < 0)
|
|
475
|
+
return false;
|
|
476
|
+
const commandIndex = unknownSwitchIndex + 2;
|
|
477
|
+
if (commandIndex >= commandTokens.length)
|
|
478
|
+
return false;
|
|
479
|
+
return commandStringHasGuardedVerb(commandWords.slice(commandIndex), depth + 1, matcher);
|
|
480
|
+
}
|
|
481
|
+
const lower = commandTokens.slice(1).map((token) => token.toLowerCase());
|
|
482
|
+
const switchIndex = lower.findIndex((token) => token === "-c" || token === "--run" || token === "-lc" || /^-[^-]*c$/.test(token) && !token.startsWith("--") || token === "/c" || token === "-command" || token === "-command:" || token === "-encodedcommand");
|
|
483
|
+
if (switchIndex < 0 || switchIndex + 1 >= commandTokens.length)
|
|
484
|
+
return false;
|
|
485
|
+
if (lower[switchIndex] === "-encodedcommand")
|
|
486
|
+
return false;
|
|
487
|
+
let commandIndex = switchIndex + 2;
|
|
488
|
+
if (commandTokens[commandIndex] === "--")
|
|
489
|
+
commandIndex += 1;
|
|
490
|
+
return commandStringHasGuardedVerb(commandWords.slice(commandIndex), depth + 1, matcher);
|
|
491
|
+
}
|
|
492
|
+
export function detectGuardedGitVerb(toolName, input, matcher) {
|
|
493
|
+
if (toolName !== "bash")
|
|
494
|
+
return false;
|
|
495
|
+
const command = getShellCommand(input);
|
|
496
|
+
if (!command)
|
|
497
|
+
return false;
|
|
498
|
+
const canonical = canonicalizeGuardCommand(command);
|
|
499
|
+
if (containsGuardedSubstitution(canonical, 0, matcher))
|
|
500
|
+
return true;
|
|
501
|
+
return decodeShellWords(canonical).some((segment) => containsGuardedGitVerb(segment.words, 0, matcher));
|
|
502
|
+
}
|
|
503
|
+
export function isGitCommitOrPushAttempt(toolName, input) {
|
|
504
|
+
return detectGuardedGitVerb(toolName, input, COMMIT_PUSH_MATCHER);
|
|
505
|
+
}
|
|
506
|
+
function isTurnEndFindingsCache(value) {
|
|
507
|
+
if (!value || typeof value !== "object")
|
|
508
|
+
return false;
|
|
509
|
+
const record = value;
|
|
510
|
+
return typeof record.content === "string" && typeof record.hasBlockers === "boolean" && Array.isArray(record.affectedFiles) && record.affectedFiles.every((file) => typeof file === "string") && typeof record.sessionId === "string" && typeof record.projectSeqStart === "number" && typeof record.projectSeqEnd === "number" && Number.isFinite(record.projectSeqStart) && Number.isFinite(record.projectSeqEnd) && !!record.fileSeqByPath && typeof record.fileSeqByPath === "object" && Object.values(record.fileSeqByPath).every((seq) => typeof seq === "number" && Number.isFinite(seq)) && !!record.fileContentHashes && typeof record.fileContentHashes === "object" && Object.values(record.fileContentHashes).every((hash) => typeof hash === "string") && (record.affectedFilesTruncated === undefined || typeof record.affectedFilesTruncated === "boolean") && (record.blockingFiles === undefined || Array.isArray(record.blockingFiles)) && wellFormedStamp(record.blockerWrittenAt) && carriesWellFormedBlockers(record);
|
|
511
|
+
}
|
|
512
|
+
function carriesWellFormedBlockers(record) {
|
|
513
|
+
const carried = record.carriedBlockers;
|
|
514
|
+
if (carried === undefined)
|
|
515
|
+
return true;
|
|
516
|
+
if (!Array.isArray(carried) || carried.length === 0)
|
|
517
|
+
return false;
|
|
518
|
+
if (typeof record.blockerContent !== "string" || !record.blockerContent)
|
|
519
|
+
return false;
|
|
520
|
+
const owners = new Set([String(record.sessionId)]);
|
|
521
|
+
return carried.every((partition) => {
|
|
522
|
+
const ok = !!partition && typeof partition.sessionId === "string" && !owners.has(partition.sessionId) && typeof partition.blockerContent === "string" && partition.blockerContent.length > 0 && Array.isArray(partition.blockingFiles) && partition.blockingFiles.every((file) => typeof file === "string") && wellFormedStamp(partition.blockerWrittenAt);
|
|
523
|
+
if (ok)
|
|
524
|
+
owners.add(partition.sessionId);
|
|
525
|
+
return ok;
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
function wellFormedStamp(stamp) {
|
|
529
|
+
return stamp === undefined || Number.isFinite(stamp);
|
|
530
|
+
}
|
|
531
|
+
function storedRecord(cacheManager, cwd) {
|
|
532
|
+
const read = cacheManager.readCache("turn-end-findings", cwd, Number.POSITIVE_INFINITY);
|
|
533
|
+
if (!read)
|
|
534
|
+
return;
|
|
535
|
+
const { data } = read;
|
|
536
|
+
return {
|
|
537
|
+
fields: data && typeof data === "object" ? data : undefined
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
function cacheRecord(cacheManager, cwd) {
|
|
541
|
+
const fields = storedRecord(cacheManager, cwd)?.fields;
|
|
542
|
+
return isTurnEndFindingsCache(fields) ? fields : undefined;
|
|
543
|
+
}
|
|
544
|
+
function claimsNoBlocker(fields) {
|
|
545
|
+
if (!fields)
|
|
546
|
+
return false;
|
|
547
|
+
return fields.hasBlockers === false && (fields.testFailures === undefined || fields.testFailures === false) && (fields.blockerContent === undefined || fields.blockerContent === "") && (fields.testFailureContent === undefined || fields.testFailureContent === "") && (fields.testFailureFiles === undefined || Array.isArray(fields.testFailureFiles) && fields.testFailureFiles.length === 0) && fields.carriedBlockers === undefined;
|
|
548
|
+
}
|
|
549
|
+
function recordPartitions(record) {
|
|
550
|
+
const top = record.blockerContent ? [
|
|
551
|
+
{
|
|
552
|
+
sessionId: record.sessionId,
|
|
553
|
+
blockerContent: record.blockerContent,
|
|
554
|
+
blockingFiles: record.blockingFiles ?? [],
|
|
555
|
+
blockerWrittenAt: record.blockerWrittenAt
|
|
556
|
+
}
|
|
557
|
+
] : [];
|
|
558
|
+
return [...top, ...record.carriedBlockers ?? []];
|
|
559
|
+
}
|
|
560
|
+
export function blockerPartitionFields(partitions) {
|
|
561
|
+
const [top, ...carried] = partitions;
|
|
562
|
+
return {
|
|
563
|
+
owner: top?.sessionId,
|
|
564
|
+
blockerContent: top?.blockerContent,
|
|
565
|
+
blockingFiles: top?.blockingFiles,
|
|
566
|
+
carriedBlockers: carried.length > 0 ? carried : undefined,
|
|
567
|
+
blockerWrittenAt: top?.blockerWrittenAt
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
function sectionFileGone(section, cwd) {
|
|
571
|
+
try {
|
|
572
|
+
return nodeFs.statSync(resolveGuardPath(section.file, cwd), {
|
|
573
|
+
throwIfNoEntry: false
|
|
574
|
+
}) === undefined;
|
|
575
|
+
} catch {
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
function trimPartition(partition, cwd, dropKeys, leaves) {
|
|
580
|
+
const sections = blockingProvenance(partition.blockerContent, partition.blockingFiles, cwd);
|
|
581
|
+
if (!sections)
|
|
582
|
+
return { kept: partition, dropped: 0 };
|
|
583
|
+
const blockingFiles = partition.blockingFiles.filter((file) => !dropKeys.has(guardPathKey(file, cwd)));
|
|
584
|
+
const keptSections = sections.filter((section) => !leaves(section));
|
|
585
|
+
const dropped = sections.length - keptSections.length;
|
|
586
|
+
if (keptSections.length === 0)
|
|
587
|
+
return { kept: undefined, dropped };
|
|
588
|
+
return {
|
|
589
|
+
kept: {
|
|
590
|
+
sessionId: partition.sessionId,
|
|
591
|
+
blockerContent: dropped > 0 ? keptSections.map((section) => section.lines.join(`
|
|
592
|
+
`)).join(`
|
|
593
|
+
|
|
594
|
+
`) : partition.blockerContent,
|
|
595
|
+
blockingFiles,
|
|
596
|
+
blockerWrittenAt: partition.blockerWrittenAt
|
|
597
|
+
},
|
|
598
|
+
dropped
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
function logSectionsDropped(cwd, by, basis) {
|
|
602
|
+
logLatency({
|
|
603
|
+
type: "phase",
|
|
604
|
+
toolName: "git-guard",
|
|
605
|
+
filePath: cwd,
|
|
606
|
+
phase: "sections_dropped",
|
|
607
|
+
durationMs: 0,
|
|
608
|
+
result: basis,
|
|
609
|
+
metadata: { by, basis }
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
export function logCarriedDrops(cwd, dropped) {
|
|
613
|
+
if (dropped.noFile)
|
|
614
|
+
logSectionsDropped(cwd, "turn_end", "no_file");
|
|
615
|
+
if (dropped.gone)
|
|
616
|
+
logSectionsDropped(cwd, "turn_end", "file_gone");
|
|
617
|
+
}
|
|
618
|
+
function pastFreshnessWindow(partition, now) {
|
|
619
|
+
const writtenAt = partition.blockerWrittenAt;
|
|
620
|
+
return writtenAt !== undefined && now - writtenAt > DEFAULT_MAX_AGE_MS;
|
|
621
|
+
}
|
|
622
|
+
export function readTurnEndGuardRecord(cacheManager, runtime, cwd, sessionId) {
|
|
623
|
+
const stored = storedRecord(cacheManager, cwd)?.fields;
|
|
624
|
+
const { carried, dropped } = carriedTurnEndBlockers(stored, cwd, sessionId ?? runtime.telemetrySessionId);
|
|
625
|
+
return { stored, carried, dropped };
|
|
626
|
+
}
|
|
627
|
+
function carriedTurnEndBlockers(stored, cwd, me) {
|
|
628
|
+
const dropped = { gone: false, noFile: false };
|
|
629
|
+
if (!isTurnEndFindingsCache(stored))
|
|
630
|
+
return { carried: [], dropped, stamped: false };
|
|
631
|
+
const now = Date.now();
|
|
632
|
+
const carried = [];
|
|
633
|
+
let stamped = false;
|
|
634
|
+
for (const partition of recordPartitions(stored)) {
|
|
635
|
+
if (partition.sessionId === me)
|
|
636
|
+
continue;
|
|
637
|
+
if (!blockingProvenance(partition.blockerContent, partition.blockingFiles, cwd) && !pastFreshnessWindow(partition, now)) {
|
|
638
|
+
if (partition.blockerWrittenAt === undefined)
|
|
639
|
+
stamped = true;
|
|
640
|
+
carried.push({
|
|
641
|
+
...partition,
|
|
642
|
+
blockerWrittenAt: partition.blockerWrittenAt ?? now
|
|
643
|
+
});
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
const split = splitBlockerSections(partition.blockerContent, partition.blockingFiles.filter((file) => typeof file === "string" && file.trim().length > 0), cwd);
|
|
647
|
+
if (split.unowned)
|
|
648
|
+
dropped.noFile = true;
|
|
649
|
+
const live = split.sections.filter((section) => !sectionFileGone(section, cwd));
|
|
650
|
+
if (live.length < split.sections.length)
|
|
651
|
+
dropped.gone = true;
|
|
652
|
+
if (live.length === 0)
|
|
653
|
+
continue;
|
|
654
|
+
carried.push({
|
|
655
|
+
sessionId: partition.sessionId,
|
|
656
|
+
blockerContent: live.length === split.sections.length && !split.unowned ? partition.blockerContent : live.map((section) => section.lines.join(`
|
|
657
|
+
`)).join(`
|
|
658
|
+
|
|
659
|
+
`),
|
|
660
|
+
blockingFiles: partition.blockingFiles,
|
|
661
|
+
blockerWrittenAt: partition.blockerWrittenAt
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
return { carried, dropped, stamped };
|
|
665
|
+
}
|
|
666
|
+
const NO_CLAIM_FIELDS = [
|
|
667
|
+
"content",
|
|
668
|
+
"affectedFiles",
|
|
669
|
+
"affectedFilesTruncated",
|
|
670
|
+
"provenance"
|
|
671
|
+
];
|
|
672
|
+
function makesNoClaim(fields) {
|
|
673
|
+
return !!fields && typeof fields.content === "string" && Object.keys(fields).every((key) => NO_CLAIM_FIELDS.some((field) => field === key));
|
|
674
|
+
}
|
|
675
|
+
function logRecordRetired(cwd, by, basis) {
|
|
676
|
+
logLatency({
|
|
677
|
+
type: "phase",
|
|
678
|
+
toolName: "git-guard",
|
|
679
|
+
filePath: cwd,
|
|
680
|
+
phase: "record_retired",
|
|
681
|
+
durationMs: 0,
|
|
682
|
+
result: basis,
|
|
683
|
+
metadata: { by, basis }
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
export function retireSettledGitGuardRecord(runtime, cacheManager, cwd, sessionId) {
|
|
687
|
+
const stored = storedRecord(cacheManager, cwd)?.fields;
|
|
688
|
+
if (!stored)
|
|
689
|
+
return false;
|
|
690
|
+
const me = sessionId ?? runtime.telemetrySessionId;
|
|
691
|
+
const own = stored.sessionId === me && stored.testFailures !== true && stored.carriedBlockers === undefined;
|
|
692
|
+
const basis = own ? "own_session" : claimsNoBlocker(stored) ? "no_blocker" : makesNoClaim(stored) ? "no_claim" : undefined;
|
|
693
|
+
if (basis) {
|
|
694
|
+
cacheManager.clearCache("turn-end-findings", cwd);
|
|
695
|
+
runtime.clearGitGuardCacheUnknown();
|
|
696
|
+
logRecordRetired(cwd, "turn_end", basis);
|
|
697
|
+
return true;
|
|
698
|
+
}
|
|
699
|
+
return retireOwnPartition(runtime, cacheManager, cwd, stored, me);
|
|
700
|
+
}
|
|
701
|
+
function retireOwnPartition(runtime, cacheManager, cwd, stored, me) {
|
|
702
|
+
if (!isTurnEndFindingsCache(stored))
|
|
703
|
+
return false;
|
|
704
|
+
if (stored.sessionId === me && stored.carriedBlockers === undefined)
|
|
705
|
+
return false;
|
|
706
|
+
const ownDropped = recordPartitions(stored).some((partition) => partition.sessionId === me);
|
|
707
|
+
const { carried: kept, dropped, stamped } = carriedTurnEndBlockers(stored, cwd, me);
|
|
708
|
+
if (!ownDropped && !dropped.gone && !dropped.noFile) {
|
|
709
|
+
if (stamped) {
|
|
710
|
+
const fields = blockerPartitionFields(kept);
|
|
711
|
+
writeGitGuardRecord(cacheManager, runtime, cwd, {
|
|
712
|
+
...stored,
|
|
713
|
+
carriedBlockers: fields.carriedBlockers,
|
|
714
|
+
blockerWrittenAt: fields.blockerWrittenAt
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
return false;
|
|
718
|
+
}
|
|
719
|
+
const testFailures = stored.testFailures === true;
|
|
720
|
+
if (kept.length === 0 && !testFailures) {
|
|
721
|
+
cacheManager.clearCache("turn-end-findings", cwd);
|
|
722
|
+
runtime.clearGitGuardCacheUnknown();
|
|
723
|
+
logRecordRetired(cwd, "turn_end", dropped.noFile ? "no_file" : "file_gone");
|
|
724
|
+
return true;
|
|
725
|
+
}
|
|
726
|
+
if (ownDropped)
|
|
727
|
+
logSectionsDropped(cwd, "turn_end", "own_session");
|
|
728
|
+
logCarriedDrops(cwd, dropped);
|
|
729
|
+
const fields = blockerPartitionFields(kept);
|
|
730
|
+
const owner = fields.owner ?? stored.sessionId;
|
|
731
|
+
writeGitGuardRecord(cacheManager, runtime, cwd, {
|
|
732
|
+
...stored,
|
|
733
|
+
content: [
|
|
734
|
+
fields.blockerContent,
|
|
735
|
+
testFailures ? stored.testFailureContent : undefined
|
|
736
|
+
].filter((value) => !!value).join(`
|
|
737
|
+
|
|
738
|
+
`),
|
|
739
|
+
blockerContent: fields.blockerContent,
|
|
740
|
+
blockingFiles: fields.blockingFiles,
|
|
741
|
+
carriedBlockers: fields.carriedBlockers,
|
|
742
|
+
blockerWrittenAt: fields.blockerWrittenAt,
|
|
743
|
+
hasBlockers: kept.length > 0 || testFailures,
|
|
744
|
+
sessionId: owner,
|
|
745
|
+
consumed: stored.consumed === true
|
|
746
|
+
});
|
|
747
|
+
return false;
|
|
748
|
+
}
|
|
749
|
+
function markCacheUnknown(runtime, reason) {
|
|
750
|
+
runtime.markGitGuardCacheUnknown(reason);
|
|
751
|
+
}
|
|
752
|
+
function recordOwner(existing, runtime, storedSectionSurvives) {
|
|
753
|
+
return existing && storedSectionSurvives ? existing.sessionId : runtime.telemetrySessionId;
|
|
754
|
+
}
|
|
755
|
+
export function writeGitGuardRecord(cacheManager, runtime, cwd, record) {
|
|
756
|
+
const capped = capAffectedFiles(Array.isArray(record.affectedFiles) ? record.affectedFiles : [], cwd);
|
|
757
|
+
const fileSeqByPath = { ...record.fileSeqByPath };
|
|
758
|
+
for (const file of capped.files) {
|
|
759
|
+
const key = guardPathKey(file, cwd);
|
|
760
|
+
if (fileSeqByPath[key] === undefined) {
|
|
761
|
+
fileSeqByPath[key] = runtime.getFileSeq(resolveGuardPath(file, cwd));
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
const currentProvenance = snapshotAdvisoryProvenance({
|
|
765
|
+
cwd,
|
|
766
|
+
runtime,
|
|
767
|
+
generation: 0,
|
|
768
|
+
files: capped.files.map((file) => ({
|
|
769
|
+
path: file,
|
|
770
|
+
role: "affected"
|
|
771
|
+
})),
|
|
772
|
+
truncated: capped.truncated
|
|
773
|
+
});
|
|
774
|
+
const fileContentHashes = Object.fromEntries(currentProvenance.files.map((file) => [
|
|
775
|
+
guardPathKey(file.path, cwd),
|
|
776
|
+
file.sha256
|
|
777
|
+
]));
|
|
778
|
+
const data = {
|
|
779
|
+
...record,
|
|
780
|
+
affectedFiles: capped.files,
|
|
781
|
+
affectedFilesTruncated: capped.truncated,
|
|
782
|
+
fileSeqByPath,
|
|
783
|
+
blockingFiles: Array.isArray(record.blockingFiles) ? capAffectedFiles(record.blockingFiles, cwd).files : undefined,
|
|
784
|
+
fileContentHashes,
|
|
785
|
+
provenance: record.provenance ?? currentProvenance
|
|
786
|
+
};
|
|
787
|
+
try {
|
|
788
|
+
cacheManager.writeCache("turn-end-findings", data, cwd);
|
|
789
|
+
runtime.clearGitGuardCacheUnknown();
|
|
790
|
+
return true;
|
|
791
|
+
} catch {
|
|
792
|
+
markCacheUnknown(runtime, "cache_write_failed");
|
|
793
|
+
return false;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
function logDecision(cwd, decision, reasonCategory, metadata = {}) {
|
|
797
|
+
logLatency({
|
|
798
|
+
type: "phase",
|
|
799
|
+
toolName: "git-guard",
|
|
800
|
+
filePath: cwd,
|
|
801
|
+
phase: "decision",
|
|
802
|
+
durationMs: 0,
|
|
803
|
+
result: decision,
|
|
804
|
+
metadata: { decision, reasonCategory, ...metadata }
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
const RECHECK_REMEDY = "Write the affected files again so dm-lens re-checks them, then retry.";
|
|
808
|
+
const MAX_REMEDY_FILES = 5;
|
|
809
|
+
function shownLatchFile(filePath, cwd) {
|
|
810
|
+
const resolved = resolveGuardPath(filePath, cwd);
|
|
811
|
+
return isOutsideProjectRoot(resolved, cwd) ? "a file outside the project" : toProjectRelativePath(resolved, cwd);
|
|
812
|
+
}
|
|
813
|
+
function unconfirmedRecordRemedy(stored, inspection, me, cwd) {
|
|
814
|
+
if (stored === undefined)
|
|
815
|
+
return;
|
|
816
|
+
const { fields } = stored;
|
|
817
|
+
const record = isTurnEndFindingsCache(fields) ? fields : undefined;
|
|
818
|
+
const testRemedy = record?.testFailures === true ? "Run the failing tests again: a passing run clears them." : undefined;
|
|
819
|
+
if (record && inspection === "fresh" && record.sessionId === me && record.carriedBlockers === undefined) {
|
|
820
|
+
return testRemedy ? `Write the affected files again so dm-lens re-checks them. ${testRemedy} Then retry.` : undefined;
|
|
821
|
+
}
|
|
822
|
+
const parsed = record ? recordPartitions(record).map((partition) => blockingProvenance(partition.blockerContent, partition.blockingFiles, cwd)) : [];
|
|
823
|
+
const sections = parsed.flatMap((owned) => owned ?? []);
|
|
824
|
+
const parts = [];
|
|
825
|
+
if (sections.length > 0) {
|
|
826
|
+
const named = new Set;
|
|
827
|
+
const outsideKeys = new Set;
|
|
828
|
+
for (const section of sections) {
|
|
829
|
+
const resolved = resolveGuardPath(section.file, cwd);
|
|
830
|
+
if (isOutsideProjectRoot(resolved, cwd))
|
|
831
|
+
outsideKeys.add(section.key);
|
|
832
|
+
else
|
|
833
|
+
named.add(toProjectRelativePath(resolved, cwd));
|
|
834
|
+
}
|
|
835
|
+
const outside = outsideKeys.size;
|
|
836
|
+
const listed = [...named].slice(0, MAX_REMEDY_FILES);
|
|
837
|
+
const shownParts = listed.length > 0 ? [listed.join(", ")] : [];
|
|
838
|
+
if (named.size > listed.length) {
|
|
839
|
+
shownParts.push(`${named.size - listed.length} more`);
|
|
840
|
+
}
|
|
841
|
+
if (outside > 0) {
|
|
842
|
+
shownParts.push(`${outside} file${outside === 1 ? "" : "s"} outside the project`);
|
|
843
|
+
}
|
|
844
|
+
const shown = shownParts.join(" and ");
|
|
845
|
+
parts.push(`The record names blockers in ${shown} that dm-lens cannot confirm. Fix them and write each file again: a clean dm-lens check of a file clears its part of the record.`);
|
|
846
|
+
}
|
|
847
|
+
if (makesNoClaim(fields)) {
|
|
848
|
+
parts.push("The record makes no blocker claim dm-lens can check, so no re-check of one file clears it; a turn that ends with no blocker clears it.");
|
|
849
|
+
} else if (!record) {
|
|
850
|
+
parts.push("The record holds blockers dm-lens cannot attribute to a file, so no re-check of one file clears them; this session's next turn-end findings replace it.");
|
|
851
|
+
} else if (parsed.some((owned) => owned === undefined)) {
|
|
852
|
+
parts.push(`The record holds blockers dm-lens cannot attribute to a file, so no re-check of one file clears them; the session that wrote them replaces them at its next turn end, and once ${DEFAULT_MAX_AGE_MS / 60000} minutes pass without that session rewriting them, a turn end of any session drops them.`);
|
|
853
|
+
}
|
|
854
|
+
if (testRemedy)
|
|
855
|
+
parts.push(testRemedy);
|
|
856
|
+
return parts.length > 0 ? `${parts.join(" ")} Then retry.` : undefined;
|
|
857
|
+
}
|
|
858
|
+
function unknown(cwd, reasonCategory, metadata = {}, remedy = RECHECK_REMEDY) {
|
|
859
|
+
logDecision(cwd, "unknown", reasonCategory, metadata);
|
|
860
|
+
return {
|
|
861
|
+
block: true,
|
|
862
|
+
unknown: true,
|
|
863
|
+
reason: `\uD83D\uDD34 COMMIT BLOCKED (--lens-guard): blocker state is unknown (${reasonCategory}). ${remedy}`
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
export function retireInlineBlockerAndResyncGuard(args) {
|
|
867
|
+
const owner = args.runtime.inlineBlockerOwner(args.filePath);
|
|
868
|
+
const retired = args.runtime.retireInlineBlockerOnConfirmedClean(args.filePath, args.writeIndex, args.coveredSources);
|
|
869
|
+
if (!retired)
|
|
870
|
+
return false;
|
|
871
|
+
args.runtime.updateGitGuardStatus(false, "");
|
|
872
|
+
if (args.lensGuardEnabled) {
|
|
873
|
+
syncGitGuardRecord(args.runtime, args.cacheManager, args.cwd, args.filePath, undefined, undefined, owner);
|
|
874
|
+
}
|
|
875
|
+
return true;
|
|
876
|
+
}
|
|
877
|
+
export function resyncGitGuardAfterInlinePolicy(args) {
|
|
878
|
+
const changed = args.runtime.applyInlineBlockerPolicyVerdicts(args.suppressedFilePaths, { sessionId: args.sessionId });
|
|
879
|
+
if (args.suppressedFilePaths.length === 0 && changed === 0)
|
|
880
|
+
return;
|
|
881
|
+
args.runtime.updateGitGuardStatus(false, "");
|
|
882
|
+
}
|
|
883
|
+
export function syncGitGuardRecord(runtime, cacheManager, cwd, editedFilePath, analysisRootMode = "session", editedCleanVerdict = false, sessionId) {
|
|
884
|
+
if (!canWriteAnalysisRoot(analysisRootMode))
|
|
885
|
+
return;
|
|
886
|
+
const entries = (runtime.getInlineBlockersSnapshot?.({ sessionId }) ?? []).filter((entry) => !entry.policySuppressed);
|
|
887
|
+
const stored = storedRecord(cacheManager, cwd)?.fields;
|
|
888
|
+
if (entries.length === 0 && claimsNoBlocker(stored)) {
|
|
889
|
+
cacheManager.clearCache("turn-end-findings", cwd);
|
|
890
|
+
runtime.clearGitGuardCacheUnknown();
|
|
891
|
+
logRecordRetired(cwd, "write", "no_blocker");
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
const existing = isTurnEndFindingsCache(stored) ? stored : undefined;
|
|
895
|
+
const editedKey = editedFilePath ? guardPathKey(editedFilePath, cwd) : undefined;
|
|
896
|
+
const me = sessionId ?? runtime.telemetrySessionId;
|
|
897
|
+
const blockerSections = existing?.blockerContent ? blockingProvenance(existing.blockerContent, existing.blockingFiles ?? [], cwd) : undefined;
|
|
898
|
+
const dropKey = new Set(editedKey ? [editedKey] : []);
|
|
899
|
+
let droppedForeign = 0;
|
|
900
|
+
let droppedOwn = 0;
|
|
901
|
+
let goneForeign = 0;
|
|
902
|
+
const trimmed = [];
|
|
903
|
+
for (const partition of existing ? recordPartitions(existing) : []) {
|
|
904
|
+
const own = partition.sessionId === me;
|
|
905
|
+
const speaksForFile = !!editedKey && (own || editedCleanVerdict);
|
|
906
|
+
const result = trimPartition(partition, cwd, speaksForFile ? dropKey : new Set, (section) => {
|
|
907
|
+
if (speaksForFile && section.key === editedKey)
|
|
908
|
+
return true;
|
|
909
|
+
if (own || !sectionFileGone(section, cwd))
|
|
910
|
+
return false;
|
|
911
|
+
goneForeign += 1;
|
|
912
|
+
return true;
|
|
913
|
+
});
|
|
914
|
+
if (own)
|
|
915
|
+
droppedOwn += result.dropped;
|
|
916
|
+
else
|
|
917
|
+
droppedForeign += result.dropped;
|
|
918
|
+
if (result.kept)
|
|
919
|
+
trimmed.push(result.kept);
|
|
920
|
+
}
|
|
921
|
+
const foreign = !!existing && existing.sessionId !== me;
|
|
922
|
+
if (foreign && entries.length === 0 && droppedForeign === 0 && droppedOwn === 0) {
|
|
923
|
+
if (sessionId !== undefined && !runtime.isCoordinatorSession(sessionId)) {
|
|
924
|
+
recordDegradationOnce({
|
|
925
|
+
kind: "git-guard-non-owner-write",
|
|
926
|
+
subject: sessionId,
|
|
927
|
+
reason: "a concurrent session's write left another session's commit-gate record and latch untouched"
|
|
928
|
+
});
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
markCacheUnknown(runtime, "session_mismatch");
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
if (!existing && entries.length === 0) {
|
|
935
|
+
const inspection = cacheManager.inspectCache("turn-end-findings", cwd);
|
|
936
|
+
if (inspection !== "missing") {
|
|
937
|
+
markCacheUnknown(runtime, `cache_${inspection}`);
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
const fileSeqByPath = {};
|
|
942
|
+
for (const [filePath, seq] of runtime.getFileSeqEntries?.() ?? []) {
|
|
943
|
+
fileSeqByPath[guardPathKey(filePath, cwd)] = seq;
|
|
944
|
+
}
|
|
945
|
+
const inlineFiles = entries.map((entry) => resolveGuardPath(entry.filePath, cwd));
|
|
946
|
+
if (existing?.blockerContent && !blockerSections) {
|
|
947
|
+
markCacheUnknown(runtime, "blocking_provenance_untrusted");
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
const partitions = entries.length > 0 ? [
|
|
951
|
+
{
|
|
952
|
+
sessionId: me,
|
|
953
|
+
blockerContent: entries.map((entry) => `${entry.filePath}: ${entry.summary}`).join(`
|
|
954
|
+
`),
|
|
955
|
+
blockingFiles: inlineFiles
|
|
956
|
+
},
|
|
957
|
+
...trimmed.filter((partition) => partition.sessionId !== me)
|
|
958
|
+
] : trimmed;
|
|
959
|
+
const fields = blockerPartitionFields(partitions);
|
|
960
|
+
const testFiles = existing?.testFailureFiles ?? [];
|
|
961
|
+
let affectedFiles = [...existing?.affectedFiles ?? [], ...inlineFiles];
|
|
962
|
+
if (!entries.length && editedKey && existing) {
|
|
963
|
+
const isStillTestFailure = testFiles.some((file) => guardPathKey(file, cwd) === editedKey);
|
|
964
|
+
const stillRecorded = partitions.some((partition) => !!blockingProvenance(partition.blockerContent, partition.blockingFiles, cwd)?.some((section) => section.key === editedKey));
|
|
965
|
+
if (!isStillTestFailure && !stillRecorded) {
|
|
966
|
+
affectedFiles = affectedFiles.filter((file) => guardPathKey(file, cwd) !== editedKey);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
const blockerContent = fields.blockerContent;
|
|
970
|
+
const hasTestFailures = existing?.testFailures === true;
|
|
971
|
+
const hasBlockers = partitions.length > 0 || hasTestFailures;
|
|
972
|
+
const content = [
|
|
973
|
+
blockerContent,
|
|
974
|
+
hasTestFailures ? existing?.testFailureContent : undefined
|
|
975
|
+
].filter((value) => !!value).join(`
|
|
976
|
+
|
|
977
|
+
`);
|
|
978
|
+
if (!hasBlockers && !content) {
|
|
979
|
+
cacheManager.clearCache("turn-end-findings", cwd);
|
|
980
|
+
runtime.clearGitGuardCacheUnknown();
|
|
981
|
+
if (droppedForeign > goneForeign)
|
|
982
|
+
logRecordRetired(cwd, "write", "rechecked");
|
|
983
|
+
else if (goneForeign > 0)
|
|
984
|
+
logRecordRetired(cwd, "write", "file_gone");
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
if (goneForeign > 0)
|
|
988
|
+
logSectionsDropped(cwd, "write", "file_gone");
|
|
989
|
+
const owner = fields.owner ?? existing?.sessionId ?? me;
|
|
990
|
+
writeGitGuardRecord(cacheManager, runtime, cwd, {
|
|
991
|
+
content: content || existing?.content || "",
|
|
992
|
+
blockerContent,
|
|
993
|
+
blockingFiles: fields.blockingFiles ?? [],
|
|
994
|
+
carriedBlockers: fields.carriedBlockers,
|
|
995
|
+
blockerWrittenAt: fields.blockerWrittenAt,
|
|
996
|
+
hasBlockers,
|
|
997
|
+
affectedFiles,
|
|
998
|
+
sessionId: owner,
|
|
999
|
+
projectSeqStart: runtime.turnStartProjectSeq,
|
|
1000
|
+
projectSeqEnd: runtime.projectSeq,
|
|
1001
|
+
fileSeqByPath,
|
|
1002
|
+
fileContentHashes: {},
|
|
1003
|
+
consumed: owner !== me && existing?.consumed === true,
|
|
1004
|
+
testFailures: existing?.testFailures,
|
|
1005
|
+
testFailureContent: existing?.testFailureContent,
|
|
1006
|
+
testFailureFiles: existing?.testFailureFiles
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
export function mergeGitGuardTestFailure(cacheManager, cwd, runtime, content, files) {
|
|
1010
|
+
const existing = cacheRecord(cacheManager, cwd);
|
|
1011
|
+
const fileSeqByPath = {};
|
|
1012
|
+
for (const [filePath, seq] of runtime.getFileSeqEntries?.() ?? []) {
|
|
1013
|
+
fileSeqByPath[guardPathKey(filePath, cwd)] = seq;
|
|
1014
|
+
}
|
|
1015
|
+
const failedFiles = files.map((file) => resolveGuardPath(file, cwd));
|
|
1016
|
+
const blockerContent = existing?.blockerContent;
|
|
1017
|
+
const sessionId = recordOwner(existing, runtime, !!blockerContent);
|
|
1018
|
+
const testFailureFiles = [
|
|
1019
|
+
...existing?.testFailureFiles ?? [],
|
|
1020
|
+
...failedFiles
|
|
1021
|
+
].filter((file, index, all) => all.findIndex((candidate) => guardPathKey(candidate, cwd) === guardPathKey(file, cwd)) === index);
|
|
1022
|
+
writeGitGuardRecord(cacheManager, runtime, cwd, {
|
|
1023
|
+
content: [blockerContent, content].filter(Boolean).join(`
|
|
1024
|
+
|
|
1025
|
+
`),
|
|
1026
|
+
blockerContent,
|
|
1027
|
+
blockingFiles: existing?.blockingFiles ?? [],
|
|
1028
|
+
carriedBlockers: existing?.carriedBlockers,
|
|
1029
|
+
blockerWrittenAt: existing?.blockerWrittenAt,
|
|
1030
|
+
testFailureContent: content,
|
|
1031
|
+
testFailureFiles,
|
|
1032
|
+
hasBlockers: true,
|
|
1033
|
+
affectedFiles: [...existing?.affectedFiles ?? [], ...failedFiles],
|
|
1034
|
+
sessionId,
|
|
1035
|
+
projectSeqStart: runtime.turnStartProjectSeq,
|
|
1036
|
+
projectSeqEnd: runtime.projectSeq,
|
|
1037
|
+
fileSeqByPath,
|
|
1038
|
+
fileContentHashes: {},
|
|
1039
|
+
consumed: false,
|
|
1040
|
+
testFailures: true
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
export function clearGitGuardTestFailure(cacheManager, cwd, runtime, passedFiles = []) {
|
|
1044
|
+
const existing = cacheRecord(cacheManager, cwd);
|
|
1045
|
+
if (!existing?.testFailures)
|
|
1046
|
+
return;
|
|
1047
|
+
const passedKeys = new Set((passedFiles.length > 0 ? passedFiles : existing.testFailureFiles ?? []).map((file) => guardPathKey(file, cwd)));
|
|
1048
|
+
const remainingFiles = (existing.testFailureFiles ?? []).filter((file) => !passedKeys.has(guardPathKey(file, cwd)));
|
|
1049
|
+
const blockerContent = existing.blockerContent ?? "";
|
|
1050
|
+
if (!blockerContent && remainingFiles.length === 0) {
|
|
1051
|
+
cacheManager.clearCache("turn-end-findings", cwd);
|
|
1052
|
+
runtime.clearGitGuardCacheUnknown();
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
const blockingKeys = new Set([
|
|
1056
|
+
...existing.blockingFiles ?? [],
|
|
1057
|
+
...(existing.carriedBlockers ?? []).flatMap((partition) => partition.blockingFiles)
|
|
1058
|
+
].map((file) => guardPathKey(file, cwd)));
|
|
1059
|
+
const affectedFiles = existing.affectedFiles.filter((file) => blockingKeys.has(guardPathKey(file, cwd)) || remainingFiles.some((testFile) => guardPathKey(testFile, cwd) === guardPathKey(file, cwd)));
|
|
1060
|
+
writeGitGuardRecord(cacheManager, runtime, cwd, {
|
|
1061
|
+
...existing,
|
|
1062
|
+
content: blockerContent,
|
|
1063
|
+
blockerContent,
|
|
1064
|
+
affectedFiles,
|
|
1065
|
+
testFailures: remainingFiles.length > 0,
|
|
1066
|
+
testFailureContent: remainingFiles.length > 0 ? existing.testFailureContent : undefined,
|
|
1067
|
+
testFailureFiles: remainingFiles.length > 0 ? remainingFiles : undefined,
|
|
1068
|
+
hasBlockers: !!blockerContent || remainingFiles.length > 0,
|
|
1069
|
+
sessionId: recordOwner(existing, runtime, !!blockerContent),
|
|
1070
|
+
projectSeqStart: runtime.turnStartProjectSeq,
|
|
1071
|
+
projectSeqEnd: runtime.projectSeq,
|
|
1072
|
+
fileSeqByPath: Object.fromEntries(runtime.getFileSeqEntries().map(([filePath, seq]) => [guardPathKey(filePath, cwd), seq])),
|
|
1073
|
+
fileContentHashes: {}
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
function firstExpiredSuppressionVerdict(runtime) {
|
|
1077
|
+
for (const entry of runtime.getInlineBlockersSnapshot?.() ?? []) {
|
|
1078
|
+
if (!entry.policySuppressed)
|
|
1079
|
+
continue;
|
|
1080
|
+
if (entry.recordedHash === undefined) {
|
|
1081
|
+
return { filePath: entry.filePath, tier: "no_baseline" };
|
|
1082
|
+
}
|
|
1083
|
+
if (fileFingerprint(entry.filePath) !== entry.recordedHash) {
|
|
1084
|
+
return { filePath: entry.filePath, tier: "content" };
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
export function evaluateGitGuard(runtime, cacheManager, cwd, host = "pi", sessionId) {
|
|
1090
|
+
const me = sessionId ?? runtime.telemetrySessionId;
|
|
1091
|
+
const diagnosticsTool = resolveLensToolName("lens_diagnostics", host);
|
|
1092
|
+
const inspectLine = diagnosticsTool ? `Run ${diagnosticsTool} mode=all for full details, then commit again.` : "Inspect the full diagnostics, then commit again.";
|
|
1093
|
+
try {
|
|
1094
|
+
const absorbed = absorbSettledRunnerBlockers(runtime, cwd);
|
|
1095
|
+
if (absorbed.recorded > 0)
|
|
1096
|
+
syncGitGuardRecord(runtime, cacheManager, cwd);
|
|
1097
|
+
for (const filePath of absorbed.retiredFiles) {
|
|
1098
|
+
syncGitGuardRecord(runtime, cacheManager, cwd, filePath);
|
|
1099
|
+
}
|
|
1100
|
+
} catch (failure) {
|
|
1101
|
+
incrementDegradationCount({
|
|
1102
|
+
kind: "deferred-blocker-gate-error",
|
|
1103
|
+
subject: "commit_gate",
|
|
1104
|
+
reason: failure instanceof Error ? failure.message : String(failure)
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
if (runtime.gitGuardHasBlockers) {
|
|
1108
|
+
logDecision(cwd, "blocked", "runtime_blockers", {
|
|
1109
|
+
projectSeq: runtime.projectSeq
|
|
1110
|
+
});
|
|
1111
|
+
const detail = runtime.gitGuardSummary ? `
|
|
1112
|
+
${runtime.gitGuardSummary}` : "";
|
|
1113
|
+
return {
|
|
1114
|
+
block: true,
|
|
1115
|
+
reason: `\uD83D\uDD34 COMMIT BLOCKED (--lens-guard): unresolved blockers must be fixed before commit/push.${detail}
|
|
1116
|
+
${inspectLine}`
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
const expired = firstExpiredSuppressionVerdict(runtime);
|
|
1120
|
+
if (expired) {
|
|
1121
|
+
return unknown(cwd, "inline_policy_stale", {
|
|
1122
|
+
file: expired.filePath,
|
|
1123
|
+
tier: expired.tier
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
const inspection = cacheManager.inspectCache("turn-end-findings", cwd);
|
|
1127
|
+
const stored = inspection === "missing" ? undefined : storedRecord(cacheManager, cwd);
|
|
1128
|
+
const recordRemedy = () => unconfirmedRecordRemedy(stored, inspection, me, cwd) ?? RECHECK_REMEDY;
|
|
1129
|
+
const latched = runtime.gitGuardCacheUnknownReason;
|
|
1130
|
+
if (latched)
|
|
1131
|
+
return unknown(cwd, latched, {}, recordRemedy());
|
|
1132
|
+
const unanswered = runtime.gitGuardUnansweredDispatches.find((entry) => currentFileFingerprint(resolveGuardPath(entry.filePath, cwd)) !== "missing");
|
|
1133
|
+
if (unanswered) {
|
|
1134
|
+
const shown = shownLatchFile(unanswered.filePath, cwd);
|
|
1135
|
+
return unknown(cwd, unanswered.reason, { file: shown }, `dm-lens could not check ${shown}. Write it again so dm-lens re-checks it, then retry.`);
|
|
1136
|
+
}
|
|
1137
|
+
if (inspection === "missing") {
|
|
1138
|
+
logDecision(cwd, "allowed", "no_record");
|
|
1139
|
+
return { block: false };
|
|
1140
|
+
}
|
|
1141
|
+
if (claimsNoBlocker(stored?.fields)) {
|
|
1142
|
+
logDecision(cwd, "allowed", "advisory_only", { inspection });
|
|
1143
|
+
return { block: false };
|
|
1144
|
+
}
|
|
1145
|
+
if (inspection !== "fresh") {
|
|
1146
|
+
return unknown(cwd, `cache_${inspection}`, {}, recordRemedy());
|
|
1147
|
+
}
|
|
1148
|
+
const fields = stored?.fields;
|
|
1149
|
+
if (!isTurnEndFindingsCache(fields)) {
|
|
1150
|
+
return unknown(cwd, "cache_malformed", {}, recordRemedy());
|
|
1151
|
+
}
|
|
1152
|
+
const record = fields;
|
|
1153
|
+
if (!record.hasBlockers)
|
|
1154
|
+
return unknown(cwd, "cache_malformed");
|
|
1155
|
+
if (record.affectedFilesTruncated) {
|
|
1156
|
+
return unknown(cwd, "affected_files_truncated");
|
|
1157
|
+
}
|
|
1158
|
+
if (record.sessionId !== me || record.carriedBlockers !== undefined) {
|
|
1159
|
+
return unknown(cwd, "session_mismatch", {}, recordRemedy());
|
|
1160
|
+
}
|
|
1161
|
+
if (record.projectSeqEnd !== runtime.projectSeq) {
|
|
1162
|
+
return unknown(cwd, "project_sequence_mismatch", {
|
|
1163
|
+
recordedProjectSeq: record.projectSeqEnd,
|
|
1164
|
+
currentProjectSeq: runtime.projectSeq
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
const liveFiles = [];
|
|
1168
|
+
for (const file of record.affectedFiles) {
|
|
1169
|
+
const resolved = resolveGuardPath(file, cwd);
|
|
1170
|
+
const key = guardPathKey(resolved, cwd);
|
|
1171
|
+
const recordedSeq = record.fileSeqByPath[key];
|
|
1172
|
+
if (recordedSeq === undefined || recordedSeq !== (runtime.getFileSeq?.(resolved) ?? 0)) {
|
|
1173
|
+
return unknown(cwd, "file_sequence_mismatch", { file: resolved });
|
|
1174
|
+
}
|
|
1175
|
+
try {
|
|
1176
|
+
if (!isPathIgnoredByProject(resolved, runtime.projectRoot || cwd, false)) {
|
|
1177
|
+
const currentHash = currentFileFingerprint(resolved);
|
|
1178
|
+
if (currentHash !== "missing") {
|
|
1179
|
+
liveFiles.push(resolved);
|
|
1180
|
+
const expectedHash = record.fileContentHashes[key];
|
|
1181
|
+
if (!expectedHash || expectedHash.startsWith("unreadable:") || currentHash.startsWith("unreadable:") || expectedHash !== currentHash) {
|
|
1182
|
+
return unknown(cwd, "file_content_changed", { file: resolved });
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
} catch {
|
|
1187
|
+
return unknown(cwd, "file_unreadable", { file: resolved });
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
if (record.hasBlockers && record.affectedFiles.length === 0) {
|
|
1191
|
+
return unknown(cwd, "blocker_without_affected_file");
|
|
1192
|
+
}
|
|
1193
|
+
if (record.hasBlockers && liveFiles.length === 0 && record.affectedFiles.length > 0) {
|
|
1194
|
+
logDecision(cwd, "allowed", "affected_files_resolved", {
|
|
1195
|
+
projectSeq: record.projectSeqEnd
|
|
1196
|
+
});
|
|
1197
|
+
return { block: false };
|
|
1198
|
+
}
|
|
1199
|
+
logDecision(cwd, "blocked", "cache_blockers", {
|
|
1200
|
+
projectSeq: record.projectSeqEnd,
|
|
1201
|
+
affectedFileCount: record.affectedFiles.length
|
|
1202
|
+
});
|
|
1203
|
+
return {
|
|
1204
|
+
block: true,
|
|
1205
|
+
reason: `\uD83D\uDD34 COMMIT BLOCKED (--lens-guard): unresolved blockers must be fixed before commit/push.
|
|
1206
|
+
${inspectLine}`
|
|
1207
|
+
};
|
|
1208
|
+
}
|