pi-lens 4.4.4 → 4.4.6
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 +477 -0
- package/README.md +45 -3
- package/config/biome/core.jsonc +3 -3
- package/config/dependency-cruiser-eager-allowlist.json +1 -0
- package/dist/{chunk-UBOQLVT2.js → chunk-2DDDCJDL.js} +4 -4
- package/dist/{chunk-RKKOYPRA.js → chunk-2DMLM3ZO.js} +13 -15
- package/dist/chunk-2F47TQOA.js +73 -0
- package/dist/{chunk-O4NWQT6I.js → chunk-2PHMIAKO.js} +4 -4
- package/dist/{chunk-DGUKIYSI.js → chunk-2RLWJO5K.js} +8 -10
- package/dist/{chunk-S67KYG37.js → chunk-2X4VLOCC.js} +2 -2
- package/dist/{chunk-TIQ2PKDW.js → chunk-3MYEA7QD.js} +4 -4
- package/dist/{chunk-3DA2JDOL.js → chunk-3WEPUD2V.js} +551 -203
- package/dist/{chunk-AMERCH6V.js → chunk-4AVZ3TG7.js} +15 -16
- package/dist/{chunk-IYNJ6YPZ.js → chunk-4PCQCU47.js} +4 -4
- package/dist/chunk-4WX4CTUE.js +57 -0
- package/dist/{chunk-P63GXC37.js → chunk-5APMQ2IJ.js} +31 -4
- package/dist/{chunk-ZIVJBOO3.js → chunk-5CV5ITZF.js} +2 -2
- package/dist/{chunk-6DLWKFEX.js → chunk-5ZR3APIM.js} +41 -42
- package/dist/{chunk-XTBDCR27.js → chunk-63RIVFQI.js} +4 -4
- package/dist/{chunk-GSLNCYGG.js → chunk-75SY4F24.js} +13 -14
- package/dist/{chunk-U44DJXQP.js → chunk-7RQXA5GG.js} +15 -18
- package/dist/chunk-A3YNG5KP.js +45 -0
- package/dist/{chunk-5OFV52AM.js → chunk-AE37FEGH.js} +1 -1
- package/dist/{chunk-BWD5EPKO.js → chunk-AMXIUN2R.js} +4 -6
- package/dist/{chunk-3KAZU3VR.js → chunk-ARD426WI.js} +2 -2
- package/dist/{chunk-BW5KFIQC.js → chunk-AWQWXSW4.js} +1 -0
- package/dist/{chunk-YH5MVY2U.js → chunk-BHUWL2Y3.js} +7 -7
- package/dist/{chunk-CT4MN5IU.js → chunk-BI5LAQ3Y.js} +353 -359
- package/dist/{chunk-KAPJINKN.js → chunk-BM5GS6ZH.js} +2 -2
- package/dist/{chunk-TLX72JTG.js → chunk-BWYQUPOS.js} +1 -1
- package/dist/chunk-CFRQMBGP.js +49 -0
- package/dist/{chunk-RMLC67LF.js → chunk-CJYKEW2L.js} +2 -30
- package/dist/chunk-CKEQFGLT.js +32 -0
- package/dist/{chunk-IWDLU6K3.js → chunk-DC4CFXM5.js} +4 -6
- package/dist/{chunk-ZVUL7QYY.js → chunk-DMSLNKF7.js} +29 -32
- package/dist/{chunk-KN35K52N.js → chunk-DQXSPYRI.js} +3 -3
- package/dist/{chunk-HYGZEMX6.js → chunk-EVDGNG4F.js} +11 -5
- package/dist/{chunk-SRYEJNES.js → chunk-F5Z6URKM.js} +2 -2
- package/dist/{chunk-UMS2MFPZ.js → chunk-F6X3YJWD.js} +2 -3
- package/dist/{chunk-XYURS6EN.js → chunk-FA5LDARD.js} +15 -17
- package/dist/{chunk-24AKHFGP.js → chunk-FFL3A2VP.js} +6 -6
- package/dist/chunk-FJIVKLPH.js +31 -0
- package/dist/chunk-G2B7F6ZU.js +88 -0
- package/dist/{chunk-US7ECLD7.js → chunk-GAACZY6R.js} +131 -41
- package/dist/{chunk-MZGQNL3Y.js → chunk-GMTFDAOK.js} +12 -13
- package/dist/{chunk-VOOAPROD.js → chunk-GNSIWBAT.js} +3 -3
- package/dist/chunk-GTAI2J6U.js +27 -0
- package/dist/{chunk-RVK72CZX.js → chunk-GZE7WOI4.js} +1362 -459
- package/dist/{chunk-IUE7SSKV.js → chunk-H7HTEQUZ.js} +13 -7
- package/dist/{chunk-EUXZEFTV.js → chunk-HK6JVFZC.js} +3 -3
- package/dist/chunk-IPDG45G5.js +26 -0
- package/dist/{chunk-5HSRT26B.js → chunk-J6JP25XU.js} +16 -15
- package/dist/{chunk-HWCCCQNX.js → chunk-JL6CXUMW.js} +13 -6
- package/dist/{chunk-EBC36LNN.js → chunk-K2YGBXOA.js} +17 -17
- package/dist/{chunk-WMYE35PX.js → chunk-KLQVC3XC.js} +7 -5
- package/dist/{chunk-ATKJFDQN.js → chunk-KSR7RGQY.js} +12 -14
- package/dist/{chunk-POMLXPMY.js → chunk-KXF5R4UN.js} +1 -1
- package/dist/{chunk-LLJNQKQW.js → chunk-LEJOJDXL.js} +20 -13
- package/dist/{chunk-JUKMK5Y4.js → chunk-MA77RSFN.js} +10 -11
- package/dist/{chunk-GAQ7OQG6.js → chunk-MKVZQUEG.js} +85 -96
- package/dist/{chunk-2EECBNC5.js → chunk-MN7MHUXQ.js} +75 -0
- package/dist/{chunk-DEL2U6CM.js → chunk-MT6BVNFW.js} +16 -14
- package/dist/chunk-NDMCVUYK.js +507 -0
- package/dist/{chunk-HRNHZA3N.js → chunk-NIU2IPC5.js} +12 -16
- package/dist/{chunk-AGSS7277.js → chunk-NNKXDXXS.js} +7 -24
- package/dist/{chunk-V35JG4JB.js → chunk-OJLTLYHB.js} +152 -334
- package/dist/{chunk-J6MPGQTS.js → chunk-OLAWH5UQ.js} +81 -15
- package/dist/{chunk-T57LYLZT.js → chunk-OOU2WZZE.js} +1 -1
- package/dist/{chunk-CYRKQRPM.js → chunk-OSTKYB55.js} +2 -4
- package/dist/chunk-P4QNXS6I.js +27 -0
- package/dist/chunk-PKES3ISE.js +297 -0
- package/dist/{chunk-ROYSX2S5.js → chunk-PO45POGF.js} +2 -2
- package/dist/{chunk-T7FEBKXN.js → chunk-PPIBVH4R.js} +7 -9
- package/dist/{chunk-3RKP3FMS.js → chunk-PQJFG24Z.js} +295 -23
- package/dist/{chunk-KUA4OJ5Y.js → chunk-Q3UZHW6N.js} +846 -350
- package/dist/{chunk-N5FLEO7W.js → chunk-Q4EMRFNA.js} +37 -37
- package/dist/{chunk-5IUSNGOC.js → chunk-Q4FCYCRE.js} +28 -21
- package/dist/chunk-Q6D6VMI4.js +22 -0
- package/dist/{chunk-UZ2XCLYS.js → chunk-QGSTQH4D.js} +8 -8
- package/dist/{chunk-DUO2TU77.js → chunk-RZOXUSPC.js} +10 -4
- package/dist/{chunk-JMYYOTQG.js → chunk-S26LC76R.js} +13 -1
- package/dist/{chunk-GMX5OS7B.js → chunk-S67UJDGQ.js} +11 -12
- package/dist/chunk-SCIUNBPF.js +44 -0
- package/dist/{chunk-RKBXZN3A.js → chunk-SJJYRZB4.js} +2 -2
- package/dist/chunk-SXGD4ANG.js +25 -0
- package/dist/{chunk-YCWYO6TQ.js → chunk-T7FTXGS3.js} +48 -45
- package/dist/{chunk-FM4RDMKT.js → chunk-TIQJPRDD.js} +115 -61
- package/dist/{chunk-XHJBS436.js → chunk-TIYGSODX.js} +25 -25
- package/dist/{chunk-S2HEXIWI.js → chunk-U2SDMG7C.js} +10 -6
- package/dist/{chunk-2KXTHF3M.js → chunk-U6OC3QEM.js} +253 -33
- package/dist/{chunk-AWSCPCN2.js → chunk-UCGQT677.js} +19 -19
- package/dist/chunk-UHGF5UT5.js +32 -0
- package/dist/{chunk-JW3YWBVB.js → chunk-UN4TEBWN.js} +17 -19
- package/dist/{chunk-ZHH37KZL.js → chunk-V3APN3DY.js} +17 -17
- package/dist/{chunk-ED36RF6Y.js → chunk-V63BC55Q.js} +1 -1
- package/dist/{chunk-XBJVAEEO.js → chunk-VG5JS5SW.js} +3 -2
- package/dist/{chunk-W66O5E25.js → chunk-VPBIMOAQ.js} +13 -15
- package/dist/chunk-VQH24FIP.js +37 -0
- package/dist/{chunk-YNE3RP52.js → chunk-VSFLRN5Y.js} +8 -1
- package/dist/{chunk-7D6L4MTX.js → chunk-W2V54OCL.js} +3 -3
- package/dist/{chunk-2FN63LPV.js → chunk-W5LGKNET.js} +13 -14
- package/dist/{chunk-IQWN5JCP.js → chunk-W5R5SABV.js} +13 -14
- package/dist/{chunk-R3T7CLQ2.js → chunk-WIZWZR4C.js} +41 -41
- package/dist/{chunk-TOY6QKOH.js → chunk-WQOIR3QY.js} +17 -17
- package/dist/{chunk-Y6GZHWSJ.js → chunk-XAIT2YGS.js} +6 -6
- package/dist/chunk-XCUHKYCQ.js +23 -0
- package/dist/{chunk-GSM5UU7A.js → chunk-XQCSWV2G.js} +44 -35
- package/dist/{chunk-OHKJ7PQF.js → chunk-YBSONGSZ.js} +43 -39
- package/dist/{chunk-GXFV6MYU.js → chunk-YISME6ON.js} +72 -39
- package/dist/chunk-YRD4ISED.js +30 -0
- package/dist/{chunk-SD4I7ZO4.js → chunk-YSBHPOY6.js} +43 -53
- package/dist/{chunk-QBFBRV2B.js → chunk-Z2XAOKHK.js} +4 -2
- package/dist/{chunk-5VSF4UUQ.js → chunk-Z7IGUAXL.js} +34 -39
- package/dist/{chunk-MPNJLASA.js → chunk-ZKXQKGWZ.js} +10 -13
- package/dist/{chunk-J64T55EI.js → chunk-ZQ6NZZTB.js} +75 -9
- package/dist/chunk-ZUUI3ZSA.js +38 -0
- package/dist/{chunk-7HXE67BN.js → chunk-ZYNI26MI.js} +2 -2
- package/dist/index.js +32674 -27567
- package/dist/mcp/analyze-cli.js +11 -12
- package/dist/mcp/cli.js +46 -45
- package/dist/mcp/server.js +1210 -574
- package/dist/mcp/worker.js +65 -65
- package/dist/probes/installer.js +21 -23
- package/docs/adr/0010-trace-validation-session-lifecycle.md +390 -0
- package/docs/adr/README.md +1 -0
- package/docs/agent-tools.md +28 -7
- package/docs/ast-grep_rules_catalog.md +5 -3
- package/docs/configuration.md +12 -1
- package/docs/defect-shapes.md +738 -0
- package/docs/engineering-principles.md +12 -0
- package/docs/environment-variables.md +20 -0
- package/docs/features.md +16 -1
- package/docs/globalconfig.md +37 -8
- package/docs/invariants/caches-stores.md +30 -0
- package/docs/invariants/dispatch-runners.md +164 -0
- package/docs/invariants/git-guard-host.md +53 -0
- package/docs/invariants/language-config.md +31 -0
- package/docs/invariants/lsp-trust-exec.md +286 -0
- package/docs/invariants/paths-os.md +59 -0
- package/docs/invariants/session-telemetry.md +74 -0
- package/docs/lsp-capability-matrix.md +105 -12
- package/docs/lsp-idle-eviction.md +37 -18
- package/docs/pi-lens-fixer.md +24 -2
- package/docs/pi-lens-investigator.md +14 -0
- package/docs/pi-lens-merge-policy.md +32 -17
- package/docs/pi-lens-monitor.md +66 -10
- package/docs/pi-lens-orchestration.md +41 -0
- package/docs/pi-lens-release.md +20 -0
- package/docs/pi-lens-retro.md +5 -4
- package/docs/pi-lens-reviewer.md +54 -7
- package/docs/pi-lens-subagent.md +10 -3
- package/docs/release-qa-baseline.md +19 -7
- package/docs/servercapabilities.md +47 -47
- package/docs/settings.md +9 -5
- package/docs/subagent-compat.md +1 -1
- package/docs/usage.md +1 -0
- package/package.json +8 -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/lib/is-main-module.mjs +27 -0
- package/scripts/lib/scratch-home-env.mjs +21 -0
- package/scripts/rpc-load-check.mjs +4 -6
- package/scripts/warm-loader-cache.mjs +2 -5
- package/dist/chunk-3PTHXJXR.js +0 -28
- package/dist/chunk-3QED2P4V.js +0 -31
- package/dist/chunk-5WRPDP2A.js +0 -47
- package/dist/chunk-ABBOA7UD.js +0 -157
- package/dist/chunk-CUHSHSB6.js +0 -273
- package/dist/chunk-GL5LUMZE.js +0 -51
- package/dist/chunk-HAD7QRQI.js +0 -30
- package/dist/chunk-JORED7EX.js +0 -44
- package/dist/chunk-KYUB6QDC.js +0 -72
- package/dist/chunk-LZSEQW6A.js +0 -57
- package/dist/chunk-M2IFVFWU.js +0 -79
- package/dist/chunk-M2UD3LPU.js +0 -88
- package/dist/chunk-MBKQHGA7.js +0 -39
- package/dist/chunk-R7YOCSNV.js +0 -23
- package/dist/chunk-SKAMFC7A.js +0 -28
- package/dist/chunk-SYE6T2EB.js +0 -28
- package/dist/chunk-TRETHTQO.js +0 -26
- package/dist/chunk-UA7ZXYDR.js +0 -184
- package/dist/chunk-XTFDJI3T.js +0 -24
- package/dist/chunk-Z3CCVDUB.js +0 -76
package/dist/mcp/server.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createRequire as __pilensCreateRequire } from "node:module"; const requ
|
|
|
3
3
|
import {
|
|
4
4
|
GitleaksClient,
|
|
5
5
|
classifyAndFilterFindings
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-FFL3A2VP.js";
|
|
7
7
|
import {
|
|
8
8
|
DEAD_CODE_DELTA_MAX_SHOWN,
|
|
9
9
|
deadCodeIssueCount,
|
|
@@ -11,18 +11,18 @@ import {
|
|
|
11
11
|
deadCodeIssues,
|
|
12
12
|
formatDeadCodeDelta,
|
|
13
13
|
stableFindingKey
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-2DMLM3ZO.js";
|
|
15
15
|
import {
|
|
16
16
|
clearFormatterCache
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-XQCSWV2G.js";
|
|
18
18
|
import {
|
|
19
19
|
findNearestProjectRoot,
|
|
20
20
|
isStartupScanVerdictFresh,
|
|
21
21
|
resolveStartupScanContext
|
|
22
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-7RQXA5GG.js";
|
|
23
23
|
import {
|
|
24
24
|
loadCallGraph
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-W2V54OCL.js";
|
|
26
26
|
import {
|
|
27
27
|
isHardFailureSummary
|
|
28
28
|
} from "../chunk-7U2IDNXN.js";
|
|
@@ -31,11 +31,11 @@ import {
|
|
|
31
31
|
formatRunDurationMs,
|
|
32
32
|
isExcludedTestTarget,
|
|
33
33
|
isRunnerErrorResult
|
|
34
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-YSBHPOY6.js";
|
|
35
35
|
import {
|
|
36
36
|
GovulncheckClient
|
|
37
|
-
} from "../chunk-
|
|
38
|
-
import "../chunk-
|
|
37
|
+
} from "../chunk-H7HTEQUZ.js";
|
|
38
|
+
import "../chunk-5CV5ITZF.js";
|
|
39
39
|
import {
|
|
40
40
|
resetManagedToolRefreshSession
|
|
41
41
|
} from "../chunk-UXVNL3D7.js";
|
|
@@ -53,9 +53,10 @@ import {
|
|
|
53
53
|
peekTurnEndFindings,
|
|
54
54
|
snapshotAdvisoryProvenance,
|
|
55
55
|
validateAdvisoryProvenance
|
|
56
|
-
} from "../chunk-
|
|
56
|
+
} from "../chunk-KLQVC3XC.js";
|
|
57
57
|
import {
|
|
58
58
|
CacheManager,
|
|
59
|
+
DEFAULT_MAX_AGE_MS,
|
|
59
60
|
DELTA_UNUSED_PROMOTION_NOTE,
|
|
60
61
|
MCP_TURN_STATE_OWNER_ID,
|
|
61
62
|
acquireWarmWordIndex,
|
|
@@ -74,8 +75,6 @@ import {
|
|
|
74
75
|
convertLspDiagnostics,
|
|
75
76
|
createDispatchContext,
|
|
76
77
|
createMcpHost,
|
|
77
|
-
demoteInferredProjectDiagnostics,
|
|
78
|
-
demoteInferredProjectSweepResults,
|
|
79
78
|
dispositionSuppressedLine,
|
|
80
79
|
drainPendingRunnerFindings,
|
|
81
80
|
dropStaleRunnerFindings,
|
|
@@ -114,53 +113,52 @@ import {
|
|
|
114
113
|
resetPsScriptAnalyzerAvailability,
|
|
115
114
|
runProviders,
|
|
116
115
|
stampLineHashes
|
|
117
|
-
} from "../chunk-
|
|
116
|
+
} from "../chunk-BI5LAQ3Y.js";
|
|
118
117
|
import {
|
|
119
118
|
resetLazyInstallAttempts
|
|
120
|
-
} from "../chunk-
|
|
119
|
+
} from "../chunk-2DDDCJDL.js";
|
|
121
120
|
import {
|
|
122
121
|
isTestRoleCollateral
|
|
123
|
-
} from "../chunk-
|
|
122
|
+
} from "../chunk-AE37FEGH.js";
|
|
124
123
|
import {
|
|
125
124
|
findingsResult,
|
|
126
125
|
hasUsableResult,
|
|
127
126
|
reachedNoVerdict
|
|
128
|
-
} from "../chunk-
|
|
129
|
-
import "../chunk-
|
|
130
|
-
import "../chunk-
|
|
131
|
-
import "../chunk-KN35K52N.js";
|
|
127
|
+
} from "../chunk-SJJYRZB4.js";
|
|
128
|
+
import "../chunk-2X4VLOCC.js";
|
|
129
|
+
import "../chunk-DQXSPYRI.js";
|
|
132
130
|
import {
|
|
133
131
|
resetGoAvailability
|
|
134
|
-
} from "../chunk-
|
|
132
|
+
} from "../chunk-PO45POGF.js";
|
|
135
133
|
import {
|
|
136
134
|
TrivyClient
|
|
137
|
-
} from "../chunk-
|
|
135
|
+
} from "../chunk-BHUWL2Y3.js";
|
|
138
136
|
import {
|
|
139
137
|
scannerReportParentDir
|
|
140
|
-
} from "../chunk-
|
|
141
|
-
import "../chunk-
|
|
142
|
-
import "../chunk-
|
|
138
|
+
} from "../chunk-V63BC55Q.js";
|
|
139
|
+
import "../chunk-AMXIUN2R.js";
|
|
140
|
+
import "../chunk-3MYEA7QD.js";
|
|
143
141
|
import {
|
|
144
142
|
resetRustAvailability
|
|
145
|
-
} from "../chunk-
|
|
146
|
-
import "../chunk-
|
|
147
|
-
import "../chunk-
|
|
143
|
+
} from "../chunk-K2YGBXOA.js";
|
|
144
|
+
import "../chunk-EVDGNG4F.js";
|
|
145
|
+
import "../chunk-QGSTQH4D.js";
|
|
148
146
|
import {
|
|
149
147
|
getSgCommand,
|
|
150
148
|
resetDispatchAvailabilityState,
|
|
151
149
|
resolveManagedToolClient
|
|
152
|
-
} from "../chunk-
|
|
153
|
-
import "../chunk-
|
|
154
|
-
import "../chunk-
|
|
155
|
-
import "../chunk-
|
|
156
|
-
import "../chunk-
|
|
150
|
+
} from "../chunk-V3APN3DY.js";
|
|
151
|
+
import "../chunk-XAIT2YGS.js";
|
|
152
|
+
import "../chunk-4PCQCU47.js";
|
|
153
|
+
import "../chunk-HK6JVFZC.js";
|
|
154
|
+
import "../chunk-OOU2WZZE.js";
|
|
157
155
|
import {
|
|
158
156
|
SYMBOL_KIND_NAMES,
|
|
159
157
|
captureReviewGraphStructuralIr,
|
|
160
158
|
formatReviewGraphRevisionDriftNote,
|
|
161
159
|
publishReviewGraphFileIr,
|
|
162
160
|
reviewGraphIrContentHash
|
|
163
|
-
} from "../chunk-
|
|
161
|
+
} from "../chunk-TIYGSODX.js";
|
|
164
162
|
import {
|
|
165
163
|
buildSymbolId
|
|
166
164
|
} from "../chunk-3MED75HT.js";
|
|
@@ -168,6 +166,7 @@ import {
|
|
|
168
166
|
MAX_LATE_AUX_REARMS,
|
|
169
167
|
PAST_EOF_STALE_MARKER,
|
|
170
168
|
PRIMARY_UNAVAILABLE_CAUSE,
|
|
169
|
+
PartialApplyRecordStore,
|
|
171
170
|
ReadGuard,
|
|
172
171
|
STALE_LINE_MARKER,
|
|
173
172
|
Text,
|
|
@@ -183,15 +182,17 @@ import {
|
|
|
183
182
|
beginScope,
|
|
184
183
|
buildProbeScopeKey,
|
|
185
184
|
canRearmPendingAuxiliary,
|
|
185
|
+
captureRenameExpectedContent,
|
|
186
186
|
classifyDiagnosticTier,
|
|
187
187
|
clearAllSessions,
|
|
188
188
|
combinePrimaryUnavailableCauses,
|
|
189
189
|
configDisabledAuxiliaryLspServerIds,
|
|
190
190
|
countRetainedSuppressedRows,
|
|
191
|
-
createFileTime,
|
|
192
191
|
createLazyImport,
|
|
193
192
|
createLiveBusEmitter,
|
|
194
193
|
createWorkspaceDiagnosticsCacheContext,
|
|
194
|
+
demoteInferredProjectSweepResults,
|
|
195
|
+
demoteLanguageServerRows,
|
|
195
196
|
demotePastEofDiagnostics,
|
|
196
197
|
drainPendingAuxCapEvictedCount,
|
|
197
198
|
drainPendingAuxiliaryCoverage,
|
|
@@ -231,8 +232,8 @@ import {
|
|
|
231
232
|
recordLspMutationOutcome,
|
|
232
233
|
recordRunner,
|
|
233
234
|
recordStaleBusFailure,
|
|
234
|
-
refuseStaleWorkspaceEdit,
|
|
235
235
|
registerDeferredLspWork,
|
|
236
|
+
resetDeferredDispositions,
|
|
236
237
|
resetLSPService,
|
|
237
238
|
resetLspMutationNoBridgeDbgLatch,
|
|
238
239
|
resetObservedMutationNet,
|
|
@@ -253,9 +254,8 @@ import {
|
|
|
253
254
|
touchCoverageGap,
|
|
254
255
|
tryWarmAttachedDiagnostics,
|
|
255
256
|
widgetDiagnosticUri,
|
|
256
|
-
workspaceEditTextPaths,
|
|
257
257
|
writeOrderToken
|
|
258
|
-
} from "../chunk-
|
|
258
|
+
} from "../chunk-GZE7WOI4.js";
|
|
259
259
|
import {
|
|
260
260
|
ANY_POSITION,
|
|
261
261
|
foldedFindingIdentity,
|
|
@@ -265,7 +265,7 @@ import {
|
|
|
265
265
|
resetMutationAttribution,
|
|
266
266
|
retainRecordedFindings,
|
|
267
267
|
stableFindingId
|
|
268
|
-
} from "../chunk-
|
|
268
|
+
} from "../chunk-DC4CFXM5.js";
|
|
269
269
|
import {
|
|
270
270
|
mapWithConcurrency
|
|
271
271
|
} from "../chunk-XIMYZ3JA.js";
|
|
@@ -289,17 +289,19 @@ import {
|
|
|
289
289
|
resetLSPCaseSensitivityState,
|
|
290
290
|
resolveLspCwdForFile,
|
|
291
291
|
shouldInitializeSessionRoot
|
|
292
|
-
} from "../chunk-
|
|
293
|
-
import "../chunk-
|
|
292
|
+
} from "../chunk-3WEPUD2V.js";
|
|
293
|
+
import "../chunk-JL6CXUMW.js";
|
|
294
294
|
import {
|
|
295
|
+
PYTHON_DECLARATION_CONCURRENCY,
|
|
296
|
+
describePythonCompileWithheld,
|
|
297
|
+
detectPythonTargetVersion,
|
|
295
298
|
emitBounded,
|
|
296
299
|
hasAmbientPythonEnvironment,
|
|
300
|
+
isJediCompileVerdict,
|
|
301
|
+
partitionOutrankedPythonCompileVerdicts,
|
|
302
|
+
recordPythonCompileVerdictDrop,
|
|
297
303
|
resetBoundedTelemetry
|
|
298
|
-
} from "../chunk-
|
|
299
|
-
import {
|
|
300
|
-
resolveGitCheckout,
|
|
301
|
-
resolveLinkedWorktreeOwner
|
|
302
|
-
} from "../chunk-UA7ZXYDR.js";
|
|
304
|
+
} from "../chunk-NDMCVUYK.js";
|
|
303
305
|
import {
|
|
304
306
|
PROJECT_SNAPSHOT_VERSION,
|
|
305
307
|
getProjectSnapshotLegacyPath,
|
|
@@ -314,13 +316,13 @@ import {
|
|
|
314
316
|
readJsonCache,
|
|
315
317
|
readProjectSnapshotMeta,
|
|
316
318
|
saveRuntimeProjectSnapshot
|
|
317
|
-
} from "../chunk-
|
|
319
|
+
} from "../chunk-PPIBVH4R.js";
|
|
318
320
|
import {
|
|
319
321
|
SWEEP_IDLE_SAFETY_MARGIN_MS,
|
|
320
322
|
getFullScanWallClockMs,
|
|
321
323
|
isWorkspaceSweepActive,
|
|
322
324
|
runWhenWorkspaceSweepIdle
|
|
323
|
-
} from "../chunk-
|
|
325
|
+
} from "../chunk-F5Z6URKM.js";
|
|
324
326
|
import "../chunk-5W3R6LFT.js";
|
|
325
327
|
import {
|
|
326
328
|
DEPENDENCY_DRIFT_MAX_DELIVERIES,
|
|
@@ -330,9 +332,10 @@ import {
|
|
|
330
332
|
resolveImportToFiles,
|
|
331
333
|
sweepInlineBlockerFreshness,
|
|
332
334
|
symbolExtractionGrammar
|
|
333
|
-
} from "../chunk-
|
|
334
|
-
import "../chunk-
|
|
335
|
-
import "../chunk-
|
|
335
|
+
} from "../chunk-OJLTLYHB.js";
|
|
336
|
+
import "../chunk-63RIVFQI.js";
|
|
337
|
+
import "../chunk-PKES3ISE.js";
|
|
338
|
+
import "../chunk-ZKXQKGWZ.js";
|
|
336
339
|
import {
|
|
337
340
|
EXT_TO_LANG,
|
|
338
341
|
classifyTreeSitterWasmError,
|
|
@@ -345,38 +348,41 @@ import {
|
|
|
345
348
|
queryLoader,
|
|
346
349
|
reportBundledResourceDirHealth,
|
|
347
350
|
resolveTreeSitterLanguage
|
|
348
|
-
} from "../chunk-
|
|
351
|
+
} from "../chunk-GAACZY6R.js";
|
|
349
352
|
import "../chunk-Z54ZSOBZ.js";
|
|
353
|
+
import {
|
|
354
|
+
getUserRuleRoot
|
|
355
|
+
} from "../chunk-ZUUI3ZSA.js";
|
|
356
|
+
import {
|
|
357
|
+
dump,
|
|
358
|
+
resolvePackagePath
|
|
359
|
+
} from "../chunk-TIQJPRDD.js";
|
|
350
360
|
import {
|
|
351
361
|
SCAN_LANGUAGE_PRIORITY,
|
|
352
362
|
extensionsForLanguage,
|
|
353
363
|
extensionsForLanguageToken,
|
|
354
|
-
getUserRuleRoot,
|
|
355
364
|
resolveLanguage
|
|
356
|
-
} from "../chunk-
|
|
365
|
+
} from "../chunk-YISME6ON.js";
|
|
366
|
+
import "../chunk-6HWVI6MI.js";
|
|
367
|
+
import "../chunk-UHGF5UT5.js";
|
|
357
368
|
import {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
} from "../chunk-FM4RDMKT.js";
|
|
369
|
+
HOOK_WALL_BUDGET_MS
|
|
370
|
+
} from "../chunk-CKEQFGLT.js";
|
|
361
371
|
import {
|
|
362
|
-
HOOK_WALL_BUDGET_MS,
|
|
363
372
|
bounded,
|
|
364
373
|
combineAbortSignals,
|
|
365
374
|
withDeadline
|
|
366
|
-
} from "../chunk-
|
|
375
|
+
} from "../chunk-CJYKEW2L.js";
|
|
367
376
|
import {
|
|
368
377
|
centralityFromReverseDeps,
|
|
369
378
|
getWordIndexBuildStatus,
|
|
370
379
|
logWordIndex,
|
|
371
380
|
searchWordIndex,
|
|
372
381
|
triggerBackgroundWordIndexBuild
|
|
373
|
-
} from "../chunk-
|
|
382
|
+
} from "../chunk-VPBIMOAQ.js";
|
|
374
383
|
import {
|
|
375
384
|
getProjectDiagnosticsScannerMaxFiles
|
|
376
|
-
} from "../chunk-
|
|
377
|
-
import {
|
|
378
|
-
PathKeyedMap
|
|
379
|
-
} from "../chunk-Z3CCVDUB.js";
|
|
385
|
+
} from "../chunk-ZYNI26MI.js";
|
|
380
386
|
import {
|
|
381
387
|
WARM_TURN_END_SCHEMA_VERSION,
|
|
382
388
|
createWarmIpcLineReader,
|
|
@@ -384,34 +390,33 @@ import {
|
|
|
384
390
|
ipcPathForCwd,
|
|
385
391
|
readTurnEndStatus,
|
|
386
392
|
unlinkStaleUnixSocket
|
|
387
|
-
} from "../chunk-
|
|
393
|
+
} from "../chunk-BM5GS6ZH.js";
|
|
388
394
|
import {
|
|
389
|
-
freshnessFromMtime,
|
|
390
395
|
hashContentBytes,
|
|
391
396
|
resolveRunnerPath,
|
|
392
397
|
toRunnerDisplayPath
|
|
393
|
-
} from "../chunk-
|
|
398
|
+
} from "../chunk-NNKXDXXS.js";
|
|
394
399
|
import "../chunk-2BEMIWEW.js";
|
|
395
400
|
import "../chunk-IJYGIDF4.js";
|
|
396
401
|
import {
|
|
397
402
|
commitDurableStore,
|
|
398
403
|
resetResolvedPathCache,
|
|
399
404
|
resetZizmorTokenAvailability
|
|
400
|
-
} from "../chunk-
|
|
405
|
+
} from "../chunk-MKVZQUEG.js";
|
|
401
406
|
import {
|
|
402
407
|
resolveToolCwd
|
|
403
|
-
} from "../chunk-
|
|
408
|
+
} from "../chunk-MT6BVNFW.js";
|
|
404
409
|
import {
|
|
405
410
|
_resetPackageManagerCache,
|
|
406
411
|
findGlobalBinary,
|
|
407
412
|
pmBinary,
|
|
408
413
|
resolveNodePackageManager,
|
|
409
414
|
runScriptArgs
|
|
410
|
-
} from "../chunk-
|
|
415
|
+
} from "../chunk-Z7IGUAXL.js";
|
|
411
416
|
import {
|
|
412
417
|
getIsolatedNpxSpawnOptions,
|
|
413
418
|
probeToolAsync
|
|
414
|
-
} from "../chunk-
|
|
419
|
+
} from "../chunk-ARD426WI.js";
|
|
415
420
|
import {
|
|
416
421
|
classifyProbeFailure,
|
|
417
422
|
createAvailabilityLatch,
|
|
@@ -419,20 +424,20 @@ import {
|
|
|
419
424
|
logAvailabilityDecision,
|
|
420
425
|
resetInstallRetryLatches,
|
|
421
426
|
startHostStallSampler
|
|
422
|
-
} from "../chunk-
|
|
427
|
+
} from "../chunk-5APMQ2IJ.js";
|
|
423
428
|
import {
|
|
424
429
|
canRunStartupHeavyScans,
|
|
425
430
|
detectProjectLanguageProfile,
|
|
426
431
|
getDefaultStartupTools
|
|
427
|
-
} from "../chunk-
|
|
428
|
-
import "../chunk-
|
|
432
|
+
} from "../chunk-NIU2IPC5.js";
|
|
433
|
+
import "../chunk-BWYQUPOS.js";
|
|
429
434
|
import {
|
|
430
435
|
collectSourceFilesWithBudgetAsync,
|
|
431
436
|
getSlowFsVerdict,
|
|
432
437
|
isSlowFs,
|
|
433
438
|
slowFsDegradationNotice
|
|
434
|
-
} from "../chunk-
|
|
435
|
-
import "../chunk-
|
|
439
|
+
} from "../chunk-2RLWJO5K.js";
|
|
440
|
+
import "../chunk-VG5JS5SW.js";
|
|
436
441
|
import {
|
|
437
442
|
displayProjectDataPath,
|
|
438
443
|
drainProjectDataDirMigrations,
|
|
@@ -453,24 +458,27 @@ import {
|
|
|
453
458
|
resetProjectDataDirSessionState,
|
|
454
459
|
resetSafeSpawnWindowsCommandCache,
|
|
455
460
|
resetSpawnTimeoutCooldowns,
|
|
461
|
+
resolveGitCheckout,
|
|
462
|
+
resolveLinkedWorktreeOwner,
|
|
456
463
|
safeSpawnAsync,
|
|
457
464
|
subagentLightModeNotice,
|
|
458
465
|
sweepAtomicWriteStages,
|
|
459
466
|
sweepDeadEphemeralDataDirs,
|
|
460
467
|
updateHeartbeat,
|
|
461
468
|
withGenerationLockSync
|
|
462
|
-
} from "../chunk-
|
|
469
|
+
} from "../chunk-Q3UZHW6N.js";
|
|
463
470
|
import {
|
|
464
471
|
createSingleFlight
|
|
465
|
-
} from "../chunk-
|
|
472
|
+
} from "../chunk-AWQWXSW4.js";
|
|
466
473
|
import {
|
|
467
474
|
createDeadline,
|
|
468
475
|
yieldIfOverBudget
|
|
469
476
|
} from "../chunk-QYF5S6P6.js";
|
|
470
477
|
import {
|
|
471
478
|
detectFileKind
|
|
472
|
-
} from "../chunk-
|
|
479
|
+
} from "../chunk-RZOXUSPC.js";
|
|
473
480
|
import {
|
|
481
|
+
PathKeyedMap,
|
|
474
482
|
compareKeys,
|
|
475
483
|
detectFileRole,
|
|
476
484
|
loadPiLensProjectConfig,
|
|
@@ -479,24 +487,22 @@ import {
|
|
|
479
487
|
provenanceView,
|
|
480
488
|
resolvePiLensConfig,
|
|
481
489
|
summarizeConfigResolution
|
|
482
|
-
} from "../chunk-
|
|
490
|
+
} from "../chunk-OLAWH5UQ.js";
|
|
483
491
|
import {
|
|
484
492
|
LSP_NAMESPACE_KEY,
|
|
485
493
|
getPiLensGlobalConfigPath,
|
|
486
494
|
resetWorkspaceTopology
|
|
487
|
-
} from "../chunk-
|
|
495
|
+
} from "../chunk-J6JP25XU.js";
|
|
488
496
|
import {
|
|
497
|
+
DEFAULT_MAX_OUTPUT_BYTES,
|
|
498
|
+
createBoundedOutputSink,
|
|
489
499
|
getProjectTrustState,
|
|
490
500
|
isToolInstallAllowedByTrust,
|
|
491
501
|
projectTrustDenialReason,
|
|
492
|
-
setProjectTrustState
|
|
493
|
-
} from "../chunk-M2IFVFWU.js";
|
|
494
|
-
import {
|
|
495
|
-
DEFAULT_MAX_OUTPUT_BYTES,
|
|
496
|
-
createBoundedOutputSink,
|
|
502
|
+
setProjectTrustState,
|
|
497
503
|
truncatedByOutputCap,
|
|
498
504
|
writeFileAtomic
|
|
499
|
-
} from "../chunk-
|
|
505
|
+
} from "../chunk-MN7MHUXQ.js";
|
|
500
506
|
import {
|
|
501
507
|
LENS_TOOL_NAMES,
|
|
502
508
|
TOOL_REGISTRY,
|
|
@@ -510,18 +516,21 @@ import {
|
|
|
510
516
|
resetDegradationLedger,
|
|
511
517
|
resolveLensToolEnabled,
|
|
512
518
|
resolveLensToolName,
|
|
513
|
-
toolRegistryEntryForMcp
|
|
514
|
-
|
|
519
|
+
toolRegistryEntryForMcp,
|
|
520
|
+
translateGuidanceToolNames
|
|
521
|
+
} from "../chunk-ZQ6NZZTB.js";
|
|
515
522
|
import {
|
|
516
523
|
createSubsystemLogger,
|
|
517
524
|
flushExtensionLog,
|
|
518
525
|
logExtension
|
|
519
|
-
} from "../chunk-
|
|
520
|
-
import
|
|
526
|
+
} from "../chunk-KXF5R4UN.js";
|
|
527
|
+
import {
|
|
528
|
+
freshnessFromMtime
|
|
529
|
+
} from "../chunk-S26LC76R.js";
|
|
521
530
|
import {
|
|
522
531
|
claimPhaseOncePerSession,
|
|
523
532
|
logLatency
|
|
524
|
-
} from "../chunk-
|
|
533
|
+
} from "../chunk-Z2XAOKHK.js";
|
|
525
534
|
import {
|
|
526
535
|
beginTurnContext,
|
|
527
536
|
createNdjsonLogger,
|
|
@@ -530,16 +539,14 @@ import {
|
|
|
530
539
|
isTestMode,
|
|
531
540
|
runLogCleanup,
|
|
532
541
|
setTurnContextSession
|
|
533
|
-
} from "../chunk-
|
|
542
|
+
} from "../chunk-VSFLRN5Y.js";
|
|
534
543
|
import "../chunk-LJDODBBZ.js";
|
|
535
544
|
import {
|
|
536
545
|
FactStore
|
|
537
|
-
} from "../chunk-
|
|
546
|
+
} from "../chunk-OSTKYB55.js";
|
|
538
547
|
import {
|
|
539
548
|
BoundedFifoMap,
|
|
540
|
-
BoundedLruCache
|
|
541
|
-
} from "../chunk-ABBOA7UD.js";
|
|
542
|
-
import {
|
|
549
|
+
BoundedLruCache,
|
|
543
550
|
homeRelativePath,
|
|
544
551
|
isAtOrAboveHomeDir,
|
|
545
552
|
isUnderDir,
|
|
@@ -551,12 +558,13 @@ import {
|
|
|
551
558
|
realpathOrResolve,
|
|
552
559
|
resolveHostToolPath,
|
|
553
560
|
toProjectRelativePath,
|
|
554
|
-
uriToPath
|
|
555
|
-
|
|
561
|
+
uriToPath,
|
|
562
|
+
walkUpDirs
|
|
563
|
+
} from "../chunk-PQJFG24Z.js";
|
|
556
564
|
import "../chunk-NXL4FFQQ.js";
|
|
557
565
|
|
|
558
566
|
// dist/mcp/server.js
|
|
559
|
-
import * as
|
|
567
|
+
import * as fs24 from "node:fs";
|
|
560
568
|
import * as net from "node:net";
|
|
561
569
|
import * as path40 from "node:path";
|
|
562
570
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -1270,13 +1278,8 @@ var SgRunner = class {
|
|
|
1270
1278
|
if (platform === "win32" && arch === "arm64")
|
|
1271
1279
|
pkgSuffixes.push("win32-arm64-msvc");
|
|
1272
1280
|
const searchRoots = [];
|
|
1273
|
-
|
|
1274
|
-
for (let depth = 0; depth < 5; depth++) {
|
|
1281
|
+
for (const dir of walkUpDirs(process.cwd(), { maxDepth: 5 })) {
|
|
1275
1282
|
searchRoots.push(path3.join(dir, "node_modules"));
|
|
1276
|
-
const parent = path3.dirname(dir);
|
|
1277
|
-
if (parent === dir)
|
|
1278
|
-
break;
|
|
1279
|
-
dir = parent;
|
|
1280
1283
|
}
|
|
1281
1284
|
for (const suffix of pkgSuffixes) {
|
|
1282
1285
|
const pkgName = `@ast-grep/cli-${suffix}`;
|
|
@@ -2917,7 +2920,7 @@ function summarizeScan(diagnostics) {
|
|
|
2917
2920
|
|
|
2918
2921
|
// dist/clients/mcp/session.js
|
|
2919
2922
|
import * as crypto from "node:crypto";
|
|
2920
|
-
import * as
|
|
2923
|
+
import * as fs17 from "node:fs";
|
|
2921
2924
|
import * as path25 from "node:path";
|
|
2922
2925
|
|
|
2923
2926
|
// dist/clients/bootstrap.js
|
|
@@ -2975,29 +2978,29 @@ async function buildBootstrapClients() {
|
|
|
2975
2978
|
}
|
|
2976
2979
|
}
|
|
2977
2980
|
const [ruffClient, biomeClient, knipClient, todoScanner, jscpdClient, depChecker, testRunnerClient, metricsClient, complexityClient, goClient, govulncheckClient, gitleaksClient, trivyClient, opengrepClient, rustClient, agentBehaviorClient2, deadCodeClients] = await Promise.all([
|
|
2978
|
-
load("ruff", async () => new (await import("../chunk-
|
|
2979
|
-
load("biome", async () => new (await import("../chunk-
|
|
2980
|
-
load("knip", async () => new (await import("../chunk-
|
|
2981
|
-
load("todo", async () => new (await import("../chunk-
|
|
2982
|
-
load("jscpd", async () => new (await import("../chunk-
|
|
2983
|
-
load("dependency-checker", async () => new (await import("../chunk-
|
|
2984
|
-
load("test-runner", async () => new (await import("../chunk-
|
|
2985
|
-
load("metrics", async () => new (await import("../chunk-
|
|
2986
|
-
load("complexity", async () => new (await import("../chunk-
|
|
2981
|
+
load("ruff", async () => new (await import("../chunk-YBSONGSZ.js")).RuffClient()),
|
|
2982
|
+
load("biome", async () => new (await import("../chunk-Q4EMRFNA.js")).BiomeClient()),
|
|
2983
|
+
load("knip", async () => new (await import("../chunk-5ZR3APIM.js")).KnipClient()),
|
|
2984
|
+
load("todo", async () => new (await import("../chunk-W5LGKNET.js")).TodoScanner()),
|
|
2985
|
+
load("jscpd", async () => new (await import("../chunk-WIZWZR4C.js")).JscpdClient()),
|
|
2986
|
+
load("dependency-checker", async () => new (await import("../chunk-4WX4CTUE.js")).DependencyChecker()),
|
|
2987
|
+
load("test-runner", async () => new (await import("../chunk-CFRQMBGP.js")).TestRunnerClient()),
|
|
2988
|
+
load("metrics", async () => new (await import("../chunk-GNSIWBAT.js")).MetricsClient()),
|
|
2989
|
+
load("complexity", async () => new (await import("../chunk-UCGQT677.js")).ComplexityClient()),
|
|
2987
2990
|
// The process-wide singleton, NOT a fresh instance (#2455 fix round 4,
|
|
2988
2991
|
// F2). `handleSessionStart` reads this object for its "Active tools"
|
|
2989
2992
|
// line while `resetGoAvailability` re-arms the singleton's latch; a
|
|
2990
2993
|
// second instance here meant the reset never reached the surface a
|
|
2991
2994
|
// user actually sees.
|
|
2992
|
-
load("go", async () => (await import("../chunk-
|
|
2993
|
-
load("govulncheck", async () => new (await import("../chunk-
|
|
2994
|
-
load("gitleaks", async () => new (await import("../chunk-
|
|
2995
|
-
load("trivy", async () => new (await import("../chunk-
|
|
2996
|
-
load("opengrep", async () => new (await import("../chunk-
|
|
2995
|
+
load("go", async () => (await import("../chunk-GTAI2J6U.js")).goClient),
|
|
2996
|
+
load("govulncheck", async () => new (await import("../chunk-IPDG45G5.js")).GovulncheckClient()),
|
|
2997
|
+
load("gitleaks", async () => new (await import("../chunk-VQH24FIP.js")).GitleaksClient()),
|
|
2998
|
+
load("trivy", async () => new (await import("../chunk-UN4TEBWN.js")).TrivyClient()),
|
|
2999
|
+
load("opengrep", async () => new (await import("../chunk-Q4FCYCRE.js")).OpengrepClient()),
|
|
2997
3000
|
// The process-wide singleton, for the same reason as "go" above.
|
|
2998
|
-
load("rust", async () => (await import("../chunk-
|
|
2999
|
-
load("agent-behavior", async () => (await import("../chunk-
|
|
3000
|
-
loadList("dead-code", async () => (await import("../chunk-
|
|
3001
|
+
load("rust", async () => (await import("../chunk-P4QNXS6I.js")).rustClient),
|
|
3002
|
+
load("agent-behavior", async () => (await import("../chunk-Q6D6VMI4.js")).agentBehaviorClient),
|
|
3003
|
+
loadList("dead-code", async () => (await import("../chunk-SCIUNBPF.js")).getDeadCodeClients())
|
|
3001
3004
|
]);
|
|
3002
3005
|
if (failures.length > 0)
|
|
3003
3006
|
await logBootstrapFailures(failures);
|
|
@@ -3084,7 +3087,7 @@ function resetAnalyzerBootstrapSessionState() {
|
|
|
3084
3087
|
}
|
|
3085
3088
|
|
|
3086
3089
|
// dist/clients/formatters-lazy.js
|
|
3087
|
-
var lazyFormatters = createLazyImport(() => import("../chunk-
|
|
3090
|
+
var lazyFormatters = createLazyImport(() => import("../chunk-DMSLNKF7.js"));
|
|
3088
3091
|
function warmFormatters() {
|
|
3089
3092
|
return lazyFormatters.get();
|
|
3090
3093
|
}
|
|
@@ -3103,7 +3106,7 @@ function resetFormatService() {
|
|
|
3103
3106
|
|
|
3104
3107
|
// dist/clients/runtime-coordinator.js
|
|
3105
3108
|
import { randomBytes } from "node:crypto";
|
|
3106
|
-
import * as
|
|
3109
|
+
import * as fs8 from "node:fs";
|
|
3107
3110
|
import * as path8 from "node:path";
|
|
3108
3111
|
|
|
3109
3112
|
// dist/clients/project-changes.js
|
|
@@ -3277,73 +3280,6 @@ function inlineBlockerLines(blockers, filePath) {
|
|
|
3277
3280
|
).map((d) => d.line).filter((line) => typeof line === "number");
|
|
3278
3281
|
}
|
|
3279
3282
|
|
|
3280
|
-
// dist/clients/partial-edit-apply.js
|
|
3281
|
-
import { createHash } from "node:crypto";
|
|
3282
|
-
import * as fs8 from "node:fs";
|
|
3283
|
-
var MAX_APPLIED_RECORDS_PER_FILE = 8;
|
|
3284
|
-
var MAX_APPLIED_RECORD_FILES = 64;
|
|
3285
|
-
function editPairDigest(oldText, newText) {
|
|
3286
|
-
return createHash("sha256").update(JSON.stringify([oldText, newText ?? ""]), "utf8").digest("hex");
|
|
3287
|
-
}
|
|
3288
|
-
var PartialApplyRecordStore = class {
|
|
3289
|
-
// Bounded on the PathKeyedMap itself (#2442): the file axis used to
|
|
3290
|
-
// hand-roll `keys().next().value` here, which also evicted an unrelated
|
|
3291
|
-
// file when a path ALREADY in the map was re-recorded at capacity.
|
|
3292
|
-
files = new PathKeyedMap(normalizeMapKey, MAX_APPLIED_RECORD_FILES);
|
|
3293
|
-
find(filePath, oldText, newText) {
|
|
3294
|
-
if (!oldText)
|
|
3295
|
-
return void 0;
|
|
3296
|
-
const pairDigest = editPairDigest(oldText, newText);
|
|
3297
|
-
const records = this.files.get(filePath) ?? [];
|
|
3298
|
-
return records.find((r) => r.pairDigest === pairDigest);
|
|
3299
|
-
}
|
|
3300
|
-
record(filePath, oldText, newText, contentHash) {
|
|
3301
|
-
if (!oldText)
|
|
3302
|
-
return;
|
|
3303
|
-
const pairDigest = editPairDigest(oldText, newText);
|
|
3304
|
-
const records = this.files.get(filePath) ?? [];
|
|
3305
|
-
const existing = records.findIndex((r) => r.pairDigest === pairDigest);
|
|
3306
|
-
if (existing >= 0)
|
|
3307
|
-
records.splice(existing, 1);
|
|
3308
|
-
const entry = {
|
|
3309
|
-
pairDigest,
|
|
3310
|
-
contentHash: contentHash ?? hashFile(filePath),
|
|
3311
|
-
appliedAtMs: Date.now()
|
|
3312
|
-
};
|
|
3313
|
-
if (records.length >= MAX_APPLIED_RECORDS_PER_FILE)
|
|
3314
|
-
records.shift();
|
|
3315
|
-
records.push(entry);
|
|
3316
|
-
this.files.set(filePath, records);
|
|
3317
|
-
}
|
|
3318
|
-
/**
|
|
3319
|
-
* Stamps the post-afterWrite file hash onto an existing record so a later
|
|
3320
|
-
* identical retry against the formatter-rewritten file is still recognized as
|
|
3321
|
-
* already-applied (#2402). No-op when the pair was never recorded.
|
|
3322
|
-
*/
|
|
3323
|
-
noteAfterWriteHash(filePath, oldText, newText, afterWriteContentHash) {
|
|
3324
|
-
if (!oldText)
|
|
3325
|
-
return;
|
|
3326
|
-
const pairDigest = editPairDigest(oldText, newText);
|
|
3327
|
-
const record = this.files.get(filePath)?.find((r) => r.pairDigest === pairDigest);
|
|
3328
|
-
if (record)
|
|
3329
|
-
record.afterWriteContentHash = afterWriteContentHash;
|
|
3330
|
-
}
|
|
3331
|
-
clear() {
|
|
3332
|
-
this.files.clear();
|
|
3333
|
-
}
|
|
3334
|
-
get fileCount() {
|
|
3335
|
-
return this.files.size;
|
|
3336
|
-
}
|
|
3337
|
-
};
|
|
3338
|
-
var fileLock = createFileTime("partial-edit-apply");
|
|
3339
|
-
function hashFile(filePath) {
|
|
3340
|
-
try {
|
|
3341
|
-
return createHash("sha256").update(fs8.readFileSync(filePath)).digest("hex");
|
|
3342
|
-
} catch {
|
|
3343
|
-
return void 0;
|
|
3344
|
-
}
|
|
3345
|
-
}
|
|
3346
|
-
|
|
3347
3283
|
// dist/clients/turn-summary.js
|
|
3348
3284
|
var TurnSummaryCollector = class {
|
|
3349
3285
|
filesByKey = /* @__PURE__ */ new Map();
|
|
@@ -3584,6 +3520,14 @@ var RuntimeCoordinator = class {
|
|
|
3584
3520
|
_gitGuardHasBlockers = false;
|
|
3585
3521
|
_gitGuardSummary = "";
|
|
3586
3522
|
_gitGuardCacheUnknownReason;
|
|
3523
|
+
/**
|
|
3524
|
+
* #4733 r2 F12: per file, a dispatch that never answered
|
|
3525
|
+
* (`pipeline_crash`, `pipeline_error`). It is about that file, not the
|
|
3526
|
+
* persisted record, so it lives apart from the record's latch above: only
|
|
3527
|
+
* that file's own dispatch returning removes it, and no record write or
|
|
3528
|
+
* delete does. Cleared per session.
|
|
3529
|
+
*/
|
|
3530
|
+
_gitGuardUnansweredDispatches = new PathKeyedMap(normalizeMapKey);
|
|
3587
3531
|
callGraph = null;
|
|
3588
3532
|
wordIndex = null;
|
|
3589
3533
|
_readGuard = null;
|
|
@@ -3701,6 +3645,7 @@ var RuntimeCoordinator = class {
|
|
|
3701
3645
|
this._gitGuardHasBlockers = false;
|
|
3702
3646
|
this._gitGuardSummary = "";
|
|
3703
3647
|
this._gitGuardCacheUnknownReason = void 0;
|
|
3648
|
+
this._gitGuardUnansweredDispatches.clear();
|
|
3704
3649
|
this._readGuard = null;
|
|
3705
3650
|
this._pendingDeferredMutations.clear();
|
|
3706
3651
|
this._toolCallAttributions.clear();
|
|
@@ -3779,6 +3724,21 @@ var RuntimeCoordinator = class {
|
|
|
3779
3724
|
get gitGuardCacheUnknownReason() {
|
|
3780
3725
|
return this._gitGuardCacheUnknownReason;
|
|
3781
3726
|
}
|
|
3727
|
+
markGitGuardDispatchUnanswered(filePath, reason) {
|
|
3728
|
+
this._gitGuardUnansweredDispatches.set(filePath, reason);
|
|
3729
|
+
}
|
|
3730
|
+
/** The file's dispatch returned: it answers its own latch, and only that. */
|
|
3731
|
+
answerGitGuardDispatch(filePath) {
|
|
3732
|
+
this._gitGuardUnansweredDispatches.delete(filePath);
|
|
3733
|
+
}
|
|
3734
|
+
/** Every file whose dispatch has not answered, with its reason, in order. */
|
|
3735
|
+
get gitGuardUnansweredDispatches() {
|
|
3736
|
+
return [...this._gitGuardUnansweredDispatches].map(([filePath, reason]) => ({ filePath, reason }));
|
|
3737
|
+
}
|
|
3738
|
+
/** Whether this session holds an inline-blocker entry for the file. */
|
|
3739
|
+
hasInlineBlocker(filePath) {
|
|
3740
|
+
return this._pendingInlineBlockers.has(filePath);
|
|
3741
|
+
}
|
|
3782
3742
|
/**
|
|
3783
3743
|
* Start a turn. `sessionId` is the turn's own session (its ctx's stable id);
|
|
3784
3744
|
* omitted, or equal to this coordinator's session, the turn is the
|
|
@@ -4360,7 +4320,7 @@ var RuntimeCoordinator = class {
|
|
|
4360
4320
|
if (!this._inlineBlockerWriteOrder.shouldWrite(normalizeMapKey(filePath), writeOrder))
|
|
4361
4321
|
return void 0;
|
|
4362
4322
|
this._resolvedBlockerFilesThisTurn.delete(filePath);
|
|
4363
|
-
this._pendingInlineBlockers.set(
|
|
4323
|
+
this._pendingInlineBlockers.set(filePath, {
|
|
4364
4324
|
filePath,
|
|
4365
4325
|
summary,
|
|
4366
4326
|
writeIndex,
|
|
@@ -4399,7 +4359,7 @@ var RuntimeCoordinator = class {
|
|
|
4399
4359
|
* @returns how many findings were new to the record (0 = a replay).
|
|
4400
4360
|
*/
|
|
4401
4361
|
recordDeferredInlineBlockers(filePath, blocking, analysed) {
|
|
4402
|
-
const key =
|
|
4362
|
+
const key = filePath;
|
|
4403
4363
|
const existing = this._pendingInlineBlockers.get(key);
|
|
4404
4364
|
if (existing && !existing.diagnostics)
|
|
4405
4365
|
return 0;
|
|
@@ -4446,7 +4406,7 @@ var RuntimeCoordinator = class {
|
|
|
4446
4406
|
* the record holds text only.
|
|
4447
4407
|
*/
|
|
4448
4408
|
getInlineBlockerDiagnostics(filePath) {
|
|
4449
|
-
return this._pendingInlineBlockers.get(
|
|
4409
|
+
return this._pendingInlineBlockers.get(filePath)?.diagnostics;
|
|
4450
4410
|
}
|
|
4451
4411
|
/**
|
|
4452
4412
|
* #4484 round 3: the anchor the next write's pipeline aligns to: the line
|
|
@@ -4470,7 +4430,7 @@ var RuntimeCoordinator = class {
|
|
|
4470
4430
|
setAnalysisAnchor(filePath, anchor) {
|
|
4471
4431
|
const existing = this._pendingInlineBlockers.get(filePath);
|
|
4472
4432
|
if (existing) {
|
|
4473
|
-
const key =
|
|
4433
|
+
const key = filePath;
|
|
4474
4434
|
const { analysisAnchor: _dropped, ...rest } = existing;
|
|
4475
4435
|
this._pendingInlineBlockers.set(key, anchor ? { ...rest, analysisAnchor: anchor } : rest);
|
|
4476
4436
|
}
|
|
@@ -4499,7 +4459,7 @@ var RuntimeCoordinator = class {
|
|
|
4499
4459
|
* @returns how many recorded blockers the run retired.
|
|
4500
4460
|
*/
|
|
4501
4461
|
retireUnobservedRunnerBlockers(filePath, run) {
|
|
4502
|
-
const key =
|
|
4462
|
+
const key = filePath;
|
|
4503
4463
|
const existing = this._pendingInlineBlockers.get(key);
|
|
4504
4464
|
if (!existing?.diagnostics || run.sha256 === void 0 || existing.recordedHash !== run.sha256 || existing.recordedAtMs === void 0 || run.markedAtMs < existing.recordedAtMs)
|
|
4505
4465
|
return 0;
|
|
@@ -4568,7 +4528,7 @@ var RuntimeCoordinator = class {
|
|
|
4568
4528
|
* is refused and counted the same way.
|
|
4569
4529
|
*/
|
|
4570
4530
|
clearInlineBlockers(filePath, writeIndex, orderTurn = this._writeOrderTurn, analysis) {
|
|
4571
|
-
const existing = this._pendingInlineBlockers.get(
|
|
4531
|
+
const existing = this._pendingInlineBlockers.get(filePath);
|
|
4572
4532
|
if (existing && (analysis?.blocking ?? 0) > 0) {
|
|
4573
4533
|
incrementDegradationCount({
|
|
4574
4534
|
kind: "blocker-clear-refused",
|
|
@@ -4590,7 +4550,7 @@ var RuntimeCoordinator = class {
|
|
|
4590
4550
|
if (existing) {
|
|
4591
4551
|
this.noteResolvedBlockerFile(existing, writeOrderToken(orderTurn, writeIndex), false);
|
|
4592
4552
|
}
|
|
4593
|
-
this._pendingInlineBlockers.delete(
|
|
4553
|
+
this._pendingInlineBlockers.delete(filePath);
|
|
4594
4554
|
return true;
|
|
4595
4555
|
}
|
|
4596
4556
|
/**
|
|
@@ -4604,7 +4564,7 @@ var RuntimeCoordinator = class {
|
|
|
4604
4564
|
* entry to stale, so a caller can log the demotion exactly once.
|
|
4605
4565
|
*/
|
|
4606
4566
|
markInlineBlockerStale(filePath, reason = "dependency-drift") {
|
|
4607
|
-
const key =
|
|
4567
|
+
const key = filePath;
|
|
4608
4568
|
const existing = this._pendingInlineBlockers.get(key);
|
|
4609
4569
|
if (!existing || existing.stale)
|
|
4610
4570
|
return false;
|
|
@@ -4627,7 +4587,7 @@ var RuntimeCoordinator = class {
|
|
|
4627
4587
|
* transition, so the caller logs/resyncs exactly once per edge.
|
|
4628
4588
|
*/
|
|
4629
4589
|
setInlineBlockerPastEofStale(filePath, isPastEof) {
|
|
4630
|
-
const key =
|
|
4590
|
+
const key = filePath;
|
|
4631
4591
|
const existing = this._pendingInlineBlockers.get(key);
|
|
4632
4592
|
if (!existing)
|
|
4633
4593
|
return false;
|
|
@@ -4662,7 +4622,7 @@ var RuntimeCoordinator = class {
|
|
|
4662
4622
|
* the caller counts exactly one edge.
|
|
4663
4623
|
*/
|
|
4664
4624
|
setInlineBlockerSelfDriftStale(filePath, isSelfDrift) {
|
|
4665
|
-
const key =
|
|
4625
|
+
const key = filePath;
|
|
4666
4626
|
const existing = this._pendingInlineBlockers.get(key);
|
|
4667
4627
|
if (!existing)
|
|
4668
4628
|
return false;
|
|
@@ -4726,7 +4686,7 @@ var RuntimeCoordinator = class {
|
|
|
4726
4686
|
pastEofRetireKey(filePath, deadLines) {
|
|
4727
4687
|
if (deadLines.length === 0)
|
|
4728
4688
|
return void 0;
|
|
4729
|
-
const key =
|
|
4689
|
+
const key = filePath;
|
|
4730
4690
|
const existing = this._pendingInlineBlockers.get(key);
|
|
4731
4691
|
if (!existing)
|
|
4732
4692
|
return void 0;
|
|
@@ -4746,7 +4706,7 @@ var RuntimeCoordinator = class {
|
|
|
4746
4706
|
* content is NOT being suppressed.
|
|
4747
4707
|
*/
|
|
4748
4708
|
peekInlineBlockerStaleDeliveryCount(filePath) {
|
|
4749
|
-
const key =
|
|
4709
|
+
const key = filePath;
|
|
4750
4710
|
return this._pendingInlineBlockers.get(key)?.staleDeliveryCount ?? 0;
|
|
4751
4711
|
}
|
|
4752
4712
|
/**
|
|
@@ -4762,7 +4722,7 @@ var RuntimeCoordinator = class {
|
|
|
4762
4722
|
* or never recorded).
|
|
4763
4723
|
*/
|
|
4764
4724
|
incrementInlineBlockerStaleDelivery(filePath) {
|
|
4765
|
-
const key =
|
|
4725
|
+
const key = filePath;
|
|
4766
4726
|
const existing = this._pendingInlineBlockers.get(key);
|
|
4767
4727
|
if (!existing)
|
|
4768
4728
|
return 0;
|
|
@@ -4791,7 +4751,7 @@ var RuntimeCoordinator = class {
|
|
|
4791
4751
|
* suppression is never silent (#1432 Gap 1).
|
|
4792
4752
|
*/
|
|
4793
4753
|
retireDemotedDependencyDriftBlocker(filePath) {
|
|
4794
|
-
const key =
|
|
4754
|
+
const key = filePath;
|
|
4795
4755
|
const existing = this._pendingInlineBlockers.get(key);
|
|
4796
4756
|
if (!existing)
|
|
4797
4757
|
return false;
|
|
@@ -4844,7 +4804,7 @@ var RuntimeCoordinator = class {
|
|
|
4844
4804
|
* eviction is never silent (#1432 Gap 1).
|
|
4845
4805
|
*/
|
|
4846
4806
|
retireInlineBlockerOnConfirmedClean(filePath, confirmedAtWriteOrder, coveredSources) {
|
|
4847
|
-
const key =
|
|
4807
|
+
const key = filePath;
|
|
4848
4808
|
const existing = this._pendingInlineBlockers.get(key);
|
|
4849
4809
|
if (!existing)
|
|
4850
4810
|
return false;
|
|
@@ -4897,7 +4857,7 @@ var RuntimeCoordinator = class {
|
|
|
4897
4857
|
reconcileInlineBlockers() {
|
|
4898
4858
|
const survivors = [];
|
|
4899
4859
|
for (const [displayPath, value] of this._pendingInlineBlockers.entries()) {
|
|
4900
|
-
if (
|
|
4860
|
+
if (fs8.existsSync(displayPath))
|
|
4901
4861
|
survivors.push([displayPath, value]);
|
|
4902
4862
|
}
|
|
4903
4863
|
if (survivors.length !== this._pendingInlineBlockers.size) {
|
|
@@ -5086,7 +5046,7 @@ var RuntimeCoordinator = class {
|
|
|
5086
5046
|
deferMutation(filePath, cwd, toolName, turnStateCwd, kind, ownerSessionId, originCwd, readGuardBranchEpoch = this.readGuard.currentBranchEpoch, analysisRootMode = "session") {
|
|
5087
5047
|
if (!canWriteAnalysisRoot(analysisRootMode))
|
|
5088
5048
|
return false;
|
|
5089
|
-
const key =
|
|
5049
|
+
const key = realpathOrResolve(filePath);
|
|
5090
5050
|
const now = Date.now();
|
|
5091
5051
|
const resolvedOriginCwd = originCwd ?? turnStateCwd;
|
|
5092
5052
|
const existing = this._pendingDeferredMutations.get(key);
|
|
@@ -5125,7 +5085,7 @@ var RuntimeCoordinator = class {
|
|
|
5125
5085
|
}
|
|
5126
5086
|
/** Return the ownership identity of a queued format record for bus events. */
|
|
5127
5087
|
deferredFormatIdentity(filePath) {
|
|
5128
|
-
const record = this._pendingDeferredMutations.get(
|
|
5088
|
+
const record = this._pendingDeferredMutations.get(filePath);
|
|
5129
5089
|
if (!record || !record.kinds.has("format"))
|
|
5130
5090
|
return void 0;
|
|
5131
5091
|
return {
|
|
@@ -5210,7 +5170,7 @@ var RuntimeCoordinator = class {
|
|
|
5210
5170
|
/** Return claimed records that were never started by an aborted drain. */
|
|
5211
5171
|
requeueDeferredFormatFiles(records) {
|
|
5212
5172
|
for (const record of records) {
|
|
5213
|
-
const key =
|
|
5173
|
+
const key = record.filePath;
|
|
5214
5174
|
const existing = this._pendingDeferredMutations.get(key);
|
|
5215
5175
|
if (existing) {
|
|
5216
5176
|
for (const kind of record.kinds)
|
|
@@ -5295,7 +5255,7 @@ function isPrintMode(argv = process.argv) {
|
|
|
5295
5255
|
}
|
|
5296
5256
|
|
|
5297
5257
|
// dist/clients/rules-scanner.js
|
|
5298
|
-
import * as
|
|
5258
|
+
import * as fs9 from "node:fs";
|
|
5299
5259
|
import * as path10 from "node:path";
|
|
5300
5260
|
var RULE_DIRS = [
|
|
5301
5261
|
{ dir: ".claude/rules", source: ".claude/rules" },
|
|
@@ -5312,9 +5272,9 @@ function findMarkdownFiles(dir, baseDir, depth = 0, collected = { count: 0 }) {
|
|
|
5312
5272
|
const results = [];
|
|
5313
5273
|
if (depth > RULES_SCAN_MAX_DEPTH)
|
|
5314
5274
|
return results;
|
|
5315
|
-
if (!
|
|
5275
|
+
if (!fs9.existsSync(dir))
|
|
5316
5276
|
return results;
|
|
5317
|
-
const entries =
|
|
5277
|
+
const entries = fs9.readdirSync(dir, { withFileTypes: true });
|
|
5318
5278
|
for (const entry of entries) {
|
|
5319
5279
|
if (collected.count >= RULES_SCAN_MAX_FILES)
|
|
5320
5280
|
break;
|
|
@@ -5337,7 +5297,7 @@ function scanProjectRules(cwd) {
|
|
|
5337
5297
|
const rules = [];
|
|
5338
5298
|
for (const { dir, source } of RULE_DIRS) {
|
|
5339
5299
|
const dirPath = path10.join(cwd, dir);
|
|
5340
|
-
if (
|
|
5300
|
+
if (fs9.existsSync(dirPath)) {
|
|
5341
5301
|
const found = findMarkdownFiles(dirPath, path10.join(cwd, dir));
|
|
5342
5302
|
for (const rule of found) {
|
|
5343
5303
|
rules.push({
|
|
@@ -5351,7 +5311,7 @@ function scanProjectRules(cwd) {
|
|
|
5351
5311
|
}
|
|
5352
5312
|
for (const { file, source } of RULE_FILES) {
|
|
5353
5313
|
const filePath = path10.join(cwd, file);
|
|
5354
|
-
if (
|
|
5314
|
+
if (fs9.existsSync(filePath)) {
|
|
5355
5315
|
rules.push({
|
|
5356
5316
|
source,
|
|
5357
5317
|
name: file,
|
|
@@ -5367,7 +5327,7 @@ function scanProjectRules(cwd) {
|
|
|
5367
5327
|
}
|
|
5368
5328
|
|
|
5369
5329
|
// dist/clients/smells-rollup.js
|
|
5370
|
-
import * as
|
|
5330
|
+
import * as fs10 from "node:fs";
|
|
5371
5331
|
import * as path11 from "node:path";
|
|
5372
5332
|
var SMELLS_TAIL_BYTES_PER_FILE = 64 * 1024;
|
|
5373
5333
|
var SMELLS_ROLLING_WINDOW_MS = 24 * 60 * 6e4;
|
|
@@ -5383,18 +5343,18 @@ var SMELL_KEYS = ["staleCtxEmitFailed", "opengrepRespawn"];
|
|
|
5383
5343
|
function tailReadText(filePath, maxBytes) {
|
|
5384
5344
|
let fd;
|
|
5385
5345
|
try {
|
|
5386
|
-
fd =
|
|
5346
|
+
fd = fs10.openSync(filePath, "r");
|
|
5387
5347
|
} catch {
|
|
5388
5348
|
return "";
|
|
5389
5349
|
}
|
|
5390
5350
|
try {
|
|
5391
|
-
const size =
|
|
5351
|
+
const size = fs10.fstatSync(fd).size;
|
|
5392
5352
|
const readBytes2 = Math.min(size, maxBytes);
|
|
5393
5353
|
if (readBytes2 <= 0)
|
|
5394
5354
|
return "";
|
|
5395
5355
|
const start = size - readBytes2;
|
|
5396
5356
|
const buf = Buffer.alloc(readBytes2);
|
|
5397
|
-
|
|
5357
|
+
fs10.readSync(fd, buf, 0, readBytes2, start);
|
|
5398
5358
|
const text = buf.toString("utf8");
|
|
5399
5359
|
if (start <= 0)
|
|
5400
5360
|
return text;
|
|
@@ -5404,7 +5364,7 @@ function tailReadText(filePath, maxBytes) {
|
|
|
5404
5364
|
return "";
|
|
5405
5365
|
} finally {
|
|
5406
5366
|
try {
|
|
5407
|
-
|
|
5367
|
+
fs10.closeSync(fd);
|
|
5408
5368
|
} catch {
|
|
5409
5369
|
}
|
|
5410
5370
|
}
|
|
@@ -5577,6 +5537,11 @@ function resetTestRunnerDelivery() {
|
|
|
5577
5537
|
pending.clear();
|
|
5578
5538
|
}
|
|
5579
5539
|
|
|
5540
|
+
// dist/clients/session-event-guard.js
|
|
5541
|
+
function isStaleExtensionCtxError(err) {
|
|
5542
|
+
return err instanceof Error && err.message.includes("stale after session replacement or reload");
|
|
5543
|
+
}
|
|
5544
|
+
|
|
5580
5545
|
// dist/clients/runtime-session.js
|
|
5581
5546
|
function notifyStartupWarmSkip(args) {
|
|
5582
5547
|
if (!args.runtime.isCurrentSession(args.sessionGeneration))
|
|
@@ -5831,8 +5796,8 @@ async function igniteDominantLanguageWarm(cwd, runtime, sessionGeneration, dbg)
|
|
|
5831
5796
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
5832
5797
|
return;
|
|
5833
5798
|
const lspService = (await loadLspService()).getLSPService();
|
|
5834
|
-
const { collectSourceFilesAsync } = await import("../chunk-
|
|
5835
|
-
const { CODE_KINDS, detectFileKind: detectFileKind2 } = await import("../chunk-
|
|
5799
|
+
const { collectSourceFilesAsync } = await import("../chunk-W5R5SABV.js");
|
|
5800
|
+
const { CODE_KINDS, detectFileKind: detectFileKind2 } = await import("../chunk-U2SDMG7C.js");
|
|
5836
5801
|
const files = await collectSourceFilesAsync(cwd, {
|
|
5837
5802
|
inspectGeneratedHeaders: false
|
|
5838
5803
|
});
|
|
@@ -5893,13 +5858,23 @@ function firePreinstallDefaults(ensureTool, dbg, startupDefaults) {
|
|
|
5893
5858
|
}
|
|
5894
5859
|
}
|
|
5895
5860
|
var MANAGED_TOOL_REFRESH_DELAY_MS = 3e4;
|
|
5896
|
-
|
|
5861
|
+
var managedToolRefreshTimer;
|
|
5862
|
+
function cancelScheduledManagedToolRefresh() {
|
|
5863
|
+
if (managedToolRefreshTimer === void 0)
|
|
5864
|
+
return;
|
|
5865
|
+
clearTimeout(managedToolRefreshTimer);
|
|
5866
|
+
managedToolRefreshTimer = void 0;
|
|
5867
|
+
}
|
|
5868
|
+
function scheduleManagedToolRefresh(dbg, rulePack) {
|
|
5897
5869
|
const delayMs = Number(process.env.PI_LENS_TOOL_REFRESH_DELAY_MS ?? MANAGED_TOOL_REFRESH_DELAY_MS);
|
|
5898
5870
|
const timer = setTimeout(() => {
|
|
5871
|
+
managedToolRefreshTimer = void 0;
|
|
5899
5872
|
void (async () => {
|
|
5900
5873
|
try {
|
|
5901
|
-
const refresh = await import("../chunk-
|
|
5902
|
-
const outcome = await refresh.runManagedToolRefresh(
|
|
5874
|
+
const refresh = await import("../chunk-U6OC3QEM.js");
|
|
5875
|
+
const outcome = await refresh.runManagedToolRefresh(void 0, {
|
|
5876
|
+
rulePack
|
|
5877
|
+
});
|
|
5903
5878
|
if (outcome.skipped) {
|
|
5904
5879
|
dbg(`session_start tool-refresh: skipped (${outcome.skipped})`);
|
|
5905
5880
|
return;
|
|
@@ -5913,6 +5888,7 @@ function scheduleManagedToolRefresh(dbg) {
|
|
|
5913
5888
|
})();
|
|
5914
5889
|
}, Number.isFinite(delayMs) ? delayMs : MANAGED_TOOL_REFRESH_DELAY_MS);
|
|
5915
5890
|
timer.unref?.();
|
|
5891
|
+
managedToolRefreshTimer = timer;
|
|
5916
5892
|
}
|
|
5917
5893
|
async function probePrettierInstall(ensureTool, dbg, analysisRoot) {
|
|
5918
5894
|
const pkgPath = path13.join(analysisRoot, "package.json");
|
|
@@ -5945,7 +5921,7 @@ function scanOneTodoFile(scanner, filePath, items) {
|
|
|
5945
5921
|
async function collectTodoBaselineItems(scanner, analysisRoot, stillCurrent) {
|
|
5946
5922
|
const items = [];
|
|
5947
5923
|
try {
|
|
5948
|
-
const { getSourceFilesAsync } = await import("../chunk-
|
|
5924
|
+
const { getSourceFilesAsync } = await import("../chunk-SXGD4ANG.js");
|
|
5949
5925
|
const files = await getSourceFilesAsync(analysisRoot, true);
|
|
5950
5926
|
if (!stillCurrent())
|
|
5951
5927
|
return items;
|
|
@@ -5974,7 +5950,7 @@ async function buildOrRefreshWordIndex(args) {
|
|
|
5974
5950
|
const snapshot = loadProjectSnapshot(snapshotRoot);
|
|
5975
5951
|
const snapshotLoadMs = Date.now() - snapshotLoadStartMs;
|
|
5976
5952
|
if (snapshot?.wordIndex) {
|
|
5977
|
-
const { deserializeWordIndex, refreshWordIndexIncrementally, countWordIndexPostingEntries: countWordIndexPostingEntries2, estimateWordIndexResidentBytes: estimateWordIndexResidentBytes2, notifyWordIndexPublished: notifyWordIndexPublished2 } = await import("../chunk-
|
|
5953
|
+
const { deserializeWordIndex, refreshWordIndexIncrementally, countWordIndexPostingEntries: countWordIndexPostingEntries2, estimateWordIndexResidentBytes: estimateWordIndexResidentBytes2, notifyWordIndexPublished: notifyWordIndexPublished2 } = await import("../chunk-KSR7RGQY.js");
|
|
5978
5954
|
const deserializeStartMs = Date.now();
|
|
5979
5955
|
const index = deserializeWordIndex(snapshot.wordIndex);
|
|
5980
5956
|
const deserializeMs = Date.now() - deserializeStartMs;
|
|
@@ -6047,7 +6023,7 @@ async function buildOrRefreshWordIndex(args) {
|
|
|
6047
6023
|
}
|
|
6048
6024
|
}
|
|
6049
6025
|
}
|
|
6050
|
-
const { buildWordIndexAsync, collectWordIndexDocs, countWordIndexPostingEntries, estimateWordIndexResidentBytes, notifyWordIndexPublished } = await import("../chunk-
|
|
6026
|
+
const { buildWordIndexAsync, collectWordIndexDocs, countWordIndexPostingEntries, estimateWordIndexResidentBytes, notifyWordIndexPublished } = await import("../chunk-KSR7RGQY.js");
|
|
6051
6027
|
const docs = await collectWordIndexDocs(analysisRoot, () => runtime.isCurrentSession(sessionGeneration), rebuildPreflightFiles);
|
|
6052
6028
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
6053
6029
|
return;
|
|
@@ -6092,6 +6068,16 @@ var STARTUP_TASK_DEFER_MS = {
|
|
|
6092
6068
|
"codebase-model": 5200,
|
|
6093
6069
|
"ast-grep-exports": 5400
|
|
6094
6070
|
};
|
|
6071
|
+
function recordStaleScanSkip(err, dbg) {
|
|
6072
|
+
if (!isStaleExtensionCtxError(err))
|
|
6073
|
+
throw err;
|
|
6074
|
+
dbg("session_start scans: extension ctx went stale \u2014 skipped");
|
|
6075
|
+
recordDegradationOnce({
|
|
6076
|
+
kind: "extension-ctx-stale",
|
|
6077
|
+
subject: "session-start-scans",
|
|
6078
|
+
reason: "session-start scans skipped: the session was replaced while the analyzer bootstrap was pending"
|
|
6079
|
+
});
|
|
6080
|
+
}
|
|
6095
6081
|
function scheduleStartupScans(deps, runtime, sessionGeneration, analysisRoot, snapshotRoot, languageProfile, dbg) {
|
|
6096
6082
|
void (async () => {
|
|
6097
6083
|
const resolved = await demandBootstrapDeps(deps, "session-start-scans");
|
|
@@ -6099,7 +6085,11 @@ function scheduleStartupScans(deps, runtime, sessionGeneration, analysisRoot, sn
|
|
|
6099
6085
|
dbg("session_start scans: analyzer bootstrap unavailable \u2014 skipped");
|
|
6100
6086
|
return;
|
|
6101
6087
|
}
|
|
6102
|
-
|
|
6088
|
+
try {
|
|
6089
|
+
scheduleStartupScansWithClients(resolved, runtime, sessionGeneration, analysisRoot, snapshotRoot, languageProfile, dbg);
|
|
6090
|
+
} catch (err) {
|
|
6091
|
+
recordStaleScanSkip(err, dbg);
|
|
6092
|
+
}
|
|
6103
6093
|
})();
|
|
6104
6094
|
}
|
|
6105
6095
|
function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analysisRoot, snapshotRoot, languageProfile, dbg) {
|
|
@@ -6412,9 +6402,9 @@ function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analy
|
|
|
6412
6402
|
});
|
|
6413
6403
|
let callGraphIdentity;
|
|
6414
6404
|
const callGraphTask = runTask("call-graph", async () => {
|
|
6415
|
-
const { FactStore: FactStore2 } = await import("../chunk-
|
|
6416
|
-
const { buildOrUpdateGraph, extractSymbolsAndRefsFromGraph, getReviewGraphCacheIdentity } = await import("../chunk-
|
|
6417
|
-
const { buildCallGraph, saveCallGraph, loadCallGraph: loadCallGraph2 } = await import("../chunk-
|
|
6405
|
+
const { FactStore: FactStore2 } = await import("../chunk-F6X3YJWD.js");
|
|
6406
|
+
const { buildOrUpdateGraph, extractSymbolsAndRefsFromGraph, getReviewGraphCacheIdentity } = await import("../chunk-T7FTXGS3.js");
|
|
6407
|
+
const { buildCallGraph, saveCallGraph, loadCallGraph: loadCallGraph2 } = await import("../chunk-S67UJDGQ.js");
|
|
6418
6408
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
6419
6409
|
return;
|
|
6420
6410
|
const startMs = Date.now();
|
|
@@ -6455,7 +6445,7 @@ function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analy
|
|
|
6455
6445
|
return;
|
|
6456
6446
|
if (!runtime.callGraph)
|
|
6457
6447
|
return;
|
|
6458
|
-
const { buildCodebaseModel, saveCodebaseModel, DEFAULT_CODEBASE_MODEL_TOKEN_BUDGET } = await import("../chunk-
|
|
6448
|
+
const { buildCodebaseModel, saveCodebaseModel, DEFAULT_CODEBASE_MODEL_TOKEN_BUDGET } = await import("../chunk-WQOIR3QY.js");
|
|
6459
6449
|
if (!callGraphIdentity)
|
|
6460
6450
|
return;
|
|
6461
6451
|
const model = buildCodebaseModel(runtime.callGraph, analysisRoot, DEFAULT_CODEBASE_MODEL_TOKEN_BUDGET, callGraphIdentity);
|
|
@@ -6532,6 +6522,7 @@ function resetSessionScopedState(cwd, sessionStartMs = Date.now()) {
|
|
|
6532
6522
|
resetMutationAttribution();
|
|
6533
6523
|
primePersistedMutationAttribution(cwd);
|
|
6534
6524
|
resetPendingAuxiliaryCoverage();
|
|
6525
|
+
resetDeferredDispositions();
|
|
6535
6526
|
resetSafeSpawnWindowsCommandCache();
|
|
6536
6527
|
resetDispatchAvailabilityState();
|
|
6537
6528
|
resetObservedRunnerLatency();
|
|
@@ -6552,6 +6543,7 @@ function resetSessionScopedState(cwd, sessionStartMs = Date.now()) {
|
|
|
6552
6543
|
resetSmellsSessionState();
|
|
6553
6544
|
resetSituationalToolTelemetry();
|
|
6554
6545
|
resetWorkspaceDiagnosticsCacheSession(sessionStartMs);
|
|
6546
|
+
cancelScheduledManagedToolRefresh();
|
|
6555
6547
|
}
|
|
6556
6548
|
function readSubstituteGuidance(isEnabled) {
|
|
6557
6549
|
const units = [];
|
|
@@ -6584,19 +6576,17 @@ function readSubstituteGuidance(isEnabled) {
|
|
|
6584
6576
|
}
|
|
6585
6577
|
function situationalGuidance(isEnabled) {
|
|
6586
6578
|
const active = [];
|
|
6587
|
-
for (const
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
if (isEnabled(name))
|
|
6593
|
-
active.push(name);
|
|
6579
|
+
for (const entry of TOOL_REGISTRY) {
|
|
6580
|
+
if (!entry.situational)
|
|
6581
|
+
continue;
|
|
6582
|
+
if (isEnabled(entry.name))
|
|
6583
|
+
active.push(entry.name);
|
|
6594
6584
|
}
|
|
6595
6585
|
if (active.length === 0)
|
|
6596
6586
|
return void 0;
|
|
6597
|
-
let text = `\u2022 Situational (activate via pi_lens_activate_tools): ${active.join(", ")}.`;
|
|
6587
|
+
let text = `\u2022 Situational (activate via pi_lens_activate_tools if unlisted): ${active.join(", ")}.`;
|
|
6598
6588
|
if (isEnabled("ast_grep_search")) {
|
|
6599
|
-
text += " Use ast_grep_search
|
|
6589
|
+
text += " Use ast_grep_search dump=true to inspect AST.";
|
|
6600
6590
|
}
|
|
6601
6591
|
return text;
|
|
6602
6592
|
}
|
|
@@ -6664,8 +6654,8 @@ async function handleSessionStart(deps) {
|
|
|
6664
6654
|
try {
|
|
6665
6655
|
warmupDbg("warmup: starting background warmup");
|
|
6666
6656
|
const scanContextStartedAt = Date.now();
|
|
6667
|
-
const startupScanModule = await import("../chunk-
|
|
6668
|
-
const languageProfileModule = await import("../chunk-
|
|
6657
|
+
const startupScanModule = await import("../chunk-75SY4F24.js");
|
|
6658
|
+
const languageProfileModule = await import("../chunk-4AVZ3TG7.js");
|
|
6669
6659
|
const warmupSnapshotRoot = resolveSnapshotRoot(warmupCwd);
|
|
6670
6660
|
const cachedSnapshot = loadProjectSnapshot(warmupSnapshotRoot);
|
|
6671
6661
|
warmupOwnSnapshotRead = cachedSnapshot ? {
|
|
@@ -6810,7 +6800,12 @@ async function handleSessionStart(deps) {
|
|
|
6810
6800
|
filePath: ctxCwd ?? process.cwd(),
|
|
6811
6801
|
startedAt: new Date(handlerEnteredAt).toISOString(),
|
|
6812
6802
|
durationMs: Date.now() - handlerEnteredAt,
|
|
6813
|
-
metadata: {
|
|
6803
|
+
metadata: {
|
|
6804
|
+
mode: startupMode,
|
|
6805
|
+
reason: deps.sessionReason,
|
|
6806
|
+
// #4704: true when another live session keeps the shared LSP fleet.
|
|
6807
|
+
sharedLspKept: deps.keepSharedLsp === true
|
|
6808
|
+
}
|
|
6814
6809
|
});
|
|
6815
6810
|
const cleanupCwd = ctxCwd ?? process.cwd();
|
|
6816
6811
|
setImmediate(() => {
|
|
@@ -6837,7 +6832,9 @@ async function handleSessionStart(deps) {
|
|
|
6837
6832
|
}
|
|
6838
6833
|
});
|
|
6839
6834
|
dbg(`session_start startup mode: ${startupMode}`);
|
|
6840
|
-
if (
|
|
6835
|
+
if (deps.keepSharedLsp) {
|
|
6836
|
+
dbg("session_start: LSP service kept for a live in-process session");
|
|
6837
|
+
} else if (!getFlag("no-lsp")) {
|
|
6841
6838
|
resetLSPService2({ fast: true, reason: "session_start" });
|
|
6842
6839
|
dbg("session_start: LSP service reset");
|
|
6843
6840
|
dbg("session_start: phase0 workspace diagnostics observation enabled (capability probe only)");
|
|
@@ -6859,7 +6856,7 @@ async function handleSessionStart(deps) {
|
|
|
6859
6856
|
recordDegradationOnce({
|
|
6860
6857
|
kind: "data_dir_migrated",
|
|
6861
6858
|
subject: hash,
|
|
6862
|
-
reason: migration.outcome === "renamed" ? "using hashed directory after renaming legacy directory" : migration.outcome === "coexisting" ? "using hashed directory because legacy and hashed directories both exist" : migration.outcome === "rename-failed" ? "using legacy directory after hashed-directory rename failure" : "using resolved directory after realpath fallback"
|
|
6859
|
+
reason: migration.outcome === "renamed" ? "using hashed directory after renaming legacy directory" : migration.outcome === "coexisting" ? "using hashed directory because legacy and hashed directories both exist" : migration.outcome === "rename-failed" ? "using legacy directory after hashed-directory rename failure" : migration.outcome === "adopted" ? "copied the data an earlier version stored under the root's link spelling into the real path's directory; the old directory is kept" : migration.outcome === "adopt-failed" ? "some data an earlier version stored under the root's link spelling could not be copied and stays in the old directory" : "using resolved directory after realpath fallback"
|
|
6863
6860
|
});
|
|
6864
6861
|
}
|
|
6865
6862
|
const globalDir = getGlobalPiLensDir();
|
|
@@ -7188,7 +7185,7 @@ async function handleSessionStart(deps) {
|
|
|
7188
7185
|
const startupScansEnabled = deps.projectConfig?.startup?.scans?.enabled ?? deps.globalConfig?.startup?.scans?.enabled ?? true;
|
|
7189
7186
|
if (allowBootstrapTasks) {
|
|
7190
7187
|
scheduleDeferredToolProbes(deps, languageProfile, startupDefaults, dbg);
|
|
7191
|
-
scheduleManagedToolRefresh(dbg);
|
|
7188
|
+
scheduleManagedToolRefresh(dbg, !deps.getFlag("no-opengrep"));
|
|
7192
7189
|
}
|
|
7193
7190
|
if (allowBootstrapTasks) {
|
|
7194
7191
|
void probePrettierInstall(ensureTool, dbg, analysisRoot);
|
|
@@ -7308,12 +7305,12 @@ function emitSmellsSessionStartLine(dbg, sessionStartMs) {
|
|
|
7308
7305
|
}
|
|
7309
7306
|
|
|
7310
7307
|
// dist/clients/runtime-turn.js
|
|
7311
|
-
import * as
|
|
7308
|
+
import * as fs16 from "node:fs";
|
|
7312
7309
|
import * as path24 from "node:path";
|
|
7313
7310
|
|
|
7314
7311
|
// dist/clients/actionable-warnings.js
|
|
7315
|
-
import { createHash
|
|
7316
|
-
import * as
|
|
7312
|
+
import { createHash } from "node:crypto";
|
|
7313
|
+
import * as fs11 from "node:fs";
|
|
7317
7314
|
import * as path15 from "node:path";
|
|
7318
7315
|
|
|
7319
7316
|
// dist/clients/actionable-warnings-logger.js
|
|
@@ -7403,14 +7400,14 @@ function deserializeSuppressionState(contents) {
|
|
|
7403
7400
|
function readSuppressionState(cwd) {
|
|
7404
7401
|
const statePath = path15.join(getProjectDataDir(cwd), "cache", "actionable-warning-state.json");
|
|
7405
7402
|
try {
|
|
7406
|
-
return deserializeSuppressionState(
|
|
7403
|
+
return deserializeSuppressionState(fs11.readFileSync(statePath, "utf8"));
|
|
7407
7404
|
} catch {
|
|
7408
7405
|
return {};
|
|
7409
7406
|
}
|
|
7410
7407
|
}
|
|
7411
7408
|
function updateWarningState(cwd, warnings) {
|
|
7412
7409
|
const statePath = path15.join(getProjectDataDir(cwd), "cache", "actionable-warning-state.json");
|
|
7413
|
-
|
|
7410
|
+
fs11.mkdirSync(path15.dirname(statePath), { recursive: true });
|
|
7414
7411
|
const hook = beforeWarningStateLockForTests;
|
|
7415
7412
|
beforeWarningStateLockForTests = null;
|
|
7416
7413
|
hook?.();
|
|
@@ -7614,8 +7611,8 @@ async function buildActionableWarningsReport(args) {
|
|
|
7614
7611
|
const primed = [];
|
|
7615
7612
|
const cold = [];
|
|
7616
7613
|
for (const filePath of capped) {
|
|
7617
|
-
const content =
|
|
7618
|
-
const contentHash = content !== void 0 ?
|
|
7614
|
+
const content = fs11.existsSync(filePath) ? fs11.readFileSync(filePath, "utf-8") : void 0;
|
|
7615
|
+
const contentHash = content !== void 0 ? createHash("sha256").update(content).digest("hex") : void 0;
|
|
7619
7616
|
const cached = contentHash !== void 0 ? lspService.getLastKnownDiagnostics(filePath, contentHash) : void 0;
|
|
7620
7617
|
(cached !== void 0 ? primed : cold).push({
|
|
7621
7618
|
filePath,
|
|
@@ -8167,8 +8164,8 @@ function appendActionableWarningsHistory(cwd, report) {
|
|
|
8167
8164
|
return;
|
|
8168
8165
|
const historyPath = getActionableWarningsHistoryPath(cwd);
|
|
8169
8166
|
try {
|
|
8170
|
-
|
|
8171
|
-
|
|
8167
|
+
fs11.mkdirSync(path15.dirname(historyPath), { recursive: true });
|
|
8168
|
+
fs11.appendFileSync(historyPath, `${entries.map((entry) => JSON.stringify(entry)).join("\n")}
|
|
8172
8169
|
`, "utf8");
|
|
8173
8170
|
} catch {
|
|
8174
8171
|
}
|
|
@@ -8205,7 +8202,7 @@ ${fileList}${more}` : void 0,
|
|
|
8205
8202
|
}
|
|
8206
8203
|
|
|
8207
8204
|
// dist/clients/code-quality-warnings.js
|
|
8208
|
-
import * as
|
|
8205
|
+
import * as fs12 from "node:fs";
|
|
8209
8206
|
import * as path16 from "node:path";
|
|
8210
8207
|
var TIER_BUDGET_ORDER = [
|
|
8211
8208
|
"warning",
|
|
@@ -8309,8 +8306,8 @@ function appendCodeQualityWarningsHistory(cwd, report) {
|
|
|
8309
8306
|
return;
|
|
8310
8307
|
const historyPath = getCodeQualityWarningsHistoryPath(cwd);
|
|
8311
8308
|
try {
|
|
8312
|
-
|
|
8313
|
-
|
|
8309
|
+
fs12.mkdirSync(path16.dirname(historyPath), { recursive: true });
|
|
8310
|
+
fs12.appendFileSync(historyPath, `${warnings.map((entry) => JSON.stringify(entry)).join("\n")}
|
|
8314
8311
|
`, "utf8");
|
|
8315
8312
|
} catch {
|
|
8316
8313
|
}
|
|
@@ -8341,14 +8338,11 @@ function formatCodeQualityWarningsAdvisory(report, cwd, host = "pi") {
|
|
|
8341
8338
|
}
|
|
8342
8339
|
|
|
8343
8340
|
// dist/clients/git-guard.js
|
|
8341
|
+
import * as nodeFs2 from "node:fs";
|
|
8344
8342
|
import * as path17 from "node:path";
|
|
8345
8343
|
|
|
8346
|
-
// dist/clients/read-guard-tool-lines.js
|
|
8347
|
-
var MAX_FAILURE_TRACKER_SIZE = 200;
|
|
8348
|
-
var recentOldTextFailures = new BoundedFifoMap(MAX_FAILURE_TRACKER_SIZE);
|
|
8349
|
-
|
|
8350
8344
|
// dist/clients/deferred-runner-blockers.js
|
|
8351
|
-
import * as
|
|
8345
|
+
import * as fs13 from "node:fs";
|
|
8352
8346
|
import { resolve as resolve9 } from "node:path";
|
|
8353
8347
|
function judgeDeferredRunnerFindings(pending2, cwd, options = {}) {
|
|
8354
8348
|
const findings = pending2.result?.diagnostics ?? [];
|
|
@@ -8438,7 +8432,7 @@ function withoutLaneCopies(runtime, pending2, findings) {
|
|
|
8438
8432
|
}
|
|
8439
8433
|
function readBytes(filePath) {
|
|
8440
8434
|
try {
|
|
8441
|
-
return
|
|
8435
|
+
return fs13.readFileSync(filePath);
|
|
8442
8436
|
} catch {
|
|
8443
8437
|
return void 0;
|
|
8444
8438
|
}
|
|
@@ -8478,40 +8472,282 @@ function blockingProvenance(blockerContent, blockingFiles, cwd) {
|
|
|
8478
8472
|
if (blockingFiles.some((file) => typeof file !== "string" || file.trim().length === 0)) {
|
|
8479
8473
|
return void 0;
|
|
8480
8474
|
}
|
|
8481
|
-
const
|
|
8482
|
-
|
|
8483
|
-
|
|
8475
|
+
const { sections, unowned } = splitBlockerSections(blockerContent, blockingFiles, cwd);
|
|
8476
|
+
if (unowned || sections.length === 0)
|
|
8477
|
+
return void 0;
|
|
8478
|
+
return sections;
|
|
8479
|
+
}
|
|
8480
|
+
function splitBlockerSections(blockerContent, blockingFiles, cwd) {
|
|
8481
|
+
const provenanceKeys = new Set(blockingFiles.map((file) => guardPathKey(file, cwd)));
|
|
8482
|
+
const sections = [];
|
|
8483
|
+
let unowned = false;
|
|
8484
|
+
let open;
|
|
8484
8485
|
for (const line of blockerContent.split("\n")) {
|
|
8485
8486
|
if (line.length === 0) {
|
|
8486
|
-
|
|
8487
|
+
open = void 0;
|
|
8487
8488
|
continue;
|
|
8488
8489
|
}
|
|
8489
8490
|
const file = blockerSectionFile(line);
|
|
8490
8491
|
if (file === void 0) {
|
|
8491
|
-
if (
|
|
8492
|
-
|
|
8492
|
+
if (open)
|
|
8493
|
+
open.lines.push(line);
|
|
8494
|
+
else
|
|
8495
|
+
unowned = true;
|
|
8493
8496
|
continue;
|
|
8494
8497
|
}
|
|
8495
|
-
|
|
8496
|
-
|
|
8498
|
+
open = { key: guardPathKey(file, cwd), file, lines: [line] };
|
|
8499
|
+
if (provenanceKeys.has(open.key))
|
|
8500
|
+
sections.push(open);
|
|
8501
|
+
else
|
|
8502
|
+
unowned = true;
|
|
8497
8503
|
}
|
|
8498
|
-
|
|
8499
|
-
return void 0;
|
|
8500
|
-
return sectionKeys.every((key) => provenanceKeys.includes(key)) ? sectionKeys : void 0;
|
|
8504
|
+
return { sections, unowned };
|
|
8501
8505
|
}
|
|
8502
8506
|
function isTurnEndFindingsCache(value) {
|
|
8503
8507
|
if (!value || typeof value !== "object")
|
|
8504
8508
|
return false;
|
|
8505
8509
|
const record = value;
|
|
8506
|
-
return typeof record.content === "string" && typeof record.hasBlockers === "boolean" && Array.isArray(record.affectedFiles) && record.affectedFiles.every((file) => typeof file === "string") && typeof record.sessionId === "string" && typeof record.projectSeqStart === "number" && typeof record.projectSeqEnd === "number" && Number.isFinite(record.projectSeqStart) && Number.isFinite(record.projectSeqEnd) && !!record.fileSeqByPath && typeof record.fileSeqByPath === "object" && Object.values(record.fileSeqByPath).every((seq) => typeof seq === "number" && Number.isFinite(seq)) && !!record.fileContentHashes && typeof record.fileContentHashes === "object" && Object.values(record.fileContentHashes).every((hash) => typeof hash === "string") && (record.affectedFilesTruncated === void 0 || typeof record.affectedFilesTruncated === "boolean") && (record.blockingFiles === void 0 || Array.isArray(record.blockingFiles));
|
|
8510
|
+
return typeof record.content === "string" && typeof record.hasBlockers === "boolean" && Array.isArray(record.affectedFiles) && record.affectedFiles.every((file) => typeof file === "string") && typeof record.sessionId === "string" && typeof record.projectSeqStart === "number" && typeof record.projectSeqEnd === "number" && Number.isFinite(record.projectSeqStart) && Number.isFinite(record.projectSeqEnd) && !!record.fileSeqByPath && typeof record.fileSeqByPath === "object" && Object.values(record.fileSeqByPath).every((seq) => typeof seq === "number" && Number.isFinite(seq)) && !!record.fileContentHashes && typeof record.fileContentHashes === "object" && Object.values(record.fileContentHashes).every((hash) => typeof hash === "string") && (record.affectedFilesTruncated === void 0 || typeof record.affectedFilesTruncated === "boolean") && (record.blockingFiles === void 0 || Array.isArray(record.blockingFiles)) && wellFormedStamp(record.blockerWrittenAt) && carriesWellFormedBlockers(record);
|
|
8511
|
+
}
|
|
8512
|
+
function carriesWellFormedBlockers(record) {
|
|
8513
|
+
const carried = record.carriedBlockers;
|
|
8514
|
+
if (carried === void 0)
|
|
8515
|
+
return true;
|
|
8516
|
+
if (!Array.isArray(carried) || carried.length === 0)
|
|
8517
|
+
return false;
|
|
8518
|
+
if (typeof record.blockerContent !== "string" || !record.blockerContent)
|
|
8519
|
+
return false;
|
|
8520
|
+
const owners = /* @__PURE__ */ new Set([String(record.sessionId)]);
|
|
8521
|
+
return carried.every((partition) => {
|
|
8522
|
+
const ok = !!partition && typeof partition.sessionId === "string" && !owners.has(partition.sessionId) && typeof partition.blockerContent === "string" && partition.blockerContent.length > 0 && Array.isArray(partition.blockingFiles) && partition.blockingFiles.every((file) => typeof file === "string") && wellFormedStamp(partition.blockerWrittenAt);
|
|
8523
|
+
if (ok)
|
|
8524
|
+
owners.add(partition.sessionId);
|
|
8525
|
+
return ok;
|
|
8526
|
+
});
|
|
8527
|
+
}
|
|
8528
|
+
function wellFormedStamp(stamp) {
|
|
8529
|
+
return stamp === void 0 || Number.isFinite(stamp);
|
|
8530
|
+
}
|
|
8531
|
+
function storedRecord(cacheManager2, cwd) {
|
|
8532
|
+
const read = cacheManager2.readCache("turn-end-findings", cwd, Number.POSITIVE_INFINITY);
|
|
8533
|
+
if (!read)
|
|
8534
|
+
return void 0;
|
|
8535
|
+
const { data } = read;
|
|
8536
|
+
return {
|
|
8537
|
+
fields: data && typeof data === "object" ? data : void 0
|
|
8538
|
+
};
|
|
8507
8539
|
}
|
|
8508
8540
|
function cacheRecord(cacheManager2, cwd) {
|
|
8509
|
-
const
|
|
8510
|
-
return
|
|
8541
|
+
const fields = storedRecord(cacheManager2, cwd)?.fields;
|
|
8542
|
+
return isTurnEndFindingsCache(fields) ? fields : void 0;
|
|
8543
|
+
}
|
|
8544
|
+
function claimsNoBlocker(fields) {
|
|
8545
|
+
if (!fields)
|
|
8546
|
+
return false;
|
|
8547
|
+
return fields.hasBlockers === false && (fields.testFailures === void 0 || fields.testFailures === false) && (fields.blockerContent === void 0 || fields.blockerContent === "") && // #4733 r1 F7: a test failure's text or files contradict the claim too.
|
|
8548
|
+
(fields.testFailureContent === void 0 || fields.testFailureContent === "") && (fields.testFailureFiles === void 0 || Array.isArray(fields.testFailureFiles) && fields.testFailureFiles.length === 0) && // #4738: another session's carried blocker contradicts it too.
|
|
8549
|
+
fields.carriedBlockers === void 0;
|
|
8550
|
+
}
|
|
8551
|
+
function recordPartitions(record) {
|
|
8552
|
+
const top = record.blockerContent ? [
|
|
8553
|
+
{
|
|
8554
|
+
sessionId: record.sessionId,
|
|
8555
|
+
blockerContent: record.blockerContent,
|
|
8556
|
+
blockingFiles: record.blockingFiles ?? [],
|
|
8557
|
+
blockerWrittenAt: record.blockerWrittenAt
|
|
8558
|
+
}
|
|
8559
|
+
] : [];
|
|
8560
|
+
return [...top, ...record.carriedBlockers ?? []];
|
|
8561
|
+
}
|
|
8562
|
+
function blockerPartitionFields(partitions) {
|
|
8563
|
+
const [top, ...carried] = partitions;
|
|
8564
|
+
return {
|
|
8565
|
+
owner: top?.sessionId,
|
|
8566
|
+
blockerContent: top?.blockerContent,
|
|
8567
|
+
blockingFiles: top?.blockingFiles,
|
|
8568
|
+
carriedBlockers: carried.length > 0 ? carried : void 0,
|
|
8569
|
+
blockerWrittenAt: top?.blockerWrittenAt
|
|
8570
|
+
};
|
|
8571
|
+
}
|
|
8572
|
+
function sectionFileGone(section, cwd) {
|
|
8573
|
+
try {
|
|
8574
|
+
return nodeFs2.statSync(resolveGuardPath(section.file, cwd), {
|
|
8575
|
+
throwIfNoEntry: false
|
|
8576
|
+
}) === void 0;
|
|
8577
|
+
} catch {
|
|
8578
|
+
return false;
|
|
8579
|
+
}
|
|
8580
|
+
}
|
|
8581
|
+
function trimPartition(partition, cwd, dropKeys, leaves) {
|
|
8582
|
+
const sections = blockingProvenance(partition.blockerContent, partition.blockingFiles, cwd);
|
|
8583
|
+
if (!sections)
|
|
8584
|
+
return { kept: partition, dropped: 0 };
|
|
8585
|
+
const blockingFiles = partition.blockingFiles.filter((file) => !dropKeys.has(guardPathKey(file, cwd)));
|
|
8586
|
+
const keptSections = sections.filter((section) => !leaves(section));
|
|
8587
|
+
const dropped = sections.length - keptSections.length;
|
|
8588
|
+
if (keptSections.length === 0)
|
|
8589
|
+
return { kept: void 0, dropped };
|
|
8590
|
+
return {
|
|
8591
|
+
kept: {
|
|
8592
|
+
sessionId: partition.sessionId,
|
|
8593
|
+
blockerContent: dropped > 0 ? keptSections.map((section) => section.lines.join("\n")).join("\n\n") : partition.blockerContent,
|
|
8594
|
+
blockingFiles,
|
|
8595
|
+
blockerWrittenAt: partition.blockerWrittenAt
|
|
8596
|
+
},
|
|
8597
|
+
dropped
|
|
8598
|
+
};
|
|
8599
|
+
}
|
|
8600
|
+
function logSectionsDropped(cwd, by, basis) {
|
|
8601
|
+
logLatency({
|
|
8602
|
+
type: "phase",
|
|
8603
|
+
toolName: "git-guard",
|
|
8604
|
+
filePath: cwd,
|
|
8605
|
+
phase: "sections_dropped",
|
|
8606
|
+
durationMs: 0,
|
|
8607
|
+
result: basis,
|
|
8608
|
+
metadata: { by, basis }
|
|
8609
|
+
});
|
|
8610
|
+
}
|
|
8611
|
+
function logCarriedDrops(cwd, dropped) {
|
|
8612
|
+
if (dropped.noFile)
|
|
8613
|
+
logSectionsDropped(cwd, "turn_end", "no_file");
|
|
8614
|
+
if (dropped.gone)
|
|
8615
|
+
logSectionsDropped(cwd, "turn_end", "file_gone");
|
|
8616
|
+
}
|
|
8617
|
+
function pastFreshnessWindow(partition, now) {
|
|
8618
|
+
const writtenAt = partition.blockerWrittenAt;
|
|
8619
|
+
return writtenAt !== void 0 && now - writtenAt > DEFAULT_MAX_AGE_MS;
|
|
8620
|
+
}
|
|
8621
|
+
function readTurnEndGuardRecord(cacheManager2, runtime, cwd) {
|
|
8622
|
+
const stored = storedRecord(cacheManager2, cwd)?.fields;
|
|
8623
|
+
const { carried, dropped } = carriedTurnEndBlockers(stored, runtime, cwd);
|
|
8624
|
+
return { stored, carried, dropped };
|
|
8625
|
+
}
|
|
8626
|
+
function carriedTurnEndBlockers(stored, runtime, cwd) {
|
|
8627
|
+
const dropped = { gone: false, noFile: false };
|
|
8628
|
+
if (!isTurnEndFindingsCache(stored))
|
|
8629
|
+
return { carried: [], dropped, stamped: false };
|
|
8630
|
+
const me = runtime.telemetrySessionId;
|
|
8631
|
+
const now = Date.now();
|
|
8632
|
+
const carried = [];
|
|
8633
|
+
let stamped = false;
|
|
8634
|
+
for (const partition of recordPartitions(stored)) {
|
|
8635
|
+
if (partition.sessionId === me)
|
|
8636
|
+
continue;
|
|
8637
|
+
if (!blockingProvenance(partition.blockerContent, partition.blockingFiles, cwd) && !pastFreshnessWindow(partition, now)) {
|
|
8638
|
+
if (partition.blockerWrittenAt === void 0)
|
|
8639
|
+
stamped = true;
|
|
8640
|
+
carried.push({
|
|
8641
|
+
...partition,
|
|
8642
|
+
blockerWrittenAt: partition.blockerWrittenAt ?? now
|
|
8643
|
+
});
|
|
8644
|
+
continue;
|
|
8645
|
+
}
|
|
8646
|
+
const split = splitBlockerSections(partition.blockerContent, partition.blockingFiles.filter((file) => typeof file === "string" && file.trim().length > 0), cwd);
|
|
8647
|
+
if (split.unowned)
|
|
8648
|
+
dropped.noFile = true;
|
|
8649
|
+
const live = split.sections.filter((section) => !sectionFileGone(section, cwd));
|
|
8650
|
+
if (live.length < split.sections.length)
|
|
8651
|
+
dropped.gone = true;
|
|
8652
|
+
if (live.length === 0)
|
|
8653
|
+
continue;
|
|
8654
|
+
carried.push({
|
|
8655
|
+
sessionId: partition.sessionId,
|
|
8656
|
+
blockerContent: live.length === split.sections.length && !split.unowned ? partition.blockerContent : live.map((section) => section.lines.join("\n")).join("\n\n"),
|
|
8657
|
+
blockingFiles: partition.blockingFiles,
|
|
8658
|
+
blockerWrittenAt: partition.blockerWrittenAt
|
|
8659
|
+
});
|
|
8660
|
+
}
|
|
8661
|
+
return { carried, dropped, stamped };
|
|
8662
|
+
}
|
|
8663
|
+
var NO_CLAIM_FIELDS = [
|
|
8664
|
+
"content",
|
|
8665
|
+
"affectedFiles",
|
|
8666
|
+
"affectedFilesTruncated",
|
|
8667
|
+
"provenance"
|
|
8668
|
+
];
|
|
8669
|
+
function makesNoClaim(fields) {
|
|
8670
|
+
return !!fields && typeof fields.content === "string" && Object.keys(fields).every((key) => NO_CLAIM_FIELDS.some((field) => field === key));
|
|
8671
|
+
}
|
|
8672
|
+
function logRecordRetired(cwd, by, basis) {
|
|
8673
|
+
logLatency({
|
|
8674
|
+
type: "phase",
|
|
8675
|
+
toolName: "git-guard",
|
|
8676
|
+
filePath: cwd,
|
|
8677
|
+
phase: "record_retired",
|
|
8678
|
+
durationMs: 0,
|
|
8679
|
+
result: basis,
|
|
8680
|
+
metadata: { by, basis }
|
|
8681
|
+
});
|
|
8682
|
+
}
|
|
8683
|
+
function retireSettledGitGuardRecord(runtime, cacheManager2, cwd) {
|
|
8684
|
+
const stored = storedRecord(cacheManager2, cwd)?.fields;
|
|
8685
|
+
if (!stored)
|
|
8686
|
+
return false;
|
|
8687
|
+
const own = stored.sessionId === runtime.telemetrySessionId && stored.testFailures !== true && stored.carriedBlockers === void 0;
|
|
8688
|
+
const basis = own ? "own_session" : claimsNoBlocker(stored) ? "no_blocker" : makesNoClaim(stored) ? "no_claim" : void 0;
|
|
8689
|
+
if (basis) {
|
|
8690
|
+
cacheManager2.clearCache("turn-end-findings", cwd);
|
|
8691
|
+
runtime.clearGitGuardCacheUnknown();
|
|
8692
|
+
logRecordRetired(cwd, "turn_end", basis);
|
|
8693
|
+
return true;
|
|
8694
|
+
}
|
|
8695
|
+
return retireOwnPartition(runtime, cacheManager2, cwd, stored);
|
|
8696
|
+
}
|
|
8697
|
+
function retireOwnPartition(runtime, cacheManager2, cwd, stored) {
|
|
8698
|
+
if (!isTurnEndFindingsCache(stored))
|
|
8699
|
+
return false;
|
|
8700
|
+
const me = runtime.telemetrySessionId;
|
|
8701
|
+
if (stored.sessionId === me && stored.carriedBlockers === void 0)
|
|
8702
|
+
return false;
|
|
8703
|
+
const ownDropped = recordPartitions(stored).some((partition) => partition.sessionId === me);
|
|
8704
|
+
const { carried: kept, dropped, stamped } = carriedTurnEndBlockers(stored, runtime, cwd);
|
|
8705
|
+
if (!ownDropped && !dropped.gone && !dropped.noFile) {
|
|
8706
|
+
if (stamped) {
|
|
8707
|
+
const fields2 = blockerPartitionFields(kept);
|
|
8708
|
+
writeGitGuardRecord(cacheManager2, runtime, cwd, {
|
|
8709
|
+
...stored,
|
|
8710
|
+
carriedBlockers: fields2.carriedBlockers,
|
|
8711
|
+
blockerWrittenAt: fields2.blockerWrittenAt
|
|
8712
|
+
});
|
|
8713
|
+
}
|
|
8714
|
+
return false;
|
|
8715
|
+
}
|
|
8716
|
+
const testFailures = stored.testFailures === true;
|
|
8717
|
+
if (kept.length === 0 && !testFailures) {
|
|
8718
|
+
cacheManager2.clearCache("turn-end-findings", cwd);
|
|
8719
|
+
runtime.clearGitGuardCacheUnknown();
|
|
8720
|
+
logRecordRetired(cwd, "turn_end", dropped.noFile ? "no_file" : "file_gone");
|
|
8721
|
+
return true;
|
|
8722
|
+
}
|
|
8723
|
+
if (ownDropped)
|
|
8724
|
+
logSectionsDropped(cwd, "turn_end", "own_session");
|
|
8725
|
+
logCarriedDrops(cwd, dropped);
|
|
8726
|
+
const fields = blockerPartitionFields(kept);
|
|
8727
|
+
const owner = fields.owner ?? stored.sessionId;
|
|
8728
|
+
writeGitGuardRecord(cacheManager2, runtime, cwd, {
|
|
8729
|
+
...stored,
|
|
8730
|
+
content: [
|
|
8731
|
+
fields.blockerContent,
|
|
8732
|
+
testFailures ? stored.testFailureContent : void 0
|
|
8733
|
+
].filter((value) => !!value).join("\n\n"),
|
|
8734
|
+
blockerContent: fields.blockerContent,
|
|
8735
|
+
blockingFiles: fields.blockingFiles,
|
|
8736
|
+
carriedBlockers: fields.carriedBlockers,
|
|
8737
|
+
blockerWrittenAt: fields.blockerWrittenAt,
|
|
8738
|
+
hasBlockers: kept.length > 0 || testFailures,
|
|
8739
|
+
sessionId: owner,
|
|
8740
|
+
// Nothing new to deliver: the sections kept were already in the record.
|
|
8741
|
+
consumed: stored.consumed === true
|
|
8742
|
+
});
|
|
8743
|
+
return false;
|
|
8511
8744
|
}
|
|
8512
8745
|
function markCacheUnknown(runtime, reason) {
|
|
8513
8746
|
runtime.markGitGuardCacheUnknown(reason);
|
|
8514
8747
|
}
|
|
8748
|
+
function recordOwner(existing, runtime, storedSectionSurvives) {
|
|
8749
|
+
return existing && storedSectionSurvives ? existing.sessionId : runtime.telemetrySessionId;
|
|
8750
|
+
}
|
|
8515
8751
|
function writeGitGuardRecord(cacheManager2, runtime, cwd, record) {
|
|
8516
8752
|
const capped = capAffectedFiles(Array.isArray(record.affectedFiles) ? record.affectedFiles : [], cwd);
|
|
8517
8753
|
const fileSeqByPath = { ...record.fileSeqByPath };
|
|
@@ -8569,46 +8805,86 @@ function resyncGitGuardAfterInlinePolicy(args) {
|
|
|
8569
8805
|
return;
|
|
8570
8806
|
args.runtime.updateGitGuardStatus(false, "");
|
|
8571
8807
|
}
|
|
8572
|
-
function syncGitGuardRecord(runtime, cacheManager2, cwd, editedFilePath, analysisRootMode = "session") {
|
|
8808
|
+
function syncGitGuardRecord(runtime, cacheManager2, cwd, editedFilePath, analysisRootMode = "session", editedCleanVerdict = false) {
|
|
8573
8809
|
if (!canWriteAnalysisRoot(analysisRootMode))
|
|
8574
8810
|
return;
|
|
8575
8811
|
const entries = (runtime.getInlineBlockersSnapshot?.() ?? []).filter((entry) => !entry.policySuppressed);
|
|
8576
|
-
const
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8812
|
+
const stored = storedRecord(cacheManager2, cwd)?.fields;
|
|
8813
|
+
if (entries.length === 0 && claimsNoBlocker(stored)) {
|
|
8814
|
+
cacheManager2.clearCache("turn-end-findings", cwd);
|
|
8815
|
+
runtime.clearGitGuardCacheUnknown();
|
|
8816
|
+
logRecordRetired(cwd, "write", "no_blocker");
|
|
8580
8817
|
return;
|
|
8581
8818
|
}
|
|
8582
|
-
|
|
8583
|
-
|
|
8819
|
+
const existing = isTurnEndFindingsCache(stored) ? stored : void 0;
|
|
8820
|
+
const editedKey = editedFilePath ? guardPathKey(editedFilePath, cwd) : void 0;
|
|
8821
|
+
const me = runtime.telemetrySessionId;
|
|
8822
|
+
const blockerSections = existing?.blockerContent ? blockingProvenance(existing.blockerContent, existing.blockingFiles ?? [], cwd) : void 0;
|
|
8823
|
+
const dropKey = new Set(editedKey ? [editedKey] : []);
|
|
8824
|
+
let droppedForeign = 0;
|
|
8825
|
+
let droppedOwn = 0;
|
|
8826
|
+
let goneForeign = 0;
|
|
8827
|
+
const trimmed = [];
|
|
8828
|
+
for (const partition of existing ? recordPartitions(existing) : []) {
|
|
8829
|
+
const own = partition.sessionId === me;
|
|
8830
|
+
const speaksForFile = !!editedKey && (own || editedCleanVerdict);
|
|
8831
|
+
const result = trimPartition(partition, cwd, speaksForFile ? dropKey : /* @__PURE__ */ new Set(), (section) => {
|
|
8832
|
+
if (speaksForFile && section.key === editedKey)
|
|
8833
|
+
return true;
|
|
8834
|
+
if (own || !sectionFileGone(section, cwd))
|
|
8835
|
+
return false;
|
|
8836
|
+
goneForeign += 1;
|
|
8837
|
+
return true;
|
|
8838
|
+
});
|
|
8839
|
+
if (own)
|
|
8840
|
+
droppedOwn += result.dropped;
|
|
8841
|
+
else
|
|
8842
|
+
droppedForeign += result.dropped;
|
|
8843
|
+
if (result.kept)
|
|
8844
|
+
trimmed.push(result.kept);
|
|
8845
|
+
}
|
|
8846
|
+
const foreign = !!existing && existing.sessionId !== me;
|
|
8847
|
+
if (foreign && entries.length === 0 && droppedForeign === 0 && droppedOwn === 0) {
|
|
8848
|
+
markCacheUnknown(runtime, "session_mismatch");
|
|
8584
8849
|
return;
|
|
8585
8850
|
}
|
|
8851
|
+
if (!existing && entries.length === 0) {
|
|
8852
|
+
const inspection = cacheManager2.inspectCache("turn-end-findings", cwd);
|
|
8853
|
+
if (inspection !== "missing") {
|
|
8854
|
+
markCacheUnknown(runtime, `cache_${inspection}`);
|
|
8855
|
+
return;
|
|
8856
|
+
}
|
|
8857
|
+
}
|
|
8586
8858
|
const fileSeqByPath = {};
|
|
8587
8859
|
for (const [filePath, seq] of runtime.getFileSeqEntries?.() ?? []) {
|
|
8588
8860
|
fileSeqByPath[guardPathKey(filePath, cwd)] = seq;
|
|
8589
8861
|
}
|
|
8590
8862
|
const inlineFiles = entries.map((entry) => resolveGuardPath(entry.filePath, cwd));
|
|
8591
|
-
const existingBlockingFiles = existing?.blockingFiles ?? [];
|
|
8592
|
-
const blockerSections = existing?.blockerContent ? blockingProvenance(existing.blockerContent, existingBlockingFiles, cwd) : void 0;
|
|
8593
8863
|
if (existing?.blockerContent && !blockerSections) {
|
|
8594
8864
|
markCacheUnknown(runtime, "blocking_provenance_untrusted");
|
|
8595
8865
|
return;
|
|
8596
8866
|
}
|
|
8597
|
-
const
|
|
8867
|
+
const partitions = entries.length > 0 ? [
|
|
8868
|
+
{
|
|
8869
|
+
sessionId: me,
|
|
8870
|
+
blockerContent: entries.map((entry) => `${entry.filePath}: ${entry.summary}`).join("\n"),
|
|
8871
|
+
blockingFiles: inlineFiles
|
|
8872
|
+
},
|
|
8873
|
+
...trimmed.filter((partition) => partition.sessionId !== me)
|
|
8874
|
+
] : trimmed;
|
|
8875
|
+
const fields = blockerPartitionFields(partitions);
|
|
8598
8876
|
const testFiles = existing?.testFailureFiles ?? [];
|
|
8599
|
-
const remainingBlockingFiles = editedKey && existingBlockingFiles.length > 0 ? existingBlockingFiles.filter((file) => guardPathKey(file, cwd) !== editedKey) : existingBlockingFiles;
|
|
8600
8877
|
let affectedFiles = [...existing?.affectedFiles ?? [], ...inlineFiles];
|
|
8601
8878
|
if (!entries.length && editedKey && existing) {
|
|
8602
8879
|
const isStillTestFailure = testFiles.some((file) => guardPathKey(file, cwd) === editedKey);
|
|
8603
|
-
const
|
|
8604
|
-
if (!isStillTestFailure && !
|
|
8880
|
+
const stillRecorded = partitions.some((partition) => !!blockingProvenance(partition.blockerContent, partition.blockingFiles, cwd)?.some((section) => section.key === editedKey));
|
|
8881
|
+
if (!isStillTestFailure && !stillRecorded) {
|
|
8605
8882
|
affectedFiles = affectedFiles.filter((file) => guardPathKey(file, cwd) !== editedKey);
|
|
8606
8883
|
}
|
|
8607
8884
|
}
|
|
8608
|
-
const
|
|
8609
|
-
const blockerContent = entries.length > 0 ? entries.map((entry) => `${entry.filePath}: ${entry.summary}`).join("\n") : clearedLastKnownBlocker ? void 0 : existing?.blockerContent;
|
|
8885
|
+
const blockerContent = fields.blockerContent;
|
|
8610
8886
|
const hasTestFailures = existing?.testFailures === true;
|
|
8611
|
-
const hasBlockers =
|
|
8887
|
+
const hasBlockers = partitions.length > 0 || hasTestFailures;
|
|
8612
8888
|
const content = [
|
|
8613
8889
|
blockerContent,
|
|
8614
8890
|
hasTestFailures ? existing?.testFailureContent : void 0
|
|
@@ -8616,20 +8892,29 @@ function syncGitGuardRecord(runtime, cacheManager2, cwd, editedFilePath, analysi
|
|
|
8616
8892
|
if (!hasBlockers && !content) {
|
|
8617
8893
|
cacheManager2.clearCache("turn-end-findings", cwd);
|
|
8618
8894
|
runtime.clearGitGuardCacheUnknown();
|
|
8895
|
+
if (droppedForeign > goneForeign)
|
|
8896
|
+
logRecordRetired(cwd, "write", "rechecked");
|
|
8897
|
+
else if (goneForeign > 0)
|
|
8898
|
+
logRecordRetired(cwd, "write", "file_gone");
|
|
8619
8899
|
return;
|
|
8620
8900
|
}
|
|
8901
|
+
if (goneForeign > 0)
|
|
8902
|
+
logSectionsDropped(cwd, "write", "file_gone");
|
|
8903
|
+
const owner = fields.owner ?? existing?.sessionId ?? me;
|
|
8621
8904
|
writeGitGuardRecord(cacheManager2, runtime, cwd, {
|
|
8622
8905
|
content: content || existing?.content || "",
|
|
8623
8906
|
blockerContent,
|
|
8624
|
-
blockingFiles:
|
|
8907
|
+
blockingFiles: fields.blockingFiles ?? [],
|
|
8908
|
+
carriedBlockers: fields.carriedBlockers,
|
|
8909
|
+
blockerWrittenAt: fields.blockerWrittenAt,
|
|
8625
8910
|
hasBlockers,
|
|
8626
8911
|
affectedFiles,
|
|
8627
|
-
sessionId:
|
|
8912
|
+
sessionId: owner,
|
|
8628
8913
|
projectSeqStart: runtime.turnStartProjectSeq,
|
|
8629
8914
|
projectSeqEnd: runtime.projectSeq,
|
|
8630
8915
|
fileSeqByPath,
|
|
8631
8916
|
fileContentHashes: {},
|
|
8632
|
-
consumed:
|
|
8917
|
+
consumed: owner !== me && existing?.consumed === true,
|
|
8633
8918
|
testFailures: existing?.testFailures,
|
|
8634
8919
|
testFailureContent: existing?.testFailureContent,
|
|
8635
8920
|
testFailureFiles: existing?.testFailureFiles
|
|
@@ -8643,6 +8928,7 @@ function mergeGitGuardTestFailure(cacheManager2, cwd, runtime, content, files) {
|
|
|
8643
8928
|
}
|
|
8644
8929
|
const failedFiles = files.map((file) => resolveGuardPath(file, cwd));
|
|
8645
8930
|
const blockerContent = existing?.blockerContent;
|
|
8931
|
+
const sessionId = recordOwner(existing, runtime, !!blockerContent);
|
|
8646
8932
|
const testFailureFiles = [
|
|
8647
8933
|
...existing?.testFailureFiles ?? [],
|
|
8648
8934
|
...failedFiles
|
|
@@ -8651,11 +8937,14 @@ function mergeGitGuardTestFailure(cacheManager2, cwd, runtime, content, files) {
|
|
|
8651
8937
|
content: [blockerContent, content].filter(Boolean).join("\n\n"),
|
|
8652
8938
|
blockerContent,
|
|
8653
8939
|
blockingFiles: existing?.blockingFiles ?? [],
|
|
8940
|
+
// #4738: other sessions' sections ride along with their owners.
|
|
8941
|
+
carriedBlockers: existing?.carriedBlockers,
|
|
8942
|
+
blockerWrittenAt: existing?.blockerWrittenAt,
|
|
8654
8943
|
testFailureContent: content,
|
|
8655
8944
|
testFailureFiles,
|
|
8656
8945
|
hasBlockers: true,
|
|
8657
8946
|
affectedFiles: [...existing?.affectedFiles ?? [], ...failedFiles],
|
|
8658
|
-
sessionId
|
|
8947
|
+
sessionId,
|
|
8659
8948
|
projectSeqStart: runtime.turnStartProjectSeq,
|
|
8660
8949
|
projectSeqEnd: runtime.projectSeq,
|
|
8661
8950
|
fileSeqByPath,
|
|
@@ -8673,9 +8962,13 @@ function clearGitGuardTestFailure(cacheManager2, cwd, runtime, passedFiles = [])
|
|
|
8673
8962
|
const blockerContent = existing.blockerContent ?? "";
|
|
8674
8963
|
if (!blockerContent && remainingFiles.length === 0) {
|
|
8675
8964
|
cacheManager2.clearCache("turn-end-findings", cwd);
|
|
8965
|
+
runtime.clearGitGuardCacheUnknown();
|
|
8676
8966
|
return;
|
|
8677
8967
|
}
|
|
8678
|
-
const blockingKeys = new Set(
|
|
8968
|
+
const blockingKeys = new Set([
|
|
8969
|
+
...existing.blockingFiles ?? [],
|
|
8970
|
+
...(existing.carriedBlockers ?? []).flatMap((partition) => partition.blockingFiles)
|
|
8971
|
+
].map((file) => guardPathKey(file, cwd)));
|
|
8679
8972
|
const affectedFiles = existing.affectedFiles.filter((file) => blockingKeys.has(guardPathKey(file, cwd)) || remainingFiles.some((testFile) => guardPathKey(testFile, cwd) === guardPathKey(file, cwd)));
|
|
8680
8973
|
writeGitGuardRecord(cacheManager2, runtime, cwd, {
|
|
8681
8974
|
...existing,
|
|
@@ -8686,7 +8979,9 @@ function clearGitGuardTestFailure(cacheManager2, cwd, runtime, passedFiles = [])
|
|
|
8686
8979
|
testFailureContent: remainingFiles.length > 0 ? existing.testFailureContent : void 0,
|
|
8687
8980
|
testFailureFiles: remainingFiles.length > 0 ? remainingFiles : void 0,
|
|
8688
8981
|
hasBlockers: !!blockerContent || remainingFiles.length > 0,
|
|
8689
|
-
|
|
8982
|
+
// #4733 r1 F1: a passing run re-checks its tests, not the stored
|
|
8983
|
+
// sections, so they keep their owner.
|
|
8984
|
+
sessionId: recordOwner(existing, runtime, !!blockerContent),
|
|
8690
8985
|
projectSeqStart: runtime.turnStartProjectSeq,
|
|
8691
8986
|
projectSeqEnd: runtime.projectSeq,
|
|
8692
8987
|
fileSeqByPath: Object.fromEntries(runtime.getFileSeqEntries().map(([filePath, seq]) => [guardPathKey(filePath, cwd), seq])),
|
|
@@ -9278,14 +9573,14 @@ function emitLensTurnFindings(payload) {
|
|
|
9278
9573
|
}
|
|
9279
9574
|
|
|
9280
9575
|
// dist/clients/test-target-roots.js
|
|
9281
|
-
import { dirname as
|
|
9576
|
+
import { dirname as dirname6 } from "node:path";
|
|
9282
9577
|
function createTurnEndTestRoots(sessionCwd) {
|
|
9283
9578
|
const session = resolveGitCheckout(sessionCwd);
|
|
9284
9579
|
const ownerByDir = /* @__PURE__ */ new Map();
|
|
9285
9580
|
return (absoluteFile) => {
|
|
9286
9581
|
if (session === null)
|
|
9287
9582
|
return sessionCwd;
|
|
9288
|
-
const dir =
|
|
9583
|
+
const dir = dirname6(absoluteFile);
|
|
9289
9584
|
let owner = ownerByDir.get(dir);
|
|
9290
9585
|
if (owner === void 0) {
|
|
9291
9586
|
owner = resolveLinkedWorktreeOwner(session, absoluteFile);
|
|
@@ -9347,7 +9642,7 @@ function sweepInlineBlockerPastEof(runtime, cwd, options) {
|
|
|
9347
9642
|
}
|
|
9348
9643
|
|
|
9349
9644
|
// dist/clients/persistent-reverify.js
|
|
9350
|
-
import * as
|
|
9645
|
+
import * as fs14 from "node:fs";
|
|
9351
9646
|
var MAX_REVERIFY_FILES = 4;
|
|
9352
9647
|
var REVERIFY_BUDGET_MS = 3e3;
|
|
9353
9648
|
var TOUCH_SOURCE = "persistent_reverify";
|
|
@@ -9365,7 +9660,7 @@ function selectPersistentReverifyFiles(report, nowMs = Date.now()) {
|
|
|
9365
9660
|
continue;
|
|
9366
9661
|
let mtimeMs;
|
|
9367
9662
|
try {
|
|
9368
|
-
mtimeMs =
|
|
9663
|
+
mtimeMs = fs14.statSync(entry.filePath).mtimeMs;
|
|
9369
9664
|
} catch {
|
|
9370
9665
|
continue;
|
|
9371
9666
|
}
|
|
@@ -9407,7 +9702,7 @@ async function runPersistentReverify(args) {
|
|
|
9407
9702
|
processed += 1;
|
|
9408
9703
|
let content;
|
|
9409
9704
|
try {
|
|
9410
|
-
content =
|
|
9705
|
+
content = fs14.readFileSync(entry.filePath, "utf-8");
|
|
9411
9706
|
} catch {
|
|
9412
9707
|
outcomes.push({
|
|
9413
9708
|
filePath: entry.filePath,
|
|
@@ -9511,11 +9806,11 @@ async function runPersistentReverify(args) {
|
|
|
9511
9806
|
}
|
|
9512
9807
|
|
|
9513
9808
|
// dist/clients/inline-blocker-dispositions.js
|
|
9514
|
-
import * as
|
|
9809
|
+
import * as fs15 from "node:fs";
|
|
9515
9810
|
import * as path23 from "node:path";
|
|
9516
9811
|
function readCurrentContent(filePath) {
|
|
9517
9812
|
try {
|
|
9518
|
-
return
|
|
9813
|
+
return fs15.readFileSync(filePath, "utf-8");
|
|
9519
9814
|
} catch {
|
|
9520
9815
|
return "";
|
|
9521
9816
|
}
|
|
@@ -9787,8 +10082,9 @@ function deadCodeScanEvent(client, cwd, result, durationMs) {
|
|
|
9787
10082
|
...!result.success && { reason: result.summary }
|
|
9788
10083
|
};
|
|
9789
10084
|
}
|
|
9790
|
-
function dropLateDeadCodeScan(scans, key, client, reason) {
|
|
9791
|
-
scans.
|
|
10085
|
+
function dropLateDeadCodeScan(scans, key, entry, client, reason) {
|
|
10086
|
+
if (scans.get(key) === entry)
|
|
10087
|
+
scans.delete(key);
|
|
9792
10088
|
incrementDegradationCount({
|
|
9793
10089
|
kind: "dead-code-late-scan-dropped",
|
|
9794
10090
|
subject: client.id,
|
|
@@ -9807,28 +10103,39 @@ function parkLateDeadCodeScan(args) {
|
|
|
9807
10103
|
askedAt: startedAt
|
|
9808
10104
|
};
|
|
9809
10105
|
scans.set(key, entry);
|
|
9810
|
-
|
|
10106
|
+
const watch = withRowForFailureWrite(args.scan, cacheManager2, cacheKey, cwd, entry.previousScan ? { data: entry.previousScan } : null).then(({ result, row }) => {
|
|
9811
10107
|
if (!scope.isLive()) {
|
|
9812
|
-
dropLateDeadCodeScan(scans, key, client, "session-ended");
|
|
10108
|
+
dropLateDeadCodeScan(scans, key, entry, client, "session-ended");
|
|
9813
10109
|
return;
|
|
9814
10110
|
}
|
|
9815
10111
|
const durationMs = Date.now() - startedAt;
|
|
9816
10112
|
const cacheKept = wouldPoisonCache(row, result);
|
|
9817
10113
|
if (!cacheKept) {
|
|
9818
|
-
|
|
9819
|
-
|
|
9820
|
-
|
|
10114
|
+
try {
|
|
10115
|
+
cacheManager2.writeCache(cacheKey, result, cwd, {
|
|
10116
|
+
scanDurationMs: durationMs
|
|
10117
|
+
});
|
|
10118
|
+
} catch (err) {
|
|
10119
|
+
incrementDegradationCount({
|
|
10120
|
+
kind: "dead-code-baseline-write-failed",
|
|
10121
|
+
subject: client.id,
|
|
10122
|
+
reason: String(err)
|
|
10123
|
+
});
|
|
10124
|
+
}
|
|
9821
10125
|
}
|
|
9822
10126
|
logDeadCodeScan({
|
|
9823
10127
|
...deadCodeScanEvent(client, cwd, result, durationMs),
|
|
9824
10128
|
...cacheKept && { cacheKept }
|
|
9825
10129
|
});
|
|
9826
10130
|
if (!result.success) {
|
|
9827
|
-
dropLateDeadCodeScan(scans, key, client, `scan-failed: ${result.summary}`);
|
|
10131
|
+
dropLateDeadCodeScan(scans, key, entry, client, `scan-failed: ${result.summary}`);
|
|
9828
10132
|
return;
|
|
9829
10133
|
}
|
|
9830
10134
|
entry.settled = result;
|
|
9831
|
-
}, (err) => dropLateDeadCodeScan(scans, key, client, `scan-threw: ${err}`));
|
|
10135
|
+
}, (err) => dropLateDeadCodeScan(scans, key, entry, client, `scan-threw: ${err}`));
|
|
10136
|
+
void watch.catch((err) => {
|
|
10137
|
+
dropLateDeadCodeScan(scans, key, entry, client, `scan-settle-threw: ${err}`);
|
|
10138
|
+
});
|
|
9832
10139
|
}
|
|
9833
10140
|
var lspIdleResetTimeout = null;
|
|
9834
10141
|
var pendingSweepRearm = null;
|
|
@@ -9963,6 +10270,50 @@ function formatWriteOrdinal(n) {
|
|
|
9963
10270
|
return `${n}th`;
|
|
9964
10271
|
}
|
|
9965
10272
|
}
|
|
10273
|
+
function resyncCommitGateForReadOnlyTurn(args) {
|
|
10274
|
+
if (!args.lensGuardEnabled)
|
|
10275
|
+
return;
|
|
10276
|
+
if (!args.runtime.gitGuardHasBlockers)
|
|
10277
|
+
return;
|
|
10278
|
+
if (!hasAnyDispositionMarks(args.cwd))
|
|
10279
|
+
return;
|
|
10280
|
+
const inlinePolicyEntries = [];
|
|
10281
|
+
const policySuppressedPaths = [];
|
|
10282
|
+
const inlinePolicyStart = Date.now();
|
|
10283
|
+
for (const entry of args.runtime.getInlineBlockersSnapshot()) {
|
|
10284
|
+
const tally = {
|
|
10285
|
+
displayPath: toRunnerDisplayPath(args.cwd, entry.filePath),
|
|
10286
|
+
sources: entry.sources
|
|
10287
|
+
};
|
|
10288
|
+
if (entry.stale) {
|
|
10289
|
+
inlinePolicyEntries.push({ ...tally, stale: true });
|
|
10290
|
+
continue;
|
|
10291
|
+
}
|
|
10292
|
+
const policy = applyInlineBlockerPolicy(entry, args.cwd);
|
|
10293
|
+
inlinePolicyEntries.push({ ...tally, stale: false, outcome: policy });
|
|
10294
|
+
if (policy.body === void 0)
|
|
10295
|
+
policySuppressedPaths.push(entry.filePath);
|
|
10296
|
+
}
|
|
10297
|
+
if (inlinePolicyEntries.length === 0)
|
|
10298
|
+
return;
|
|
10299
|
+
const guardLatchBefore = args.runtime.gitGuardHasBlockers;
|
|
10300
|
+
resyncGitGuardAfterInlinePolicy({
|
|
10301
|
+
runtime: args.runtime,
|
|
10302
|
+
suppressedFilePaths: policySuppressedPaths
|
|
10303
|
+
});
|
|
10304
|
+
logLatency({
|
|
10305
|
+
type: "phase",
|
|
10306
|
+
toolName: "turn_end",
|
|
10307
|
+
filePath: args.cwd,
|
|
10308
|
+
phase: "inline_blocker_policy",
|
|
10309
|
+
durationMs: Date.now() - inlinePolicyStart,
|
|
10310
|
+
metadata: {
|
|
10311
|
+
...summarizeInlineBlockerPolicy(inlinePolicyEntries),
|
|
10312
|
+
guardFilesSuppressed: policySuppressedPaths.length,
|
|
10313
|
+
guardLatchCleared: guardLatchBefore && !args.runtime.gitGuardHasBlockers
|
|
10314
|
+
}
|
|
10315
|
+
});
|
|
10316
|
+
}
|
|
9966
10317
|
async function handleTurnEnd(deps) {
|
|
9967
10318
|
const { ctxCwd, getFlag, dbg, runtime, cacheManager: cacheManager2, knipClient, deadCodeClients, depChecker, testRunnerClient, sessionId, host = "pi", owner, resetLSPService: resetLSPService2, resetFormatService: resetFormatService2 } = deps;
|
|
9968
10319
|
const turnIndexAtDispatch = runtime.turnIndex;
|
|
@@ -10020,11 +10371,13 @@ async function handleTurnEnd(deps) {
|
|
|
10020
10371
|
}
|
|
10021
10372
|
}
|
|
10022
10373
|
if (files.length === 0 && !runtime.hasCascadeRuns() && !isSecondarySession) {
|
|
10374
|
+
resyncCommitGateForReadOnlyTurn({
|
|
10375
|
+
runtime,
|
|
10376
|
+
cwd,
|
|
10377
|
+
lensGuardEnabled: Boolean(getFlag("lens-guard"))
|
|
10378
|
+
});
|
|
10023
10379
|
if (getFlag("lens-guard") && !runtime.gitGuardHasBlockers) {
|
|
10024
|
-
|
|
10025
|
-
if (guardRecord?.sessionId === runtime.telemetrySessionId && guardRecord.testFailures !== true) {
|
|
10026
|
-
cacheManager2.clearCache("turn-end-findings", cwd);
|
|
10027
|
-
}
|
|
10380
|
+
retireSettledGitGuardRecord(runtime, cacheManager2, cwd);
|
|
10028
10381
|
}
|
|
10029
10382
|
const idleResetMs = getEffectiveLspIdleResetMs();
|
|
10030
10383
|
dbg(`turn_end: no modified files, scheduling LSP idle reset (${idleResetMs / 1e3}s)`);
|
|
@@ -11474,15 +11827,15 @@ ${lines.join("\n")}`;
|
|
|
11474
11827
|
incrementDegradationCount({
|
|
11475
11828
|
kind: "test-runner-batch-capped",
|
|
11476
11829
|
subject: `${cwd}:deferral-exhausted`,
|
|
11477
|
-
reason: `test target was cut after ${attempts} turn(s) at the turn-end budget and is retired for this session \u2014 too slow for a per-turn batch; run it explicitly (target: ${
|
|
11830
|
+
reason: `test target was cut after ${attempts} turn(s) at the turn-end budget and is retired for this session \u2014 too slow for a per-turn batch; run it explicitly (target: ${toRunnerDisplayPath(cwd, testFile)})`
|
|
11478
11831
|
});
|
|
11479
|
-
dbg(`turn_end: retiring deferred test target ${
|
|
11832
|
+
dbg(`turn_end: retiring deferred test target ${toRunnerDisplayPath(cwd, testFile)} after ${attempts} cut batch(es) \u2014 too slow for the turn-end budget, run it explicitly`);
|
|
11480
11833
|
}
|
|
11481
11834
|
continue;
|
|
11482
11835
|
}
|
|
11483
11836
|
const config = RUNNERS[carried.runner];
|
|
11484
11837
|
const carriedRoot = testRootFor(testFile);
|
|
11485
|
-
if (!config || isExcludedTestTarget(testFile, carriedRoot) || !
|
|
11838
|
+
if (!config || isExcludedTestTarget(testFile, carriedRoot) || !fs16.existsSync(testFile)) {
|
|
11486
11839
|
resolvedDeferralKeys.add(carriedKey);
|
|
11487
11840
|
deadDeferred++;
|
|
11488
11841
|
continue;
|
|
@@ -11510,7 +11863,7 @@ ${lines.join("\n")}`;
|
|
|
11510
11863
|
testRoot: carriedRoot,
|
|
11511
11864
|
deferralAttempts: attempts
|
|
11512
11865
|
});
|
|
11513
|
-
dbg(`turn_end: re-running deferred test target ${
|
|
11866
|
+
dbg(`turn_end: re-running deferred test target ${toRunnerDisplayPath(cwd, testFile)} (${carried.runner}) from the previous turn's cut batch`);
|
|
11514
11867
|
}
|
|
11515
11868
|
if (deadDeferred > 0) {
|
|
11516
11869
|
dbg(`turn_end: dropped ${deadDeferred} deferred test target(s) that no longer resolve (missing file, excluded, or unknown runner)`);
|
|
@@ -11554,17 +11907,17 @@ ${lines.join("\n")}`;
|
|
|
11554
11907
|
seen2.add(targetKey);
|
|
11555
11908
|
if (retiredKeys.has(targetKey)) {
|
|
11556
11909
|
retiredSkips++;
|
|
11557
|
-
dbg(`turn_end: ${display} \u2192 test target retired earlier this session (outran the turn-end batch budget), skipping spawn (${
|
|
11910
|
+
dbg(`turn_end: ${display} \u2192 test target retired earlier this session (outran the turn-end batch budget), skipping spawn (${toRunnerDisplayPath(cwd, target.testFile)})`);
|
|
11558
11911
|
continue;
|
|
11559
11912
|
}
|
|
11560
11913
|
if (isExcludedTestTarget(target.testFile, testRoot)) {
|
|
11561
11914
|
excludedTargets++;
|
|
11562
|
-
dbg(`turn_end: ${display} \u2192 test target excluded by the built-in turn-end policy, skipping spawn (${
|
|
11915
|
+
dbg(`turn_end: ${display} \u2192 test target excluded by the built-in turn-end policy, skipping spawn (${toRunnerDisplayPath(cwd, target.testFile)})`);
|
|
11563
11916
|
continue;
|
|
11564
11917
|
}
|
|
11565
|
-
if (!
|
|
11918
|
+
if (!fs16.existsSync(target.testFile)) {
|
|
11566
11919
|
missingTargetFiles++;
|
|
11567
|
-
dbg(`turn_end: ${display} \u2192 test file missing, skipping spawn (${
|
|
11920
|
+
dbg(`turn_end: ${display} \u2192 test file missing, skipping spawn (${toRunnerDisplayPath(cwd, target.testFile)})`);
|
|
11568
11921
|
continue;
|
|
11569
11922
|
}
|
|
11570
11923
|
if (targets.length >= TEST_RUNNER_MAX_TARGETS) {
|
|
@@ -11572,7 +11925,7 @@ ${lines.join("\n")}`;
|
|
|
11572
11925
|
continue;
|
|
11573
11926
|
}
|
|
11574
11927
|
targets.push({ ...target, sourceFile: abs, testRoot });
|
|
11575
|
-
dbg(`turn_end: ${display} \u2192 test ${target.runner} ${
|
|
11928
|
+
dbg(`turn_end: ${display} \u2192 test ${target.runner} ${toRunnerDisplayPath(cwd, target.testFile)} (${target.strategy}${isNeighbor ? ", cascade-neighbor" : ""})`);
|
|
11576
11929
|
} else if (!target) {
|
|
11577
11930
|
noTestFile++;
|
|
11578
11931
|
dbg(`turn_end: ${display} \u2192 no test file found${isNeighbor ? " (cascade-neighbor)" : ""}`);
|
|
@@ -11736,7 +12089,7 @@ ${lines.join("\n")}`;
|
|
|
11736
12089
|
});
|
|
11737
12090
|
dbg(`turn_end: test batch stopped early (${stopReason ?? "incomplete"}), ${deferred.length} target(s) deferred to the next turn`);
|
|
11738
12091
|
}
|
|
11739
|
-
const deferralNote = deferred.length > 0 ? `${deferred.length} test target(s) did not finish within the turn-end batch budget and are deferred to the next turn (they run first): ${deferredTargets.map((t) =>
|
|
12092
|
+
const deferralNote = deferred.length > 0 ? `${deferred.length} test target(s) did not finish within the turn-end batch budget and are deferred to the next turn (they run first): ${deferredTargets.map((t) => toRunnerDisplayPath(cwd, t.testFile)).join(", ")}` : "";
|
|
11740
12093
|
const supersededByNewerGeneration = (label) => {
|
|
11741
12094
|
const current = cacheManager2.readCache("test-runner-findings", cwd)?.data;
|
|
11742
12095
|
const currentGeneration = current?.testRunGeneration;
|
|
@@ -11952,8 +12305,8 @@ ${lines.join("\n")}`;
|
|
|
11952
12305
|
} else {
|
|
11953
12306
|
const callGraphStart = Date.now();
|
|
11954
12307
|
try {
|
|
11955
|
-
const { impact, formatImpact, parseSymbolKey } = await import("../chunk-
|
|
11956
|
-
const { callGraphImpactToProjectDiagnostics } = await import("../chunk-
|
|
12308
|
+
const { impact, formatImpact, parseSymbolKey } = await import("../chunk-S67UJDGQ.js");
|
|
12309
|
+
const { callGraphImpactToProjectDiagnostics } = await import("../chunk-GMTFDAOK.js");
|
|
11957
12310
|
const impactLines = [];
|
|
11958
12311
|
let callGraphDispositionSuppressed = 0;
|
|
11959
12312
|
const impactFindings = [];
|
|
@@ -12314,7 +12667,7 @@ ${impactLines.join("\n")}`;
|
|
|
12314
12667
|
if (!lateAuxContentRead) {
|
|
12315
12668
|
lateAuxContentRead = true;
|
|
12316
12669
|
try {
|
|
12317
|
-
lateAuxContentValue =
|
|
12670
|
+
lateAuxContentValue = fs16.readFileSync(lateAuxPath, "utf-8");
|
|
12318
12671
|
} catch {
|
|
12319
12672
|
lateAuxContentValue = void 0;
|
|
12320
12673
|
}
|
|
@@ -12638,14 +12991,26 @@ ${raw}`
|
|
|
12638
12991
|
resolvedBlockerFileList.length === 0) {
|
|
12639
12992
|
dbg("turn_end: duplicate findings detected (same session), suppressing re-prompt");
|
|
12640
12993
|
if (getFlag("lens-guard")) {
|
|
12641
|
-
const
|
|
12642
|
-
if (
|
|
12994
|
+
const { stored: existingGuard2, carried: carried2, dropped: dropped2 } = readTurnEndGuardRecord(cacheManager2, runtime, cwd);
|
|
12995
|
+
if (existingGuard2) {
|
|
12996
|
+
const own = blockerParts.length > 0 ? [
|
|
12997
|
+
{
|
|
12998
|
+
sessionId: runtime.telemetrySessionId,
|
|
12999
|
+
blockerContent: capTurnEndMessage(blockerParts.join("\n\n")),
|
|
13000
|
+
blockingFiles: existingGuard2.affectedFiles ?? [],
|
|
13001
|
+
blockerWrittenAt: Date.now()
|
|
13002
|
+
}
|
|
13003
|
+
] : [];
|
|
13004
|
+
const blockers = blockerPartitionFields([...own, ...carried2]);
|
|
12643
13005
|
writeGitGuardRecord(cacheManager2, runtime, cwd, {
|
|
12644
|
-
...
|
|
13006
|
+
...existingGuard2,
|
|
13007
|
+
sessionId: blockers.owner ?? runtime.telemetrySessionId,
|
|
12645
13008
|
content,
|
|
12646
|
-
blockerContent:
|
|
12647
|
-
|
|
12648
|
-
|
|
13009
|
+
blockerContent: blockers.blockerContent,
|
|
13010
|
+
carriedBlockers: blockers.carriedBlockers,
|
|
13011
|
+
blockerWrittenAt: blockers.blockerWrittenAt,
|
|
13012
|
+
hasBlockers: blockers.owner !== void 0 || existingGuard2.testFailures === true,
|
|
13013
|
+
blockingFiles: blockers.blockingFiles,
|
|
12649
13014
|
projectSeqStart: runtime.turnStartProjectSeq,
|
|
12650
13015
|
projectSeqEnd: runtime.projectSeq,
|
|
12651
13016
|
fileSeqByPath: Object.fromEntries(runtime.getFileSeqEntries().map(([filePath, seq]) => [
|
|
@@ -12655,6 +13020,7 @@ ${raw}`
|
|
|
12655
13020
|
fileContentHashes: {},
|
|
12656
13021
|
consumed: false
|
|
12657
13022
|
});
|
|
13023
|
+
logCarriedDrops(cwd, dropped2);
|
|
12658
13024
|
}
|
|
12659
13025
|
}
|
|
12660
13026
|
settleHolds(true);
|
|
@@ -12668,21 +13034,32 @@ ${raw}`
|
|
|
12668
13034
|
for (const [filePath, seq] of runtime.getFileSeqEntries()) {
|
|
12669
13035
|
fileSeqByPath2[normalizeMapKey(path24.resolve(filePath))] = seq;
|
|
12670
13036
|
}
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
const blockingContent = blockerParts.length > 0 ? capTurnEndMessage(blockerParts.join("\n\n")) : void 0;
|
|
13037
|
+
const { stored: existingGuard, carried, dropped } = readTurnEndGuardRecord(cacheManager2, runtime, cwd);
|
|
13038
|
+
if (getFlag("lens-guard") || carried.length > 0) {
|
|
13039
|
+
const blockingContent = getFlag("lens-guard") && blockerParts.length > 0 ? capTurnEndMessage(blockerParts.join("\n\n")) : void 0;
|
|
12674
13040
|
const affectedFiles = [
|
|
12675
13041
|
...existingGuard?.affectedFiles ?? [],
|
|
12676
13042
|
...files.map((file) => resolveRunnerPath(cwd, file)),
|
|
12677
13043
|
...cascadeResults.flatMap((result) => result.neighbors.filter((neighbor) => neighbor.diagnostics.length > 0).map((neighbor) => resolveRunnerPath(cwd, neighbor.filePath)))
|
|
12678
13044
|
];
|
|
13045
|
+
const own = blockingContent ? [
|
|
13046
|
+
{
|
|
13047
|
+
sessionId: runtime.telemetrySessionId,
|
|
13048
|
+
blockerContent: blockingContent,
|
|
13049
|
+
blockingFiles: affectedFiles,
|
|
13050
|
+
blockerWrittenAt: Date.now()
|
|
13051
|
+
}
|
|
13052
|
+
] : [];
|
|
13053
|
+
const blockers = blockerPartitionFields([...own, ...carried]);
|
|
12679
13054
|
writeGitGuardRecord(cacheManager2, runtime, cwd, {
|
|
12680
13055
|
content: [content, existingGuard?.testFailureContent].filter((value) => !!value).join("\n\n"),
|
|
12681
|
-
blockerContent:
|
|
12682
|
-
blockingFiles:
|
|
12683
|
-
|
|
13056
|
+
blockerContent: blockers.blockerContent,
|
|
13057
|
+
blockingFiles: blockers.blockingFiles,
|
|
13058
|
+
carriedBlockers: blockers.carriedBlockers,
|
|
13059
|
+
blockerWrittenAt: blockers.blockerWrittenAt,
|
|
13060
|
+
hasBlockers: blockers.owner !== void 0 || existingGuard?.testFailures === true,
|
|
12684
13061
|
affectedFiles,
|
|
12685
|
-
sessionId: runtime.telemetrySessionId,
|
|
13062
|
+
sessionId: blockers.owner ?? runtime.telemetrySessionId,
|
|
12686
13063
|
projectSeqStart: runtime.turnStartProjectSeq,
|
|
12687
13064
|
projectSeqEnd: runtime.projectSeq,
|
|
12688
13065
|
fileSeqByPath: fileSeqByPath2,
|
|
@@ -12694,6 +13071,8 @@ ${raw}`
|
|
|
12694
13071
|
});
|
|
12695
13072
|
} else {
|
|
12696
13073
|
const allAffectedFiles = [
|
|
13074
|
+
// #4617: confirmed-clean checks can resolve a file without writing it.
|
|
13075
|
+
...resolvedBlockerFileList.map((entry) => entry.filePath),
|
|
12697
13076
|
...files.map((file) => resolveRunnerPath(cwd, file)),
|
|
12698
13077
|
...cascadeResults.flatMap((result) => result.neighbors.filter((neighbor) => neighbor.diagnostics.length > 0).map((neighbor) => resolveRunnerPath(cwd, neighbor.filePath)))
|
|
12699
13078
|
];
|
|
@@ -12715,6 +13094,7 @@ ${raw}`
|
|
|
12715
13094
|
})
|
|
12716
13095
|
}, cwd);
|
|
12717
13096
|
}
|
|
13097
|
+
logCarriedDrops(cwd, dropped);
|
|
12718
13098
|
cacheManager2.writeCache("turn-end-findings-last", {
|
|
12719
13099
|
signature,
|
|
12720
13100
|
sessionId: runtime.telemetrySessionId,
|
|
@@ -12737,10 +13117,7 @@ ${raw}`
|
|
|
12737
13117
|
// so it must not be erased by the no-blockers clean-up. The
|
|
12738
13118
|
// reader clears it after delivery because `hasBlockers` is false.
|
|
12739
13119
|
resolvedParts.length === 0 && !runtime.gitGuardHasBlockers) {
|
|
12740
|
-
|
|
12741
|
-
if (guardRecord?.sessionId === runtime.telemetrySessionId && guardRecord.testFailures !== true) {
|
|
12742
|
-
cacheManager2.clearCache("turn-end-findings", cwd);
|
|
12743
|
-
}
|
|
13120
|
+
retireSettledGitGuardRecord(runtime, cacheManager2, cwd);
|
|
12744
13121
|
}
|
|
12745
13122
|
}
|
|
12746
13123
|
runtime.fixedThisTurn.clear();
|
|
@@ -12934,7 +13311,7 @@ async function runTurnEndNowImpl(cwd, files = [], deferredDelivery = false) {
|
|
|
12934
13311
|
const abs = path25.isAbsolute(file) ? file : path25.resolve(cwd, file);
|
|
12935
13312
|
let lineCount3 = 1;
|
|
12936
13313
|
try {
|
|
12937
|
-
lineCount3 =
|
|
13314
|
+
lineCount3 = fs17.readFileSync(abs, "utf8").split("\n").length;
|
|
12938
13315
|
} catch {
|
|
12939
13316
|
continue;
|
|
12940
13317
|
}
|
|
@@ -13068,7 +13445,7 @@ function acknowledgeTurnEnd(cwd, deliveryId) {
|
|
|
13068
13445
|
}
|
|
13069
13446
|
|
|
13070
13447
|
// dist/clients/module-report.js
|
|
13071
|
-
import * as
|
|
13448
|
+
import * as fs18 from "node:fs";
|
|
13072
13449
|
import * as path26 from "node:path";
|
|
13073
13450
|
|
|
13074
13451
|
// dist/clients/middle-man-analysis.js
|
|
@@ -13618,7 +13995,7 @@ function blastReadArgs(graph, normalizedFile) {
|
|
|
13618
13995
|
return { path: normalizedFile, offset: 1, limit };
|
|
13619
13996
|
}
|
|
13620
13997
|
async function computeBlastRadius(graph, normalizedPath, projectRoot, maxDepth) {
|
|
13621
|
-
const { computeTransitiveImpact } = await import("../chunk-
|
|
13998
|
+
const { computeTransitiveImpact } = await import("../chunk-XCUHKYCQ.js");
|
|
13622
13999
|
const result = computeTransitiveImpact(graph, normalizedPath, { maxDepth });
|
|
13623
14000
|
const byFile = /* @__PURE__ */ new Map();
|
|
13624
14001
|
for (const hit of result.hits) {
|
|
@@ -14212,7 +14589,7 @@ async function moduleReport(file, cwd, options) {
|
|
|
14212
14589
|
const normalizedPath = normalizeMapKey(absPath);
|
|
14213
14590
|
let content;
|
|
14214
14591
|
try {
|
|
14215
|
-
content =
|
|
14592
|
+
content = fs18.readFileSync(absPath, "utf-8");
|
|
14216
14593
|
} catch {
|
|
14217
14594
|
return unavailableReport(toDisplayPath(absPath, cwd));
|
|
14218
14595
|
}
|
|
@@ -14235,7 +14612,7 @@ async function moduleReport(file, cwd, options) {
|
|
|
14235
14612
|
let callGraphIdentity;
|
|
14236
14613
|
let revisionDriftNote;
|
|
14237
14614
|
try {
|
|
14238
|
-
const { getCachedReviewGraph, getReviewGraphCacheIdentity, getReviewGraphSizeSkipVerdict, getReviewGraphRevisionDrift, formatReviewGraphRevisionDriftNote: formatReviewGraphRevisionDriftNote2 } = await import("../chunk-
|
|
14615
|
+
const { getCachedReviewGraph, getReviewGraphCacheIdentity, getReviewGraphSizeSkipVerdict, getReviewGraphRevisionDrift, formatReviewGraphRevisionDriftNote: formatReviewGraphRevisionDriftNote2 } = await import("../chunk-T7FTXGS3.js");
|
|
14239
14616
|
graph = getCachedReviewGraph(cwd);
|
|
14240
14617
|
graphFileCap = getReviewGraphSizeSkipVerdict(cwd)?.maxFileCount;
|
|
14241
14618
|
const drift = graph ? getReviewGraphRevisionDrift(cwd) : void 0;
|
|
@@ -14537,7 +14914,7 @@ async function readSymbol(file, symbolName, cwd, options = {}) {
|
|
|
14537
14914
|
};
|
|
14538
14915
|
let content;
|
|
14539
14916
|
try {
|
|
14540
|
-
content =
|
|
14917
|
+
content = fs18.readFileSync(absPath, "utf-8");
|
|
14541
14918
|
} catch {
|
|
14542
14919
|
log(false);
|
|
14543
14920
|
return { found: false, path: absPath, name: symbolName };
|
|
@@ -14713,7 +15090,7 @@ async function readEnclosing(file, line, cwd, options) {
|
|
|
14713
15090
|
};
|
|
14714
15091
|
let content;
|
|
14715
15092
|
try {
|
|
14716
|
-
content =
|
|
15093
|
+
content = fs18.readFileSync(absPath, "utf-8");
|
|
14717
15094
|
} catch {
|
|
14718
15095
|
log(false);
|
|
14719
15096
|
return { found: false, path: absPath, line: targetLine };
|
|
@@ -15019,7 +15396,7 @@ function roleFor(graph, filePath) {
|
|
|
15019
15396
|
return top.length > 0 ? top.map((s) => s.name).join(", ") : void 0;
|
|
15020
15397
|
}
|
|
15021
15398
|
async function computeHubs(graph, degrees, cwd, limit, focusTerms) {
|
|
15022
|
-
const { computeTransitiveImpact } = await import("../chunk-
|
|
15399
|
+
const { computeTransitiveImpact } = await import("../chunk-XCUHKYCQ.js");
|
|
15023
15400
|
const ranked = [...graph.fileNodes.entries()].map(([filePath, fileNodeId]) => ({
|
|
15024
15401
|
filePath,
|
|
15025
15402
|
fileNodeId,
|
|
@@ -15271,7 +15648,7 @@ async function projectReport(cwd, options) {
|
|
|
15271
15648
|
const limit = clampLimit(options?.limit);
|
|
15272
15649
|
const focusTerms = normalizeFocus2(options?.focus);
|
|
15273
15650
|
const view = options?.view;
|
|
15274
|
-
const { getCachedReviewGraph, getReviewGraphSizeSkipVerdict, getLastReviewGraphBuildAttempt, buildOrUpdateGraph, isGraphBuildInFlight, getReviewGraphRevisionDrift } = await import("../chunk-
|
|
15651
|
+
const { getCachedReviewGraph, getReviewGraphSizeSkipVerdict, getLastReviewGraphBuildAttempt, buildOrUpdateGraph, isGraphBuildInFlight, getReviewGraphRevisionDrift } = await import("../chunk-T7FTXGS3.js");
|
|
15275
15652
|
let graph;
|
|
15276
15653
|
try {
|
|
15277
15654
|
graph = getCachedReviewGraph(cwd);
|
|
@@ -15295,7 +15672,7 @@ async function projectReport(cwd, options) {
|
|
|
15295
15672
|
};
|
|
15296
15673
|
}
|
|
15297
15674
|
const previousAttempt = getLastReviewGraphBuildAttempt(cwd);
|
|
15298
|
-
const { FactStore: FactStore2 } = await import("../chunk-
|
|
15675
|
+
const { FactStore: FactStore2 } = await import("../chunk-F6X3YJWD.js");
|
|
15299
15676
|
const trigger = triggerBackgroundGraphBuild(cwd, {
|
|
15300
15677
|
buildOrUpdateGraph,
|
|
15301
15678
|
isGraphBuildInFlight,
|
|
@@ -15720,7 +16097,7 @@ async function symbolSearch(query, cwd, limit = 20, options = {}) {
|
|
|
15720
16097
|
warmLease.release();
|
|
15721
16098
|
}
|
|
15722
16099
|
const hits = results.map(toSymbolSearchHit);
|
|
15723
|
-
const { getCachedReviewGraph } = await import("../chunk-
|
|
16100
|
+
const { getCachedReviewGraph } = await import("../chunk-T7FTXGS3.js");
|
|
15724
16101
|
const graph = getCachedReviewGraph(cwd);
|
|
15725
16102
|
if (graph)
|
|
15726
16103
|
annotateSymbolSearchHitsWithGraph(hits, centrality, graph);
|
|
@@ -15950,6 +16327,18 @@ var LANGUAGES = [
|
|
|
15950
16327
|
"typescript",
|
|
15951
16328
|
"yaml"
|
|
15952
16329
|
];
|
|
16330
|
+
function readAstGrepLang(rawArg, required) {
|
|
16331
|
+
const raw = rawArg === null && !required ? void 0 : rawArg;
|
|
16332
|
+
const lang = typeof raw === "string" ? raw.replace(/^"|"$/g, "") : "";
|
|
16333
|
+
if (typeof raw === "string" && LANGUAGES.includes(lang))
|
|
16334
|
+
return { lang };
|
|
16335
|
+
const validIds = `valid ids: ${LANGUAGES.join(", ")}`;
|
|
16336
|
+
if (raw !== void 0 && typeof raw !== "string")
|
|
16337
|
+
return { lang, refusal: `lang must be a string; ${validIds}` };
|
|
16338
|
+
if (!lang.trim())
|
|
16339
|
+
return required ? { lang: "", refusal: "lang is required" } : { lang: "" };
|
|
16340
|
+
return { lang, refusal: `unknown lang "${lang}"; ${validIds}` };
|
|
16341
|
+
}
|
|
15953
16342
|
|
|
15954
16343
|
// dist/tools/ast-grep-replace.js
|
|
15955
16344
|
function errorTextWithHint(raw) {
|
|
@@ -15993,36 +16382,35 @@ function createAstGrepReplaceTool(astGrepClient2, captureLineage) {
|
|
|
15993
16382
|
description: "Replacement using meta-variables from pattern"
|
|
15994
16383
|
}),
|
|
15995
16384
|
lang: Type.String({
|
|
15996
|
-
|
|
15997
|
-
description: "Target language"
|
|
16385
|
+
description: "Language id, e.g. typescript, tsx, python, go."
|
|
15998
16386
|
}),
|
|
15999
16387
|
paths: Type.Optional(Type.Array(Type.String(), { description: "Specific files/folders" })),
|
|
16000
16388
|
insideKind: Type.Optional(Type.String({
|
|
16001
|
-
description: "
|
|
16389
|
+
description: "Ancestor AST node kind filter."
|
|
16002
16390
|
})),
|
|
16003
16391
|
hasKind: Type.Optional(Type.String({
|
|
16004
|
-
description:
|
|
16392
|
+
description: "Immediate child AST node kind filter."
|
|
16005
16393
|
})),
|
|
16006
16394
|
hasDescendantKind: Type.Optional(Type.String({
|
|
16007
|
-
description: "
|
|
16395
|
+
description: "Recursive descendant AST node kind filter."
|
|
16008
16396
|
})),
|
|
16009
16397
|
follows: Type.Optional(Type.String({
|
|
16010
|
-
description: "
|
|
16398
|
+
description: "Preceding sibling pattern filter."
|
|
16011
16399
|
})),
|
|
16012
16400
|
precedes: Type.Optional(Type.String({
|
|
16013
|
-
description: "
|
|
16401
|
+
description: "Following sibling pattern filter."
|
|
16014
16402
|
})),
|
|
16015
16403
|
apply: Type.Optional(Type.Boolean({ description: "Apply changes (default: false)" })),
|
|
16016
16404
|
strictness: Type.Optional(Type.String({
|
|
16017
16405
|
enum: ["smart", "relaxed", "ast", "cst", "signature", "template"],
|
|
16018
|
-
description: "
|
|
16406
|
+
description: "Match strictness; default smart."
|
|
16019
16407
|
}))
|
|
16020
16408
|
}),
|
|
16021
16409
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
16022
16410
|
const lineage = captureLineage?.();
|
|
16023
16411
|
const startedAt = Date.now();
|
|
16024
16412
|
const { pattern, rewrite, paths, apply, strictness, insideKind, hasKind, hasDescendantKind, follows, precedes } = params;
|
|
16025
|
-
const lang = (params.lang
|
|
16413
|
+
const { lang, refusal: langError } = readAstGrepLang(params.lang, true);
|
|
16026
16414
|
const pathsCount = paths?.length ?? 1;
|
|
16027
16415
|
const applyFlag = apply ?? false;
|
|
16028
16416
|
const resultMaxItems = ctx.resultMaxItems ?? 50;
|
|
@@ -16047,6 +16435,14 @@ function createAstGrepReplaceTool(astGrepClient2, captureLineage) {
|
|
|
16047
16435
|
} catch {
|
|
16048
16436
|
}
|
|
16049
16437
|
}
|
|
16438
|
+
if (langError) {
|
|
16439
|
+
logOutcome("error", { errorRaw: langError });
|
|
16440
|
+
return {
|
|
16441
|
+
content: [{ type: "text", text: `Error: ${langError}` }],
|
|
16442
|
+
isError: true,
|
|
16443
|
+
details: {}
|
|
16444
|
+
};
|
|
16445
|
+
}
|
|
16050
16446
|
if (!await astGrepClient2.ensureAvailable()) {
|
|
16051
16447
|
logOutcome("error", { errorRaw: "ast-grep CLI not found" });
|
|
16052
16448
|
return {
|
|
@@ -16182,11 +16578,11 @@ function createAstGrepReplaceTool(astGrepClient2, captureLineage) {
|
|
|
16182
16578
|
}
|
|
16183
16579
|
|
|
16184
16580
|
// dist/tools/ast-grep-search.js
|
|
16185
|
-
function errorTextWithHint2(raw) {
|
|
16581
|
+
function errorTextWithHint2(raw, host) {
|
|
16186
16582
|
const hint = astGrepRemediationHint(classifyAstGrepError(raw));
|
|
16187
16583
|
return hint ? `Error: ${raw}
|
|
16188
16584
|
|
|
16189
|
-
${hint}` : `Error: ${raw}`;
|
|
16585
|
+
${translateGuidanceToolNames(hint, host)}` : `Error: ${raw}`;
|
|
16190
16586
|
}
|
|
16191
16587
|
function _telemetryErrorForTest(raw) {
|
|
16192
16588
|
if (!raw)
|
|
@@ -16416,8 +16812,7 @@ function createAstGrepSearchTool(astGrepClient2) {
|
|
|
16416
16812
|
dump: Type.Optional(Type.Boolean()),
|
|
16417
16813
|
pattern: Type.Optional(Type.String({ description: "AST pattern." })),
|
|
16418
16814
|
lang: Type.String({
|
|
16419
|
-
|
|
16420
|
-
description: "Target language"
|
|
16815
|
+
description: "Language id, e.g. typescript, tsx, python, go."
|
|
16421
16816
|
}),
|
|
16422
16817
|
paths: Type.Optional(Type.Array(Type.String(), {
|
|
16423
16818
|
maxItems: MAX_PATHS,
|
|
@@ -16436,7 +16831,7 @@ function createAstGrepSearchTool(astGrepClient2) {
|
|
|
16436
16831
|
description: "Ancestor AST node kind filter."
|
|
16437
16832
|
})),
|
|
16438
16833
|
hasKind: Type.Optional(Type.String({
|
|
16439
|
-
description: "Immediate
|
|
16834
|
+
description: "Immediate child AST node kind filter."
|
|
16440
16835
|
})),
|
|
16441
16836
|
hasDescendantKind: Type.Optional(Type.String({
|
|
16442
16837
|
description: "Recursive descendant AST node kind filter."
|
|
@@ -16461,22 +16856,22 @@ function createAstGrepSearchTool(astGrepClient2) {
|
|
|
16461
16856
|
})),
|
|
16462
16857
|
strictness: Type.Optional(Type.String({
|
|
16463
16858
|
enum: ["smart", "relaxed", "ast", "cst", "signature", "template"],
|
|
16464
|
-
description: "
|
|
16859
|
+
description: "Match strictness; default smart."
|
|
16465
16860
|
})),
|
|
16466
16861
|
validateOnly: Type.Optional(Type.Boolean({
|
|
16467
16862
|
description: "Validate without scanning."
|
|
16468
16863
|
}))
|
|
16469
16864
|
}),
|
|
16470
16865
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
16866
|
+
const host = ctx.host ?? "pi";
|
|
16471
16867
|
const abortSignal = combineAbortSignals(_signal, ctx.signal);
|
|
16472
16868
|
const startedAt = Date.now();
|
|
16473
16869
|
const deadlineAt = startedAt + AST_GREP_SEARCH_TIMEOUT_MS;
|
|
16474
16870
|
const { paths, nodeKind, selector, context, skip, maxMatches, groupByFile, strictness, rule, insideKind, hasKind, hasDescendantKind, follows, precedes, validateOnly, dump: dump2 } = params;
|
|
16475
16871
|
const pattern = typeof params.pattern === "string" ? params.pattern : "";
|
|
16476
|
-
const rawLang = typeof params.lang === "string" ? params.lang : "";
|
|
16477
16872
|
const normalizedNodeKind = typeof nodeKind === "string" ? nodeKind.trim() : "";
|
|
16478
16873
|
const skipOffset = Math.max(0, Math.floor(skip ?? 0));
|
|
16479
|
-
const lang =
|
|
16874
|
+
const { lang, refusal: langError } = readAstGrepLang(params.lang, true);
|
|
16480
16875
|
const searchPathsCount = paths?.length ?? 1;
|
|
16481
16876
|
const executionOptions = { signal: abortSignal, deadlineAt };
|
|
16482
16877
|
const dumpMode = dump2 === true;
|
|
@@ -16569,12 +16964,10 @@ function createAstGrepSearchTool(astGrepClient2) {
|
|
|
16569
16964
|
details: {}
|
|
16570
16965
|
};
|
|
16571
16966
|
}
|
|
16572
|
-
if (
|
|
16573
|
-
logOutcome("error", { errorRaw:
|
|
16967
|
+
if (langError) {
|
|
16968
|
+
logOutcome("error", { errorRaw: langError });
|
|
16574
16969
|
return {
|
|
16575
|
-
content: [
|
|
16576
|
-
{ type: "text", text: "Error: lang is required" }
|
|
16577
|
-
],
|
|
16970
|
+
content: [{ type: "text", text: `Error: ${langError}` }],
|
|
16578
16971
|
isError: true,
|
|
16579
16972
|
details: {}
|
|
16580
16973
|
};
|
|
@@ -16764,7 +17157,7 @@ function createAstGrepSearchTool(astGrepClient2) {
|
|
|
16764
17157
|
content: [
|
|
16765
17158
|
{
|
|
16766
17159
|
type: "text",
|
|
16767
|
-
text: errorTextWithHint2(ruleResult.error)
|
|
17160
|
+
text: errorTextWithHint2(ruleResult.error, host)
|
|
16768
17161
|
}
|
|
16769
17162
|
],
|
|
16770
17163
|
isError: true,
|
|
@@ -16817,7 +17210,10 @@ function createAstGrepSearchTool(astGrepClient2) {
|
|
|
16817
17210
|
logOutcome("error", { errorRaw: result.error });
|
|
16818
17211
|
return {
|
|
16819
17212
|
content: [
|
|
16820
|
-
{
|
|
17213
|
+
{
|
|
17214
|
+
type: "text",
|
|
17215
|
+
text: errorTextWithHint2(result.error, host)
|
|
17216
|
+
}
|
|
16821
17217
|
],
|
|
16822
17218
|
isError: true,
|
|
16823
17219
|
details: {}
|
|
@@ -16827,7 +17223,8 @@ function createAstGrepSearchTool(astGrepClient2) {
|
|
|
16827
17223
|
const page = afterSkip.slice(0, PAGE_SIZE);
|
|
16828
17224
|
const hasMore = afterSkip.length > PAGE_SIZE || result.truncated;
|
|
16829
17225
|
const output = groupByFile ? formatGroupedByFile(page) : astGrepClient2.formatMatches(page, false, false, PAGE_SIZE);
|
|
16830
|
-
const
|
|
17226
|
+
const rawHint = page.length === 0 && !result.error ? getPatternHint(pattern, lang, selector) : void 0;
|
|
17227
|
+
const hint = rawHint ? translateGuidanceToolNames(rawHint, host) : void 0;
|
|
16831
17228
|
const paginationNote = hasMore && page.length > 0 ? `
|
|
16832
17229
|
|
|
16833
17230
|
(Showing ${page.length} of ${result.matches.length - skipOffset} remaining matches. Use skip=${skipOffset + PAGE_SIZE} for the next page.)` : "";
|
|
@@ -16870,7 +17267,7 @@ ${hint}` : `${output}${paginationNote}`;
|
|
|
16870
17267
|
}
|
|
16871
17268
|
|
|
16872
17269
|
// dist/tools/lens-diagnostics.js
|
|
16873
|
-
import { promises as
|
|
17270
|
+
import { promises as fs22 } from "node:fs";
|
|
16874
17271
|
import * as fsSync from "node:fs";
|
|
16875
17272
|
import * as path38 from "node:path";
|
|
16876
17273
|
|
|
@@ -16930,7 +17327,7 @@ function reasonFromAvailabilityVerdict(tool, verdict) {
|
|
|
16930
17327
|
}
|
|
16931
17328
|
|
|
16932
17329
|
// dist/clients/project-diagnostics/fresh-fetch.js
|
|
16933
|
-
import * as
|
|
17330
|
+
import * as fs20 from "node:fs";
|
|
16934
17331
|
import * as os3 from "node:os";
|
|
16935
17332
|
import * as path36 from "node:path";
|
|
16936
17333
|
|
|
@@ -17034,7 +17431,7 @@ function opengrepResultToProjectDiagnostics(cwd, result) {
|
|
|
17034
17431
|
}
|
|
17035
17432
|
|
|
17036
17433
|
// dist/clients/project-diagnostics/runner-adapters/runner-findings.js
|
|
17037
|
-
import * as
|
|
17434
|
+
import * as fs19 from "node:fs";
|
|
17038
17435
|
import * as path35 from "node:path";
|
|
17039
17436
|
function failureMessage(failure) {
|
|
17040
17437
|
const firstLine2 = failure.message.split("\n")[0]?.slice(0, 300) ?? "";
|
|
@@ -17101,7 +17498,7 @@ function testRunnerFindingsToProjectDiagnostics(cache, cwd, runtime) {
|
|
|
17101
17498
|
return [];
|
|
17102
17499
|
const validation = cwd ? validateAdvisoryProvenance(cache, cwd, runtime) : { status: "unknown", reasons: ["validation-context-missing"] };
|
|
17103
17500
|
const root = cwd ?? process.cwd();
|
|
17104
|
-
const missingKeys = new Set((cache.provenance?.files ?? []).filter((file) => !
|
|
17501
|
+
const missingKeys = new Set((cache.provenance?.files ?? []).filter((file) => !fs19.existsSync(path35.resolve(root, file.path))).map((file) => advisoryPathKey(file.path, root)));
|
|
17105
17502
|
const historical = cache.superseded === true || cache.stale === true || validation.status !== "current";
|
|
17106
17503
|
return cache.results.filter((result) => !missingKeys.has(advisoryPathKey(result.file, root))).flatMap((result) => testResultToProjectDiagnostics(result, historical)).map((diagnostic) => historical ? {
|
|
17107
17504
|
...diagnostic,
|
|
@@ -17136,10 +17533,10 @@ async function fetchFreshProjectDiagnostics(cacheManager2, cwd, clients, signal,
|
|
|
17136
17533
|
let analysisRootValidation;
|
|
17137
17534
|
if (options.analysisRoot !== void 0) {
|
|
17138
17535
|
try {
|
|
17139
|
-
if (!
|
|
17536
|
+
if (!fs20.statSync(requestedRoot).isDirectory()) {
|
|
17140
17537
|
throw new Error("is not a directory");
|
|
17141
17538
|
}
|
|
17142
|
-
analysisRoot =
|
|
17539
|
+
analysisRoot = fs20.realpathSync(requestedRoot);
|
|
17143
17540
|
} catch (error) {
|
|
17144
17541
|
const detail = error instanceof Error ? error.message : String(error);
|
|
17145
17542
|
const reason = `the explicit analysis root ${requestedRoot} is unavailable or ${detail}`;
|
|
@@ -17298,7 +17695,7 @@ async function fetchFreshProjectDiagnostics(cacheManager2, cwd, clients, signal,
|
|
|
17298
17695
|
markCold("jscpd", reasonFromAvailabilityVerdict("jscpd", clients.jscpdClient.getAvailabilityVerdict?.()));
|
|
17299
17696
|
return;
|
|
17300
17697
|
}
|
|
17301
|
-
const isTsProject =
|
|
17698
|
+
const isTsProject = fs20.existsSync(path36.join(analysisRoot, "tsconfig.json"));
|
|
17302
17699
|
const scannerKey = isTsProject ? "jscpd-ts" : "jscpd";
|
|
17303
17700
|
const startMs = Date.now();
|
|
17304
17701
|
const result = await clients.jscpdClient.scan(analysisRoot, void 0, void 0, isTsProject);
|
|
@@ -17614,7 +18011,7 @@ function makeProgressReporter(onUpdate, label, throttleMs = 250) {
|
|
|
17614
18011
|
}
|
|
17615
18012
|
|
|
17616
18013
|
// dist/tools/lsp-diagnostics.js
|
|
17617
|
-
import * as
|
|
18014
|
+
import * as fs21 from "node:fs";
|
|
17618
18015
|
import * as path37 from "node:path";
|
|
17619
18016
|
var MAX_FILES = 100;
|
|
17620
18017
|
var MAX_BATCH_FILES = 100;
|
|
@@ -17632,6 +18029,37 @@ var LSP_SEVERITY_FILTERS = [
|
|
|
17632
18029
|
...Object.values(SEVERITY_NAMES),
|
|
17633
18030
|
"all"
|
|
17634
18031
|
];
|
|
18032
|
+
function withheldCompileNote(withheld) {
|
|
18033
|
+
if (!withheld)
|
|
18034
|
+
return void 0;
|
|
18035
|
+
if (!withheld.declarations) {
|
|
18036
|
+
return describePythonCompileWithheld(withheld.count, withheld.declared);
|
|
18037
|
+
}
|
|
18038
|
+
const groups = withheld.declarations.map((group) => `${group.count} under Python ${group.declared.major}.${group.declared.minor} (${group.declared.source}) in ${group.declared.file}`);
|
|
18039
|
+
return `${withheld.count} python-jedi compile finding${withheld.count === 1 ? "" : "s"} withheld across ${groups.length} declarations: ${groups.join("; ")}`;
|
|
18040
|
+
}
|
|
18041
|
+
function mergeWithheld(entries) {
|
|
18042
|
+
const groups = /* @__PURE__ */ new Map();
|
|
18043
|
+
for (const entry of entries) {
|
|
18044
|
+
if (!entry || entry.count <= 0)
|
|
18045
|
+
continue;
|
|
18046
|
+
for (const part of entry.declarations ?? [entry]) {
|
|
18047
|
+
const { declared } = part;
|
|
18048
|
+
const key = `${declared.file}\0${declared.source}\0${declared.major}.${declared.minor}`;
|
|
18049
|
+
const group = groups.get(key);
|
|
18050
|
+
if (group)
|
|
18051
|
+
group.count += part.count;
|
|
18052
|
+
else
|
|
18053
|
+
groups.set(key, { count: part.count, declared });
|
|
18054
|
+
}
|
|
18055
|
+
}
|
|
18056
|
+
const merged = [...groups.values()];
|
|
18057
|
+
const first = merged[0];
|
|
18058
|
+
if (!first)
|
|
18059
|
+
return void 0;
|
|
18060
|
+
const count = merged.reduce((sum, group) => sum + group.count, 0);
|
|
18061
|
+
return merged.length === 1 ? { count, declared: first.declared } : { count, declared: first.declared, declarations: merged };
|
|
18062
|
+
}
|
|
17635
18063
|
function assertNeverBatchFileOutcome(value) {
|
|
17636
18064
|
throw new Error(`Unhandled batch file outcome: ${String(value)}`);
|
|
17637
18065
|
}
|
|
@@ -17689,7 +18117,7 @@ async function collectFiles(dir, extensions, maxFiles, isIgnored = () => false)
|
|
|
17689
18117
|
return;
|
|
17690
18118
|
let entries;
|
|
17691
18119
|
try {
|
|
17692
|
-
entries = await
|
|
18120
|
+
entries = await fs21.promises.readdir(current, { withFileTypes: true });
|
|
17693
18121
|
} catch {
|
|
17694
18122
|
return;
|
|
17695
18123
|
}
|
|
@@ -17801,7 +18229,7 @@ function createLspDiagnosticsTool(nextWriteIndex, onConfirmedNoBlockers, getServ
|
|
|
17801
18229
|
const absPath = normalizeMapKey(typedParams.pathAlreadyResolved === true ? rawPath : resolveHostToolPath(rawPath, cwd));
|
|
17802
18230
|
let stat;
|
|
17803
18231
|
try {
|
|
17804
|
-
stat =
|
|
18232
|
+
stat = fs21.statSync(absPath);
|
|
17805
18233
|
} catch {
|
|
17806
18234
|
return {
|
|
17807
18235
|
content: [
|
|
@@ -17833,7 +18261,7 @@ async function collectDiagnosticsForFile(absPath, lspService, scanRoot, waitMs,
|
|
|
17833
18261
|
let content;
|
|
17834
18262
|
let touched;
|
|
17835
18263
|
try {
|
|
17836
|
-
content =
|
|
18264
|
+
content = fs21.readFileSync(absPath, "utf-8");
|
|
17837
18265
|
const contentLimit = exceedsLspSyncLimits(content);
|
|
17838
18266
|
if (contentLimit.tooLarge) {
|
|
17839
18267
|
const reason = `file too large for LSP diagnostics (${contentLimit.reason})`;
|
|
@@ -17883,7 +18311,10 @@ async function collectDiagnosticsForFile(absPath, lspService, scanRoot, waitMs,
|
|
|
17883
18311
|
// pre-#1470 handling, unchanged.
|
|
17884
18312
|
unconfirmedServerIds: attached.response.unconfirmedServerIds ?? [],
|
|
17885
18313
|
diagnosticsUnsupportedServerIds: [],
|
|
17886
|
-
content
|
|
18314
|
+
content,
|
|
18315
|
+
...attached.response.projectIdentity !== void 0 && {
|
|
18316
|
+
projectIdentity: attached.response.projectIdentity
|
|
18317
|
+
}
|
|
17887
18318
|
};
|
|
17888
18319
|
}
|
|
17889
18320
|
}
|
|
@@ -18021,14 +18452,7 @@ function coveredSourcesForCheck(file, serverScope, unconfirmedServerIds, exclude
|
|
|
18021
18452
|
}
|
|
18022
18453
|
return [...covered];
|
|
18023
18454
|
}
|
|
18024
|
-
function
|
|
18025
|
-
return demoteInferredProjectDiagnostics(diagnostics, {
|
|
18026
|
-
filePath: file,
|
|
18027
|
-
cwd,
|
|
18028
|
-
service: lspService
|
|
18029
|
-
});
|
|
18030
|
-
}
|
|
18031
|
-
function applyProbeFindingPolicy(file, diagnostics, cwd, content, severity, toolName = "lsp_diagnostics") {
|
|
18455
|
+
function applyProbeFindingPolicy(file, diagnostics, cwd, content, severity, toolName = "lsp_diagnostics", pythonCompileTarget) {
|
|
18032
18456
|
const started = Date.now();
|
|
18033
18457
|
try {
|
|
18034
18458
|
const result = applyLspFindingPolicy(diagnostics, {
|
|
@@ -18038,6 +18462,10 @@ function applyProbeFindingPolicy(file, diagnostics, cwd, content, severity, tool
|
|
|
18038
18462
|
policyMap: loadProjectRulePolicyMap(cwd),
|
|
18039
18463
|
fileRole: detectFileRole(file, content)
|
|
18040
18464
|
});
|
|
18465
|
+
const { kept: delivered, dropped } = partitionOutrankedPythonCompileVerdicts(result.kept, pythonCompileTarget);
|
|
18466
|
+
if (dropped > 0 && pythonCompileTarget) {
|
|
18467
|
+
recordPythonCompileVerdictDrop(file, pythonCompileTarget, dropped);
|
|
18468
|
+
}
|
|
18041
18469
|
const inScopeBefore = applySeverityFilter(diagnostics, severity).length;
|
|
18042
18470
|
const suppressed = inScopeBefore - applySeverityFilter(result.kept, severity).length;
|
|
18043
18471
|
if (suppressed > 0) {
|
|
@@ -18054,7 +18482,17 @@ function applyProbeFindingPolicy(file, diagnostics, cwd, content, severity, tool
|
|
|
18054
18482
|
}
|
|
18055
18483
|
});
|
|
18056
18484
|
}
|
|
18057
|
-
return {
|
|
18485
|
+
return {
|
|
18486
|
+
kept: delivered,
|
|
18487
|
+
inlineKept: result.inlineKept,
|
|
18488
|
+
suppressed,
|
|
18489
|
+
...delivered.length !== result.kept.length && pythonCompileTarget && {
|
|
18490
|
+
withheld: {
|
|
18491
|
+
count: result.kept.length - delivered.length,
|
|
18492
|
+
declared: pythonCompileTarget
|
|
18493
|
+
}
|
|
18494
|
+
}
|
|
18495
|
+
};
|
|
18058
18496
|
} catch (err) {
|
|
18059
18497
|
recordDegradationOnce({
|
|
18060
18498
|
kind: "lsp-probe-finding-policy",
|
|
@@ -18091,19 +18529,24 @@ async function collectFileDiagnosticResult(file, severity, lspService, waitMs, n
|
|
|
18091
18529
|
const scannedAt = Date.now();
|
|
18092
18530
|
let stat;
|
|
18093
18531
|
try {
|
|
18094
|
-
stat =
|
|
18532
|
+
stat = fs21.statSync(file);
|
|
18095
18533
|
if (!stat.isFile()) {
|
|
18096
18534
|
return { file, diagnostics: [], error: `${file}: not a file` };
|
|
18097
18535
|
}
|
|
18098
18536
|
} catch {
|
|
18099
18537
|
return { file, diagnostics: [], error: `${file}: path not found` };
|
|
18100
18538
|
}
|
|
18539
|
+
const pythonCompileTarget = await detectPythonTargetVersion(file);
|
|
18101
18540
|
if (cacheCtx && scopeKey !== void 0) {
|
|
18102
18541
|
const cached = cacheCtx.lookup(file, scopeKey);
|
|
18103
18542
|
if (cached && cached.binding.boundToCurrentDisk !== false) {
|
|
18104
18543
|
const confirmation2 = cached.diagnostics.length === 0 ? "clean" : void 0;
|
|
18105
|
-
const demotedCached = await
|
|
18106
|
-
|
|
18544
|
+
const demotedCached = (await demoteLanguageServerRows(cached.diagnostics, {
|
|
18545
|
+
filePath: file,
|
|
18546
|
+
cwd,
|
|
18547
|
+
service: lspService
|
|
18548
|
+
})).rows;
|
|
18549
|
+
const cachedPolicy = applyProbeFindingPolicy(file, demotedCached, cwd, replayContentForStrictMarks(file, cwd), severity, void 0, pythonCompileTarget);
|
|
18107
18550
|
const cachedDiags = cachedPolicy.kept;
|
|
18108
18551
|
const filteredDiags2 = applySeverityFilter(cachedDiags, severity);
|
|
18109
18552
|
reconcileWidgetFromLspResult(
|
|
@@ -18126,11 +18569,14 @@ async function collectFileDiagnosticResult(file, severity, lspService, waitMs, n
|
|
|
18126
18569
|
primaryServerId: primaryServerId(file),
|
|
18127
18570
|
...cachedPolicy.suppressed > 0 && {
|
|
18128
18571
|
dispositionSuppressed: cachedPolicy.suppressed
|
|
18572
|
+
},
|
|
18573
|
+
...cachedPolicy.withheld && {
|
|
18574
|
+
withheldCompile: cachedPolicy.withheld
|
|
18129
18575
|
}
|
|
18130
18576
|
};
|
|
18131
18577
|
}
|
|
18132
18578
|
}
|
|
18133
|
-
const { diagnostics: rawDiags, timedOut, confirmedByTouch, unconfirmedServerIds, diagnosticsUnsupportedServerIds, content: collectedContent, binding, tooLargeReason, skipReason, primaryUnavailable, primaryUnavailableCause: primaryUnavailableCause2, noClientAnswered } = await collectDiagnosticsForFile(file, lspService, cwd, waitMs, serverScope, excludeServerIds);
|
|
18579
|
+
const { diagnostics: rawDiags, timedOut, confirmedByTouch, unconfirmedServerIds, diagnosticsUnsupportedServerIds, content: collectedContent, binding, tooLargeReason, skipReason, primaryUnavailable, primaryUnavailableCause: primaryUnavailableCause2, noClientAnswered, projectIdentity } = await collectDiagnosticsForFile(file, lspService, cwd, waitMs, serverScope, excludeServerIds);
|
|
18134
18580
|
if (tooLargeReason !== void 0) {
|
|
18135
18581
|
return { file, diagnostics: [], outcome: "too_large", tooLargeReason };
|
|
18136
18582
|
}
|
|
@@ -18159,14 +18605,24 @@ async function collectFileDiagnosticResult(file, severity, lspService, waitMs, n
|
|
|
18159
18605
|
const boundMismatch = binding?.boundToCurrentDisk === false;
|
|
18160
18606
|
if (boundMismatch)
|
|
18161
18607
|
confirmation = "unconfirmed";
|
|
18162
|
-
const rootFallback = confirmation === "clean" ? await primaryRootFallback(file, cwd) : void 0;
|
|
18608
|
+
const rootFallback = confirmation === "clean" || primaryUnavailable !== void 0 ? await primaryRootFallback(file, cwd) : void 0;
|
|
18163
18609
|
if (rootFallback)
|
|
18164
18610
|
confirmation = "unconfirmed";
|
|
18165
18611
|
if (unconfirmedServerIds.length > 0 && confirmation === "clean") {
|
|
18166
18612
|
confirmation = "unconfirmed";
|
|
18167
18613
|
}
|
|
18168
|
-
|
|
18169
|
-
|
|
18614
|
+
const demotion = await demoteLanguageServerRows(effectiveRawDiags, {
|
|
18615
|
+
filePath: file,
|
|
18616
|
+
cwd,
|
|
18617
|
+
service: lspService,
|
|
18618
|
+
// #4645: the warm incumbent's answer stands in for this process's probe.
|
|
18619
|
+
...projectIdentity !== void 0 && {
|
|
18620
|
+
identityCache: /* @__PURE__ */ new Map([[file, projectIdentity]])
|
|
18621
|
+
}
|
|
18622
|
+
});
|
|
18623
|
+
const shownRows = demotion.rows;
|
|
18624
|
+
effectiveRawDiags = shownRows;
|
|
18625
|
+
const policy = applyProbeFindingPolicy(file, effectiveRawDiags, cwd, collectedContent, severity, void 0, pythonCompileTarget);
|
|
18170
18626
|
effectiveRawDiags = policy.kept;
|
|
18171
18627
|
const filteredDiags = applySeverityFilter(effectiveRawDiags, severity);
|
|
18172
18628
|
const verdict = reconcileWidgetFromLspResult(
|
|
@@ -18191,7 +18647,14 @@ async function collectFileDiagnosticResult(file, severity, lspService, waitMs, n
|
|
|
18191
18647
|
});
|
|
18192
18648
|
}
|
|
18193
18649
|
if (cacheCtx && scopeKey !== void 0 && confirmation !== "unconfirmed" && diagnosticsUnsupportedServerIds.length === 0 && unconfirmedServerIds.length === 0) {
|
|
18194
|
-
|
|
18650
|
+
const replayable = await demotion.replayable();
|
|
18651
|
+
const replayRowOf = /* @__PURE__ */ new Map();
|
|
18652
|
+
for (const [index, row] of shownRows.entries()) {
|
|
18653
|
+
const stored = replayable[index];
|
|
18654
|
+
if (stored !== void 0)
|
|
18655
|
+
replayRowOf.set(row, stored);
|
|
18656
|
+
}
|
|
18657
|
+
cacheCtx.record(file, scopeKey, policy.inlineKept.map((row) => replayRowOf.get(row) ?? row), stat.mtimeMs, collectedContent !== void 0 ? hashDiagnosticContent(collectedContent) : void 0, stat.size, scannedAt);
|
|
18195
18658
|
}
|
|
18196
18659
|
return {
|
|
18197
18660
|
file,
|
|
@@ -18210,17 +18673,21 @@ async function collectFileDiagnosticResult(file, severity, lspService, waitMs, n
|
|
|
18210
18673
|
diagnosticsUnsupported: diagnosticsUnsupportedServerIds.length > 0,
|
|
18211
18674
|
...policy.suppressed > 0 && {
|
|
18212
18675
|
dispositionSuppressed: policy.suppressed
|
|
18676
|
+
},
|
|
18677
|
+
...policy.withheld && {
|
|
18678
|
+
withheldCompile: policy.withheld
|
|
18213
18679
|
}
|
|
18214
18680
|
};
|
|
18215
18681
|
}
|
|
18216
18682
|
async function runFileDiagnostics(absPath, severity, lspService, waitMs, nextWriteIndex, serverScope = "all", cwd = process.cwd(), onConfirmedNoBlockers, excludeServerIds) {
|
|
18217
18683
|
const writeIndex = nextWriteIndex?.();
|
|
18684
|
+
const pythonCompileTarget = await detectPythonTargetVersion(absPath);
|
|
18218
18685
|
lspService.announceCreatedFiles([
|
|
18219
18686
|
...goPackageFilesToAnnounce([absPath]),
|
|
18220
18687
|
...await importTargetsToAnnounce(cwd, [absPath])
|
|
18221
18688
|
]);
|
|
18222
18689
|
const observedAt = Date.now();
|
|
18223
|
-
const { diagnostics: rawDiags, timedOut, confirmedByTouch, unconfirmedServerIds, diagnosticsUnsupportedServerIds, content: collectedContent, binding, tooLargeReason, skipReason, primaryUnavailable } = await collectDiagnosticsForFile(absPath, lspService, cwd, waitMs, serverScope, excludeServerIds);
|
|
18690
|
+
const { diagnostics: rawDiags, timedOut, confirmedByTouch, unconfirmedServerIds, diagnosticsUnsupportedServerIds, content: collectedContent, binding, tooLargeReason, skipReason, primaryUnavailable, projectIdentity } = await collectDiagnosticsForFile(absPath, lspService, cwd, waitMs, serverScope, excludeServerIds);
|
|
18224
18691
|
if (tooLargeReason !== void 0) {
|
|
18225
18692
|
return {
|
|
18226
18693
|
content: [{ type: "text", text: tooLargeReason }],
|
|
@@ -18262,14 +18729,21 @@ async function runFileDiagnostics(absPath, severity, lspService, waitMs, nextWri
|
|
|
18262
18729
|
const boundMismatch = binding?.boundToCurrentDisk === false;
|
|
18263
18730
|
if (boundMismatch)
|
|
18264
18731
|
confirmation = "unconfirmed";
|
|
18265
|
-
const rootFallback = confirmation === "clean" ? await primaryRootFallback(absPath, cwd) : void 0;
|
|
18732
|
+
const rootFallback = confirmation === "clean" || primaryUnavailable !== void 0 ? await primaryRootFallback(absPath, cwd) : void 0;
|
|
18266
18733
|
if (rootFallback)
|
|
18267
18734
|
confirmation = "unconfirmed";
|
|
18268
18735
|
const primaryCoverageGapOnly = unconfirmedServerIds.length > 0 && confirmation === "clean";
|
|
18269
18736
|
if (primaryCoverageGapOnly)
|
|
18270
18737
|
confirmation = "unconfirmed";
|
|
18271
|
-
effectiveRawDiags = await
|
|
18272
|
-
|
|
18738
|
+
effectiveRawDiags = (await demoteLanguageServerRows(effectiveRawDiags, {
|
|
18739
|
+
filePath: absPath,
|
|
18740
|
+
cwd,
|
|
18741
|
+
service: lspService,
|
|
18742
|
+
...projectIdentity !== void 0 && {
|
|
18743
|
+
identityCache: /* @__PURE__ */ new Map([[absPath, projectIdentity]])
|
|
18744
|
+
}
|
|
18745
|
+
})).rows;
|
|
18746
|
+
const policy = applyProbeFindingPolicy(absPath, effectiveRawDiags, cwd, collectedContent, severity, void 0, pythonCompileTarget);
|
|
18273
18747
|
effectiveRawDiags = policy.kept;
|
|
18274
18748
|
const filtered = applySeverityFilter(effectiveRawDiags, severity);
|
|
18275
18749
|
const total = filtered.length;
|
|
@@ -18289,8 +18763,9 @@ async function runFileDiagnostics(absPath, severity, lspService, waitMs, nextWri
|
|
|
18289
18763
|
const primaryDiags = limited.filter((d) => d.serverId === primaryId);
|
|
18290
18764
|
const auxiliaryDiags = limited.filter((d) => d.serverId !== primaryId);
|
|
18291
18765
|
const primaryLine = (() => {
|
|
18292
|
-
if (primaryUnavailable !== void 0)
|
|
18293
|
-
return primaryUnavailable;
|
|
18766
|
+
if (primaryUnavailable !== void 0) {
|
|
18767
|
+
return rootFallback ? `${primaryUnavailable} ${describeRootFallback(rootFallback, false)}.` : primaryUnavailable;
|
|
18768
|
+
}
|
|
18294
18769
|
if (diagnosticsUnsupportedServerIds.length > 0) {
|
|
18295
18770
|
return `Primary LSP${primaryId ? ` (${primaryId})` : ""}: navigation-only \u2014 diagnostics unsupported (no pull provider or publish evidence).`;
|
|
18296
18771
|
}
|
|
@@ -18310,6 +18785,7 @@ async function runFileDiagnostics(absPath, severity, lspService, waitMs, nextWri
|
|
|
18310
18785
|
})();
|
|
18311
18786
|
const coverageLine = unconfirmedServerIds.length > 0 ? `Auxiliary coverage INCOMPLETE \u2014 ${[...unconfirmedServerIds].join(", ")} did not answer within the wait budget, so ${unconfirmedServerIds.length === 1 ? "its findings are" : "their findings are"} NOT included here. This is not a clean bill of health for ${unconfirmedServerIds.length === 1 ? "that scanner" : "those scanners"}; re-check after the next edit. waitMs can extend an ordinary wait, but it cannot override a session-demoted scanner.` : void 0;
|
|
18312
18787
|
const suppressedLine = dispositionSuppressedLine(policy.suppressed);
|
|
18788
|
+
const withheldLine = withheldCompileNote(policy.withheld);
|
|
18313
18789
|
const switchedOffServerIds = serverScope === "all" && excludeServerIds && excludeServerIds.size > 0 ? getServersForFileWithConfig(absPath).flatMap((server) => excludeServerIds.has(server.id) ? [server.id] : []) : [];
|
|
18314
18790
|
const noAuxiliaryLine = switchedOffServerIds.length > 0 ? `No auxiliary findings. Switched off, not run: ${switchedOffServerIds.join(", ")}.` : "No auxiliary findings.";
|
|
18315
18791
|
let text;
|
|
@@ -18319,7 +18795,8 @@ async function runFileDiagnostics(absPath, severity, lspService, waitMs, nextWri
|
|
|
18319
18795
|
"",
|
|
18320
18796
|
unavailable ?? noAuxiliaryLine,
|
|
18321
18797
|
...coverageLine ? [coverageLine] : [],
|
|
18322
|
-
...suppressedLine ? [suppressedLine] : []
|
|
18798
|
+
...suppressedLine ? [suppressedLine] : [],
|
|
18799
|
+
...withheldLine ? [withheldLine] : []
|
|
18323
18800
|
].join("\n");
|
|
18324
18801
|
} else {
|
|
18325
18802
|
const lines = [primaryLine, ""];
|
|
@@ -18334,6 +18811,8 @@ async function runFileDiagnostics(absPath, severity, lspService, waitMs, nextWri
|
|
|
18334
18811
|
lines.push("", coverageLine);
|
|
18335
18812
|
if (suppressedLine)
|
|
18336
18813
|
lines.push("", suppressedLine);
|
|
18814
|
+
if (withheldLine)
|
|
18815
|
+
lines.push("", withheldLine);
|
|
18337
18816
|
if (unavailable)
|
|
18338
18817
|
lines.unshift(unavailable, "");
|
|
18339
18818
|
if (truncated) {
|
|
@@ -18364,6 +18843,9 @@ async function runFileDiagnostics(absPath, severity, lspService, waitMs, nextWri
|
|
|
18364
18843
|
...policy.suppressed > 0 && {
|
|
18365
18844
|
dispositionSuppressed: policy.suppressed
|
|
18366
18845
|
},
|
|
18846
|
+
...policy.withheld && {
|
|
18847
|
+
withheldCompile: policy.withheld
|
|
18848
|
+
},
|
|
18367
18849
|
truncated,
|
|
18368
18850
|
unconfirmed,
|
|
18369
18851
|
timedOut: unconfirmed ? timedOut : void 0,
|
|
@@ -18371,7 +18853,7 @@ async function runFileDiagnostics(absPath, severity, lspService, waitMs, nextWri
|
|
|
18371
18853
|
...skipReason !== void 0 && { skipReason },
|
|
18372
18854
|
...primaryUnavailable !== void 0 && { primaryUnavailable },
|
|
18373
18855
|
...rootFallback && {
|
|
18374
|
-
rootFallbackReason: describeRootFallback(rootFallback)
|
|
18856
|
+
rootFallbackReason: describeRootFallback(rootFallback, primaryUnavailable === void 0)
|
|
18375
18857
|
},
|
|
18376
18858
|
// #1470: which servers this result does NOT speak for. Absent when it
|
|
18377
18859
|
// speaks for all of them.
|
|
@@ -18389,6 +18871,7 @@ function tallyConfirmation(results) {
|
|
|
18389
18871
|
let timedOut = 0;
|
|
18390
18872
|
let primaryUnavailable = 0;
|
|
18391
18873
|
const primaryUnavailableCauses = [];
|
|
18874
|
+
const primaryUnavailableRootReasons = /* @__PURE__ */ new Set();
|
|
18392
18875
|
const rootFallbackReasons = /* @__PURE__ */ new Set();
|
|
18393
18876
|
let navigationOnly = 0;
|
|
18394
18877
|
let tooLarge = 0;
|
|
@@ -18413,7 +18896,11 @@ function tallyConfirmation(results) {
|
|
|
18413
18896
|
primaryUnavailableCauses.push(result.primaryUnavailableCause);
|
|
18414
18897
|
}
|
|
18415
18898
|
if (result.rootFallback) {
|
|
18416
|
-
|
|
18899
|
+
if (result.primaryUnavailable !== void 0) {
|
|
18900
|
+
primaryUnavailableRootReasons.add(describeRootFallback(result.rootFallback, false));
|
|
18901
|
+
} else {
|
|
18902
|
+
rootFallbackReasons.add(describeRootFallback(result.rootFallback));
|
|
18903
|
+
}
|
|
18417
18904
|
}
|
|
18418
18905
|
} else if (classifyBatchFileOutcome(result) === "clean") {
|
|
18419
18906
|
clean += 1;
|
|
@@ -18425,7 +18912,8 @@ function tallyConfirmation(results) {
|
|
|
18425
18912
|
timedOut,
|
|
18426
18913
|
primaryUnavailable: {
|
|
18427
18914
|
count: primaryUnavailable,
|
|
18428
|
-
cause: combinePrimaryUnavailableCauses(primaryUnavailableCauses)
|
|
18915
|
+
cause: combinePrimaryUnavailableCauses(primaryUnavailableCauses),
|
|
18916
|
+
rootFallbackReasons: [...primaryUnavailableRootReasons]
|
|
18429
18917
|
},
|
|
18430
18918
|
rootFallbackReasons: [...rootFallbackReasons],
|
|
18431
18919
|
navigationOnly,
|
|
@@ -18476,9 +18964,13 @@ function auxiliaryOnlyFindingsLine(results) {
|
|
|
18476
18964
|
const cause = combinePrimaryUnavailableCauses(auxiliaryOnly.flatMap((result) => result.primaryUnavailableCause ?? [])) ?? "unstarted";
|
|
18477
18965
|
return `${count} file${count === 1 ? "" : "s"} with auxiliary findings only: no language server answered (${PRIMARY_UNAVAILABLE_CAUSE[cause]}), so the language itself was not checked.`;
|
|
18478
18966
|
}
|
|
18479
|
-
function unconfirmedReasonClause(unconfirmed, timedOut, rootFallbackReasons = [], primaryUnavailable = {
|
|
18967
|
+
function unconfirmedReasonClause(unconfirmed, timedOut, rootFallbackReasons = [], primaryUnavailable = {
|
|
18968
|
+
count: 0,
|
|
18969
|
+
cause: void 0,
|
|
18970
|
+
rootFallbackReasons: []
|
|
18971
|
+
}) {
|
|
18480
18972
|
if (primaryUnavailable.count > 0) {
|
|
18481
|
-
const head = `${primaryUnavailable.count} with no language server answer (${PRIMARY_UNAVAILABLE_CAUSE[primaryUnavailable.cause ?? "unstarted"]})
|
|
18973
|
+
const head = `${primaryUnavailable.count} with no language server answer (${PRIMARY_UNAVAILABLE_CAUSE[primaryUnavailable.cause ?? "unstarted"]})` + (primaryUnavailable.rootFallbackReasons.length > 0 ? `: ${primaryUnavailable.rootFallbackReasons.join("; ")}` : "");
|
|
18482
18974
|
const rest = unconfirmed - primaryUnavailable.count;
|
|
18483
18975
|
return rest > 0 ? `${head}; the other ${rest}: ${unconfirmedReasonClause(rest, timedOut, rootFallbackReasons)}` : `${head}.`;
|
|
18484
18976
|
}
|
|
@@ -18604,7 +19096,7 @@ async function expandPathsToFiles(cwd, rawPaths) {
|
|
|
18604
19096
|
const abs = normalizeMapKey(resolveHostToolPath(entry, cwd));
|
|
18605
19097
|
let stat;
|
|
18606
19098
|
try {
|
|
18607
|
-
stat =
|
|
19099
|
+
stat = fs21.statSync(abs);
|
|
18608
19100
|
} catch {
|
|
18609
19101
|
}
|
|
18610
19102
|
if (stat?.isDirectory()) {
|
|
@@ -18687,9 +19179,14 @@ async function runBatchFileDiagnostics(absPaths, severity, lspService, options,
|
|
|
18687
19179
|
const auxiliaryOnlyLine = auxiliaryOnlyFindingsLine(results);
|
|
18688
19180
|
if (auxiliaryOnlyLine)
|
|
18689
19181
|
lines.push("", auxiliaryOnlyLine);
|
|
19182
|
+
const withheldBatch = mergeWithheld(results.map((r) => r.withheldCompile));
|
|
19183
|
+
const withheld = withheldCompileNote(withheldBatch);
|
|
19184
|
+
const allClean = display.length === 0 && unconfirmed === 0 && outcomeCounts.clean === results.length;
|
|
19185
|
+
if (withheld && !allClean)
|
|
19186
|
+
lines.push("", withheld);
|
|
18690
19187
|
if (display.length === 0) {
|
|
18691
|
-
if (
|
|
18692
|
-
lines.push("", "No diagnostics found.");
|
|
19188
|
+
if (allClean) {
|
|
19189
|
+
lines.push("", withheld ? `No diagnostics found. ${withheld}` : "No diagnostics found.");
|
|
18693
19190
|
}
|
|
18694
19191
|
} else {
|
|
18695
19192
|
if (primaryDisplay.length > 0) {
|
|
@@ -18723,6 +19220,7 @@ async function runBatchFileDiagnostics(absPaths, severity, lspService, options,
|
|
|
18723
19220
|
auxiliaryDiagnosticsCount: auxiliaryDisplay.length,
|
|
18724
19221
|
totalDiagnostics: total,
|
|
18725
19222
|
...dispositionSuppressed > 0 && { dispositionSuppressed },
|
|
19223
|
+
...withheldBatch && { withheldCompile: withheldBatch },
|
|
18726
19224
|
truncated,
|
|
18727
19225
|
cleanFiles: clean,
|
|
18728
19226
|
unconfirmedFiles: unconfirmed,
|
|
@@ -18810,9 +19308,12 @@ async function runDirectoryDiagnostics(absPath, severity, lspService, options) {
|
|
|
18810
19308
|
}));
|
|
18811
19309
|
const auxiliaryOnlyLine = auxiliaryOnlyFindingsLine(results);
|
|
18812
19310
|
const tooLargeLines = renderBatchOutcomeLines(outcomeDetails, (file) => path37.relative(absPath, file));
|
|
19311
|
+
const withheldDirectory = mergeWithheld(results.map((r) => r.withheldCompile));
|
|
19312
|
+
const withheldDisclosure = withheldCompileNote(withheldDirectory);
|
|
18813
19313
|
let text;
|
|
18814
19314
|
if (total === 0) {
|
|
18815
|
-
const cleanLine = unconfirmed > 0 ? `${clean} clean \xB7 ${unconfirmed} unconfirmed: ${unconfirmedReasonClause(unconfirmed, timedOut, rootFallbackReasons, primaryUnavailable)} NOT the same as 0 diagnostics.` : "No diagnostics found.";
|
|
19315
|
+
const cleanLine = unconfirmed > 0 ? `${clean} clean \xB7 ${unconfirmed} unconfirmed: ${unconfirmedReasonClause(unconfirmed, timedOut, rootFallbackReasons, primaryUnavailable)} NOT the same as 0 diagnostics.` : withheldDisclosure ? `No diagnostics found. ${withheldDisclosure}` : "No diagnostics found.";
|
|
19316
|
+
const cleanLineShown = unconfirmed > 0 || lspHealthWarnings.length === 0 && outcomeCounts.clean === filesToProcess.length;
|
|
18816
19317
|
text = [
|
|
18817
19318
|
`Directory: ${absPath}`,
|
|
18818
19319
|
`Files scanned: ${filesToProcess.length}${wasCapped ? ` (capped at ${MAX_FILES})` : ""}`,
|
|
@@ -18822,7 +19323,10 @@ async function runDirectoryDiagnostics(absPath, severity, lspService, options) {
|
|
|
18822
19323
|
] : [],
|
|
18823
19324
|
// #4403: an unconfirmed file says why even beside a health warning,
|
|
18824
19325
|
// which names what was missing but not that the file is unconfirmed.
|
|
18825
|
-
...
|
|
19326
|
+
...cleanLineShown ? [cleanLine] : [],
|
|
19327
|
+
// The clean sentence carries the disclosure only when nothing is
|
|
19328
|
+
// unconfirmed; every other shape names it on its own line (#4638 r3 N2).
|
|
19329
|
+
...withheldDisclosure && !(cleanLineShown && unconfirmed === 0) ? ["", withheldDisclosure] : [],
|
|
18826
19330
|
...tooLargeLines.length > 0 ? ["", "Files too large for LSP diagnostics:", ...tooLargeLines] : [],
|
|
18827
19331
|
...suppressedLine ? ["", suppressedLine] : []
|
|
18828
19332
|
].join("\n");
|
|
@@ -18861,6 +19365,8 @@ async function runDirectoryDiagnostics(absPath, severity, lspService, options) {
|
|
|
18861
19365
|
}
|
|
18862
19366
|
if (suppressedLine)
|
|
18863
19367
|
lines.push("", suppressedLine);
|
|
19368
|
+
if (withheldDisclosure)
|
|
19369
|
+
lines.push("", withheldDisclosure);
|
|
18864
19370
|
if (tooLargeLines.length > 0) {
|
|
18865
19371
|
lines.push("", "Files too large for LSP diagnostics:", ...tooLargeLines);
|
|
18866
19372
|
}
|
|
@@ -18888,6 +19394,7 @@ async function runDirectoryDiagnostics(absPath, severity, lspService, options) {
|
|
|
18888
19394
|
auxiliaryDiagnosticsCount: auxiliaryDisplay.length,
|
|
18889
19395
|
totalDiagnostics: total,
|
|
18890
19396
|
...dispositionSuppressed > 0 && { dispositionSuppressed },
|
|
19397
|
+
...withheldDirectory && { withheldCompile: withheldDirectory },
|
|
18891
19398
|
truncated,
|
|
18892
19399
|
cleanFiles: clean,
|
|
18893
19400
|
unconfirmedFiles: unconfirmed,
|
|
@@ -18952,7 +19459,7 @@ async function findFullScanBindingMismatches(results) {
|
|
|
18952
19459
|
result.boundToCurrentDisk !== true && result.contentHash !== void 0
|
|
18953
19460
|
) {
|
|
18954
19461
|
try {
|
|
18955
|
-
const content = await
|
|
19462
|
+
const content = await fs22.readFile(result.filePath, "utf-8");
|
|
18956
19463
|
if (hashDiagnosticContent(content) !== result.contentHash) {
|
|
18957
19464
|
mismatched.add(result);
|
|
18958
19465
|
}
|
|
@@ -18967,6 +19474,17 @@ async function findFullScanBindingMismatches(results) {
|
|
|
18967
19474
|
}
|
|
18968
19475
|
return mismatched;
|
|
18969
19476
|
}
|
|
19477
|
+
async function applyDeclarationRule(filePath, diagnostics) {
|
|
19478
|
+
if (!diagnostics.some(isJediCompileVerdict)) {
|
|
19479
|
+
return { kept: [...diagnostics], dropped: 0 };
|
|
19480
|
+
}
|
|
19481
|
+
const declared = await detectPythonTargetVersion(filePath);
|
|
19482
|
+
const partition = partitionOutrankedPythonCompileVerdicts(diagnostics, declared);
|
|
19483
|
+
if (partition.dropped > 0 && declared) {
|
|
19484
|
+
recordPythonCompileVerdictDrop(filePath, declared, partition.dropped);
|
|
19485
|
+
}
|
|
19486
|
+
return declared ? { ...partition, declared } : partition;
|
|
19487
|
+
}
|
|
18970
19488
|
function createLensDiagnosticsTool(cacheManager2, getCwd, getLspService = getLSPService, flushPending = async () => {
|
|
18971
19489
|
}, nextWriteIndex, captureLspStatusRepaint, getRuntime, isLensGuardEnabled2 = () => true, getFlag) {
|
|
18972
19490
|
const lspProbe = createLspDiagnosticsTool(nextWriteIndex, (info) => {
|
|
@@ -19047,15 +19565,16 @@ function createLensDiagnosticsTool(cacheManager2, getCwd, getLspService = getLSP
|
|
|
19047
19565
|
const w = details?.totalWarnings ?? 0;
|
|
19048
19566
|
const adv = details?.totalAdvisories ?? 0;
|
|
19049
19567
|
const files = details?.filesWithIssues ?? details?.filesChecked ?? 0;
|
|
19568
|
+
const cacheVerdict = details?.validationStatus === "no-matching-findings" ? "no matching cached findings" : details?.validationStatus === "findings" ? void 0 : details?.validationStatus;
|
|
19050
19569
|
if (b + e + w === 0) {
|
|
19051
19570
|
const advisorySuffix = adv > 0 ? `, ${adv} hint${adv === 1 ? "" : "s"}` : "";
|
|
19052
|
-
return `lens_diagnostics ${mode} \u2014 clean${advisorySuffix} (${files} files)${coldSuffix}${failedSuffix}`;
|
|
19571
|
+
return `lens_diagnostics ${mode} \u2014 ${cacheVerdict ?? "clean"}${advisorySuffix} (${files} files)${coldSuffix}${failedSuffix}`;
|
|
19053
19572
|
}
|
|
19054
19573
|
const parts = [`${b} blocking`];
|
|
19055
19574
|
if (b === 0 && e > 0)
|
|
19056
19575
|
parts.push(`${e} errors`);
|
|
19057
19576
|
parts.push(`${w} warnings`);
|
|
19058
|
-
return `lens_diagnostics ${mode} \u2014 ${parts.join(" \xB7 ")} (${files} files)${coldSuffix}${failedSuffix}`;
|
|
19577
|
+
return `lens_diagnostics ${mode} \u2014 ${parts.join(" \xB7 ")}${cacheVerdict === "inconclusive" || cacheVerdict === "unverified" ? ` \xB7 ${cacheVerdict}` : ""} (${files} files)${coldSuffix}${failedSuffix}`;
|
|
19059
19578
|
}),
|
|
19060
19579
|
parameters: Type.Object({
|
|
19061
19580
|
source: Type.Optional(Type.String({
|
|
@@ -19186,7 +19705,8 @@ function createLensDiagnosticsTool(cacheManager2, getCwd, getLspService = getLSP
|
|
|
19186
19705
|
}
|
|
19187
19706
|
const abortSignal = combineAbortSignals(signal, ctx.signal);
|
|
19188
19707
|
await flushPending();
|
|
19189
|
-
const
|
|
19708
|
+
const stalePaths = [];
|
|
19709
|
+
await reconcileStaleWidgetFiles((file) => stalePaths.push(file));
|
|
19190
19710
|
if (mode === "all") {
|
|
19191
19711
|
const dependencyGateStart = Date.now();
|
|
19192
19712
|
const { demoted: dependencyDemoted, truncatedImports } = await reconcileStaleWidgetDependencyBlockers(cwd, getRuntime?.()?.turnIndex);
|
|
@@ -19202,7 +19722,8 @@ function createLensDiagnosticsTool(cacheManager2, getCwd, getLspService = getLSP
|
|
|
19202
19722
|
surface: "mode=all"
|
|
19203
19723
|
}
|
|
19204
19724
|
});
|
|
19205
|
-
|
|
19725
|
+
const scopedStalePaths = stalePaths.filter(createScopedFileFilter(cwd, pathsScope));
|
|
19726
|
+
return formatAllMode(cwd, severity, void 0, void 0, scopedStalePaths.length, pathsScope, void 0, { stalePaths: scopedStalePaths, host: ctx.host ?? "pi" });
|
|
19206
19727
|
}
|
|
19207
19728
|
if (mode === "full") {
|
|
19208
19729
|
const ceiling = AbortSignal.timeout(FULL_SCAN_WALL_CLOCK_MS);
|
|
@@ -19378,17 +19899,17 @@ function applyDeltaFreshnessGate(files, cwd, generatedAt) {
|
|
|
19378
19899
|
})).filter((file) => file.warnings.length > 0);
|
|
19379
19900
|
}
|
|
19380
19901
|
function getDeltaFileGroup(groups, cwd, filePath) {
|
|
19381
|
-
const
|
|
19382
|
-
let group = groups.get(
|
|
19902
|
+
const key = normalizeMapKey(filePath);
|
|
19903
|
+
let group = groups.get(key);
|
|
19383
19904
|
if (!group) {
|
|
19384
19905
|
group = {
|
|
19385
|
-
rel,
|
|
19906
|
+
rel: toProjectRelativePath(filePath, cwd),
|
|
19386
19907
|
actionableLines: [],
|
|
19387
19908
|
qualityLines: [],
|
|
19388
19909
|
projectLines: [],
|
|
19389
19910
|
incomplete: false
|
|
19390
19911
|
};
|
|
19391
|
-
groups.set(
|
|
19912
|
+
groups.set(key, group);
|
|
19392
19913
|
}
|
|
19393
19914
|
return group;
|
|
19394
19915
|
}
|
|
@@ -19688,9 +20209,9 @@ function projectDiagnosticToWidget(diagnostic, filePath) {
|
|
|
19688
20209
|
}
|
|
19689
20210
|
};
|
|
19690
20211
|
}
|
|
19691
|
-
function diagnosticDedupKey(
|
|
20212
|
+
function diagnosticDedupKey(fileKey, diagnostic) {
|
|
19692
20213
|
const ruleId = normalizeRuleId(diagnostic.rule ?? diagnostic.tool ?? "");
|
|
19693
|
-
return [
|
|
20214
|
+
return [fileKey, diagnostic.line ?? "?", ruleId].join(":");
|
|
19694
20215
|
}
|
|
19695
20216
|
function runnerIdOf(diagnostic) {
|
|
19696
20217
|
return diagnostic.tool ?? diagnostic.rule?.split(":", 1)[0] ?? "";
|
|
@@ -19704,8 +20225,8 @@ function runnerRetirementDecision(diagnostic, filePath, authoritativeRunnerIds,
|
|
|
19704
20225
|
const realFilePath = realpathOrResolve(filePath);
|
|
19705
20226
|
for (const entry of coverage) {
|
|
19706
20227
|
const root = entry.root;
|
|
19707
|
-
const
|
|
19708
|
-
const underRoot =
|
|
20228
|
+
const relative8 = path38.relative(root, realFilePath);
|
|
20229
|
+
const underRoot = relative8 === "" || !relative8.startsWith("..") && !path38.isAbsolute(relative8);
|
|
19709
20230
|
if (!underRoot)
|
|
19710
20231
|
continue;
|
|
19711
20232
|
if (entry.files.has(realFilePath)) {
|
|
@@ -19835,14 +20356,36 @@ function tallyLspPrimaryVsAuxiliary(results) {
|
|
|
19835
20356
|
function mergeDiagnosticsWithWidgetSummaries(widgetSummaries, lspResults, projectSnapshot, projectDelta, authoritativeLspFiles, authoritativeRunnerIds, authoritativeRunnerCoverage) {
|
|
19836
20357
|
const byFile = /* @__PURE__ */ new Map();
|
|
19837
20358
|
const seen = /* @__PURE__ */ new Set();
|
|
20359
|
+
const addDiagnostic = (filePath, widgetDiagnostic) => {
|
|
20360
|
+
const fileKey = normalizeMapKey(filePath);
|
|
20361
|
+
const existing = byFile.get(fileKey);
|
|
20362
|
+
const diagnostics = existing ? [...existing.diagnostics] : [];
|
|
20363
|
+
const key = diagnosticDedupKey(fileKey, widgetDiagnostic);
|
|
20364
|
+
if (seen.has(key))
|
|
20365
|
+
return;
|
|
20366
|
+
seen.add(key);
|
|
20367
|
+
diagnostics.push(widgetDiagnostic);
|
|
20368
|
+
byFile.set(fileKey, summarizeDiagnostics(existing?.filePath ?? filePath, diagnostics, existing?.hasFinalSnapshot ?? true));
|
|
20369
|
+
};
|
|
19838
20370
|
for (const summary of widgetSummaries) {
|
|
19839
20371
|
const filePath = path38.resolve(summary.filePath);
|
|
19840
|
-
|
|
20372
|
+
const fileKey = normalizeMapKey(summary.filePath);
|
|
20373
|
+
if (authoritativeLspFiles?.has(fileKey))
|
|
19841
20374
|
continue;
|
|
19842
20375
|
const retained = summary.diagnostics ?? [];
|
|
19843
20376
|
const diagnostics = retained.filter((diagnostic) => runnerRetirementDecision(diagnostic, filePath, authoritativeRunnerIds, authoritativeRunnerCoverage) !== "retire").map((d) => ({ ...d }));
|
|
20377
|
+
const prior = byFile.get(fileKey);
|
|
20378
|
+
if (prior) {
|
|
20379
|
+
byFile.set(fileKey, {
|
|
20380
|
+
...prior,
|
|
20381
|
+
hasFinalSnapshot: (prior.hasFinalSnapshot ?? true) && (summary.hasFinalSnapshot ?? true)
|
|
20382
|
+
});
|
|
20383
|
+
for (const diagnostic of diagnostics)
|
|
20384
|
+
addDiagnostic(filePath, diagnostic);
|
|
20385
|
+
continue;
|
|
20386
|
+
}
|
|
19844
20387
|
byFile.set(
|
|
19845
|
-
|
|
20388
|
+
fileKey,
|
|
19846
20389
|
// #2154 v4: when the filter retires rows, the stored tallies describe
|
|
19847
20390
|
// diagnostics that are no longer delivered — full mode rendered
|
|
19848
20391
|
// `main.go 1W … 1 warning` with no row under it. Recompute from what
|
|
@@ -19850,19 +20393,9 @@ function mergeDiagnosticsWithWidgetSummaries(widgetSummaries, lspResults, projec
|
|
|
19850
20393
|
diagnostics.length === retained.length ? { ...summary, filePath, diagnostics } : summarizeDiagnostics(filePath, diagnostics, summary.hasFinalSnapshot ?? true)
|
|
19851
20394
|
);
|
|
19852
20395
|
for (const diagnostic of diagnostics) {
|
|
19853
|
-
seen.add(diagnosticDedupKey(
|
|
20396
|
+
seen.add(diagnosticDedupKey(fileKey, diagnostic));
|
|
19854
20397
|
}
|
|
19855
20398
|
}
|
|
19856
|
-
const addDiagnostic = (filePath, widgetDiagnostic) => {
|
|
19857
|
-
const existing = byFile.get(filePath);
|
|
19858
|
-
const diagnostics = existing ? [...existing.diagnostics] : [];
|
|
19859
|
-
const key = diagnosticDedupKey(filePath, widgetDiagnostic);
|
|
19860
|
-
if (seen.has(key))
|
|
19861
|
-
return;
|
|
19862
|
-
seen.add(key);
|
|
19863
|
-
diagnostics.push(widgetDiagnostic);
|
|
19864
|
-
byFile.set(filePath, summarizeDiagnostics(filePath, diagnostics, existing?.hasFinalSnapshot ?? true));
|
|
19865
|
-
};
|
|
19866
20399
|
for (const result of lspResults) {
|
|
19867
20400
|
const filePath = path38.resolve(result.filePath);
|
|
19868
20401
|
for (const diagnostic of result.diagnostics ?? []) {
|
|
@@ -19902,7 +20435,7 @@ async function applyInlineSuppressionsToSummaries(summaries, cwd, policyMap, dis
|
|
|
19902
20435
|
return summary;
|
|
19903
20436
|
let content;
|
|
19904
20437
|
try {
|
|
19905
|
-
content = await
|
|
20438
|
+
content = await fs22.readFile(summary.filePath, "utf8");
|
|
19906
20439
|
} catch {
|
|
19907
20440
|
const policyKept2 = applyRulePolicy(summary.diagnostics, policyMap, {
|
|
19908
20441
|
root: cwd,
|
|
@@ -19916,6 +20449,7 @@ async function applyInlineSuppressionsToSummaries(summaries, cwd, policyMap, dis
|
|
|
19916
20449
|
content,
|
|
19917
20450
|
policyMap
|
|
19918
20451
|
});
|
|
20452
|
+
const pythonKept = await applyDeclarationRule(summary.filePath, policyKept);
|
|
19919
20453
|
if (disposed.length < inlineKept.length) {
|
|
19920
20454
|
const survivors = new Set(disposed);
|
|
19921
20455
|
for (const d of inlineKept) {
|
|
@@ -19923,15 +20457,16 @@ async function applyInlineSuppressionsToSummaries(summaries, cwd, policyMap, dis
|
|
|
19923
20457
|
dispositionDropped.push(d);
|
|
19924
20458
|
}
|
|
19925
20459
|
}
|
|
19926
|
-
for (const d of
|
|
20460
|
+
for (const d of pythonKept.kept) {
|
|
19927
20461
|
const { weak } = anchorsForDiagnostic(cwd, summary.filePath, d, content);
|
|
19928
20462
|
if (getDisposition(cwd, weak)?.disposition === "flagged") {
|
|
19929
20463
|
d.flagged = true;
|
|
19930
20464
|
}
|
|
19931
20465
|
}
|
|
19932
|
-
if (
|
|
20466
|
+
if (pythonKept.kept.length === summary.diagnostics.length) {
|
|
19933
20467
|
return summary;
|
|
19934
|
-
|
|
20468
|
+
}
|
|
20469
|
+
return summarizeDiagnostics(summary.filePath, pythonKept.kept, summary.hasFinalSnapshot);
|
|
19935
20470
|
}));
|
|
19936
20471
|
}
|
|
19937
20472
|
function shouldUseCachedProjectDiagnostics(value) {
|
|
@@ -20065,7 +20600,7 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
20065
20600
|
};
|
|
20066
20601
|
}
|
|
20067
20602
|
const aborted = signal?.aborted ?? false;
|
|
20068
|
-
|
|
20603
|
+
let lspResults = await demoteInferredProjectSweepResults(
|
|
20069
20604
|
rawLspResults.filter((result2) => includeFile(result2.filePath)),
|
|
20070
20605
|
cwd,
|
|
20071
20606
|
lspService,
|
|
@@ -20073,6 +20608,20 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
20073
20608
|
// so the probe loop that post-processes them must be too.
|
|
20074
20609
|
signal
|
|
20075
20610
|
);
|
|
20611
|
+
const pythonSweep = await mapWithConcurrency(lspResults, PYTHON_DECLARATION_CONCURRENCY, async (result2) => {
|
|
20612
|
+
const pythonKept = await applyDeclarationRule(result2.filePath, result2.diagnostics);
|
|
20613
|
+
if (pythonKept.dropped === 0)
|
|
20614
|
+
return { result: result2 };
|
|
20615
|
+
return {
|
|
20616
|
+
result: { ...result2, diagnostics: pythonKept.kept },
|
|
20617
|
+
withheld: pythonKept.declared && {
|
|
20618
|
+
count: pythonKept.dropped,
|
|
20619
|
+
declared: pythonKept.declared
|
|
20620
|
+
}
|
|
20621
|
+
};
|
|
20622
|
+
});
|
|
20623
|
+
lspResults = pythonSweep.map((entry) => entry.result);
|
|
20624
|
+
const withheldCompile = mergeWithheld(pythonSweep.map((entry) => "withheld" in entry ? entry.withheld : void 0));
|
|
20076
20625
|
const mismatchedLspResults = await findFullScanBindingMismatches(lspResults);
|
|
20077
20626
|
const confirmedLspResults = lspResults.filter((result2) => !result2.timedOut && !result2.error && !mismatchedLspResults.has(result2));
|
|
20078
20627
|
const fullyCoveredLspResults = confirmedLspResults.filter((result2) => (result2.unconfirmedServerIds?.length ?? 0) === 0);
|
|
@@ -20082,6 +20631,7 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
20082
20631
|
const unreconciledFiles = /* @__PURE__ */ new Set();
|
|
20083
20632
|
const policyMap = loadProjectRulePolicyMap(cwd);
|
|
20084
20633
|
for (const result2 of fullyCoveredLspResults) {
|
|
20634
|
+
const fileKey = normalizeMapKey(result2.filePath);
|
|
20085
20635
|
try {
|
|
20086
20636
|
const diagnostics = convertLspDiagnostics(result2.diagnostics, result2.filePath, { scanOrigin: "lens_diagnostics_full" });
|
|
20087
20637
|
const retagged = retagAuxiliaryDiagnostics(diagnostics, result2.diagnostics, "", { cwd, fileRole: detectFileRole(result2.filePath) });
|
|
@@ -20092,9 +20642,10 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
20092
20642
|
content: content ?? "",
|
|
20093
20643
|
policyMap
|
|
20094
20644
|
});
|
|
20645
|
+
const pythonKept = await applyDeclarationRule(result2.filePath, policyKept);
|
|
20095
20646
|
const retired = reconcileScanDiagnostics(
|
|
20096
20647
|
result2.filePath,
|
|
20097
|
-
|
|
20648
|
+
pythonKept.kept,
|
|
20098
20649
|
true,
|
|
20099
20650
|
// The service reserves this token when the file enters the scan. The
|
|
20100
20651
|
// fallback preserves compatibility with older test doubles/services.
|
|
@@ -20107,9 +20658,9 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
20107
20658
|
result2.observedAt
|
|
20108
20659
|
);
|
|
20109
20660
|
if (retired === true) {
|
|
20110
|
-
authoritativeLspFiles.add(
|
|
20661
|
+
authoritativeLspFiles.add(fileKey);
|
|
20111
20662
|
} else {
|
|
20112
|
-
unreconciledFiles.add(
|
|
20663
|
+
unreconciledFiles.add(fileKey);
|
|
20113
20664
|
recordDegradationOnce({
|
|
20114
20665
|
kind: "diagnostic-retained-unreconciled",
|
|
20115
20666
|
subject: `${path38.resolve(result2.filePath)}:lsp`,
|
|
@@ -20117,7 +20668,7 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
20117
20668
|
});
|
|
20118
20669
|
}
|
|
20119
20670
|
} catch {
|
|
20120
|
-
unreconciledFiles.add(
|
|
20671
|
+
unreconciledFiles.add(fileKey);
|
|
20121
20672
|
recordDegradationOnce({
|
|
20122
20673
|
kind: "diagnostic-retained-unreconciled",
|
|
20123
20674
|
subject: `${path38.resolve(result2.filePath)}:lsp`,
|
|
@@ -20131,7 +20682,7 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
20131
20682
|
const foldedProjectSnapshot = foldExtraDiagnosticsIntoSnapshot(scannedSnapshot, extracted.diagnostics.filter((d) => includeFile(d.filePath)), extracted.runners, cwd);
|
|
20132
20683
|
const projectSnapshot = applyProjectRulePolicy(foldedProjectSnapshot, policyMap, cwd);
|
|
20133
20684
|
const projectDelta = applyProjectRulePolicy(filterProjectDiagnosticsDeltaReport(loadProjectDiagnosticsDeltaReport(cwd), includeFile), policyMap, cwd);
|
|
20134
|
-
const authoritativeRetiredCount = getFileDiagnosticSummaries().filter((summary) => includeFile(summary.filePath) && authoritativeLspFiles.has(
|
|
20685
|
+
const authoritativeRetiredCount = getFileDiagnosticSummaries().filter((summary) => includeFile(summary.filePath) && authoritativeLspFiles.has(normalizeMapKey(summary.filePath)) && (summary.diagnostics?.length ?? 0) > 0).length;
|
|
20135
20686
|
if (authoritativeRetiredCount > 0) {
|
|
20136
20687
|
logLatency({
|
|
20137
20688
|
type: "phase",
|
|
@@ -20187,14 +20738,14 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
20187
20738
|
const dispositionDropped = [];
|
|
20188
20739
|
let summaries = await applyInlineSuppressionsToSummaries(mergeDiagnosticsWithWidgetSummaries(getFileDiagnosticSummaries().filter((summary) => includeFile(summary.filePath)), confirmedLspResults, projectSnapshot, projectDelta, authoritativeLspFiles, authoritativeRunnerIds, authoritativeRunnerCoverage), cwd, policyMap, dispositionDropped);
|
|
20189
20740
|
if (unreconciledFiles.size > 0) {
|
|
20190
|
-
summaries = summaries.map((summary) => unreconciledFiles.has(
|
|
20741
|
+
summaries = summaries.map((summary) => unreconciledFiles.has(normalizeMapKey(summary.filePath)) ? summarizeDiagnostics(summary.filePath, markUnreconciledFindings(summary.diagnostics), summary.hasFinalSnapshot) : summary);
|
|
20191
20742
|
}
|
|
20192
20743
|
const parsedProjectScanObservedAt = projectSnapshot?.scannedAt ? Date.parse(projectSnapshot.scannedAt) : void 0;
|
|
20193
20744
|
const projectScanObservedAt = parsedProjectScanObservedAt !== void 0 && Number.isFinite(parsedProjectScanObservedAt) ? parsedProjectScanObservedAt : void 0;
|
|
20194
20745
|
for (const summary of summaries) {
|
|
20195
20746
|
reconcileCorrelatedScanDiagnostics(summary.filePath, summary.diagnostics, nextWriteIndex?.(), projectScanObservedAt);
|
|
20196
20747
|
}
|
|
20197
|
-
const
|
|
20748
|
+
const formatted = await formatAllMode(cwd, severity, summaries, {
|
|
20198
20749
|
mode: "full",
|
|
20199
20750
|
lspFilesChecked: rawLspResults.length,
|
|
20200
20751
|
partial: aborted,
|
|
@@ -20209,7 +20760,7 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
20209
20760
|
sources: projectDelta.sources,
|
|
20210
20761
|
turnIndex: projectDelta.turnIndex
|
|
20211
20762
|
}
|
|
20212
|
-
}, 0, pathsScope,
|
|
20763
|
+
}, 0, pathsScope, {
|
|
20213
20764
|
dropped: dispositionDropped,
|
|
20214
20765
|
// #1617: the #1616 suppressed-bucket rule applied to the analyzers —
|
|
20215
20766
|
// a finding marked false-positive/won't-fix drops out of
|
|
@@ -20221,6 +20772,19 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
20221
20772
|
analyzers: extracted.dispositionSuppressed ?? 0,
|
|
20222
20773
|
analyzersByLane: extracted.dispositionSuppressedByLane ?? {}
|
|
20223
20774
|
});
|
|
20775
|
+
const withheldText = withheldCompileNote(withheldCompile);
|
|
20776
|
+
const result = withheldText ? {
|
|
20777
|
+
...formatted,
|
|
20778
|
+
content: [
|
|
20779
|
+
{
|
|
20780
|
+
type: "text",
|
|
20781
|
+
text: `${formatted.content[0].text}
|
|
20782
|
+
|
|
20783
|
+
${withheldText}`
|
|
20784
|
+
}
|
|
20785
|
+
],
|
|
20786
|
+
details: { ...formatted.details, withheldCompile }
|
|
20787
|
+
} : formatted;
|
|
20224
20788
|
const missingNote = pathsScopeMissingNote(pathsScope);
|
|
20225
20789
|
const unconfirmedByReason = tallyUnconfirmedReasons(unconfirmedLspResults, mismatchedLspResults);
|
|
20226
20790
|
const lspServerBreakdown = tallyLspByPrimaryServer(confirmedLspResults, unconfirmedLspResults);
|
|
@@ -20407,9 +20971,7 @@ async function projectResolvedCwd(summary, cwd) {
|
|
|
20407
20971
|
diagnostics: summary.diagnostics ?? []
|
|
20408
20972
|
};
|
|
20409
20973
|
}
|
|
20410
|
-
async function formatAllMode(cwd, severity, summaries = getFileDiagnosticSummaries(), detailOverrides = { mode: "all" }, staleDropped = 0, pathsScope,
|
|
20411
|
-
const footerCapped = summaries.reduce((n, s) => n + (s.diagnostics ?? []).filter((d) => d.footerRetired === true).length, 0);
|
|
20412
|
-
const staleNote = (staleDropped > 0 ? ` (${staleDropped} changed file${staleDropped === 1 ? "" : "s"} omitted as stale \u2014 use mode=full to rescan)` : "") + (dependencyDemoted > 0 ? ` (${dependencyDemoted} blocking finding${dependencyDemoted === 1 ? "" : "s"} demoted to [stale] \u2014 an imported file changed since; re-run to confirm)` : "") + (footerCapped > 0 ? ` (${footerCapped} demoted finding${footerCapped === 1 ? "" : "s"} capped after ${DEPENDENCY_DRIFT_MAX_DELIVERIES} unconfirmed deliveries \u2014 no longer shown in the pi-lens footer, still listed here; re-run to confirm)` : "");
|
|
20974
|
+
async function formatAllMode(cwd, severity, summaries = getFileDiagnosticSummaries(), detailOverrides = { mode: "all" }, staleDropped = 0, pathsScope, fullModeDisposition = { dropped: [], analyzers: 0, analyzersByLane: {} }, sessionEvidence) {
|
|
20413
20975
|
const isFullMode = detailOverrides.mode === "full";
|
|
20414
20976
|
const includeFile = createScopedFileFilter(cwd, pathsScope);
|
|
20415
20977
|
const policyMap = loadProjectRulePolicyMap(cwd);
|
|
@@ -20449,6 +21011,10 @@ async function formatAllMode(cwd, severity, summaries = getFileDiagnosticSummari
|
|
|
20449
21011
|
return summarizeDiagnostics(s.filePath, diagnostics, s.hasFinalSnapshot);
|
|
20450
21012
|
});
|
|
20451
21013
|
const visibleSummaries = eofGated.filter((s) => includeFile(s.filePath));
|
|
21014
|
+
const visibleDiagnostics = visibleSummaries.flatMap((s) => s.diagnostics ?? []);
|
|
21015
|
+
const dependencyDemoted = visibleDiagnostics.filter((d) => d.stale && d.staleReason === "dependency-drift").length;
|
|
21016
|
+
const footerCapped = visibleDiagnostics.filter((d) => d.footerRetired === true).length;
|
|
21017
|
+
const staleNote = (dependencyDemoted > 0 ? ` (${dependencyDemoted} blocking finding${dependencyDemoted === 1 ? "" : "s"} demoted to [stale] \u2014 an imported file changed since; re-run to confirm)` : "") + (footerCapped > 0 ? ` (${footerCapped} demoted finding${footerCapped === 1 ? "" : "s"} capped after ${DEPENDENCY_DRIFT_MAX_DELIVERIES} unconfirmed deliveries \u2014 no longer shown in the pi-lens footer, still listed here; re-run to confirm)` : "");
|
|
20452
21018
|
const withIssues = visibleSummaries.filter((s) => {
|
|
20453
21019
|
if (severity === "error")
|
|
20454
21020
|
return s.blocking > 0 || s.errors > 0;
|
|
@@ -20456,17 +21022,81 @@ async function formatAllMode(cwd, severity, summaries = getFileDiagnosticSummari
|
|
|
20456
21022
|
return s.blocking > 0 || s.errors > 0 || s.warnings > 0;
|
|
20457
21023
|
return s.blocking > 0 || s.errors > 0 || s.warnings > 0 || s.advisories > 0 || (s.diagnostics ?? []).some((d) => d.stale);
|
|
20458
21024
|
});
|
|
20459
|
-
|
|
21025
|
+
let validationStatus;
|
|
21026
|
+
let validationNote = "";
|
|
21027
|
+
let evidenceDetails = {};
|
|
21028
|
+
if (!isFullMode) {
|
|
21029
|
+
const pending2 = visibleSummaries.filter((s) => !s.hasFinalSnapshot);
|
|
21030
|
+
const stale = visibleSummaries.filter((s) => (s.diagnostics ?? []).some((d) => d.stale));
|
|
21031
|
+
const staleDiagnosticCount = visibleDiagnostics.filter((d) => d.stale).length;
|
|
21032
|
+
const requestedFiles = [
|
|
21033
|
+
...pathsScope?.existingEntries ?? [],
|
|
21034
|
+
...pathsScope?.missing ?? []
|
|
21035
|
+
];
|
|
21036
|
+
const observed = requestedFiles.length > 0 ? new Set([
|
|
21037
|
+
...visibleSummaries.map((s) => s.filePath),
|
|
21038
|
+
...sessionEvidence?.stalePaths ?? []
|
|
21039
|
+
].map(normalizeFilePath)) : /* @__PURE__ */ new Set();
|
|
21040
|
+
const unverified = requestedFiles.filter((file) => !observed.has(normalizeFilePath(file)));
|
|
21041
|
+
const rescanPaths = [
|
|
21042
|
+
.../* @__PURE__ */ new Set([
|
|
21043
|
+
...sessionEvidence?.stalePaths ?? [],
|
|
21044
|
+
...pending2.map((s) => s.filePath),
|
|
21045
|
+
...stale.map((s) => s.filePath),
|
|
21046
|
+
...unverified
|
|
21047
|
+
])
|
|
21048
|
+
];
|
|
21049
|
+
validationStatus = staleDropped > 0 || staleDiagnosticCount > 0 || pending2.length > 0 ? "inconclusive" : visibleSummaries.length === 0 || unverified.length > 0 ? "unverified" : withIssues.length > 0 ? "findings" : "no-matching-findings";
|
|
21050
|
+
const nextTool = resolveLensToolName("lens_diagnostics", sessionEvidence?.host ?? "pi");
|
|
21051
|
+
const nextPaths = rescanPaths.slice(0, MAX_PATHS_ENTRIES);
|
|
21052
|
+
const remainingRescanPathCount = rescanPaths.length - nextPaths.length;
|
|
21053
|
+
evidenceDetails = {
|
|
21054
|
+
validationStatus,
|
|
21055
|
+
pendingFileCount: pending2.length,
|
|
21056
|
+
staleDiagnosticCount,
|
|
21057
|
+
unverifiedFileCount: unverified.length,
|
|
21058
|
+
remainingRescanPathCount,
|
|
21059
|
+
...nextPaths.length > 0 ? {
|
|
21060
|
+
nextCheck: {
|
|
21061
|
+
tool: nextTool,
|
|
21062
|
+
source: "lsp",
|
|
21063
|
+
scope: "paths",
|
|
21064
|
+
paths: nextPaths
|
|
21065
|
+
}
|
|
21066
|
+
} : {}
|
|
21067
|
+
};
|
|
21068
|
+
const omittedClause = staleDropped > 0 ? `, ${staleDropped} changed file${staleDropped === 1 ? "" : "s"} omitted as stale` : "";
|
|
21069
|
+
validationNote = validationStatus === "inconclusive" || validationStatus === "unverified" ? `Session cache ${validationStatus} \u2014 not a clean verdict: ${pending2.length} pending file(s), ${staleDiagnosticCount} stale finding(s), ${unverified.length} requested file(s) without cached evidence${omittedClause}. Not active validation.
|
|
21070
|
+
Next check: ${nextTool ?? "diagnostics"} source=lsp scope=paths${nextPaths.length > 0 ? ` paths=${JSON.stringify(nextPaths)}` : " with the changed paths"}.` + (remainingRescanPathCount > 0 ? ` ${remainingRescanPathCount} more path(s) need a check; narrow or batch the remaining paths.` : "") + " LSP may not cover these files; use a file-appropriate validator for unsupported or missing files.\n" : "Session cache only; not active validation.\n";
|
|
21071
|
+
logLatency({
|
|
21072
|
+
type: "phase",
|
|
21073
|
+
phase: "lens_diagnostics_session_evidence",
|
|
21074
|
+
toolName: "lens_diagnostics",
|
|
21075
|
+
filePath: cwd,
|
|
21076
|
+
durationMs: 0,
|
|
21077
|
+
metadata: {
|
|
21078
|
+
validationStatus,
|
|
21079
|
+
pendingFileCount: pending2.length,
|
|
21080
|
+
staleDiagnosticCount,
|
|
21081
|
+
staleDropped,
|
|
21082
|
+
unverifiedFileCount: unverified.length,
|
|
21083
|
+
remainingRescanPathCount
|
|
21084
|
+
}
|
|
21085
|
+
});
|
|
21086
|
+
}
|
|
21087
|
+
const pathsNote = isFullMode || evidenceDetails.nextCheck !== void 0 ? "" : pathsScopeCacheOnlyNote(pathsScope);
|
|
20460
21088
|
const suppressedLine = dispositionSuppressedLine(dispositionSuppressed, suppressedBreakdown);
|
|
20461
21089
|
const suppressedNote = suppressedLine ? `
|
|
20462
21090
|
${suppressedLine}` : "";
|
|
20463
21091
|
const suppressedDetails = dispositionSuppressed > 0 ? { dispositionSuppressed } : {};
|
|
20464
21092
|
if (withIssues.length === 0) {
|
|
20465
|
-
const text = (visibleSummaries.length === 0 ? "No files diagnosed yet this session
|
|
21093
|
+
const text = (visibleSummaries.length === 0 ? "No files diagnosed yet this session.\n" : validationStatus === "inconclusive" || validationStatus === "unverified" ? "" : `No ${severity === "all" ? "" : severity + " "}issues across ${visibleSummaries.length} file${visibleSummaries.length === 1 ? "" : "s"} diagnosed this session. \u2713
|
|
21094
|
+
`) + validationNote + staleNote + suppressedNote + pathsNote;
|
|
20466
21095
|
return {
|
|
20467
21096
|
content: [{ type: "text", text }],
|
|
20468
21097
|
details: {
|
|
20469
21098
|
...detailOverrides,
|
|
21099
|
+
...evidenceDetails,
|
|
20470
21100
|
filesChecked: visibleSummaries.length,
|
|
20471
21101
|
staleDropped,
|
|
20472
21102
|
...suppressedDetails
|
|
@@ -20481,7 +21111,7 @@ ${suppressedLine}` : "";
|
|
|
20481
21111
|
let totalWarnings = 0;
|
|
20482
21112
|
let totalAdvisories = 0;
|
|
20483
21113
|
for (const s of rendered) {
|
|
20484
|
-
const rel =
|
|
21114
|
+
const rel = toProjectRelativePath(s.filePath, cwd);
|
|
20485
21115
|
const parts = [];
|
|
20486
21116
|
if (s.blocking > 0)
|
|
20487
21117
|
parts.push(`\u{1F534} ${s.blocking} blocking`);
|
|
@@ -20535,11 +21165,12 @@ Summary (${visibleSummaries.length} files diagnosed this session):`,
|
|
|
20535
21165
|
content: [
|
|
20536
21166
|
{
|
|
20537
21167
|
type: "text",
|
|
20538
|
-
text: lines.join("\n") + summary + staleNote + suppressedNote
|
|
21168
|
+
text: validationNote + lines.join("\n") + summary + staleNote + suppressedNote
|
|
20539
21169
|
}
|
|
20540
21170
|
],
|
|
20541
21171
|
details: {
|
|
20542
21172
|
...detailOverrides,
|
|
21173
|
+
...evidenceDetails,
|
|
20543
21174
|
filesWithIssues: withIssues.length,
|
|
20544
21175
|
totalBlocking,
|
|
20545
21176
|
totalErrors,
|
|
@@ -20552,7 +21183,7 @@ Summary (${visibleSummaries.length} files diagnosed this session):`,
|
|
|
20552
21183
|
}
|
|
20553
21184
|
|
|
20554
21185
|
// dist/tools/lsp-navigation.js
|
|
20555
|
-
import * as
|
|
21186
|
+
import * as nodeFs3 from "node:fs";
|
|
20556
21187
|
import * as path39 from "node:path";
|
|
20557
21188
|
import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
20558
21189
|
|
|
@@ -20884,6 +21515,43 @@ function normalizeOperation(value) {
|
|
|
20884
21515
|
function isValidOperation(value) {
|
|
20885
21516
|
return VALID_OPERATIONS.includes(value);
|
|
20886
21517
|
}
|
|
21518
|
+
function rangeProblem(value) {
|
|
21519
|
+
if (!value || typeof value !== "object")
|
|
21520
|
+
return " must be a range object";
|
|
21521
|
+
for (const end of ["start", "end"]) {
|
|
21522
|
+
const position = value[end];
|
|
21523
|
+
if (!position || typeof position !== "object")
|
|
21524
|
+
return `.${end} must be a position object`;
|
|
21525
|
+
for (const axis of ["line", "character"]) {
|
|
21526
|
+
if (typeof position[axis] !== "number")
|
|
21527
|
+
return `.${end}.${axis} must be a number`;
|
|
21528
|
+
}
|
|
21529
|
+
}
|
|
21530
|
+
return void 0;
|
|
21531
|
+
}
|
|
21532
|
+
function checkCallHierarchyItem(value) {
|
|
21533
|
+
if (value === void 0 || value === null)
|
|
21534
|
+
return { problem: "callHierarchyItem parameter required" };
|
|
21535
|
+
if (typeof value !== "object" || Array.isArray(value))
|
|
21536
|
+
return {
|
|
21537
|
+
problem: "callHierarchyItem must be the object prepareCallHierarchy returned"
|
|
21538
|
+
};
|
|
21539
|
+
const item = value;
|
|
21540
|
+
for (const [field, type] of [
|
|
21541
|
+
["name", "string"],
|
|
21542
|
+
["kind", "number"],
|
|
21543
|
+
["uri", "string"]
|
|
21544
|
+
]) {
|
|
21545
|
+
if (typeof item[field] !== type)
|
|
21546
|
+
return { problem: `callHierarchyItem.${field} must be a ${type}` };
|
|
21547
|
+
}
|
|
21548
|
+
for (const field of ["range", "selectionRange"]) {
|
|
21549
|
+
const problem = rangeProblem(item[field]);
|
|
21550
|
+
if (problem)
|
|
21551
|
+
return { problem: `callHierarchyItem.${field}${problem}` };
|
|
21552
|
+
}
|
|
21553
|
+
return { item: value };
|
|
21554
|
+
}
|
|
20887
21555
|
function operationSupportStatus(operation, support) {
|
|
20888
21556
|
if (!support)
|
|
20889
21557
|
return null;
|
|
@@ -21330,7 +21998,7 @@ function classifyCodeActions(actions) {
|
|
|
21330
21998
|
async function openFileBestEffort(lspService, filePath, waitForDiagnostics = false, excludeServerIds) {
|
|
21331
21999
|
let fileContent;
|
|
21332
22000
|
try {
|
|
21333
|
-
fileContent =
|
|
22001
|
+
fileContent = nodeFs3.readFileSync(filePath, "utf-8");
|
|
21334
22002
|
} catch {
|
|
21335
22003
|
return void 0;
|
|
21336
22004
|
}
|
|
@@ -21347,51 +22015,6 @@ async function openFileBestEffort(lspService, filePath, waitForDiagnostics = fal
|
|
|
21347
22015
|
}
|
|
21348
22016
|
return fileContent;
|
|
21349
22017
|
}
|
|
21350
|
-
var RENAME_MTIME_MARGIN_MS = 2e3;
|
|
21351
|
-
function captureRenameExpectedContent(lspService, edit, cwd, targetFilePath, targetContent, requestedAtMs) {
|
|
21352
|
-
const expected = /* @__PURE__ */ new Map();
|
|
21353
|
-
let targetRealPath;
|
|
21354
|
-
if (targetContent !== void 0) {
|
|
21355
|
-
try {
|
|
21356
|
-
targetRealPath = nodeFs2.realpathSync.native(targetFilePath);
|
|
21357
|
-
} catch {
|
|
21358
|
-
targetRealPath = void 0;
|
|
21359
|
-
}
|
|
21360
|
-
}
|
|
21361
|
-
for (const diskPath of workspaceEditTextPaths(edit)) {
|
|
21362
|
-
let realPath;
|
|
21363
|
-
let content;
|
|
21364
|
-
let mtimeMs;
|
|
21365
|
-
try {
|
|
21366
|
-
realPath = nodeFs2.realpathSync.native(diskPath);
|
|
21367
|
-
content = nodeFs2.readFileSync(realPath, "utf-8");
|
|
21368
|
-
mtimeMs = nodeFs2.statSync(realPath).mtimeMs;
|
|
21369
|
-
} catch {
|
|
21370
|
-
continue;
|
|
21371
|
-
}
|
|
21372
|
-
if (targetContent !== void 0 && realPath === targetRealPath) {
|
|
21373
|
-
expected.set(realPath, targetContent);
|
|
21374
|
-
continue;
|
|
21375
|
-
}
|
|
21376
|
-
const tracked = lspService.getTrackedContent(diskPath, cwd);
|
|
21377
|
-
const firstOpenedAfterRequest = tracked !== void 0 && (tracked.openedAtMs ?? 0) >= requestedAtMs;
|
|
21378
|
-
const quietSinceClientStart = tracked?.clientStartedAtMs !== void 0 && mtimeMs < tracked.clientStartedAtMs - RENAME_MTIME_MARGIN_MS;
|
|
21379
|
-
const sent = firstOpenedAfterRequest && quietSinceClientStart ? void 0 : tracked;
|
|
21380
|
-
if (sent !== void 0) {
|
|
21381
|
-
if (sent.hash !== hashDiagnosticContent(content) || (sent.changedAtMs ?? requestedAtMs) >= requestedAtMs) {
|
|
21382
|
-
refuseStaleWorkspaceEdit(diskPath, "it changed after the language server computed the rename from it");
|
|
21383
|
-
}
|
|
21384
|
-
} else if (tracked !== void 0 && (tracked.hash !== hashDiagnosticContent(content) || tracked.openedHash !== tracked.hash)) {
|
|
21385
|
-
refuseStaleWorkspaceEdit(diskPath, "it changed after the language client first opened it, after the rename was requested");
|
|
21386
|
-
} else if (mtimeMs >= requestedAtMs) {
|
|
21387
|
-
refuseStaleWorkspaceEdit(diskPath, "it was written after the rename was requested and the language server has no open copy, so it may not have read these bytes");
|
|
21388
|
-
} else if (mtimeMs >= requestedAtMs - RENAME_MTIME_MARGIN_MS) {
|
|
21389
|
-
refuseStaleWorkspaceEdit(diskPath, `it was modified within ${RENAME_MTIME_MARGIN_MS / 1e3} s of the rename request; retry`);
|
|
21390
|
-
}
|
|
21391
|
-
expected.set(realPath, content);
|
|
21392
|
-
}
|
|
21393
|
-
return expected;
|
|
21394
|
-
}
|
|
21395
22018
|
function createLspNavigationTool(getFlag, mutationDeps) {
|
|
21396
22019
|
return {
|
|
21397
22020
|
name: "lsp_navigation",
|
|
@@ -21411,7 +22034,8 @@ function createLspNavigationTool(getFlag, mutationDeps) {
|
|
|
21411
22034
|
}),
|
|
21412
22035
|
parameters: Type.Object({
|
|
21413
22036
|
operation: Type.String({
|
|
21414
|
-
|
|
22037
|
+
enum: [...VALID_OPERATIONS],
|
|
22038
|
+
description: "LSP operation."
|
|
21415
22039
|
}),
|
|
21416
22040
|
path: Type.Optional(Type.String({
|
|
21417
22041
|
description: "Target file path."
|
|
@@ -21461,31 +22085,11 @@ function createLspNavigationTool(getFlag, mutationDeps) {
|
|
|
21461
22085
|
maxResults: Type.Optional(Type.Number({
|
|
21462
22086
|
description: "Maximum symbol matches."
|
|
21463
22087
|
})),
|
|
21464
|
-
|
|
21465
|
-
|
|
21466
|
-
|
|
21467
|
-
|
|
21468
|
-
|
|
21469
|
-
start: Type.Object({
|
|
21470
|
-
line: Type.Number(),
|
|
21471
|
-
character: Type.Number()
|
|
21472
|
-
}),
|
|
21473
|
-
end: Type.Object({
|
|
21474
|
-
line: Type.Number(),
|
|
21475
|
-
character: Type.Number()
|
|
21476
|
-
})
|
|
21477
|
-
}),
|
|
21478
|
-
selectionRange: Type.Object({
|
|
21479
|
-
start: Type.Object({
|
|
21480
|
-
line: Type.Number(),
|
|
21481
|
-
character: Type.Number()
|
|
21482
|
-
}),
|
|
21483
|
-
end: Type.Object({
|
|
21484
|
-
line: Type.Number(),
|
|
21485
|
-
character: Type.Number()
|
|
21486
|
-
})
|
|
21487
|
-
})
|
|
21488
|
-
}, {}))
|
|
22088
|
+
// #4687: opaque on the wire (the nested schema was 817 bytes per
|
|
22089
|
+
// request); `checkCallHierarchyItem` checks the shape at execute.
|
|
22090
|
+
callHierarchyItem: Type.Optional(Type.Object({}, {
|
|
22091
|
+
description: "An item prepareCallHierarchy returned, passed back unchanged."
|
|
22092
|
+
}))
|
|
21489
22093
|
}),
|
|
21490
22094
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
21491
22095
|
const session = mutationDeps?.runtime?.captureSessionGeneration?.();
|
|
@@ -21645,7 +22249,7 @@ function createLspNavigationTool(getFlag, mutationDeps) {
|
|
|
21645
22249
|
let filePathIsDirectory = false;
|
|
21646
22250
|
if (filePath) {
|
|
21647
22251
|
try {
|
|
21648
|
-
filePathIsDirectory =
|
|
22252
|
+
filePathIsDirectory = nodeFs3.statSync(filePath).isDirectory();
|
|
21649
22253
|
} catch {
|
|
21650
22254
|
}
|
|
21651
22255
|
}
|
|
@@ -21691,9 +22295,11 @@ function createLspNavigationTool(getFlag, mutationDeps) {
|
|
|
21691
22295
|
}
|
|
21692
22296
|
const excludeServerIds = configDisabledAuxiliaryLspServerIds((name) => getFlag(name, ctx.cwd));
|
|
21693
22297
|
const openedContent = await openFileBestEffort(lspService, filePath, true, excludeServerIds);
|
|
21694
|
-
const
|
|
22298
|
+
const pythonCompileTarget = await detectPythonTargetVersion(filePath);
|
|
22299
|
+
const policy = applyProbeFindingPolicy(filePath, await lspService.getDiagnostics(filePath, void 0, excludeServerIds), policyCwd, openedContent, "all", "lsp_navigation", pythonCompileTarget);
|
|
21695
22300
|
const diagnostics = policy.kept;
|
|
21696
22301
|
const suppressedLine = dispositionSuppressedLine(policy.suppressed);
|
|
22302
|
+
const withheldLine = withheldCompileNote(policy.withheld);
|
|
21697
22303
|
const primaryUnavailable = describePrimaryUnavailable(void 0, lspService.getDiagnosticsHealth(filePath))?.text;
|
|
21698
22304
|
const result3 = [
|
|
21699
22305
|
{
|
|
@@ -21715,7 +22321,8 @@ function createLspNavigationTool(getFlag, mutationDeps) {
|
|
|
21715
22321
|
text: `${note2}
|
|
21716
22322
|
${JSON.stringify(result3)}${primaryUnavailable ? `
|
|
21717
22323
|
Note: ${primaryUnavailable}` : ""}${suppressedLine ? `
|
|
21718
|
-
Note: ${suppressedLine}` : ""}`
|
|
22324
|
+
Note: ${suppressedLine}` : ""}${withheldLine ? `
|
|
22325
|
+
Note: ${withheldLine}` : ""}`
|
|
21719
22326
|
}
|
|
21720
22327
|
],
|
|
21721
22328
|
details: {
|
|
@@ -21726,6 +22333,9 @@ Note: ${suppressedLine}` : ""}`
|
|
|
21726
22333
|
...policy.suppressed > 0 && {
|
|
21727
22334
|
dispositionSuppressed: policy.suppressed
|
|
21728
22335
|
},
|
|
22336
|
+
...policy.withheld && {
|
|
22337
|
+
withheldCompile: policy.withheld
|
|
22338
|
+
},
|
|
21729
22339
|
...primaryUnavailable !== void 0 && {
|
|
21730
22340
|
unconfirmed: true,
|
|
21731
22341
|
primaryUnavailable
|
|
@@ -21739,12 +22349,25 @@ Note: ${suppressedLine}` : ""}`
|
|
|
21739
22349
|
});
|
|
21740
22350
|
}
|
|
21741
22351
|
const allDiagnostics = await lspService.getAllDiagnostics(configDisabledAuxiliaryLspServerIds((name) => getFlag(name, ctx.cwd)));
|
|
22352
|
+
const compileVerdictFiles = [];
|
|
22353
|
+
for (const [trackedFile, entry] of allDiagnostics) {
|
|
22354
|
+
if (entry.diags.some(isJediCompileVerdict)) {
|
|
22355
|
+
compileVerdictFiles.push(trackedFile);
|
|
22356
|
+
}
|
|
22357
|
+
}
|
|
22358
|
+
const compileVerdictTargets = await mapWithConcurrency(compileVerdictFiles, PYTHON_DECLARATION_CONCURRENCY, async (trackedFile) => ({
|
|
22359
|
+
trackedFile,
|
|
22360
|
+
target: await detectPythonTargetVersion(trackedFile)
|
|
22361
|
+
}));
|
|
22362
|
+
const pythonCompileTargets = new Map(compileVerdictTargets.map((entry) => [entry.trackedFile, entry.target]));
|
|
21742
22363
|
let snapshotSuppressed = 0;
|
|
22364
|
+
const snapshotWithheldEntries = [];
|
|
21743
22365
|
const result2 = Array.from(allDiagnostics.entries()).map(([trackedFile, { diags, ts }]) => {
|
|
21744
22366
|
let kept = diags;
|
|
21745
22367
|
if (diags.length > 0) {
|
|
21746
|
-
const policy = applyProbeFindingPolicy(trackedFile, diags, policyCwd, readFileContent(trackedFile), "all", "lsp_navigation");
|
|
22368
|
+
const policy = applyProbeFindingPolicy(trackedFile, diags, policyCwd, readFileContent(trackedFile), "all", "lsp_navigation", pythonCompileTargets.get(trackedFile));
|
|
21747
22369
|
snapshotSuppressed += policy.suppressed;
|
|
22370
|
+
snapshotWithheldEntries.push(policy.withheld);
|
|
21748
22371
|
kept = policy.kept;
|
|
21749
22372
|
}
|
|
21750
22373
|
return {
|
|
@@ -21755,6 +22378,8 @@ Note: ${suppressedLine}` : ""}`
|
|
|
21755
22378
|
};
|
|
21756
22379
|
});
|
|
21757
22380
|
const snapshotSuppressedLine = dispositionSuppressedLine(snapshotSuppressed);
|
|
22381
|
+
const snapshotWithheld = mergeWithheld(snapshotWithheldEntries);
|
|
22382
|
+
const snapshotWithheldLine = withheldCompileNote(snapshotWithheld);
|
|
21758
22383
|
const noteMap2 = {
|
|
21759
22384
|
"push-only": "Note: push-only tracked diagnostics snapshot (not full workspace pull diagnostics).",
|
|
21760
22385
|
pull: "Note: tracked diagnostics snapshot from active clients. Provide path to force file-level diagnostics collection"
|
|
@@ -21766,7 +22391,8 @@ Note: ${suppressedLine}` : ""}`
|
|
|
21766
22391
|
type: "text",
|
|
21767
22392
|
text: `${note}
|
|
21768
22393
|
${JSON.stringify(result2)}${snapshotSuppressedLine ? `
|
|
21769
|
-
Note: ${snapshotSuppressedLine}` : ""}`
|
|
22394
|
+
Note: ${snapshotSuppressedLine}` : ""}${snapshotWithheldLine ? `
|
|
22395
|
+
Note: ${snapshotWithheldLine}` : ""}`
|
|
21770
22396
|
}
|
|
21771
22397
|
],
|
|
21772
22398
|
details: {
|
|
@@ -21776,6 +22402,9 @@ Note: ${snapshotSuppressedLine}` : ""}`
|
|
|
21776
22402
|
coverage: "tracked-open-files",
|
|
21777
22403
|
...snapshotSuppressed > 0 && {
|
|
21778
22404
|
dispositionSuppressed: snapshotSuppressed
|
|
22405
|
+
},
|
|
22406
|
+
...snapshotWithheld && {
|
|
22407
|
+
withheldCompile: snapshotWithheld
|
|
21779
22408
|
}
|
|
21780
22409
|
}
|
|
21781
22410
|
}, {
|
|
@@ -21853,7 +22482,7 @@ Note: ${snapshotSuppressedLine}` : ""}`
|
|
|
21853
22482
|
"implementation",
|
|
21854
22483
|
"prepareCallHierarchy"
|
|
21855
22484
|
].includes(operation);
|
|
21856
|
-
const resolvedCharacter = needsPosition && filePath ? resolveSymbolColumn(
|
|
22485
|
+
const resolvedCharacter = needsPosition && filePath ? resolveSymbolColumn(nodeFs3.existsSync(filePath) ? nodeFs3.readFileSync(filePath, "utf-8") : "", line ?? 1, character, symbol) : {
|
|
21857
22486
|
character: character ?? 1,
|
|
21858
22487
|
strategy: "explicit"
|
|
21859
22488
|
};
|
|
@@ -21942,7 +22571,7 @@ Note: ${snapshotSuppressedLine}` : ""}`
|
|
|
21942
22571
|
// file held when it answered. A file that changed in between is
|
|
21943
22572
|
// refused inside pi's queue, before any write, so the edit never
|
|
21944
22573
|
// lands on text it was not computed for.
|
|
21945
|
-
expectedContent: captureRenameExpectedContent(
|
|
22574
|
+
expectedContent: captureRenameExpectedContent(edit, ctx.cwd || ".", renameRequestedAtMs, (filePath2, atCwd) => lspService.getTrackedContent(filePath2, atCwd), openedFileContent === void 0 ? void 0 : { filePath, content: openedFileContent })
|
|
21946
22575
|
});
|
|
21947
22576
|
for (const touchedFile of applied.files) {
|
|
21948
22577
|
try {
|
|
@@ -21998,24 +22627,26 @@ Note: ${snapshotSuppressedLine}` : ""}`
|
|
|
21998
22627
|
return rawPath ? lspService.executeCommand(filePath, command, commandArguments, mutationContext) : lspService.executeCommand(void 0, command, commandArguments, mutationContext, workspaceScopeAttribution);
|
|
21999
22628
|
}
|
|
22000
22629
|
case "incomingCalls": {
|
|
22001
|
-
|
|
22002
|
-
|
|
22630
|
+
const checked = checkCallHierarchyItem(callHierarchyItem);
|
|
22631
|
+
if ("problem" in checked) {
|
|
22632
|
+
throw new Error(`__BADINPUT__ ${checked.problem} for incomingCalls`);
|
|
22003
22633
|
}
|
|
22004
|
-
supported = operationSupportStatus(operation, await lspService.getOperationSupport(uriToPath(
|
|
22634
|
+
supported = operationSupportStatus(operation, await lspService.getOperationSupport(uriToPath(checked.item.uri)));
|
|
22005
22635
|
if (supported === false) {
|
|
22006
22636
|
throw new Error("__UNSUPPORTED__ Active LSP server does not advertise support for incomingCalls");
|
|
22007
22637
|
}
|
|
22008
|
-
return lspService.incomingCalls(
|
|
22638
|
+
return lspService.incomingCalls(checked.item);
|
|
22009
22639
|
}
|
|
22010
22640
|
case "outgoingCalls": {
|
|
22011
|
-
|
|
22012
|
-
|
|
22641
|
+
const checked = checkCallHierarchyItem(callHierarchyItem);
|
|
22642
|
+
if ("problem" in checked) {
|
|
22643
|
+
throw new Error(`__BADINPUT__ ${checked.problem} for outgoingCalls`);
|
|
22013
22644
|
}
|
|
22014
|
-
supported = operationSupportStatus(operation, await lspService.getOperationSupport(uriToPath(
|
|
22645
|
+
supported = operationSupportStatus(operation, await lspService.getOperationSupport(uriToPath(checked.item.uri)));
|
|
22015
22646
|
if (supported === false) {
|
|
22016
22647
|
throw new Error("__UNSUPPORTED__ Active LSP server does not advertise support for outgoingCalls");
|
|
22017
22648
|
}
|
|
22018
|
-
return lspService.outgoingCalls(
|
|
22649
|
+
return lspService.outgoingCalls(checked.item);
|
|
22019
22650
|
}
|
|
22020
22651
|
default:
|
|
22021
22652
|
return [];
|
|
@@ -22043,7 +22674,7 @@ Note: ${snapshotSuppressedLine}` : ""}`
|
|
|
22043
22674
|
}
|
|
22044
22675
|
const stillEmpty = !result || Array.isArray(result) && result.length === 0;
|
|
22045
22676
|
if (stillEmpty && needsFilePath && operation === "definition") {
|
|
22046
|
-
const content =
|
|
22677
|
+
const content = nodeFs3.readFileSync(filePath, "utf-8");
|
|
22047
22678
|
const token = line && character ? tokenAtPosition(content, line, character) : void 0;
|
|
22048
22679
|
if (token) {
|
|
22049
22680
|
const docSymbols = await lspService.documentSymbol(filePath);
|
|
@@ -22283,10 +22914,10 @@ Not run: ${reasons.join("; ")}.`
|
|
|
22283
22914
|
}
|
|
22284
22915
|
|
|
22285
22916
|
// dist/mcp/build-staleness.js
|
|
22286
|
-
import * as
|
|
22917
|
+
import * as fs23 from "node:fs";
|
|
22287
22918
|
var realStat = (targetPath) => {
|
|
22288
22919
|
try {
|
|
22289
|
-
return
|
|
22920
|
+
return fs23.statSync(targetPath);
|
|
22290
22921
|
} catch {
|
|
22291
22922
|
return void 0;
|
|
22292
22923
|
}
|
|
@@ -22377,9 +23008,9 @@ function findRepoRoot(start) {
|
|
|
22377
23008
|
let dir = start;
|
|
22378
23009
|
for (let depth = 0; depth < 6; depth++) {
|
|
22379
23010
|
const pkgPath = path40.join(dir, "package.json");
|
|
22380
|
-
if (
|
|
23011
|
+
if (fs24.existsSync(pkgPath)) {
|
|
22381
23012
|
try {
|
|
22382
|
-
const pkg = JSON.parse(
|
|
23013
|
+
const pkg = JSON.parse(fs24.readFileSync(pkgPath, "utf8"));
|
|
22383
23014
|
if (pkg.name === "pi-lens")
|
|
22384
23015
|
return dir;
|
|
22385
23016
|
} catch {
|
|
@@ -23435,7 +24066,12 @@ ${outcome.tests}` : ""
|
|
|
23435
24066
|
if (name === "pilens_ast_grep_search" || name === "pilens_ast_grep_replace") {
|
|
23436
24067
|
const cwd = typeof args.cwd === "string" ? args.cwd : DEFAULT_CWD;
|
|
23437
24068
|
const tool = name === "pilens_ast_grep_search" ? astGrepSearchTool : astGrepReplaceTool;
|
|
23438
|
-
const
|
|
24069
|
+
const ctx = {
|
|
24070
|
+
cwd,
|
|
24071
|
+
resultMaxItems: Number.POSITIVE_INFINITY,
|
|
24072
|
+
...name === "pilens_ast_grep_search" ? { host: "mcp" } : {}
|
|
24073
|
+
};
|
|
24074
|
+
const out = await tool.execute("mcp", args, new AbortController().signal, void 0, ctx);
|
|
23439
24075
|
return out;
|
|
23440
24076
|
}
|
|
23441
24077
|
if (name === "pilens_lsp_navigation") {
|