pi-lens 4.3.0 → 4.4.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 +1064 -0
- package/README.md +115 -25
- package/config/dependency-cruiser-eager-allowlist.json +6 -2
- package/dist/chunk-22AVIGXS.js +560 -0
- package/dist/chunk-27BBHSZC.js +106 -0
- package/dist/chunk-2BEMIWEW.js +51 -0
- package/dist/chunk-2EECBNC5.js +89 -0
- package/dist/chunk-34U7PLGE.js +23 -0
- package/dist/chunk-3I5QFT3N.js +181 -0
- package/dist/chunk-3MED75HT.js +37 -0
- package/dist/chunk-47D2BO4S.js +87 -0
- package/dist/chunk-4RERDEXR.js +348 -0
- package/dist/chunk-4W2PLC4J.js +27 -0
- package/dist/chunk-52H5B5TC.js +202 -0
- package/dist/chunk-54B42YRX.js +27 -0
- package/dist/chunk-5RXBNSW2.js +266 -0
- package/dist/chunk-5THXD6X5.js +201 -0
- package/dist/chunk-5W3R6LFT.js +24 -0
- package/dist/chunk-5ZEJHV35.js +341 -0
- package/dist/chunk-6P62QVEA.js +118 -0
- package/dist/chunk-6QIUX4EP.js +459 -0
- package/dist/chunk-6VCD4VKZ.js +78 -0
- package/dist/chunk-7F72PXY2.js +326 -0
- package/dist/chunk-7FBF7NPR.js +998 -0
- package/dist/chunk-7U2IDNXN.js +37 -0
- package/dist/chunk-ABBOA7UD.js +157 -0
- package/dist/chunk-AHDW3GPE.js +50 -0
- package/dist/chunk-AJ3QXTRQ.js +756 -0
- package/dist/chunk-AJVLWNFN.js +1610 -0
- package/dist/chunk-AJXODZY6.js +112 -0
- package/dist/chunk-ARFCXG7S.js +84 -0
- package/dist/chunk-AS44CFQ4.js +708 -0
- package/dist/chunk-AWE5TMPO.js +38 -0
- package/dist/chunk-B3I2UUT4.js +4692 -0
- package/dist/chunk-BRJKOBZP.js +331 -0
- package/dist/chunk-BW5KFIQC.js +59 -0
- package/dist/chunk-C2AUYXQH.js +149 -0
- package/dist/chunk-CGGAIP7J.js +29 -0
- package/dist/chunk-D6QS3U6M.js +30 -0
- package/dist/chunk-DFVMIKMQ.js +349 -0
- package/dist/chunk-DIULIWKU.js +169 -0
- package/dist/chunk-DQ2NZ7C4.js +2317 -0
- package/dist/chunk-E2WFBRHM.js +213 -0
- package/dist/chunk-E4MAEDPM.js +50 -0
- package/dist/chunk-EOKRQ3SA.js +30 -0
- package/dist/chunk-F3AU2TMM.js +2626 -0
- package/dist/chunk-F3P7VQ7H.js +170 -0
- package/dist/chunk-FC4RP4I2.js +12 -0
- package/dist/chunk-FJNKANOS.js +32 -0
- package/dist/chunk-GUOGVTCQ.js +146 -0
- package/dist/chunk-GVXA6CCE.js +18 -0
- package/dist/chunk-HHYAELLJ.js +2334 -0
- package/dist/chunk-HMFXILPV.js +83 -0
- package/dist/chunk-HVUZXSWK.js +421 -0
- package/dist/chunk-HWBZIGMJ.js +62 -0
- package/dist/chunk-I3R7GKDR.js +17 -0
- package/dist/chunk-I7SPGOWI.js +55 -0
- package/dist/chunk-IIXOAGHR.js +38 -0
- package/dist/chunk-IVP5KAB7.js +2250 -0
- package/dist/chunk-IXEBJSUE.js +22 -0
- package/dist/chunk-JOLITGCC.js +27 -0
- package/dist/chunk-K6VYLB2U.js +145 -0
- package/dist/chunk-LJDODBBZ.js +78 -0
- package/dist/chunk-LNAKEO63.js +78 -0
- package/dist/chunk-LSMJ6KBE.js +4139 -0
- package/dist/chunk-LW6XKDZQ.js +5565 -0
- package/dist/chunk-N3YQJI6O.js +899 -0
- package/dist/chunk-NABLC7W3.js +148 -0
- package/dist/chunk-NKOUFPQF.js +659 -0
- package/dist/chunk-NL5GLMFI.js +211 -0
- package/dist/chunk-NMABWBZN.js +327 -0
- package/dist/chunk-NTHH2J74.js +27 -0
- package/dist/chunk-NTUJEGDZ.js +59 -0
- package/dist/chunk-NXL4FFQQ.js +47 -0
- package/dist/chunk-NXPS2L6U.js +466 -0
- package/dist/chunk-O5WILGMI.js +42 -0
- package/dist/chunk-O6TQT6RI.js +48 -0
- package/dist/chunk-OAXNDZJ7.js +323 -0
- package/dist/chunk-ODEEOXPH.js +44 -0
- package/dist/chunk-OQGFCZJ4.js +4533 -0
- package/dist/chunk-ORTMY4Q4.js +282 -0
- package/dist/chunk-OS32RNR2.js +442 -0
- package/dist/chunk-PAK6IDME.js +189 -0
- package/dist/chunk-PWFHBTSF.js +406 -0
- package/dist/chunk-Q5U6FMDI.js +2352 -0
- package/dist/chunk-QOZXJ4NA.js +3364 -0
- package/dist/chunk-QYF5S6P6.js +45 -0
- package/dist/chunk-RIISMHKN.js +36 -0
- package/dist/chunk-RPD4ZSB7.js +25 -0
- package/dist/chunk-RPD5K5NC.js +79 -0
- package/dist/chunk-RUOG5D2C.js +262 -0
- package/dist/chunk-T4ERT73Y.js +599 -0
- package/dist/chunk-T6D4Q4AQ.js +54 -0
- package/dist/chunk-TGPXLY2J.js +391 -0
- package/dist/chunk-TLGFBM3F.js +12116 -0
- package/dist/chunk-TO6WL3GM.js +88 -0
- package/dist/chunk-TT22N74J.js +517 -0
- package/dist/chunk-TVN5N6GY.js +21216 -0
- package/dist/chunk-U3VGR4VU.js +308 -0
- package/dist/chunk-UK3CMEAL.js +1250 -0
- package/dist/chunk-UOPVJQ4N.js +103 -0
- package/dist/chunk-UXVNL3D7.js +23 -0
- package/dist/chunk-UY752QSN.js +45 -0
- package/dist/chunk-V5PXFSZK.js +188 -0
- package/dist/chunk-V7R425XG.js +398 -0
- package/dist/chunk-VCSRSYLF.js +81 -0
- package/dist/chunk-VD4JQCQC.js +162 -0
- package/dist/chunk-VDBPVIKD.js +62 -0
- package/dist/chunk-VHQLPIRJ.js +114 -0
- package/dist/chunk-VN2AXLEX.js +5414 -0
- package/dist/chunk-VNMT7C64.js +478 -0
- package/dist/chunk-WONERJTP.js +309 -0
- package/dist/chunk-XECLWQZN.js +85 -0
- package/dist/chunk-XIMYZ3JA.js +27 -0
- package/dist/chunk-XK4CIILI.js +144 -0
- package/dist/chunk-Y4T27COV.js +562 -0
- package/dist/chunk-YGVYKNSN.js +1860 -0
- package/dist/chunk-YLF3PPT5.js +308 -0
- package/dist/chunk-YSNFMJKN.js +14 -0
- package/dist/chunk-Z3CCVDUB.js +76 -0
- package/dist/chunk-Z54ZSOBZ.js +61 -0
- package/dist/chunk-ZAWW3AF6.js +97 -0
- package/dist/chunk-ZMOL6RQC.js +167 -0
- package/dist/index.js +16456 -8335
- package/dist/mcp/analyze-cli.js +186 -232
- package/dist/mcp/cli.js +137 -98
- package/dist/mcp/server.js +22589 -1573
- package/dist/mcp/worker.js +97 -38
- package/dist/probes/installer.js +135 -0
- package/dist/workers/project-snapshot-persist-worker.js +22 -0
- package/dist/workers/review-graph-persist-worker.js +15 -0
- package/docs/agent-guide.md +13 -4
- package/docs/agent-tools.md +42 -0
- package/docs/ast-grep_rules_catalog.md +3 -2
- package/docs/configuration.md +20 -1
- package/docs/environment-variables.md +52 -2
- package/docs/features.md +8 -4
- package/docs/globalconfig.md +1 -0
- package/docs/io-bridge-v2-migration.md +94 -0
- package/docs/lsp-capability-matrix.md +36 -4
- package/docs/lsp-idle-eviction.md +124 -0
- package/docs/mcp.md +21 -5
- package/docs/merge-queue-rollout.md +77 -0
- package/docs/pi-lens-fixer.md +156 -88
- package/docs/pi-lens-investigator.md +74 -26
- package/docs/pi-lens-merge-policy.md +694 -0
- package/docs/pi-lens-monitor.md +73 -7
- package/docs/pi-lens-retro.md +6 -4
- package/docs/pi-lens-reviewer.md +188 -48
- package/docs/pi-lens-subagent.md +246 -45
- package/docs/pi-lens-warden.md +18 -7
- package/docs/public-api-stability.md +55 -0
- package/docs/release-qa-baseline.md +84 -17
- package/docs/rfcs/3654-unified-io-bridge-v2.md +316 -0
- package/docs/servercapabilities.md +53 -49
- package/docs/settings.md +1 -0
- package/docs/usage.md +5 -1
- package/grammars/tree-sitter-bash.wasm +0 -0
- package/grammars/tree-sitter-bash.wasm.json +3 -3
- package/package.json +19 -7
- package/rules/ast-grep-rules/rule-tests/advisory-registry-subset-test.yml +41 -0
- package/rules/ast-grep-rules/rules/advisory-registry-subset.yml +50 -0
- package/scripts/analyze-pi-lens-logs.mjs +1275 -62
- package/scripts/download-grammars.js +5 -0
- package/scripts/grammars.lock.json +6 -1
- package/scripts/install-selftest.mjs +33 -34
- package/scripts/lib/host-provided-deps.mjs +13 -4
- package/scripts/lib/web-tree-sitter-dir.mjs +18 -0
- package/dist/clients/actionable-warnings-logger.js +0 -35
- package/dist/clients/actionable-warnings.js +0 -1610
- package/dist/clients/advisory-provenance.js +0 -593
- package/dist/clients/agent-behavior-client.js +0 -147
- package/dist/clients/agent-nudge.js +0 -325
- package/dist/clients/analysed-root.js +0 -1
- package/dist/clients/ast-grep-client.js +0 -731
- package/dist/clients/ast-grep-rule-manager.js +0 -146
- package/dist/clients/ast-grep-tool-logger.js +0 -118
- package/dist/clients/ast-grep-types.js +0 -10
- package/dist/clients/ast-grep-yaml-synth.js +0 -154
- package/dist/clients/atomic-write-staging.js +0 -75
- package/dist/clients/atomic-write.js +0 -189
- package/dist/clients/availability-probe-flight.js +0 -12
- package/dist/clients/bash-file-access.js +0 -1056
- package/dist/clients/biome-client.js +0 -357
- package/dist/clients/blocker-freshness.js +0 -837
- package/dist/clients/blocker-past-eof.js +0 -129
- package/dist/clients/bootstrap.js +0 -569
- package/dist/clients/bounded-cache.js +0 -190
- package/dist/clients/bounded-pid-file-lock.js +0 -202
- package/dist/clients/bounded-telemetry.js +0 -295
- package/dist/clients/build-identity.js +0 -95
- package/dist/clients/bundled-resource-health.js +0 -113
- package/dist/clients/bus-events-logger.js +0 -105
- package/dist/clients/bus-publish.js +0 -171
- package/dist/clients/cache/rule-cache.js +0 -190
- package/dist/clients/cache-manager.js +0 -524
- package/dist/clients/cache-observability.js +0 -1313
- package/dist/clients/call-graph.js +0 -852
- package/dist/clients/cargo-manifest.js +0 -422
- package/dist/clients/cascade-budget.js +0 -196
- package/dist/clients/cascade-format.js +0 -315
- package/dist/clients/cascade-logger.js +0 -31
- package/dist/clients/cascade-types.js +0 -9
- package/dist/clients/child-unref.js +0 -124
- package/dist/clients/code-quality-warnings.js +0 -286
- package/dist/clients/codebase-model.js +0 -173
- package/dist/clients/collateral-test-role.js +0 -40
- package/dist/clients/complexity-client.js +0 -462
- package/dist/clients/config-core/deny.js +0 -221
- package/dist/clients/config-core/index.js +0 -50
- package/dist/clients/config-core/merge.js +0 -357
- package/dist/clients/config-core/normalize.js +0 -340
- package/dist/clients/config-core/process-spec.js +0 -248
- package/dist/clients/config-core/provenance.js +0 -164
- package/dist/clients/config-core/records.js +0 -218
- package/dist/clients/config-core/resolve.js +0 -125
- package/dist/clients/config-core/safe-object.js +0 -78
- package/dist/clients/config-core/schema.js +0 -165
- package/dist/clients/config-diagnostic-codes.js +0 -285
- package/dist/clients/config-locations.js +0 -388
- package/dist/clients/config-resolve.js +0 -798
- package/dist/clients/config-schema.js +0 -251
- package/dist/clients/config-warn.js +0 -407
- package/dist/clients/console-guard-install.js +0 -26
- package/dist/clients/cooperative-budget.js +0 -42
- package/dist/clients/dead-code-client.js +0 -510
- package/dist/clients/dead-code-logger.js +0 -30
- package/dist/clients/deadline-utils.js +0 -280
- package/dist/clients/debug-handles.js +0 -211
- package/dist/clients/debug-heap.js +0 -174
- package/dist/clients/deferred-lsp-work.js +0 -106
- package/dist/clients/degradation-ledger.js +0 -426
- package/dist/clients/demoted-finding-render.js +0 -169
- package/dist/clients/dependency-checker.js +0 -885
- package/dist/clients/deps/ast-grep-napi.js +0 -22
- package/dist/clients/deps/js-yaml.js +0 -9
- package/dist/clients/deps/minimatch.js +0 -4
- package/dist/clients/deps/pi-tui.js +0 -14
- package/dist/clients/deps/typebox.js +0 -14
- package/dist/clients/deps/vscode-jsonrpc.js +0 -1
- package/dist/clients/deps/web-tree-sitter.js +0 -24
- package/dist/clients/diagnostic-dispositions.js +0 -630
- package/dist/clients/diagnostic-line-freshness.js +0 -305
- package/dist/clients/diagnostic-logger.js +0 -73
- package/dist/clients/diagnostic-tracker.js +0 -105
- package/dist/clients/diagnostics-publish.js +0 -230
- package/dist/clients/dispatch/ast-grep-catalog.js +0 -65
- package/dist/clients/dispatch/auxiliary-lsp.js +0 -343
- package/dist/clients/dispatch/collect-later-tier.js +0 -35
- package/dist/clients/dispatch/diagnostic-taxonomy.js +0 -66
- package/dist/clients/dispatch/dispatcher.js +0 -1269
- package/dist/clients/dispatch/fact-provider-types.js +0 -1
- package/dist/clients/dispatch/fact-rule-runner.js +0 -17
- package/dist/clients/dispatch/fact-runner.js +0 -30
- package/dist/clients/dispatch/fact-scheduler.js +0 -68
- package/dist/clients/dispatch/fact-store.js +0 -377
- package/dist/clients/dispatch/facts/comment-facts.js +0 -22
- package/dist/clients/dispatch/facts/file-content.js +0 -19
- package/dist/clients/dispatch/facts/function-facts.js +0 -348
- package/dist/clients/dispatch/facts/import-facts.js +0 -204
- package/dist/clients/dispatch/facts/tree-sitter-facts.js +0 -34
- package/dist/clients/dispatch/facts/try-catch-facts.js +0 -119
- package/dist/clients/dispatch/finding-policy.js +0 -339
- package/dist/clients/dispatch/indent-detect.js +0 -417
- package/dist/clients/dispatch/inline-suppressions.js +0 -89
- package/dist/clients/dispatch/integration.js +0 -2377
- package/dist/clients/dispatch/lazy.js +0 -11
- package/dist/clients/dispatch/pending-runner-findings.js +0 -87
- package/dist/clients/dispatch/plan.js +0 -278
- package/dist/clients/dispatch/priorities.js +0 -20
- package/dist/clients/dispatch/rule-id-normalize.js +0 -50
- package/dist/clients/dispatch/rule-ignores.js +0 -69
- package/dist/clients/dispatch/rule-policy.js +0 -135
- package/dist/clients/dispatch/rules/async-noise.js +0 -40
- package/dist/clients/dispatch/rules/async-unnecessary-wrapper.js +0 -27
- package/dist/clients/dispatch/rules/cors-wildcard.js +0 -54
- package/dist/clients/dispatch/rules/error-obscuring.js +0 -32
- package/dist/clients/dispatch/rules/error-swallowing.js +0 -31
- package/dist/clients/dispatch/rules/framework-call-noise.js +0 -67
- package/dist/clients/dispatch/rules/high-complexity.js +0 -72
- package/dist/clients/dispatch/rules/high-fan-out.js +0 -74
- package/dist/clients/dispatch/rules/high-import-coupling.js +0 -37
- package/dist/clients/dispatch/rules/missing-error-propagation.js +0 -62
- package/dist/clients/dispatch/rules/no-commented-credentials.js +0 -52
- package/dist/clients/dispatch/rules/pass-through-wrappers.js +0 -42
- package/dist/clients/dispatch/rules/placeholder-comments.js +0 -40
- package/dist/clients/dispatch/rules/unsafe-boundary.js +0 -126
- package/dist/clients/dispatch/runner-context.js +0 -52
- package/dist/clients/dispatch/runners/actionlint.js +0 -111
- package/dist/clients/dispatch/runners/ast-grep-napi.js +0 -1196
- package/dist/clients/dispatch/runners/biome-check.js +0 -296
- package/dist/clients/dispatch/runners/cpp-check.js +0 -219
- package/dist/clients/dispatch/runners/credo.js +0 -82
- package/dist/clients/dispatch/runners/cue-vet.js +0 -416
- package/dist/clients/dispatch/runners/dart-analyze.js +0 -183
- package/dist/clients/dispatch/runners/detekt.js +0 -176
- package/dist/clients/dispatch/runners/dotnet-build.js +0 -164
- package/dist/clients/dispatch/runners/elixir-check.js +0 -195
- package/dist/clients/dispatch/runners/eslint.js +0 -137
- package/dist/clients/dispatch/runners/fact-rules.js +0 -29
- package/dist/clients/dispatch/runners/fish-indent.js +0 -69
- package/dist/clients/dispatch/runners/gleam-check.js +0 -167
- package/dist/clients/dispatch/runners/go-vet.js +0 -104
- package/dist/clients/dispatch/runners/golangci-lint.js +0 -135
- package/dist/clients/dispatch/runners/hadolint.js +0 -91
- package/dist/clients/dispatch/runners/helm-lint.js +0 -171
- package/dist/clients/dispatch/runners/helm-render.js +0 -940
- package/dist/clients/dispatch/runners/htmlhint.js +0 -117
- package/dist/clients/dispatch/runners/index.js +0 -108
- package/dist/clients/dispatch/runners/javac.js +0 -99
- package/dist/clients/dispatch/runners/ktlint.js +0 -110
- package/dist/clients/dispatch/runners/lsp.js +0 -379
- package/dist/clients/dispatch/runners/markdownlint.js +0 -167
- package/dist/clients/dispatch/runners/mypy.js +0 -102
- package/dist/clients/dispatch/runners/oxlint.js +0 -414
- package/dist/clients/dispatch/runners/php-lint.js +0 -85
- package/dist/clients/dispatch/runners/phpstan.js +0 -120
- package/dist/clients/dispatch/runners/prisma-validate.js +0 -62
- package/dist/clients/dispatch/runners/psscriptanalyzer.js +0 -445
- package/dist/clients/dispatch/runners/pyright.js +0 -169
- package/dist/clients/dispatch/runners/rubocop.js +0 -99
- package/dist/clients/dispatch/runners/ruff.js +0 -88
- package/dist/clients/dispatch/runners/rust-clippy.js +0 -256
- package/dist/clients/dispatch/runners/shellcheck.js +0 -173
- package/dist/clients/dispatch/runners/shfmt.js +0 -102
- package/dist/clients/dispatch/runners/spellcheck.js +0 -128
- package/dist/clients/dispatch/runners/spotbugs.js +0 -259
- package/dist/clients/dispatch/runners/sqlfluff.js +0 -183
- package/dist/clients/dispatch/runners/stylelint.js +0 -166
- package/dist/clients/dispatch/runners/swiftlint.js +0 -163
- package/dist/clients/dispatch/runners/taplo.js +0 -174
- package/dist/clients/dispatch/runners/terragrunt.js +0 -168
- package/dist/clients/dispatch/runners/tflint.js +0 -125
- package/dist/clients/dispatch/runners/tree-sitter.js +0 -643
- package/dist/clients/dispatch/runners/trivy-config.js +0 -253
- package/dist/clients/dispatch/runners/utils/availability-policy.js +0 -496
- package/dist/clients/dispatch/runners/utils/candidate-probe.js +0 -90
- package/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -95
- package/dist/clients/dispatch/runners/utils/lazy-installer.js +0 -274
- package/dist/clients/dispatch/runners/utils/runner-helpers.js +0 -1701
- package/dist/clients/dispatch/runners/utils/spawn-outcome.js +0 -101
- package/dist/clients/dispatch/runners/utils/tool-failure.js +0 -235
- package/dist/clients/dispatch/runners/utils/toolchain-availability.js +0 -169
- package/dist/clients/dispatch/runners/utils.js +0 -15
- package/dist/clients/dispatch/runners/vale.js +0 -128
- package/dist/clients/dispatch/runners/yaml-rule-parser.js +0 -242
- package/dist/clients/dispatch/runners/yamllint.js +0 -95
- package/dist/clients/dispatch/runners/zig-check.js +0 -79
- package/dist/clients/dispatch/suppress-writer.js +0 -79
- package/dist/clients/dispatch/tool-profile.js +0 -30
- package/dist/clients/dispatch/types.js +0 -21
- package/dist/clients/dispatch/utils/format-utils.js +0 -45
- package/dist/clients/dispatch/utils/lsp-diagnostics.js +0 -35
- package/dist/clients/disposition-logger.js +0 -32
- package/dist/clients/disposition-publish.js +0 -124
- package/dist/clients/durable-store.js +0 -97
- package/dist/clients/effective-config.js +0 -415
- package/dist/clients/env-utils.js +0 -83
- package/dist/clients/error-class.js +0 -23
- package/dist/clients/eval-timestamp.js +0 -17
- package/dist/clients/event-loop-hold.js +0 -274
- package/dist/clients/event-loop-monitor.js +0 -250
- package/dist/clients/extension-log.js +0 -504
- package/dist/clients/extension-mode.js +0 -73
- package/dist/clients/feature-hints.js +0 -103
- package/dist/clients/file-kinds.js +0 -412
- package/dist/clients/file-role.js +0 -134
- package/dist/clients/file-time.js +0 -160
- package/dist/clients/file-utils.js +0 -1032
- package/dist/clients/finding-delivery-gate.js +0 -494
- package/dist/clients/finding-identity.js +0 -88
- package/dist/clients/fix-worklog.js +0 -103
- package/dist/clients/format-events-publish.js +0 -343
- package/dist/clients/format-service.js +0 -222
- package/dist/clients/formatters-lazy.js +0 -9
- package/dist/clients/formatters.js +0 -2032
- package/dist/clients/freshness-cadence.js +0 -17
- package/dist/clients/freshness.js +0 -38
- package/dist/clients/generated-artifacts.js +0 -394
- package/dist/clients/generation-guard.js +0 -215
- package/dist/clients/git-guard.js +0 -1136
- package/dist/clients/git-tracked-ignore.js +0 -243
- package/dist/clients/gitleaks-client.js +0 -509
- package/dist/clients/go-client.js +0 -104
- package/dist/clients/govulncheck-client.js +0 -605
- package/dist/clients/gradle-ktfmt-style.js +0 -348
- package/dist/clients/grammar-source.js +0 -465
- package/dist/clients/gzip-stage-write.js +0 -135
- package/dist/clients/hashline-anchor.js +0 -424
- package/dist/clients/hook-budgets.js +0 -76
- package/dist/clients/host-edit-normalize.js +0 -140
- package/dist/clients/host-ports.js +0 -39
- package/dist/clients/indent-retarget.js +0 -154
- package/dist/clients/inline-blocker-dispositions.js +0 -186
- package/dist/clients/install-diagnostics.js +0 -156
- package/dist/clients/installer/index.js +0 -5416
- package/dist/clients/installer/managed-tool-refresh-session.js +0 -58
- package/dist/clients/installer/managed-tool-refresh.js +0 -783
- package/dist/clients/instance-reaper-state.js +0 -7
- package/dist/clients/instance-reaper.js +0 -1137
- package/dist/clients/instance-registry-lock.js +0 -145
- package/dist/clients/instance-registry.js +0 -773
- package/dist/clients/jscpd-client.js +0 -378
- package/dist/clients/json-cache-read.js +0 -65
- package/dist/clients/knip-client.js +0 -788
- package/dist/clients/language-policy.js +0 -252
- package/dist/clients/language-profile.js +0 -361
- package/dist/clients/language-registry.js +0 -603
- package/dist/clients/latency-logger.js +0 -727
- package/dist/clients/lazy-import.js +0 -21
- package/dist/clients/ledger-bounds.js +0 -54
- package/dist/clients/lens-config.js +0 -404
- package/dist/clients/lens-engine.js +0 -358
- package/dist/clients/lens-events.js +0 -125
- package/dist/clients/lens-flag-registry.js +0 -467
- package/dist/clients/lens-map.js +0 -1156
- package/dist/clients/live-bus-emitter.js +0 -74
- package/dist/clients/log-cleanup.js +0 -222
- package/dist/clients/lsp/aggregation.js +0 -178
- package/dist/clients/lsp/cascade-tier.js +0 -421
- package/dist/clients/lsp/client.js +0 -4593
- package/dist/clients/lsp/config.js +0 -691
- package/dist/clients/lsp/content-limits.js +0 -41
- package/dist/clients/lsp/diagnostic-binding.js +0 -225
- package/dist/clients/lsp/document-drift.js +0 -467
- package/dist/clients/lsp/edits.js +0 -1219
- package/dist/clients/lsp/index.js +0 -8305
- package/dist/clients/lsp/inferred-project.js +0 -216
- package/dist/clients/lsp/jvm-runtime.js +0 -298
- package/dist/clients/lsp/language.js +0 -63
- package/dist/clients/lsp/launch.js +0 -746
- package/dist/clients/lsp/lombok.js +0 -158
- package/dist/clients/lsp/path-utils.js +0 -5
- package/dist/clients/lsp/pending-aux-coverage.js +0 -251
- package/dist/clients/lsp/position-encoding.js +0 -61
- package/dist/clients/lsp/ruby-drive-dirs.js +0 -83
- package/dist/clients/lsp/server.js +0 -3290
- package/dist/clients/lsp/session-roots.js +0 -192
- package/dist/clients/lsp/spawn-history.js +0 -17
- package/dist/clients/lsp/sync-kind.js +0 -56
- package/dist/clients/lsp/tsserver-sync.js +0 -332
- package/dist/clients/lsp/wait-policy/capability-snapshot.js +0 -1
- package/dist/clients/lsp/wait-policy/classification.js +0 -85
- package/dist/clients/lsp/wait-policy/index.js +0 -10
- package/dist/clients/lsp/wait-policy/strategies.js +0 -392
- package/dist/clients/lsp/watch-queue.js +0 -61
- package/dist/clients/lsp/workspace-diagnostics-cache.js +0 -639
- package/dist/clients/lsp/workspace-diagnostics-session.js +0 -30
- package/dist/clients/lsp/workspace-sweep-hold.js +0 -184
- package/dist/clients/lsp-budget.js +0 -186
- package/dist/clients/lsp-document-symbols.js +0 -110
- package/dist/clients/lsp-lazy.js +0 -9
- package/dist/clients/lsp-mutation.js +0 -396
- package/dist/clients/lsp-status.js +0 -59
- package/dist/clients/map-with-concurrency.js +0 -40
- package/dist/clients/mcp/analyze.js +0 -420
- package/dist/clients/mcp/host-shim.js +0 -31
- package/dist/clients/mcp/ipc.js +0 -523
- package/dist/clients/mcp/review.js +0 -197
- package/dist/clients/mcp/session.js +0 -412
- package/dist/clients/memory-sampler.js +0 -208
- package/dist/clients/message-end-attribution.js +0 -30
- package/dist/clients/metrics-client.js +0 -107
- package/dist/clients/metrics-history.js +0 -327
- package/dist/clients/middle-man-analysis.js +0 -263
- package/dist/clients/model-provider.js +0 -53
- package/dist/clients/module-report-lsp.js +0 -189
- package/dist/clients/module-report.js +0 -2150
- package/dist/clients/mutating-tool.js +0 -651
- package/dist/clients/mutation-attribution.js +0 -368
- package/dist/clients/mutation-bridge.js +0 -240
- package/dist/clients/ndjson-logger.js +0 -734
- package/dist/clients/observed-mutation-sources.js +0 -101
- package/dist/clients/observed-mutation.js +0 -1253
- package/dist/clients/oldtext-autopatch.js +0 -128
- package/dist/clients/opaque-mutation-scan.js +0 -496
- package/dist/clients/opengrep-client.js +0 -333
- package/dist/clients/opengrep-config.js +0 -76
- package/dist/clients/package-manager.js +0 -607
- package/dist/clients/package-root.js +0 -38
- package/dist/clients/partial-edit-apply.js +0 -439
- package/dist/clients/path-attribution-telemetry.js +0 -43
- package/dist/clients/path-keyed-map.js +0 -108
- package/dist/clients/path-utils.js +0 -1244
- package/dist/clients/performance-report.js +0 -331
- package/dist/clients/persist-debounce.js +0 -70
- package/dist/clients/persistent-reverify.js +0 -271
- package/dist/clients/php-cs-fixer-config.js +0 -119
- package/dist/clients/pipeline.js +0 -1480
- package/dist/clients/post-autofix-notice.js +0 -37
- package/dist/clients/print-mode.js +0 -21
- package/dist/clients/probe-home-state.js +0 -228
- package/dist/clients/process-bridge.js +0 -66
- package/dist/clients/process-singletons.js +0 -210
- package/dist/clients/process-snapshot.js +0 -68
- package/dist/clients/project-changes.js +0 -181
- package/dist/clients/project-conventions.js +0 -171
- package/dist/clients/project-diagnostics/cache.js +0 -137
- package/dist/clients/project-diagnostics/extractors.js +0 -109
- package/dist/clients/project-diagnostics/fresh-fetch.js +0 -668
- package/dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js +0 -118
- package/dist/clients/project-diagnostics/runner-adapters/dead-code.js +0 -47
- package/dist/clients/project-diagnostics/runner-adapters/gitleaks.js +0 -40
- package/dist/clients/project-diagnostics/runner-adapters/govulncheck.js +0 -34
- package/dist/clients/project-diagnostics/runner-adapters/jscpd.js +0 -38
- package/dist/clients/project-diagnostics/runner-adapters/knip.js +0 -47
- package/dist/clients/project-diagnostics/runner-adapters/madge.js +0 -48
- package/dist/clients/project-diagnostics/runner-adapters/opengrep.js +0 -40
- package/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +0 -127
- package/dist/clients/project-diagnostics/runner-adapters/trivy.js +0 -81
- package/dist/clients/project-diagnostics/scanner.js +0 -520
- package/dist/clients/project-diagnostics/types.js +0 -1
- package/dist/clients/project-lens-config.js +0 -807
- package/dist/clients/project-report.js +0 -701
- package/dist/clients/project-scale.js +0 -237
- package/dist/clients/project-scan-policy.js +0 -11
- package/dist/clients/project-snapshot-fingerprint.js +0 -48
- package/dist/clients/project-snapshot-persist-worker.js +0 -20
- package/dist/clients/project-snapshot.js +0 -1653
- package/dist/clients/project-trust.js +0 -181
- package/dist/clients/python-environment.js +0 -217
- package/dist/clients/python-provenance.js +0 -639
- package/dist/clients/quiet-window-config.js +0 -47
- package/dist/clients/quiet-window.js +0 -236
- package/dist/clients/read-bridge.js +0 -139
- package/dist/clients/read-expansion.js +0 -266
- package/dist/clients/read-guard-logger.js +0 -251
- package/dist/clients/read-guard-tool-lines.js +0 -1306
- package/dist/clients/read-guard.js +0 -1561
- package/dist/clients/recent-touches.js +0 -240
- package/dist/clients/redact/secrets.js +0 -449
- package/dist/clients/resource-sampler.js +0 -628
- package/dist/clients/reverse-deps.js +0 -270
- package/dist/clients/review-graph/builder.js +0 -5126
- package/dist/clients/review-graph/format.js +0 -33
- package/dist/clients/review-graph/git-identity.js +0 -163
- package/dist/clients/review-graph/import-resolvers.js +0 -481
- package/dist/clients/review-graph/persist-worker.js +0 -10
- package/dist/clients/review-graph/query.js +0 -244
- package/dist/clients/review-graph/revision-drift.js +0 -21
- package/dist/clients/review-graph/service.js +0 -96
- package/dist/clients/review-graph/shared-extraction-ir.js +0 -82
- package/dist/clients/review-graph/symbol-id.js +0 -103
- package/dist/clients/review-graph/tsconfig-paths.js +0 -299
- package/dist/clients/review-graph/types.js +0 -1
- package/dist/clients/review-graph/workspace-modules.js +0 -449
- package/dist/clients/review-graph-logger.js +0 -81
- package/dist/clients/ruff-client.js +0 -179
- package/dist/clients/rules-scanner.js +0 -131
- package/dist/clients/run-duration.js +0 -55
- package/dist/clients/runtime-agent-end.js +0 -746
- package/dist/clients/runtime-config.js +0 -77
- package/dist/clients/runtime-context.js +0 -211
- package/dist/clients/runtime-coordinator.js +0 -1324
- package/dist/clients/runtime-session.js +0 -2485
- package/dist/clients/runtime-tool-call.js +0 -1295
- package/dist/clients/runtime-tool-result.js +0 -2049
- package/dist/clients/runtime-turn.js +0 -3767
- package/dist/clients/rust-client.js +0 -97
- package/dist/clients/safe-spawn.js +0 -2357
- package/dist/clients/sanitize.js +0 -286
- package/dist/clients/scan-utils.js +0 -25
- package/dist/clients/scratch-tree-policy.js +0 -165
- package/dist/clients/search-read-registration.js +0 -94
- package/dist/clients/secret-findings.js +0 -114
- package/dist/clients/security-scan-client.js +0 -352
- package/dist/clients/session-event-guard.js +0 -297
- package/dist/clients/session-lifecycle.js +0 -484
- package/dist/clients/session-start-observability.js +0 -94
- package/dist/clients/session-state-store.js +0 -101
- package/dist/clients/session-summary.js +0 -15
- package/dist/clients/sessionstart-logger.js +0 -27
- package/dist/clients/sg-runner.js +0 -876
- package/dist/clients/sgconfig.js +0 -347
- package/dist/clients/shared-checkout-guard.js +0 -338
- package/dist/clients/single-flight.js +0 -158
- package/dist/clients/situational-tool-telemetry.js +0 -108
- package/dist/clients/skills-resolver.js +0 -141
- package/dist/clients/slow-fs.js +0 -138
- package/dist/clients/smells-rollup.js +0 -231
- package/dist/clients/source-filter.js +0 -596
- package/dist/clients/source-walker.js +0 -211
- package/dist/clients/spawn-output-cap.js +0 -120
- package/dist/clients/spawn-timeout-cooldown.js +0 -110
- package/dist/clients/stale-marker.js +0 -17
- package/dist/clients/startup-scan.js +0 -400
- package/dist/clients/startup-timing.js +0 -130
- package/dist/clients/string-utils.js +0 -33
- package/dist/clients/subagent-mode.js +0 -111
- package/dist/clients/symbol-containment.js +0 -24
- package/dist/clients/symbol-types.js +0 -5
- package/dist/clients/test-runner-client.js +0 -2507
- package/dist/clients/test-runner-delivery.js +0 -287
- package/dist/clients/todo-scanner.js +0 -229
- package/dist/clients/tool-agreement.js +0 -423
- package/dist/clients/tool-config.js +0 -249
- package/dist/clients/tool-cwd.js +0 -270
- package/dist/clients/tool-definition.js +0 -47
- package/dist/clients/tool-event.js +0 -105
- package/dist/clients/tool-policy.js +0 -2755
- package/dist/clients/tool-probe.js +0 -53
- package/dist/clients/tool-render.js +0 -156
- package/dist/clients/tool-set-policy.js +0 -118
- package/dist/clients/tree-sitter-cache.js +0 -364
- package/dist/clients/tree-sitter-client.js +0 -4195
- package/dist/clients/tree-sitter-logger.js +0 -100
- package/dist/clients/tree-sitter-navigator.js +0 -269
- package/dist/clients/tree-sitter-query-loader.js +0 -569
- package/dist/clients/tree-sitter-shared.js +0 -158
- package/dist/clients/tree-sitter-symbol-extractor.js +0 -1265
- package/dist/clients/trivy-client.js +0 -467
- package/dist/clients/tui-fit.js +0 -50
- package/dist/clients/turn-context.js +0 -52
- package/dist/clients/turn-end/lane.js +0 -51
- package/dist/clients/turn-end/lanes/govulncheck.js +0 -112
- package/dist/clients/turn-end/lanes/secrets.js +0 -204
- package/dist/clients/turn-summary-render.js +0 -72
- package/dist/clients/turn-summary.js +0 -132
- package/dist/clients/typos-config.js +0 -29
- package/dist/clients/user-notify.js +0 -51
- package/dist/clients/vanished-instance-marker.js +0 -57
- package/dist/clients/warm-attach.js +0 -305
- package/dist/clients/widget-state.js +0 -1808
- package/dist/clients/word-index-logger.js +0 -49
- package/dist/clients/word-index-store.js +0 -459
- package/dist/clients/word-index.js +0 -2080
- package/dist/clients/workspace-topology.js +0 -443
- package/dist/clients/write-ordering-guard.js +0 -65
- package/dist/clients/zizmor-config.js +0 -340
- package/dist/i18n.js +0 -69
- package/dist/mcp/build-staleness.js +0 -124
- package/dist/scripts/lib/process-scan.mjs +0 -583
- package/dist/scripts/lib/skills-predicate.mjs +0 -129
- package/dist/scripts/lib/web-tree-sitter-dir.mjs +0 -123
- package/dist/tools/activate-tools.js +0 -87
- package/dist/tools/ast-grep-outline.js +0 -137
- package/dist/tools/ast-grep-replace.js +0 -244
- package/dist/tools/ast-grep-search.js +0 -762
- package/dist/tools/effective-config.js +0 -90
- package/dist/tools/lens-diagnostic-mark.js +0 -375
- package/dist/tools/lens-diagnostics.js +0 -2571
- package/dist/tools/lsp-diagnostics.js +0 -1745
- package/dist/tools/lsp-navigation.js +0 -1367
- package/dist/tools/lsp-structured-output.js +0 -294
- package/dist/tools/module-report.js +0 -382
- package/dist/tools/project-report.js +0 -86
- package/dist/tools/render-compact.js +0 -374
- package/dist/tools/scan-progress.js +0 -53
- package/dist/tools/shared.js +0 -29
- package/dist/tools/symbol-search.js +0 -155
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { safeSpawnAsync } from "../../safe-spawn.js";
|
|
2
|
-
import { findNearestContaining } from "../../path-utils.js";
|
|
3
|
-
import { resolveRunnerCwd } from "../../tool-cwd.js";
|
|
4
|
-
import { PRIORITY } from "../priorities.js";
|
|
5
|
-
import { createAvailabilityChecker, resolveAvailableOrInstall, } from "./utils/runner-helpers.js";
|
|
6
|
-
const shfmt = createAvailabilityChecker("shfmt", ".exe");
|
|
7
|
-
// shfmt's only config source is .editorconfig. We treat its presence as the
|
|
8
|
-
// opt-in for the (non-error) format-diff warning, so out of the box shfmt only
|
|
9
|
-
// reports genuine parse errors instead of nagging every unformatted shell file
|
|
10
|
-
// against shfmt's built-in defaults (#211).
|
|
11
|
-
function hasEditorConfig(cwd) {
|
|
12
|
-
return findNearestContaining(cwd, [".editorconfig"]) !== undefined;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* shfmt runner — checks shell script formatting.
|
|
16
|
-
* Reports files that differ from shfmt's canonical output as a single warning.
|
|
17
|
-
* Does NOT auto-apply formatting (that's the formatter's job).
|
|
18
|
-
*/
|
|
19
|
-
const shfmtRunner = {
|
|
20
|
-
id: "shfmt",
|
|
21
|
-
appliesTo: ["shell"],
|
|
22
|
-
priority: PRIORITY.FORMAT_AND_LINT_PRIMARY,
|
|
23
|
-
skipTestFiles: false,
|
|
24
|
-
async run(ctx) {
|
|
25
|
-
const cwd = resolveRunnerCwd(ctx, "shfmt");
|
|
26
|
-
let cmd = null;
|
|
27
|
-
if (await shfmt.isAvailableAsync(cwd)) {
|
|
28
|
-
cmd = shfmt.getCommand(cwd);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
const installed = await resolveAvailableOrInstall(shfmt, "shfmt", cwd);
|
|
32
|
-
if (!installed) {
|
|
33
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
34
|
-
}
|
|
35
|
-
cmd = installed;
|
|
36
|
-
}
|
|
37
|
-
if (!cmd)
|
|
38
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
39
|
-
// --diff exits 1 and prints a unified diff if the file needs formatting
|
|
40
|
-
const result = await safeSpawnAsync(cmd, ["--diff", ctx.filePath], {
|
|
41
|
-
timeout: 10000,
|
|
42
|
-
cwd,
|
|
43
|
-
});
|
|
44
|
-
// exit 0 = already formatted, exit 1 = needs formatting, exit >1 = parse error
|
|
45
|
-
if (result.status === 0) {
|
|
46
|
-
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
47
|
-
}
|
|
48
|
-
if ((result.status ?? 2) > 1) {
|
|
49
|
-
// Parse error — report on line 1
|
|
50
|
-
const errMsg = (result.stderr ?? "").split("\n")[0].trim();
|
|
51
|
-
const diagnostics = [
|
|
52
|
-
{
|
|
53
|
-
id: `shfmt-parse-${ctx.filePath}`,
|
|
54
|
-
message: errMsg
|
|
55
|
-
? `shfmt parse error: ${errMsg}`
|
|
56
|
-
: "shfmt: failed to parse shell script",
|
|
57
|
-
filePath: ctx.filePath,
|
|
58
|
-
line: 1,
|
|
59
|
-
column: 1,
|
|
60
|
-
severity: "error",
|
|
61
|
-
semantic: "blocking",
|
|
62
|
-
tool: "shfmt",
|
|
63
|
-
rule: "shfmt-parse-error",
|
|
64
|
-
},
|
|
65
|
-
];
|
|
66
|
-
return { status: "failed", diagnostics, semantic: "blocking" };
|
|
67
|
-
}
|
|
68
|
-
// Needs formatting (exit 1). Only warn if the project opted into shfmt via
|
|
69
|
-
// .editorconfig — otherwise this nags on every shell write against shfmt's
|
|
70
|
-
// defaults (#211). Parse errors (above) are always reported.
|
|
71
|
-
if (!hasEditorConfig(cwd)) {
|
|
72
|
-
// #211: without project opt-in, do not nag about formatting. But
|
|
73
|
-
// shfmt DID exit 1 — differences exist — so this is "chose not to
|
|
74
|
-
// check", reported as skipped, never as a clean result (#1839).
|
|
75
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
76
|
-
}
|
|
77
|
-
// Extract first changed line from diff if possible
|
|
78
|
-
const diffOutput = result.stdout ?? result.stderr ?? "";
|
|
79
|
-
let line = 1;
|
|
80
|
-
const lineMatch = diffOutput.match(/^@@\s+-(\d+)/m);
|
|
81
|
-
if (lineMatch)
|
|
82
|
-
line = Number(lineMatch[1]);
|
|
83
|
-
const diagnostics = [
|
|
84
|
-
{
|
|
85
|
-
id: `shfmt-format-${ctx.filePath}`,
|
|
86
|
-
message: "Shell script is not formatted — run `shfmt -w` to fix",
|
|
87
|
-
filePath: ctx.filePath,
|
|
88
|
-
line,
|
|
89
|
-
column: 1,
|
|
90
|
-
severity: "warning",
|
|
91
|
-
semantic: "warning",
|
|
92
|
-
tool: "shfmt",
|
|
93
|
-
rule: "shfmt-unformatted",
|
|
94
|
-
fixable: true,
|
|
95
|
-
autoFixAvailable: false,
|
|
96
|
-
fixKind: "manual",
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
|
-
return { status: "succeeded", diagnostics, semantic: "warning" };
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
export default shfmtRunner;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Spellcheck runner for dispatch system
|
|
3
|
-
*
|
|
4
|
-
* Uses typos-cli (Rust-based, fast, zero-config) to check spelling in:
|
|
5
|
-
* - Markdown files (.md, .mdx)
|
|
6
|
-
* - Code comments (optional, if typos is configured)
|
|
7
|
-
*
|
|
8
|
-
* Key features:
|
|
9
|
-
* - Fast (Rust-based, ~10x faster than cspell)
|
|
10
|
-
* - Low false positives (only checks known typos)
|
|
11
|
-
* - Zero-config by default
|
|
12
|
-
* - JSON output for easy parsing
|
|
13
|
-
*
|
|
14
|
-
* Alternative considered: cspell
|
|
15
|
-
* - cspell: More comprehensive, but higher false positives, needs config
|
|
16
|
-
* - typos-cli: Faster, less noise, works out of the box
|
|
17
|
-
*
|
|
18
|
-
* Install: cargo install typos-cli
|
|
19
|
-
* Or: npm install -g typos-cli (if wrapped)
|
|
20
|
-
*/
|
|
21
|
-
import * as path from "node:path";
|
|
22
|
-
import { pathsEqual } from "../../path-utils.js";
|
|
23
|
-
import { safeSpawnAsync } from "../../safe-spawn.js";
|
|
24
|
-
import { PRIORITY } from "../priorities.js";
|
|
25
|
-
import { createAvailabilityChecker, resolveRunnerCwd, } from "./utils/runner-helpers.js";
|
|
26
|
-
import { parseToolRun } from "./utils/tool-failure.js";
|
|
27
|
-
const typos = createAvailabilityChecker("typos", ".exe");
|
|
28
|
-
// EXIT TABLE (typos-cli 1.29 docs https://github.com/crate-ci/typos): 0 = no typos, 2 = typos found, 1 = an error that
|
|
29
|
-
// stopped the scan. Anything nonzero outside {2} is a rejected invocation.
|
|
30
|
-
const TYPOS_EXIT_CODES = { ran: [2] };
|
|
31
|
-
/**
|
|
32
|
-
* Parse typos-cli JSON output (JSON Lines format)
|
|
33
|
-
*
|
|
34
|
-
* Each line is a JSON object:
|
|
35
|
-
* {
|
|
36
|
-
* "path": "file.md",
|
|
37
|
-
* "line_num": 42,
|
|
38
|
-
* "byte_offset": 1234,
|
|
39
|
-
* "typo": "recieve",
|
|
40
|
-
* "corrections": ["receive"]
|
|
41
|
-
* }
|
|
42
|
-
*/
|
|
43
|
-
function parseTyposOutput(raw, filePath, cwd) {
|
|
44
|
-
const diagnostics = [];
|
|
45
|
-
const absTarget = path.resolve(cwd, filePath);
|
|
46
|
-
if (!raw.trim()) {
|
|
47
|
-
return diagnostics;
|
|
48
|
-
}
|
|
49
|
-
const lines = raw
|
|
50
|
-
.trim()
|
|
51
|
-
.split("\n")
|
|
52
|
-
.filter((l) => l.trim());
|
|
53
|
-
for (const line of lines) {
|
|
54
|
-
try {
|
|
55
|
-
const parsed = JSON.parse(line);
|
|
56
|
-
if (!parsed.typo || !parsed.line_num)
|
|
57
|
-
continue;
|
|
58
|
-
// #3295: every typos JSONL record names its own `path`; a `typos.toml`
|
|
59
|
-
// `files.extend-exclude` or a directory argv makes that a second file.
|
|
60
|
-
if (parsed.path && !pathsEqual(path.resolve(cwd, parsed.path), absTarget))
|
|
61
|
-
continue;
|
|
62
|
-
const corrections = parsed.corrections?.join(", ") || "no suggestions";
|
|
63
|
-
const message = `Typo: "${parsed.typo}" → ${corrections}`;
|
|
64
|
-
diagnostics.push({
|
|
65
|
-
id: `typos-${parsed.line_num}-${parsed.typo}`,
|
|
66
|
-
message,
|
|
67
|
-
filePath,
|
|
68
|
-
line: parsed.line_num,
|
|
69
|
-
column: 1, // typos-cli doesn't provide column, just byte offset
|
|
70
|
-
severity: "warning",
|
|
71
|
-
semantic: "warning",
|
|
72
|
-
tool: "typos",
|
|
73
|
-
rule: "typo",
|
|
74
|
-
fixable: !!parsed.corrections?.length,
|
|
75
|
-
autoFixAvailable: false,
|
|
76
|
-
fixKind: parsed.corrections?.length ? "suggestion" : undefined,
|
|
77
|
-
fixSuggestion: parsed.corrections?.[0],
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
catch (err) {
|
|
81
|
-
void err;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return diagnostics;
|
|
85
|
-
}
|
|
86
|
-
const spellcheckRunner = {
|
|
87
|
-
id: "spellcheck",
|
|
88
|
-
appliesTo: ["markdown"],
|
|
89
|
-
priority: PRIORITY.DOC_QUALITY,
|
|
90
|
-
skipTestFiles: false, // Check docs in test files too
|
|
91
|
-
async run(ctx) {
|
|
92
|
-
const cwd = resolveRunnerCwd(ctx, "spellcheck/typos");
|
|
93
|
-
// Skip if typos-cli is not installed
|
|
94
|
-
if (!(await typos.isAvailableAsync(cwd))) {
|
|
95
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
96
|
-
}
|
|
97
|
-
// Run typos-cli with JSON output
|
|
98
|
-
// --format json: Output JSON Lines
|
|
99
|
-
// --exclude <pattern>: Could be used to exclude code blocks if needed
|
|
100
|
-
const args = ["--format", "json", ctx.filePath];
|
|
101
|
-
const result = await safeSpawnAsync(typos.getCommand(cwd), args, {
|
|
102
|
-
cwd,
|
|
103
|
-
timeout: 15000,
|
|
104
|
-
});
|
|
105
|
-
// #1816: typos-cli exits 0 clean, 2 with typos found, and 1 on an ERROR
|
|
106
|
-
// (unreadable config, bad argument). The `status === 2 || stdout` test
|
|
107
|
-
// below is false for exit 1 with an empty stdout, so a failed run was
|
|
108
|
-
// reported as a clean file. Only 0 and 2 are runs.
|
|
109
|
-
//
|
|
110
|
-
// #1948: parse through the shared seam so an exit-2 run whose JSON lines
|
|
111
|
-
// yield nothing leaves a record. `parseOutput` keeps the historical
|
|
112
|
-
// split: the gate judges "did it run" on stdout, the parser reads both
|
|
113
|
-
// streams.
|
|
114
|
-
const run = parseToolRun("spellcheck", { result, exitCodes: TYPOS_EXIT_CODES }, (out) => parseTyposOutput(out, ctx.filePath, cwd), { parseOutput: `${result.stdout ?? ""}${result.stderr ?? ""}` });
|
|
115
|
-
if (run.skipped)
|
|
116
|
-
return run.skipped;
|
|
117
|
-
const diagnostics = run.diagnostics;
|
|
118
|
-
if (diagnostics.length === 0) {
|
|
119
|
-
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
status: "failed",
|
|
123
|
-
diagnostics,
|
|
124
|
-
semantic: "warning",
|
|
125
|
-
};
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
export default spellcheckRunner;
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as os from "node:os";
|
|
3
|
-
import * as path from "node:path";
|
|
4
|
-
import { BoundedLruCache } from "../../bounded-cache.js";
|
|
5
|
-
import { safeSpawnAsync } from "../../safe-spawn.js";
|
|
6
|
-
import { resolveRunnerCwd } from "../../tool-cwd.js";
|
|
7
|
-
import { findCompiledClassesDir } from "../../tool-policy.js";
|
|
8
|
-
import { PRIORITY } from "../priorities.js";
|
|
9
|
-
import { createAvailabilityChecker, resolveAvailableOrInstall, } from "./utils/runner-helpers.js";
|
|
10
|
-
// SpotBugs is a JVM tool installed via the archive strategy (#133); java gates
|
|
11
|
-
// it (no JRE → skip). It analyzes the *bytecode tree*, not the edited source.
|
|
12
|
-
const java = createAvailabilityChecker("java", ".exe", ["-version"]);
|
|
13
|
-
const spotbugs = createAvailabilityChecker("spotbugs", ".bat", ["-version"]);
|
|
14
|
-
const MAX_DIAGNOSTICS = 50;
|
|
15
|
-
const MAX_XML_BYTES = 4 * 1024 * 1024;
|
|
16
|
-
const scanCache = new BoundedLruCache(32);
|
|
17
|
-
/** Reset the SpotBugs scan cache (tests). */
|
|
18
|
-
export function _resetSpotbugsCacheForTests() {
|
|
19
|
-
scanCache.clear();
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Cheap signature of the compiled-classes tree: count + newest mtime of all
|
|
23
|
-
* `.class` files. Changes iff the user rebuilt, which is exactly when SpotBugs
|
|
24
|
-
* should re-run.
|
|
25
|
-
*/
|
|
26
|
-
function classesSignature(classesDir) {
|
|
27
|
-
let count = 0;
|
|
28
|
-
let newest = 0;
|
|
29
|
-
const stack = [classesDir];
|
|
30
|
-
// Bounded walk — large class trees are fine (count is cheap), but cap depth
|
|
31
|
-
// of the stack defensively.
|
|
32
|
-
while (stack.length > 0) {
|
|
33
|
-
const dir = stack.pop();
|
|
34
|
-
if (!dir)
|
|
35
|
-
break;
|
|
36
|
-
let entries;
|
|
37
|
-
try {
|
|
38
|
-
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
for (const entry of entries) {
|
|
44
|
-
const full = path.join(dir, entry.name);
|
|
45
|
-
if (entry.isDirectory()) {
|
|
46
|
-
stack.push(full);
|
|
47
|
-
}
|
|
48
|
-
else if (entry.isFile() && entry.name.endsWith(".class")) {
|
|
49
|
-
count++;
|
|
50
|
-
try {
|
|
51
|
-
const m = fs.statSync(full).mtimeMs;
|
|
52
|
-
if (m > newest)
|
|
53
|
-
newest = m;
|
|
54
|
-
}
|
|
55
|
-
catch { }
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return `${count}:${newest}`;
|
|
60
|
-
}
|
|
61
|
-
// SpotBugs bug categories → pi-lens defect taxonomy (per #133).
|
|
62
|
-
function mapCategory(category) {
|
|
63
|
-
switch (category.toUpperCase()) {
|
|
64
|
-
case "CORRECTNESS":
|
|
65
|
-
case "MT_CORRECTNESS":
|
|
66
|
-
return "correctness";
|
|
67
|
-
case "SECURITY":
|
|
68
|
-
return "safety";
|
|
69
|
-
case "PERFORMANCE":
|
|
70
|
-
case "BAD_PRACTICE":
|
|
71
|
-
case "STYLE":
|
|
72
|
-
case "I18N":
|
|
73
|
-
case "EXPERIMENTAL":
|
|
74
|
-
return "style";
|
|
75
|
-
default:
|
|
76
|
-
// Unmapped SpotBugs categories are still bug patterns — treat as correctness.
|
|
77
|
-
return "correctness";
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function mapSeverity(priority) {
|
|
81
|
-
switch (priority) {
|
|
82
|
-
case "1":
|
|
83
|
-
return "error";
|
|
84
|
-
case "3":
|
|
85
|
-
return "info";
|
|
86
|
-
default:
|
|
87
|
-
return "warning";
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function attr(attrs, name) {
|
|
91
|
-
// Bounded, non-backtracking: a single negated-char class, no nesting (S5852-safe).
|
|
92
|
-
const m = new RegExp(`\\b${name}="([^"]*)"`).exec(attrs);
|
|
93
|
-
return m ? m[1] : undefined;
|
|
94
|
-
}
|
|
95
|
-
function firstSentence(text) {
|
|
96
|
-
const trimmed = text.replace(/\s+/g, " ").trim();
|
|
97
|
-
const dot = trimmed.indexOf(". ");
|
|
98
|
-
return (dot > 0 ? trimmed.slice(0, dot + 1) : trimmed).slice(0, 300);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Parse SpotBugs `-xml:withMessages` output. Hand-rolled (no XML dep, zero-dep
|
|
102
|
-
* ethos) but bounded: input capped, lazy `<BugInstance>…</BugInstance>` blocks
|
|
103
|
-
* (no nested quantifiers), diagnostics capped.
|
|
104
|
-
*/
|
|
105
|
-
export function parseSpotbugsXml(raw) {
|
|
106
|
-
const xml = raw.length > MAX_XML_BYTES ? raw.slice(0, MAX_XML_BYTES) : raw;
|
|
107
|
-
const diagnostics = [];
|
|
108
|
-
const blockRe = /<BugInstance\b([^>]*)>([\s\S]*?)<\/BugInstance>/g;
|
|
109
|
-
let block;
|
|
110
|
-
let index = 0;
|
|
111
|
-
// biome-ignore lint/suspicious/noAssignInExpressions: standard regex-exec loop
|
|
112
|
-
while ((block = blockRe.exec(xml)) !== null) {
|
|
113
|
-
if (diagnostics.length >= MAX_DIAGNOSTICS)
|
|
114
|
-
break;
|
|
115
|
-
const headAttrs = block[1];
|
|
116
|
-
const body = block[2];
|
|
117
|
-
const type = attr(headAttrs, "type") || "SPOTBUGS";
|
|
118
|
-
const priority = attr(headAttrs, "priority") || "2";
|
|
119
|
-
const category = attr(headAttrs, "category") || "CORRECTNESS";
|
|
120
|
-
// A BugInstance has several SourceLines: class span, method span, and the
|
|
121
|
-
// primary (the actual defect location, marked primary="true"). Prefer the
|
|
122
|
-
// primary; otherwise the last one (most specific), else the first.
|
|
123
|
-
let filePath;
|
|
124
|
-
let line = 1;
|
|
125
|
-
const slRe = /<SourceLine\b([^>]*?)\/?>/g;
|
|
126
|
-
let sl;
|
|
127
|
-
// biome-ignore lint/suspicious/noAssignInExpressions: standard regex-exec loop
|
|
128
|
-
while ((sl = slRe.exec(body)) !== null) {
|
|
129
|
-
const slAttrs = sl[1];
|
|
130
|
-
const start = attr(slAttrs, "start");
|
|
131
|
-
const sourcepath = attr(slAttrs, "sourcepath");
|
|
132
|
-
const sourcefile = attr(slAttrs, "sourcefile");
|
|
133
|
-
if (!start || !(sourcepath || sourcefile))
|
|
134
|
-
continue;
|
|
135
|
-
filePath = sourcepath || sourcefile;
|
|
136
|
-
line = Number(start) || 1;
|
|
137
|
-
if (attr(slAttrs, "primary") === "true")
|
|
138
|
-
break; // the defect location
|
|
139
|
-
}
|
|
140
|
-
if (!filePath)
|
|
141
|
-
continue; // no source mapping — skip (can't surface usefully)
|
|
142
|
-
const longMsgMatch = /<LongMessage>([\s\S]*?)<\/LongMessage>/.exec(body);
|
|
143
|
-
const shortMsgMatch = /<ShortMessage>([\s\S]*?)<\/ShortMessage>/.exec(body);
|
|
144
|
-
const longMsg = longMsgMatch
|
|
145
|
-
? decodeXmlEntities(longMsgMatch[1].trim())
|
|
146
|
-
: "";
|
|
147
|
-
const shortMsg = shortMsgMatch
|
|
148
|
-
? decodeXmlEntities(shortMsgMatch[1].trim())
|
|
149
|
-
: "";
|
|
150
|
-
const message = shortMsg || longMsg || type;
|
|
151
|
-
const fixSuggestion = longMsg ? firstSentence(longMsg) : undefined;
|
|
152
|
-
diagnostics.push({
|
|
153
|
-
id: `spotbugs:${type}:${path.basename(filePath)}:${line}:${index}`,
|
|
154
|
-
message: `[${type}] ${message}`,
|
|
155
|
-
filePath,
|
|
156
|
-
line,
|
|
157
|
-
column: 1,
|
|
158
|
-
severity: mapSeverity(priority),
|
|
159
|
-
// Bug patterns are advisory by default (not always exploitable); a user
|
|
160
|
-
// can promote to blocking via config. So semantic stays "warning".
|
|
161
|
-
semantic: "warning",
|
|
162
|
-
tool: "spotbugs",
|
|
163
|
-
rule: type,
|
|
164
|
-
defectClass: mapCategory(category),
|
|
165
|
-
fixable: false,
|
|
166
|
-
autoFixAvailable: false,
|
|
167
|
-
fixKind: fixSuggestion ? "suggestion" : undefined,
|
|
168
|
-
fixSuggestion,
|
|
169
|
-
});
|
|
170
|
-
index++;
|
|
171
|
-
}
|
|
172
|
-
return diagnostics;
|
|
173
|
-
}
|
|
174
|
-
function decodeXmlEntities(s) {
|
|
175
|
-
return s
|
|
176
|
-
.replace(/</g, "<")
|
|
177
|
-
.replace(/>/g, ">")
|
|
178
|
-
.replace(/"/g, '"')
|
|
179
|
-
.replace(/'/g, "'")
|
|
180
|
-
.replace(/&/g, "&");
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* SpotBugs bytecode bug-pattern analyzer for Java + Kotlin (#133).
|
|
184
|
-
*
|
|
185
|
-
* Opt-in (lens-spotbugs flag) and gated via the withSpotbugsGroup dispatch
|
|
186
|
-
* group, which only adds it when a Java build descriptor + compiled .class dir
|
|
187
|
-
* exist. Operates on the compiled tree, NOT the edited source, and only
|
|
188
|
-
* re-invokes after a rebuild (mtime-cached).
|
|
189
|
-
*/
|
|
190
|
-
const spotbugsRunner = {
|
|
191
|
-
id: "spotbugs",
|
|
192
|
-
appliesTo: ["java", "kotlin"],
|
|
193
|
-
priority: PRIORITY.DEEP_LANGUAGE_ANALYSIS,
|
|
194
|
-
async run(ctx) {
|
|
195
|
-
const cwd = resolveRunnerCwd(ctx, "spotbugs");
|
|
196
|
-
const classesDir = findCompiledClassesDir(cwd);
|
|
197
|
-
if (!classesDir) {
|
|
198
|
-
ctx.log?.("spotbugs: Java project detected but no compiled .class files found — run `mvn compile` / `gradle build` first");
|
|
199
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
200
|
-
}
|
|
201
|
-
// JRE required — skip silently if absent (SpotBugs needs JDK 11+).
|
|
202
|
-
if (!(await java.isAvailableAsync(cwd))) {
|
|
203
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
204
|
-
}
|
|
205
|
-
// Cache gate: re-run only when the .class tree changed since last scan.
|
|
206
|
-
const signature = classesSignature(classesDir);
|
|
207
|
-
const cached = scanCache.get(classesDir);
|
|
208
|
-
if (cached && cached.signature === signature) {
|
|
209
|
-
return {
|
|
210
|
-
status: "succeeded",
|
|
211
|
-
diagnostics: cached.diagnostics,
|
|
212
|
-
semantic: cached.diagnostics.length > 0 ? "warning" : "none",
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
const cmd = await resolveAvailableOrInstall(spotbugs, "spotbugs", cwd);
|
|
216
|
-
if (!cmd)
|
|
217
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
218
|
-
const tmpXml = path.join(os.tmpdir(), `pi-lens-spotbugs-${process.pid}-${Date.now()}.xml`);
|
|
219
|
-
const result = await safeSpawnAsync(cmd, [
|
|
220
|
-
"-textui",
|
|
221
|
-
"-xml:withMessages",
|
|
222
|
-
"-low",
|
|
223
|
-
"-longBugCodes",
|
|
224
|
-
"-output",
|
|
225
|
-
tmpXml,
|
|
226
|
-
classesDir,
|
|
227
|
-
], { cwd, timeout: 120000 });
|
|
228
|
-
let xml = "";
|
|
229
|
-
try {
|
|
230
|
-
xml = fs.readFileSync(tmpXml, "utf8");
|
|
231
|
-
}
|
|
232
|
-
catch {
|
|
233
|
-
// No output file — if the run errored, surface a soft failure.
|
|
234
|
-
if (result.error || (result.status ?? 0) > 1) {
|
|
235
|
-
return {
|
|
236
|
-
status: "failed",
|
|
237
|
-
diagnostics: [],
|
|
238
|
-
semantic: "none",
|
|
239
|
-
rawOutput: (result.stderr || "").slice(0, 500),
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
243
|
-
}
|
|
244
|
-
finally {
|
|
245
|
-
try {
|
|
246
|
-
fs.rmSync(tmpXml, { force: true });
|
|
247
|
-
}
|
|
248
|
-
catch { }
|
|
249
|
-
}
|
|
250
|
-
const diagnostics = parseSpotbugsXml(xml);
|
|
251
|
-
scanCache.set(classesDir, { signature, diagnostics });
|
|
252
|
-
return {
|
|
253
|
-
status: "succeeded",
|
|
254
|
-
diagnostics,
|
|
255
|
-
semantic: diagnostics.length > 0 ? "warning" : "none",
|
|
256
|
-
};
|
|
257
|
-
},
|
|
258
|
-
};
|
|
259
|
-
export default spotbugsRunner;
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import * as path from "node:path";
|
|
2
|
-
import { pathsEqual } from "../../path-utils.js";
|
|
3
|
-
import { safeSpawnAsync } from "../../safe-spawn.js";
|
|
4
|
-
import { logRunnerAdvisoryOnce, resolveRunnerCwd } from "../../tool-cwd.js";
|
|
5
|
-
import { getLinterPolicyForCwd, hasSqlfluffConfig } from "../../tool-policy.js";
|
|
6
|
-
import { PRIORITY } from "../priorities.js";
|
|
7
|
-
import { createAvailabilityChecker, resolveToolCommandWithInstallFallback, } from "./utils/runner-helpers.js";
|
|
8
|
-
import { parseToolRun } from "./utils/tool-failure.js";
|
|
9
|
-
import { finishParsedRun } from "./utils/tool-failure.js";
|
|
10
|
-
const sqlfluff = createAvailabilityChecker("sqlfluff", ".exe");
|
|
11
|
-
// sqlfluff exit codes (its CLI docs): 0 = clean, 1 = violations found, 2 = a
|
|
12
|
-
// user error that stopped the lint (unknown dialect, unreadable config).
|
|
13
|
-
// Only 2 is a rejected invocation.
|
|
14
|
-
//
|
|
15
|
-
// The exit TABLE is what protects this runner, not the nothing-to-parse rule:
|
|
16
|
-
// EXIT TABLE (SQLFluff 3.1 docs https://docs.sqlfluff.com/en/stable/production.html): 0 clean; 1 findings/error; other nonzero rejected.
|
|
17
|
-
// sqlfluff writes its user errors to STDOUT, not stderr (live: an unknown
|
|
18
|
-
// dialect prints the error there), so stdout is non-empty and the fallback
|
|
19
|
-
// rule would read the failed run as a run that found nothing.
|
|
20
|
-
const SQLFLUFF_EXIT_CODES = { ran: [1] };
|
|
21
|
-
export { hasSqlfluffConfig };
|
|
22
|
-
// sqlfluff's JSON lint output does not carry a per-violation fixable flag —
|
|
23
|
-
// `sqlfluff fix` is a separate command and the lint surface doesn't tell us
|
|
24
|
-
// which violations its `--fix` would resolve. Mirror the stylelint /
|
|
25
|
-
// markdownlint pattern from commit 9c8db1b: maintain a curated set of rule
|
|
26
|
-
// codes whose `fix` is deterministic and safe, sourced from sqlfluff's docs
|
|
27
|
-
// pages that document each rule as "Auto-fix: yes" with a deterministic
|
|
28
|
-
// rewrite. Update when sqlfluff adds or removes fixable rules.
|
|
29
|
-
//
|
|
30
|
-
// Scope: layout / capitalisation / safe-convention / alias-formatting /
|
|
31
|
-
// reference-formatting rules whose fixes don't change query semantics.
|
|
32
|
-
// Excluded: ambiguity rules (AM01..), structural rules whose fix may
|
|
33
|
-
// change query plan (ST05, ST07..), and CV05 (which can flip null
|
|
34
|
-
// comparisons in ways that change result sets).
|
|
35
|
-
const SQLFLUFF_FIXABLE_RULES = new Set([
|
|
36
|
-
// Layout — pure formatting
|
|
37
|
-
"LT01",
|
|
38
|
-
"LT02",
|
|
39
|
-
"LT03",
|
|
40
|
-
"LT04",
|
|
41
|
-
"LT05",
|
|
42
|
-
"LT06",
|
|
43
|
-
"LT07",
|
|
44
|
-
"LT08",
|
|
45
|
-
"LT09",
|
|
46
|
-
"LT10",
|
|
47
|
-
"LT11",
|
|
48
|
-
"LT12",
|
|
49
|
-
"LT13",
|
|
50
|
-
// Capitalisation — pure formatting
|
|
51
|
-
"CP01",
|
|
52
|
-
"CP02",
|
|
53
|
-
"CP03",
|
|
54
|
-
"CP04",
|
|
55
|
-
"CP05",
|
|
56
|
-
// Aliasing — safe formatting / unused-alias removal
|
|
57
|
-
"AL01",
|
|
58
|
-
"AL05",
|
|
59
|
-
"AL06",
|
|
60
|
-
"AL07",
|
|
61
|
-
"AL08",
|
|
62
|
-
"AL09",
|
|
63
|
-
// Convention — safe formatting / equivalent rewrites
|
|
64
|
-
"CV01",
|
|
65
|
-
"CV02",
|
|
66
|
-
"CV06",
|
|
67
|
-
"CV07",
|
|
68
|
-
"CV10",
|
|
69
|
-
"CV11",
|
|
70
|
-
// References — quoting / qualifier formatting
|
|
71
|
-
"RF02",
|
|
72
|
-
"RF04",
|
|
73
|
-
"RF05",
|
|
74
|
-
"RF06",
|
|
75
|
-
// Structure — only deterministic-safe simplifications
|
|
76
|
-
"ST01",
|
|
77
|
-
"ST02",
|
|
78
|
-
]);
|
|
79
|
-
function parseSqlfluffOutput(raw, filePath, cwd) {
|
|
80
|
-
if (!raw.trim())
|
|
81
|
-
return [];
|
|
82
|
-
try {
|
|
83
|
-
const parsed = JSON.parse(raw);
|
|
84
|
-
if (!Array.isArray(parsed))
|
|
85
|
-
return [];
|
|
86
|
-
const diagnostics = [];
|
|
87
|
-
const absTarget = path.resolve(cwd, filePath);
|
|
88
|
-
for (const item of parsed) {
|
|
89
|
-
// #3295: sqlfluff's JSON is an array of FILES; a jinja `{% include %}`
|
|
90
|
-
// or a directory argv puts a second one in it.
|
|
91
|
-
if (item.filepath &&
|
|
92
|
-
!pathsEqual(path.resolve(cwd, item.filepath), absTarget))
|
|
93
|
-
continue;
|
|
94
|
-
for (const v of item.violations ?? []) {
|
|
95
|
-
if (!v.description)
|
|
96
|
-
continue;
|
|
97
|
-
const code = v.code ?? "SQL";
|
|
98
|
-
const fixable = SQLFLUFF_FIXABLE_RULES.has(code);
|
|
99
|
-
diagnostics.push({
|
|
100
|
-
id: `sqlfluff-${v.line_no ?? 1}-${v.line_pos ?? 1}-${code}`,
|
|
101
|
-
message: `[${code}] ${v.description}`,
|
|
102
|
-
filePath,
|
|
103
|
-
line: v.line_no ?? 1,
|
|
104
|
-
column: v.line_pos ?? 1,
|
|
105
|
-
severity: "warning",
|
|
106
|
-
semantic: "warning",
|
|
107
|
-
tool: "sqlfluff",
|
|
108
|
-
rule: code,
|
|
109
|
-
fixable,
|
|
110
|
-
fixSuggestion: fixable
|
|
111
|
-
? "Run `sqlfluff fix` to apply the deterministic auto-correction for this rule."
|
|
112
|
-
: undefined,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return diagnostics;
|
|
117
|
-
}
|
|
118
|
-
catch {
|
|
119
|
-
return [];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// Exported for the parser unit tests (#112 sqlfluff slice).
|
|
123
|
-
export { parseSqlfluffOutput };
|
|
124
|
-
const sqlfluffRunner = {
|
|
125
|
-
id: "sqlfluff",
|
|
126
|
-
appliesTo: ["sql"],
|
|
127
|
-
priority: PRIORITY.SQL_LINT,
|
|
128
|
-
skipTestFiles: false,
|
|
129
|
-
async run(ctx) {
|
|
130
|
-
const cwd = resolveRunnerCwd(ctx, "sqlfluff");
|
|
131
|
-
const policy = getLinterPolicyForCwd(ctx.filePath, cwd);
|
|
132
|
-
if (policy && !policy.preferredRunners.includes("sqlfluff")) {
|
|
133
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
134
|
-
}
|
|
135
|
-
const hasConfig = hasSqlfluffConfig(cwd);
|
|
136
|
-
if (!hasConfig) {
|
|
137
|
-
logRunnerAdvisoryOnce(ctx, "sqlfluff", cwd, "sqlfluff: no config detected, using ANSI dialect defaults");
|
|
138
|
-
}
|
|
139
|
-
let cmd = null;
|
|
140
|
-
if (await sqlfluff.isAvailableAsync(cwd)) {
|
|
141
|
-
cmd = sqlfluff.getCommand(cwd);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
cmd = await resolveToolCommandWithInstallFallback(cwd, "sqlfluff");
|
|
145
|
-
}
|
|
146
|
-
if (!cmd)
|
|
147
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
148
|
-
// #1937: this used to be `args.splice(2, 0, "--dialect", "ansi")` on
|
|
149
|
-
// `["lint", "--format", "json", file]`, which inserts BETWEEN the flag
|
|
150
|
-
// and its value and yields `lint --format --dialect ansi json file`.
|
|
151
|
-
// sqlfluff rejects `--dialect` as the value of `--format` and exits 2,
|
|
152
|
-
// so every SQL project WITHOUT a .sqlfluff — exactly the case this
|
|
153
|
-
// dialect default exists to serve — was never linted. Built in order
|
|
154
|
-
// rather than patched by index, and pinned by the argv-tie assertion
|
|
155
|
-
// in runners/captured-real-output.test.ts.
|
|
156
|
-
const args = ["lint", "--format", "json"];
|
|
157
|
-
if (!hasConfig) {
|
|
158
|
-
args.push("--dialect", "ansi");
|
|
159
|
-
}
|
|
160
|
-
args.push(ctx.filePath);
|
|
161
|
-
const result = await safeSpawnAsync(cmd, args, {
|
|
162
|
-
timeout: 20000,
|
|
163
|
-
cwd,
|
|
164
|
-
});
|
|
165
|
-
// #1816: this runner read `result.status` zero times, so a user error
|
|
166
|
-
// fell through `parseSqlfluffOutput`'s JSON catch to zero violations and
|
|
167
|
-
// reported the SQL file as clean.
|
|
168
|
-
// #1948: sqlfluff exit 1 with a JSON report we read nothing out of is a
|
|
169
|
-
// parser break, not a clean file.
|
|
170
|
-
const run = parseToolRun("sqlfluff", { result, exitCodes: SQLFLUFF_EXIT_CODES }, (out) => parseSqlfluffOutput(out, ctx.filePath, cwd), { parseOutput: result.stdout ?? "" });
|
|
171
|
-
if (run.skipped)
|
|
172
|
-
return run.skipped;
|
|
173
|
-
const diagnostics = run.diagnostics;
|
|
174
|
-
return finishParsedRun({
|
|
175
|
-
tool: "sqlfluff",
|
|
176
|
-
ctx,
|
|
177
|
-
result,
|
|
178
|
-
diagnostics,
|
|
179
|
-
classify: () => ({ status: "failed", semantic: "warning" }),
|
|
180
|
-
});
|
|
181
|
-
},
|
|
182
|
-
};
|
|
183
|
-
export default sqlfluffRunner;
|