pi-lens 4.4.3 → 4.4.5
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 +721 -0
- package/README.md +25 -3
- package/config/dependency-cruiser-eager-allowlist.json +1 -0
- package/dist/chunk-22Y2BM7H.js +23 -0
- package/dist/{chunk-WU567RSC.js → chunk-27VWVB23.js} +16 -14
- package/dist/{chunk-FLKWCIZH.js → chunk-2FYKETQJ.js} +10 -6
- package/dist/{chunk-MQLUAEOC.js → chunk-2LDMXL2M.js} +2 -2
- package/dist/{chunk-YSZNHOBY.js → chunk-2SDHYHHO.js} +17 -17
- package/dist/chunk-2Y6OJRSI.js +38 -0
- package/dist/chunk-3SNDVPOR.js +507 -0
- package/dist/{chunk-EJIUXPBX.js → chunk-3WCEHYOI.js} +1 -1
- package/dist/chunk-44X7VIKR.js +73 -0
- package/dist/{chunk-Q7DUK4LX.js → chunk-4FHUGDKU.js} +16 -14
- package/dist/{chunk-H6MF6EVN.js → chunk-4ODSZ35Z.js} +1498 -534
- package/dist/{chunk-ZGDGW2V3.js → chunk-4U7GDSZQ.js} +2 -2
- package/dist/chunk-54NIOJJZ.js +25 -0
- package/dist/{chunk-ZWFS3OEF.js → chunk-5DKE4HGX.js} +38 -37
- package/dist/{chunk-VRZP76YM.js → chunk-5LRUKYFA.js} +34 -4
- package/dist/{chunk-QOBUHWHX.js → chunk-63NMUNYP.js} +12 -16
- package/dist/{chunk-VWCXW2E7.js → chunk-6XSESGWD.js} +13 -6
- package/dist/{chunk-QGQ5CCCG.js → chunk-72J27ICO.js} +2 -3
- package/dist/{chunk-CSHFH5IN.js → chunk-7FLRUH6B.js} +1 -1
- package/dist/chunk-7IYC4ENJ.js +297 -0
- package/dist/chunk-7WWQAW5P.js +30 -0
- package/dist/{chunk-EU63SDCG.js → chunk-7ZS7MC24.js} +885 -451
- package/dist/{chunk-KBG47GHP.js → chunk-AHWA4AKM.js} +18 -12
- package/dist/{chunk-FMSO6RDZ.js → chunk-AI3GP74G.js} +17 -19
- package/dist/chunk-APFJKOP6.js +67 -0
- package/dist/{chunk-RXCOMYPY.js → chunk-ASRAO7KG.js} +31 -33
- package/dist/{chunk-BW5KFIQC.js → chunk-AWQWXSW4.js} +1 -0
- package/dist/{chunk-QILIYSJF.js → chunk-CG5V25HX.js} +1 -1
- package/dist/chunk-CKEQFGLT.js +32 -0
- package/dist/{chunk-RPLINGVB.js → chunk-COOUUC5W.js} +6 -6
- package/dist/{chunk-GBPP5P7X.js → chunk-CPZ5JJW6.js} +4 -4
- package/dist/{chunk-OCAGUNBC.js → chunk-DS2USX5G.js} +13 -15
- package/dist/chunk-EA2ZRG44.js +27 -0
- package/dist/{chunk-ZHFZWTZV.js → chunk-EDMLIW6W.js} +13 -14
- package/dist/{chunk-2EECBNC5.js → chunk-EIKRZ32J.js} +75 -0
- package/dist/chunk-EKNWOL2I.js +27 -0
- package/dist/{chunk-CMMHNUZ2.js → chunk-ELZRSR5N.js} +65 -43
- package/dist/{chunk-BKE7E7TC.js → chunk-EN5AM7PX.js} +11 -12
- package/dist/{chunk-N2H3ZPZY.js → chunk-EWXXLS26.js} +227 -24
- package/dist/chunk-EX4EXBW7.js +37 -0
- package/dist/{chunk-YYOIQFRS.js → chunk-EXVXBSGN.js} +130 -52
- package/dist/{chunk-6GFRNVYR.js → chunk-F7BO6FWH.js} +12 -13
- package/dist/chunk-FEDWAYDS.js +2485 -0
- package/dist/{chunk-JAU72XNY.js → chunk-FWZRGGGY.js} +73 -9
- package/dist/{chunk-GXW6K4YJ.js → chunk-G224FADB.js} +1 -1
- package/dist/chunk-G5UCJFT7.js +26 -0
- package/dist/{chunk-67WMNWEE.js → chunk-GLW3YDZZ.js} +22 -13
- package/dist/{chunk-724UL2TJ.js → chunk-GTDSYEA2.js} +72 -39
- package/dist/{chunk-PHDMFAKM.js → chunk-GYRZ72R4.js} +10 -4
- package/dist/chunk-HYVXA3BB.js +49 -0
- package/dist/{chunk-SAEFPSB6.js → chunk-IEBJF3PN.js} +23 -15
- package/dist/chunk-IJYGIDF4.js +186 -0
- package/dist/{chunk-ACXEQZOU.js → chunk-IL7K66ZQ.js} +101 -109
- package/dist/{chunk-ZXYDQ3TZ.js → chunk-JWOVP5BL.js} +50 -19
- package/dist/{chunk-OXXKQCSV.js → chunk-K2GUZ4DN.js} +4 -4
- package/dist/{chunk-AW7R2GWG.js → chunk-K4SZB56V.js} +39 -39
- package/dist/{chunk-WOA4LN2R.js → chunk-KCBRHV5E.js} +3 -3
- package/dist/{chunk-3W7IEVVL.js → chunk-KFXCL4OV.js} +47 -45
- package/dist/{chunk-2BBLFX75.js → chunk-KJJAVH3X.js} +81 -15
- package/dist/{chunk-VCHXCQFG.js → chunk-KPVLQHCZ.js} +4 -6
- package/dist/{chunk-P7266HLM.js → chunk-KX56K73G.js} +10 -13
- package/dist/{chunk-VSSBEUFT.js → chunk-LMCTHJ2H.js} +19 -19
- package/dist/{chunk-IBGIOBEE.js → chunk-MEFLGBCS.js} +69 -8
- package/dist/{chunk-TYM6OUIT.js → chunk-MKPCELNI.js} +17 -17
- package/dist/{chunk-XTMJ7XDT.js → chunk-N3PLNNCW.js} +1 -1
- package/dist/chunk-N5FBM25N.js +22 -0
- package/dist/{chunk-CHOW74WE.js → chunk-NFNVDDGB.js} +7 -12
- package/dist/{chunk-52FUZI6K.js → chunk-NLIVE7L6.js} +2 -30
- package/dist/{chunk-SS36ZX4J.js → chunk-OMJ3OFBJ.js} +6 -6
- package/dist/{chunk-4W4VLAPJ.js → chunk-OZNCKLOX.js} +13 -14
- package/dist/chunk-P5XUGPIX.js +31 -0
- package/dist/{chunk-5UCAH366.js → chunk-PJXNTPB2.js} +253 -33
- package/dist/chunk-PKOXJIVT.js +88 -0
- package/dist/{chunk-6C7JWPCP.js → chunk-PP2A5V2T.js} +27 -26
- package/dist/{chunk-L3BLXZG7.js → chunk-Q42LJANT.js} +31 -70
- package/dist/{chunk-AB3YYG6N.js → chunk-Q4BKKOVC.js} +8 -8
- package/dist/{chunk-3EFKIGZN.js → chunk-QT66NEYN.js} +4 -4
- package/dist/{chunk-3VPVG5SU.js → chunk-RCHO5W7M.js} +19 -18
- package/dist/{chunk-77M37OKR.js → chunk-RG3MXTRI.js} +7 -7
- package/dist/chunk-RG7OODGM.js +57 -0
- package/dist/{chunk-T6CPIZNT.js → chunk-RU34BA4D.js} +44 -39
- package/dist/{chunk-JMYYOTQG.js → chunk-S26LC76R.js} +13 -1
- package/dist/{chunk-5NGR67U5.js → chunk-S55TEC7I.js} +33 -5
- package/dist/{chunk-M6HSLBWY.js → chunk-SJHC3BCZ.js} +7956 -8047
- package/dist/{chunk-XCJN5IJU.js → chunk-SNEUMLM7.js} +4 -4
- package/dist/{chunk-UZ3TUTRV.js → chunk-T4NGVFYI.js} +2 -2
- package/dist/{chunk-2VUQMUMT.js → chunk-THEXI2QO.js} +49 -43
- package/dist/{chunk-R3PCY3YS.js → chunk-TL2TCJYL.js} +15 -16
- package/dist/{chunk-C34ZXZ7O.js → chunk-TPYYEDP5.js} +838 -352
- package/dist/{chunk-AOHZU2BM.js → chunk-TVZRLTG6.js} +8 -1
- package/dist/{chunk-XMSXXAHW.js → chunk-UCVMSOXF.js} +2 -2
- package/dist/chunk-UL5SXQVX.js +32 -0
- package/dist/{chunk-GAEGEPOC.js → chunk-UO66IMVP.js} +2 -2
- package/dist/{chunk-N3X6Q4YT.js → chunk-UVY4TOJH.js} +3 -3
- package/dist/{chunk-2CD5RS6M.js → chunk-VIDEKABZ.js} +23 -2
- package/dist/{chunk-JSQFTSC6.js → chunk-VITFDI3O.js} +13 -14
- package/dist/{chunk-YIUAVF7E.js → chunk-VUAVE3QC.js} +42 -42
- package/dist/{chunk-QOZXJ4NA.js → chunk-WUY4BZEP.js} +21 -20
- package/dist/{chunk-VCO24T4L.js → chunk-X3UTCXAA.js} +43 -53
- package/dist/chunk-XHDBJODR.js +45 -0
- package/dist/{chunk-MXGY6KPT.js → chunk-XHLK33VM.js} +28 -21
- package/dist/{chunk-RWWYJ623.js → chunk-XI34NWDI.js} +2 -2
- package/dist/{chunk-QQNQ7SJW.js → chunk-XWFIHYCH.js} +12 -4
- package/dist/{chunk-6SDEP3AJ.js → chunk-Y2TPADJR.js} +10 -11
- package/dist/{chunk-MRXKYPCS.js → chunk-Y5KTA2OB.js} +17 -17
- package/dist/{chunk-7DYBLXYA.js → chunk-YKVDBNPO.js} +11 -5
- package/dist/{chunk-2B73ZPOK.js → chunk-YSDPVDFC.js} +3 -3
- package/dist/chunk-YWNO5Q4R.js +44 -0
- package/dist/{chunk-QHJ6DQ2R.js → chunk-YWWG4AQA.js} +165 -32
- package/dist/{chunk-3JNKMP3B.js → chunk-YXDCRUKQ.js} +4 -4
- package/dist/{chunk-UXGETRP4.js → chunk-YXGRRORB.js} +16 -17
- package/dist/{chunk-SQ4TVJBR.js → chunk-ZAPSUBLU.js} +13 -7
- package/dist/{chunk-76MWC2K6.js → chunk-ZPJM7DID.js} +90 -97
- package/dist/{chunk-XVF2VVXP.js → chunk-ZSUX7KEM.js} +16 -15
- package/dist/index.js +31038 -20893
- package/dist/mcp/analyze-cli.js +11 -11
- package/dist/mcp/cli.js +47 -43
- package/dist/mcp/server.js +2188 -906
- package/dist/mcp/worker.js +66 -63
- package/dist/probes/installer.js +21 -23
- package/dist/workers/project-snapshot-persist-worker.js +28 -9
- package/dist/workers/review-graph-persist-worker.js +1 -1
- package/docs/adr/0010-trace-validation-session-lifecycle.md +390 -0
- package/docs/adr/README.md +1 -0
- package/docs/ast-grep_rules_catalog.md +5 -3
- package/docs/configuration.md +20 -0
- package/docs/engineering-principles.md +44 -0
- package/docs/environment-variables.md +20 -0
- package/docs/features.md +16 -1
- package/docs/globalconfig.md +37 -8
- package/docs/lsp-capability-matrix.md +105 -12
- package/docs/lsp-idle-eviction.md +44 -36
- package/docs/pi-lens-fixer.md +139 -14
- package/docs/pi-lens-investigator.md +14 -0
- package/docs/pi-lens-merge-policy.md +120 -17
- package/docs/pi-lens-monitor.md +71 -9
- package/docs/pi-lens-retro.md +6 -3
- package/docs/pi-lens-reviewer.md +160 -5
- package/docs/pi-lens-subagent.md +29 -14
- package/docs/release-qa-baseline.md +21 -7
- package/docs/servercapabilities.md +53 -63
- package/docs/settings.md +9 -5
- package/docs/subagent-compat.md +1 -1
- package/docs/usage.md +1 -0
- package/package.json +9 -5
- package/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +17 -0
- package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-js-test.yml +86 -0
- package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-test.yml +86 -0
- package/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +15 -0
- package/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +9 -4
- package/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +119 -0
- package/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +119 -0
- package/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +13 -2
- package/rules/rule-catalog.json +25 -1
- package/scripts/analyze-pi-lens-logs.mjs +15 -5
- package/scripts/download-grammars.js +40 -7
- package/scripts/lib/is-main-module.mjs +27 -0
- package/scripts/lib/latency-log-phases.mjs +95 -0
- package/scripts/lib/scratch-home-env.mjs +21 -0
- package/scripts/rpc-load-check.mjs +568 -81
- package/scripts/warm-loader-cache.mjs +2 -5
- package/dist/chunk-23WOO7TX.js +0 -23
- package/dist/chunk-3YN6V5TV.js +0 -85
- package/dist/chunk-466Z26MG.js +0 -30
- package/dist/chunk-4UNXBNE2.js +0 -24
- package/dist/chunk-6STA6Z7I.js +0 -47
- package/dist/chunk-ABBOA7UD.js +0 -157
- package/dist/chunk-BRGDSBJE.js +0 -28
- package/dist/chunk-EC47DWFA.js +0 -56
- package/dist/chunk-FCSOVF55.js +0 -273
- package/dist/chunk-IZSHAIJ7.js +0 -26
- package/dist/chunk-KDERNTCQ.js +0 -28
- package/dist/chunk-KSX3TXSZ.js +0 -69
- package/dist/chunk-LOP6GRPH.js +0 -31
- package/dist/chunk-PNQDPDRC.js +0 -184
- package/dist/chunk-UOPVJQ4N.js +0 -103
- package/dist/chunk-XAGLWMJ4.js +0 -51
- package/dist/chunk-XIJZVPD5.js +0 -39
- package/dist/chunk-Z3CCVDUB.js +0 -76
- package/dist/chunk-Z527N6YQ.js +0 -28
- package/dist/chunk-ZANLILYD.js +0 -79
- /package/dist/{chunk-FC4RP4I2.js → chunk-6HWVI6MI.js} +0 -0
|
@@ -2,7 +2,7 @@ import { createRequire as __pilensCreateRequire } from "node:module"; const requ
|
|
|
2
2
|
import {
|
|
3
3
|
getLazyInstallAttempt,
|
|
4
4
|
tryLazyInstall
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-K2GUZ4DN.js";
|
|
6
6
|
import {
|
|
7
7
|
findingsResult,
|
|
8
8
|
finishParsedRun,
|
|
@@ -11,24 +11,26 @@ import {
|
|
|
11
11
|
isRunnerClaimSource,
|
|
12
12
|
isRunnerSkipReason,
|
|
13
13
|
parseToolRun,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from "./chunk-FC4RP4I2.js";
|
|
14
|
+
reachedNoVerdict,
|
|
15
|
+
skipUnlessToolRan,
|
|
16
|
+
spanOverlapsModifiedRanges
|
|
17
|
+
} from "./chunk-VIDEKABZ.js";
|
|
19
18
|
import {
|
|
20
19
|
spawnFailedWithNoOutput
|
|
21
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-T4NGVFYI.js";
|
|
21
|
+
import {
|
|
22
|
+
computeImpactCascade
|
|
23
|
+
} from "./chunk-YSDPVDFC.js";
|
|
22
24
|
import {
|
|
23
25
|
goClient
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-UCVMSOXF.js";
|
|
25
27
|
import {
|
|
26
28
|
isTrivyEnabled,
|
|
27
29
|
resolveSeverityFloor
|
|
28
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-RG3MXTRI.js";
|
|
29
31
|
import {
|
|
30
32
|
rustClient
|
|
31
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-Y5KTA2OB.js";
|
|
32
34
|
import {
|
|
33
35
|
coveringLaneAvailable,
|
|
34
36
|
createAvailabilityChecker,
|
|
@@ -44,7 +46,7 @@ import {
|
|
|
44
46
|
resolveToolCommand,
|
|
45
47
|
resolveToolCommandWithInstallFallback,
|
|
46
48
|
resolveVendorToolCommand
|
|
47
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-2SDHYHHO.js";
|
|
48
50
|
import {
|
|
49
51
|
biomeConfigArgs,
|
|
50
52
|
findCompiledClassesDir,
|
|
@@ -63,27 +65,24 @@ import {
|
|
|
63
65
|
hasYamllintConfig,
|
|
64
66
|
markdownlintConfigArgs,
|
|
65
67
|
ruffConfigArgs
|
|
66
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-COOUUC5W.js";
|
|
67
69
|
import {
|
|
68
70
|
importFactProvider
|
|
69
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-SNEUMLM7.js";
|
|
70
72
|
import {
|
|
71
73
|
functionFactProvider
|
|
72
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-ZPJM7DID.js";
|
|
73
75
|
import {
|
|
74
76
|
extractFactsFromTree
|
|
75
|
-
} from "./chunk-
|
|
76
|
-
import {
|
|
77
|
-
computeImpactCascade
|
|
78
|
-
} from "./chunk-2B73ZPOK.js";
|
|
77
|
+
} from "./chunk-G224FADB.js";
|
|
79
78
|
import {
|
|
80
79
|
buildOrUpdateGraph,
|
|
81
80
|
clearReviewGraphWorkspaceCache,
|
|
82
81
|
fileContentProvider
|
|
83
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-EXVXBSGN.js";
|
|
84
83
|
import {
|
|
85
84
|
MAX_BLOCKING_RULE_COMPLEXITY,
|
|
86
|
-
|
|
85
|
+
PRIMARY_UNAVAILABLE_CAUSE,
|
|
87
86
|
applyDispositions,
|
|
88
87
|
applyDispositionsMultiFile,
|
|
89
88
|
buildEffectiveAstGrepCatalog,
|
|
@@ -92,17 +91,18 @@ import {
|
|
|
92
91
|
classifyDiagnostic,
|
|
93
92
|
classifyDiagnosticTier,
|
|
94
93
|
clearPendingAuxiliaryCoverage,
|
|
94
|
+
combinePrimaryUnavailableCauses,
|
|
95
|
+
demoteLanguageServerRows,
|
|
95
96
|
enabledAuxiliaryLspServerIds,
|
|
96
|
-
exceedsLspSyncLimits,
|
|
97
|
-
fetchTsserverProjectIdentity,
|
|
98
97
|
getLSPService,
|
|
99
|
-
getRunnerTimeoutFloorMs,
|
|
100
98
|
hasAnyDispositionMarks,
|
|
101
99
|
hasAuxiliaryLspPublishedForRoot,
|
|
102
100
|
hasPendingAuxiliaryCoverage,
|
|
103
101
|
isOverlyBroadPattern,
|
|
104
102
|
isRuleIgnoredForPath,
|
|
105
103
|
isStructuredRule,
|
|
104
|
+
lineContentHash,
|
|
105
|
+
primaryUnavailableCause,
|
|
106
106
|
recordDiagnostics,
|
|
107
107
|
recordNapiFallbackCoverage,
|
|
108
108
|
recordRunner,
|
|
@@ -110,25 +110,46 @@ import {
|
|
|
110
110
|
touchCoverageGap,
|
|
111
111
|
tryWarmAttachedCodeActions,
|
|
112
112
|
tryWarmAttachedDiagnostics
|
|
113
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-SJHC3BCZ.js";
|
|
114
|
+
import {
|
|
115
|
+
ANY_POSITION,
|
|
116
|
+
retainRecordedFindings
|
|
117
|
+
} from "./chunk-MEFLGBCS.js";
|
|
114
118
|
import {
|
|
115
119
|
mapWithConcurrency
|
|
116
120
|
} from "./chunk-XIMYZ3JA.js";
|
|
117
121
|
import {
|
|
118
122
|
LSP_SERVERS,
|
|
123
|
+
canWriteAnalysisRoot,
|
|
124
|
+
disabledPrimaries,
|
|
119
125
|
getAstGrepRuleSources,
|
|
120
126
|
registerRunnerId,
|
|
121
127
|
resolveAnalysisRoot
|
|
122
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-7ZS7MC24.js";
|
|
123
129
|
import {
|
|
124
130
|
augmentPythonEnvironment,
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
describePythonCompileWithheld,
|
|
132
|
+
detectPythonEnvironment,
|
|
133
|
+
detectPythonTargetVersion,
|
|
134
|
+
emitBounded,
|
|
135
|
+
partitionOutrankedPythonCompileVerdicts,
|
|
136
|
+
recordPythonCompileVerdictDrop
|
|
137
|
+
} from "./chunk-3SNDVPOR.js";
|
|
127
138
|
import {
|
|
128
139
|
loadProjectSnapshot,
|
|
129
140
|
readJsonCache,
|
|
130
141
|
readJsonCacheAsync
|
|
131
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-JWOVP5BL.js";
|
|
143
|
+
import {
|
|
144
|
+
RUNTIME_CONFIG,
|
|
145
|
+
exceedsLspSyncLimits,
|
|
146
|
+
getRunnerTimeoutFloorMs,
|
|
147
|
+
loadAstGrepNapi
|
|
148
|
+
} from "./chunk-FEDWAYDS.js";
|
|
149
|
+
import {
|
|
150
|
+
buildModuleGraph,
|
|
151
|
+
clearModuleGraphCache
|
|
152
|
+
} from "./chunk-CPZ5JJW6.js";
|
|
132
153
|
import {
|
|
133
154
|
BUNDLED_QUERIES_ROOT,
|
|
134
155
|
classifyTreeSitterWasmError,
|
|
@@ -148,44 +169,44 @@ import {
|
|
|
148
169
|
ruleFilesForLanguage,
|
|
149
170
|
ruleSourceLanguages,
|
|
150
171
|
walk
|
|
151
|
-
} from "./chunk-
|
|
172
|
+
} from "./chunk-YWWG4AQA.js";
|
|
152
173
|
import {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
} from "./chunk-GBPP5P7X.js";
|
|
174
|
+
stripAnsi
|
|
175
|
+
} from "./chunk-6HWVI6MI.js";
|
|
156
176
|
import {
|
|
157
177
|
WORD_INDEX_MAX_BYTES,
|
|
158
178
|
deserializeWordIndex,
|
|
159
179
|
logWordIndex,
|
|
160
180
|
removeWordIndexDocumentAsync,
|
|
161
181
|
scheduleWordIndexPersist,
|
|
182
|
+
setWordIndexPublishedListener,
|
|
162
183
|
updateWordIndexDocumentForEdit
|
|
163
|
-
} from "./chunk-
|
|
164
|
-
import {
|
|
165
|
-
PathKeyedMap
|
|
166
|
-
} from "./chunk-Z3CCVDUB.js";
|
|
184
|
+
} from "./chunk-IEBJF3PN.js";
|
|
167
185
|
import {
|
|
168
186
|
WARM_CODE_ACTION_LOOKUP_LIMIT,
|
|
169
|
-
contentHash
|
|
170
|
-
|
|
171
|
-
|
|
187
|
+
contentHash
|
|
188
|
+
} from "./chunk-Q42LJANT.js";
|
|
189
|
+
import {
|
|
190
|
+
resolveRunnerPath,
|
|
191
|
+
toRunnerDisplayPath
|
|
192
|
+
} from "./chunk-APFJKOP6.js";
|
|
172
193
|
import {
|
|
173
194
|
isSpawnableCommand
|
|
174
|
-
} from "./chunk-
|
|
195
|
+
} from "./chunk-IL7K66ZQ.js";
|
|
175
196
|
import {
|
|
176
197
|
logRunnerAdvisoryOnce,
|
|
177
198
|
resolveRunnerCwd,
|
|
178
199
|
resolveRunnerCwdWithReason
|
|
179
|
-
} from "./chunk-
|
|
200
|
+
} from "./chunk-4FHUGDKU.js";
|
|
180
201
|
import {
|
|
181
202
|
findLocalBinUpwards,
|
|
182
203
|
localBinPath
|
|
183
|
-
} from "./chunk-
|
|
204
|
+
} from "./chunk-K4SZB56V.js";
|
|
184
205
|
import {
|
|
185
206
|
createAvailabilityProbeFlight,
|
|
186
207
|
getIsolatedNpxSpawnOptions,
|
|
187
208
|
probeToolAsync
|
|
188
|
-
} from "./chunk-
|
|
209
|
+
} from "./chunk-XI34NWDI.js";
|
|
189
210
|
import {
|
|
190
211
|
classifyProbeFailure,
|
|
191
212
|
createAvailabilityLatch,
|
|
@@ -195,12 +216,12 @@ import {
|
|
|
195
216
|
logAvailabilityDecision,
|
|
196
217
|
startHostStallSampler,
|
|
197
218
|
transientRetryDelayMs
|
|
198
|
-
} from "./chunk-
|
|
219
|
+
} from "./chunk-5LRUKYFA.js";
|
|
199
220
|
import {
|
|
200
221
|
getLspCapableKinds,
|
|
201
222
|
getPrimaryDispatchGroup,
|
|
202
223
|
resolveLanguageRootForFile
|
|
203
|
-
} from "./chunk-
|
|
224
|
+
} from "./chunk-63NMUNYP.js";
|
|
204
225
|
import {
|
|
205
226
|
getGlobalPiLensDir,
|
|
206
227
|
getProjectDataDir,
|
|
@@ -210,57 +231,59 @@ import {
|
|
|
210
231
|
noteSpawnTimeout,
|
|
211
232
|
resolvePiLensFlag,
|
|
212
233
|
safeSpawnAsync
|
|
213
|
-
} from "./chunk-
|
|
234
|
+
} from "./chunk-TPYYEDP5.js";
|
|
214
235
|
import {
|
|
236
|
+
DOTNET_CSHARP_PROJECT_MARKERS,
|
|
237
|
+
DOTNET_CSHARP_SOLUTION_MARKERS,
|
|
215
238
|
detectFileKind
|
|
216
|
-
} from "./chunk-
|
|
239
|
+
} from "./chunk-GYRZ72R4.js";
|
|
217
240
|
import {
|
|
241
|
+
PathKeyedMap,
|
|
218
242
|
classifyGeneratedOrArtifactDetailed,
|
|
219
243
|
detectFileRole,
|
|
220
244
|
loadPiLensProjectConfig,
|
|
221
245
|
resolvePiLensConfig
|
|
222
|
-
} from "./chunk-
|
|
246
|
+
} from "./chunk-KJJAVH3X.js";
|
|
223
247
|
import {
|
|
224
248
|
findNearestDirWithAnyBasename,
|
|
225
249
|
findNearestDirWithMarker,
|
|
226
250
|
getPiLensGlobalConfigPath
|
|
227
|
-
} from "./chunk-
|
|
251
|
+
} from "./chunk-ZSUX7KEM.js";
|
|
228
252
|
import {
|
|
229
253
|
getProjectTrustState,
|
|
230
|
-
projectTrustDenialReason
|
|
231
|
-
} from "./chunk-ZANLILYD.js";
|
|
232
|
-
import {
|
|
233
254
|
killedForOutputCap,
|
|
255
|
+
projectTrustDenialReason,
|
|
234
256
|
truncatedByOutputCap,
|
|
235
257
|
writeFileAtomic
|
|
236
|
-
} from "./chunk-
|
|
258
|
+
} from "./chunk-EIKRZ32J.js";
|
|
237
259
|
import {
|
|
238
260
|
incrementDegradationCount,
|
|
239
261
|
recordDegradationOnce
|
|
240
|
-
} from "./chunk-
|
|
262
|
+
} from "./chunk-FWZRGGGY.js";
|
|
241
263
|
import {
|
|
242
264
|
createSubsystemLogger,
|
|
243
265
|
logExtension
|
|
244
|
-
} from "./chunk-
|
|
266
|
+
} from "./chunk-N3PLNNCW.js";
|
|
245
267
|
import {
|
|
246
268
|
logLatency,
|
|
247
269
|
phaseFinished,
|
|
248
270
|
phaseStarted
|
|
249
|
-
} from "./chunk-
|
|
271
|
+
} from "./chunk-XWFIHYCH.js";
|
|
250
272
|
import {
|
|
251
273
|
createNdjsonLogger,
|
|
252
274
|
getGlobalPiLensLogDir,
|
|
253
275
|
getMaxLogSizeMB,
|
|
254
276
|
isTestMode
|
|
255
|
-
} from "./chunk-
|
|
277
|
+
} from "./chunk-TVZRLTG6.js";
|
|
256
278
|
import {
|
|
257
279
|
FactStore,
|
|
258
280
|
setFactStoreEvictionReporter
|
|
259
|
-
} from "./chunk-
|
|
260
|
-
import {
|
|
261
|
-
BoundedLruCache
|
|
262
|
-
} from "./chunk-ABBOA7UD.js";
|
|
281
|
+
} from "./chunk-NFNVDDGB.js";
|
|
263
282
|
import {
|
|
283
|
+
BoundedFifoMap,
|
|
284
|
+
BoundedLruCache,
|
|
285
|
+
direntsHaveMarkerGlobMatch,
|
|
286
|
+
findLocalToolConfig,
|
|
264
287
|
findNearestContaining,
|
|
265
288
|
isAbsoluteFilePath,
|
|
266
289
|
isUnderDir,
|
|
@@ -268,13 +291,12 @@ import {
|
|
|
268
291
|
normalizeEphemeralMapKey,
|
|
269
292
|
normalizeLoggedPath,
|
|
270
293
|
normalizeMapKey,
|
|
271
|
-
pathsEqual
|
|
272
|
-
|
|
273
|
-
} from "./chunk-N2H3ZPZY.js";
|
|
294
|
+
pathsEqual
|
|
295
|
+
} from "./chunk-EWXXLS26.js";
|
|
274
296
|
|
|
275
297
|
// dist/clients/mcp/analyze.js
|
|
276
|
-
import * as
|
|
277
|
-
import * as
|
|
298
|
+
import * as fs18 from "node:fs";
|
|
299
|
+
import * as path49 from "node:path";
|
|
278
300
|
|
|
279
301
|
// dist/clients/cache-manager.js
|
|
280
302
|
import * as fs from "node:fs";
|
|
@@ -559,6 +581,44 @@ var CacheManager = class {
|
|
|
559
581
|
sessions: { ...envelope.sessions, [sessionId]: secondary }
|
|
560
582
|
}, cwd);
|
|
561
583
|
}
|
|
584
|
+
/**
|
|
585
|
+
* #4751: the primary's half of the turn_start role mirror above. The
|
|
586
|
+
* envelope's owner is the identity `resolveTurnStatePartition` reads the
|
|
587
|
+
* role from, so it must name the live primary. A departing primary keeps
|
|
588
|
+
* its worklist for successor replay, which left its id there: its
|
|
589
|
+
* in-process successor (pi's newSession, fork, clone, a resume of another
|
|
590
|
+
* session) was read as a secondary, wrote a partition no turn end of its
|
|
591
|
+
* own reads, and its turn end found no files. The claim admits two forms
|
|
592
|
+
* and refuses every other: a pi owner of THIS process with another id (an
|
|
593
|
+
* in-process predecessor, whose files the successor's turn end replays),
|
|
594
|
+
* and an envelope with no owner and no files. A predecessor past the
|
|
595
|
+
* #2504 stale bound (`isTurnStateOwnerStale`) is still claimed, or the
|
|
596
|
+
* successor's write would be stranded again, but its files are evicted
|
|
597
|
+
* here, as the turn end would evict them: they are not this turn's work.
|
|
598
|
+
* Files under another process's owner, or under no owner, stay for the
|
|
599
|
+
* liveness rule and the #2504 eviction at turn end.
|
|
600
|
+
*/
|
|
601
|
+
claimPrimaryTurnState(cwd, sessionId) {
|
|
602
|
+
const envelope = this.readTurnStateEnvelope(cwd);
|
|
603
|
+
const owner = envelope.owner;
|
|
604
|
+
const filesKept = Object.keys(envelope.files ?? {}).length;
|
|
605
|
+
const predecessor = owner?.kind === "pi" && owner.pid === process.pid && owner.id !== sessionId;
|
|
606
|
+
const arm = predecessor ? this.isTurnStateOwnerStale(owner) ? "evicted" : "predecessor" : owner === void 0 && filesKept === 0 ? "empty" : void 0;
|
|
607
|
+
if (arm === void 0)
|
|
608
|
+
return void 0;
|
|
609
|
+
const base = arm === "evicted" ? { ...envelope, ...DEFAULT_TURN_STATE, files: {} } : envelope;
|
|
610
|
+
this.writeTurnState({
|
|
611
|
+
...base,
|
|
612
|
+
sessionId,
|
|
613
|
+
owner: {
|
|
614
|
+
kind: "pi",
|
|
615
|
+
id: sessionId,
|
|
616
|
+
pid: process.pid,
|
|
617
|
+
lastSeen: (/* @__PURE__ */ new Date()).toISOString()
|
|
618
|
+
}
|
|
619
|
+
}, cwd);
|
|
620
|
+
return arm === "evicted" ? { from: owner?.id, arm, filesKept: 0, filesDropped: filesKept } : { from: owner?.id, arm, filesKept };
|
|
621
|
+
}
|
|
562
622
|
/** Resolve the persisted primary/secondary turn-state partition. */
|
|
563
623
|
resolveTurnStatePartition(cwd, sessionId) {
|
|
564
624
|
const envelope = this.readTurnStateEnvelope(cwd);
|
|
@@ -889,6 +949,62 @@ function createDiagnosticLogger() {
|
|
|
889
949
|
import * as fs3 from "node:fs";
|
|
890
950
|
import * as path4 from "node:path";
|
|
891
951
|
|
|
952
|
+
// dist/clients/line-alignment.js
|
|
953
|
+
var MAX_OWED_LINE_TEXTS = 4096;
|
|
954
|
+
function lineHashOf(line) {
|
|
955
|
+
return Number.parseInt(lineContentHash(line), 16);
|
|
956
|
+
}
|
|
957
|
+
function stampLineHashes(findings, content, isOwn) {
|
|
958
|
+
if (content === void 0)
|
|
959
|
+
return [...findings];
|
|
960
|
+
let lines;
|
|
961
|
+
return findings.map((d) => {
|
|
962
|
+
if (d.lineHash !== void 0 || d.line === void 0 || !isOwn(d))
|
|
963
|
+
return d;
|
|
964
|
+
lines ??= content.split(/\r?\n/);
|
|
965
|
+
const text = lines[d.line - 1];
|
|
966
|
+
return text === void 0 ? d : { ...d, lineHash: lineHashOf(text) };
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
function linesOfRanges(ranges) {
|
|
970
|
+
const lines = [];
|
|
971
|
+
for (const { start, end } of ranges)
|
|
972
|
+
for (let line = start; line <= end; line += 1)
|
|
973
|
+
lines.push(line);
|
|
974
|
+
return lines;
|
|
975
|
+
}
|
|
976
|
+
function rangesOfLines(lines) {
|
|
977
|
+
const sorted = [...new Set(lines)].sort((a, b) => a - b);
|
|
978
|
+
const ranges = [];
|
|
979
|
+
for (const line of sorted) {
|
|
980
|
+
const last = ranges.at(-1);
|
|
981
|
+
if (last && line === last.end + 1)
|
|
982
|
+
last.end = line;
|
|
983
|
+
else
|
|
984
|
+
ranges.push({ start: line, end: line });
|
|
985
|
+
}
|
|
986
|
+
return ranges;
|
|
987
|
+
}
|
|
988
|
+
function owedContentOf(ranges, lineHashes) {
|
|
989
|
+
if (lineHashes === void 0)
|
|
990
|
+
return "whole-file";
|
|
991
|
+
const texts = /* @__PURE__ */ new Set();
|
|
992
|
+
for (const line of linesOfRanges(ranges)) {
|
|
993
|
+
const hash = lineHashes[line - 1];
|
|
994
|
+
if (hash !== void 0)
|
|
995
|
+
texts.add(hash);
|
|
996
|
+
if (texts.size > MAX_OWED_LINE_TEXTS)
|
|
997
|
+
return "whole-file";
|
|
998
|
+
}
|
|
999
|
+
return Uint32Array.from(texts).sort();
|
|
1000
|
+
}
|
|
1001
|
+
function owedByContentOnly(anchor) {
|
|
1002
|
+
const owedContent = new Map(anchor?.owedContent ?? []);
|
|
1003
|
+
for (const [runnerId, ranges] of anchor?.owedRanges ?? [])
|
|
1004
|
+
owedContent.set(runnerId, owedContentOf(ranges, anchor?.lineHashes));
|
|
1005
|
+
return owedContent.size > 0 ? { lineHashes: void 0, owedRanges: /* @__PURE__ */ new Map(), owedContent } : void 0;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
892
1008
|
// dist/clients/dispatch/rule-id-normalize.js
|
|
893
1009
|
import * as fs2 from "node:fs";
|
|
894
1010
|
import * as path3 from "node:path";
|
|
@@ -922,7 +1038,12 @@ if (bundledCodeRabbitRules) {
|
|
|
922
1038
|
RULE_ID_LANGUAGE_SUFFIXES.add(suffix);
|
|
923
1039
|
}
|
|
924
1040
|
}
|
|
925
|
-
var LSP_SOURCE_PREFIXES = [
|
|
1041
|
+
var LSP_SOURCE_PREFIXES = [
|
|
1042
|
+
"ast-grep:",
|
|
1043
|
+
"shuck:",
|
|
1044
|
+
"Pyright:",
|
|
1045
|
+
"basedpyright:"
|
|
1046
|
+
];
|
|
926
1047
|
function normalizeRuleId(ruleId) {
|
|
927
1048
|
let normalized = ruleId;
|
|
928
1049
|
for (const prefix of LSP_SOURCE_PREFIXES) {
|
|
@@ -1384,8 +1505,8 @@ async function drainPendingRunnerFindings(maxWaitMs = 2e3, currentSession, curre
|
|
|
1384
1505
|
if (maxWaitMs === 0)
|
|
1385
1506
|
await Promise.resolve();
|
|
1386
1507
|
if (maxWaitMs > 0 && current.some((entry) => !entry.settled)) {
|
|
1387
|
-
await new Promise((
|
|
1388
|
-
const timer = setTimeout(
|
|
1508
|
+
await new Promise((resolve45) => {
|
|
1509
|
+
const timer = setTimeout(resolve45, maxWaitMs);
|
|
1389
1510
|
timer.unref?.();
|
|
1390
1511
|
});
|
|
1391
1512
|
}
|
|
@@ -1448,6 +1569,30 @@ function filterGroupsForAdoptedRoot(groups) {
|
|
|
1448
1569
|
return filtered;
|
|
1449
1570
|
}
|
|
1450
1571
|
|
|
1572
|
+
// dist/clients/dispatch/lane-copies.js
|
|
1573
|
+
function semanticRank(semantic) {
|
|
1574
|
+
if (semantic === "blocking")
|
|
1575
|
+
return 4;
|
|
1576
|
+
if (semantic === "warning")
|
|
1577
|
+
return 3;
|
|
1578
|
+
if (semantic === "fixed")
|
|
1579
|
+
return 2;
|
|
1580
|
+
if (semantic === "silent")
|
|
1581
|
+
return 1;
|
|
1582
|
+
return 0;
|
|
1583
|
+
}
|
|
1584
|
+
function laneKey(d) {
|
|
1585
|
+
return `${d.line ?? 1}\0${normalizeRuleId(d.rule ?? "")}`;
|
|
1586
|
+
}
|
|
1587
|
+
function laneCopyStandsFor(lane) {
|
|
1588
|
+
const rankByKey = /* @__PURE__ */ new Map();
|
|
1589
|
+
for (const d of lane) {
|
|
1590
|
+
const key2 = laneKey(d);
|
|
1591
|
+
rankByKey.set(key2, Math.max(rankByKey.get(key2) ?? 0, semanticRank(d.semantic)));
|
|
1592
|
+
}
|
|
1593
|
+
return (d) => (rankByKey.get(laneKey(d)) ?? -1) >= semanticRank(d.semantic);
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1451
1596
|
// dist/clients/dispatch/rule-policy.js
|
|
1452
1597
|
function resolvedRulePolicyMap(root) {
|
|
1453
1598
|
const resolved = resolvePiLensConfig({
|
|
@@ -1579,6 +1724,58 @@ function getToolProfile(tool, defectClass) {
|
|
|
1579
1724
|
return TOOL_PROFILE_MAP[t] ?? DEFAULT_TOOL_PROFILE;
|
|
1580
1725
|
}
|
|
1581
1726
|
|
|
1727
|
+
// dist/clients/dispatch/pre-edit-seed.js
|
|
1728
|
+
var PRE_EDIT_SEED_RUNNER_IDS = /* @__PURE__ */ new Set([
|
|
1729
|
+
"actionlint",
|
|
1730
|
+
"biome-check-json",
|
|
1731
|
+
"credo",
|
|
1732
|
+
"detekt",
|
|
1733
|
+
"eslint",
|
|
1734
|
+
"golangci-lint",
|
|
1735
|
+
"hadolint",
|
|
1736
|
+
"htmlhint",
|
|
1737
|
+
"ktlint",
|
|
1738
|
+
"markdownlint",
|
|
1739
|
+
"oxlint",
|
|
1740
|
+
"psscriptanalyzer",
|
|
1741
|
+
"rubocop",
|
|
1742
|
+
"ruff-lint",
|
|
1743
|
+
"rust-clippy",
|
|
1744
|
+
"shellcheck",
|
|
1745
|
+
"spellcheck",
|
|
1746
|
+
"sqlfluff",
|
|
1747
|
+
"stylelint",
|
|
1748
|
+
"swiftlint",
|
|
1749
|
+
"tflint",
|
|
1750
|
+
"vale",
|
|
1751
|
+
"yamllint"
|
|
1752
|
+
]);
|
|
1753
|
+
function preEditSeedFactKey(filePath) {
|
|
1754
|
+
return `session.preEdit.${filePath}`;
|
|
1755
|
+
}
|
|
1756
|
+
function classifyPreExisting(seed, current, content, answered) {
|
|
1757
|
+
let lines;
|
|
1758
|
+
const hashAt = (line) => {
|
|
1759
|
+
if (line === void 0)
|
|
1760
|
+
return void 0;
|
|
1761
|
+
lines ??= content.split(/\r?\n/);
|
|
1762
|
+
const text = lines[line - 1];
|
|
1763
|
+
return text === void 0 ? void 0 : lineHashOf(text);
|
|
1764
|
+
};
|
|
1765
|
+
const candidates = current.filter((d) => d.runnerId !== void 0 && PRE_EDIT_SEED_RUNNER_IDS.has(d.runnerId));
|
|
1766
|
+
const { kept } = retainRecordedFindings(seed, candidates, {
|
|
1767
|
+
positionOf: () => ANY_POSITION,
|
|
1768
|
+
keepUnobserved: (d) => d.runnerId === void 0 || !answered.has(d.runnerId),
|
|
1769
|
+
matchesAnywhere: (prior, observed2) => prior.lineHash !== void 0 && prior.lineHash === hashAt(observed2.line)
|
|
1770
|
+
});
|
|
1771
|
+
const observed = new Set(candidates);
|
|
1772
|
+
const preExisting = kept.filter((d) => observed.has(d));
|
|
1773
|
+
return {
|
|
1774
|
+
preExisting,
|
|
1775
|
+
nextSeed: stampLineHashes(kept, content, (d) => observed.has(d))
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1582
1779
|
// dist/clients/dispatch/utils/format-utils.js
|
|
1583
1780
|
var EMOJI = {
|
|
1584
1781
|
blocking: "\u{1F534}",
|
|
@@ -1833,35 +2030,50 @@ function createDispatchContext(filePath, cwd, pi, facts, blockingOnly, modifiedR
|
|
|
1833
2030
|
}
|
|
1834
2031
|
};
|
|
1835
2032
|
}
|
|
1836
|
-
function
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
const
|
|
2033
|
+
function deltaBaselineFactKey(filePath) {
|
|
2034
|
+
return `session.baseline.${filePath}`;
|
|
2035
|
+
}
|
|
2036
|
+
function filterDelta(after, before, copyOf) {
|
|
2037
|
+
const namedBy = (side) => {
|
|
2038
|
+
const ids = new Set(side.map((d) => d.id));
|
|
2039
|
+
const lanesByKey = /* @__PURE__ */ new Map();
|
|
2040
|
+
for (const d of side) {
|
|
2041
|
+
const key2 = copyOf.key(d);
|
|
2042
|
+
const lanes = lanesByKey.get(key2) ?? /* @__PURE__ */ new Set();
|
|
2043
|
+
lanes.add(copyOf.lane(d));
|
|
2044
|
+
lanesByKey.set(key2, lanes);
|
|
2045
|
+
}
|
|
2046
|
+
return (d) => {
|
|
2047
|
+
if (ids.has(d.id))
|
|
2048
|
+
return true;
|
|
2049
|
+
const lane = copyOf.lane(d);
|
|
2050
|
+
for (const other of lanesByKey.get(copyOf.key(d)) ?? []) {
|
|
2051
|
+
if (other !== lane)
|
|
2052
|
+
return true;
|
|
2053
|
+
}
|
|
2054
|
+
return false;
|
|
2055
|
+
};
|
|
2056
|
+
};
|
|
2057
|
+
const inBefore = namedBy(before ?? []);
|
|
2058
|
+
const inAfter = namedBy(after);
|
|
2059
|
+
const fixed = (before ?? []).filter((d) => !inAfter(d));
|
|
2060
|
+
const newItems = after.filter((d) => !inBefore(d));
|
|
1841
2061
|
return { new: newItems, fixed };
|
|
1842
2062
|
}
|
|
1843
|
-
function semanticRank(semantic) {
|
|
1844
|
-
if (semantic === "blocking")
|
|
1845
|
-
return 4;
|
|
1846
|
-
if (semantic === "warning")
|
|
1847
|
-
return 3;
|
|
1848
|
-
if (semantic === "fixed")
|
|
1849
|
-
return 2;
|
|
1850
|
-
if (semantic === "silent")
|
|
1851
|
-
return 1;
|
|
1852
|
-
return 0;
|
|
1853
|
-
}
|
|
1854
2063
|
function toolPriority(tool, defectClass) {
|
|
1855
2064
|
return getToolProfile(tool, defectClass).dedupPriority;
|
|
1856
2065
|
}
|
|
2066
|
+
function findingKey(d, defectClass = d.defectClass ?? classifyDiagnostic(d)) {
|
|
2067
|
+
const line = d.line ?? 1;
|
|
2068
|
+
const column = d.column ?? 1;
|
|
2069
|
+
const ruleKey = normalizeRuleId(d.rule || d.id || "unknown");
|
|
2070
|
+
return `${d.filePath}:${line}:${column}:${defectClass}:${ruleKey}`;
|
|
2071
|
+
}
|
|
1857
2072
|
function dedupeOverlappingDiagnostics(diagnostics) {
|
|
1858
2073
|
const byKey = /* @__PURE__ */ new Map();
|
|
1859
2074
|
for (const d of diagnostics) {
|
|
1860
2075
|
const defectClass = d.defectClass ?? classifyDiagnostic(d);
|
|
1861
|
-
const
|
|
1862
|
-
const column = d.column ?? 1;
|
|
1863
|
-
const ruleKey = d.rule || d.id || "unknown";
|
|
1864
|
-
const key2 = `${d.filePath}:${line}:${column}:${defectClass}:${ruleKey}`;
|
|
2076
|
+
const key2 = findingKey(d, defectClass);
|
|
1865
2077
|
const current = byKey.get(key2);
|
|
1866
2078
|
if (!current) {
|
|
1867
2079
|
byKey.set(key2, { ...d, defectClass });
|
|
@@ -1949,14 +2161,14 @@ function promoteDeltaUnusedToBlockers(diagnostics) {
|
|
|
1949
2161
|
}
|
|
1950
2162
|
function buildCoverageNotice(ctx, runnerLatencies, dedupe) {
|
|
1951
2163
|
if (!ctx.kind)
|
|
1952
|
-
return
|
|
2164
|
+
return {};
|
|
1953
2165
|
const lspEnabled = !ctx.pi.getFlag("no-lsp");
|
|
1954
2166
|
const primary2 = getPrimaryDispatchGroup(ctx.kind, lspEnabled);
|
|
1955
2167
|
if (!primary2 || primary2.runnerIds.length === 0)
|
|
1956
|
-
return
|
|
2168
|
+
return { coverage: "unconfigured" };
|
|
1957
2169
|
const relevant = runnerLatencies.filter((r) => primary2.runnerIds.includes(r.runnerId));
|
|
1958
2170
|
if (relevant.length === 0)
|
|
1959
|
-
return
|
|
2171
|
+
return {};
|
|
1960
2172
|
const unconfirmedServerIds = [
|
|
1961
2173
|
...new Set(relevant.flatMap((r) => r.unconfirmedServerIds ?? []))
|
|
1962
2174
|
];
|
|
@@ -1973,7 +2185,7 @@ function buildCoverageNotice(ctx, runnerLatencies, dedupe) {
|
|
|
1973
2185
|
const onceKey2 = `${ctx.kind}:${ctx.filePath}:${dedupeSet(silentServerIds)}|${dedupeSet(deferredServerIds)}`;
|
|
1974
2186
|
if (dedupe) {
|
|
1975
2187
|
if (coverageNoticeSeen.has(onceKey2))
|
|
1976
|
-
return
|
|
2188
|
+
return {};
|
|
1977
2189
|
coverageNoticeSeen.add(onceKey2);
|
|
1978
2190
|
}
|
|
1979
2191
|
const coverageParts = [];
|
|
@@ -1984,20 +2196,28 @@ function buildCoverageNotice(ctx, runnerLatencies, dedupe) {
|
|
|
1984
2196
|
coverageParts.push(`coverage: ${markerFor(silentServerIds)} silent \u2014 diagnostics are incomplete (not a clean result).`);
|
|
1985
2197
|
}
|
|
1986
2198
|
return {
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
2199
|
+
notice: {
|
|
2200
|
+
id: `coverage-partial:${ctx.kind}:${path4.basename(ctx.filePath)}`,
|
|
2201
|
+
message: coverageParts.join("\n"),
|
|
2202
|
+
filePath: ctx.filePath,
|
|
2203
|
+
severity: "warning",
|
|
2204
|
+
semantic: "warning",
|
|
2205
|
+
tool: "pi-lens"
|
|
2206
|
+
}
|
|
1993
2207
|
};
|
|
1994
2208
|
}
|
|
1995
2209
|
const primaryHasCoverage = relevant.some(hasUsableResult);
|
|
1996
|
-
if (primaryHasCoverage)
|
|
1997
|
-
return
|
|
2210
|
+
if (primaryHasCoverage) {
|
|
2211
|
+
return {
|
|
2212
|
+
coverage: "primary",
|
|
2213
|
+
...relevant.some((r) => r.runnerId === "lsp" && hasUsableResult(r)) && {
|
|
2214
|
+
primaryLspChecked: true
|
|
2215
|
+
}
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
1998
2218
|
const primaryStillInFlight = relevant.some((r) => r.status === "pending" || r.status === "deferred");
|
|
1999
2219
|
if (primaryStillInFlight)
|
|
2000
|
-
return
|
|
2220
|
+
return { coverage: "in_flight" };
|
|
2001
2221
|
const plan = getToolPlan(ctx.kind);
|
|
2002
2222
|
const fallbackRunnerIds = new Set((plan?.groups ?? []).filter((group) => !group.runnerIds.every((runnerId) => primary2.runnerIds.includes(runnerId))).flatMap((group) => group.runnerIds).filter((runnerId) => !primary2.runnerIds.includes(runnerId)));
|
|
2003
2223
|
const STRUCTURAL_RUNNERS = /* @__PURE__ */ new Set([
|
|
@@ -2010,20 +2230,48 @@ function buildCoverageNotice(ctx, runnerLatencies, dedupe) {
|
|
|
2010
2230
|
const TYPE_CAPABLE_FALLBACK_RUNNERS = /* @__PURE__ */ new Set(["mypy"]);
|
|
2011
2231
|
const anyFallbackHasCoverage = runnerLatencies.some((r) => fallbackRunnerIds.has(r.runnerId) && !STRUCTURAL_RUNNERS.has(r.runnerId) && hasUsableResult(r) && (!plan?.capabilities.includes("types") || TYPE_CAPABLE_FALLBACK_RUNNERS.has(r.runnerId)));
|
|
2012
2232
|
if (anyFallbackHasCoverage)
|
|
2013
|
-
return
|
|
2233
|
+
return { coverage: "fallback" };
|
|
2234
|
+
const cause = combinePrimaryUnavailableCauses(relevant.flatMap((r) => r.primaryUnavailableCause ?? []));
|
|
2235
|
+
const unconfirmedStatus = cause ? `no language server answered (${PRIMARY_UNAVAILABLE_CAUSE[cause]})` : "not fully checked (a language tool is missing, timed out, or failed to run)";
|
|
2236
|
+
if (cause === "disabled" || cause === "disabledFallback") {
|
|
2237
|
+
const disabledIds = [
|
|
2238
|
+
...new Set(relevant.flatMap((r) => r.disabledPrimaryServerIds ?? []))
|
|
2239
|
+
].sort((a, b) => Number(a > b) - Number(a < b));
|
|
2240
|
+
const onceKeys = disabledIds.map((id) => `disabled-primary:${id}`);
|
|
2241
|
+
if (dedupe) {
|
|
2242
|
+
if (onceKeys.every((key2) => coverageNoticeSeen.has(key2)))
|
|
2243
|
+
return { unconfirmedStatus };
|
|
2244
|
+
for (const key2 of onceKeys)
|
|
2245
|
+
coverageNoticeSeen.add(key2);
|
|
2246
|
+
}
|
|
2247
|
+
return {
|
|
2248
|
+
notice: {
|
|
2249
|
+
id: `coverage-disabled:${ctx.kind}:${disabledIds.join(",")}`,
|
|
2250
|
+
message: cause === "disabled" ? `Pi-lens ${ctx.kind} analysis unconfirmed \u2014 Primary LSP (${disabledIds.join(", ")}) is disabled in config by lsp.disabledServers, so no language server checks these files this session (not a clean result).` : `Pi-lens ${ctx.kind} analysis unconfirmed \u2014 Primary LSP (${disabledIds.join(", ")}) is disabled in config by lsp.disabledServers and its fallback did not answer, so no language server checked these files (not a clean result).`,
|
|
2251
|
+
filePath: ctx.filePath,
|
|
2252
|
+
severity: "warning",
|
|
2253
|
+
semantic: "warning",
|
|
2254
|
+
tool: "pi-lens"
|
|
2255
|
+
},
|
|
2256
|
+
unconfirmedStatus
|
|
2257
|
+
};
|
|
2258
|
+
}
|
|
2014
2259
|
const onceKey = `${ctx.kind}:${ctx.filePath}`;
|
|
2015
2260
|
if (dedupe) {
|
|
2016
2261
|
if (coverageNoticeSeen.has(onceKey))
|
|
2017
|
-
return
|
|
2262
|
+
return { unconfirmedStatus };
|
|
2018
2263
|
coverageNoticeSeen.add(onceKey);
|
|
2019
2264
|
}
|
|
2020
2265
|
return {
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2266
|
+
notice: {
|
|
2267
|
+
id: `coverage-unavailable:${ctx.kind}:${path4.basename(ctx.filePath)}`,
|
|
2268
|
+
message: `Pi-lens ${ctx.kind} analysis unavailable \u2014 a language tool is missing, timed out, or failed to run, or the LSP server isn't ready yet, so this file was not fully checked (not a clean result).`,
|
|
2269
|
+
filePath: ctx.filePath,
|
|
2270
|
+
severity: "warning",
|
|
2271
|
+
semantic: "warning",
|
|
2272
|
+
tool: "pi-lens"
|
|
2273
|
+
},
|
|
2274
|
+
unconfirmedStatus
|
|
2027
2275
|
};
|
|
2028
2276
|
}
|
|
2029
2277
|
var latencyReports = [];
|
|
@@ -2036,10 +2284,29 @@ function clearCoverageNoticeState() {
|
|
|
2036
2284
|
coverageNoticeSeen.clear();
|
|
2037
2285
|
generatedSkipRecorded.clear();
|
|
2038
2286
|
}
|
|
2287
|
+
function runnerDispatchContext(ctx, runnerId) {
|
|
2288
|
+
const owed = ctx.owedRanges?.get(runnerId);
|
|
2289
|
+
if (!owed?.length || !ctx.modifiedRanges)
|
|
2290
|
+
return ctx;
|
|
2291
|
+
return {
|
|
2292
|
+
...ctx,
|
|
2293
|
+
modifiedRanges: rangesOfLines([
|
|
2294
|
+
...linesOfRanges(ctx.modifiedRanges),
|
|
2295
|
+
...linesOfRanges(owed)
|
|
2296
|
+
])
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2039
2299
|
async function runGroup(ctx, group, registry, onRunnerResult) {
|
|
2040
2300
|
const diagnostics = [];
|
|
2041
2301
|
const latencies = [];
|
|
2042
2302
|
let hadBlocker = false;
|
|
2303
|
+
const outOfEditScope = [];
|
|
2304
|
+
const inconclusiveRunnerIds = [];
|
|
2305
|
+
const inconclusiveServerIds = [];
|
|
2306
|
+
const collectLaterRunnerIds = [];
|
|
2307
|
+
const editScopedRunnerIds = [];
|
|
2308
|
+
const answeredRunnerIds = [];
|
|
2309
|
+
const coveredRunners = [];
|
|
2043
2310
|
const runnerIds = group.filterKinds ? group.runnerIds.filter((id) => {
|
|
2044
2311
|
const runner = registry.get(id);
|
|
2045
2312
|
return runner && ctx.kind && group.filterKinds?.includes(ctx.kind);
|
|
@@ -2121,6 +2388,7 @@ async function runGroup(ctx, group, registry, onRunnerResult) {
|
|
|
2121
2388
|
} catch (error) {
|
|
2122
2389
|
ctx.log(`Runner ${runner.id} precondition failed: ${error}`);
|
|
2123
2390
|
shouldRun = false;
|
|
2391
|
+
inconclusiveRunnerIds.push(runner.id);
|
|
2124
2392
|
}
|
|
2125
2393
|
}
|
|
2126
2394
|
if (!shouldRun) {
|
|
@@ -2145,10 +2413,11 @@ async function runGroup(ctx, group, registry, onRunnerResult) {
|
|
|
2145
2413
|
continue;
|
|
2146
2414
|
}
|
|
2147
2415
|
const projectRoot = ctx.projectRoot ?? ctx.cwd;
|
|
2416
|
+
const runnerCtx = runnerDispatchContext(ctx, runner.id);
|
|
2148
2417
|
const observedTier = ctx.writeIndex === void 0 ? "inline" : classifyObservedRunner(projectRoot, runner.id);
|
|
2149
2418
|
if (observedTier === "collect-later") {
|
|
2150
2419
|
const markedAtMs = Date.now();
|
|
2151
|
-
const deferred = runRunner(
|
|
2420
|
+
const deferred = runRunner(runnerCtx, runner, semantic).then((result2) => {
|
|
2152
2421
|
const durationMs = Date.now() - markedAtMs;
|
|
2153
2422
|
const tier2 = observeRunnerLatency({
|
|
2154
2423
|
projectRoot,
|
|
@@ -2215,6 +2484,8 @@ async function runGroup(ctx, group, registry, onRunnerResult) {
|
|
|
2215
2484
|
semantic
|
|
2216
2485
|
});
|
|
2217
2486
|
recordRunner(ctx.filePath, runner.id, "pending", 0, 0, ctx.writeIndex);
|
|
2487
|
+
inconclusiveRunnerIds.push(runner.id);
|
|
2488
|
+
collectLaterRunnerIds.push(runner.id);
|
|
2218
2489
|
logLatency({
|
|
2219
2490
|
type: "runner",
|
|
2220
2491
|
filePath: ctx.filePath,
|
|
@@ -2227,7 +2498,7 @@ async function runGroup(ctx, group, registry, onRunnerResult) {
|
|
|
2227
2498
|
});
|
|
2228
2499
|
continue;
|
|
2229
2500
|
}
|
|
2230
|
-
const result = await runRunner(
|
|
2501
|
+
const result = await runRunner(runnerCtx, runner, semantic);
|
|
2231
2502
|
onRunnerResult?.(runnerId, result);
|
|
2232
2503
|
const runnerEnd = Date.now();
|
|
2233
2504
|
const duration = runnerEnd - runnerStart;
|
|
@@ -2282,6 +2553,15 @@ async function runGroup(ctx, group, registry, onRunnerResult) {
|
|
|
2282
2553
|
},
|
|
2283
2554
|
...result.deferredServerIds !== void 0 && {
|
|
2284
2555
|
deferredServerIds: result.deferredServerIds
|
|
2556
|
+
},
|
|
2557
|
+
...result.primaryUnavailableCause !== void 0 && {
|
|
2558
|
+
primaryUnavailableCause: result.primaryUnavailableCause
|
|
2559
|
+
},
|
|
2560
|
+
...result.disabledPrimaryServerIds !== void 0 && {
|
|
2561
|
+
disabledPrimaryServerIds: result.disabledPrimaryServerIds
|
|
2562
|
+
},
|
|
2563
|
+
...result.withheldNotice !== void 0 && {
|
|
2564
|
+
withheldNotice: result.withheldNotice
|
|
2285
2565
|
}
|
|
2286
2566
|
});
|
|
2287
2567
|
logLatency({
|
|
@@ -2301,7 +2581,28 @@ async function runGroup(ctx, group, registry, onRunnerResult) {
|
|
|
2301
2581
|
})) : void 0,
|
|
2302
2582
|
metadata: failureRowMetadata(result) ?? (skipReason ? { skipReason, ...claimSource !== void 0 && { claimSource } } : void 0)
|
|
2303
2583
|
});
|
|
2304
|
-
|
|
2584
|
+
if (!ctx.preEditCapture)
|
|
2585
|
+
recordRunner(ctx.filePath, runnerId, result.status, result.diagnostics.length, duration, ctx.writeIndex);
|
|
2586
|
+
for (const d of result.diagnostics)
|
|
2587
|
+
d.runnerId ??= runnerId;
|
|
2588
|
+
for (const d of result.outOfEditScope ?? []) {
|
|
2589
|
+
d.runnerId ??= runnerId;
|
|
2590
|
+
outOfEditScope.push(d);
|
|
2591
|
+
}
|
|
2592
|
+
if (reachedNoVerdict(result))
|
|
2593
|
+
inconclusiveRunnerIds.push(runnerId);
|
|
2594
|
+
else {
|
|
2595
|
+
answeredRunnerIds.push(runnerId);
|
|
2596
|
+
if (result.coveredBy)
|
|
2597
|
+
coveredRunners.push({
|
|
2598
|
+
runnerId,
|
|
2599
|
+
lane: result.coveredBy,
|
|
2600
|
+
ran: result.skipReason !== "covered-by-primary"
|
|
2601
|
+
});
|
|
2602
|
+
if (result.editScopedVerdict === true)
|
|
2603
|
+
editScopedRunnerIds.push(runnerId);
|
|
2604
|
+
}
|
|
2605
|
+
inconclusiveServerIds.push(...result.unconfirmedServerIds ?? [], ...result.deferredServerIds ?? []);
|
|
2305
2606
|
diagnostics.push(...result.diagnostics);
|
|
2306
2607
|
const resultSemantic = result.semantic ?? semantic;
|
|
2307
2608
|
if (resultSemantic === "blocking" && result.diagnostics.length > 0 || result.diagnostics.some((d) => d.semantic === "blocking")) {
|
|
@@ -2311,7 +2612,18 @@ async function runGroup(ctx, group, registry, onRunnerResult) {
|
|
|
2311
2612
|
break;
|
|
2312
2613
|
}
|
|
2313
2614
|
}
|
|
2314
|
-
return {
|
|
2615
|
+
return {
|
|
2616
|
+
diagnostics,
|
|
2617
|
+
latencies,
|
|
2618
|
+
hadBlocker,
|
|
2619
|
+
outOfEditScope,
|
|
2620
|
+
inconclusiveRunnerIds,
|
|
2621
|
+
inconclusiveServerIds,
|
|
2622
|
+
collectLaterRunnerIds,
|
|
2623
|
+
editScopedRunnerIds,
|
|
2624
|
+
answeredRunnerIds,
|
|
2625
|
+
coveredRunners
|
|
2626
|
+
};
|
|
2315
2627
|
}
|
|
2316
2628
|
async function dispatchForFile(ctx, groups, registry, onRunnerResult, options) {
|
|
2317
2629
|
const _overallStart = Date.now();
|
|
@@ -2385,7 +2697,8 @@ async function dispatchForFile(ctx, groups, registry, onRunnerResult, options) {
|
|
|
2385
2697
|
metadata: {
|
|
2386
2698
|
groupCount: groups.length,
|
|
2387
2699
|
kind: ctx.kind,
|
|
2388
|
-
runners: allRunnerIds.join(",")
|
|
2700
|
+
runners: allRunnerIds.join(","),
|
|
2701
|
+
...ctx.preEditCapture && { preEditCapture: true }
|
|
2389
2702
|
}
|
|
2390
2703
|
});
|
|
2391
2704
|
const groupResults = await Promise.all(groups.map((group) => runGroup(ctx, group, registry, onRunnerResult)));
|
|
@@ -2397,17 +2710,51 @@ async function dispatchForFile(ctx, groups, registry, onRunnerResult, options) {
|
|
|
2397
2710
|
reason: "dispatchForFile requires an absolute ctx.filePath to key the delta baseline (refs #2489)"
|
|
2398
2711
|
});
|
|
2399
2712
|
}
|
|
2400
|
-
const baselineAbsKey =
|
|
2713
|
+
const baselineAbsKey = deltaBaselineFactKey(ctx.filePath);
|
|
2401
2714
|
const previousBaseline = ctx.deltaMode && baselinePathSafe ? ctx.facts.getBoundedSessionFact(baselineAbsKey) : void 0;
|
|
2402
2715
|
const baselineWarnings = previousBaseline?.filter((d) => d.semantic === "warning" || d.semantic === "none");
|
|
2403
2716
|
const baselineWarningCount = baselineWarnings?.length ?? 0;
|
|
2404
|
-
|
|
2717
|
+
const outOfEditScope = [];
|
|
2718
|
+
const inconclusiveRunnerIds = /* @__PURE__ */ new Set();
|
|
2719
|
+
const inconclusiveServerIds = /* @__PURE__ */ new Set();
|
|
2720
|
+
const collectLaterRunnerIds = /* @__PURE__ */ new Set();
|
|
2721
|
+
const editScopedRunnerIds = [];
|
|
2722
|
+
const answeredRunnerIds = /* @__PURE__ */ new Set();
|
|
2723
|
+
const coveredRunners = [];
|
|
2724
|
+
for (const { diagnostics: groupDiags, latencies, hadBlocker, outOfEditScope: groupOutOfScope, inconclusiveRunnerIds: groupRunnerIds, inconclusiveServerIds: groupServerIds, collectLaterRunnerIds: groupCollectLater, editScopedRunnerIds: groupEditScoped, answeredRunnerIds: groupAnswered, coveredRunners: groupCovered } of groupResults) {
|
|
2405
2725
|
runnerLatencies.push(...latencies);
|
|
2726
|
+
outOfEditScope.push(...groupOutOfScope);
|
|
2727
|
+
for (const id of groupRunnerIds)
|
|
2728
|
+
inconclusiveRunnerIds.add(id);
|
|
2729
|
+
for (const id of groupServerIds)
|
|
2730
|
+
inconclusiveServerIds.add(id);
|
|
2731
|
+
for (const id of groupCollectLater)
|
|
2732
|
+
collectLaterRunnerIds.add(id);
|
|
2733
|
+
editScopedRunnerIds.push(...groupEditScoped);
|
|
2734
|
+
for (const id of groupAnswered)
|
|
2735
|
+
answeredRunnerIds.add(id);
|
|
2736
|
+
coveredRunners.push(...groupCovered);
|
|
2406
2737
|
allDiagnostics.push(...groupDiags);
|
|
2407
2738
|
if (hadBlocker)
|
|
2408
2739
|
stopped = true;
|
|
2409
2740
|
}
|
|
2410
|
-
const
|
|
2741
|
+
const voidedCovers = /* @__PURE__ */ new Set();
|
|
2742
|
+
const laneCopyByRunner = /* @__PURE__ */ new Map();
|
|
2743
|
+
for (const { runnerId, lane, ran } of coveredRunners) {
|
|
2744
|
+
const silent = !answeredRunnerIds.has(lane.runnerId) || lane.serverId !== void 0 && inconclusiveServerIds.has(lane.serverId);
|
|
2745
|
+
if (ran) {
|
|
2746
|
+
if (silent)
|
|
2747
|
+
continue;
|
|
2748
|
+
laneCopyByRunner.set(runnerId, laneCopyStandsFor(allDiagnostics.flatMap((d) => d.runnerId === lane.runnerId && (lane.serverId === void 0 || d.serverId === lane.serverId) ? [d] : [])));
|
|
2749
|
+
continue;
|
|
2750
|
+
}
|
|
2751
|
+
if (!silent)
|
|
2752
|
+
continue;
|
|
2753
|
+
voidedCovers.add(runnerId);
|
|
2754
|
+
inconclusiveRunnerIds.add(runnerId);
|
|
2755
|
+
}
|
|
2756
|
+
const deliveredDiagnostics = laneCopyByRunner.size === 0 ? allDiagnostics : allDiagnostics.flatMap((d) => laneCopyByRunner.get(d.runnerId ?? "")?.(d) ? [] : [d]);
|
|
2757
|
+
const dedupedDiagnostics = dedupeOverlappingDiagnostics(deliveredDiagnostics);
|
|
2411
2758
|
const fileContent = ctx.facts.getFileFact(ctx.filePath, "file.content") ?? "";
|
|
2412
2759
|
const rulePolicy = ctx.rulePolicy ?? rulePolicyMapFromConfig(loadPiLensProjectConfig(ctx.projectRoot ?? ctx.cwd).rules);
|
|
2413
2760
|
const applyOutputFilters = (diags) => {
|
|
@@ -2422,11 +2769,33 @@ async function dispatchForFile(ctx, groups, registry, onRunnerResult, options) {
|
|
|
2422
2769
|
};
|
|
2423
2770
|
let visibleDiagnostics = applyOutputFilters(dedupedDiagnostics);
|
|
2424
2771
|
let resolvedCount = 0;
|
|
2772
|
+
const stillObserved = outOfEditScope.length > 0 ? applyOutputFilters(outOfEditScope).flatMap((d) => d.semantic === "blocking" ? [d] : []) : [];
|
|
2773
|
+
let heldBackBlockers = [];
|
|
2425
2774
|
if (ctx.deltaMode && previousBaseline) {
|
|
2426
|
-
const filtered = filterDelta(visibleDiagnostics, applyOutputFilters(previousBaseline), (d) => d.
|
|
2775
|
+
const filtered = filterDelta(visibleDiagnostics, applyOutputFilters(previousBaseline), { key: (d) => findingKey(d), lane: (d) => d.tool });
|
|
2776
|
+
const isNew = new Set(filtered.new);
|
|
2777
|
+
heldBackBlockers = visibleDiagnostics.filter((d) => d.semantic === "blocking" && !isNew.has(d));
|
|
2778
|
+
stillObserved.push(...promoteDeltaUnusedToBlockers(visibleDiagnostics.flatMap((d) => !isNew.has(d) && d.semantic !== "blocking" && isUnusedValueDiagnostic(d) ? [d] : [])));
|
|
2427
2779
|
visibleDiagnostics = promoteDeltaUnusedToBlockers(filtered.new);
|
|
2428
2780
|
resolvedCount = filtered.fixed.length;
|
|
2429
2781
|
}
|
|
2782
|
+
const seedKey = preEditSeedFactKey(ctx.filePath);
|
|
2783
|
+
const preEditSeed = ctx.deltaMode && baselinePathSafe ? ctx.facts.getBoundedSessionFact(seedKey) : void 0;
|
|
2784
|
+
const seedContent = ctx.facts.getFileFact(ctx.filePath, "file.content");
|
|
2785
|
+
let preExisting = [];
|
|
2786
|
+
if (preEditSeed && seedContent !== void 0) {
|
|
2787
|
+
const classified = classifyPreExisting(preEditSeed, [
|
|
2788
|
+
...visibleDiagnostics.filter((d) => d.semantic === "blocking"),
|
|
2789
|
+
...heldBackBlockers
|
|
2790
|
+
], seedContent, new Set([...answeredRunnerIds].filter((id) => !inconclusiveRunnerIds.has(id))));
|
|
2791
|
+
if (classified.preExisting.length > 0) {
|
|
2792
|
+
const held = new Set(classified.preExisting);
|
|
2793
|
+
visibleDiagnostics = visibleDiagnostics.filter((d) => !held.has(d));
|
|
2794
|
+
heldBackBlockers = heldBackBlockers.filter((d) => !held.has(d));
|
|
2795
|
+
preExisting = classified.preExisting;
|
|
2796
|
+
}
|
|
2797
|
+
ctx.facts.setBoundedSessionFact(seedKey, classified.nextSeed);
|
|
2798
|
+
}
|
|
2430
2799
|
if (ctx.deltaMode && baselinePathSafe) {
|
|
2431
2800
|
ctx.facts.setBoundedSessionFact(baselineAbsKey, [...dedupedDiagnostics]);
|
|
2432
2801
|
}
|
|
@@ -2438,27 +2807,42 @@ async function dispatchForFile(ctx, groups, registry, onRunnerResult, options) {
|
|
|
2438
2807
|
provider: ctx.telemetryProvider
|
|
2439
2808
|
};
|
|
2440
2809
|
if (fixedItems.length > 0) {
|
|
2441
|
-
import("./chunk-
|
|
2810
|
+
import("./chunk-Y2TPADJR.js").then(({ appendToWorklog }) => {
|
|
2442
2811
|
appendToWorklog(ctx.cwd, fixedItems, true, worklogIdentity);
|
|
2443
2812
|
}).catch(() => {
|
|
2444
2813
|
});
|
|
2445
2814
|
}
|
|
2446
2815
|
const fixableWarnings = warnings.filter((d) => d.fixable);
|
|
2447
2816
|
if (fixableWarnings.length > 0) {
|
|
2448
|
-
import("./chunk-
|
|
2817
|
+
import("./chunk-Y2TPADJR.js").then(({ appendToWorklog }) => {
|
|
2449
2818
|
appendToWorklog(ctx.cwd, fixableWarnings, false, worklogIdentity);
|
|
2450
2819
|
}).catch(() => {
|
|
2451
2820
|
});
|
|
2452
2821
|
}
|
|
2453
2822
|
const inlineBlockers = blockers;
|
|
2454
2823
|
const inlineFixed = fixedItems;
|
|
2455
|
-
const coverageNotice = buildCoverageNotice(ctx, runnerLatencies, options?.dedupeCoverageNotice ?? true);
|
|
2824
|
+
const { notice: coverageNotice, unconfirmedStatus, coverage, primaryLspChecked } = buildCoverageNotice(ctx, runnerLatencies, options?.dedupeCoverageNotice ?? true);
|
|
2456
2825
|
const blockerOutput = formatDiagnostics(inlineBlockers, "blocking");
|
|
2457
2826
|
let output = blockerOutput;
|
|
2458
2827
|
output += formatDiagnostics(inlineFixed, "fixed");
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2828
|
+
const withheldMessages = [
|
|
2829
|
+
...new Set(runnerLatencies.flatMap((r) => r.withheldNotice ?? []))
|
|
2830
|
+
];
|
|
2831
|
+
const withheldNotice = withheldMessages.length > 0 ? {
|
|
2832
|
+
id: `withheld-compile:${ctx.kind}:${path4.basename(ctx.filePath)}`,
|
|
2833
|
+
message: withheldMessages.join("\n"),
|
|
2834
|
+
filePath: ctx.filePath,
|
|
2835
|
+
severity: "warning",
|
|
2836
|
+
semantic: "warning",
|
|
2837
|
+
tool: "pi-lens"
|
|
2838
|
+
} : void 0;
|
|
2839
|
+
const inlineNotices = [
|
|
2840
|
+
...coverageNotice ? [coverageNotice] : [],
|
|
2841
|
+
...withheldNotice ? [withheldNotice] : []
|
|
2842
|
+
];
|
|
2843
|
+
if (inlineNotices.length > 0) {
|
|
2844
|
+
output += formatDiagnostics(inlineNotices, "warning", inlineNotices.length);
|
|
2845
|
+
warnings.push(...inlineNotices);
|
|
2462
2846
|
}
|
|
2463
2847
|
const pendingRunners = runnerLatencies.filter((runner) => runner.status === "pending").map((runner) => runner.runnerId);
|
|
2464
2848
|
if (pendingRunners.length > 0) {
|
|
@@ -2508,7 +2892,19 @@ async function dispatchForFile(ctx, groups, registry, onRunnerResult, options) {
|
|
|
2508
2892
|
// (above, `metadata: { groupCount, kind, runners }`) fires before the
|
|
2509
2893
|
// baseline read ever runs and cannot carry either value.
|
|
2510
2894
|
baselineHit: previousBaseline !== void 0,
|
|
2511
|
-
baselineWarningCount
|
|
2895
|
+
baselineWarningCount,
|
|
2896
|
+
// #4484: blockers still observed that the delta did not call new.
|
|
2897
|
+
heldBackBlockers: heldBackBlockers.length,
|
|
2898
|
+
// #4483: whether a pre-edit seed was read, and the blocking linter
|
|
2899
|
+
// findings it reported as pre-existing.
|
|
2900
|
+
preEditSeed: preEditSeed !== void 0,
|
|
2901
|
+
preExisting: preExisting.length,
|
|
2902
|
+
...ctx.preEditCapture && { preEditCapture: true },
|
|
2903
|
+
// #4484 r2: findings that only keep a recorded blocker pending, and
|
|
2904
|
+
// the sources whose silence is no evidence.
|
|
2905
|
+
stillObserved: stillObserved.length,
|
|
2906
|
+
inconclusiveRunners: inconclusiveRunnerIds.size,
|
|
2907
|
+
inconclusiveServers: inconclusiveServerIds.size
|
|
2512
2908
|
}
|
|
2513
2909
|
});
|
|
2514
2910
|
return {
|
|
@@ -2521,7 +2917,23 @@ async function dispatchForFile(ctx, groups, registry, onRunnerResult, options) {
|
|
|
2521
2917
|
resolvedCount,
|
|
2522
2918
|
output,
|
|
2523
2919
|
blockerOutput,
|
|
2524
|
-
hasBlockers: blockers.length > 0
|
|
2920
|
+
hasBlockers: blockers.length > 0,
|
|
2921
|
+
...heldBackBlockers.length > 0 && { heldBackBlockers },
|
|
2922
|
+
...preExisting.length > 0 && { preExisting },
|
|
2923
|
+
...stillObserved.length > 0 && { stillObserved },
|
|
2924
|
+
...editScopedRunnerIds.some((id) => !voidedCovers.has(id)) && {
|
|
2925
|
+
editScopedRunnerIds: editScopedRunnerIds.flatMap((id) => voidedCovers.has(id) ? [] : [id])
|
|
2926
|
+
},
|
|
2927
|
+
...(inconclusiveRunnerIds.size > 0 || inconclusiveServerIds.size > 0) && {
|
|
2928
|
+
inconclusiveSources: {
|
|
2929
|
+
runnerIds: [...inconclusiveRunnerIds],
|
|
2930
|
+
serverIds: [...inconclusiveServerIds],
|
|
2931
|
+
collectLaterRunnerIds: [...collectLaterRunnerIds]
|
|
2932
|
+
}
|
|
2933
|
+
},
|
|
2934
|
+
...unconfirmedStatus !== void 0 && { unconfirmedStatus },
|
|
2935
|
+
...coverage !== void 0 && { coverage },
|
|
2936
|
+
...primaryLspChecked && { primaryLspChecked }
|
|
2525
2937
|
};
|
|
2526
2938
|
}
|
|
2527
2939
|
var RUNNER_TIMEOUT_MS = RUNTIME_CONFIG.dispatch.runnerTimeoutMs;
|
|
@@ -2551,10 +2963,15 @@ function normalizeDiagnosticFilePath(ctx, rawPath) {
|
|
|
2551
2963
|
return resolveRunnerPath(ctx.cwd, rawPath || ctx.filePath);
|
|
2552
2964
|
}
|
|
2553
2965
|
function failureRowMetadata(result) {
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2966
|
+
const inconclusive = result.inconclusive === true ? { inconclusive: true } : {};
|
|
2967
|
+
if (result.status === "failed" && result.failureKind) {
|
|
2968
|
+
return {
|
|
2969
|
+
failureKind: result.failureKind,
|
|
2970
|
+
failureMessage: result.failureMessage,
|
|
2971
|
+
...inconclusive
|
|
2972
|
+
};
|
|
2973
|
+
}
|
|
2974
|
+
return result.inconclusive === true ? inconclusive : void 0;
|
|
2558
2975
|
}
|
|
2559
2976
|
async function runRunner(ctx, runner, defaultSemantic) {
|
|
2560
2977
|
const timeoutMs = Math.max(runner.timeoutMs ?? RUNNER_TIMEOUT_MS, getRunnerTimeoutFloorMs());
|
|
@@ -2602,6 +3019,16 @@ var DEFAULT_NEIGHBOUR_BUDGET = 40;
|
|
|
2602
3019
|
var CASCADE_NEIGHBOUR_BUDGET = Math.max(MIN_NEIGHBOUR_BUDGET, Number.parseInt(process.env.PI_LENS_CASCADE_NEIGHBOUR_BUDGET ?? "40", 10) || DEFAULT_NEIGHBOUR_BUDGET);
|
|
2603
3020
|
var NEIGHBOUR_BUDGET_OVERRIDDEN = process.env.PI_LENS_CASCADE_NEIGHBOUR_BUDGET !== void 0 && CASCADE_NEIGHBOUR_BUDGET !== DEFAULT_NEIGHBOUR_BUDGET;
|
|
2604
3021
|
|
|
3022
|
+
// dist/clients/dispatch/runners/utils.js
|
|
3023
|
+
import * as fs4 from "node:fs";
|
|
3024
|
+
function readFileContent(filePath) {
|
|
3025
|
+
try {
|
|
3026
|
+
return fs4.readFileSync(filePath, "utf-8");
|
|
3027
|
+
} catch {
|
|
3028
|
+
return void 0;
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
|
|
2605
3032
|
// dist/clients/dispatch/utils/lsp-diagnostics.js
|
|
2606
3033
|
function convertLspDiagnostics(diags, filePath, options = {}) {
|
|
2607
3034
|
const tool = options.tool ?? "lsp";
|
|
@@ -2630,7 +3057,10 @@ function convertLspDiagnostics(diags, filePath, options = {}) {
|
|
|
2630
3057
|
autoFixAvailable: false,
|
|
2631
3058
|
fixKind: hasSuggestion ? "suggestion" : void 0,
|
|
2632
3059
|
fixSuggestion: options.fixSuggestionByIndex?.get(idx),
|
|
2633
|
-
scanOrigin: options.scanOrigin
|
|
3060
|
+
scanOrigin: options.scanOrigin,
|
|
3061
|
+
// #4484 r2: the publishing server, so a run that leaves it
|
|
3062
|
+
// unconfirmed keeps its recorded blockers. Never identity.
|
|
3063
|
+
...d.serverId !== void 0 && { serverId: d.serverId }
|
|
2634
3064
|
};
|
|
2635
3065
|
});
|
|
2636
3066
|
}
|
|
@@ -2644,7 +3074,8 @@ function applyFindingPolicy(diagnostics, options) {
|
|
|
2644
3074
|
root: options.cwd,
|
|
2645
3075
|
filePath: options.filePath
|
|
2646
3076
|
}),
|
|
2647
|
-
inlineKept
|
|
3077
|
+
inlineKept,
|
|
3078
|
+
disposed
|
|
2648
3079
|
};
|
|
2649
3080
|
}
|
|
2650
3081
|
function loadProjectRulePolicyMap(cwd) {
|
|
@@ -2709,6 +3140,28 @@ function applyPushedFindingPolicy(findings, options) {
|
|
|
2709
3140
|
});
|
|
2710
3141
|
return { kept, suppressed: findings.length - kept.length };
|
|
2711
3142
|
}
|
|
3143
|
+
function applyPushedFindingPolicyByFile(findings, cwd) {
|
|
3144
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
3145
|
+
for (const finding of findings) {
|
|
3146
|
+
const group = byFile.get(finding.filePath);
|
|
3147
|
+
if (group)
|
|
3148
|
+
group.push(finding);
|
|
3149
|
+
else
|
|
3150
|
+
byFile.set(finding.filePath, [finding]);
|
|
3151
|
+
}
|
|
3152
|
+
const kept = [];
|
|
3153
|
+
let suppressed = 0;
|
|
3154
|
+
for (const [filePath, group] of byFile) {
|
|
3155
|
+
const policy = applyPushedFindingPolicy(group, {
|
|
3156
|
+
cwd,
|
|
3157
|
+
filePath,
|
|
3158
|
+
content: readFileContent(filePath)
|
|
3159
|
+
});
|
|
3160
|
+
kept.push(...policy.kept);
|
|
3161
|
+
suppressed += policy.suppressed;
|
|
3162
|
+
}
|
|
3163
|
+
return { kept, suppressed };
|
|
3164
|
+
}
|
|
2712
3165
|
function expandRenderedIdentities(rendered) {
|
|
2713
3166
|
const out = [];
|
|
2714
3167
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -2819,6 +3272,12 @@ function formatCacheAgeLabel(scannedAt, nowMs = Date.now()) {
|
|
|
2819
3272
|
const remMinutes = ageMinutes % 60;
|
|
2820
3273
|
return remMinutes === 0 ? `scanned ${ageHours}h ago` : `scanned ${ageHours}h ${remMinutes}m ago`;
|
|
2821
3274
|
}
|
|
3275
|
+
function dispositionSuppressedLine(suppressed, breakdown) {
|
|
3276
|
+
if (suppressed <= 0)
|
|
3277
|
+
return void 0;
|
|
3278
|
+
const lanes = breakdown ? ` (${breakdown})` : "";
|
|
3279
|
+
return `suppressed by disposition: ${suppressed} finding(s)${lanes} dropped from this result because they're marked false-positive/won't-fix, disabled by \`.pi-lens.json\` rule policy, or suppressed by an inline \`pi-lens-ignore\` comment. Not a clean verdict for those locations \u2014 they were found, then intentionally hidden.`;
|
|
3280
|
+
}
|
|
2822
3281
|
function admitsProjectWideFindings(sessionRole) {
|
|
2823
3282
|
return sessionRole === "primary";
|
|
2824
3283
|
}
|
|
@@ -2932,6 +3391,17 @@ var DELIVERY_SURFACES = {
|
|
|
2932
3391
|
{ evidenceMin: 2 }
|
|
2933
3392
|
),
|
|
2934
3393
|
"runtime-turn:cascade-blocker": labeled(RUNTIME_TURN_FILE, "Turn-end \u{1F9EA} cascade neighbor blocker.", "Cascade results settle synchronously this turn where possible (`settleCascadeRuns`), but an unsettled compute can carry over to a later turn (bounded by a carry cap) \u2014 a carried-over result renders with an explicit `(carried N turns \xB7 scanned Xm ago)` label (#3167, #3168 F3), so the agent can tell it from a fresh observation.", "live", ["cascadeCarrySuffix("], { evidenceMin: 1 }),
|
|
3394
|
+
// #4487: cascade neighbour errors a cascade showed in an EARLIER turn and
|
|
3395
|
+
// no later cascade or edit has shown gone. A cached claim, not a fresh
|
|
3396
|
+
// observation, so each entry passes the freshness gate against its own
|
|
3397
|
+
// read bound (`checkedAt`) before it renders (#4495 review F1, round 3):
|
|
3398
|
+
// a deleted neighbour is forgotten; one written after the check by
|
|
3399
|
+
// something pi never saw is named once as changed and not re-checked.
|
|
3400
|
+
// Survivors carry the `(scanned Xm ago)` age of that read. The evidence is
|
|
3401
|
+
// the two RENDERED lists, so the binding chain walks each back to the gate
|
|
3402
|
+
// call's own arms (a render of the ungated candidates reds, #4495 r2
|
|
3403
|
+
// verify census note).
|
|
3404
|
+
"runtime-turn:cascade-pending-errors": gated(RUNTIME_TURN_FILE, "Turn-end \u{1F4D0} list of cascade neighbour errors shown in an earlier turn and not re-checked since.", ["gateFindingsByPathFreshness"], ["unresolvedNeighbors", "changedShown"]),
|
|
2935
3405
|
"runtime-turn:cascade-coverage-advisory": labeled(RUNTIME_TURN_FILE, "Turn-end cascade-coverage-gap advisories (graph/binding/budget).", "Explains what the cascade check could NOT confirm this turn \u2014 not a finding with a cited path, an absence-of-coverage disclosure computed from this turn's own indeterminate-run list. An advisory computed from a carried indeterminate run is labeled `(carried N turns \xB7 <age>)` (#3167, #3168 F4 \u2014 dropped on mixed carried/fresh buckets). The age half reads `scan age unknown` on this surface today: no indeterminate-run producer stamps `observedAt` (only the resolved-found plumb does, `clients/cascade-format.ts`), and one unstamped carried run collapses the whole bucket's age rather than claiming the stamped runs' (#3168 F13). The carry COUNT is always real.", "live", ["withCarryLabel("], { evidenceMin: 3 }),
|
|
2936
3406
|
// #3102: the cold-neighbour cascade run is BUILT here, in the quiet-window
|
|
2937
3407
|
// reconcile (`onResolvedFound` in index.ts), a turn earlier than the
|
|
@@ -3020,16 +3490,185 @@ var DELIVERY_SURFACES = {
|
|
|
3020
3490
|
"read-guard-tool-lines:preflight-errors": labeled("clients/read-guard-tool-lines.ts", "Read-guard hashline BLOCKED / RE-READ REQUIRED / PARTIAL APPLY / ALREADY APPLIED preflight errors (#2402).", "Computed fresh per edit attempt and returned as that attempt's rejection \u2014 no cached findings are replayed, so there is no staleness window. The PARTIAL APPLY and ALREADY APPLIED variants describe the same attempt's commit outcome; applied-edit recognition reads RuntimeCoordinator's session-scoped record, which resets with the session.", "live"),
|
|
3021
3491
|
"mutating-tool:adapter-preflight-errors": labeled("clients/mutating-tool.ts", "Shape-adapter BLOCKED preflight errors for hashline edit inputs the adapter recognized but could not resolve to a range (#2423).", "Computed fresh from the tool input on each attempt and returned as that attempt's rejection, so there is no staleness window. The adapters read only the call's own arguments; nothing cached is replayed.", "live"),
|
|
3022
3492
|
"tool-call:duplicate-export-blocker": labeled("clients/runtime-tool-call.ts", "Duplicate-export STOP rejection returned inline with the failed edit.", "Synchronous preflight rejection computed per edit attempt; no stored state.", "live"),
|
|
3023
|
-
"agent-behavior:thrashing-notice": labeled("clients/agent-behavior-client.ts", "In-result thrashing/blind-write detection notice.", "Ephemeral notice computed at detection time inside the same tool result \u2014 no persistence and no cache, so nothing can be stale.", "live")
|
|
3493
|
+
"agent-behavior:thrashing-notice": labeled("clients/agent-behavior-client.ts", "In-result thrashing/blind-write detection notice.", "Ephemeral notice computed at detection time inside the same tool result \u2014 no persistence and no cache, so nothing can be stale.", "live"),
|
|
3494
|
+
// ── #1634 enumeration round: the rest of the agent-facing sinks ─────────
|
|
3495
|
+
// Found by the sink census in `tests/clients/finding-delivery-gate.test.ts`,
|
|
3496
|
+
// which derives every production file holding an agent-facing sink (a tool
|
|
3497
|
+
// result's text block, a context or hook message, a tool_call block, a
|
|
3498
|
+
// custom entry, a status/widget line) and fails on one that is neither a
|
|
3499
|
+
// surface `file` here nor classified there.
|
|
3500
|
+
"lsp-navigation:workspace-diagnostics-path": gated(
|
|
3501
|
+
"tools/lsp-navigation.ts",
|
|
3502
|
+
"`lsp_navigation workspaceDiagnostics` with a path: the server's answer for that file, read after a touch that waits for diagnostics.",
|
|
3503
|
+
["applyProbeFindingPolicy"],
|
|
3504
|
+
// The path read and the tracked snapshot below are the two calls.
|
|
3505
|
+
["applyProbeFindingPolicy("],
|
|
3506
|
+
{ evidenceMin: 2 }
|
|
3507
|
+
),
|
|
3508
|
+
"lsp-navigation:tracked-snapshot": labeled("tools/lsp-navigation.ts", "`lsp_navigation workspaceDiagnostics` with no path: each tracked file's last client publish.", "A replay of what each language client last published, with no re-check of the file, so every row states its age. The rows also pass the same finding policy as the path read (`readFileContent` supplies the current content), so the label and the disposition filter compose.", "LSP client publish ts", ["lag: formatCacheAgeLabel(ts)", "readFileContent(trackedFile)"]),
|
|
3509
|
+
"runtime-context:persisted-findings": gated(
|
|
3510
|
+
"clients/runtime-context.ts",
|
|
3511
|
+
"Persisted turn-end and test-runner findings replayed into the next context message, the MCP turn_end tool and the Stop hook.",
|
|
3512
|
+
["validateAdvisoryProvenance"],
|
|
3513
|
+
// peekTurnEndFindings, consumeTurnEndFindings, peekTestFindings.
|
|
3514
|
+
["validateAdvisoryProvenance(findings.data, cwd, runtime)"],
|
|
3515
|
+
{ evidenceMin: 3 }
|
|
3516
|
+
),
|
|
3517
|
+
"index:turn-summary": labeled("index.ts", "One-line turn summary custom entry (`--lens-turn-summary`).", "Counts drained from this turn's own accumulator (`runtime.turnSummary.consume`) at the quiet window; nothing is replayed from a cache.", "live"),
|
|
3518
|
+
"lens-engine:project-scan": gated("clients/lens-engine.ts", "`pilens_project_scan` (MCP): a fresh cheap project scan.", ["applyPushedFindingPolicyByFile"], ["applyPushedFindingPolicyByFile(scan.diagnostics, cwd)"]),
|
|
3519
|
+
"mcp-server:analyze": labeled("mcp/server.ts", "`pilens_analyze` (MCP): one file's dispatch result.", "A dispatch run for this call, warm or in a fresh worker; the dispatcher applies the finding policy before it returns.", "live"),
|
|
3520
|
+
"mcp-analyze-cli:post-edit-report": labeled("mcp/analyze-cli.ts", "Claude Code PostToolUse hook report (`analyze-cli --hook`).", "Same per-call dispatch as `pilens_analyze`; its Stop-hook output is the `runtime-context:persisted-findings` replay or a fresh turn-end pass.", "live")
|
|
3024
3521
|
};
|
|
3025
3522
|
|
|
3026
3523
|
// dist/clients/cascade-format.js
|
|
3524
|
+
function formatCascadeNeighborDiagnostics(cwd, neighbors, options = {}) {
|
|
3525
|
+
const withErrors = neighbors.filter((n) => n.diagnostics.length > 0);
|
|
3526
|
+
const inconclusive = neighbors.filter((n) => n.inconclusive === true && n.diagnostics.length === 0);
|
|
3527
|
+
const uncovered = neighbors.filter((n) => n.diagnostics.length === 0 && n.inconclusive !== true && (n.unconfirmedServerIds?.length ?? 0) > 0);
|
|
3528
|
+
if (withErrors.length === 0 && inconclusive.length === 0 && uncovered.length === 0) {
|
|
3529
|
+
return "";
|
|
3530
|
+
}
|
|
3531
|
+
const noun = options.noun ?? "neighbor";
|
|
3532
|
+
let out = withErrors.length > 0 ? `\u{1F4D0} Cascade errors in ${withErrors.length} ${noun} file(s) \u2014 fix before finishing turn:` : "";
|
|
3533
|
+
for (const neighbor of withErrors) {
|
|
3534
|
+
const display = toRunnerDisplayPath(cwd, neighbor.filePath);
|
|
3535
|
+
const reason = options.includeReason ? ` reason="${neighbor.reason}"` : "";
|
|
3536
|
+
out += `
|
|
3537
|
+
<diagnostics file="${display}"${reason}>`;
|
|
3538
|
+
for (const d of neighbor.diagnostics) {
|
|
3539
|
+
const line = d.line ?? 1;
|
|
3540
|
+
const col = d.column ?? 1;
|
|
3541
|
+
const rule = d.rule ? ` rule=${d.rule}` : "";
|
|
3542
|
+
const since = options.stillPresentSince?.(neighbor, d);
|
|
3543
|
+
const label = since === void 0 ? "" : ` (still present since turn ${since})`;
|
|
3544
|
+
out += `
|
|
3545
|
+
line ${line}, col ${col}${rule}: ${d.message.split("\n")[0].slice(0, 100)}${label}`;
|
|
3546
|
+
}
|
|
3547
|
+
out += "\n</diagnostics>";
|
|
3548
|
+
}
|
|
3549
|
+
if (inconclusive.length > 0) {
|
|
3550
|
+
if (out)
|
|
3551
|
+
out += "\n";
|
|
3552
|
+
out += `\u26A0\uFE0F Cascade diagnostics inconclusive for ${inconclusive.length} ${noun} file(s) \u2014 no clean result was confirmed:`;
|
|
3553
|
+
for (const neighbor of inconclusive) {
|
|
3554
|
+
out += `
|
|
3555
|
+
${toRunnerDisplayPath(cwd, neighbor.filePath)}`;
|
|
3556
|
+
}
|
|
3557
|
+
}
|
|
3558
|
+
if (uncovered.length > 0) {
|
|
3559
|
+
if (out)
|
|
3560
|
+
out += "\n";
|
|
3561
|
+
out += `\u26A0\uFE0F Cascade scanners did not cover ${uncovered.length} ${noun} file(s) \u2014 no findings does NOT mean clean here:`;
|
|
3562
|
+
for (const neighbor of uncovered) {
|
|
3563
|
+
const servers = (neighbor.unconfirmedServerIds ?? []).join(", ");
|
|
3564
|
+
out += `
|
|
3565
|
+
${toRunnerDisplayPath(cwd, neighbor.filePath)} (not scanned by ${servers})`;
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
return out;
|
|
3569
|
+
}
|
|
3570
|
+
function composeCascadeSection(block, layout, unansweredPrimaryNote = "") {
|
|
3571
|
+
const diagnosticsBlock = block && unansweredPrimaryNote ? `${block}
|
|
3572
|
+
${unansweredPrimaryNote}` : block || unansweredPrimaryNote;
|
|
3573
|
+
if (!diagnosticsBlock && !layout.coverageLine)
|
|
3574
|
+
return "";
|
|
3575
|
+
let out = !diagnosticsBlock ? "" : layout.header ? `${layout.header}
|
|
3576
|
+
${diagnosticsBlock}` : diagnosticsBlock;
|
|
3577
|
+
if (layout.truncationLine)
|
|
3578
|
+
out += `
|
|
3579
|
+
${layout.truncationLine}`;
|
|
3580
|
+
if (layout.coverageLine) {
|
|
3581
|
+
if (out)
|
|
3582
|
+
out += "\n";
|
|
3583
|
+
out += layout.coverageLine;
|
|
3584
|
+
}
|
|
3585
|
+
if (layout.policySuppressed > 0) {
|
|
3586
|
+
out += `
|
|
3587
|
+
suppressed by disposition: ${layout.policySuppressed} finding(s) (marked false-positive or won't-fix).`;
|
|
3588
|
+
}
|
|
3589
|
+
return out;
|
|
3590
|
+
}
|
|
3027
3591
|
function cascadeCarrySuffix(carriedTurns, observedAt) {
|
|
3028
3592
|
if (carriedTurns === void 0 || carriedTurns < 1)
|
|
3029
3593
|
return void 0;
|
|
3030
3594
|
const noun = carriedTurns === 1 ? "turn" : "turns";
|
|
3031
3595
|
return `(carried ${carriedTurns} ${noun} \xB7 ${formatCacheAgeLabel(observedAt)})`;
|
|
3032
3596
|
}
|
|
3597
|
+
var cascadeUnansweredPrimariesDelivered = /* @__PURE__ */ new Set();
|
|
3598
|
+
function resetCascadeUnansweredPrimariesDelivered() {
|
|
3599
|
+
cascadeUnansweredPrimariesDelivered.clear();
|
|
3600
|
+
}
|
|
3601
|
+
function markCascadeUnansweredPrimariesDelivered(serverIds) {
|
|
3602
|
+
for (const id of serverIds)
|
|
3603
|
+
cascadeUnansweredPrimariesDelivered.add(id);
|
|
3604
|
+
}
|
|
3605
|
+
function renderCascadeResult(result, shownServerIds) {
|
|
3606
|
+
const unanswered = result.unansweredPrimaries;
|
|
3607
|
+
if (!unanswered)
|
|
3608
|
+
return { text: result.formatted, lines: [], serverIds: [] };
|
|
3609
|
+
const kept = unanswered.notes.filter((note) => note.serverIds.some((id) => !cascadeUnansweredPrimariesDelivered.has(id) && !shownServerIds.has(id)));
|
|
3610
|
+
const serverIds = kept.flatMap((note) => [...note.serverIds]);
|
|
3611
|
+
for (const id of serverIds)
|
|
3612
|
+
shownServerIds.add(id);
|
|
3613
|
+
return {
|
|
3614
|
+
text: unanswered.formattedWithoutNotes,
|
|
3615
|
+
lines: kept.map((note) => note.line),
|
|
3616
|
+
serverIds
|
|
3617
|
+
};
|
|
3618
|
+
}
|
|
3619
|
+
var MAX_PENDING_NEIGHBORS = 256;
|
|
3620
|
+
var pendingNeighbors = new BoundedFifoMap(MAX_PENDING_NEIGHBORS);
|
|
3621
|
+
function cascadeErrorKey(diagnostic) {
|
|
3622
|
+
return [
|
|
3623
|
+
diagnostic.id,
|
|
3624
|
+
diagnostic.rule ?? "",
|
|
3625
|
+
diagnostic.line ?? 0,
|
|
3626
|
+
diagnostic.column ?? 0,
|
|
3627
|
+
diagnostic.message
|
|
3628
|
+
].join(":");
|
|
3629
|
+
}
|
|
3630
|
+
function cascadeStillPresentSince(filePath, diagnostic, turn) {
|
|
3631
|
+
const first = pendingNeighbors.get(normalizeMapKey(filePath))?.errors.get(cascadeErrorKey(diagnostic));
|
|
3632
|
+
return first !== void 0 && first < turn ? first : void 0;
|
|
3633
|
+
}
|
|
3634
|
+
function recordDeliveredCascadeNeighbor(filePath, diagnostics, turn, checkedAt) {
|
|
3635
|
+
const key2 = normalizeMapKey(filePath);
|
|
3636
|
+
const previous = pendingNeighbors.get(key2);
|
|
3637
|
+
const errors = /* @__PURE__ */ new Map();
|
|
3638
|
+
for (const d of diagnostics) {
|
|
3639
|
+
const k = cascadeErrorKey(d);
|
|
3640
|
+
errors.set(k, previous?.errors.get(k) ?? turn);
|
|
3641
|
+
}
|
|
3642
|
+
pendingNeighbors.delete(key2);
|
|
3643
|
+
if (errors.size === 0)
|
|
3644
|
+
return;
|
|
3645
|
+
if (pendingNeighbors.set(key2, { filePath, errors, checkedAt }).length > 0) {
|
|
3646
|
+
recordDegradationOnce({
|
|
3647
|
+
kind: "cascade-pending-neighbors-evicted",
|
|
3648
|
+
subject: `cap=${MAX_PENDING_NEIGHBORS}`,
|
|
3649
|
+
reason: "the pending cascade neighbour-error record hit its cap; the oldest neighbour's errors are no longer re-served"
|
|
3650
|
+
});
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
function forgetCascadePendingNeighbor(filePath, observedAt) {
|
|
3654
|
+
const key2 = normalizeMapKey(filePath);
|
|
3655
|
+
const entry = pendingNeighbors.get(key2);
|
|
3656
|
+
if (!entry)
|
|
3657
|
+
return;
|
|
3658
|
+
if (observedAt !== void 0 && observedAt <= entry.checkedAt)
|
|
3659
|
+
return;
|
|
3660
|
+
pendingNeighbors.delete(key2);
|
|
3661
|
+
}
|
|
3662
|
+
function listCascadePendingNeighbors() {
|
|
3663
|
+
return [...pendingNeighbors.values()].map((entry) => ({
|
|
3664
|
+
filePath: entry.filePath,
|
|
3665
|
+
errorCount: entry.errors.size,
|
|
3666
|
+
checkedAt: entry.checkedAt
|
|
3667
|
+
}));
|
|
3668
|
+
}
|
|
3669
|
+
function resetCascadePendingNeighbors() {
|
|
3670
|
+
pendingNeighbors.clear();
|
|
3671
|
+
}
|
|
3033
3672
|
|
|
3034
3673
|
// dist/clients/cascade-logger.js
|
|
3035
3674
|
import * as path5 from "node:path";
|
|
@@ -3142,33 +3781,152 @@ function createDiagnosticTracker() {
|
|
|
3142
3781
|
}
|
|
3143
3782
|
|
|
3144
3783
|
// dist/clients/lsp/cascade-tier.js
|
|
3784
|
+
var MAX_OUTSTANDING_TOUCHES = 256;
|
|
3145
3785
|
var OUTSTANDING_TOUCH_MAX_AGE_MS = 15 * 6e4;
|
|
3146
|
-
var _outstandingTouches =
|
|
3786
|
+
var _outstandingTouches = new BoundedFifoMap(MAX_OUTSTANDING_TOUCHES);
|
|
3147
3787
|
var _expiredSinceLastSweep = 0;
|
|
3148
3788
|
var _evictedSinceLastSweep = 0;
|
|
3789
|
+
var MAX_LOGGED_PATHS = 20;
|
|
3790
|
+
function pruneExpiredOutstandingTouches(now, guard, reads = /* @__PURE__ */ new Map()) {
|
|
3791
|
+
const expired = [];
|
|
3792
|
+
for (const [key2, touch] of _outstandingTouches) {
|
|
3793
|
+
if (now - touch.touchedAt <= OUTSTANDING_TOUCH_MAX_AGE_MS)
|
|
3794
|
+
break;
|
|
3795
|
+
_outstandingTouches.delete(key2);
|
|
3796
|
+
_expiredSinceLastSweep++;
|
|
3797
|
+
expired.push(touch);
|
|
3798
|
+
}
|
|
3799
|
+
if (expired.length === 0)
|
|
3800
|
+
return;
|
|
3801
|
+
let found = 0;
|
|
3802
|
+
let clean = 0;
|
|
3803
|
+
for (const touch of expired) {
|
|
3804
|
+
const outcome = readTouchedClient(touch, now, reads);
|
|
3805
|
+
if (!outcome)
|
|
3806
|
+
continue;
|
|
3807
|
+
if (outcome.outcome === "resolved-found")
|
|
3808
|
+
found++;
|
|
3809
|
+
else
|
|
3810
|
+
clean++;
|
|
3811
|
+
deliverResolvedOutcome(outcome, guard);
|
|
3812
|
+
}
|
|
3813
|
+
logCascade({
|
|
3814
|
+
phase: "cascade_tier3_expired",
|
|
3815
|
+
filePath: "<cascade-registry>",
|
|
3816
|
+
metadata: {
|
|
3817
|
+
count: expired.length,
|
|
3818
|
+
found,
|
|
3819
|
+
clean,
|
|
3820
|
+
unanswered: expired.length - found - clean,
|
|
3821
|
+
maxAgeCapMs: OUTSTANDING_TOUCH_MAX_AGE_MS,
|
|
3822
|
+
paths: expired.slice(0, MAX_LOGGED_PATHS).map((t) => t.filePath),
|
|
3823
|
+
...expired.length > MAX_LOGGED_PATHS && {
|
|
3824
|
+
pathsTruncated: expired.length - MAX_LOGGED_PATHS
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3827
|
+
});
|
|
3828
|
+
}
|
|
3829
|
+
function readTouchedClient(touch, now, reads) {
|
|
3830
|
+
const client = touch.client?.deref();
|
|
3831
|
+
if (!client || client.serverId !== touch.serverId)
|
|
3832
|
+
return void 0;
|
|
3833
|
+
if (client.isAlive?.() === false)
|
|
3834
|
+
return void 0;
|
|
3835
|
+
let all = reads.get(client);
|
|
3836
|
+
if (all === void 0) {
|
|
3837
|
+
all = client.getAllDiagnostics();
|
|
3838
|
+
reads.set(client, all);
|
|
3839
|
+
}
|
|
3840
|
+
const entry = all.get(normalizeMapKey(touch.filePath));
|
|
3841
|
+
if (!entry || entry.ts <= touch.touchedAt)
|
|
3842
|
+
return void 0;
|
|
3843
|
+
const found = entry.diags.length > 0;
|
|
3844
|
+
return {
|
|
3845
|
+
filePath: touch.filePath,
|
|
3846
|
+
serverId: touch.serverId,
|
|
3847
|
+
outcome: found ? "resolved-found" : "resolved-clean",
|
|
3848
|
+
ageMs: now - touch.touchedAt,
|
|
3849
|
+
diagnosticCount: entry.diags.length,
|
|
3850
|
+
publishedAt: entry.ts,
|
|
3851
|
+
touchedAt: touch.touchedAt,
|
|
3852
|
+
...found && { diagnostics: entry.diags }
|
|
3853
|
+
};
|
|
3854
|
+
}
|
|
3855
|
+
function deliverResolvedOutcome(o, guard) {
|
|
3856
|
+
try {
|
|
3857
|
+
if (o.outcome === "resolved-found" && o.diagnostics?.length) {
|
|
3858
|
+
const neighbor = {
|
|
3859
|
+
filePath: o.filePath,
|
|
3860
|
+
serverId: o.serverId,
|
|
3861
|
+
diagnostics: o.diagnostics,
|
|
3862
|
+
...o.publishedAt !== void 0 ? { publishedAt: o.publishedAt } : {},
|
|
3863
|
+
...o.touchedAt !== void 0 ? { touchedAt: o.touchedAt } : {}
|
|
3864
|
+
};
|
|
3865
|
+
const deliver = () => _reconcileOptions.onResolvedFound?.(neighbor);
|
|
3866
|
+
if (guard)
|
|
3867
|
+
guard.guardedWrite(o.filePath, deliver);
|
|
3868
|
+
else
|
|
3869
|
+
deliver();
|
|
3870
|
+
} else if (o.outcome === "resolved-clean" && o.publishedAt != null) {
|
|
3871
|
+
_reconcileOptions.onResolvedClean?.({
|
|
3872
|
+
filePath: o.filePath,
|
|
3873
|
+
serverId: o.serverId,
|
|
3874
|
+
publishedAt: o.publishedAt
|
|
3875
|
+
});
|
|
3876
|
+
}
|
|
3877
|
+
} catch {
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3149
3880
|
function resetCascadeTierSessionState() {
|
|
3881
|
+
const dropped = _outstandingTouches.size;
|
|
3150
3882
|
_outstandingTouches.clear();
|
|
3151
3883
|
_expiredSinceLastSweep = 0;
|
|
3152
3884
|
_evictedSinceLastSweep = 0;
|
|
3885
|
+
if (dropped > 0) {
|
|
3886
|
+
logCascade({
|
|
3887
|
+
phase: "cascade_tier3_dropped",
|
|
3888
|
+
filePath: "<session-reset>",
|
|
3889
|
+
metadata: { count: dropped }
|
|
3890
|
+
});
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
function peekOutstandingCascadeTouches(guard) {
|
|
3894
|
+
const now = Date.now();
|
|
3895
|
+
const reads = /* @__PURE__ */ new Map();
|
|
3896
|
+
pruneExpiredOutstandingTouches(now, guard, reads);
|
|
3897
|
+
const count = _outstandingTouches.size;
|
|
3898
|
+
if (count === 0)
|
|
3899
|
+
return;
|
|
3900
|
+
let found = 0;
|
|
3901
|
+
let clean = 0;
|
|
3902
|
+
for (const [key2, touch] of _outstandingTouches) {
|
|
3903
|
+
const outcome = readTouchedClient(touch, now, reads);
|
|
3904
|
+
if (!outcome)
|
|
3905
|
+
continue;
|
|
3906
|
+
_outstandingTouches.delete(key2);
|
|
3907
|
+
if (outcome.outcome === "resolved-found")
|
|
3908
|
+
found++;
|
|
3909
|
+
else
|
|
3910
|
+
clean++;
|
|
3911
|
+
deliverResolvedOutcome(outcome, guard);
|
|
3912
|
+
}
|
|
3913
|
+
logCascade({
|
|
3914
|
+
phase: "cascade_tier3_peek",
|
|
3915
|
+
filePath: "<turn_end>",
|
|
3916
|
+
metadata: {
|
|
3917
|
+
count,
|
|
3918
|
+
found,
|
|
3919
|
+
clean,
|
|
3920
|
+
outstanding: _outstandingTouches.size
|
|
3921
|
+
}
|
|
3922
|
+
});
|
|
3153
3923
|
}
|
|
3924
|
+
var _reconcileOptions = {};
|
|
3154
3925
|
|
|
3155
3926
|
// dist/clients/dispatch/runners/ast-grep-napi.js
|
|
3156
|
-
import * as
|
|
3927
|
+
import * as fs5 from "node:fs";
|
|
3157
3928
|
import * as path6 from "node:path";
|
|
3158
3929
|
|
|
3159
|
-
// dist/clients/deps/ast-grep-napi.js
|
|
3160
|
-
import { createRequire } from "node:module";
|
|
3161
|
-
import { pathToFileURL } from "node:url";
|
|
3162
|
-
var _require = createRequire(import.meta.url);
|
|
3163
|
-
function loadAstGrepNapi() {
|
|
3164
|
-
try {
|
|
3165
|
-
const entry = _require.resolve("@ast-grep/napi");
|
|
3166
|
-
return import(pathToFileURL(entry).href);
|
|
3167
|
-
} catch {
|
|
3168
|
-
return import("@ast-grep/napi");
|
|
3169
|
-
}
|
|
3170
|
-
}
|
|
3171
|
-
|
|
3172
3930
|
// dist/clients/dispatch/priorities.js
|
|
3173
3931
|
var PRIORITY = {
|
|
3174
3932
|
LSP_PRIMARY: 4,
|
|
@@ -3185,6 +3943,66 @@ var PRIORITY = {
|
|
|
3185
3943
|
DEEP_LANGUAGE_ANALYSIS: 50
|
|
3186
3944
|
};
|
|
3187
3945
|
|
|
3946
|
+
// dist/clients/dispatch/runners/ast-grep-literal-anchors.js
|
|
3947
|
+
var PATTERN_WORD = /\$?[A-Za-z_]\w*/g;
|
|
3948
|
+
var LITERAL_REGEX = /^\^?((?:[A-Za-z0-9_"'`:\- =!<>/@#%&,;~]|\\\.)+)\$?$/;
|
|
3949
|
+
var RELATIONAL_KEYS = ["has", "inside", "follows", "precedes"];
|
|
3950
|
+
function ownLiterals(node) {
|
|
3951
|
+
const literals = [];
|
|
3952
|
+
if (typeof node.pattern === "string") {
|
|
3953
|
+
for (const word of node.pattern.match(PATTERN_WORD) ?? []) {
|
|
3954
|
+
if (!word.startsWith("$"))
|
|
3955
|
+
literals.push(word);
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
const regex = typeof node.regex === "string" ? node.regex : "";
|
|
3959
|
+
const literal = LITERAL_REGEX.exec(regex)?.[1];
|
|
3960
|
+
if (literal)
|
|
3961
|
+
literals.push(literal.replaceAll(String.raw`\.`, "."));
|
|
3962
|
+
return literals;
|
|
3963
|
+
}
|
|
3964
|
+
function anyOf(branches) {
|
|
3965
|
+
if (branches.length === 0 || branches.includes(true))
|
|
3966
|
+
return true;
|
|
3967
|
+
return { or: branches };
|
|
3968
|
+
}
|
|
3969
|
+
function requirementOf(node, utils, resolving) {
|
|
3970
|
+
if (!node || typeof node !== "object")
|
|
3971
|
+
return true;
|
|
3972
|
+
const of = (child) => requirementOf(child, utils, resolving);
|
|
3973
|
+
const parts = [
|
|
3974
|
+
...ownLiterals(node),
|
|
3975
|
+
...RELATIONAL_KEYS.map((key2) => of(node[key2])),
|
|
3976
|
+
...Array.isArray(node.all) ? node.all.map(of) : [],
|
|
3977
|
+
Array.isArray(node.any) ? anyOf(node.any.map(of)) : true
|
|
3978
|
+
];
|
|
3979
|
+
const name = node.matches;
|
|
3980
|
+
if (typeof name === "string" && utils != null && Object.hasOwn(utils, name) && !resolving.has(name)) {
|
|
3981
|
+
parts.push(requirementOf(utils[name], utils, /* @__PURE__ */ new Set([...resolving, name])));
|
|
3982
|
+
}
|
|
3983
|
+
const required = parts.filter((part) => part !== true);
|
|
3984
|
+
return required.length === 0 ? true : { and: required };
|
|
3985
|
+
}
|
|
3986
|
+
function satisfied(requirement, text) {
|
|
3987
|
+
if (requirement === true)
|
|
3988
|
+
return true;
|
|
3989
|
+
if (typeof requirement === "string")
|
|
3990
|
+
return text.includes(requirement);
|
|
3991
|
+
if ("and" in requirement) {
|
|
3992
|
+
return requirement.and.every((part) => satisfied(part, text));
|
|
3993
|
+
}
|
|
3994
|
+
return requirement.or.some((part) => satisfied(part, text));
|
|
3995
|
+
}
|
|
3996
|
+
var requirements = /* @__PURE__ */ new WeakMap();
|
|
3997
|
+
function ruleCanMatchText(rule, text) {
|
|
3998
|
+
let requirement = requirements.get(rule);
|
|
3999
|
+
if (requirement === void 0) {
|
|
4000
|
+
requirement = requirementOf(rule.rule, rule.utils, /* @__PURE__ */ new Set());
|
|
4001
|
+
requirements.set(rule, requirement);
|
|
4002
|
+
}
|
|
4003
|
+
return satisfied(requirement, text);
|
|
4004
|
+
}
|
|
4005
|
+
|
|
3188
4006
|
// dist/clients/dispatch/runners/ast-grep-napi.js
|
|
3189
4007
|
var defaultUnsupportedLanguageLog = /* @__PURE__ */ new Set();
|
|
3190
4008
|
var UNSUPPORTED_RULE_ID_SAMPLE_SIZE = 5;
|
|
@@ -3702,12 +4520,19 @@ function evaluateAstGrepRules(filePath, rootNode, cwd, kind, options = {}) {
|
|
|
3702
4520
|
}
|
|
3703
4521
|
if (!rule.rule)
|
|
3704
4522
|
continue;
|
|
4523
|
+
if (options.content !== void 0 && !ruleCanMatchText(rule, options.content)) {
|
|
4524
|
+
continue;
|
|
4525
|
+
}
|
|
3705
4526
|
try {
|
|
3706
4527
|
const scopes = runsInsideHtmlScript ? htmlInjections.map((injection) => ({
|
|
3707
4528
|
root: injection.root,
|
|
3708
4529
|
position(match) {
|
|
3709
4530
|
const start = match.range().start;
|
|
3710
4531
|
return filePositionForIndex(fileLineStarts, injection.startIndex + start.index);
|
|
4532
|
+
},
|
|
4533
|
+
endLine(match) {
|
|
4534
|
+
const end = match.range().end;
|
|
4535
|
+
return filePositionForIndex(fileLineStarts, injection.startIndex + end.index).line;
|
|
3711
4536
|
}
|
|
3712
4537
|
})) : [
|
|
3713
4538
|
{
|
|
@@ -3715,6 +4540,9 @@ function evaluateAstGrepRules(filePath, rootNode, cwd, kind, options = {}) {
|
|
|
3715
4540
|
position(match) {
|
|
3716
4541
|
const start = match.range().start;
|
|
3717
4542
|
return { line: start.line, column: start.column };
|
|
4543
|
+
},
|
|
4544
|
+
endLine(match) {
|
|
4545
|
+
return match.range().end.line;
|
|
3718
4546
|
}
|
|
3719
4547
|
}
|
|
3720
4548
|
];
|
|
@@ -3724,7 +4552,9 @@ function evaluateAstGrepRules(filePath, rootNode, cwd, kind, options = {}) {
|
|
|
3724
4552
|
if (rule.utils)
|
|
3725
4553
|
nativeConfig.utils = rule.utils;
|
|
3726
4554
|
const collected = [];
|
|
4555
|
+
const withheld = [];
|
|
3727
4556
|
let rejectLogged = false;
|
|
4557
|
+
const editScoped = options.modifiedRanges !== void 0 && normalizeRuleSeverity(rule.severity) === "error";
|
|
3728
4558
|
for (const scope of scopes) {
|
|
3729
4559
|
let found;
|
|
3730
4560
|
try {
|
|
@@ -3739,19 +4569,23 @@ function evaluateAstGrepRules(filePath, rootNode, cwd, kind, options = {}) {
|
|
|
3739
4569
|
for (const match of found) {
|
|
3740
4570
|
if (collected.length >= maxMatchesPerRule)
|
|
3741
4571
|
break;
|
|
3742
|
-
|
|
4572
|
+
const position = scope.position(match);
|
|
4573
|
+
if (editScoped && !spanOverlapsModifiedRanges(position.line + 1, scope.endLine(match) + 1, options.modifiedRanges)) {
|
|
4574
|
+
if (withheld.length < maxMatchesPerRule)
|
|
4575
|
+
withheld.push({ position });
|
|
4576
|
+
continue;
|
|
4577
|
+
}
|
|
4578
|
+
collected.push({ match, position });
|
|
3743
4579
|
}
|
|
3744
4580
|
if (collected.length >= maxMatchesPerRule)
|
|
3745
4581
|
break;
|
|
3746
4582
|
}
|
|
3747
|
-
|
|
3748
|
-
if (diagnostics.length >= maxTotalDiagnostics)
|
|
3749
|
-
break;
|
|
4583
|
+
const toDiagnostic3 = (position) => {
|
|
3750
4584
|
const severity = normalizeRuleSeverity(rule.severity);
|
|
3751
4585
|
const semantic = severity === "error" ? "blocking" : "warning";
|
|
3752
4586
|
const defectClass = classifyDefect(rule.id, "ast-grep-napi", rule.message || rule.id);
|
|
3753
4587
|
const ruleFix = explicitRuleFixSuggestion(rule);
|
|
3754
|
-
|
|
4588
|
+
return {
|
|
3755
4589
|
id: `ast-grep-napi-${position.line}-${rule.id}`,
|
|
3756
4590
|
message: `[${rule.metadata?.category || "slop"}] ${rule.message || rule.id}`,
|
|
3757
4591
|
filePath,
|
|
@@ -3766,7 +4600,15 @@ function evaluateAstGrepRules(filePath, rootNode, cwd, kind, options = {}) {
|
|
|
3766
4600
|
autoFixAvailable: false,
|
|
3767
4601
|
fixKind: ruleFix ? "suggestion" : void 0,
|
|
3768
4602
|
fixSuggestion: semantic === "blocking" ? ruleFix ?? defaultFixSuggestion(defectClass, rule.id) : ruleFix
|
|
3769
|
-
}
|
|
4603
|
+
};
|
|
4604
|
+
};
|
|
4605
|
+
for (const { position } of collected) {
|
|
4606
|
+
if (diagnostics.length >= maxTotalDiagnostics)
|
|
4607
|
+
break;
|
|
4608
|
+
diagnostics.push(toDiagnostic3(position));
|
|
4609
|
+
}
|
|
4610
|
+
for (const { position } of withheld) {
|
|
4611
|
+
options.outOfEditScope?.push(toDiagnostic3(position));
|
|
3770
4612
|
}
|
|
3771
4613
|
if (diagnostics.length >= maxTotalDiagnostics)
|
|
3772
4614
|
break;
|
|
@@ -3788,8 +4630,10 @@ var astGrepNapiRunner = {
|
|
|
3788
4630
|
}
|
|
3789
4631
|
const astGrepLspEnabled = enabledAuxiliaryLspServerIds((f) => ctx.pi?.getFlag?.(f)).includes("ast-grep");
|
|
3790
4632
|
const astGrepLspPublished = astGrepLspEnabled ? await hasAuxiliaryLspPublishedForRoot("ast-grep", ctx.filePath) : false;
|
|
3791
|
-
|
|
3792
|
-
|
|
4633
|
+
const coveredByServer = astGrepLspEnabled && astGrepLspPublished;
|
|
4634
|
+
if (coveredByServer && !ctx.recordedRunnerIds?.has("ast-grep-napi")) {
|
|
4635
|
+
const coveragePending = hasPendingAuxiliaryCoverage(ctx.filePath, "ast-grep");
|
|
4636
|
+
if (coveragePending) {
|
|
3793
4637
|
incrementDegradationCount({
|
|
3794
4638
|
kind: "aux-runner-findings-lost",
|
|
3795
4639
|
subject: "ast-grep",
|
|
@@ -3798,13 +4642,23 @@ var astGrepNapiRunner = {
|
|
|
3798
4642
|
reason: `Gate B skipped napi: pending late-auxiliary pair from an EARLIER touch remains undelivered while prior publication satisfies per-file gate (file: ${ctx.filePath})`
|
|
3799
4643
|
});
|
|
3800
4644
|
}
|
|
3801
|
-
return {
|
|
4645
|
+
return {
|
|
4646
|
+
status: "skipped",
|
|
4647
|
+
diagnostics: [],
|
|
4648
|
+
semantic: "none",
|
|
4649
|
+
// Round 7: the verdict holds only if the server's host answered.
|
|
4650
|
+
...coveragePending ? {} : {
|
|
4651
|
+
skipReason: "covered-by-primary",
|
|
4652
|
+
coveredBy: { runnerId: "lsp", serverId: "ast-grep" }
|
|
4653
|
+
},
|
|
4654
|
+
...ctx.blockingOnly && ctx.modifiedRanges?.length ? { editScopedVerdict: true } : {}
|
|
4655
|
+
};
|
|
3802
4656
|
}
|
|
3803
4657
|
const sgModule = await loadSg();
|
|
3804
4658
|
if (!sgModule) {
|
|
3805
4659
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
3806
4660
|
}
|
|
3807
|
-
if (!
|
|
4661
|
+
if (!fs5.existsSync(ctx.filePath)) {
|
|
3808
4662
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
3809
4663
|
}
|
|
3810
4664
|
const lang = getLang(ctx.filePath, sgModule);
|
|
@@ -3813,7 +4667,7 @@ var astGrepNapiRunner = {
|
|
|
3813
4667
|
}
|
|
3814
4668
|
let stats;
|
|
3815
4669
|
try {
|
|
3816
|
-
stats =
|
|
4670
|
+
stats = fs5.statSync(ctx.filePath);
|
|
3817
4671
|
} catch {
|
|
3818
4672
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
3819
4673
|
}
|
|
@@ -3826,7 +4680,7 @@ var astGrepNapiRunner = {
|
|
|
3826
4680
|
content = contentFromFacts;
|
|
3827
4681
|
} else {
|
|
3828
4682
|
try {
|
|
3829
|
-
content =
|
|
4683
|
+
content = fs5.readFileSync(ctx.filePath, "utf-8");
|
|
3830
4684
|
} catch {
|
|
3831
4685
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
3832
4686
|
}
|
|
@@ -3848,10 +4702,16 @@ var astGrepNapiRunner = {
|
|
|
3848
4702
|
recordNapiFallbackCoverage(ctx.filePath);
|
|
3849
4703
|
clearPendingAuxiliaryCoverage(ctx.filePath, "ast-grep");
|
|
3850
4704
|
}
|
|
4705
|
+
const outOfEditScope = [];
|
|
3851
4706
|
const diagnostics = evaluateAstGrepRules(ctx.filePath, rootNode, ctx.cwd, ctx.kind, {
|
|
3852
4707
|
blockingOnly: runningAsLspSubstitute ? false : ctx.blockingOnly,
|
|
3853
4708
|
projectRoot: ctx.projectRoot,
|
|
3854
4709
|
rulePolicy: ctx.rulePolicy,
|
|
4710
|
+
// #4481: keyed off the per-edit pass, not the substitute floor
|
|
4711
|
+
// above, so a pre-existing blocker on an unchanged line never
|
|
4712
|
+
// STOPs the write in either role.
|
|
4713
|
+
modifiedRanges: ctx.blockingOnly ? ctx.modifiedRanges : void 0,
|
|
4714
|
+
outOfEditScope,
|
|
3855
4715
|
log: (message) => ctx.log(message),
|
|
3856
4716
|
content,
|
|
3857
4717
|
sgModule
|
|
@@ -3881,10 +4741,16 @@ var astGrepNapiRunner = {
|
|
|
3881
4741
|
} else if (diagnostics.length > 0) {
|
|
3882
4742
|
semantic = "warning";
|
|
3883
4743
|
}
|
|
3884
|
-
return
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
4744
|
+
return {
|
|
4745
|
+
...findingsResult(diagnostics, {
|
|
4746
|
+
status: hasBlocking ? "failed" : "succeeded",
|
|
4747
|
+
semantic
|
|
4748
|
+
}),
|
|
4749
|
+
...outOfEditScope.length > 0 && { outOfEditScope },
|
|
4750
|
+
...coveredByServer && {
|
|
4751
|
+
coveredBy: { runnerId: "lsp", serverId: "ast-grep" }
|
|
4752
|
+
}
|
|
4753
|
+
};
|
|
3888
4754
|
}
|
|
3889
4755
|
};
|
|
3890
4756
|
var ast_grep_napi_default = astGrepNapiRunner;
|
|
@@ -4425,7 +5291,7 @@ var biomeCheckJsonRunner = {
|
|
|
4425
5291
|
var biome_check_default = biomeCheckJsonRunner;
|
|
4426
5292
|
|
|
4427
5293
|
// dist/clients/dispatch/runners/cpp-check.js
|
|
4428
|
-
import * as
|
|
5294
|
+
import * as fs6 from "node:fs";
|
|
4429
5295
|
import * as path9 from "node:path";
|
|
4430
5296
|
var compilerCheckers = {
|
|
4431
5297
|
clang: createAvailabilityChecker("clang", ".exe"),
|
|
@@ -4464,7 +5330,7 @@ var CPP_HEADER_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
4464
5330
|
]);
|
|
4465
5331
|
function headerLooksLikeCpp(absPath) {
|
|
4466
5332
|
try {
|
|
4467
|
-
const content =
|
|
5333
|
+
const content = fs6.readFileSync(absPath, "utf-8");
|
|
4468
5334
|
return /\b(namespace|template|class|constexpr|concept|using)\b|std::|\b(public|private|protected)\s*:/.test(content);
|
|
4469
5335
|
} catch {
|
|
4470
5336
|
return false;
|
|
@@ -4615,7 +5481,7 @@ var cpp_check_default = cppCheckRunner;
|
|
|
4615
5481
|
|
|
4616
5482
|
// dist/clients/dispatch/runners/credo.js
|
|
4617
5483
|
import * as path10 from "node:path";
|
|
4618
|
-
import * as
|
|
5484
|
+
import * as fs7 from "node:fs";
|
|
4619
5485
|
var CREDO_PROBE_BUDGET_MS = 1e4;
|
|
4620
5486
|
var probeCredo = createCwdCachedProbe((cwd) => safeSpawnAsync("mix", ["credo", "--version"], {
|
|
4621
5487
|
timeout: CREDO_PROBE_BUDGET_MS,
|
|
@@ -4641,7 +5507,7 @@ function parseCredoJson(raw, fallbackPath, cwd) {
|
|
|
4641
5507
|
}
|
|
4642
5508
|
}
|
|
4643
5509
|
function hasMixExs(cwd) {
|
|
4644
|
-
return
|
|
5510
|
+
return fs7.existsSync(path10.join(cwd, "mix.exs"));
|
|
4645
5511
|
}
|
|
4646
5512
|
var credoRunner = {
|
|
4647
5513
|
id: "credo",
|
|
@@ -4678,7 +5544,7 @@ var credoRunner = {
|
|
|
4678
5544
|
var credo_default = credoRunner;
|
|
4679
5545
|
|
|
4680
5546
|
// dist/clients/dispatch/runners/cue-vet.js
|
|
4681
|
-
import * as
|
|
5547
|
+
import * as fs8 from "node:fs";
|
|
4682
5548
|
import * as path11 from "node:path";
|
|
4683
5549
|
var cue = createAvailabilityChecker("cue", ".exe", ["version"]);
|
|
4684
5550
|
function parseCueVetOutput(raw) {
|
|
@@ -4783,7 +5649,7 @@ var cueVetRunner = {
|
|
|
4783
5649
|
const singleFileArgs = ["vet", "-c=false", `./${fileName}`];
|
|
4784
5650
|
let touchedContent = null;
|
|
4785
5651
|
try {
|
|
4786
|
-
touchedContent =
|
|
5652
|
+
touchedContent = fs8.readFileSync(absPath, "utf8");
|
|
4787
5653
|
} catch {
|
|
4788
5654
|
touchedContent = null;
|
|
4789
5655
|
}
|
|
@@ -4988,8 +5854,11 @@ var dartAnalyzeRunner = {
|
|
|
4988
5854
|
const parsed = parseToolRun("dart-analyze", {
|
|
4989
5855
|
result,
|
|
4990
5856
|
output: raw,
|
|
4991
|
-
// EXIT TABLE (Dart 3.
|
|
4992
|
-
|
|
5857
|
+
// EXIT TABLE (Dart 3.13 measured fixture, tests/fixtures/runner-output/
|
|
5858
|
+
// dart-analyze): 0 clean; 1 infos; 2 warnings; 3 errors; other nonzero
|
|
5859
|
+
// rejected. The 3.5 table stopped at 2, so a file with a compile error
|
|
5860
|
+
// read as a rejected invocation and its findings were dropped.
|
|
5861
|
+
exitCodes: { ran: [1, 2, 3] }
|
|
4993
5862
|
}, (out) => parseDartMachineOutput(out, ctx.filePath, cwd));
|
|
4994
5863
|
if (parsed.skipped)
|
|
4995
5864
|
return parsed.skipped;
|
|
@@ -5004,7 +5873,7 @@ var dartAnalyzeRunner = {
|
|
|
5004
5873
|
var dart_analyze_default = dartAnalyzeRunner;
|
|
5005
5874
|
|
|
5006
5875
|
// dist/clients/dispatch/runners/detekt.js
|
|
5007
|
-
import * as
|
|
5876
|
+
import * as fs9 from "node:fs";
|
|
5008
5877
|
import * as path13 from "node:path";
|
|
5009
5878
|
var detekt = createAvailabilityChecker("detekt", ".bat");
|
|
5010
5879
|
var DETEKT_CONFIG_CANDIDATES = [
|
|
@@ -5078,14 +5947,14 @@ var DETEKT_FIXABLE_RULES = /* @__PURE__ */ new Set([
|
|
|
5078
5947
|
function findDetektConfig(cwd) {
|
|
5079
5948
|
for (const candidate of DETEKT_CONFIG_CANDIDATES) {
|
|
5080
5949
|
const full = path13.join(cwd, candidate);
|
|
5081
|
-
if (
|
|
5950
|
+
if (fs9.existsSync(full))
|
|
5082
5951
|
return full;
|
|
5083
5952
|
}
|
|
5084
5953
|
return void 0;
|
|
5085
5954
|
}
|
|
5086
5955
|
function parseDetektOutput(raw, filePath, cwd) {
|
|
5087
5956
|
const diagnostics = [];
|
|
5088
|
-
const pattern = /^(.+?):(\d+):(\d+): (error|warning): (.+?)(?:\s+\[([^\]]+)\])?$/gm;
|
|
5957
|
+
const pattern = /^(.+?):(\d+):(\d+): (?:(error|warning): )?(.+?)(?:\s+\[([^\]]+)\])?$/gm;
|
|
5089
5958
|
const absTarget = path13.resolve(cwd, filePath);
|
|
5090
5959
|
for (const match of raw.matchAll(pattern)) {
|
|
5091
5960
|
const [, file, lineStr, colStr, level, message, rule] = match;
|
|
@@ -5138,9 +6007,14 @@ var detektRunner = {
|
|
|
5138
6007
|
const run = parseToolRun("detekt", {
|
|
5139
6008
|
result,
|
|
5140
6009
|
output: raw,
|
|
5141
|
-
// EXIT TABLE (detekt 1.23
|
|
6010
|
+
// EXIT TABLE (detekt 1.23.8 captured fixtures): 0 clean; 2 findings on stdout with empty stderr.
|
|
6011
|
+
// Exit 1 is a tool error with NO findings (captured broken-config run: an invalid detekt.yml
|
|
6012
|
+
// prints InvalidConfigurationError on stderr), and also can follow printed findings (captured
|
|
6013
|
+
// findings-then-exit1 run: a non-numeric build.weights value fails after the report). Exit 1 is
|
|
6014
|
+
// therefore admitted, and skipWhenParsedNothing skips it only when the parser read no finding,
|
|
6015
|
+
// so a printed finding is kept. Any other nonzero exit is rejected.
|
|
5142
6016
|
exitCodes: { ran: [1, 2] }
|
|
5143
|
-
}, (out) => parseDetektOutput(out, ctx.filePath, cwd));
|
|
6017
|
+
}, (out) => parseDetektOutput(out, ctx.filePath, cwd), { skipWhenParsedNothing: true });
|
|
5144
6018
|
if (run.skipped)
|
|
5145
6019
|
return run.skipped;
|
|
5146
6020
|
const diagnostics = run.diagnostics;
|
|
@@ -5148,24 +6022,30 @@ var detektRunner = {
|
|
|
5148
6022
|
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
5149
6023
|
}
|
|
5150
6024
|
const hasErrors = diagnostics.some((d) => d.severity === "error");
|
|
5151
|
-
|
|
6025
|
+
const verdict = findingsResult(diagnostics, {
|
|
5152
6026
|
status: hasErrors ? "failed" : "succeeded",
|
|
5153
6027
|
semantic: hasErrors ? "blocking" : "warning"
|
|
5154
6028
|
});
|
|
6029
|
+
return result.status === 1 ? { ...verdict, inconclusive: true } : verdict;
|
|
5155
6030
|
}
|
|
5156
6031
|
};
|
|
5157
6032
|
var detekt_default = detektRunner;
|
|
5158
6033
|
|
|
5159
6034
|
// dist/clients/dispatch/runners/dotnet-build.js
|
|
5160
|
-
import * as
|
|
6035
|
+
import * as fs10 from "node:fs";
|
|
5161
6036
|
import * as path14 from "node:path";
|
|
5162
6037
|
var dotnet = createAvailabilityChecker("dotnet", ".exe");
|
|
5163
6038
|
function findProjectTarget(cwd) {
|
|
5164
|
-
const entries =
|
|
5165
|
-
const
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
6039
|
+
const entries = fs10.readdirSync(cwd, { withFileTypes: true });
|
|
6040
|
+
for (const patterns of [
|
|
6041
|
+
DOTNET_CSHARP_SOLUTION_MARKERS,
|
|
6042
|
+
DOTNET_CSHARP_PROJECT_MARKERS
|
|
6043
|
+
]) {
|
|
6044
|
+
const hit = entries.find((entry) => patterns.some((pattern) => direntsHaveMarkerGlobMatch([entry], pattern)));
|
|
6045
|
+
if (hit)
|
|
6046
|
+
return hit.name;
|
|
6047
|
+
}
|
|
6048
|
+
return void 0;
|
|
5169
6049
|
}
|
|
5170
6050
|
function isDotnetRuleId(value) {
|
|
5171
6051
|
if (value.length < 2)
|
|
@@ -5311,12 +6191,12 @@ ${result.stderr ?? ""}`.trim();
|
|
|
5311
6191
|
var dotnet_build_default = dotnetBuildRunner;
|
|
5312
6192
|
|
|
5313
6193
|
// dist/clients/dispatch/runners/elixir-check.js
|
|
5314
|
-
import * as
|
|
6194
|
+
import * as fs11 from "node:fs";
|
|
5315
6195
|
import * as path15 from "node:path";
|
|
5316
6196
|
var mix = createAvailabilityChecker("mix", ".bat");
|
|
5317
6197
|
var elixirc = createAvailabilityChecker("elixirc", ".bat");
|
|
5318
6198
|
function hasMixExs2(cwd) {
|
|
5319
|
-
return
|
|
6199
|
+
return fs11.existsSync(path15.join(cwd, "mix.exs"));
|
|
5320
6200
|
}
|
|
5321
6201
|
var ELIXIR_SNIPPET_LOCATION = /└─\s+(.+?):(\d+)(?::(\d+))?(?::|$)/;
|
|
5322
6202
|
function parseElixirOutput(raw, filePath, cwd = process.cwd()) {
|
|
@@ -5416,7 +6296,7 @@ var elixirCheckRunner = {
|
|
|
5416
6296
|
args = ["compile", "--warnings-as-errors"];
|
|
5417
6297
|
} else if (await elixirc.isAvailableAsync(cwd)) {
|
|
5418
6298
|
const outDir = path15.join(getProjectDataDir(cwd), "elixir-check");
|
|
5419
|
-
|
|
6299
|
+
fs11.mkdirSync(outDir, { recursive: true });
|
|
5420
6300
|
command = "elixirc";
|
|
5421
6301
|
args = ["-o", outDir, absPath];
|
|
5422
6302
|
}
|
|
@@ -5751,9 +6631,10 @@ var parseRuffOutput = createLineParser({
|
|
|
5751
6631
|
autoFixAvailable: ruffAutofix?.safePipelineAutofix ?? false,
|
|
5752
6632
|
fixKind: ruffAutofix?.fixKind === "none" ? void 0 : ruffAutofix?.fixKind
|
|
5753
6633
|
});
|
|
6634
|
+
var GO_VET_LINE = /^(?:vet:\s+)?(.+?):(\d+):(\d+):\s*(.+)/;
|
|
5754
6635
|
var parseGoVetOutput = createLineParser({
|
|
5755
6636
|
tool: "go-vet",
|
|
5756
|
-
regex:
|
|
6637
|
+
regex: GO_VET_LINE,
|
|
5757
6638
|
extractMessage: (m) => m[4],
|
|
5758
6639
|
generateId: (m) => `go-vet-${m[2]}`,
|
|
5759
6640
|
defectClass: "correctness"
|
|
@@ -5795,7 +6676,7 @@ var goVetRunner = {
|
|
|
5795
6676
|
}
|
|
5796
6677
|
const absTarget = resolve14(ctx.filePath);
|
|
5797
6678
|
const relevant = raw.split("\n").filter((line) => {
|
|
5798
|
-
const m = line.match(
|
|
6679
|
+
const m = line.match(GO_VET_LINE);
|
|
5799
6680
|
return m != null && pathsEqual(resolve14(cwd, m[1].trim()), absTarget);
|
|
5800
6681
|
}).join("\n");
|
|
5801
6682
|
const diagnostics = parseGoVetOutput(relevant, ctx.filePath, cwd);
|
|
@@ -5807,6 +6688,16 @@ var go_vet_default = goVetRunner;
|
|
|
5807
6688
|
// dist/clients/dispatch/runners/golangci-lint.js
|
|
5808
6689
|
import * as path19 from "node:path";
|
|
5809
6690
|
var golangci = createAvailabilityChecker("golangci-lint", ".exe");
|
|
6691
|
+
var OTHER_OUTPUT_FORMATS = [
|
|
6692
|
+
"text",
|
|
6693
|
+
"tab",
|
|
6694
|
+
"html",
|
|
6695
|
+
"checkstyle",
|
|
6696
|
+
"code-climate",
|
|
6697
|
+
"junit-xml",
|
|
6698
|
+
"teamcity",
|
|
6699
|
+
"sarif"
|
|
6700
|
+
];
|
|
5810
6701
|
function describeReplacement(replacement) {
|
|
5811
6702
|
if (!replacement)
|
|
5812
6703
|
return void 0;
|
|
@@ -5867,12 +6758,18 @@ var golangciRunner = {
|
|
|
5867
6758
|
const cmd = await resolveAvailableOrInstall(golangci, "golangci-lint", cwd);
|
|
5868
6759
|
if (!cmd)
|
|
5869
6760
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
5870
|
-
const result = await safeSpawnAsync(cmd, [
|
|
6761
|
+
const result = await safeSpawnAsync(cmd, [
|
|
6762
|
+
"run",
|
|
6763
|
+
"--output.json.path=stdout",
|
|
6764
|
+
...OTHER_OUTPUT_FORMATS.map((format) => `--output.${format}.path=`),
|
|
6765
|
+
"--show-stats=false",
|
|
6766
|
+
ctx.filePath
|
|
6767
|
+
], { timeout: 6e4, cwd });
|
|
5871
6768
|
const raw = (result.stdout ?? "").length > 0 ? result.stdout ?? "" : result.status !== 0 ? result.stderr || "" : "";
|
|
5872
6769
|
const parsed = parseToolRun("golangci-lint", {
|
|
5873
6770
|
result,
|
|
5874
6771
|
output: raw,
|
|
5875
|
-
// EXIT TABLE (golangci-lint
|
|
6772
|
+
// EXIT TABLE (golangci-lint v2 docs https://golangci-lint.run/docs/welcome/quick-start/; 2.14.0 exits 1 on findings and 3 on an unknown flag): 0 clean; 1 findings; 2 error; 3 error; 4 error; 5 error; other nonzero rejected.
|
|
5876
6773
|
exitCodes: { ran: [1, 2, 3, 4, 5] }
|
|
5877
6774
|
}, (raw2) => parseGolangciJson(raw2, ctx.filePath, cwd));
|
|
5878
6775
|
if (parsed.skipped)
|
|
@@ -5967,7 +6864,7 @@ var hadolint_default = hadolintRunner;
|
|
|
5967
6864
|
|
|
5968
6865
|
// dist/clients/dispatch/runners/helm-lint.js
|
|
5969
6866
|
import * as path21 from "node:path";
|
|
5970
|
-
var helm = createAvailabilityChecker("helm", ".exe");
|
|
6867
|
+
var helm = createAvailabilityChecker("helm", ".exe", ["version", "--short"]);
|
|
5971
6868
|
var inFlightByChartRoot = new PathKeyedMap(normalizeMapKey);
|
|
5972
6869
|
var HELM_LINT_TIMEOUT_MS = 3e4;
|
|
5973
6870
|
var MAX_HELM_LINT_OUTPUT_BYTES = 8 * 1024 * 1024;
|
|
@@ -5981,14 +6878,17 @@ function isWithin(root, candidate) {
|
|
|
5981
6878
|
return relative5 === "" || !relative5.startsWith(`..${path21.sep}`) && relative5 !== ".." && !path21.isAbsolute(relative5);
|
|
5982
6879
|
}
|
|
5983
6880
|
function diagnosticLocation(message, chartRoot) {
|
|
5984
|
-
const location = message.match(/(
|
|
5985
|
-
|
|
6881
|
+
const location = message.match(/(?:^|[\s(])((?:[^\s:()\r\n]*\/[^:()\r\n"]*?|[^\s:()\r\n]+)\.(?:ya?ml|tpl|json))(?::(\d+))?(?=[:\s)]|$)/i);
|
|
6882
|
+
const [, found, rawLine] = location ?? [];
|
|
6883
|
+
if (!found) {
|
|
5986
6884
|
return { filePath: path21.join(chartRoot, "Chart.yaml"), message };
|
|
5987
6885
|
}
|
|
5988
|
-
const
|
|
6886
|
+
const embedded = !message.startsWith(found);
|
|
6887
|
+
const relative5 = embedded ? found.slice(found.indexOf("/") + 1) : found;
|
|
6888
|
+
const candidate = path21.resolve(chartRoot, relative5);
|
|
5989
6889
|
return {
|
|
5990
6890
|
filePath: isWithin(chartRoot, candidate) ? candidate : path21.join(chartRoot, "Chart.yaml"),
|
|
5991
|
-
line:
|
|
6891
|
+
line: rawLine ? Number(rawLine) : void 0,
|
|
5992
6892
|
message
|
|
5993
6893
|
};
|
|
5994
6894
|
}
|
|
@@ -6103,10 +7003,10 @@ var helmLintRunner = {
|
|
|
6103
7003
|
var helm_lint_default = helmLintRunner;
|
|
6104
7004
|
|
|
6105
7005
|
// dist/clients/dispatch/runners/helm-render.js
|
|
6106
|
-
import * as
|
|
7006
|
+
import * as fs12 from "node:fs";
|
|
6107
7007
|
import * as os from "node:os";
|
|
6108
7008
|
import * as path22 from "node:path";
|
|
6109
|
-
var helm2 = createAvailabilityChecker("helm", ".exe");
|
|
7009
|
+
var helm2 = createAvailabilityChecker("helm", ".exe", ["version", "--short"]);
|
|
6110
7010
|
var trivy = createAvailabilityChecker("trivy", ".exe");
|
|
6111
7011
|
var inFlightByChartRoot2 = new PathKeyedMap(normalizeMapKey);
|
|
6112
7012
|
var RENDER_TIMEOUT_MS = 3e4;
|
|
@@ -6140,10 +7040,10 @@ function resolveTemplateSource(sourceRef, chartRoot, realChartRoot) {
|
|
|
6140
7040
|
if (!isWithin2(chartRoot, candidate))
|
|
6141
7041
|
return null;
|
|
6142
7042
|
try {
|
|
6143
|
-
if (!
|
|
7043
|
+
if (!fs12.lstatSync(candidate).isFile())
|
|
6144
7044
|
return null;
|
|
6145
|
-
const root = realChartRoot ??
|
|
6146
|
-
if (!isWithin2(root,
|
|
7045
|
+
const root = realChartRoot ?? fs12.realpathSync(chartRoot);
|
|
7046
|
+
if (!isWithin2(root, fs12.realpathSync(candidate)))
|
|
6147
7047
|
return null;
|
|
6148
7048
|
} catch {
|
|
6149
7049
|
return null;
|
|
@@ -6152,7 +7052,7 @@ function resolveTemplateSource(sourceRef, chartRoot, realChartRoot) {
|
|
|
6152
7052
|
}
|
|
6153
7053
|
function canonicalChartRoot(chartRoot) {
|
|
6154
7054
|
try {
|
|
6155
|
-
return
|
|
7055
|
+
return fs12.realpathSync(chartRoot);
|
|
6156
7056
|
} catch {
|
|
6157
7057
|
return chartRoot;
|
|
6158
7058
|
}
|
|
@@ -6387,7 +7287,7 @@ function collectRenderedFiles(root) {
|
|
|
6387
7287
|
const dir = stack.pop();
|
|
6388
7288
|
let entries;
|
|
6389
7289
|
try {
|
|
6390
|
-
entries =
|
|
7290
|
+
entries = fs12.readdirSync(dir, { withFileTypes: true });
|
|
6391
7291
|
} catch {
|
|
6392
7292
|
continue;
|
|
6393
7293
|
}
|
|
@@ -6426,7 +7326,7 @@ function readRenderedTree(outputDir, chartRoot) {
|
|
|
6426
7326
|
for (const renderedPath of walk2.files) {
|
|
6427
7327
|
let content;
|
|
6428
7328
|
try {
|
|
6429
|
-
content =
|
|
7329
|
+
content = fs12.readFileSync(renderedPath, "utf-8");
|
|
6430
7330
|
} catch {
|
|
6431
7331
|
unreadable += 1;
|
|
6432
7332
|
continue;
|
|
@@ -6545,7 +7445,7 @@ function logRenderPass(filePath, chartRoot, startedAt, metadata) {
|
|
|
6545
7445
|
metadata: { chartRoot, ...metadata }
|
|
6546
7446
|
});
|
|
6547
7447
|
}
|
|
6548
|
-
function discardScratchDir(outputDir, filePath, remove = (target) =>
|
|
7448
|
+
function discardScratchDir(outputDir, filePath, remove = (target) => fs12.rmSync(target, { recursive: true, force: true })) {
|
|
6549
7449
|
try {
|
|
6550
7450
|
remove(outputDir);
|
|
6551
7451
|
} catch (error) {
|
|
@@ -6566,7 +7466,7 @@ async function renderAndValidate(chartRoot, cwd, filePath) {
|
|
|
6566
7466
|
const helmCmd = await resolveAvailableOrInstall(helm2, "helm", cwd);
|
|
6567
7467
|
if (!helmCmd)
|
|
6568
7468
|
return helmUnavailableResult(cwd);
|
|
6569
|
-
const outputDir =
|
|
7469
|
+
const outputDir = fs12.mkdtempSync(path22.join(os.tmpdir(), "pi-lens-helm-render-"));
|
|
6570
7470
|
try {
|
|
6571
7471
|
const render = await safeSpawnAsync(helmCmd, ["template", "pi-lens-render", chartRoot, "--output-dir", outputDir], {
|
|
6572
7472
|
cwd,
|
|
@@ -6887,9 +7787,30 @@ function normalizeKtlintResults(parsed) {
|
|
|
6887
7787
|
}
|
|
6888
7788
|
return null;
|
|
6889
7789
|
}
|
|
7790
|
+
function parseResults(text) {
|
|
7791
|
+
try {
|
|
7792
|
+
return normalizeKtlintResults(JSON.parse(text));
|
|
7793
|
+
} catch {
|
|
7794
|
+
return null;
|
|
7795
|
+
}
|
|
7796
|
+
}
|
|
7797
|
+
function parseReporterDocument(raw) {
|
|
7798
|
+
const lines = raw.split(/\r?\n/);
|
|
7799
|
+
const start = lines.findIndex((line) => /^\s*[[{]/.test(line));
|
|
7800
|
+
if (start < 0)
|
|
7801
|
+
return parseResults(raw);
|
|
7802
|
+
for (let end = lines.length - 1; end >= start; end--) {
|
|
7803
|
+
if (!/[\]}]\s*$/.test(lines[end] ?? ""))
|
|
7804
|
+
continue;
|
|
7805
|
+
const results = parseResults(lines.slice(start, end + 1).join("\n"));
|
|
7806
|
+
if (results)
|
|
7807
|
+
return results;
|
|
7808
|
+
}
|
|
7809
|
+
return null;
|
|
7810
|
+
}
|
|
6890
7811
|
function parseKtlintOutput(raw, filePath, cwd) {
|
|
6891
7812
|
try {
|
|
6892
|
-
const parsed =
|
|
7813
|
+
const parsed = parseReporterDocument(raw);
|
|
6893
7814
|
if (!parsed)
|
|
6894
7815
|
return null;
|
|
6895
7816
|
const autofix = getAutofixCapability("ktlint");
|
|
@@ -6900,15 +7821,15 @@ function parseKtlintOutput(raw, filePath, cwd) {
|
|
|
6900
7821
|
continue;
|
|
6901
7822
|
for (const err of result.errors ?? []) {
|
|
6902
7823
|
diagnostics.push({
|
|
6903
|
-
id: `ktlint-${err.
|
|
6904
|
-
message: `[${err.
|
|
7824
|
+
id: `ktlint-${err.rule}-${err.line}-${err.column}`,
|
|
7825
|
+
message: `[${err.rule}] ${err.message}`,
|
|
6905
7826
|
filePath,
|
|
6906
7827
|
line: err.line,
|
|
6907
|
-
column: err.
|
|
7828
|
+
column: err.column,
|
|
6908
7829
|
severity: "warning",
|
|
6909
7830
|
semantic: "warning",
|
|
6910
7831
|
tool: "ktlint",
|
|
6911
|
-
rule: err.
|
|
7832
|
+
rule: err.rule,
|
|
6912
7833
|
fixable: true,
|
|
6913
7834
|
autoFixAvailable: autofix?.safePipelineAutofix ?? false,
|
|
6914
7835
|
fixKind: autofix?.fixKind === "none" ? void 0 : autofix?.fixKind
|
|
@@ -6962,136 +7883,6 @@ ${result.stderr ?? ""}`,
|
|
|
6962
7883
|
};
|
|
6963
7884
|
var ktlint_default = ktlintRunner;
|
|
6964
7885
|
|
|
6965
|
-
// dist/clients/lsp/inferred-project.js
|
|
6966
|
-
import * as path26 from "node:path";
|
|
6967
|
-
var INFERRED_PROJECT_MARKER = "not in any tsconfig project \u2014 checked with inferred settings";
|
|
6968
|
-
var TS_PROJECT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
6969
|
-
".ts",
|
|
6970
|
-
".tsx",
|
|
6971
|
-
".mts",
|
|
6972
|
-
".cts",
|
|
6973
|
-
".js",
|
|
6974
|
-
".jsx",
|
|
6975
|
-
".mjs",
|
|
6976
|
-
".cjs"
|
|
6977
|
-
]);
|
|
6978
|
-
var TYPESCRIPT_DIAGNOSTIC_SOURCES = /* @__PURE__ */ new Set(["typescript", "ts", "tsserver"]);
|
|
6979
|
-
function isTsProjectFile(filePath) {
|
|
6980
|
-
return TS_PROJECT_EXTENSIONS.has(path26.extname(filePath).toLowerCase());
|
|
6981
|
-
}
|
|
6982
|
-
function isTypeScriptSourcedDiagnostic(d) {
|
|
6983
|
-
return TYPESCRIPT_DIAGNOSTIC_SOURCES.has((d.source ?? "").toLowerCase());
|
|
6984
|
-
}
|
|
6985
|
-
function suggestTsconfigInclude(filePath, cwd) {
|
|
6986
|
-
const relative5 = toProjectRelativePath(filePath, cwd);
|
|
6987
|
-
if (path26.posix.isAbsolute(relative5) || /^[A-Za-z]:/.test(relative5)) {
|
|
6988
|
-
const dir = relative5.slice(0, relative5.lastIndexOf("/"));
|
|
6989
|
-
return dir ? `${dir}/**` : relative5;
|
|
6990
|
-
}
|
|
6991
|
-
const segments = relative5.split("/").filter(Boolean);
|
|
6992
|
-
return segments.length > 1 ? `${segments[0]}/**` : relative5;
|
|
6993
|
-
}
|
|
6994
|
-
function inferredProjectNotice(filePath, cwd) {
|
|
6995
|
-
return `[${INFERRED_PROJECT_MARKER}; add ${suggestTsconfigInclude(filePath, cwd)} to a tsconfig for authoritative checking]`;
|
|
6996
|
-
}
|
|
6997
|
-
function applyInferredProjectDemotion(diagnostics, filePath, cwd) {
|
|
6998
|
-
if (!diagnostics.some(isDemotableDiagnostic))
|
|
6999
|
-
return diagnostics;
|
|
7000
|
-
const notice = inferredProjectNotice(filePath, cwd);
|
|
7001
|
-
return diagnostics.map((d) => isDemotableDiagnostic(d) ? { ...d, severity: 2, message: `${d.message} ${notice}` } : d);
|
|
7002
|
-
}
|
|
7003
|
-
function isDemotableDiagnostic(d) {
|
|
7004
|
-
return d.severity === 1 && isTypeScriptSourcedDiagnostic(d);
|
|
7005
|
-
}
|
|
7006
|
-
async function demoteInferredProjectDiagnostics(diagnostics, options) {
|
|
7007
|
-
const { filePath, cwd, service } = options;
|
|
7008
|
-
if (!isTsProjectFile(filePath))
|
|
7009
|
-
return diagnostics;
|
|
7010
|
-
if (!diagnostics.some(isDemotableDiagnostic))
|
|
7011
|
-
return diagnostics;
|
|
7012
|
-
if (options.signal?.aborted)
|
|
7013
|
-
return diagnostics;
|
|
7014
|
-
const fetchIdentity = options.fetchIdentity ?? fetchTsserverProjectIdentity;
|
|
7015
|
-
const cache = options.identityCache;
|
|
7016
|
-
let identity;
|
|
7017
|
-
if (cache?.has(filePath)) {
|
|
7018
|
-
identity = cache.get(filePath);
|
|
7019
|
-
} else {
|
|
7020
|
-
identity = await fetchIdentity(service, filePath);
|
|
7021
|
-
cache?.set(filePath, identity);
|
|
7022
|
-
}
|
|
7023
|
-
if (identity?.projectKind !== "inferred")
|
|
7024
|
-
return diagnostics;
|
|
7025
|
-
return applyInferredProjectDemotion(diagnostics, filePath, cwd);
|
|
7026
|
-
}
|
|
7027
|
-
var INFERRED_PROJECT_PROBE_BUDGET = 300;
|
|
7028
|
-
async function demoteInferredProjectSweepResults(results, cwd, service, signal) {
|
|
7029
|
-
if (typeof service?.executeReadOnlyCommandOnLiveClient !== "function") {
|
|
7030
|
-
return results;
|
|
7031
|
-
}
|
|
7032
|
-
const startedAt = Date.now();
|
|
7033
|
-
const identityCache = /* @__PURE__ */ new Map();
|
|
7034
|
-
const out = [];
|
|
7035
|
-
let demotedFiles = 0;
|
|
7036
|
-
let demotedDiagnostics = 0;
|
|
7037
|
-
let budgetExhausted = false;
|
|
7038
|
-
let aborted = false;
|
|
7039
|
-
for (const result of results) {
|
|
7040
|
-
const diagnostics = result.diagnostics ?? [];
|
|
7041
|
-
if (signal?.aborted) {
|
|
7042
|
-
aborted = true;
|
|
7043
|
-
out.push(result);
|
|
7044
|
-
continue;
|
|
7045
|
-
}
|
|
7046
|
-
if (identityCache.size >= INFERRED_PROJECT_PROBE_BUDGET && !identityCache.has(result.filePath)) {
|
|
7047
|
-
budgetExhausted = true;
|
|
7048
|
-
out.push(result);
|
|
7049
|
-
continue;
|
|
7050
|
-
}
|
|
7051
|
-
const demoted = await demoteInferredProjectDiagnostics(diagnostics, {
|
|
7052
|
-
filePath: result.filePath,
|
|
7053
|
-
cwd,
|
|
7054
|
-
service,
|
|
7055
|
-
identityCache,
|
|
7056
|
-
signal
|
|
7057
|
-
});
|
|
7058
|
-
if (demoted === diagnostics) {
|
|
7059
|
-
out.push(result);
|
|
7060
|
-
continue;
|
|
7061
|
-
}
|
|
7062
|
-
demotedFiles += 1;
|
|
7063
|
-
demotedDiagnostics += demoted.filter((d, i) => d !== diagnostics[i]).length;
|
|
7064
|
-
out.push({ ...result, diagnostics: demoted });
|
|
7065
|
-
}
|
|
7066
|
-
if (demotedFiles > 0 || budgetExhausted || aborted) {
|
|
7067
|
-
logLatency({
|
|
7068
|
-
type: "phase",
|
|
7069
|
-
phase: "lsp_inferred_project_demote",
|
|
7070
|
-
filePath: cwd,
|
|
7071
|
-
durationMs: Date.now() - startedAt,
|
|
7072
|
-
metadata: {
|
|
7073
|
-
filesConsidered: results.length,
|
|
7074
|
-
filesProbed: identityCache.size,
|
|
7075
|
-
demotedFiles,
|
|
7076
|
-
demotedDiagnostics,
|
|
7077
|
-
budgetExhausted,
|
|
7078
|
-
aborted
|
|
7079
|
-
}
|
|
7080
|
-
});
|
|
7081
|
-
}
|
|
7082
|
-
return out;
|
|
7083
|
-
}
|
|
7084
|
-
|
|
7085
|
-
// dist/clients/dispatch/runners/utils.js
|
|
7086
|
-
import * as fs12 from "node:fs";
|
|
7087
|
-
function readFileContent(filePath) {
|
|
7088
|
-
try {
|
|
7089
|
-
return fs12.readFileSync(filePath, "utf-8");
|
|
7090
|
-
} catch {
|
|
7091
|
-
return void 0;
|
|
7092
|
-
}
|
|
7093
|
-
}
|
|
7094
|
-
|
|
7095
7886
|
// dist/clients/dispatch/runners/lsp.js
|
|
7096
7887
|
var LSP_SPAWN_BUDGET_MS = RUNTIME_CONFIG.pipeline.lspSpawnBudgetMs;
|
|
7097
7888
|
var LSP_DIAGNOSTICS_WAIT_MS = 2500;
|
|
@@ -7128,16 +7919,27 @@ var lspRunner = {
|
|
|
7128
7919
|
}
|
|
7129
7920
|
const lspService = getLSPService();
|
|
7130
7921
|
if (!lspService.supportsLSP(ctx.filePath)) {
|
|
7131
|
-
|
|
7922
|
+
const { disabledServerIds: disabledPrimaryServerIds } = disabledPrimaries(ctx.filePath);
|
|
7923
|
+
return {
|
|
7924
|
+
status: "skipped",
|
|
7925
|
+
diagnostics: [],
|
|
7926
|
+
semantic: "none",
|
|
7927
|
+
...disabledPrimaryServerIds.length > 0 && {
|
|
7928
|
+
primaryUnavailableCause: "disabled",
|
|
7929
|
+
disabledPrimaryServerIds
|
|
7930
|
+
}
|
|
7931
|
+
};
|
|
7132
7932
|
}
|
|
7133
7933
|
let lspDiags = [];
|
|
7134
7934
|
let serverFailed = false;
|
|
7135
7935
|
let lspClientReady = true;
|
|
7136
7936
|
let diagnosticsInconclusive = false;
|
|
7137
7937
|
let inconclusiveServerIds = [];
|
|
7938
|
+
let primaryUnavailable;
|
|
7138
7939
|
let unconfirmedServerIds = [];
|
|
7139
7940
|
let deferredServerIds = [];
|
|
7140
7941
|
let usedWarmAttach = false;
|
|
7942
|
+
let incumbentProjectIdentity;
|
|
7141
7943
|
let failureReason = "";
|
|
7142
7944
|
const readStamp = performance.now();
|
|
7143
7945
|
const content = readFileContent(ctx.filePath);
|
|
@@ -7151,6 +7953,9 @@ var lspRunner = {
|
|
|
7151
7953
|
try {
|
|
7152
7954
|
const attached = await tryWarmAttachedDiagnostics(ctx.filePath, content, Math.max(LSP_SPAWN_BUDGET_MS, LSP_DIAGNOSTICS_WAIT_MS));
|
|
7153
7955
|
usedWarmAttach = attached?.available === true;
|
|
7956
|
+
if (attached?.available) {
|
|
7957
|
+
incumbentProjectIdentity = attached.response.projectIdentity;
|
|
7958
|
+
}
|
|
7154
7959
|
const touched = attached?.available ? {
|
|
7155
7960
|
diags: attached.response.diagnostics,
|
|
7156
7961
|
...attached.response.unconfirmedServerIds !== void 0 && {
|
|
@@ -7172,6 +7977,15 @@ var lspRunner = {
|
|
|
7172
7977
|
lspDiags = touched.diags;
|
|
7173
7978
|
diagnosticsInconclusive = touched.inconclusive === true;
|
|
7174
7979
|
inconclusiveServerIds = touched.inconclusiveServerIds ?? [];
|
|
7980
|
+
if (touched.inconclusiveReason === "primary-unavailable") {
|
|
7981
|
+
const disabledPrimaryServerIds = touched.disabledPrimaryServerIds ?? [];
|
|
7982
|
+
primaryUnavailable = {
|
|
7983
|
+
primaryUnavailableCause: touched.primaryUnavailableCause ?? primaryUnavailableCause(inconclusiveServerIds, disabledPrimaryServerIds),
|
|
7984
|
+
...disabledPrimaryServerIds.length > 0 && {
|
|
7985
|
+
disabledPrimaryServerIds
|
|
7986
|
+
}
|
|
7987
|
+
};
|
|
7988
|
+
}
|
|
7175
7989
|
unconfirmedServerIds = [
|
|
7176
7990
|
.../* @__PURE__ */ new Set([
|
|
7177
7991
|
...touchCoverageGap(touched),
|
|
@@ -7201,6 +8015,16 @@ var lspRunner = {
|
|
|
7201
8015
|
});
|
|
7202
8016
|
}
|
|
7203
8017
|
}
|
|
8018
|
+
let withheldNotice;
|
|
8019
|
+
if (lspDiags.length > 0) {
|
|
8020
|
+
const declared = await detectPythonTargetVersion(diagnosticPath);
|
|
8021
|
+
const { kept, dropped } = partitionOutrankedPythonCompileVerdicts(lspDiags, declared);
|
|
8022
|
+
if (dropped > 0 && declared) {
|
|
8023
|
+
recordPythonCompileVerdictDrop(diagnosticPath, declared, dropped);
|
|
8024
|
+
lspDiags = kept;
|
|
8025
|
+
withheldNotice = describePythonCompileWithheld(dropped, declared);
|
|
8026
|
+
}
|
|
8027
|
+
}
|
|
7204
8028
|
if (serverFailed) {
|
|
7205
8029
|
return {
|
|
7206
8030
|
status: "failed",
|
|
@@ -7223,10 +8047,20 @@ var lspRunner = {
|
|
|
7223
8047
|
};
|
|
7224
8048
|
}
|
|
7225
8049
|
if (!lspClientReady) {
|
|
7226
|
-
return {
|
|
8050
|
+
return {
|
|
8051
|
+
status: "skipped",
|
|
8052
|
+
diagnostics: [],
|
|
8053
|
+
semantic: "none",
|
|
8054
|
+
primaryUnavailableCause: "unstarted"
|
|
8055
|
+
};
|
|
7227
8056
|
}
|
|
7228
8057
|
if (diagnosticsInconclusive && lspDiags.length === 0) {
|
|
7229
|
-
return {
|
|
8058
|
+
return {
|
|
8059
|
+
status: "skipped",
|
|
8060
|
+
diagnostics: [],
|
|
8061
|
+
semantic: "none",
|
|
8062
|
+
...primaryUnavailable
|
|
8063
|
+
};
|
|
7230
8064
|
}
|
|
7231
8065
|
if (lspDiags.length === 0) {
|
|
7232
8066
|
if (deferredServerIds.length > 0) {
|
|
@@ -7250,15 +8084,19 @@ var lspRunner = {
|
|
|
7250
8084
|
status: "succeeded",
|
|
7251
8085
|
diagnostics: [],
|
|
7252
8086
|
semantic: "none",
|
|
7253
|
-
rawOutput: "no-diagnostics"
|
|
8087
|
+
rawOutput: "no-diagnostics",
|
|
8088
|
+
...withheldNotice !== void 0 && { withheldNotice }
|
|
7254
8089
|
};
|
|
7255
8090
|
}
|
|
7256
8091
|
const rawValidLspDiags = lspDiags.filter((d) => d.range?.start?.line !== void 0);
|
|
7257
|
-
const validLspDiags =
|
|
8092
|
+
const validLspDiags = (await demoteLanguageServerRows(rawValidLspDiags, {
|
|
7258
8093
|
filePath: diagnosticPath,
|
|
7259
8094
|
cwd: ctx.cwd,
|
|
7260
|
-
service: lspService
|
|
7261
|
-
|
|
8095
|
+
...!usedWarmAttach && { service: lspService },
|
|
8096
|
+
...incumbentProjectIdentity !== void 0 && {
|
|
8097
|
+
identityCache: /* @__PURE__ */ new Map([[diagnosticPath, incumbentProjectIdentity]])
|
|
8098
|
+
}
|
|
8099
|
+
})).rows;
|
|
7262
8100
|
const fixSuggestionByIndex = /* @__PURE__ */ new Map();
|
|
7263
8101
|
const blockingDiagIndexes = rawValidLspDiags.map((d, idx) => ({ d, idx })).filter(({ d }) => d.severity === 1).slice(0, WARM_CODE_ACTION_LOOKUP_LIMIT);
|
|
7264
8102
|
if (usedWarmAttach) {
|
|
@@ -7291,7 +8129,15 @@ var lspRunner = {
|
|
|
7291
8129
|
}));
|
|
7292
8130
|
}
|
|
7293
8131
|
const diagnostics = convertLspDiagnostics(validLspDiags, diagnosticPath, { fixSuggestionByIndex });
|
|
7294
|
-
const
|
|
8132
|
+
const rawRangeByDiagnostic = new Map(diagnostics.map((d, i) => [d, validLspDiags[i]?.range]));
|
|
8133
|
+
const retaggedDiagnostics = retagAuxiliaryDiagnostics(diagnostics, validLspDiags, content, { cwd: ctx.cwd, fileRole: ctx.fileRole });
|
|
8134
|
+
const keptDiagnostics = [];
|
|
8135
|
+
const outOfEditScope = [];
|
|
8136
|
+
for (const d of retaggedDiagnostics) {
|
|
8137
|
+
const range = ctx.blockingOnly && d.tool === "ast-grep" && d.semantic === "blocking" ? rawRangeByDiagnostic.get(d) : void 0;
|
|
8138
|
+
const inScope = range === void 0 || spanOverlapsModifiedRanges(range.start.line + 1, (range.end?.line ?? range.start.line) + 1, ctx.modifiedRanges);
|
|
8139
|
+
(inScope ? keptDiagnostics : outOfEditScope).push(d);
|
|
8140
|
+
}
|
|
7295
8141
|
const hasErrors = keptDiagnostics.some((d) => d.semantic === "blocking");
|
|
7296
8142
|
const resultSemantic = hasErrors ? "blocking" : keptDiagnostics.length > 0 ? "warning" : "none";
|
|
7297
8143
|
return {
|
|
@@ -7306,14 +8152,16 @@ var lspRunner = {
|
|
|
7306
8152
|
},
|
|
7307
8153
|
...deferredServerIds.length > 0 && {
|
|
7308
8154
|
deferredServerIds: [...deferredServerIds]
|
|
7309
|
-
}
|
|
8155
|
+
},
|
|
8156
|
+
...outOfEditScope.length > 0 && { outOfEditScope },
|
|
8157
|
+
...withheldNotice !== void 0 && { withheldNotice }
|
|
7310
8158
|
};
|
|
7311
8159
|
}
|
|
7312
8160
|
};
|
|
7313
8161
|
var lsp_default = lspRunner;
|
|
7314
8162
|
|
|
7315
8163
|
// dist/clients/dispatch/runners/markdownlint.js
|
|
7316
|
-
import * as
|
|
8164
|
+
import * as path26 from "node:path";
|
|
7317
8165
|
var markdownlint = createAvailabilityChecker("markdownlint-cli2", ".cmd", [
|
|
7318
8166
|
"--no-globs",
|
|
7319
8167
|
"-"
|
|
@@ -7353,7 +8201,7 @@ var MARKDOWNLINT_FIXABLE_RULES = /* @__PURE__ */ new Set([
|
|
|
7353
8201
|
]);
|
|
7354
8202
|
function parseMarkdownlintOutput(raw, filePath, cwd) {
|
|
7355
8203
|
const diagnostics = [];
|
|
7356
|
-
const absTarget =
|
|
8204
|
+
const absTarget = path26.resolve(cwd, filePath);
|
|
7357
8205
|
for (const line of raw.split(/\r?\n/)) {
|
|
7358
8206
|
if (!line.trim())
|
|
7359
8207
|
continue;
|
|
@@ -7361,7 +8209,7 @@ function parseMarkdownlintOutput(raw, filePath, cwd) {
|
|
|
7361
8209
|
if (!match)
|
|
7362
8210
|
continue;
|
|
7363
8211
|
const [, reported, lineNum, col, ruleCode, message] = match;
|
|
7364
|
-
if (reported && !pathsEqual(
|
|
8212
|
+
if (reported && !pathsEqual(path26.resolve(cwd, reported), absTarget))
|
|
7365
8213
|
continue;
|
|
7366
8214
|
const ruleName = ruleCode.split("/")[0];
|
|
7367
8215
|
const fixable = MARKDOWNLINT_FIXABLE_RULES.has(ruleName);
|
|
@@ -7435,7 +8283,7 @@ var markdownlintRunner = {
|
|
|
7435
8283
|
var markdownlint_default = markdownlintRunner;
|
|
7436
8284
|
|
|
7437
8285
|
// dist/clients/dispatch/runners/mypy.js
|
|
7438
|
-
import * as
|
|
8286
|
+
import * as path27 from "node:path";
|
|
7439
8287
|
var mypy = createAvailabilityChecker("mypy", "");
|
|
7440
8288
|
var MYPY_EXIT_CODES = { ran: [1, 2] };
|
|
7441
8289
|
function parseMypyOutput(raw, fallbackPath, cwd) {
|
|
@@ -7449,7 +8297,7 @@ function parseMypyOutput(raw, fallbackPath, cwd) {
|
|
|
7449
8297
|
continue;
|
|
7450
8298
|
const severity = level === "error" ? "error" : "warning";
|
|
7451
8299
|
const rule = errorCode ?? "mypy";
|
|
7452
|
-
const filePath = file && file.trim() ?
|
|
8300
|
+
const filePath = file && file.trim() ? path27.isAbsolute(file) ? file : path27.resolve(cwd, file) : fallbackPath;
|
|
7453
8301
|
diagnostics.push({
|
|
7454
8302
|
id: `mypy-${lineNum}-${rule}`,
|
|
7455
8303
|
message: errorCode ? `[${errorCode}] ${message}` : message,
|
|
@@ -7500,7 +8348,7 @@ var mypyRunner = {
|
|
|
7500
8348
|
var mypy_default = mypyRunner;
|
|
7501
8349
|
|
|
7502
8350
|
// dist/clients/dispatch/runners/oxlint.js
|
|
7503
|
-
import * as
|
|
8351
|
+
import * as path28 from "node:path";
|
|
7504
8352
|
var MAX_OXLINT_OUTPUT_BYTES = 8 * 1024 * 1024;
|
|
7505
8353
|
var OXLINT_NO_FILES = /* @__PURE__ */ Symbol("oxlint-no-files");
|
|
7506
8354
|
var OXLINT_NO_FILES_UNCONFIRMED = /* @__PURE__ */ Symbol("oxlint-no-files-unconfirmed");
|
|
@@ -7744,9 +8592,9 @@ function parseOxlintJson(raw, filePath, cwd) {
|
|
|
7744
8592
|
if (!Array.isArray(parsed.diagnostics))
|
|
7745
8593
|
return [];
|
|
7746
8594
|
const diagnostics = [];
|
|
7747
|
-
const absTarget =
|
|
8595
|
+
const absTarget = path28.resolve(cwd, filePath);
|
|
7748
8596
|
for (const d of parsed.diagnostics) {
|
|
7749
|
-
if (!d.filename || !pathsEqual(
|
|
8597
|
+
if (!d.filename || !pathsEqual(path28.resolve(cwd, d.filename), absTarget)) {
|
|
7750
8598
|
continue;
|
|
7751
8599
|
}
|
|
7752
8600
|
const rule = extractOxlintRule(d.code);
|
|
@@ -7776,14 +8624,14 @@ function parseOxlintJson(raw, filePath, cwd) {
|
|
|
7776
8624
|
}
|
|
7777
8625
|
function parseOxlintUnix(raw, filePath, cwd) {
|
|
7778
8626
|
const diagnostics = [];
|
|
7779
|
-
const absTarget =
|
|
8627
|
+
const absTarget = path28.resolve(cwd, filePath);
|
|
7780
8628
|
for (const line of raw.split("\n")) {
|
|
7781
8629
|
const match = line.match(/^(.+):(\d+):(\d+):\s*(.+?)\s*\(([^)]+)\)$/);
|
|
7782
8630
|
if (match) {
|
|
7783
8631
|
const [, reportedPath, lineStr, _col, message, rule] = match;
|
|
7784
8632
|
if (!reportedPath || !lineStr || !message || !rule)
|
|
7785
8633
|
continue;
|
|
7786
|
-
if (!pathsEqual(
|
|
8634
|
+
if (!pathsEqual(path28.resolve(cwd, reportedPath), absTarget))
|
|
7787
8635
|
continue;
|
|
7788
8636
|
diagnostics.push({
|
|
7789
8637
|
id: `oxlint-${rule}-${lineStr}`,
|
|
@@ -7802,7 +8650,7 @@ function parseOxlintUnix(raw, filePath, cwd) {
|
|
|
7802
8650
|
var oxlint_default = oxlintRunner;
|
|
7803
8651
|
|
|
7804
8652
|
// dist/clients/dispatch/runners/php-lint.js
|
|
7805
|
-
import * as
|
|
8653
|
+
import * as path29 from "node:path";
|
|
7806
8654
|
var PHP_LINT_EXIT_CODES = { ran: [1, 255] };
|
|
7807
8655
|
var php = createAvailabilityChecker("php", ".exe");
|
|
7808
8656
|
function parsePhpLintOutput(raw, filePath, cwd) {
|
|
@@ -7812,7 +8660,7 @@ function parsePhpLintOutput(raw, filePath, cwd) {
|
|
|
7812
8660
|
const lineMatch = output.match(/on line (\d+)/i);
|
|
7813
8661
|
const messageMatch = output.match(/PHP Parse error:\s*(.+?)(?:\s+in\s+(.+?)\s+on line \d+)?$/im) ?? output.match(/Parse error:\s*(.+?)(?:\s+in\s+(.+?)\s+on line \d+)?$/im);
|
|
7814
8662
|
const reported = messageMatch?.[2]?.trim();
|
|
7815
|
-
if (reported && !pathsEqual(
|
|
8663
|
+
if (reported && !pathsEqual(path29.resolve(cwd, reported), path29.resolve(cwd, filePath)))
|
|
7816
8664
|
return [];
|
|
7817
8665
|
return [
|
|
7818
8666
|
{
|
|
@@ -7839,7 +8687,7 @@ var phpLintRunner = {
|
|
|
7839
8687
|
const cmd = ctx.analysisRootMode === "adopted" ? resolveAdoptedRootCommand("php", ctx, cwd) : await php.isAvailableAsync(cwd) ? php.getCommand(cwd) : null;
|
|
7840
8688
|
if (!cmd)
|
|
7841
8689
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
7842
|
-
const absPath =
|
|
8690
|
+
const absPath = path29.resolve(cwd, ctx.filePath);
|
|
7843
8691
|
const result = await safeSpawnAsync(cmd, ["-l", absPath], {
|
|
7844
8692
|
timeout: 15e3,
|
|
7845
8693
|
cwd
|
|
@@ -7864,7 +8712,7 @@ ${result.stderr ?? ""}`,
|
|
|
7864
8712
|
var php_lint_default = phpLintRunner;
|
|
7865
8713
|
|
|
7866
8714
|
// dist/clients/dispatch/runners/phpstan.js
|
|
7867
|
-
import * as
|
|
8715
|
+
import * as path30 from "node:path";
|
|
7868
8716
|
var PHPSTAN_EXIT_CODES = { ran: [1] };
|
|
7869
8717
|
var phpstan = createAvailabilityChecker("phpstan", ".phar");
|
|
7870
8718
|
function parsePhpstanJson(raw, fallbackPath, cwd) {
|
|
@@ -7872,7 +8720,7 @@ function parsePhpstanJson(raw, fallbackPath, cwd) {
|
|
|
7872
8720
|
const output = JSON.parse(raw);
|
|
7873
8721
|
const diagnostics = [];
|
|
7874
8722
|
for (const [file, fileErrors] of Object.entries(output.files ?? {})) {
|
|
7875
|
-
const filePath = file && file.trim() ?
|
|
8723
|
+
const filePath = file && file.trim() ? path30.isAbsolute(file) ? file : path30.resolve(cwd, file) : fallbackPath;
|
|
7876
8724
|
for (const err of fileErrors?.messages ?? []) {
|
|
7877
8725
|
diagnostics.push({
|
|
7878
8726
|
id: `phpstan:${err.line ?? 1}:${err.message.slice(0, 40)}`,
|
|
@@ -7931,7 +8779,7 @@ var phpstanRunner = {
|
|
|
7931
8779
|
const cmd = await resolvePhpstan(cwd);
|
|
7932
8780
|
if (!cmd)
|
|
7933
8781
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
7934
|
-
const absPath =
|
|
8782
|
+
const absPath = path30.resolve(cwd, ctx.filePath);
|
|
7935
8783
|
const result = await safeSpawnAsync(cmd, ["analyse", "--error-format=json", "--no-progress", absPath], { timeout: 3e4, cwd });
|
|
7936
8784
|
const run = parseToolRun("phpstan", { result, exitCodes: PHPSTAN_EXIT_CODES }, (out) => parsePhpstanJson(out, ctx.filePath, cwd), { parseOutput: result.stdout ?? "" });
|
|
7937
8785
|
if (run.skipped)
|
|
@@ -7949,7 +8797,7 @@ var phpstanRunner = {
|
|
|
7949
8797
|
var phpstan_default = phpstanRunner;
|
|
7950
8798
|
|
|
7951
8799
|
// dist/clients/dispatch/runners/prisma-validate.js
|
|
7952
|
-
import * as
|
|
8800
|
+
import * as path31 from "node:path";
|
|
7953
8801
|
var PRISMA_VALIDATION_REPORT = /\bValidation Error Count:\s*\d+/;
|
|
7954
8802
|
function parsePrismaValidateOutput(raw, filePath) {
|
|
7955
8803
|
const output = raw.split("\n").map((line) => line.trim()).filter(Boolean).filter((line) => !line.startsWith("Environment variables loaded")).filter((line) => !line.startsWith("Prisma schema loaded")).join(" ");
|
|
@@ -7980,7 +8828,7 @@ var prismaValidateRunner = {
|
|
|
7980
8828
|
async run(ctx) {
|
|
7981
8829
|
const cwd = resolveRunnerCwd(ctx, "prisma-validate");
|
|
7982
8830
|
const resolved = await resolveLocalFirstAsync("prisma", cwd);
|
|
7983
|
-
const absPath =
|
|
8831
|
+
const absPath = path31.resolve(cwd, ctx.filePath);
|
|
7984
8832
|
const result = await safeSpawnAsync(resolved.cmd, [...resolved.args, "validate", "--schema", absPath], {
|
|
7985
8833
|
timeout: 2e4,
|
|
7986
8834
|
// ONE neutral-cwd seam for npx fallbacks (#4193, #4268 acceptance 3),
|
|
@@ -8018,7 +8866,7 @@ var prisma_validate_default = prismaValidateRunner;
|
|
|
8018
8866
|
// dist/clients/dispatch/runners/psscriptanalyzer.js
|
|
8019
8867
|
import * as fs13 from "node:fs/promises";
|
|
8020
8868
|
import * as os2 from "node:os";
|
|
8021
|
-
import * as
|
|
8869
|
+
import * as path32 from "node:path";
|
|
8022
8870
|
var PS_SCRIPT = `
|
|
8023
8871
|
param([string]$FilePath)
|
|
8024
8872
|
Import-Module PSScriptAnalyzer -ErrorAction Stop
|
|
@@ -8210,8 +9058,8 @@ var psScriptAnalyzerRunner = {
|
|
|
8210
9058
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
8211
9059
|
}
|
|
8212
9060
|
const cwd = resolveRunnerCwd(ctx, "psscriptanalyzer");
|
|
8213
|
-
const absPath =
|
|
8214
|
-
const tmpScript =
|
|
9061
|
+
const absPath = path32.resolve(cwd, ctx.filePath);
|
|
9062
|
+
const tmpScript = path32.join(os2.tmpdir(), `pi-lens-psa-${process.pid}.ps1`);
|
|
8215
9063
|
await fs13.writeFile(tmpScript, PS_SCRIPT, "utf-8");
|
|
8216
9064
|
try {
|
|
8217
9065
|
const sampler = startHostStallSampler();
|
|
@@ -8342,7 +9190,7 @@ var pyrightRunner = {
|
|
|
8342
9190
|
cmd = installedPath;
|
|
8343
9191
|
}
|
|
8344
9192
|
if (!cmd) {
|
|
8345
|
-
const { findCommandAsync } = await import("./chunk-
|
|
9193
|
+
const { findCommandAsync } = await import("./chunk-GLW3YDZZ.js");
|
|
8346
9194
|
const foundCmd = await findCommandAsync("pyright");
|
|
8347
9195
|
if (foundCmd)
|
|
8348
9196
|
cmd = foundCmd;
|
|
@@ -8439,7 +9287,7 @@ function parsePyrightOutput(data, _filePath) {
|
|
|
8439
9287
|
var pyright_default = pyrightRunner;
|
|
8440
9288
|
|
|
8441
9289
|
// dist/clients/dispatch/runners/rubocop.js
|
|
8442
|
-
import * as
|
|
9290
|
+
import * as path33 from "node:path";
|
|
8443
9291
|
var SEVERITY_MAP = {
|
|
8444
9292
|
fatal: "error",
|
|
8445
9293
|
error: "error",
|
|
@@ -8452,9 +9300,9 @@ function parseRubocopJson(raw, filePath, cwd) {
|
|
|
8452
9300
|
const output = JSON.parse(raw);
|
|
8453
9301
|
const autofix = getAutofixCapability("rubocop");
|
|
8454
9302
|
const diagnostics = [];
|
|
8455
|
-
const absTarget =
|
|
9303
|
+
const absTarget = path33.resolve(cwd, filePath);
|
|
8456
9304
|
for (const file of output.files) {
|
|
8457
|
-
if (file.path && !pathsEqual(
|
|
9305
|
+
if (file.path && !pathsEqual(path33.resolve(cwd, file.path), absTarget))
|
|
8458
9306
|
continue;
|
|
8459
9307
|
for (const offense of file.offenses) {
|
|
8460
9308
|
const severity = SEVERITY_MAP[offense.severity] ?? "warning";
|
|
@@ -8739,7 +9587,7 @@ var rust_clippy_default = rustClippyRunner;
|
|
|
8739
9587
|
// dist/clients/dispatch/runners/spotbugs.js
|
|
8740
9588
|
import * as fs14 from "node:fs";
|
|
8741
9589
|
import * as os3 from "node:os";
|
|
8742
|
-
import * as
|
|
9590
|
+
import * as path34 from "node:path";
|
|
8743
9591
|
var java = createAvailabilityChecker("java", ".exe", ["-version"]);
|
|
8744
9592
|
var spotbugs = createAvailabilityChecker("spotbugs", ".bat", ["-version"]);
|
|
8745
9593
|
var MAX_DIAGNOSTICS = 50;
|
|
@@ -8760,7 +9608,7 @@ function classesSignature(classesDir) {
|
|
|
8760
9608
|
continue;
|
|
8761
9609
|
}
|
|
8762
9610
|
for (const entry of entries) {
|
|
8763
|
-
const full =
|
|
9611
|
+
const full = path34.join(dir, entry.name);
|
|
8764
9612
|
if (entry.isDirectory()) {
|
|
8765
9613
|
stack.push(full);
|
|
8766
9614
|
} else if (entry.isFile() && entry.name.endsWith(".class")) {
|
|
@@ -8851,7 +9699,7 @@ function parseSpotbugsXml(raw) {
|
|
|
8851
9699
|
const message = shortMsg || longMsg || type;
|
|
8852
9700
|
const fixSuggestion = longMsg ? firstSentence(longMsg) : void 0;
|
|
8853
9701
|
diagnostics.push({
|
|
8854
|
-
id: `spotbugs:${type}:${
|
|
9702
|
+
id: `spotbugs:${type}:${path34.basename(filePath)}:${line}:${index}`,
|
|
8855
9703
|
message: `[${type}] ${message}`,
|
|
8856
9704
|
filePath,
|
|
8857
9705
|
line,
|
|
@@ -8901,7 +9749,7 @@ var spotbugsRunner = {
|
|
|
8901
9749
|
const cmd = await resolveAvailableOrInstall(spotbugs, "spotbugs", cwd);
|
|
8902
9750
|
if (!cmd)
|
|
8903
9751
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
8904
|
-
const tmpXml =
|
|
9752
|
+
const tmpXml = path34.join(os3.tmpdir(), `pi-lens-spotbugs-${process.pid}-${Date.now()}.xml`);
|
|
8905
9753
|
const result = await safeSpawnAsync(cmd, [
|
|
8906
9754
|
"-textui",
|
|
8907
9755
|
"-xml:withMessages",
|
|
@@ -8943,8 +9791,9 @@ var spotbugs_default = spotbugsRunner;
|
|
|
8943
9791
|
|
|
8944
9792
|
// dist/clients/dispatch/runners/shellcheck.js
|
|
8945
9793
|
import * as fs15 from "node:fs";
|
|
8946
|
-
import * as
|
|
9794
|
+
import * as path35 from "node:path";
|
|
8947
9795
|
var shellcheck = createAvailabilityChecker("shellcheck", ".exe");
|
|
9796
|
+
var SHELLCHECK_EXIT_CODES = { ran: [1] };
|
|
8948
9797
|
var SHELLCHECK_DIALECTS = [
|
|
8949
9798
|
"sh",
|
|
8950
9799
|
"bash",
|
|
@@ -8984,7 +9833,7 @@ function resolveShellFileDialect(filePath) {
|
|
|
8984
9833
|
}
|
|
8985
9834
|
const directive = parseShellDirective(content);
|
|
8986
9835
|
const shebang = parseShebang(content);
|
|
8987
|
-
const parsed = directive ?? shebang ?? (
|
|
9836
|
+
const parsed = directive ?? shebang ?? (path35.extname(filePath).toLowerCase() === ".zsh" ? "zsh" : null);
|
|
8988
9837
|
return {
|
|
8989
9838
|
shebang,
|
|
8990
9839
|
directive,
|
|
@@ -8992,24 +9841,11 @@ function resolveShellFileDialect(filePath) {
|
|
|
8992
9841
|
};
|
|
8993
9842
|
}
|
|
8994
9843
|
function findShellcheckConfig(cwd) {
|
|
8995
|
-
|
|
8996
|
-
if (fs15.existsSync(local))
|
|
8997
|
-
return local;
|
|
8998
|
-
let current = path36.resolve(cwd);
|
|
8999
|
-
while (true) {
|
|
9000
|
-
const candidate = path36.join(current, ".shellcheckrc");
|
|
9001
|
-
if (fs15.existsSync(candidate))
|
|
9002
|
-
return candidate;
|
|
9003
|
-
const parent = path36.dirname(current);
|
|
9004
|
-
if (parent === current)
|
|
9005
|
-
break;
|
|
9006
|
-
current = parent;
|
|
9007
|
-
}
|
|
9008
|
-
return void 0;
|
|
9844
|
+
return findLocalToolConfig(cwd, [".shellcheckrc"]);
|
|
9009
9845
|
}
|
|
9010
9846
|
function parseShellcheckOutput(raw, filePath, cwd) {
|
|
9011
9847
|
const diagnostics = [];
|
|
9012
|
-
const absTarget =
|
|
9848
|
+
const absTarget = path35.resolve(cwd, filePath);
|
|
9013
9849
|
if (!raw.trim()) {
|
|
9014
9850
|
return diagnostics;
|
|
9015
9851
|
}
|
|
@@ -9021,7 +9857,7 @@ function parseShellcheckOutput(raw, filePath, cwd) {
|
|
|
9021
9857
|
for (const item of parsed) {
|
|
9022
9858
|
if (!item.message || !item.line)
|
|
9023
9859
|
continue;
|
|
9024
|
-
if (!item.file || !pathsEqual(
|
|
9860
|
+
if (!item.file || !pathsEqual(path35.resolve(cwd, item.file), absTarget))
|
|
9025
9861
|
continue;
|
|
9026
9862
|
const severityMap = {
|
|
9027
9863
|
error: "error",
|
|
@@ -9068,7 +9904,10 @@ var shellcheckRunner = {
|
|
|
9068
9904
|
skipReason: "covered-by-primary",
|
|
9069
9905
|
// WHO claimed (#3968 F2): declared (the row's own covers, gated
|
|
9070
9906
|
// on the custom row's own command) or builtin-fact.
|
|
9071
|
-
claimSource: cover.claimSource
|
|
9907
|
+
claimSource: cover.claimSource,
|
|
9908
|
+
// #4484 round 8: the skip is a verdict only when that server's
|
|
9909
|
+
// lane answers; the dispatcher voids it otherwise.
|
|
9910
|
+
coveredBy: { runnerId: "lsp", serverId: cover.serverId }
|
|
9072
9911
|
};
|
|
9073
9912
|
}
|
|
9074
9913
|
const dialectInfo = resolveShellFileDialect(ctx.filePath);
|
|
@@ -9103,20 +9942,52 @@ var shellcheckRunner = {
|
|
|
9103
9942
|
if (result.status === 0 && !result.stdout?.trim()) {
|
|
9104
9943
|
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
9105
9944
|
}
|
|
9106
|
-
const raw = result.stdout
|
|
9107
|
-
const
|
|
9945
|
+
const raw = `${result.stdout ?? ""}${result.stderr ?? ""}`;
|
|
9946
|
+
const parsed = parseToolRun("shellcheck", { result, output: raw, exitCodes: SHELLCHECK_EXIT_CODES }, (output) => parseShellcheckOutput(output, ctx.filePath, cwd));
|
|
9947
|
+
if (parsed.skipped)
|
|
9948
|
+
return parsed.skipped;
|
|
9108
9949
|
return finishParsedRun({
|
|
9109
9950
|
tool: "shellcheck",
|
|
9110
9951
|
ctx,
|
|
9111
9952
|
result,
|
|
9112
|
-
diagnostics
|
|
9953
|
+
diagnostics: parsed.diagnostics
|
|
9113
9954
|
});
|
|
9114
9955
|
}
|
|
9115
9956
|
};
|
|
9116
9957
|
var shellcheck_default = shellcheckRunner;
|
|
9117
9958
|
|
|
9118
9959
|
// dist/clients/dispatch/runners/fish-indent.js
|
|
9960
|
+
import { resolve as resolve32 } from "node:path";
|
|
9119
9961
|
var fishIndent = createAvailabilityChecker("fish_indent");
|
|
9962
|
+
var fish = createAvailabilityChecker("fish");
|
|
9963
|
+
var SYNTAX_STEP = "fish-syntax-check";
|
|
9964
|
+
function parseSyntaxErrors(output, filePath, cwd) {
|
|
9965
|
+
const diagnostics = [];
|
|
9966
|
+
for (const line of output.split("\n")) {
|
|
9967
|
+
const [, reported, lineText, message] = line.match(/^(.+) \(line (\d+)\): (.+)$/) ?? [];
|
|
9968
|
+
if (!reported || !lineText || !message)
|
|
9969
|
+
continue;
|
|
9970
|
+
const wanted = resolve32(cwd, filePath);
|
|
9971
|
+
if (!pathsEqual(resolve32(cwd, reported), wanted) && !(reported.startsWith("~/") && wanted.endsWith(reported.slice(1))))
|
|
9972
|
+
continue;
|
|
9973
|
+
const lineNumber = Number(lineText);
|
|
9974
|
+
diagnostics.push({
|
|
9975
|
+
id: `fish-syntax-${filePath}:${lineNumber}`,
|
|
9976
|
+
message: `fish: ${message.trim()}`,
|
|
9977
|
+
filePath,
|
|
9978
|
+
line: lineNumber,
|
|
9979
|
+
column: 1,
|
|
9980
|
+
severity: "error",
|
|
9981
|
+
semantic: "blocking",
|
|
9982
|
+
tool: "fish-indent",
|
|
9983
|
+
rule: "fish-syntax-error"
|
|
9984
|
+
});
|
|
9985
|
+
break;
|
|
9986
|
+
}
|
|
9987
|
+
return diagnostics;
|
|
9988
|
+
}
|
|
9989
|
+
var FISH_SYNTAX_EXIT_CODES = { ran: [127] };
|
|
9990
|
+
var BLOCKING_VERDICT = { status: "failed", semantic: "blocking" };
|
|
9120
9991
|
var fishIndentRunner = {
|
|
9121
9992
|
id: "fish-indent",
|
|
9122
9993
|
appliesTo: ["fish"],
|
|
@@ -9127,6 +9998,24 @@ var fishIndentRunner = {
|
|
|
9127
9998
|
const cmd = ctx.analysisRootMode === "adopted" ? resolveAdoptedRootCommand("fish_indent", ctx, cwd) : await fishIndent.isAvailableAsync(cwd) ? fishIndent.getCommand(cwd) : null;
|
|
9128
9999
|
if (!cmd)
|
|
9129
10000
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
10001
|
+
const fishCmd = ctx.analysisRootMode === "adopted" ? resolveAdoptedRootCommand("fish", ctx, cwd) : await fish.isAvailableAsync(cwd) ? fish.getCommand(cwd) : null;
|
|
10002
|
+
if (fishCmd) {
|
|
10003
|
+
const syntax = await safeSpawnAsync(fishCmd, ["--no-config", "--no-execute", ctx.filePath], { timeout: 1e4, cwd });
|
|
10004
|
+
const parsed = parseToolRun(SYNTAX_STEP, {
|
|
10005
|
+
result: syntax,
|
|
10006
|
+
output: syntax.stderr ?? "",
|
|
10007
|
+
exitCodes: FISH_SYNTAX_EXIT_CODES
|
|
10008
|
+
}, (output) => parseSyntaxErrors(output, ctx.filePath, cwd));
|
|
10009
|
+
if (parsed.diagnostics.length > 0) {
|
|
10010
|
+
return findingsResult(parsed.diagnostics, BLOCKING_VERDICT);
|
|
10011
|
+
}
|
|
10012
|
+
} else {
|
|
10013
|
+
recordDegradationOnce({
|
|
10014
|
+
kind: "fish-syntax-check-unavailable",
|
|
10015
|
+
subject: "fish",
|
|
10016
|
+
reason: "fish not found next to fish_indent: syntax errors are not checked"
|
|
10017
|
+
});
|
|
10018
|
+
}
|
|
9130
10019
|
const result = await safeSpawnAsync(cmd, ["--check", ctx.filePath], {
|
|
9131
10020
|
timeout: 1e4,
|
|
9132
10021
|
cwd
|
|
@@ -9134,7 +10023,12 @@ var fishIndentRunner = {
|
|
|
9134
10023
|
if (result.status === 0) {
|
|
9135
10024
|
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
9136
10025
|
}
|
|
9137
|
-
|
|
10026
|
+
if (result.signal || result.status === null) {
|
|
10027
|
+
const didNotRun = skipUnlessToolRan("fish_indent", { result });
|
|
10028
|
+
if (didNotRun)
|
|
10029
|
+
return didNotRun;
|
|
10030
|
+
}
|
|
10031
|
+
const stderrLine = (result.stderr ?? "").split("\n").find((l) => l.trim() && !pathsEqual(resolve32(cwd, l.trim()), resolve32(cwd, ctx.filePath)));
|
|
9138
10032
|
if (stderrLine) {
|
|
9139
10033
|
const lineMatch = stderrLine.match(/\(line\s+(\d+)\)/);
|
|
9140
10034
|
const line = lineMatch ? Number(lineMatch[1]) : 1;
|
|
@@ -9151,10 +10045,7 @@ var fishIndentRunner = {
|
|
|
9151
10045
|
rule: "fish-indent-parse-error"
|
|
9152
10046
|
}
|
|
9153
10047
|
];
|
|
9154
|
-
return findingsResult(diagnostics2,
|
|
9155
|
-
status: "failed",
|
|
9156
|
-
semantic: "blocking"
|
|
9157
|
-
});
|
|
10048
|
+
return findingsResult(diagnostics2, BLOCKING_VERDICT);
|
|
9158
10049
|
}
|
|
9159
10050
|
const diagnostics = [
|
|
9160
10051
|
{
|
|
@@ -9205,6 +10096,12 @@ var shfmtRunner = {
|
|
|
9205
10096
|
timeout: 1e4,
|
|
9206
10097
|
cwd
|
|
9207
10098
|
});
|
|
10099
|
+
const didNotRun = skipUnlessToolRan("shfmt", {
|
|
10100
|
+
result,
|
|
10101
|
+
output: `${result.stdout ?? ""}${result.stderr ?? ""}`
|
|
10102
|
+
});
|
|
10103
|
+
if (didNotRun)
|
|
10104
|
+
return didNotRun;
|
|
9208
10105
|
if (result.status === 0) {
|
|
9209
10106
|
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
9210
10107
|
}
|
|
@@ -9258,12 +10155,12 @@ var shfmtRunner = {
|
|
|
9258
10155
|
var shfmt_default = shfmtRunner;
|
|
9259
10156
|
|
|
9260
10157
|
// dist/clients/dispatch/runners/spellcheck.js
|
|
9261
|
-
import * as
|
|
10158
|
+
import * as path36 from "node:path";
|
|
9262
10159
|
var typos = createAvailabilityChecker("typos", ".exe");
|
|
9263
10160
|
var TYPOS_EXIT_CODES = { ran: [2] };
|
|
9264
10161
|
function parseTyposOutput(raw, filePath, cwd) {
|
|
9265
10162
|
const diagnostics = [];
|
|
9266
|
-
const absTarget =
|
|
10163
|
+
const absTarget = path36.resolve(cwd, filePath);
|
|
9267
10164
|
if (!raw.trim()) {
|
|
9268
10165
|
return diagnostics;
|
|
9269
10166
|
}
|
|
@@ -9273,7 +10170,7 @@ function parseTyposOutput(raw, filePath, cwd) {
|
|
|
9273
10170
|
const parsed = JSON.parse(line);
|
|
9274
10171
|
if (!parsed.typo || !parsed.line_num)
|
|
9275
10172
|
continue;
|
|
9276
|
-
if (parsed.path && !pathsEqual(
|
|
10173
|
+
if (parsed.path && !pathsEqual(path36.resolve(cwd, parsed.path), absTarget))
|
|
9277
10174
|
continue;
|
|
9278
10175
|
const corrections = parsed.corrections?.join(", ") || "no suggestions";
|
|
9279
10176
|
const message = `Typo: "${parsed.typo}" \u2192 ${corrections}`;
|
|
@@ -9331,7 +10228,7 @@ var spellcheckRunner = {
|
|
|
9331
10228
|
var spellcheck_default = spellcheckRunner;
|
|
9332
10229
|
|
|
9333
10230
|
// dist/clients/dispatch/runners/sqlfluff.js
|
|
9334
|
-
import * as
|
|
10231
|
+
import * as path37 from "node:path";
|
|
9335
10232
|
var sqlfluff = createAvailabilityChecker("sqlfluff", ".exe");
|
|
9336
10233
|
var SQLFLUFF_EXIT_CODES = { ran: [1] };
|
|
9337
10234
|
var SQLFLUFF_FIXABLE_RULES = /* @__PURE__ */ new Set([
|
|
@@ -9386,9 +10283,9 @@ function parseSqlfluffOutput(raw, filePath, cwd) {
|
|
|
9386
10283
|
if (!Array.isArray(parsed))
|
|
9387
10284
|
return [];
|
|
9388
10285
|
const diagnostics = [];
|
|
9389
|
-
const absTarget =
|
|
10286
|
+
const absTarget = path37.resolve(cwd, filePath);
|
|
9390
10287
|
for (const item of parsed) {
|
|
9391
|
-
if (item.filepath && !pathsEqual(
|
|
10288
|
+
if (item.filepath && !pathsEqual(path37.resolve(cwd, item.filepath), absTarget))
|
|
9392
10289
|
continue;
|
|
9393
10290
|
for (const v of item.violations ?? []) {
|
|
9394
10291
|
if (!v.description)
|
|
@@ -9463,7 +10360,7 @@ var sqlfluffRunner = {
|
|
|
9463
10360
|
var sqlfluff_default = sqlfluffRunner;
|
|
9464
10361
|
|
|
9465
10362
|
// dist/clients/dispatch/runners/stylelint.js
|
|
9466
|
-
import * as
|
|
10363
|
+
import * as path38 from "node:path";
|
|
9467
10364
|
var stylelint = createAvailabilityChecker("stylelint", ".cmd");
|
|
9468
10365
|
var STYLELINT_EXIT_CODES = { ran: [1, 2] };
|
|
9469
10366
|
function stylelintReport(stdout, stderr) {
|
|
@@ -9508,9 +10405,9 @@ function parseStylelintJson(raw, filePath, cwd) {
|
|
|
9508
10405
|
try {
|
|
9509
10406
|
const results = JSON.parse(raw);
|
|
9510
10407
|
const diagnostics = [];
|
|
9511
|
-
const absTarget =
|
|
10408
|
+
const absTarget = path38.resolve(cwd, filePath);
|
|
9512
10409
|
for (const result of results) {
|
|
9513
|
-
if (result.source && !pathsEqual(
|
|
10410
|
+
if (result.source && !pathsEqual(path38.resolve(cwd, result.source), absTarget))
|
|
9514
10411
|
continue;
|
|
9515
10412
|
for (const w of result.warnings) {
|
|
9516
10413
|
const severity = w.severity === "error" ? "error" : "warning";
|
|
@@ -9546,7 +10443,7 @@ var stylelintRunner = {
|
|
|
9546
10443
|
if (policy && !policy.preferredRunners.includes("stylelint")) {
|
|
9547
10444
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
9548
10445
|
}
|
|
9549
|
-
const fileDir =
|
|
10446
|
+
const fileDir = path38.dirname(path38.resolve(cwd, ctx.filePath));
|
|
9550
10447
|
const hasConfig = hasStylelintConfig(fileDir) || hasStylelintConfig(cwd);
|
|
9551
10448
|
if (!hasConfig) {
|
|
9552
10449
|
logRunnerAdvisoryOnce(ctx, "stylelint", cwd, "stylelint: no config detected, running with default rules");
|
|
@@ -9576,7 +10473,7 @@ var stylelintRunner = {
|
|
|
9576
10473
|
var stylelint_default = stylelintRunner;
|
|
9577
10474
|
|
|
9578
10475
|
// dist/clients/dispatch/runners/swiftlint.js
|
|
9579
|
-
import * as
|
|
10476
|
+
import * as path39 from "node:path";
|
|
9580
10477
|
var swiftlint = createAvailabilityChecker("swiftlint", ".exe");
|
|
9581
10478
|
var SWIFTLINT_FIXABLE_RULES = /* @__PURE__ */ new Set([
|
|
9582
10479
|
"closing_brace",
|
|
@@ -9639,7 +10536,7 @@ function parseSwiftLintOutput(raw, filePath, cwd) {
|
|
|
9639
10536
|
const diagnostics = [];
|
|
9640
10537
|
if (!raw.trim())
|
|
9641
10538
|
return diagnostics;
|
|
9642
|
-
const absTarget =
|
|
10539
|
+
const absTarget = path39.resolve(cwd, filePath);
|
|
9643
10540
|
try {
|
|
9644
10541
|
const parsed = JSON.parse(raw);
|
|
9645
10542
|
if (!Array.isArray(parsed))
|
|
@@ -9647,7 +10544,7 @@ function parseSwiftLintOutput(raw, filePath, cwd) {
|
|
|
9647
10544
|
for (const item of parsed) {
|
|
9648
10545
|
if (!item.reason)
|
|
9649
10546
|
continue;
|
|
9650
|
-
if (item.file && !pathsEqual(
|
|
10547
|
+
if (item.file && !pathsEqual(path39.resolve(cwd, item.file), absTarget))
|
|
9651
10548
|
continue;
|
|
9652
10549
|
const severityMap = {
|
|
9653
10550
|
error: "error",
|
|
@@ -9692,7 +10589,7 @@ var swiftlintRunner = {
|
|
|
9692
10589
|
}
|
|
9693
10590
|
if (!cmd)
|
|
9694
10591
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
9695
|
-
const result = await safeSpawnAsync(cmd, ["--reporter", "json",
|
|
10592
|
+
const result = await safeSpawnAsync(cmd, ["--reporter", "json", path39.resolve(cwd, ctx.filePath)], { cwd, timeout: 15e3 });
|
|
9696
10593
|
const run = parseToolRun("swiftlint", {
|
|
9697
10594
|
result,
|
|
9698
10595
|
// EXIT TABLE (SwiftLint 0.56 measured fixture): 0 clean; 1 findings; 2 error; other nonzero rejected.
|
|
@@ -9714,7 +10611,7 @@ var swiftlintRunner = {
|
|
|
9714
10611
|
var swiftlint_default = swiftlintRunner;
|
|
9715
10612
|
|
|
9716
10613
|
// dist/clients/dispatch/runners/taplo.js
|
|
9717
|
-
import * as
|
|
10614
|
+
import * as path40 from "node:path";
|
|
9718
10615
|
var taplo = createAvailabilityChecker("taplo", ".exe");
|
|
9719
10616
|
var TAPLO_EXIT_CODES = { ran: [1] };
|
|
9720
10617
|
var HEADER_PATTERN = /^\s*(error|warning):(.*)$/;
|
|
@@ -9722,7 +10619,7 @@ var LOCATION_LEAD = "\u250C\u2500";
|
|
|
9722
10619
|
var LOCATION_PATTERN = /^\s*┌─\s+(.+?):(\d+):(\d+)$/;
|
|
9723
10620
|
function parseTaploOutput(raw, filePath, cwd) {
|
|
9724
10621
|
const diagnostics = [];
|
|
9725
|
-
const absTarget =
|
|
10622
|
+
const absTarget = path40.resolve(cwd, filePath);
|
|
9726
10623
|
const lines = stripAnsi(raw ?? "").split(/\r?\n/);
|
|
9727
10624
|
for (let i = 0; i < lines.length; i++) {
|
|
9728
10625
|
const header = HEADER_PATTERN.exec(lines[i].trimEnd());
|
|
@@ -9740,7 +10637,7 @@ function parseTaploOutput(raw, filePath, cwd) {
|
|
|
9740
10637
|
const location = LOCATION_PATTERN.exec(lines[j].trimEnd());
|
|
9741
10638
|
if (!location)
|
|
9742
10639
|
continue;
|
|
9743
|
-
if (!pathsEqual(
|
|
10640
|
+
if (!pathsEqual(path40.resolve(cwd, location[1].trim()), absTarget))
|
|
9744
10641
|
continue;
|
|
9745
10642
|
line = Number.parseInt(location[2], 10) || 1;
|
|
9746
10643
|
column = Number.parseInt(location[3], 10) || 1;
|
|
@@ -9786,7 +10683,10 @@ var taploRunner = {
|
|
|
9786
10683
|
// an unexplained empty output on the delivery surfaces
|
|
9787
10684
|
// (defect shape 10). F2 adds the claim's provenance beside it.
|
|
9788
10685
|
skipReason: "covered-by-primary",
|
|
9789
|
-
claimSource: cover.claimSource
|
|
10686
|
+
claimSource: cover.claimSource,
|
|
10687
|
+
// #4484 round 8: the skip is a verdict only when that server's
|
|
10688
|
+
// lane answers; the dispatcher voids it otherwise.
|
|
10689
|
+
coveredBy: { runnerId: "lsp", serverId: cover.serverId }
|
|
9790
10690
|
};
|
|
9791
10691
|
}
|
|
9792
10692
|
let cmd = localBinPath(findLocalBinUpwards("taplo", cwd)) ?? null;
|
|
@@ -9799,7 +10699,7 @@ var taploRunner = {
|
|
|
9799
10699
|
}
|
|
9800
10700
|
if (!cmd)
|
|
9801
10701
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
9802
|
-
const absPath =
|
|
10702
|
+
const absPath = path40.resolve(cwd, ctx.filePath);
|
|
9803
10703
|
const result = await safeSpawnAsync(cmd, ["check", "--colors", "never", absPath], { cwd, timeout: 15e3 });
|
|
9804
10704
|
const raw = result.stderr?.trim() ? result.stderr : result.stdout ?? "";
|
|
9805
10705
|
const run = parseToolRun("taplo", { result, output: raw, exitCodes: TAPLO_EXIT_CODES }, (out) => parseTaploOutput(out, ctx.filePath, cwd), { skipWhenParsedNothing: true });
|
|
@@ -9818,7 +10718,7 @@ var taploRunner = {
|
|
|
9818
10718
|
var taplo_default = taploRunner;
|
|
9819
10719
|
|
|
9820
10720
|
// dist/clients/dispatch/runners/terragrunt.js
|
|
9821
|
-
import * as
|
|
10721
|
+
import * as path41 from "node:path";
|
|
9822
10722
|
var terragrunt = createAvailabilityChecker("terragrunt", ".exe");
|
|
9823
10723
|
function normalizeSeverity(raw) {
|
|
9824
10724
|
if (typeof raw === "number")
|
|
@@ -9837,7 +10737,7 @@ function toRawDiagnostics(parsed) {
|
|
|
9837
10737
|
return [];
|
|
9838
10738
|
return invalidFiles.flatMap((f) => Array.isArray(f?.diagnostics) ? f.diagnostics : []);
|
|
9839
10739
|
}
|
|
9840
|
-
function parseTerragruntOutput(raw, filePath, absPath =
|
|
10740
|
+
function parseTerragruntOutput(raw, filePath, absPath = path41.resolve(filePath)) {
|
|
9841
10741
|
if (!raw.trim())
|
|
9842
10742
|
return [];
|
|
9843
10743
|
let parsed;
|
|
@@ -9846,13 +10746,13 @@ function parseTerragruntOutput(raw, filePath, absPath = path42.resolve(filePath)
|
|
|
9846
10746
|
} catch {
|
|
9847
10747
|
return [];
|
|
9848
10748
|
}
|
|
9849
|
-
const unitDir =
|
|
10749
|
+
const unitDir = path41.dirname(absPath);
|
|
9850
10750
|
const diagnostics = [];
|
|
9851
10751
|
for (const d of toRawDiagnostics(parsed)) {
|
|
9852
10752
|
if (!d || typeof d !== "object")
|
|
9853
10753
|
continue;
|
|
9854
10754
|
const diagFile = d.range?.filename;
|
|
9855
|
-
if (diagFile && !pathsEqual(
|
|
10755
|
+
if (diagFile && !pathsEqual(path41.resolve(unitDir, diagFile), absPath))
|
|
9856
10756
|
continue;
|
|
9857
10757
|
const line = d.range?.start?.line ?? 1;
|
|
9858
10758
|
const column = d.range?.start?.column ?? 1;
|
|
@@ -9898,8 +10798,8 @@ var terragruntRunner = {
|
|
|
9898
10798
|
}
|
|
9899
10799
|
if (!cmd)
|
|
9900
10800
|
return SKIPPED3;
|
|
9901
|
-
const absPath =
|
|
9902
|
-
const fileDir =
|
|
10801
|
+
const absPath = path41.resolve(cwd, ctx.filePath);
|
|
10802
|
+
const fileDir = path41.dirname(absPath);
|
|
9903
10803
|
const result = await safeSpawnAsync(cmd, ["hcl", "validate", "--json", "--non-interactive"], { cwd: fileDir, timeout: 3e4 });
|
|
9904
10804
|
if (spawnFailedWithNoOutput(result))
|
|
9905
10805
|
return SKIPPED3;
|
|
@@ -9922,22 +10822,22 @@ var terragruntRunner = {
|
|
|
9922
10822
|
var terragrunt_default = terragruntRunner;
|
|
9923
10823
|
|
|
9924
10824
|
// dist/clients/dispatch/runners/tflint.js
|
|
9925
|
-
import * as
|
|
10825
|
+
import * as path42 from "node:path";
|
|
9926
10826
|
var tflint = createAvailabilityChecker("tflint", ".exe");
|
|
9927
10827
|
var TFLINT_CONFIG = ".tflint.hcl";
|
|
9928
10828
|
function findTflintConfig(fileDir) {
|
|
9929
10829
|
if (process.env.TFLINT_CONFIG_FILE)
|
|
9930
10830
|
return null;
|
|
9931
10831
|
const dir = findNearestDirWithAnyBasename(fileDir, [TFLINT_CONFIG]);
|
|
9932
|
-
return dir ?
|
|
10832
|
+
return dir ? path42.join(dir, TFLINT_CONFIG) : null;
|
|
9933
10833
|
}
|
|
9934
10834
|
function parseTflintOutput(raw, filePath, toolCwd) {
|
|
9935
10835
|
try {
|
|
9936
10836
|
const parsed = JSON.parse(raw);
|
|
9937
10837
|
const issues = parsed.issues ?? [];
|
|
9938
|
-
const absTarget =
|
|
10838
|
+
const absTarget = path42.resolve(toolCwd, filePath);
|
|
9939
10839
|
return issues.flatMap((issue) => {
|
|
9940
|
-
if (issue.range?.filename && !pathsEqual(
|
|
10840
|
+
if (issue.range?.filename && !pathsEqual(path42.resolve(toolCwd, issue.range.filename), absTarget))
|
|
9941
10841
|
return [];
|
|
9942
10842
|
const severity = issue.rule.severity === "error" ? "error" : "warning";
|
|
9943
10843
|
return [
|
|
@@ -9980,12 +10880,12 @@ var tflintRunner = {
|
|
|
9980
10880
|
}
|
|
9981
10881
|
if (!cmd)
|
|
9982
10882
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
9983
|
-
const absPath =
|
|
9984
|
-
const fileDir =
|
|
10883
|
+
const absPath = path42.resolve(cwd, ctx.filePath);
|
|
10884
|
+
const fileDir = path42.dirname(absPath);
|
|
9985
10885
|
const args = [
|
|
9986
10886
|
"--format=json",
|
|
9987
10887
|
"--no-color",
|
|
9988
|
-
`--filter=${
|
|
10888
|
+
`--filter=${path42.basename(absPath)}`
|
|
9989
10889
|
];
|
|
9990
10890
|
const configPath = findTflintConfig(fileDir);
|
|
9991
10891
|
if (configPath)
|
|
@@ -10021,7 +10921,7 @@ var tflint_default = tflintRunner;
|
|
|
10021
10921
|
|
|
10022
10922
|
// dist/clients/dispatch/runners/trivy-config.js
|
|
10023
10923
|
import * as fs16 from "node:fs";
|
|
10024
|
-
import * as
|
|
10924
|
+
import * as path43 from "node:path";
|
|
10025
10925
|
var trivy2 = createAvailabilityChecker("trivy", ".exe");
|
|
10026
10926
|
function looksLikeKubernetesManifest(content) {
|
|
10027
10927
|
for (const doc of content.split(/^---\s*$/m)) {
|
|
@@ -10058,12 +10958,12 @@ function parseTrivyConfigOutput(raw, filePath, cwd = process.cwd()) {
|
|
|
10058
10958
|
if (!Array.isArray(results))
|
|
10059
10959
|
return [];
|
|
10060
10960
|
const diagnostics = [];
|
|
10061
|
-
const absTarget =
|
|
10961
|
+
const absTarget = path43.resolve(cwd, filePath);
|
|
10062
10962
|
for (const resultEntry of results) {
|
|
10063
10963
|
if (!resultEntry || typeof resultEntry !== "object")
|
|
10064
10964
|
continue;
|
|
10065
10965
|
const target = resultEntry.Target;
|
|
10066
|
-
if (typeof target !== "string" || !pathsEqual(
|
|
10966
|
+
if (typeof target !== "string" || !pathsEqual(path43.resolve(cwd, target), absTarget))
|
|
10067
10967
|
continue;
|
|
10068
10968
|
const rows = resultEntry.Misconfigurations;
|
|
10069
10969
|
if (!Array.isArray(rows))
|
|
@@ -10107,7 +11007,7 @@ var trivyConfigRunner = {
|
|
|
10107
11007
|
if (!isTrivyEnabled(cwd)) {
|
|
10108
11008
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
10109
11009
|
}
|
|
10110
|
-
const absPath =
|
|
11010
|
+
const absPath = path43.resolve(cwd, ctx.filePath);
|
|
10111
11011
|
if (ctx.kind === "yaml" || ctx.kind === "json") {
|
|
10112
11012
|
let content = "";
|
|
10113
11013
|
try {
|
|
@@ -10179,30 +11079,16 @@ var trivyConfigRunner = {
|
|
|
10179
11079
|
var trivy_config_default = trivyConfigRunner;
|
|
10180
11080
|
|
|
10181
11081
|
// dist/clients/dispatch/runners/vale.js
|
|
10182
|
-
import * as
|
|
10183
|
-
import * as path45 from "node:path";
|
|
11082
|
+
import * as path44 from "node:path";
|
|
10184
11083
|
var vale = createAvailabilityChecker("vale", ".exe");
|
|
10185
11084
|
function findValeConfig(cwd) {
|
|
10186
|
-
|
|
10187
|
-
if (fs17.existsSync(local))
|
|
10188
|
-
return local;
|
|
10189
|
-
let current = path45.resolve(cwd);
|
|
10190
|
-
while (true) {
|
|
10191
|
-
const candidate = path45.join(current, ".vale.ini");
|
|
10192
|
-
if (fs17.existsSync(candidate))
|
|
10193
|
-
return candidate;
|
|
10194
|
-
const parent = path45.dirname(current);
|
|
10195
|
-
if (parent === current)
|
|
10196
|
-
break;
|
|
10197
|
-
current = parent;
|
|
10198
|
-
}
|
|
10199
|
-
return void 0;
|
|
11085
|
+
return findLocalToolConfig(cwd, [".vale.ini"]);
|
|
10200
11086
|
}
|
|
10201
11087
|
function parseValeOutput(raw, filePath, cwd) {
|
|
10202
11088
|
const diagnostics = [];
|
|
10203
11089
|
if (!raw.trim())
|
|
10204
11090
|
return diagnostics;
|
|
10205
|
-
const absTarget =
|
|
11091
|
+
const absTarget = path44.resolve(cwd, filePath);
|
|
10206
11092
|
try {
|
|
10207
11093
|
const parsed = JSON.parse(raw);
|
|
10208
11094
|
if (!parsed || typeof parsed !== "object")
|
|
@@ -10210,7 +11096,7 @@ function parseValeOutput(raw, filePath, cwd) {
|
|
|
10210
11096
|
for (const [reported, alerts] of Object.entries(parsed)) {
|
|
10211
11097
|
if (!Array.isArray(alerts))
|
|
10212
11098
|
continue;
|
|
10213
|
-
if (reported && !pathsEqual(
|
|
11099
|
+
if (reported && !pathsEqual(path44.resolve(cwd, reported), absTarget))
|
|
10214
11100
|
continue;
|
|
10215
11101
|
for (const alert of alerts) {
|
|
10216
11102
|
if (!alert.Message)
|
|
@@ -10281,11 +11167,11 @@ var valeRunner = {
|
|
|
10281
11167
|
var vale_default = valeRunner;
|
|
10282
11168
|
|
|
10283
11169
|
// dist/clients/dispatch/runners/tree-sitter.js
|
|
10284
|
-
import * as
|
|
11170
|
+
import * as path46 from "node:path";
|
|
10285
11171
|
|
|
10286
11172
|
// dist/clients/cache/rule-cache.js
|
|
10287
|
-
import * as
|
|
10288
|
-
import * as
|
|
11173
|
+
import * as fs17 from "node:fs";
|
|
11174
|
+
import * as path45 from "node:path";
|
|
10289
11175
|
var CACHE_VERSION = "v7";
|
|
10290
11176
|
function reportBundledRulesRootHealth() {
|
|
10291
11177
|
reportBundledResourceDirHealth("tree-sitter-queries-dir-missing", BUNDLED_QUERIES_ROOT, getBundledQueriesRootHealth(), "bundled tree-sitter query rules");
|
|
@@ -10297,12 +11183,12 @@ var RuleCache = class {
|
|
|
10297
11183
|
constructor(language, rootDir = process.cwd()) {
|
|
10298
11184
|
this.language = language;
|
|
10299
11185
|
reportBundledRulesRootHealth();
|
|
10300
|
-
this.cacheDir =
|
|
10301
|
-
this.cacheFile =
|
|
11186
|
+
this.cacheDir = path45.join(getProjectDataDir(rootDir), "cache");
|
|
11187
|
+
this.cacheFile = path45.join(this.cacheDir, `${language}-rules-${CACHE_VERSION}.json`);
|
|
10302
11188
|
}
|
|
10303
11189
|
ensureCacheDir() {
|
|
10304
|
-
if (!
|
|
10305
|
-
|
|
11190
|
+
if (!fs17.existsSync(this.cacheDir)) {
|
|
11191
|
+
fs17.mkdirSync(this.cacheDir, { recursive: true });
|
|
10306
11192
|
}
|
|
10307
11193
|
}
|
|
10308
11194
|
computeRuleHash(ruleFiles) {
|
|
@@ -10311,7 +11197,7 @@ var RuleCache = class {
|
|
|
10311
11197
|
get(ruleFiles) {
|
|
10312
11198
|
try {
|
|
10313
11199
|
this.ensureCacheDir();
|
|
10314
|
-
if (!
|
|
11200
|
+
if (!fs17.existsSync(this.cacheFile))
|
|
10315
11201
|
return null;
|
|
10316
11202
|
const currentHash = this.computeRuleHash(ruleFiles);
|
|
10317
11203
|
const cached = readJsonCache(this.cacheFile, (parsed) => {
|
|
@@ -10345,11 +11231,11 @@ var RuleCache = class {
|
|
|
10345
11231
|
// on their own — nothing ever read or removed them again once the version
|
|
10346
11232
|
// bumped. Delete every sibling for this language that isn't the current file.
|
|
10347
11233
|
pruneStaleVersions() {
|
|
10348
|
-
const currentName =
|
|
11234
|
+
const currentName = path45.basename(this.cacheFile);
|
|
10349
11235
|
const pattern = new RegExp(`^${this.language}-rules-v\\d+\\.json$`);
|
|
10350
11236
|
let dirents;
|
|
10351
11237
|
try {
|
|
10352
|
-
dirents =
|
|
11238
|
+
dirents = fs17.readdirSync(this.cacheDir);
|
|
10353
11239
|
} catch {
|
|
10354
11240
|
return;
|
|
10355
11241
|
}
|
|
@@ -10357,15 +11243,15 @@ var RuleCache = class {
|
|
|
10357
11243
|
if (name === currentName || !pattern.test(name))
|
|
10358
11244
|
continue;
|
|
10359
11245
|
try {
|
|
10360
|
-
|
|
11246
|
+
fs17.unlinkSync(path45.join(this.cacheDir, name));
|
|
10361
11247
|
} catch {
|
|
10362
11248
|
}
|
|
10363
11249
|
}
|
|
10364
11250
|
}
|
|
10365
11251
|
clear() {
|
|
10366
11252
|
try {
|
|
10367
|
-
if (
|
|
10368
|
-
|
|
11253
|
+
if (fs17.existsSync(this.cacheFile)) {
|
|
11254
|
+
fs17.unlinkSync(this.cacheFile);
|
|
10369
11255
|
}
|
|
10370
11256
|
} catch {
|
|
10371
11257
|
}
|
|
@@ -10634,11 +11520,6 @@ function defaultFixSuggestion2(defectClass, ruleId) {
|
|
|
10634
11520
|
}
|
|
10635
11521
|
return "Refactor this pattern to a safer, explicit form matching project conventions.";
|
|
10636
11522
|
}
|
|
10637
|
-
function isLineInModifiedRanges(line, ranges) {
|
|
10638
|
-
if (!ranges || ranges.length === 0)
|
|
10639
|
-
return true;
|
|
10640
|
-
return ranges.some((r) => line >= r.start && line <= r.end);
|
|
10641
|
-
}
|
|
10642
11523
|
function getTotalLinesChanged(ranges) {
|
|
10643
11524
|
if (!ranges || ranges.length === 0)
|
|
10644
11525
|
return 0;
|
|
@@ -10684,7 +11565,7 @@ var treeSitterRunner = {
|
|
|
10684
11565
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
10685
11566
|
}
|
|
10686
11567
|
const filePath = ctx.filePath;
|
|
10687
|
-
const ext =
|
|
11568
|
+
const ext = path46.extname(filePath).toLowerCase();
|
|
10688
11569
|
const languageId = resolveTreeSitterLanguage(filePath);
|
|
10689
11570
|
if (!languageId) {
|
|
10690
11571
|
logTreeSitter({
|
|
@@ -10763,19 +11644,20 @@ var treeSitterRunner = {
|
|
|
10763
11644
|
const contentFromFacts = ctx.facts.getFileFact(filePath, "file.content");
|
|
10764
11645
|
const contentOverride = contentFromFacts !== void 0 && contentFromFacts !== null ? contentFromFacts : void 0;
|
|
10765
11646
|
const diagnostics = [];
|
|
11647
|
+
const withheld = [];
|
|
11648
|
+
let queryRunFailed = false;
|
|
10766
11649
|
try {
|
|
10767
11650
|
const found = await client.runQueriesOnFile(effectiveQueries, filePath, languageId, { maxResults: 10 }, contentOverride);
|
|
10768
11651
|
for (const { queryDef: query, match } of found) {
|
|
10769
11652
|
const { line, column } = match;
|
|
10770
11653
|
const isSeverityBlocking = query.severity === "error" || query.inline_tier === "blocking" || SILENT_ERROR_QUERY_IDS.has(query.id);
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
}
|
|
11654
|
+
const endLine = line + (match.matchedText.match(/\n/g)?.length ?? 0);
|
|
11655
|
+
const outOfScope = ctx.blockingOnly && isSeverityBlocking && !spanOverlapsModifiedRanges(line, endLine, ctx.modifiedRanges);
|
|
10774
11656
|
const semantic = query.severity === "error" ? "blocking" : query.severity === "warning" ? "warning" : "none";
|
|
10775
11657
|
const defectClass = query.defect_class ?? classifyDefect(query.id, "tree-sitter", query.message);
|
|
10776
11658
|
const suggestion = query.has_fix && query.fix_action ? `${query.fix_action} this statement` : semantic === "blocking" ? defaultFixSuggestion2(defectClass, query.id) : void 0;
|
|
10777
11659
|
const hasSuggestedFix = !!query.has_fix;
|
|
10778
|
-
diagnostics.push({
|
|
11660
|
+
(outOfScope ? withheld : diagnostics).push({
|
|
10779
11661
|
id: `tree-sitter:${query.id}:${line}`,
|
|
10780
11662
|
message: query.message.replace(/\{\{(\w+)\}\}/g, (_, name) => match.captures[name]?.trim() ?? `{{${name}}}`),
|
|
10781
11663
|
filePath,
|
|
@@ -10797,6 +11679,7 @@ var treeSitterRunner = {
|
|
|
10797
11679
|
});
|
|
10798
11680
|
}
|
|
10799
11681
|
} catch (err) {
|
|
11682
|
+
queryRunFailed = true;
|
|
10800
11683
|
const msg = err instanceof Error ? err.message : String(err);
|
|
10801
11684
|
if (classifyTreeSitterWasmError(err) === "abort") {
|
|
10802
11685
|
markTreeSitterWasmAborted();
|
|
@@ -10856,6 +11739,10 @@ var treeSitterRunner = {
|
|
|
10856
11739
|
} catch {
|
|
10857
11740
|
}
|
|
10858
11741
|
}
|
|
11742
|
+
const observationExtras = {
|
|
11743
|
+
...withheld.length > 0 && { outOfEditScope: withheld },
|
|
11744
|
+
...queryRunFailed && { inconclusive: true }
|
|
11745
|
+
};
|
|
10859
11746
|
if (diagnostics.length === 0) {
|
|
10860
11747
|
if (!isTreeSitterWasmAborted() && !client.getLanguage(languageId)) {
|
|
10861
11748
|
logTreeSitter({
|
|
@@ -10865,7 +11752,11 @@ var treeSitterRunner = {
|
|
|
10865
11752
|
reason: "grammar_unavailable",
|
|
10866
11753
|
status: "skipped"
|
|
10867
11754
|
});
|
|
10868
|
-
return {
|
|
11755
|
+
return {
|
|
11756
|
+
status: "skipped",
|
|
11757
|
+
diagnostics: [],
|
|
11758
|
+
semantic: "none"
|
|
11759
|
+
};
|
|
10869
11760
|
}
|
|
10870
11761
|
logTreeSitter({
|
|
10871
11762
|
phase: "runner_complete",
|
|
@@ -10877,7 +11768,12 @@ var treeSitterRunner = {
|
|
|
10877
11768
|
queryCount: languageQueries.length,
|
|
10878
11769
|
effectiveQueryCount: effectiveQueries.length
|
|
10879
11770
|
});
|
|
10880
|
-
return {
|
|
11771
|
+
return {
|
|
11772
|
+
status: "succeeded",
|
|
11773
|
+
diagnostics: [],
|
|
11774
|
+
semantic: "none",
|
|
11775
|
+
...observationExtras
|
|
11776
|
+
};
|
|
10881
11777
|
}
|
|
10882
11778
|
const hasBlocking = diagnostics.some((d) => d.semantic === "blocking");
|
|
10883
11779
|
const blockingCount = diagnostics.filter((d) => d.semantic === "blocking").length;
|
|
@@ -10891,27 +11787,30 @@ var treeSitterRunner = {
|
|
|
10891
11787
|
queryCount: languageQueries.length,
|
|
10892
11788
|
effectiveQueryCount: effectiveQueries.length
|
|
10893
11789
|
});
|
|
10894
|
-
return
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
11790
|
+
return {
|
|
11791
|
+
...findingsResult(diagnostics, {
|
|
11792
|
+
status: hasBlocking ? "failed" : "succeeded",
|
|
11793
|
+
semantic: hasBlocking ? "blocking" : "warning"
|
|
11794
|
+
}),
|
|
11795
|
+
...observationExtras
|
|
11796
|
+
};
|
|
10898
11797
|
}
|
|
10899
11798
|
};
|
|
10900
11799
|
var tree_sitter_default = treeSitterRunner;
|
|
10901
11800
|
|
|
10902
11801
|
// dist/clients/dispatch/runners/yamllint.js
|
|
10903
|
-
import * as
|
|
11802
|
+
import * as path47 from "node:path";
|
|
10904
11803
|
var yamllint = createAvailabilityChecker("yamllint", ".exe");
|
|
10905
11804
|
function parseYamllintParsable(raw, filePath, cwd) {
|
|
10906
11805
|
const diagnostics = [];
|
|
10907
|
-
const absTarget =
|
|
11806
|
+
const absTarget = path47.resolve(cwd, filePath);
|
|
10908
11807
|
for (const line of raw.split(/\r?\n/)) {
|
|
10909
11808
|
if (!line.trim())
|
|
10910
11809
|
continue;
|
|
10911
11810
|
const match = line.match(/^(.*?):(\d+):(\d+):\s*\[(error|warning)\]\s*(.*?)\s*\(([^)]+)\)\s*$/i);
|
|
10912
11811
|
if (!match)
|
|
10913
11812
|
continue;
|
|
10914
|
-
if (!pathsEqual(
|
|
11813
|
+
if (!pathsEqual(path47.resolve(cwd, match[1]), absTarget))
|
|
10915
11814
|
continue;
|
|
10916
11815
|
const severity = match[4].toLowerCase() === "error" ? "error" : "warning";
|
|
10917
11816
|
diagnostics.push({
|
|
@@ -10976,17 +11875,17 @@ var yamllintRunner = {
|
|
|
10976
11875
|
var yamllint_default = yamllintRunner;
|
|
10977
11876
|
|
|
10978
11877
|
// dist/clients/dispatch/runners/zig-check.js
|
|
10979
|
-
import * as
|
|
11878
|
+
import * as path48 from "node:path";
|
|
10980
11879
|
var zig = createAvailabilityChecker("zig", ".exe", ["version"]);
|
|
10981
11880
|
function parseZigOutput(raw, filePath, cwd) {
|
|
10982
11881
|
const diagnostics = [];
|
|
10983
|
-
const absTarget =
|
|
11882
|
+
const absTarget = path48.resolve(cwd, filePath);
|
|
10984
11883
|
for (const line of raw.split(/\r?\n/)) {
|
|
10985
11884
|
const match = line.match(/^(.*?):(\d+):(\d+):\s*(error|warning|note):\s*(.+)$/);
|
|
10986
11885
|
if (!match)
|
|
10987
11886
|
continue;
|
|
10988
11887
|
const [, rawFile, lineStr, colStr, level, message] = match;
|
|
10989
|
-
if (!pathsEqual(
|
|
11888
|
+
if (!pathsEqual(path48.resolve(cwd, rawFile.trim()), absTarget))
|
|
10990
11889
|
continue;
|
|
10991
11890
|
const severity = level === "error" ? "error" : "warning";
|
|
10992
11891
|
diagnostics.push({
|
|
@@ -11017,7 +11916,7 @@ var zigCheckRunner = {
|
|
|
11017
11916
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
11018
11917
|
}
|
|
11019
11918
|
const cmd = zig.getCommand(cwd);
|
|
11020
|
-
const absPath =
|
|
11919
|
+
const absPath = path48.resolve(cwd, ctx.filePath);
|
|
11021
11920
|
const result = await safeSpawnAsync(cmd, ["build-exe", absPath, "-fno-emit-bin"], { cwd, timeout: 3e4 });
|
|
11022
11921
|
if (result.error && !result.stdout && !result.stderr) {
|
|
11023
11922
|
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
@@ -11305,8 +12204,6 @@ function isTestSuiteOrganizer(calls) {
|
|
|
11305
12204
|
// dist/clients/dispatch/rules/high-complexity.js
|
|
11306
12205
|
var DEFAULT_HIGH_COMPLEXITY_THRESHOLD = 15;
|
|
11307
12206
|
var DEFAULT_HIGH_COMPLEXITY_DEPTH_THRESHOLD = 6;
|
|
11308
|
-
var ccThreshold = DEFAULT_HIGH_COMPLEXITY_THRESHOLD;
|
|
11309
|
-
var depthThreshold = DEFAULT_HIGH_COMPLEXITY_DEPTH_THRESHOLD;
|
|
11310
12207
|
var highComplexityRule = {
|
|
11311
12208
|
id: "high-complexity",
|
|
11312
12209
|
requires: ["file.functionSummaries"],
|
|
@@ -11317,12 +12214,12 @@ var highComplexityRule = {
|
|
|
11317
12214
|
const fns = store.getFileFact(ctx.filePath, "file.functionSummaries") ?? [];
|
|
11318
12215
|
const diagnostics = [];
|
|
11319
12216
|
const configuredCcThreshold = ctx.projectConfig?.rules["high-complexity"]?.threshold;
|
|
11320
|
-
const activeCcThreshold = configuredCcThreshold ??
|
|
12217
|
+
const activeCcThreshold = configuredCcThreshold ?? DEFAULT_HIGH_COMPLEXITY_THRESHOLD;
|
|
11321
12218
|
for (const f of fns) {
|
|
11322
12219
|
if (isTestSuiteOrganizer(f.outgoingCalls))
|
|
11323
12220
|
continue;
|
|
11324
12221
|
const ccBreached = f.cyclomaticComplexity >= activeCcThreshold;
|
|
11325
|
-
const depthBreached = f.maxNestingDepth >=
|
|
12222
|
+
const depthBreached = f.maxNestingDepth >= DEFAULT_HIGH_COMPLEXITY_DEPTH_THRESHOLD;
|
|
11326
12223
|
if (!ccBreached && !depthBreached)
|
|
11327
12224
|
continue;
|
|
11328
12225
|
const parts = [];
|
|
@@ -11348,7 +12245,6 @@ var highComplexityRule = {
|
|
|
11348
12245
|
|
|
11349
12246
|
// dist/clients/dispatch/rules/high-fan-out.js
|
|
11350
12247
|
var DEFAULT_HIGH_FAN_OUT_THRESHOLD = 20;
|
|
11351
|
-
var fanOutThreshold = DEFAULT_HIGH_FAN_OUT_THRESHOLD;
|
|
11352
12248
|
var highFanOutRule = {
|
|
11353
12249
|
id: "high-fan-out",
|
|
11354
12250
|
requires: ["file.functionSummaries"],
|
|
@@ -11359,7 +12255,7 @@ var highFanOutRule = {
|
|
|
11359
12255
|
const fns = store.getFileFact(ctx.filePath, "file.functionSummaries") ?? [];
|
|
11360
12256
|
const diagnostics = [];
|
|
11361
12257
|
const configuredFanOutThreshold = ctx.projectConfig?.rules["high-fan-out"]?.threshold;
|
|
11362
|
-
const activeFanOutThreshold = configuredFanOutThreshold ??
|
|
12258
|
+
const activeFanOutThreshold = configuredFanOutThreshold ?? DEFAULT_HIGH_FAN_OUT_THRESHOLD;
|
|
11363
12259
|
for (const f of fns) {
|
|
11364
12260
|
if (isTestSuiteOrganizer(f.outgoingCalls))
|
|
11365
12261
|
continue;
|
|
@@ -11718,6 +12614,8 @@ function applyProjectLensConfig(cwd) {
|
|
|
11718
12614
|
return loadPiLensProjectConfig(cwd);
|
|
11719
12615
|
}
|
|
11720
12616
|
var sessionFacts = new FactStore("dispatch");
|
|
12617
|
+
var preEditCaptureFacts = new FactStore("pre-edit-capture");
|
|
12618
|
+
var preEditCapturesInFlight = /* @__PURE__ */ new Map();
|
|
11721
12619
|
setFactStoreEvictionReporter((subject, axis, reason) => {
|
|
11722
12620
|
if (axis === "pinned-over-budget") {
|
|
11723
12621
|
recordDegradationOnce({
|
|
@@ -11782,7 +12680,7 @@ async function runAstGrepWarningScan(filePath, cwd, pi, logContext, facts = sess
|
|
|
11782
12680
|
try {
|
|
11783
12681
|
const group = {
|
|
11784
12682
|
mode: "all",
|
|
11785
|
-
runnerIds: ["ast-grep"],
|
|
12683
|
+
runnerIds: ["ast-grep-napi"],
|
|
11786
12684
|
filterKinds: ["jsts"]
|
|
11787
12685
|
};
|
|
11788
12686
|
await runProviders(ctx);
|
|
@@ -11899,12 +12797,16 @@ function resetDispatchBaselines(cwd) {
|
|
|
11899
12797
|
resetAstGrepNapiLoadState();
|
|
11900
12798
|
resetTreeSitterClientLoadState();
|
|
11901
12799
|
sessionFacts.clearAll();
|
|
12800
|
+
for (const controller of preEditCapturesInFlight.values())
|
|
12801
|
+
controller.abort();
|
|
12802
|
+
preEditCaptureFacts.clearAll();
|
|
11902
12803
|
resetSessionSlopScore();
|
|
11903
12804
|
clearCoverageNoticeState();
|
|
11904
12805
|
clearReviewGraphWorkspaceCache();
|
|
11905
12806
|
clearReverseDepsIndexCache();
|
|
11906
12807
|
clearModuleGraphCache();
|
|
11907
|
-
|
|
12808
|
+
resetCascadeUnansweredPrimariesDelivered();
|
|
12809
|
+
resetCascadePendingNeighbors();
|
|
11908
12810
|
primaryFilesThisTurn.clear();
|
|
11909
12811
|
cascadeSessionStats = {
|
|
11910
12812
|
runs: 0,
|
|
@@ -11920,7 +12822,6 @@ var cascadeSessionStats = {
|
|
|
11920
12822
|
diagnosticsSurfaced: 0,
|
|
11921
12823
|
coldSnapshotTouches: 0
|
|
11922
12824
|
};
|
|
11923
|
-
var recentlyCleanNeighborCache = /* @__PURE__ */ new Map();
|
|
11924
12825
|
var primaryFilesThisTurn = /* @__PURE__ */ new Set();
|
|
11925
12826
|
var MAX_PER_FILE = RUNTIME_CONFIG.pipeline.cascadeMaxDiagnosticsPerFile;
|
|
11926
12827
|
var MAX_FILES = RUNTIME_CONFIG.pipeline.cascadeMaxFiles;
|
|
@@ -11948,8 +12849,16 @@ var CASCADE_GRAPH_KINDS = /* @__PURE__ */ new Set([
|
|
|
11948
12849
|
"ruby",
|
|
11949
12850
|
"cxx"
|
|
11950
12851
|
]);
|
|
12852
|
+
var IMPLICIT_SCOPE_NEIGHBOR_CAP = MAX_FILES * 2;
|
|
11951
12853
|
async function dispatchLintWithResult(filePath, cwd, pi, modifiedRanges, logContext, options) {
|
|
11952
|
-
const
|
|
12854
|
+
const created = createDispatchContext(filePath, cwd, pi, sessionFacts, options?.blockingOnly ?? true, modifiedRanges, options?.projectRoot, options?.writeIndex, options?.telemetryModel, options?.telemetryProvider, options?.sessionGeneration, options?.sessionId, options?.analysisRootMode);
|
|
12855
|
+
const ctx = options?.owedRanges?.size || options?.recordedRunnerIds?.size ? {
|
|
12856
|
+
...created,
|
|
12857
|
+
...options.owedRanges?.size && { owedRanges: options.owedRanges },
|
|
12858
|
+
...options.recordedRunnerIds?.size && {
|
|
12859
|
+
recordedRunnerIds: options.recordedRunnerIds
|
|
12860
|
+
}
|
|
12861
|
+
} : created;
|
|
11953
12862
|
sessionFacts.clearFileFactsFor(ctx.filePath);
|
|
11954
12863
|
try {
|
|
11955
12864
|
const kind = ctx.kind;
|
|
@@ -12080,14 +12989,17 @@ function enforceWarmWordIndexLruCap() {
|
|
|
12080
12989
|
return;
|
|
12081
12990
|
}
|
|
12082
12991
|
}
|
|
12992
|
+
function usableWarmWordIndex(index) {
|
|
12993
|
+
return index?.forward ? index : void 0;
|
|
12994
|
+
}
|
|
12083
12995
|
function acquireWarmWordIndex(cwd) {
|
|
12084
|
-
const key2 =
|
|
12996
|
+
const key2 = path49.resolve(cwd);
|
|
12085
12997
|
let entry = warmWordIndexes.get(key2);
|
|
12086
12998
|
if (!entry) {
|
|
12087
12999
|
const snapshot = loadProjectSnapshot(key2);
|
|
12088
|
-
const index = deserializeWordIndex(snapshot?.wordIndex) ?? void 0;
|
|
13000
|
+
const index = usableWarmWordIndex(deserializeWordIndex(snapshot?.wordIndex) ?? void 0);
|
|
12089
13001
|
entry = {
|
|
12090
|
-
index
|
|
13002
|
+
index,
|
|
12091
13003
|
timer: void 0,
|
|
12092
13004
|
leases: 0,
|
|
12093
13005
|
lastUsedAt: Date.now(),
|
|
@@ -12115,6 +13027,26 @@ function acquireWarmWordIndex(cwd) {
|
|
|
12115
13027
|
}
|
|
12116
13028
|
};
|
|
12117
13029
|
}
|
|
13030
|
+
function adoptPublishedWarmWordIndex(cwd, published, trigger) {
|
|
13031
|
+
const index = usableWarmWordIndex(published);
|
|
13032
|
+
if (!index)
|
|
13033
|
+
return;
|
|
13034
|
+
const key2 = path49.resolve(cwd);
|
|
13035
|
+
const entry = warmWordIndexes.get(key2);
|
|
13036
|
+
if (!entry || entry.index)
|
|
13037
|
+
return;
|
|
13038
|
+
entry.index = index;
|
|
13039
|
+
entry.lastUsedAt = Date.now();
|
|
13040
|
+
scheduleWarmWordIndexIdleEviction(key2, entry);
|
|
13041
|
+
logWordIndex({
|
|
13042
|
+
phase: "warm_cache_adopted",
|
|
13043
|
+
cwd: key2,
|
|
13044
|
+
trigger,
|
|
13045
|
+
indexedFileCount: index.docCount,
|
|
13046
|
+
tokens: index.postings.size
|
|
13047
|
+
});
|
|
13048
|
+
}
|
|
13049
|
+
setWordIndexPublishedListener(adoptPublishedWarmWordIndex);
|
|
12118
13050
|
function _resetWarmWordIndexCacheForTests() {
|
|
12119
13051
|
for (const entry of warmWordIndexes.values())
|
|
12120
13052
|
clearWarmWordIndexTimer(entry);
|
|
@@ -12166,7 +13098,7 @@ async function warmLspForFile(absPath, host) {
|
|
|
12166
13098
|
return;
|
|
12167
13099
|
let content;
|
|
12168
13100
|
try {
|
|
12169
|
-
content =
|
|
13101
|
+
content = fs18.readFileSync(absPath, "utf8");
|
|
12170
13102
|
} catch {
|
|
12171
13103
|
return;
|
|
12172
13104
|
}
|
|
@@ -12177,22 +13109,29 @@ async function warmLspForFile(absPath, host) {
|
|
|
12177
13109
|
clientScope: "primary",
|
|
12178
13110
|
maxClientWaitMs: WARMUP_CLIENT_WAIT_MS,
|
|
12179
13111
|
maxDiagnosticsWaitMs: WARMUP_DIAGNOSTICS_WAIT_MS,
|
|
12180
|
-
source: "mcp-warmup"
|
|
13112
|
+
source: "mcp-warmup",
|
|
13113
|
+
// #3405: every caller of `analyzeFile` (the MCP hosts' post-write hooks,
|
|
13114
|
+
// warm and cold, and `pilens_analyze`) asks about the bytes on disk now,
|
|
13115
|
+
// and this is the analysis's first push of them, so it is the save. A
|
|
13116
|
+
// save-triggered server (Expert compiles on didSave and on nothing else)
|
|
13117
|
+
// answers an MCP host's edit only because of it.
|
|
13118
|
+
saved: true
|
|
12181
13119
|
});
|
|
12182
13120
|
} catch {
|
|
12183
13121
|
}
|
|
12184
13122
|
}
|
|
12185
13123
|
async function analyzeFile(filePath, cwd, options = {}) {
|
|
12186
|
-
const absPath =
|
|
13124
|
+
const absPath = path49.isAbsolute(filePath) ? filePath : path49.resolve(cwd, filePath);
|
|
12187
13125
|
const host = createMcpHost({ "no-delta": true, ...options.flags }, cwd);
|
|
12188
13126
|
const observedAt = Date.now();
|
|
13127
|
+
const analysisRootMode = resolveAnalysisRoot(absPath, cwd);
|
|
12189
13128
|
if (options.warmLsp !== false) {
|
|
12190
13129
|
await warmLspForFile(absPath, host);
|
|
12191
13130
|
}
|
|
12192
13131
|
const start = Date.now();
|
|
12193
13132
|
const result = await dispatchLintWithResult(absPath, cwd, host, void 0, void 0, {
|
|
12194
13133
|
blockingOnly: options.blockingOnly ?? false,
|
|
12195
|
-
analysisRootMode
|
|
13134
|
+
analysisRootMode,
|
|
12196
13135
|
// #3791: this is a pull surface. Each call is an independent question,
|
|
12197
13136
|
// so the synthetic coverage notice must come back on every call rather
|
|
12198
13137
|
// than being latched once per session by the dispatcher — otherwise a
|
|
@@ -12209,7 +13148,7 @@ async function analyzeFile(filePath, cwd, options = {}) {
|
|
|
12209
13148
|
}
|
|
12210
13149
|
if (options.registerTurnState) {
|
|
12211
13150
|
try {
|
|
12212
|
-
const lineCount =
|
|
13151
|
+
const lineCount = fs18.readFileSync(absPath, "utf8").split("\n").length;
|
|
12213
13152
|
new CacheManager().addModifiedRange(absPath, { start: 1, end: lineCount }, true, cwd, options.ownerId ?? MCP_TURN_STATE_OWNER_ID, "mcp");
|
|
12214
13153
|
} catch {
|
|
12215
13154
|
}
|
|
@@ -12227,17 +13166,28 @@ async function analyzeFile(filePath, cwd, options = {}) {
|
|
|
12227
13166
|
try {
|
|
12228
13167
|
if (warmIndex) {
|
|
12229
13168
|
try {
|
|
12230
|
-
const content =
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
|
|
13169
|
+
const content = fs18.readFileSync(absPath, "utf8");
|
|
13170
|
+
if (!canWriteAnalysisRoot(analysisRootMode)) {
|
|
13171
|
+
emitBounded("adopted_root_writer_skipped", `${absPath}:word-index`, {
|
|
13172
|
+
filePath: absPath,
|
|
13173
|
+
durationMs: 0,
|
|
13174
|
+
metadata: { writer: "word-index" }
|
|
13175
|
+
}, {
|
|
13176
|
+
ledgerKind: "adopted-root-writer-skipped",
|
|
13177
|
+
risingEdgePer: "identity"
|
|
12238
13178
|
});
|
|
13179
|
+
} else {
|
|
13180
|
+
const byteLength = Buffer.byteLength(content, "utf-8");
|
|
13181
|
+
if (byteLength > WORD_INDEX_MAX_BYTES) {
|
|
13182
|
+
await removeWordIndexDocumentAsync(warmIndex, absPath);
|
|
13183
|
+
} else {
|
|
13184
|
+
await updateWordIndexDocumentForEdit(warmIndex, {
|
|
13185
|
+
path: absPath,
|
|
13186
|
+
content
|
|
13187
|
+
});
|
|
13188
|
+
}
|
|
13189
|
+
scheduleWordIndexPersist(cwd, warmIndex);
|
|
12239
13190
|
}
|
|
12240
|
-
scheduleWordIndexPersist(cwd, warmIndex);
|
|
12241
13191
|
} catch {
|
|
12242
13192
|
}
|
|
12243
13193
|
}
|
|
@@ -12294,10 +13244,23 @@ async function analyzeFile(filePath, cwd, options = {}) {
|
|
|
12294
13244
|
}
|
|
12295
13245
|
|
|
12296
13246
|
export {
|
|
13247
|
+
DEFAULT_MAX_AGE_MS,
|
|
12297
13248
|
MCP_TURN_STATE_OWNER_ID,
|
|
12298
13249
|
CacheManager,
|
|
12299
13250
|
getDiagnosticTracker,
|
|
12300
13251
|
normalizeRuleId,
|
|
13252
|
+
readFileContent,
|
|
13253
|
+
applyRulePolicy,
|
|
13254
|
+
convertLspDiagnostics,
|
|
13255
|
+
applyFindingPolicy,
|
|
13256
|
+
loadProjectRulePolicyMap,
|
|
13257
|
+
inlineBlockerIdentities,
|
|
13258
|
+
applyPushedFindingPolicy,
|
|
13259
|
+
applyPushedFindingPolicyByFile,
|
|
13260
|
+
applyLspFindingPolicy,
|
|
13261
|
+
filterFindingsByDisposition,
|
|
13262
|
+
stampLineHashes,
|
|
13263
|
+
owedByContentOnly,
|
|
12301
13264
|
getToolPlan,
|
|
12302
13265
|
resetObservedRunnerLatency,
|
|
12303
13266
|
requeueRunnerFindings,
|
|
@@ -12305,33 +13268,34 @@ export {
|
|
|
12305
13268
|
dropStaleRunnerFindings,
|
|
12306
13269
|
resetPendingRunnerFindings,
|
|
12307
13270
|
pendingRunnerFindingsSize,
|
|
12308
|
-
|
|
13271
|
+
laneCopyStandsFor,
|
|
12309
13272
|
DELTA_UNUSED_PROMOTION_NOTE,
|
|
12310
13273
|
formatDiagnostics,
|
|
12311
13274
|
createDispatchContext,
|
|
12312
13275
|
getLatencyReports,
|
|
12313
13276
|
cascadeSettleWaitMs,
|
|
12314
|
-
convertLspDiagnostics,
|
|
12315
|
-
applyFindingPolicy,
|
|
12316
|
-
loadProjectRulePolicyMap,
|
|
12317
|
-
inlineBlockerIdentities,
|
|
12318
|
-
applyPushedFindingPolicy,
|
|
12319
|
-
applyLspFindingPolicy,
|
|
12320
|
-
filterFindingsByDisposition,
|
|
12321
13277
|
markUnreconciledFindings,
|
|
12322
13278
|
formatCacheAgeLabel,
|
|
13279
|
+
dispositionSuppressedLine,
|
|
12323
13280
|
admitsProjectWideFindings,
|
|
13281
|
+
formatCascadeNeighborDiagnostics,
|
|
13282
|
+
composeCascadeSection,
|
|
12324
13283
|
cascadeCarrySuffix,
|
|
13284
|
+
markCascadeUnansweredPrimariesDelivered,
|
|
13285
|
+
renderCascadeResult,
|
|
13286
|
+
cascadeStillPresentSince,
|
|
13287
|
+
recordDeliveredCascadeNeighbor,
|
|
13288
|
+
forgetCascadePendingNeighbor,
|
|
13289
|
+
listCascadePendingNeighbors,
|
|
12325
13290
|
logCascade,
|
|
12326
13291
|
resetCascadeTierSessionState,
|
|
13292
|
+
peekOutstandingCascadeTouches,
|
|
12327
13293
|
loadSg,
|
|
12328
13294
|
canHandle,
|
|
12329
13295
|
getLang,
|
|
12330
13296
|
evaluateAstGrepRules,
|
|
12331
13297
|
runProviders,
|
|
12332
13298
|
evaluateRules,
|
|
12333
|
-
demoteInferredProjectDiagnostics,
|
|
12334
|
-
demoteInferredProjectSweepResults,
|
|
12335
13299
|
resetPsScriptAnalyzerAvailability,
|
|
12336
13300
|
resetDispatchBaselines,
|
|
12337
13301
|
getAvailableRunners,
|