pi-lens 3.8.73 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2614 -12
- package/README.md +50 -21
- package/dist/clients/actionable-warnings.js +73 -18
- package/dist/clients/agent-behavior-client.js +21 -4
- package/dist/clients/ast-grep-client.js +68 -16
- package/dist/clients/ast-grep-types.js +0 -1
- package/dist/clients/ast-grep-yaml-synth.js +37 -10
- package/dist/clients/atomic-write-staging.js +63 -0
- package/dist/clients/atomic-write.js +116 -16
- package/dist/clients/bash-file-access.js +193 -23
- package/dist/clients/biome-client.js +29 -25
- package/dist/clients/bootstrap.js +11 -2
- package/dist/clients/bounded-cache.js +34 -0
- package/dist/clients/bounded-pid-file-lock.js +192 -0
- package/dist/clients/bus-events-logger.js +5 -1
- package/dist/clients/bus-publish.js +10 -3
- package/dist/clients/cache/rule-cache.js +89 -6
- package/dist/clients/cache-manager.js +97 -9
- package/dist/clients/cache-observability.js +498 -0
- package/dist/clients/call-graph.js +460 -108
- package/dist/clients/cascade-logger.js +5 -1
- package/dist/clients/child-unref.js +85 -0
- package/dist/clients/codebase-model.js +52 -23
- package/dist/clients/collateral-test-role.js +40 -0
- package/dist/clients/complexity-client.js +6 -8
- package/dist/clients/console-guard-install.js +14 -0
- package/dist/clients/cooperative-budget.js +42 -0
- package/dist/clients/dead-code-client.js +2 -1
- package/dist/clients/debug-handles.js +206 -0
- package/dist/clients/debug-heap.js +167 -0
- package/dist/clients/degradation-ledger.js +153 -0
- package/dist/clients/dependency-checker.js +466 -63
- package/dist/clients/diagnostic-dispositions.js +83 -13
- package/dist/clients/diagnostics-publish.js +10 -3
- package/dist/clients/dispatch/auxiliary-lsp.js +34 -0
- package/dist/clients/dispatch/dispatcher.js +71 -13
- package/dist/clients/dispatch/fact-store.js +11 -0
- package/dist/clients/dispatch/facts/function-facts.js +37 -7
- package/dist/clients/dispatch/facts/import-facts.js +108 -119
- package/dist/clients/dispatch/facts/tree-sitter-facts.js +12 -12
- package/dist/clients/dispatch/facts/try-catch-facts.js +13 -0
- package/dist/clients/dispatch/indent-detect.js +35 -0
- package/dist/clients/dispatch/inline-suppressions.js +17 -8
- package/dist/clients/dispatch/integration.js +1094 -611
- package/dist/clients/dispatch/lazy.js +14 -0
- package/dist/clients/dispatch/plan.js +11 -1
- package/dist/clients/dispatch/rule-id-normalize.js +50 -0
- package/dist/clients/dispatch/rule-policy.js +135 -0
- package/dist/clients/dispatch/rules/async-noise.js +1 -0
- package/dist/clients/dispatch/rules/unsafe-boundary.js +7 -0
- package/dist/clients/dispatch/runners/ast-grep-napi.js +47 -6
- package/dist/clients/dispatch/runners/biome-check.js +5 -9
- package/dist/clients/dispatch/runners/detekt.js +3 -2
- package/dist/clients/dispatch/runners/hadolint.js +2 -1
- package/dist/clients/dispatch/runners/helm-lint.js +154 -0
- package/dist/clients/dispatch/runners/htmlhint.js +3 -2
- package/dist/clients/dispatch/runners/index.js +5 -1
- package/dist/clients/dispatch/runners/lsp.js +14 -6
- package/dist/clients/dispatch/runners/markdownlint.js +4 -9
- package/dist/clients/dispatch/runners/psscriptanalyzer.js +10 -1
- package/dist/clients/dispatch/runners/pyright.js +9 -5
- package/dist/clients/dispatch/runners/ruff.js +4 -8
- package/dist/clients/dispatch/runners/shellcheck.js +2 -3
- package/dist/clients/dispatch/runners/shfmt.js +2 -3
- package/dist/clients/dispatch/runners/spotbugs.js +2 -1
- package/dist/clients/dispatch/runners/taplo.js +2 -1
- package/dist/clients/dispatch/runners/terragrunt.js +163 -0
- package/dist/clients/dispatch/runners/tflint.js +37 -5
- package/dist/clients/dispatch/runners/tree-sitter.js +155 -166
- package/dist/clients/dispatch/runners/trivy-config.js +13 -7
- package/dist/clients/dispatch/runners/utils/lazy-installer.js +3 -0
- package/dist/clients/dispatch/runners/utils/runner-helpers.js +284 -34
- package/dist/clients/dispatch/runners/utils/spawn-outcome.js +22 -0
- package/dist/clients/dispatch/runners/yaml-rule-parser.js +5 -4
- package/dist/clients/disposition-publish.js +10 -3
- package/dist/clients/durable-store.js +97 -0
- package/dist/clients/event-loop-monitor.js +94 -3
- package/dist/clients/extension-log.js +139 -0
- package/dist/clients/extension-mode.js +73 -0
- package/dist/clients/feature-hints.js +53 -7
- package/dist/clients/file-kinds.js +143 -31
- package/dist/clients/file-role.js +18 -3
- package/dist/clients/file-utils.js +56 -34
- package/dist/clients/fix-worklog.js +14 -2
- package/dist/clients/format-events-publish.js +16 -3
- package/dist/clients/format-service.js +24 -8
- package/dist/clients/formatters-lazy.js +8 -0
- package/dist/clients/formatters.js +358 -61
- package/dist/clients/generated-artifacts.js +169 -15
- package/dist/clients/git-guard.js +681 -11
- package/dist/clients/git-tracked-ignore.js +4 -0
- package/dist/clients/go-client.js +2 -1
- package/dist/clients/govulncheck-client.js +8 -0
- package/dist/clients/grammar-source.js +12 -4
- package/dist/clients/gzip-stage-write.js +102 -0
- package/dist/clients/host-ports.js +31 -0
- package/dist/clients/installer/index.js +733 -213
- package/dist/clients/instance-reaper.js +142 -172
- package/dist/clients/jscpd-client.js +31 -54
- package/dist/clients/knip-client.js +78 -36
- package/dist/clients/language-policy.js +14 -2
- package/dist/clients/language-profile.js +72 -77
- package/dist/clients/latency-logger.js +28 -16
- package/dist/clients/lens-config.js +140 -166
- package/dist/clients/lens-engine.js +124 -21
- package/dist/clients/lens-events.js +27 -4
- package/dist/clients/lens-flag-registry.js +293 -0
- package/dist/clients/lens-map.js +96 -26
- package/dist/clients/live-bus-emitter.js +30 -0
- package/dist/clients/log-cleanup.js +8 -18
- package/dist/clients/lsp/cascade-tier.js +23 -3
- package/dist/clients/lsp/client.js +566 -57
- package/dist/clients/lsp/config.js +74 -10
- package/dist/clients/lsp/diagnostic-binding.js +86 -0
- package/dist/clients/lsp/edits.js +1012 -121
- package/dist/clients/lsp/index.js +1840 -803
- package/dist/clients/lsp/language.js +4 -1
- package/dist/clients/lsp/launch.js +40 -32
- package/dist/clients/lsp/path-utils.js +1 -1
- package/dist/clients/lsp/ruby-drive-dirs.js +83 -0
- package/dist/clients/lsp/server.js +279 -60
- package/dist/clients/lsp/workspace-diagnostics-cache.js +28 -4
- package/dist/clients/lsp-document-symbols.js +112 -0
- package/dist/clients/lsp-lazy.js +8 -0
- package/dist/clients/lsp-mutation.js +248 -0
- package/dist/clients/mcp/analyze.js +128 -36
- package/dist/clients/mcp/ipc.js +157 -24
- package/dist/clients/mcp/review.js +36 -3
- package/dist/clients/mcp/session.js +216 -8
- package/dist/clients/memory-sampler.js +115 -0
- package/dist/clients/metrics-client.js +2 -1
- package/dist/clients/metrics-history.js +2 -1
- package/dist/clients/module-report-lsp.js +5 -0
- package/dist/clients/module-report.js +267 -82
- package/dist/clients/ndjson-logger.js +334 -103
- package/dist/clients/opengrep-client.js +1 -1
- package/dist/clients/partial-edit-apply.js +120 -5
- package/dist/clients/path-keyed-map.js +76 -0
- package/dist/clients/path-utils.js +141 -5
- package/dist/clients/performance-report.js +327 -0
- package/dist/clients/pipeline.js +54 -13
- package/dist/clients/print-mode.js +21 -0
- package/dist/clients/project-changes.js +117 -4
- package/dist/clients/project-diagnostics/cache.js +3 -2
- package/dist/clients/project-diagnostics/extractors.js +26 -115
- package/dist/clients/project-diagnostics/fresh-fetch.js +149 -19
- package/dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js +117 -0
- package/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +37 -5
- package/dist/clients/project-diagnostics/scanner.js +268 -128
- package/dist/clients/project-lens-config.js +138 -34
- package/dist/clients/project-report.js +64 -25
- package/dist/clients/project-scale.js +8 -10
- package/dist/clients/project-snapshot-persist-worker.js +6 -0
- package/dist/clients/project-snapshot.js +767 -8
- package/dist/clients/project-trust.js +181 -0
- package/dist/clients/quiet-window.js +27 -5
- package/dist/clients/read-bridge.js +147 -0
- package/dist/clients/read-expansion.js +22 -12
- package/dist/clients/read-guard-logger.js +159 -1
- package/dist/clients/read-guard-tool-lines.js +150 -29
- package/dist/clients/read-guard.js +262 -3
- package/dist/clients/redact/secrets.js +449 -0
- package/dist/clients/resource-sampler.js +144 -39
- package/dist/clients/reverse-deps.js +48 -0
- package/dist/clients/review-graph/builder.js +2570 -326
- package/dist/clients/review-graph/git-identity.js +2 -1
- package/dist/clients/review-graph/import-resolvers.js +21 -10
- package/dist/clients/review-graph/persist-worker.js +10 -0
- package/dist/clients/review-graph/query.js +5 -0
- package/dist/clients/review-graph/shared-extraction-ir.js +90 -0
- package/dist/clients/review-graph/symbol-id.js +46 -0
- package/dist/clients/review-graph/tsconfig-paths.js +57 -6
- package/dist/clients/review-graph/workspace-modules.js +51 -3
- package/dist/clients/review-graph-logger.js +53 -0
- package/dist/clients/ruff-client.js +27 -44
- package/dist/clients/runtime-agent-end.js +111 -75
- package/dist/clients/runtime-context.js +36 -12
- package/dist/clients/runtime-coordinator.js +76 -8
- package/dist/clients/runtime-session.js +799 -137
- package/dist/clients/runtime-tool-call.js +117 -62
- package/dist/clients/runtime-tool-result.js +218 -23
- package/dist/clients/runtime-turn.js +284 -40
- package/dist/clients/rust-client.js +2 -1
- package/dist/clients/safe-spawn.js +873 -71
- package/dist/clients/security-scan-client.js +2 -1
- package/dist/clients/session-start-observability.js +15 -0
- package/dist/clients/session-state-store.js +5 -3
- package/dist/clients/sessionstart-logger.js +18 -0
- package/dist/clients/sg-runner.js +284 -159
- package/dist/clients/slow-fs.js +2 -1
- package/dist/clients/smells-rollup.js +224 -0
- package/dist/clients/source-filter.js +231 -43
- package/dist/clients/source-walker.js +66 -10
- package/dist/clients/startup-scan.js +15 -16
- package/dist/clients/startup-timing.js +9 -0
- package/dist/clients/test-runner-client.js +38 -8
- package/dist/clients/todo-scanner.js +30 -3
- package/dist/clients/tool-event.js +35 -0
- package/dist/clients/tool-policy.js +388 -39
- package/dist/clients/tool-render.js +155 -0
- package/dist/clients/tree-sitter-cache.js +153 -140
- package/dist/clients/tree-sitter-client.js +1722 -80
- package/dist/clients/tree-sitter-logger.js +64 -1
- package/dist/clients/tree-sitter-query-loader.js +117 -12
- package/dist/clients/tree-sitter-shared.js +48 -19
- package/dist/clients/tree-sitter-symbol-extractor.js +115 -11
- package/dist/clients/user-notify.js +51 -0
- package/dist/clients/vanished-instance-marker.js +57 -0
- package/dist/clients/warm-attach.js +33 -13
- package/dist/clients/widget-state.js +342 -49
- package/dist/clients/word-index-logger.js +44 -0
- package/dist/clients/word-index.js +612 -68
- package/dist/clients/workspace-topology.js +100 -7
- package/dist/index.js +65923 -47161
- package/dist/mcp/analyze-cli.js +185 -29
- package/dist/mcp/cli.js +110 -0
- package/dist/mcp/server.js +272 -50
- package/dist/tools/ast-grep-search.js +93 -27
- package/dist/tools/lens-diagnostics.js +247 -41
- package/dist/tools/lsp-diagnostics.js +153 -40
- package/dist/tools/lsp-navigation.js +51 -31
- package/dist/tools/module-report.js +9 -0
- package/dist/tools/symbol-search.js +21 -2
- package/docs/agent-guide.md +247 -0
- package/docs/agent-tools.md +21 -10
- package/docs/analysisall.md +192 -0
- package/docs/api-ports-inventory.md +165 -0
- package/docs/ast-grep_rules_catalog.md +5 -2
- package/docs/astplayground.md +3 -4
- package/docs/audit1.md +5 -5
- package/docs/durable-store-audit-1202.md +32 -0
- package/docs/environment-variables.md +197 -11
- package/docs/fable.md +27 -0
- package/docs/features.md +35 -5
- package/docs/globalconfig.md +101 -5
- package/docs/language-coverage.md +6 -5
- package/docs/lsp-capability-matrix.md +2 -2
- package/docs/mcp.md +54 -20
- package/docs/servercapabilities.md +7 -4
- package/docs/settings.md +192 -0
- package/docs/tools.md +18 -1
- package/docs/tree-sitter_rules_catalog.md +11 -31
- package/docs/usage.md +31 -0
- package/package.json +139 -138
- package/rules/ast-grep-rules/rule-tests/hardcoded-url-js-test.yml +1 -0
- package/rules/ast-grep-rules/rule-tests/hardcoded-url-test.yml +2 -0
- package/rules/ast-grep-rules/rule-tests/no-bare-except-test.yml +49 -0
- package/rules/ast-grep-rules/rule-tests/no-bare-host-path-in-win32-branch-test.yml +87 -0
- package/rules/ast-grep-rules/rule-tests/no-case-declarations-js-test.yml +10 -0
- package/rules/ast-grep-rules/rule-tests/no-case-declarations-test.yml +10 -0
- package/rules/ast-grep-rules/rule-tests/no-javascript-url-js-test.yml +10 -0
- package/rules/ast-grep-rules/rule-tests/no-javascript-url-test.yml +10 -0
- package/rules/ast-grep-rules/rule-tests/no-nested-links-test.yml +11 -1
- package/rules/ast-grep-rules/rule-tests/no-raw-json-store-write-test.yml +17 -0
- package/rules/ast-grep-rules/rule-tests/no-win32-isabsolute-for-qualification-test.yml +16 -0
- package/rules/ast-grep-rules/rule-tests/strict-equality-js-test.yml +3 -0
- package/rules/ast-grep-rules/rule-tests/strict-equality-test.yml +3 -0
- package/rules/ast-grep-rules/rule-tests/strict-inequality-js-test.yml +3 -0
- package/rules/ast-grep-rules/rule-tests/strict-inequality-test.yml +4 -0
- package/rules/ast-grep-rules/rules/hardcoded-url-js.yml +22 -4
- package/rules/ast-grep-rules/rules/hardcoded-url.yml +22 -4
- package/rules/ast-grep-rules/rules/no-bare-except.yml +3 -15
- package/rules/ast-grep-rules/rules/no-bare-host-path-in-win32-branch.yml +25 -0
- package/rules/ast-grep-rules/rules/no-case-declarations-js.yml +4 -3
- package/rules/ast-grep-rules/rules/no-case-declarations.yml +4 -3
- package/rules/ast-grep-rules/rules/no-console-except-error-js.yml +10 -0
- package/rules/ast-grep-rules/rules/no-console-except-error.yml +10 -0
- package/rules/ast-grep-rules/rules/no-javascript-url-js.yml +42 -6
- package/rules/ast-grep-rules/rules/no-javascript-url.yml +42 -6
- package/rules/ast-grep-rules/rules/no-nested-links.yml +7 -0
- package/rules/ast-grep-rules/rules/no-raw-json-store-write.yml +30 -0
- package/rules/ast-grep-rules/rules/no-win32-isabsolute-for-qualification.yml +23 -0
- package/rules/ast-grep-rules/rules/strict-equality-js.yml +14 -1
- package/rules/ast-grep-rules/rules/strict-equality.yml +14 -1
- package/rules/ast-grep-rules/rules/strict-inequality-js.yml +14 -1
- package/rules/ast-grep-rules/rules/strict-inequality.yml +14 -1
- package/rules/tree-sitter-queries/cpp/no-memset-sensitive-data.yml +9 -3
- package/rules/tree-sitter-queries/cpp/no-scoped-lock-without-args.yml +6 -6
- package/rules/tree-sitter-queries/css/calc-spacing.yml +8 -6
- package/rules/tree-sitter-queries/go/go-mutex-copy.yml +21 -18
- package/rules/tree-sitter-queries/go/go-shared-map-write-goroutine.yml +3 -3
- package/rules/tree-sitter-queries/java/infinite-loop-java.yml +3 -3
- package/rules/tree-sitter-queries/java/junit-call-super.yml +6 -4
- package/rules/tree-sitter-queries/java/no-double-checked-locking.yml +10 -8
- package/rules/tree-sitter-queries/java/no-field-shadowing.yml +1 -1
- package/rules/tree-sitter-queries/java/prepared-statement-valid-indices.yml +2 -3
- package/rules/tree-sitter-queries/java/resources-closed.yml +2 -2
- package/rules/tree-sitter-queries/java/springboot-default-package.yml +6 -3
- package/rules/tree-sitter-queries/java/switch-fall-through.yml +6 -4
- package/rules/tree-sitter-queries/java/switch-non-case-labels.yml +4 -3
- package/rules/tree-sitter-queries/java/tests-include-assertions.yml +6 -5
- package/rules/tree-sitter-queries/javascript/switch-case-termination-js.yml +5 -8
- package/rules/tree-sitter-queries/javascript/switch-non-case-labels.yml +3 -2
- package/rules/tree-sitter-queries/kotlin/prepared-statement-indices.yml +9 -5
- package/rules/tree-sitter-queries/php/this-in-static-context.yml +5 -5
- package/rules/tree-sitter-queries/python/exit-signature-check.yml +2 -9
- package/rules/tree-sitter-queries/python/in-operator-unsupported.yml +3 -4
- package/rules/tree-sitter-queries/python/no-super-torchscript.yml +4 -8
- package/rules/tree-sitter-queries/python/notimplemented-boolean-context.yml +1 -5
- package/rules/tree-sitter-queries/python/python-empty-except.yml +1 -1
- package/rules/tree-sitter-queries/python/return-in-init.yml +0 -2
- package/rules/tree-sitter-queries/python/yield-return-outside-function.yml +0 -3
- package/rules/tree-sitter-queries/ruby/ruby-command-injection.yml +1 -12
- package/rules/tree-sitter-queries/ruby/ruby-eval.yml +1 -1
- package/rules/tree-sitter-queries/ruby/ruby-insecure-deserialization.yml +4 -4
- package/rules/tree-sitter-queries/ruby/ruby-insecure-random.yml +4 -11
- package/rules/tree-sitter-queries/ruby/ruby-open-struct.yml +1 -1
- package/rules/tree-sitter-queries/ruby/ruby-string-eval.yml +2 -3
- package/rules/tree-sitter-queries/ruby/ruby-weak-hash.yml +4 -4
- package/rules/tree-sitter-queries/rust/rust-lock-held-across-await.yml +4 -3
- package/rules/tree-sitter-queries/tsx/no-nested-links.yml +4 -6
- package/rules/tree-sitter-queries/typescript/console-statement.yml +11 -0
- package/rules/tree-sitter-queries/typescript/duplicate-function-arg.yml +4 -9
- package/rules/tree-sitter-queries/typescript/empty-switch-case.yml +13 -9
- package/rules/tree-sitter-queries/typescript/infinite-loop.yml +2 -2
- package/rules/tree-sitter-queries/typescript/mixed-async-styles.yml +10 -1
- package/rules/tree-sitter-queries/typescript/switch-case-termination.yml +5 -8
- package/rules/tree-sitter-queries/typescript/ts-insecure-random.yml +7 -10
- package/rules/tree-sitter-queries/typescript/unsafe-regex.yml +4 -2
- package/rules/typos/_typos.toml +17 -0
- package/scripts/analyze-pi-lens-logs.mjs +55 -2
- package/skills/pi-lens-write-tree-sitter-rule/SKILL.md +5 -0
- package/dist/clients/ast-grep-parser.js +0 -86
- package/dist/clients/config-enabled-shape.js +0 -39
- package/dist/clients/lsp/interactive-install.js +0 -367
- package/dist/clients/lsp/lsp-index.js +0 -10
- package/dist/clients/lsp/server-strategies.js +0 -5
- package/dist/clients/project-metadata.js +0 -690
- package/dist/clients/source-groups.js +0 -96
- package/dist/clients/types.js +0 -11
- package/docs/env_variables.md +0 -10
- package/rules/tree-sitter-queries/abap-disabled/delete-where.yml +0 -46
- package/rules/tree-sitter-queries/cpp/no-confused-move-forward.yml +0 -59
- package/rules/tree-sitter-queries/cpp/noexcept-functions.yml +0 -58
- package/rules/tree-sitter-queries/java/mockito-initialized.yml +0 -66
- package/rules/tree-sitter-queries/java/no-wait-notify-on-thread.yml +0 -58
- package/rules/tree-sitter-queries/java/short-circuit-logic.yml +0 -57
- package/rules/tree-sitter-queries/java/spring-session-attributes-setcomplete.yml +0 -75
- package/rules/tree-sitter-queries/plsql-disabled/delete-update-where.yml +0 -56
- package/rules/tree-sitter-queries/plsql-disabled/end-loop-semicolon.yml +0 -51
- package/rules/tree-sitter-queries/plsql-disabled/fetch-bulk-collect-limit.yml +0 -47
- package/rules/tree-sitter-queries/plsql-disabled/forallsave-exceptions.yml +0 -51
- package/rules/tree-sitter-queries/plsql-disabled/nchar-nvarchar2-bytes.yml +0 -54
- package/rules/tree-sitter-queries/plsql-disabled/not-null-initialization.yml +0 -59
- package/rules/tree-sitter-queries/plsql-disabled/raise-application-error-codes.yml +0 -50
- package/rules/tree-sitter-queries/typescript-disabled/ts-path-traversal.yml +0 -71
|
@@ -4,13 +4,16 @@ import { createDispatchContext } from "../dispatch/dispatcher.js";
|
|
|
4
4
|
import { evaluateRules } from "../dispatch/fact-rule-runner.js";
|
|
5
5
|
import { runProviders } from "../dispatch/fact-runner.js";
|
|
6
6
|
import { FactStore } from "../dispatch/fact-store.js";
|
|
7
|
-
import { canHandle as astGrepCanHandle,
|
|
7
|
+
import { canHandle as astGrepCanHandle, getLang as astGrepGetLang, evaluateAstGrepRules, loadSg, } from "../dispatch/runners/ast-grep-napi.js";
|
|
8
8
|
import { isTestFile } from "../file-utils.js";
|
|
9
9
|
import { isAtOrAboveHomeDir } from "../path-utils.js";
|
|
10
10
|
import { getProjectDiagnosticsScannerMaxFiles } from "../project-scale.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { captureReviewGraphStructuralIr } from "../review-graph/builder.js";
|
|
12
|
+
import { publishReviewGraphFileIr, reviewGraphIrContentHash, } from "../review-graph/shared-extraction-ir.js";
|
|
13
|
+
import { collectSourceFilesWithBudgetAsync, } from "../source-filter.js";
|
|
14
|
+
import { logTreeSitter, logTreeSitterCacheStats, } from "../tree-sitter-logger.js";
|
|
15
|
+
import { queriesForLanguage, queryLoader, } from "../tree-sitter-query-loader.js";
|
|
16
|
+
import { EXT_TO_LANG, getSharedTreeSitterClient, isTreeSitterWasmAborted, } from "../tree-sitter-shared.js";
|
|
14
17
|
import { PROJECT_DIAGNOSTICS_CACHE_VERSION, saveProjectDiagnosticsSnapshot, } from "./cache.js";
|
|
15
18
|
// Side-effect import: registers fact providers and fact rules.
|
|
16
19
|
import "../dispatch/integration.js";
|
|
@@ -29,19 +32,26 @@ const FACT_RULE_EXTENSIONS = new Set([
|
|
|
29
32
|
".mjs",
|
|
30
33
|
".cjs",
|
|
31
34
|
]);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
// Which languages the scan runs tree-sitter rules for: every language that has
|
|
36
|
+
// (a loadable grammar) AND (a non-disabled rules/tree-sitter-queries/<lang>/ dir).
|
|
37
|
+
//
|
|
38
|
+
// The base is the shared per-edit resolver (EXT_TO_LANG — the single
|
|
39
|
+
// ext→grammar-id authority), so c/cpp/csharp/php/css and the .tsx→tsx /
|
|
40
|
+
// .jsx→javascript nuances can never drift from the per-edit path. `.tsx` resolves
|
|
41
|
+
// to the tsx grammar (not typescript: the typescript grammar ERRORs on JSX);
|
|
42
|
+
// typescript RULES still apply because `queriesForLanguage(...)` below merges the
|
|
43
|
+
// typescript rule set onto tsx.
|
|
44
|
+
//
|
|
45
|
+
// java + kotlin are layered on here: they have loadable grammars and rule dirs
|
|
46
|
+
// (java: 24 rules, kotlin: 1) but no per-edit runner `appliesTo` entry, so only
|
|
47
|
+
// this broad project scan runs them. scanner.test.ts asserts this map covers
|
|
48
|
+
// every non-disabled rule dir whose grammar is loadable, so adding a language dir
|
|
49
|
+
// fails a test until its extension is registered here (or in EXT_TO_LANG).
|
|
50
|
+
export const TREE_SITTER_EXT_TO_LANG = {
|
|
51
|
+
...EXT_TO_LANG,
|
|
52
|
+
".java": "java",
|
|
53
|
+
".kt": "kotlin",
|
|
54
|
+
".kts": "kotlin",
|
|
45
55
|
};
|
|
46
56
|
function normalizeSeverity(severity) {
|
|
47
57
|
if (severity === "error" || severity === "warning" || severity === "hint") {
|
|
@@ -71,113 +81,78 @@ function fromDispatchDiagnostic(diagnostic, runner) {
|
|
|
71
81
|
source: "project-scan",
|
|
72
82
|
};
|
|
73
83
|
}
|
|
74
|
-
|
|
84
|
+
/**
|
|
85
|
+
* One FILE-major pass for every in-process syntax consumer (#675/#896).
|
|
86
|
+
* Per-consumer gates preserve their distinct language and size eligibility,
|
|
87
|
+
* while separate result lists preserve the historical phase-major diagnostic
|
|
88
|
+
* ordering.
|
|
89
|
+
*/
|
|
90
|
+
async function scanFileMajorRules(cwd, files, signal) {
|
|
91
|
+
const client = getSharedTreeSitterClient();
|
|
92
|
+
const treeSitterReady = !!client && client.isAvailable() && (await client.init());
|
|
93
|
+
// Same singleton the dispatch runner uses (tree-sitter.ts:444) — memoized
|
|
94
|
+
// per root, so repeated scans stop re-reading the ~180 query YAMLs.
|
|
95
|
+
const queryMap = treeSitterReady
|
|
96
|
+
? await queryLoader.loadQueries(cwd)
|
|
97
|
+
: undefined;
|
|
75
98
|
const facts = new FactStore();
|
|
76
99
|
const pi = { getFlag: () => undefined };
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
const treeSitter = [];
|
|
101
|
+
const factRules = [];
|
|
102
|
+
const astGrep = [];
|
|
103
|
+
const sgModule = await loadSg();
|
|
104
|
+
let phaseOneFilesScanned = 0;
|
|
105
|
+
let astGrepFilesScanned = 0;
|
|
106
|
+
let astGrepDurationMs = 0;
|
|
107
|
+
// #891: only fully completed files count — a wasm abort mid-file leaves that
|
|
108
|
+
// file out, so the caller can report a truncated filesScanned honestly.
|
|
109
|
+
let filesScanned = 0;
|
|
110
|
+
let wasmAborted = isTreeSitterWasmAborted();
|
|
111
|
+
const scanTreeSitterFile = async (filePath, langId, content) => {
|
|
112
|
+
if (!queryMap || !langId || !client || content === null)
|
|
113
|
+
return;
|
|
114
|
+
const queries = queriesForLanguage(queryMap, langId);
|
|
115
|
+
try {
|
|
116
|
+
const found = await client.runQueriesOnFile(queries, filePath, langId, { maxResults: 50 }, content);
|
|
117
|
+
for (const { queryDef: query, match } of found) {
|
|
118
|
+
treeSitter.push({
|
|
119
|
+
filePath,
|
|
120
|
+
line: match.line ?? 1,
|
|
121
|
+
column: match.column,
|
|
122
|
+
severity: query.severity === "error" ? "error" : query.severity,
|
|
123
|
+
semantic: query.inline_tier === "blocking" || query.severity === "error"
|
|
124
|
+
? "blocking"
|
|
125
|
+
: "warning",
|
|
126
|
+
tool: "tree-sitter",
|
|
127
|
+
runner: "tree-sitter",
|
|
128
|
+
rule: query.id,
|
|
129
|
+
message: query.message,
|
|
130
|
+
source: "project-scan",
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// Continue scanning other rules/files.
|
|
82
136
|
}
|
|
137
|
+
};
|
|
138
|
+
const scanFactRulesFile = async (filePath, content) => {
|
|
83
139
|
facts.clearFileFactsFor(filePath);
|
|
140
|
+
// Seed the exact bytes already supplied to tree-sitter so the file-content
|
|
141
|
+
// provider is skipped by runProviders.
|
|
142
|
+
facts.setFileFact(filePath, "file.content", content);
|
|
84
143
|
const ctx = createDispatchContext(filePath, cwd, pi, facts, false);
|
|
85
144
|
try {
|
|
86
145
|
await runProviders(ctx);
|
|
87
146
|
for (const diagnostic of evaluateRules(ctx)) {
|
|
88
|
-
|
|
147
|
+
factRules.push(fromDispatchDiagnostic(diagnostic, "fact-rules"));
|
|
89
148
|
}
|
|
90
149
|
}
|
|
91
150
|
catch {
|
|
92
151
|
// Project scans are best-effort; one unparsable file should not abort the tool.
|
|
93
152
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
async function scanTreeSitter(cwd, files) {
|
|
98
|
-
const client = getSharedTreeSitterClient();
|
|
99
|
-
if (!client || !client.isAvailable())
|
|
100
|
-
return [];
|
|
101
|
-
if (!(await client.init()))
|
|
102
|
-
return [];
|
|
103
|
-
const loader = new TreeSitterQueryLoader();
|
|
104
|
-
const queryMap = await loader.loadQueries(cwd);
|
|
105
|
-
const diagnostics = [];
|
|
106
|
-
for (const filePath of files) {
|
|
107
|
-
if (isTestFile(filePath))
|
|
108
|
-
continue;
|
|
109
|
-
const langId = TREE_SITTER_EXT_TO_LANG[path.extname(filePath)];
|
|
110
|
-
if (!langId)
|
|
111
|
-
continue;
|
|
112
|
-
const queries = [
|
|
113
|
-
...(queryMap.get(langId) ?? []),
|
|
114
|
-
...(langId === "javascript" ? (queryMap.get("typescript") ?? []) : []),
|
|
115
|
-
];
|
|
116
|
-
for (const query of queries) {
|
|
117
|
-
try {
|
|
118
|
-
const matches = await client.runQueryOnFile(query, filePath, langId, {
|
|
119
|
-
maxResults: 50,
|
|
120
|
-
});
|
|
121
|
-
for (const match of matches ?? []) {
|
|
122
|
-
diagnostics.push({
|
|
123
|
-
filePath,
|
|
124
|
-
line: match.line ?? 1,
|
|
125
|
-
column: match.column,
|
|
126
|
-
severity: query.severity === "error" ? "error" : query.severity,
|
|
127
|
-
semantic: query.inline_tier === "blocking" || query.severity === "error"
|
|
128
|
-
? "blocking"
|
|
129
|
-
: "warning",
|
|
130
|
-
tool: "tree-sitter",
|
|
131
|
-
runner: "tree-sitter",
|
|
132
|
-
rule: query.id,
|
|
133
|
-
message: query.message,
|
|
134
|
-
source: "project-scan",
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
// Continue scanning other rules/files.
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return diagnostics;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Project-wide ast-grep pass via the bundled napi engine — no `ast-grep` binary
|
|
147
|
-
* required (#308). In `lens_diagnostics mode=full` the ast-grep LSP already
|
|
148
|
-
* covers the project WHEN its binary is present; this closes the no-binary gap
|
|
149
|
-
* using the same Rust core + shipped ruleset. Findings dedup against the LSP's
|
|
150
|
-
* (`filePath:line:rule`) in the full-mode merge, so running both never
|
|
151
|
-
* double-reports. Iterates the SAME `files` list as the other scanners, so it
|
|
152
|
-
* inherits identical exclusion/ignore/cap behavior automatically.
|
|
153
|
-
*/
|
|
154
|
-
async function scanAstGrepNapi(cwd, files) {
|
|
155
|
-
const sgModule = await loadSg();
|
|
156
|
-
if (!sgModule)
|
|
157
|
-
return [];
|
|
158
|
-
const diagnostics = [];
|
|
159
|
-
for (const filePath of files) {
|
|
160
|
-
if (isTestFile(filePath) || !astGrepCanHandle(filePath))
|
|
161
|
-
continue;
|
|
162
|
-
let stats;
|
|
163
|
-
try {
|
|
164
|
-
stats = fs.statSync(filePath);
|
|
165
|
-
}
|
|
166
|
-
catch {
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
if (stats.size > AST_GREP_MAX_FILE_BYTES)
|
|
170
|
-
continue;
|
|
171
|
-
const lang = astGrepGetLang(filePath, sgModule);
|
|
172
|
-
if (!lang)
|
|
173
|
-
continue;
|
|
174
|
-
let content;
|
|
175
|
-
try {
|
|
176
|
-
content = fs.readFileSync(filePath, "utf-8");
|
|
177
|
-
}
|
|
178
|
-
catch {
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
153
|
+
};
|
|
154
|
+
const scanAstGrepFile = (filePath, content, lang) => {
|
|
155
|
+
const startedAt = Date.now();
|
|
181
156
|
try {
|
|
182
157
|
const rootNode = lang.parse(content).root();
|
|
183
158
|
const fileDiagnostics = evaluateAstGrepRules(filePath, rootNode, cwd, "jsts", {
|
|
@@ -185,14 +160,141 @@ async function scanAstGrepNapi(cwd, files) {
|
|
|
185
160
|
maxTotalDiagnostics: AST_GREP_SCAN_MAX_DIAGNOSTICS_PER_FILE,
|
|
186
161
|
});
|
|
187
162
|
for (const diagnostic of fileDiagnostics) {
|
|
188
|
-
|
|
163
|
+
astGrep.push(fromDispatchDiagnostic(diagnostic, "ast-grep-napi"));
|
|
189
164
|
}
|
|
190
165
|
}
|
|
191
166
|
catch {
|
|
192
167
|
// Project scans are best-effort; one unparsable file must not abort the tool.
|
|
193
168
|
}
|
|
169
|
+
finally {
|
|
170
|
+
astGrepFilesScanned++;
|
|
171
|
+
astGrepDurationMs += Date.now() - startedAt;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const scan = async () => {
|
|
175
|
+
for (const filePath of files) {
|
|
176
|
+
// #891: a wasm-level abort poisons the shared parser for the rest of the
|
|
177
|
+
// process — stop the whole pass, don't keep feeding it files.
|
|
178
|
+
if (signal?.aborted || isTreeSitterWasmAborted()) {
|
|
179
|
+
wasmAborted ||= isTreeSitterWasmAborted();
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if (isTestFile(filePath))
|
|
183
|
+
continue;
|
|
184
|
+
const ext = path.extname(filePath);
|
|
185
|
+
const langId = TREE_SITTER_EXT_TO_LANG[ext];
|
|
186
|
+
const factEligible = FACT_RULE_EXTENSIONS.has(ext);
|
|
187
|
+
let astGrepLang;
|
|
188
|
+
if (sgModule && astGrepCanHandle(filePath)) {
|
|
189
|
+
try {
|
|
190
|
+
if (fs.statSync(filePath).size <= AST_GREP_MAX_FILE_BYTES) {
|
|
191
|
+
astGrepLang = astGrepGetLang(filePath, sgModule);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
// A missing file is ineligible for every content consumer below.
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (!langId && !factEligible && !astGrepLang)
|
|
199
|
+
continue;
|
|
200
|
+
if (langId || factEligible)
|
|
201
|
+
phaseOneFilesScanned++;
|
|
202
|
+
let content;
|
|
203
|
+
try {
|
|
204
|
+
content = fs.readFileSync(filePath, "utf-8");
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
content = null;
|
|
208
|
+
}
|
|
209
|
+
try {
|
|
210
|
+
await scanTreeSitterFile(filePath, langId, content);
|
|
211
|
+
if (isTreeSitterWasmAborted()) {
|
|
212
|
+
wasmAborted = true;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
if (factEligible) {
|
|
216
|
+
await scanFactRulesFile(filePath, content);
|
|
217
|
+
if (isTreeSitterWasmAborted()) {
|
|
218
|
+
wasmAborted = true;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
let graphIr;
|
|
223
|
+
if (content !== null) {
|
|
224
|
+
try {
|
|
225
|
+
graphIr = await captureReviewGraphStructuralIr(filePath, cwd, content, facts);
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
graphIr = { complete: false };
|
|
229
|
+
}
|
|
230
|
+
if (isTreeSitterWasmAborted()) {
|
|
231
|
+
wasmAborted = true;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (signal?.aborted) {
|
|
236
|
+
// The former phase-major scan never started ast-grep after a
|
|
237
|
+
// phase-one abort. Discard earlier ast-grep work from this merged
|
|
238
|
+
// pass to preserve that partial-result contract.
|
|
239
|
+
astGrep.length = 0;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
if (astGrepLang && content !== null) {
|
|
243
|
+
scanAstGrepFile(filePath, content, astGrepLang);
|
|
244
|
+
}
|
|
245
|
+
if (signal?.aborted)
|
|
246
|
+
break;
|
|
247
|
+
if (content !== null && graphIr?.complete && graphIr.structural) {
|
|
248
|
+
// Publish only consumable entries (the registry also enforces
|
|
249
|
+
// this) — and hash via the shared contract so producer and
|
|
250
|
+
// consumer can never diverge (#955 review).
|
|
251
|
+
publishReviewGraphFileIr(cwd, {
|
|
252
|
+
filePath,
|
|
253
|
+
contentHash: reviewGraphIrContentHash(content),
|
|
254
|
+
...graphIr,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
filesScanned++;
|
|
258
|
+
}
|
|
259
|
+
finally {
|
|
260
|
+
// This store belongs to the scan, and every consumer of this file's
|
|
261
|
+
// content and derived facts has completed by the end of the iteration.
|
|
262
|
+
facts.clearFileFactsFor(filePath);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (wasmAborted) {
|
|
266
|
+
// Mirror the phase-major #891 contract: the ast-grep phase never ran
|
|
267
|
+
// after a wasm abort, so this merged pass discards its buffer too.
|
|
268
|
+
astGrep.length = 0;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
if (!client) {
|
|
272
|
+
await scan();
|
|
273
|
+
return { treeSitter, factRules, astGrep, filesScanned, wasmAborted };
|
|
194
274
|
}
|
|
195
|
-
|
|
275
|
+
const startedAt = Date.now();
|
|
276
|
+
await client.withParseCacheMeasurement(scan, (stats) => {
|
|
277
|
+
logTreeSitterCacheStats({
|
|
278
|
+
scope: "project_diagnostics_scan",
|
|
279
|
+
filePath: cwd,
|
|
280
|
+
fileCount: phaseOneFilesScanned,
|
|
281
|
+
// The merged pass interleaves ast-grep with the phase-one consumers;
|
|
282
|
+
// subtract its share so this metric stays comparable to the historical
|
|
283
|
+
// phase-major scans.
|
|
284
|
+
durationMs: Date.now() - startedAt - astGrepDurationMs,
|
|
285
|
+
stats,
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
await client.withParseCacheMeasurement(async () => { }, (stats) => {
|
|
289
|
+
logTreeSitterCacheStats({
|
|
290
|
+
scope: "project_diagnostics_ast_grep_scan",
|
|
291
|
+
filePath: cwd,
|
|
292
|
+
fileCount: astGrepFilesScanned,
|
|
293
|
+
durationMs: astGrepDurationMs,
|
|
294
|
+
stats,
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
return { treeSitter, factRules, astGrep, filesScanned, wasmAborted };
|
|
196
298
|
}
|
|
197
299
|
export async function scanProjectDiagnostics(options) {
|
|
198
300
|
const cwd = path.resolve(options.cwd);
|
|
@@ -220,29 +322,39 @@ export async function scanProjectDiagnostics(options) {
|
|
|
220
322
|
// trips `maxFiles`. Unlike `unsafeRoot` this is not a refusal: when the
|
|
221
323
|
// budget trips we scan the truncated best-effort list and flag the snapshot
|
|
222
324
|
// so callers don't read the partial result as a complete sweep.
|
|
325
|
+
// #1107 phase 2: typed as the full `SourceCollectionResult` (not just its
|
|
326
|
+
// `{files, entryBudgetExceeded}` shape) so the generated-skip counters
|
|
327
|
+
// below are readable through the ternary — the `options.files` branch
|
|
328
|
+
// legitimately never walked, so it leaves them `undefined`, same
|
|
329
|
+
// convention as `entryBudgetExceeded: false` above it.
|
|
223
330
|
const collected = options.files
|
|
224
331
|
? { files: options.files.slice(0, maxFiles), entryBudgetExceeded: false }
|
|
225
332
|
: await collectSourceFilesWithBudgetAsync(cwd, {
|
|
226
333
|
maxFiles,
|
|
227
334
|
maxScanEntries: options.maxScanEntries,
|
|
335
|
+
// #1107 phase 2 review: the actionable opt-out generatedSkipNotice
|
|
336
|
+
// points a user at.
|
|
337
|
+
includeGenerated: options.includeGenerated === true,
|
|
228
338
|
});
|
|
229
339
|
const files = collected.files;
|
|
230
|
-
// Check cancellation
|
|
231
|
-
// promptly when the agent/user aborts (#341).
|
|
232
|
-
// already file-capped, so phase granularity is enough to bound the work.
|
|
340
|
+
// Check cancellation before and during the file-major pass so a full-mode
|
|
341
|
+
// scan stops promptly when the agent/user aborts (#341).
|
|
233
342
|
const runners = [];
|
|
234
343
|
const diagnostics = [];
|
|
344
|
+
let wasmAborted = false;
|
|
345
|
+
let filesScanned = files.length;
|
|
235
346
|
if (!signal?.aborted) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
347
|
+
// All in-process syntax consumers share one file-major pass (#675/#896).
|
|
348
|
+
const scanned = await scanFileMajorRules(cwd, files, signal);
|
|
349
|
+
diagnostics.push(...scanned.treeSitter, ...scanned.factRules);
|
|
350
|
+
runners.push("tree-sitter", "fact-rules");
|
|
351
|
+
wasmAborted = scanned.wasmAborted;
|
|
352
|
+
if (wasmAborted)
|
|
353
|
+
filesScanned = scanned.filesScanned;
|
|
354
|
+
if (!signal?.aborted && !wasmAborted) {
|
|
355
|
+
diagnostics.push(...scanned.astGrep);
|
|
356
|
+
runners.push("ast-grep-napi");
|
|
357
|
+
}
|
|
246
358
|
}
|
|
247
359
|
const snapshot = {
|
|
248
360
|
version: PROJECT_DIAGNOSTICS_CACHE_VERSION,
|
|
@@ -250,20 +362,48 @@ export async function scanProjectDiagnostics(options) {
|
|
|
250
362
|
tier: options.tier,
|
|
251
363
|
scannedAt: new Date().toISOString(),
|
|
252
364
|
diagnostics,
|
|
253
|
-
filesScanned
|
|
365
|
+
filesScanned,
|
|
254
366
|
runners,
|
|
255
367
|
};
|
|
256
368
|
// #760: only present when true — keeps existing snapshots/serializations
|
|
257
369
|
// byte-identical for the untruncated (normal) case.
|
|
258
370
|
if (collected.entryBudgetExceeded)
|
|
259
371
|
snapshot.scanTruncated = true;
|
|
372
|
+
// #1107 phase 2: only present when nonzero, same convention as the
|
|
373
|
+
// truncation flag above — a healthy scan with no generated-name skips
|
|
374
|
+
// produces a byte-identical snapshot to before this change.
|
|
375
|
+
if (collected.generatedOrArtifactSkips) {
|
|
376
|
+
snapshot.generatedFileSkips = collected.generatedOrArtifactSkips;
|
|
377
|
+
}
|
|
378
|
+
if (collected.generatedNameOnlySkips) {
|
|
379
|
+
snapshot.generatedNameOnlySkips = collected.generatedNameOnlySkips;
|
|
380
|
+
}
|
|
381
|
+
if (collected.generatedDirSkips) {
|
|
382
|
+
snapshot.generatedDirSkips = collected.generatedDirSkips;
|
|
383
|
+
}
|
|
384
|
+
if (wasmAborted) {
|
|
385
|
+
snapshot.scanTruncated = true;
|
|
386
|
+
snapshot.treeSitterStatus = "wasm_aborted_restart_required";
|
|
387
|
+
logTreeSitter({
|
|
388
|
+
phase: "runner_skip",
|
|
389
|
+
filePath: cwd,
|
|
390
|
+
status: "aborted",
|
|
391
|
+
reason: "wasm_aborted_mid_scan",
|
|
392
|
+
metadata: {
|
|
393
|
+
scope: "project_diagnostics_scan",
|
|
394
|
+
filesScanned,
|
|
395
|
+
totalFiles: files.length,
|
|
396
|
+
abortPoint: filesScanned + 1,
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
}
|
|
260
400
|
// A cancelled scan yields a partial snapshot; don't persist it as the
|
|
261
401
|
// authoritative cross-session cache — only a complete run is cacheable.
|
|
262
402
|
// Likewise, an explicit `files` scan (#461) only covers a caller-chosen
|
|
263
403
|
// subset (e.g. git-staged files), not the whole project — persisting it
|
|
264
404
|
// would poison the cross-session cache with a partial view that a later
|
|
265
405
|
// unscoped `refreshRunners=cached` read would wrongly trust as complete.
|
|
266
|
-
if (signal?.aborted || options.files)
|
|
406
|
+
if (signal?.aborted || options.files || wasmAborted)
|
|
267
407
|
return snapshot;
|
|
268
408
|
saveProjectDiagnosticsSnapshot(cwd, snapshot);
|
|
269
409
|
return snapshot;
|