@herbertgao/pi-extensions 2026.11.20 → 2026.11.21
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 +6 -0
- package/README.md +8 -8
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/node_modules/@estebanforge/pi-antigravity-bridge/CHANGELOG.md +8 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/README.md +9 -5
- package/node_modules/@estebanforge/pi-antigravity-bridge/extensions/index.ts +11 -1
- package/node_modules/@estebanforge/pi-antigravity-bridge/package.json +1 -1
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/config.ts +71 -13
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/provider.ts +148 -47
- package/node_modules/@narumitw/pi-btw/CHANGELOG.md +7 -0
- package/node_modules/@narumitw/pi-btw/dist/chunks/{main-tree-picker-3PXJARQW.ts → main-tree-picker-WMTVRTR2.ts} +1 -1
- package/node_modules/@narumitw/pi-btw/dist/chunks/main-tree-picker-WMTVRTR2.ts.map +7 -0
- package/node_modules/@narumitw/pi-btw/dist/index.ts +1 -1
- package/node_modules/@narumitw/pi-btw/docs/core-alignment.md +6 -0
- package/node_modules/@narumitw/pi-btw/package.json +5 -5
- package/node_modules/@narumitw/pi-btw/src/main-tree-picker.ts +1 -1
- package/node_modules/@narumitw/pi-caffeinate/CHANGELOG.md +7 -0
- package/node_modules/@narumitw/pi-caffeinate/package.json +3 -3
- package/node_modules/pi-lens/CHANGELOG-USER.md +6 -6
- package/node_modules/pi-lens/CHANGELOG.md +121 -0
- package/node_modules/pi-lens/README.md +9 -2
- package/node_modules/pi-lens/dist/{chunk-ZVQUYCBU.js → chunk-2ERVW2UF.js} +161 -100
- package/node_modules/pi-lens/dist/{chunk-AFSG6YUB.js → chunk-2K7BUOKS.js} +13 -13
- package/node_modules/pi-lens/dist/{chunk-BJGWP4UX.js → chunk-3JJ4OAJI.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-GIK6VUCY.js → chunk-3UHGSUVL.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-EKQDQPX6.js → chunk-463WN3VP.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-F7BFIENK.js → chunk-4X3ML2UQ.js} +29 -32
- package/node_modules/pi-lens/dist/{chunk-7JMEPY6P.js → chunk-5BI5YP57.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-MKW7ZUTT.js → chunk-5Z4XLUFF.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-NIZKGBOU.js → chunk-62AJH3IN.js} +12 -14
- package/node_modules/pi-lens/dist/{chunk-4GLSO2EM.js → chunk-6F34GMP7.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-35UJUF27.js → chunk-6LIUVGOR.js} +13 -3
- package/node_modules/pi-lens/dist/{chunk-WJ7GY5WJ.js → chunk-6REF4GCO.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-HFIFEH46.js → chunk-7KRR24GO.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-WAK2AXQQ.js → chunk-7OMOMBEQ.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-S7KUDW73.js → chunk-7ZFXICNN.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-VEF3GFOL.js → chunk-ABKRQVOY.js} +28 -52
- package/node_modules/pi-lens/dist/{chunk-Y2LIOCA7.js → chunk-ANSLRJBG.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-ARTCVE6I.js → chunk-AWMFBPGJ.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-H6DNTQ4V.js → chunk-BG7KHGNX.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-FD4LJQ6Y.js → chunk-BK2R2223.js} +10 -8
- package/node_modules/pi-lens/dist/{chunk-TWAQFMLW.js → chunk-BXXC6KRR.js} +31 -34
- package/node_modules/pi-lens/dist/{chunk-S247BOH2.js → chunk-CKJS2AUI.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-GNK2IHVG.js → chunk-COGU5KQJ.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-P7EV5ISR.js → chunk-CQNXALZJ.js} +12 -6
- package/node_modules/pi-lens/dist/{chunk-IO6P3NBP.js → chunk-CSZESDPP.js} +1 -1
- package/node_modules/pi-lens/dist/chunk-CZ5TCJPB.js +98 -0
- package/node_modules/pi-lens/dist/{chunk-DLGJYQML.js → chunk-D2LFEA5U.js} +9 -2
- package/node_modules/pi-lens/dist/chunk-D3KLF5CD.js +50 -0
- package/node_modules/pi-lens/dist/{chunk-W2JPGW7Q.js → chunk-ENJ2M76Y.js} +20 -20
- package/node_modules/pi-lens/dist/{chunk-2DWNYVUN.js → chunk-EQKF6BAK.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-KIQSNH3F.js → chunk-F2SAP2FM.js} +38 -45
- package/node_modules/pi-lens/dist/{chunk-BYIEU4E4.js → chunk-F6QAJXQV.js} +2 -2
- package/node_modules/pi-lens/dist/chunk-GR2QDWH5.js +25 -0
- package/node_modules/pi-lens/dist/{chunk-T2D2WWP6.js → chunk-GVE5VZYQ.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-HMXWZUQW.js → chunk-GWZZOJD2.js} +1 -1
- package/node_modules/pi-lens/dist/chunk-GZS6VPIE.js +27 -0
- package/node_modules/pi-lens/dist/chunk-H4B4SC7I.js +71 -0
- package/node_modules/pi-lens/dist/{chunk-2RQREVGO.js → chunk-HA6TUJOE.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-NAACKIKT.js → chunk-HKPJTI47.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-NHHS5T52.js → chunk-HPKC55MA.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-B2QO7GHY.js → chunk-I65CQLCG.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-BQ72NQQM.js → chunk-IDKLWVKY.js} +11 -11
- package/node_modules/pi-lens/dist/chunk-IUM2Q7NF.js +25 -0
- package/node_modules/pi-lens/dist/{chunk-PVV27TOX.js → chunk-J24IS3KZ.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-DKXIUGNA.js → chunk-J2DAHH4T.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-CDAJQBKJ.js → chunk-JBDZVOFL.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-T7KHGEJ5.js → chunk-JC6NFC57.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-BWGNVM33.js → chunk-JTHEUTW7.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-WWZLT6AM.js → chunk-JWW3ODBN.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-Q32RJDYC.js → chunk-K3ZIYLHT.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-LDPY22FS.js → chunk-KDPZA2UE.js} +2 -3
- package/node_modules/pi-lens/dist/{chunk-YIEHUKX2.js → chunk-KMY2OU4T.js} +489 -285
- package/node_modules/pi-lens/dist/{chunk-WH6O4IFD.js → chunk-KQF7VT26.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-OG3UCAHV.js → chunk-KVGA7X76.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-TABDCX35.js → chunk-KW7O72AK.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-AOEVZXR6.js → chunk-LEQTVRSV.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-7BWPQZHE.js → chunk-LKPSBM6S.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-WA6U2URH.js → chunk-LKW2HFSZ.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-M3QGXGY4.js → chunk-LURFD4HD.js} +624 -97
- package/node_modules/pi-lens/dist/{chunk-2YQ5LI7R.js → chunk-M6ELTECW.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-OHTHVILU.js → chunk-MGVVYYKW.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-W2YHHNY3.js → chunk-MQBKGRSB.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-MET776XM.js → chunk-MVG2ZEAO.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-2XALJI2K.js → chunk-MY4XNNTX.js} +39 -41
- package/node_modules/pi-lens/dist/{chunk-GFCPPCNR.js → chunk-N4AJVFRF.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-UARVPNAU.js → chunk-OFKKMXWM.js} +31 -36
- package/node_modules/pi-lens/dist/{chunk-DHFJS2I4.js → chunk-OFZE4ANN.js} +8 -8
- package/node_modules/pi-lens/dist/chunk-OLXBUTJR.js +61 -0
- package/node_modules/pi-lens/dist/{chunk-SJ2SR432.js → chunk-OZGEHOSG.js} +38 -17
- package/node_modules/pi-lens/dist/{chunk-6MDWNZ7E.js → chunk-PKGOROPQ.js} +40 -2
- package/node_modules/pi-lens/dist/{chunk-3IWMNN2S.js → chunk-Q6D5QKRG.js} +17 -17
- package/node_modules/pi-lens/dist/{chunk-JGCBMCCS.js → chunk-QECLJFHI.js} +12 -17
- package/node_modules/pi-lens/dist/{chunk-KXKM2DFP.js → chunk-QJA33VD5.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-YV7XVYSJ.js → chunk-R5XVJ6AN.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-62PIU4TO.js → chunk-REZL4OM4.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-NNDZ7DOP.js → chunk-RK5RBREN.js} +74 -107
- package/node_modules/pi-lens/dist/chunk-RP5ZQTHO.js +86 -0
- package/node_modules/pi-lens/dist/{chunk-HKRESBMC.js → chunk-RURPX2YV.js} +23 -23
- package/node_modules/pi-lens/dist/chunk-TB5MGZLS.js +53 -0
- package/node_modules/pi-lens/dist/chunk-TC63XRYP.js +27 -0
- package/node_modules/pi-lens/dist/chunk-TJOYHAXJ.js +69 -0
- package/node_modules/pi-lens/dist/{chunk-NZ7NSKIW.js → chunk-TRXKDCBP.js} +13 -13
- package/node_modules/pi-lens/dist/{chunk-7WAQ3K26.js → chunk-TTK37D7R.js} +22 -23
- package/node_modules/pi-lens/dist/{chunk-ALTHJUZO.js → chunk-UH3QHLR5.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-6MZLS6CK.js → chunk-UNTJJ7GN.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-XRLZ75YY.js → chunk-UPAFSETJ.js} +54 -59
- package/node_modules/pi-lens/dist/{chunk-N2U644ZW.js → chunk-UX75PTQW.js} +50 -17
- package/node_modules/pi-lens/dist/{chunk-EXHSWN3P.js → chunk-V353PYMK.js} +423 -233
- package/node_modules/pi-lens/dist/{chunk-SL4G67AP.js → chunk-V4TFQY5G.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-YOMLAKU6.js → chunk-VC3W54G3.js} +289 -138
- package/node_modules/pi-lens/dist/{chunk-KSQJBGRO.js → chunk-VSBCJVPC.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-EBXCYEII.js → chunk-WAQQGXVV.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-7ORBRDFY.js → chunk-WLEVWR7Y.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-Q4UQNTLB.js → chunk-WPMPVP5I.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-TQKWR5AZ.js → chunk-WXNLFOC2.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-HOWHAKXO.js → chunk-Y3ZNOZZS.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-DNJJVKJZ.js → chunk-YL6JQTWC.js} +29 -32
- package/node_modules/pi-lens/dist/{chunk-HUWW77QY.js → chunk-YVE5Q2UU.js} +86 -217
- package/node_modules/pi-lens/dist/{chunk-25CAONWT.js → chunk-YZNARDMM.js} +12 -9
- package/node_modules/pi-lens/dist/{chunk-HERQPNY6.js → chunk-ZDWNFZJ2.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-MKQFSW2Q.js → chunk-ZEUF7BIN.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-AB26NAHA.js → chunk-ZIF4WLWR.js} +45 -25
- package/node_modules/pi-lens/dist/{chunk-6MWX2J5H.js → chunk-ZSPVF7KI.js} +227 -24
- package/node_modules/pi-lens/dist/{chunk-QQGZY2BR.js → chunk-ZX6OKBVO.js} +2 -2
- package/node_modules/pi-lens/dist/index.js +6455 -5243
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +8 -8
- package/node_modules/pi-lens/dist/mcp/cli.js +39 -41
- package/node_modules/pi-lens/dist/mcp/server.js +870 -559
- package/node_modules/pi-lens/dist/mcp/worker.js +68 -59
- package/node_modules/pi-lens/dist/probes/installer.js +19 -20
- package/node_modules/pi-lens/docs/configuration.md +24 -10
- package/node_modules/pi-lens/docs/defect-shapes.md +18 -2
- package/node_modules/pi-lens/docs/environment-variables.md +18 -9
- package/node_modules/pi-lens/docs/globalconfig.md +16 -0
- package/node_modules/pi-lens/docs/invariants/dispatch-runners.md +7 -0
- package/node_modules/pi-lens/docs/invariants/lsp-trust-exec.md +33 -3
- package/node_modules/pi-lens/docs/lsp-capability-matrix.md +23 -10
- package/node_modules/pi-lens/docs/lsp-idle-eviction.md +8 -3
- package/node_modules/pi-lens/docs/release-qa-baseline.md +22 -17
- package/node_modules/pi-lens/docs/servercapabilities.md +1 -1
- package/node_modules/pi-lens/docs/settings.md +9 -2
- package/node_modules/pi-lens/docs/tools.md +1 -1
- package/node_modules/pi-lens/package.json +3 -3
- package/package.json +7 -7
- package/node_modules/@narumitw/pi-btw/dist/chunks/main-tree-picker-3PXJARQW.ts.map +0 -7
- package/node_modules/pi-lens/dist/chunk-3UTDLQWO.js +0 -88
- package/node_modules/pi-lens/dist/chunk-3Z7Z3B7V.js +0 -27
- package/node_modules/pi-lens/dist/chunk-4E4OCW3L.js +0 -38
- package/node_modules/pi-lens/dist/chunk-5HVDD7IA.js +0 -17
- package/node_modules/pi-lens/dist/chunk-BKJ6WZKP.js +0 -255
- package/node_modules/pi-lens/dist/chunk-D3UQWOCB.js +0 -46
- package/node_modules/pi-lens/dist/chunk-EH6EHFW2.js +0 -73
- package/node_modules/pi-lens/dist/chunk-J7VNGHLN.js +0 -69
- package/node_modules/pi-lens/dist/chunk-L3Q72QGQ.js +0 -25
- package/node_modules/pi-lens/dist/chunk-TFSBHRL2.js +0 -25
- package/node_modules/pi-lens/dist/chunk-UWBD3JMH.js +0 -56
- package/node_modules/pi-lens/dist/chunk-XWWFESYZ.js +0 -27
- package/node_modules/pi-lens/dist/chunk-XZSXSM4K.js +0 -27
|
@@ -7,18 +7,18 @@ import {
|
|
|
7
7
|
deadCodeIssues,
|
|
8
8
|
formatDeadCodeDelta,
|
|
9
9
|
stableFindingKey
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-7OMOMBEQ.js";
|
|
11
11
|
import {
|
|
12
12
|
clearFormatterCache
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-ABKRQVOY.js";
|
|
14
14
|
import {
|
|
15
15
|
findNearestProjectRoot,
|
|
16
16
|
isStartupScanVerdictFresh,
|
|
17
17
|
resolveStartupScanContext
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-WXNLFOC2.js";
|
|
19
19
|
import {
|
|
20
20
|
loadCallGraph
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-5Z4XLUFF.js";
|
|
22
22
|
import {
|
|
23
23
|
isHardFailureSummary
|
|
24
24
|
} from "../chunk-7U2IDNXN.js";
|
|
@@ -28,15 +28,15 @@ import {
|
|
|
28
28
|
isCompletedPassResult,
|
|
29
29
|
isExcludedTestTarget,
|
|
30
30
|
isRunnerErrorResult
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-62AJH3IN.js";
|
|
32
32
|
import {
|
|
33
33
|
GovulncheckClient
|
|
34
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-OFZE4ANN.js";
|
|
35
35
|
import {
|
|
36
36
|
GitleaksClient,
|
|
37
37
|
classifyAndFilterFindings
|
|
38
|
-
} from "../chunk-
|
|
39
|
-
import "../chunk-
|
|
38
|
+
} from "../chunk-J24IS3KZ.js";
|
|
39
|
+
import "../chunk-LKPSBM6S.js";
|
|
40
40
|
import {
|
|
41
41
|
resetManagedToolRefreshSession
|
|
42
42
|
} from "../chunk-UXVNL3D7.js";
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
peekTurnEndFindings,
|
|
57
57
|
snapshotAdvisoryProvenance,
|
|
58
58
|
validateAdvisoryProvenance
|
|
59
|
-
} from "../chunk-
|
|
59
|
+
} from "../chunk-WPMPVP5I.js";
|
|
60
60
|
import {
|
|
61
61
|
CacheManager,
|
|
62
62
|
DEFAULT_MAX_AGE_MS,
|
|
@@ -117,47 +117,47 @@ import {
|
|
|
117
117
|
resetPsScriptAnalyzerAvailability,
|
|
118
118
|
runProviders,
|
|
119
119
|
stampLineHashes
|
|
120
|
-
} from "../chunk-
|
|
120
|
+
} from "../chunk-2ERVW2UF.js";
|
|
121
121
|
import {
|
|
122
|
-
resetLazyInstallAttempts,
|
|
123
122
|
resetObservedRunnerLatency
|
|
124
|
-
} from "../chunk-
|
|
123
|
+
} from "../chunk-CZ5TCJPB.js";
|
|
125
124
|
import {
|
|
126
125
|
isTestRoleCollateral
|
|
127
|
-
} from "../chunk-
|
|
128
|
-
import "../chunk-
|
|
126
|
+
} from "../chunk-HA6TUJOE.js";
|
|
127
|
+
import "../chunk-JC6NFC57.js";
|
|
129
128
|
import {
|
|
130
129
|
resetGoAvailability
|
|
131
|
-
} from "../chunk-
|
|
130
|
+
} from "../chunk-WLEVWR7Y.js";
|
|
132
131
|
import {
|
|
133
132
|
TrivyClient,
|
|
134
133
|
existingDependencyManifests,
|
|
135
134
|
trivyEvidenceFiles
|
|
136
|
-
} from "../chunk-
|
|
137
|
-
import "../chunk-
|
|
138
|
-
import "../chunk-
|
|
139
|
-
import "../chunk-
|
|
140
|
-
import "../chunk-
|
|
135
|
+
} from "../chunk-MQBKGRSB.js";
|
|
136
|
+
import "../chunk-KVGA7X76.js";
|
|
137
|
+
import "../chunk-BK2R2223.js";
|
|
138
|
+
import "../chunk-7KRR24GO.js";
|
|
139
|
+
import "../chunk-ZX6OKBVO.js";
|
|
141
140
|
import {
|
|
142
141
|
resetRustAvailability
|
|
143
|
-
} from "../chunk-
|
|
144
|
-
import "../chunk-
|
|
145
|
-
import "../chunk-
|
|
142
|
+
} from "../chunk-UH3QHLR5.js";
|
|
143
|
+
import "../chunk-CKJS2AUI.js";
|
|
144
|
+
import "../chunk-QECLJFHI.js";
|
|
146
145
|
import {
|
|
147
146
|
resetDispatchAvailabilityState,
|
|
148
|
-
resolveManagedToolClient
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
import "../chunk-
|
|
152
|
-
import "../chunk-
|
|
153
|
-
import "../chunk-
|
|
147
|
+
resolveManagedToolClient,
|
|
148
|
+
shouldAutoInstallTool
|
|
149
|
+
} from "../chunk-RK5RBREN.js";
|
|
150
|
+
import "../chunk-K3ZIYLHT.js";
|
|
151
|
+
import "../chunk-M6ELTECW.js";
|
|
152
|
+
import "../chunk-ANSLRJBG.js";
|
|
153
|
+
import "../chunk-CSZESDPP.js";
|
|
154
154
|
import {
|
|
155
155
|
SYMBOL_KIND_NAMES,
|
|
156
156
|
captureReviewGraphStructuralIr,
|
|
157
157
|
formatReviewGraphRevisionDriftNote,
|
|
158
158
|
publishReviewGraphFileIr,
|
|
159
159
|
reviewGraphIrContentHash
|
|
160
|
-
} from "../chunk-
|
|
160
|
+
} from "../chunk-ENJ2M76Y.js";
|
|
161
161
|
import {
|
|
162
162
|
buildSymbolId
|
|
163
163
|
} from "../chunk-3MED75HT.js";
|
|
@@ -264,6 +264,8 @@ import {
|
|
|
264
264
|
runPerServerGroups,
|
|
265
265
|
scopeCell,
|
|
266
266
|
sessionCell,
|
|
267
|
+
sessionStateFileName,
|
|
268
|
+
sessionsDir,
|
|
267
269
|
setSessionLanguages,
|
|
268
270
|
shouldShortenLspIdleTimeout,
|
|
269
271
|
summarizeWorkspaceEdit,
|
|
@@ -274,7 +276,7 @@ import {
|
|
|
274
276
|
widgetDiagnosticUri,
|
|
275
277
|
writeOrderToken,
|
|
276
278
|
writeSourceFile
|
|
277
|
-
} from "../chunk-
|
|
279
|
+
} from "../chunk-V353PYMK.js";
|
|
278
280
|
import {
|
|
279
281
|
ANY_POSITION,
|
|
280
282
|
foldedFindingIdentity,
|
|
@@ -285,7 +287,7 @@ import {
|
|
|
285
287
|
retainRecordedFindings,
|
|
286
288
|
sanitizeCorrelationId,
|
|
287
289
|
stableFindingId
|
|
288
|
-
} from "../chunk-
|
|
290
|
+
} from "../chunk-6LIUVGOR.js";
|
|
289
291
|
import {
|
|
290
292
|
mapWithConcurrency
|
|
291
293
|
} from "../chunk-XIMYZ3JA.js";
|
|
@@ -311,8 +313,7 @@ import {
|
|
|
311
313
|
resetLSPCaseSensitivityState,
|
|
312
314
|
resolveLspCwdForFile,
|
|
313
315
|
shouldInitializeSessionRoot
|
|
314
|
-
} from "../chunk-
|
|
315
|
-
import "../chunk-J7VNGHLN.js";
|
|
316
|
+
} from "../chunk-KMY2OU4T.js";
|
|
316
317
|
import {
|
|
317
318
|
PROJECT_VENV_DIR_NAMES,
|
|
318
319
|
PYTHON_DECLARATION_CONCURRENCY,
|
|
@@ -323,17 +324,15 @@ import {
|
|
|
323
324
|
isJediCompileVerdict,
|
|
324
325
|
partitionOutrankedPythonCompileVerdicts,
|
|
325
326
|
recordPythonCompileVerdictDrop,
|
|
326
|
-
resetBoundedTelemetry
|
|
327
|
-
} from "../chunk-AB26NAHA.js";
|
|
328
|
-
import {
|
|
327
|
+
resetBoundedTelemetry,
|
|
329
328
|
scannerReportParentDir
|
|
330
|
-
} from "../chunk-
|
|
329
|
+
} from "../chunk-ZIF4WLWR.js";
|
|
331
330
|
import {
|
|
332
331
|
SWEEP_IDLE_SAFETY_MARGIN_MS,
|
|
333
332
|
getFullScanWallClockMs,
|
|
334
333
|
isWorkspaceSweepActive,
|
|
335
334
|
runWhenWorkspaceSweepIdle
|
|
336
|
-
} from "../chunk-
|
|
335
|
+
} from "../chunk-I65CQLCG.js";
|
|
337
336
|
import "../chunk-5W3R6LFT.js";
|
|
338
337
|
import {
|
|
339
338
|
DEPENDENCY_DRIFT_MAX_DELIVERIES,
|
|
@@ -345,9 +344,9 @@ import {
|
|
|
345
344
|
resolveImportToFiles,
|
|
346
345
|
sweepInlineBlockerFreshness,
|
|
347
346
|
symbolExtractionGrammar
|
|
348
|
-
} from "../chunk-
|
|
349
|
-
import "../chunk-
|
|
350
|
-
import "../chunk-
|
|
347
|
+
} from "../chunk-7ZFXICNN.js";
|
|
348
|
+
import "../chunk-VSBCJVPC.js";
|
|
349
|
+
import "../chunk-BG7KHGNX.js";
|
|
351
350
|
import {
|
|
352
351
|
EXT_TO_LANG,
|
|
353
352
|
classifyTreeSitterWasmError,
|
|
@@ -360,15 +359,15 @@ import {
|
|
|
360
359
|
queryLoader,
|
|
361
360
|
reportBundledResourceDirHealth,
|
|
362
361
|
resolveTreeSitterLanguage
|
|
363
|
-
} from "../chunk-
|
|
362
|
+
} from "../chunk-6F34GMP7.js";
|
|
364
363
|
import "../chunk-Z54ZSOBZ.js";
|
|
365
364
|
import {
|
|
366
365
|
dump,
|
|
367
366
|
getUserRuleRoot,
|
|
368
367
|
resolvePackagePath
|
|
369
|
-
} from "../chunk-
|
|
368
|
+
} from "../chunk-EQKF6BAK.js";
|
|
370
369
|
import "../chunk-6HWVI6MI.js";
|
|
371
|
-
import "../chunk-
|
|
370
|
+
import "../chunk-GWZZOJD2.js";
|
|
372
371
|
import {
|
|
373
372
|
PROJECT_SNAPSHOT_VERSION,
|
|
374
373
|
getProjectSnapshotLegacyPath,
|
|
@@ -382,7 +381,7 @@ import {
|
|
|
382
381
|
loadProjectSnapshotWithoutWordIndex,
|
|
383
382
|
readProjectSnapshotMeta,
|
|
384
383
|
saveRuntimeProjectSnapshot
|
|
385
|
-
} from "../chunk-
|
|
384
|
+
} from "../chunk-MVG2ZEAO.js";
|
|
386
385
|
import {
|
|
387
386
|
centralityFromReverseDeps,
|
|
388
387
|
getWordIndexBuildStatus,
|
|
@@ -391,26 +390,28 @@ import {
|
|
|
391
390
|
parseWordIndexQuery,
|
|
392
391
|
searchWordIndex,
|
|
393
392
|
triggerBackgroundWordIndexBuild
|
|
394
|
-
} from "../chunk-
|
|
393
|
+
} from "../chunk-IDKLWVKY.js";
|
|
395
394
|
import {
|
|
396
395
|
getProjectDiagnosticsScannerMaxFiles
|
|
397
|
-
} from "../chunk-
|
|
396
|
+
} from "../chunk-F6QAJXQV.js";
|
|
398
397
|
import {
|
|
399
398
|
SCAN_LANGUAGE_PRIORITY,
|
|
400
399
|
extensionsForLanguage,
|
|
401
400
|
resolveLanguage,
|
|
402
401
|
resolveLanguageScope
|
|
403
|
-
} from "../chunk-
|
|
402
|
+
} from "../chunk-HKPJTI47.js";
|
|
404
403
|
import {
|
|
405
404
|
WARM_TURN_END_SCHEMA_VERSION,
|
|
406
405
|
boundUnixSocketKeepsIdentity,
|
|
407
406
|
boundUnixSocketPath,
|
|
407
|
+
classifyIpcSocketName,
|
|
408
408
|
createWarmIpcLineReader,
|
|
409
409
|
createWarmIpcRequestQueue,
|
|
410
410
|
ipcPathForCwd,
|
|
411
|
+
probeIpcSocketListener,
|
|
411
412
|
readTurnEndStatus,
|
|
412
413
|
unlinkStaleUnixSocket
|
|
413
|
-
} from "../chunk-
|
|
414
|
+
} from "../chunk-PKGOROPQ.js";
|
|
414
415
|
import {
|
|
415
416
|
NO_SERVER_REASON,
|
|
416
417
|
cleanVerdict,
|
|
@@ -423,30 +424,34 @@ import {
|
|
|
423
424
|
import {
|
|
424
425
|
resolveRunnerPath,
|
|
425
426
|
toRunnerDisplayPath
|
|
426
|
-
} from "../chunk-
|
|
427
|
+
} from "../chunk-REZL4OM4.js";
|
|
428
|
+
import {
|
|
429
|
+
hashContentBytes,
|
|
430
|
+
hashFileBytes
|
|
431
|
+
} from "../chunk-CIA7X2PZ.js";
|
|
427
432
|
import "../chunk-2BEMIWEW.js";
|
|
428
433
|
import "../chunk-IJYGIDF4.js";
|
|
429
434
|
import {
|
|
430
435
|
commitDurableStore,
|
|
431
436
|
resetResolvedPathCache,
|
|
432
437
|
resetZizmorTokenAvailability
|
|
433
|
-
} from "../chunk-
|
|
438
|
+
} from "../chunk-VC3W54G3.js";
|
|
434
439
|
import {
|
|
435
440
|
readFileContent,
|
|
436
441
|
resolveToolCwd
|
|
437
|
-
} from "../chunk-
|
|
442
|
+
} from "../chunk-GVE5VZYQ.js";
|
|
438
443
|
import {
|
|
439
444
|
_resetPackageManagerCache,
|
|
440
445
|
findGlobalBinary,
|
|
441
446
|
pmBinary,
|
|
442
447
|
resolveNodePackageManager,
|
|
443
448
|
runScriptArgs
|
|
444
|
-
} from "../chunk-
|
|
449
|
+
} from "../chunk-YZNARDMM.js";
|
|
445
450
|
import {
|
|
446
451
|
getIsolatedNpxSpawnOptions,
|
|
447
452
|
probeToolAsync
|
|
448
|
-
} from "../chunk-
|
|
449
|
-
import "../chunk-
|
|
453
|
+
} from "../chunk-JWW3ODBN.js";
|
|
454
|
+
import "../chunk-J2DAHH4T.js";
|
|
450
455
|
import {
|
|
451
456
|
classifyProbeFailure,
|
|
452
457
|
createAvailabilityLatch,
|
|
@@ -454,29 +459,30 @@ import {
|
|
|
454
459
|
logAvailabilityDecision,
|
|
455
460
|
resetInstallRetryLatches,
|
|
456
461
|
startHostStallSampler
|
|
457
|
-
} from "../chunk-
|
|
462
|
+
} from "../chunk-KDPZA2UE.js";
|
|
458
463
|
import {
|
|
459
464
|
canRunStartupHeavyScans,
|
|
460
465
|
detectProjectLanguageProfile,
|
|
461
466
|
getDefaultStartupTools
|
|
462
|
-
} from "../chunk-
|
|
463
|
-
import "../chunk-
|
|
467
|
+
} from "../chunk-Y3ZNOZZS.js";
|
|
468
|
+
import "../chunk-6REF4GCO.js";
|
|
464
469
|
import {
|
|
465
470
|
DEFAULT_MAX_SCAN_ENTRIES,
|
|
466
471
|
collectSourceFilesWithBudgetAsync,
|
|
467
472
|
getSlowFsVerdict,
|
|
468
473
|
isSlowFs,
|
|
469
474
|
slowFsDegradationNotice
|
|
470
|
-
} from "../chunk-
|
|
475
|
+
} from "../chunk-LKW2HFSZ.js";
|
|
471
476
|
import {
|
|
472
477
|
shouldRecurseIntoDir,
|
|
473
478
|
walkTreeStackAsync
|
|
474
|
-
} from "../chunk-
|
|
479
|
+
} from "../chunk-KW7O72AK.js";
|
|
475
480
|
import {
|
|
476
481
|
readJsonCache
|
|
477
482
|
} from "../chunk-TQWRH25U.js";
|
|
478
483
|
import "../chunk-UYXV5NIS.js";
|
|
479
484
|
import {
|
|
485
|
+
createProjectDataDirRootProbe,
|
|
480
486
|
displayProjectDataPath,
|
|
481
487
|
drainProjectDataDirMigrations,
|
|
482
488
|
getAmbientAbortSignal,
|
|
@@ -493,6 +499,7 @@ import {
|
|
|
493
499
|
isTestFile,
|
|
494
500
|
isWithinPathForm,
|
|
495
501
|
loadPiLensGlobalConfig,
|
|
502
|
+
projectDataBase,
|
|
496
503
|
realIsPidAlive,
|
|
497
504
|
resetProjectDataDirSessionState,
|
|
498
505
|
resetSafeSpawnWindowsCommandCache,
|
|
@@ -503,12 +510,13 @@ import {
|
|
|
503
510
|
subagentLightModeNotice,
|
|
504
511
|
sweepAtomicWriteStages,
|
|
505
512
|
sweepDeadEphemeralDataDirs,
|
|
513
|
+
sweepOrphans,
|
|
506
514
|
updateHeartbeat,
|
|
507
515
|
withGenerationLockSync
|
|
508
|
-
} from "../chunk-
|
|
516
|
+
} from "../chunk-LURFD4HD.js";
|
|
509
517
|
import {
|
|
510
518
|
createSingleFlight
|
|
511
|
-
} from "../chunk-
|
|
519
|
+
} from "../chunk-3UHGSUVL.js";
|
|
512
520
|
import {
|
|
513
521
|
createDeadline,
|
|
514
522
|
yieldIfOverBudget
|
|
@@ -519,24 +527,23 @@ import {
|
|
|
519
527
|
detectFileRole,
|
|
520
528
|
loadPiLensProjectConfig,
|
|
521
529
|
lspSectionOf,
|
|
530
|
+
peekPiLensProjectConfig,
|
|
522
531
|
provenanceFor,
|
|
523
532
|
provenanceView,
|
|
533
|
+
resolveOnePiLensConfigDocument,
|
|
524
534
|
resolvePiLensConfig,
|
|
525
535
|
summarizeConfigResolution
|
|
526
|
-
} from "../chunk-
|
|
536
|
+
} from "../chunk-UX75PTQW.js";
|
|
527
537
|
import {
|
|
528
538
|
detectFileKind,
|
|
529
539
|
isJstsFactFile
|
|
530
|
-
} from "../chunk-
|
|
540
|
+
} from "../chunk-V4TFQY5G.js";
|
|
531
541
|
import {
|
|
532
542
|
LSP_NAMESPACE_KEY,
|
|
533
543
|
getPiLensGlobalConfigPath,
|
|
544
|
+
holdsCanonicalProjectConfig,
|
|
534
545
|
resetWorkspaceTopology
|
|
535
|
-
} from "../chunk-
|
|
536
|
-
import {
|
|
537
|
-
hashContentBytes,
|
|
538
|
-
hashFileBytes
|
|
539
|
-
} from "../chunk-CIA7X2PZ.js";
|
|
546
|
+
} from "../chunk-D2LFEA5U.js";
|
|
540
547
|
import {
|
|
541
548
|
DEFAULT_MAX_OUTPUT_BYTES,
|
|
542
549
|
HOOK_WALL_BUDGET_MS,
|
|
@@ -552,7 +559,7 @@ import {
|
|
|
552
559
|
withBudget,
|
|
553
560
|
withDeadline,
|
|
554
561
|
writeFileAtomic
|
|
555
|
-
} from "../chunk-
|
|
562
|
+
} from "../chunk-463WN3VP.js";
|
|
556
563
|
import {
|
|
557
564
|
LENS_TOOL_NAMES,
|
|
558
565
|
TOOL_REGISTRY,
|
|
@@ -571,7 +578,7 @@ import {
|
|
|
571
578
|
resolveLensToolName,
|
|
572
579
|
toolRegistryEntryForMcp,
|
|
573
580
|
translateGuidanceToolNames
|
|
574
|
-
} from "../chunk-
|
|
581
|
+
} from "../chunk-CQNXALZJ.js";
|
|
575
582
|
import {
|
|
576
583
|
freshnessFromMtime
|
|
577
584
|
} from "../chunk-S26LC76R.js";
|
|
@@ -580,17 +587,18 @@ import {
|
|
|
580
587
|
claimPhaseOncePerSession,
|
|
581
588
|
createNdjsonLogger,
|
|
582
589
|
getGlobalPiLensLogDir,
|
|
590
|
+
getMaxLogSizeMB,
|
|
583
591
|
getProcessSingleton,
|
|
592
|
+
getRegisteredLogFiles,
|
|
584
593
|
isTestMode,
|
|
585
594
|
logLatency,
|
|
586
595
|
nonNegativeIntEnv,
|
|
587
|
-
runLogCleanup,
|
|
588
596
|
setTurnContextSession
|
|
589
|
-
} from "../chunk-
|
|
597
|
+
} from "../chunk-YVE5Q2UU.js";
|
|
590
598
|
import "../chunk-LJDODBBZ.js";
|
|
591
599
|
import {
|
|
592
600
|
FactStore
|
|
593
|
-
} from "../chunk-
|
|
601
|
+
} from "../chunk-HPKC55MA.js";
|
|
594
602
|
import {
|
|
595
603
|
BoundedFifoMap,
|
|
596
604
|
BoundedLruCache,
|
|
@@ -615,19 +623,288 @@ import {
|
|
|
615
623
|
uriToDiskPath,
|
|
616
624
|
uriToPath,
|
|
617
625
|
walkUpDirs
|
|
618
|
-
} from "../chunk-
|
|
626
|
+
} from "../chunk-ZSPVF7KI.js";
|
|
619
627
|
import "../chunk-NXL4FFQQ.js";
|
|
620
628
|
|
|
621
629
|
// dist/mcp/server.js
|
|
622
|
-
import * as
|
|
630
|
+
import * as fs26 from "node:fs";
|
|
623
631
|
import * as net from "node:net";
|
|
624
|
-
import * as
|
|
632
|
+
import * as path43 from "node:path";
|
|
625
633
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
626
634
|
|
|
627
635
|
// dist/tools/render-compact.js
|
|
636
|
+
import * as fs2 from "node:fs";
|
|
637
|
+
import * as path2 from "node:path";
|
|
638
|
+
|
|
639
|
+
// dist/clients/log-cleanup.js
|
|
640
|
+
import { randomUUID } from "node:crypto";
|
|
628
641
|
import * as fs from "node:fs";
|
|
642
|
+
import * as os from "node:os";
|
|
629
643
|
import * as path from "node:path";
|
|
630
|
-
|
|
644
|
+
var LOGS_SUBDIR = () => path.join(getGlobalPiLensLogDir(), "logs");
|
|
645
|
+
function getManagedLogFiles(dir = getGlobalPiLensLogDir()) {
|
|
646
|
+
const names = /* @__PURE__ */ new Set();
|
|
647
|
+
for (const absPath of getRegisteredLogFiles()) {
|
|
648
|
+
if (pathsEqual(path.dirname(absPath), dir)) {
|
|
649
|
+
names.add(path.basename(absPath));
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
try {
|
|
653
|
+
if (fs.existsSync(dir)) {
|
|
654
|
+
for (const entry of fs.readdirSync(dir)) {
|
|
655
|
+
if (entry.endsWith(".log") && !ROTATED_BACKUP_RE.test(entry)) {
|
|
656
|
+
names.add(entry);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
} catch {
|
|
661
|
+
}
|
|
662
|
+
return [...names].sort((a, b) => a.localeCompare(b));
|
|
663
|
+
}
|
|
664
|
+
var ROTATED_BACKUP_RE = /(\.\d{4}-\d{2}-\d{2}T.*\.log|\.log\..+)$/;
|
|
665
|
+
var SPILL_RESULT_LOG_RE = /^tool-result-\d+-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.log$/;
|
|
666
|
+
function spillResultLogName(now = Date.now(), id = randomUUID()) {
|
|
667
|
+
return `tool-result-${now}-${id}.log`;
|
|
668
|
+
}
|
|
669
|
+
var SESSION_STATE_FILE_RE = /^[A-Za-z0-9._-]{1,200}\.json$/;
|
|
670
|
+
var PROJECT_DATA_ORPHAN_RETENTION_DAYS = 30;
|
|
671
|
+
function getConfig() {
|
|
672
|
+
return {
|
|
673
|
+
retentionDays: Math.max(1, Number.parseInt(process.env.PI_LENS_LOG_RETENTION_DAYS ?? "7", 10) || 7),
|
|
674
|
+
maxSizeMB: getMaxLogSizeMB()
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
function getFileAgeDays(filePath) {
|
|
678
|
+
try {
|
|
679
|
+
const stats = fs.statSync(filePath);
|
|
680
|
+
const ageMs = Date.now() - stats.mtime.getTime();
|
|
681
|
+
return ageMs / (1e3 * 60 * 60 * 24);
|
|
682
|
+
} catch {
|
|
683
|
+
return 0;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
function getFileSizeMB(filePath) {
|
|
687
|
+
try {
|
|
688
|
+
const stats = fs.statSync(filePath);
|
|
689
|
+
return stats.size / (1024 * 1024);
|
|
690
|
+
} catch {
|
|
691
|
+
return 0;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
function realPidProbe(pid) {
|
|
695
|
+
try {
|
|
696
|
+
process.kill(pid, 0);
|
|
697
|
+
return "alive";
|
|
698
|
+
} catch (err) {
|
|
699
|
+
return err.code === "ESRCH" ? "esrch" : "refused";
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
function pidScopedSocketLiveness(pid, signal = realPidProbe) {
|
|
703
|
+
switch (signal(pid)) {
|
|
704
|
+
case "alive":
|
|
705
|
+
return "live";
|
|
706
|
+
case "esrch":
|
|
707
|
+
return "stale";
|
|
708
|
+
case "refused":
|
|
709
|
+
return "indeterminate";
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
function getRetentionRows(options) {
|
|
713
|
+
const config = getConfig();
|
|
714
|
+
return [
|
|
715
|
+
{
|
|
716
|
+
label: "daily logs",
|
|
717
|
+
directory: LOGS_SUBDIR,
|
|
718
|
+
match: (name) => name.endsWith(".jsonl"),
|
|
719
|
+
maxAgeDays: () => config.retentionDays,
|
|
720
|
+
deletion: "file"
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
label: "rotated logs",
|
|
724
|
+
directory: getGlobalPiLensLogDir,
|
|
725
|
+
match: (name) => ROTATED_BACKUP_RE.test(name),
|
|
726
|
+
maxAgeDays: () => config.retentionDays,
|
|
727
|
+
deletion: "file"
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
label: "spill logs",
|
|
731
|
+
directory: getGlobalPiLensLogDir,
|
|
732
|
+
match: (name) => SPILL_RESULT_LOG_RE.test(name),
|
|
733
|
+
maxAgeDays: () => config.retentionDays,
|
|
734
|
+
deletion: "file"
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
label: "session state files",
|
|
738
|
+
// The store owns the location (clients/session-state-store.ts).
|
|
739
|
+
directory: () => sessionsDir(options.cwd ?? process.cwd()),
|
|
740
|
+
match: (name) => SESSION_STATE_FILE_RE.test(name),
|
|
741
|
+
maxAgeDays: () => config.retentionDays,
|
|
742
|
+
deletion: "file",
|
|
743
|
+
liveness: (_absPath, name) => sessionStateLiveness(name, options.currentSessionId)
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
// The same directory `clients/mcp/ipc.ts` binds every `.sock`
|
|
747
|
+
// endpoint name into; Windows named pipes have no file to scan.
|
|
748
|
+
label: "stale sockets",
|
|
749
|
+
directory: () => os.tmpdir(),
|
|
750
|
+
match: (name) => name.endsWith(".sock"),
|
|
751
|
+
maxAgeDays: () => 1,
|
|
752
|
+
deletion: "socket",
|
|
753
|
+
liveness: socketLiveness
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
label: "orphaned project data dirs",
|
|
757
|
+
directory: projectDataBase,
|
|
758
|
+
// The liveness gate classifies every child; a name it cannot
|
|
759
|
+
// judge is kept, so the row admits all and judges each.
|
|
760
|
+
match: () => true,
|
|
761
|
+
maxAgeDays: () => PROJECT_DATA_ORPHAN_RETENTION_DAYS,
|
|
762
|
+
deletion: "dir",
|
|
763
|
+
liveness: projectDataDirLiveness
|
|
764
|
+
}
|
|
765
|
+
];
|
|
766
|
+
}
|
|
767
|
+
function rotateLogIfNeeded(logFile, maxSizeMB) {
|
|
768
|
+
const config = getConfig();
|
|
769
|
+
const maxSize = maxSizeMB ?? config.maxSizeMB;
|
|
770
|
+
const sizeMB = getFileSizeMB(logFile);
|
|
771
|
+
if (sizeMB < maxSize) {
|
|
772
|
+
return { rotated: false };
|
|
773
|
+
}
|
|
774
|
+
try {
|
|
775
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
776
|
+
const ext = path.extname(logFile);
|
|
777
|
+
const base = logFile.slice(0, -ext.length);
|
|
778
|
+
const backupFile = `${base}.${timestamp}${ext}`;
|
|
779
|
+
fs.renameSync(logFile, backupFile);
|
|
780
|
+
fs.writeFileSync(logFile, "", "utf8");
|
|
781
|
+
return { rotated: true, newFile: backupFile };
|
|
782
|
+
} catch {
|
|
783
|
+
return { rotated: false };
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
function sessionStateLiveness(name, currentSessionId) {
|
|
787
|
+
return currentSessionId !== void 0 && name === sessionStateFileName(currentSessionId) ? "live" : "stale";
|
|
788
|
+
}
|
|
789
|
+
function projectDataDirLiveness(absPath, name) {
|
|
790
|
+
let isDirectory = false;
|
|
791
|
+
try {
|
|
792
|
+
isDirectory = fs.lstatSync(absPath).isDirectory();
|
|
793
|
+
} catch {
|
|
794
|
+
isDirectory = false;
|
|
795
|
+
}
|
|
796
|
+
if (!isDirectory)
|
|
797
|
+
return "indeterminate";
|
|
798
|
+
const decoded = createProjectDataDirRootProbe().statusFor(name);
|
|
799
|
+
if (decoded === "exists")
|
|
800
|
+
return "live";
|
|
801
|
+
if (decoded === "gone")
|
|
802
|
+
return "stale";
|
|
803
|
+
return "indeterminate";
|
|
804
|
+
}
|
|
805
|
+
async function socketLiveness(absPath, name) {
|
|
806
|
+
const classified = classifyIpcSocketName(name);
|
|
807
|
+
if (!classified)
|
|
808
|
+
return "indeterminate";
|
|
809
|
+
if (classified.kind === "pid-scoped") {
|
|
810
|
+
return pidScopedSocketLiveness(classified.pid);
|
|
811
|
+
}
|
|
812
|
+
const dial = await probeIpcSocketListener(absPath);
|
|
813
|
+
return dial === "dead" ? "stale" : dial === "live" ? "live" : "indeterminate";
|
|
814
|
+
}
|
|
815
|
+
async function runRetentionRow(row) {
|
|
816
|
+
const directory = row.directory();
|
|
817
|
+
const deleted = [];
|
|
818
|
+
const errors = [];
|
|
819
|
+
let names;
|
|
820
|
+
try {
|
|
821
|
+
names = fs.existsSync(directory) ? fs.readdirSync(directory) : [];
|
|
822
|
+
} catch (err) {
|
|
823
|
+
return {
|
|
824
|
+
label: row.label,
|
|
825
|
+
deleted: 0,
|
|
826
|
+
errors: [`read ${directory}: ${err}`]
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
for (const name of names) {
|
|
830
|
+
if (!row.match(name))
|
|
831
|
+
continue;
|
|
832
|
+
const absPath = path.join(directory, name);
|
|
833
|
+
const ageDays = getFileAgeDays(absPath);
|
|
834
|
+
if (ageDays <= row.maxAgeDays())
|
|
835
|
+
continue;
|
|
836
|
+
if (row.liveness) {
|
|
837
|
+
const verdict = await row.liveness(absPath, name);
|
|
838
|
+
if (verdict !== "stale")
|
|
839
|
+
continue;
|
|
840
|
+
}
|
|
841
|
+
try {
|
|
842
|
+
const socketClass = row.deletion === "socket" ? classifyIpcSocketName(name) : void 0;
|
|
843
|
+
if (socketClass) {
|
|
844
|
+
let isSocket = false;
|
|
845
|
+
try {
|
|
846
|
+
isSocket = fs.lstatSync(absPath).isSocket();
|
|
847
|
+
} catch {
|
|
848
|
+
isSocket = false;
|
|
849
|
+
}
|
|
850
|
+
if (!isSocket)
|
|
851
|
+
continue;
|
|
852
|
+
fs.unlinkSync(absPath);
|
|
853
|
+
} else if (row.deletion === "dir") {
|
|
854
|
+
fs.rmSync(absPath, { recursive: true, force: true });
|
|
855
|
+
} else {
|
|
856
|
+
fs.unlinkSync(absPath);
|
|
857
|
+
}
|
|
858
|
+
deleted.push(name);
|
|
859
|
+
} catch (err) {
|
|
860
|
+
errors.push(`${name}: ${err}`);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return { label: row.label, deleted: deleted.length, errors };
|
|
864
|
+
}
|
|
865
|
+
async function runLogCleanup(dbg, options = {}) {
|
|
866
|
+
const config = getConfig();
|
|
867
|
+
const results = {
|
|
868
|
+
cleaned: 0,
|
|
869
|
+
rotated: 0,
|
|
870
|
+
report: ""
|
|
871
|
+
};
|
|
872
|
+
const sweeps = [];
|
|
873
|
+
const errors = [];
|
|
874
|
+
for (const row of getRetentionRows(options)) {
|
|
875
|
+
const sweep = await runRetentionRow(row);
|
|
876
|
+
sweeps.push(sweep);
|
|
877
|
+
errors.push(...sweep.errors);
|
|
878
|
+
}
|
|
879
|
+
results.cleaned = sweeps.reduce((sum, sweep) => sum + sweep.deleted, 0);
|
|
880
|
+
const mainLogs = getManagedLogFiles().map((name) => path.join(getGlobalPiLensLogDir(), name));
|
|
881
|
+
for (const logFile of mainLogs) {
|
|
882
|
+
const rotation = rotateLogIfNeeded(logFile, config.maxSizeMB);
|
|
883
|
+
if (rotation.rotated) {
|
|
884
|
+
results.rotated++;
|
|
885
|
+
if (rotation.newFile) {
|
|
886
|
+
const sizeMB = getFileSizeMB(rotation.newFile);
|
|
887
|
+
dbg?.(`log_cleanup: rotated ${path.basename(logFile)} (${sizeMB.toFixed(1)}MB) \u2192 ${path.basename(rotation.newFile)}`);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
const parts = [];
|
|
892
|
+
for (const sweep of sweeps) {
|
|
893
|
+
if (sweep.deleted > 0)
|
|
894
|
+
parts.push(`${sweep.deleted} ${sweep.label}`);
|
|
895
|
+
}
|
|
896
|
+
if (results.rotated > 0) {
|
|
897
|
+
parts.push(`${results.rotated} active logs rotated`);
|
|
898
|
+
}
|
|
899
|
+
if (errors.length > 0) {
|
|
900
|
+
parts.push(`${errors.length} deletions failed`);
|
|
901
|
+
dbg?.(`log_cleanup: ${errors.length} deletions failed; first: ${errors[0]}`);
|
|
902
|
+
}
|
|
903
|
+
results.report = parts.length > 0 ? `log_cleanup: removed ${parts.join(", ")} (retention: ${config.retentionDays}d, maxSize: ${config.maxSizeMB}MB)` : `log_cleanup: no cleanup needed (retention: ${config.retentionDays}d, maxSize: ${config.maxSizeMB}MB)`;
|
|
904
|
+
return results;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// dist/tools/render-compact.js
|
|
631
908
|
var MAX_RESULT_BYTES = 40 * 1024;
|
|
632
909
|
var COMPLETE_MCP_RESULT_INPUT_BUDGET_BYTES = 8 * 1024 * 1024;
|
|
633
910
|
var FOOTER_MAX_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
|
|
@@ -666,8 +943,8 @@ function boundToolText(text, maxBytes = MAX_RESULT_BYTES) {
|
|
|
666
943
|
if (totalBytes <= maxBytes) {
|
|
667
944
|
return { text, truncated: false, omittedCharacters: 0 };
|
|
668
945
|
}
|
|
669
|
-
const fullOutputPath =
|
|
670
|
-
|
|
946
|
+
const fullOutputPath = path2.join(getGlobalPiLensLogDir(), spillResultLogName());
|
|
947
|
+
fs2.mkdirSync(path2.dirname(fullOutputPath), { recursive: true });
|
|
671
948
|
if (totalBytes > COMPLETE_MCP_RESULT_INPUT_BUDGET_BYTES) {
|
|
672
949
|
const omittedBytes = totalBytes - COMPLETE_MCP_RESULT_INPUT_BUDGET_BYTES;
|
|
673
950
|
recordDegradationOnce({
|
|
@@ -689,7 +966,7 @@ function boundToolText(text, maxBytes = MAX_RESULT_BYTES) {
|
|
|
689
966
|
|
|
690
967
|
`;
|
|
691
968
|
});
|
|
692
|
-
|
|
969
|
+
fs2.writeFileSync(fullOutputPath, logText.text, "utf8");
|
|
693
970
|
const output2 = renderHeadTail(logText.text, maxBytes, () => `
|
|
694
971
|
|
|
695
972
|
[incomplete: ${omittedBytes} bytes omitted, budget ${COMPLETE_MCP_RESULT_INPUT_BUDGET_BYTES}]
|
|
@@ -704,7 +981,7 @@ function boundToolText(text, maxBytes = MAX_RESULT_BYTES) {
|
|
|
704
981
|
fullOutputPath
|
|
705
982
|
};
|
|
706
983
|
}
|
|
707
|
-
|
|
984
|
+
fs2.writeFileSync(fullOutputPath, text, "utf8");
|
|
708
985
|
const output = renderHeadTail(text, maxBytes, (head, tail) => `
|
|
709
986
|
|
|
710
987
|
[${text.length - head - tail} characters omitted. Full output: ${fullOutputPath}]
|
|
@@ -923,16 +1200,16 @@ function baseName(p) {
|
|
|
923
1200
|
}
|
|
924
1201
|
|
|
925
1202
|
// dist/clients/ast-grep-client.js
|
|
926
|
-
import * as
|
|
927
|
-
import * as
|
|
1203
|
+
import * as fs5 from "node:fs";
|
|
1204
|
+
import * as path5 from "node:path";
|
|
928
1205
|
|
|
929
1206
|
// dist/clients/ast-grep-rule-manager.js
|
|
930
|
-
import * as
|
|
931
|
-
import * as
|
|
1207
|
+
import * as fs3 from "node:fs";
|
|
1208
|
+
import * as path3 from "node:path";
|
|
932
1209
|
function candidateAstGrepRulesPaths(ruleDir) {
|
|
933
1210
|
return [
|
|
934
|
-
|
|
935
|
-
|
|
1211
|
+
path3.join(ruleDir, "ast-grep-rules", "rules"),
|
|
1212
|
+
path3.join(ruleDir, "rules"),
|
|
936
1213
|
ruleDir
|
|
937
1214
|
];
|
|
938
1215
|
}
|
|
@@ -940,14 +1217,14 @@ function checkAstGrepRulesHealth(ruleDir) {
|
|
|
940
1217
|
const possiblePaths = candidateAstGrepRulesPaths(ruleDir);
|
|
941
1218
|
let rulesPath;
|
|
942
1219
|
for (const candidate of possiblePaths) {
|
|
943
|
-
if (
|
|
1220
|
+
if (fs3.existsSync(candidate)) {
|
|
944
1221
|
rulesPath = candidate;
|
|
945
1222
|
break;
|
|
946
1223
|
}
|
|
947
1224
|
}
|
|
948
1225
|
if (!rulesPath) {
|
|
949
1226
|
try {
|
|
950
|
-
|
|
1227
|
+
fs3.readdirSync(ruleDir);
|
|
951
1228
|
} catch (error) {
|
|
952
1229
|
const fsErrorCode = error?.code;
|
|
953
1230
|
if (fsErrorCode && fsErrorCode !== "ENOENT") {
|
|
@@ -958,7 +1235,7 @@ function checkAstGrepRulesHealth(ruleDir) {
|
|
|
958
1235
|
}
|
|
959
1236
|
let entries;
|
|
960
1237
|
try {
|
|
961
|
-
entries =
|
|
1238
|
+
entries = fs3.readdirSync(rulesPath).filter((f) => f.endsWith(".yml"));
|
|
962
1239
|
} catch (error) {
|
|
963
1240
|
const fsErrorCode = error?.code ?? "UNKNOWN";
|
|
964
1241
|
return { status: "unreadable", fsErrorCode };
|
|
@@ -986,12 +1263,12 @@ var AstGrepRuleManager = class {
|
|
|
986
1263
|
const rulesPaths = [];
|
|
987
1264
|
if (Array.isArray(this.ruleDir)) {
|
|
988
1265
|
for (const candidate of possiblePaths) {
|
|
989
|
-
if (
|
|
1266
|
+
if (fs3.existsSync(candidate))
|
|
990
1267
|
rulesPaths.push(candidate);
|
|
991
1268
|
}
|
|
992
1269
|
} else {
|
|
993
1270
|
for (const candidate of possiblePaths) {
|
|
994
|
-
if (!
|
|
1271
|
+
if (!fs3.existsSync(candidate))
|
|
995
1272
|
continue;
|
|
996
1273
|
rulesPaths.push(candidate);
|
|
997
1274
|
break;
|
|
@@ -1006,11 +1283,11 @@ var AstGrepRuleManager = class {
|
|
|
1006
1283
|
}
|
|
1007
1284
|
try {
|
|
1008
1285
|
for (const resolvedPath of rulesPaths) {
|
|
1009
|
-
const files =
|
|
1286
|
+
const files = fs3.readdirSync(resolvedPath).filter((f) => f.endsWith(".yml"));
|
|
1010
1287
|
this.log(`Loaded ${files.length} rule descriptions from ${resolvedPath}`);
|
|
1011
1288
|
for (const file of files) {
|
|
1012
|
-
const filePath =
|
|
1013
|
-
const content =
|
|
1289
|
+
const filePath = path3.join(resolvedPath, file);
|
|
1290
|
+
const content = fs3.readFileSync(filePath, "utf-8");
|
|
1014
1291
|
const rule = this.parseRuleYaml(content);
|
|
1015
1292
|
if (rule && !descriptions.has(rule.id))
|
|
1016
1293
|
descriptions.set(rule.id, rule);
|
|
@@ -1063,8 +1340,8 @@ var AstGrepRuleManager = class {
|
|
|
1063
1340
|
};
|
|
1064
1341
|
|
|
1065
1342
|
// dist/clients/sg-runner.js
|
|
1066
|
-
import * as
|
|
1067
|
-
import * as
|
|
1343
|
+
import * as fs4 from "node:fs";
|
|
1344
|
+
import * as path4 from "node:path";
|
|
1068
1345
|
function buildBashRunArgs(cmd, allArgs) {
|
|
1069
1346
|
return ["-c", '"$0" "$@"', cmd, ...allArgs];
|
|
1070
1347
|
}
|
|
@@ -1121,7 +1398,7 @@ function tryParseNonZeroSgMatches(result) {
|
|
|
1121
1398
|
function sgMatchesAtScanRoot(matches, scanCwd) {
|
|
1122
1399
|
return matches.map((match) => ({
|
|
1123
1400
|
...match,
|
|
1124
|
-
file:
|
|
1401
|
+
file: path4.resolve(scanCwd, match.file)
|
|
1125
1402
|
}));
|
|
1126
1403
|
}
|
|
1127
1404
|
var SgRunner = class {
|
|
@@ -1378,14 +1655,14 @@ var SgRunner = class {
|
|
|
1378
1655
|
pkgSuffixes.push("win32-arm64-msvc");
|
|
1379
1656
|
const searchRoots = [];
|
|
1380
1657
|
for (const dir of walkUpDirs(process.cwd(), { maxDepth: 5 })) {
|
|
1381
|
-
searchRoots.push(
|
|
1658
|
+
searchRoots.push(path4.join(dir, "node_modules"));
|
|
1382
1659
|
}
|
|
1383
1660
|
for (const suffix of pkgSuffixes) {
|
|
1384
1661
|
const pkgName = `@ast-grep/cli-${suffix}`;
|
|
1385
1662
|
for (const root of searchRoots) {
|
|
1386
|
-
const candidate =
|
|
1663
|
+
const candidate = path4.join(root, pkgName, exeName);
|
|
1387
1664
|
try {
|
|
1388
|
-
if (
|
|
1665
|
+
if (fs4.existsSync(candidate) && await this.probeCommand(candidate, [])) {
|
|
1389
1666
|
return candidate;
|
|
1390
1667
|
}
|
|
1391
1668
|
} catch {
|
|
@@ -1409,8 +1686,8 @@ var SgRunner = class {
|
|
|
1409
1686
|
if (!prefix)
|
|
1410
1687
|
return void 0;
|
|
1411
1688
|
for (const name of ["ast-grep", "sg"]) {
|
|
1412
|
-
const candidate =
|
|
1413
|
-
if (
|
|
1689
|
+
const candidate = path4.join(prefix, "bin", name);
|
|
1690
|
+
if (fs4.existsSync(candidate) && await this.probeCommand(candidate, [])) {
|
|
1414
1691
|
return candidate;
|
|
1415
1692
|
}
|
|
1416
1693
|
}
|
|
@@ -1454,7 +1731,7 @@ ${result.stderr}`)) {
|
|
|
1454
1731
|
} else {
|
|
1455
1732
|
this.sweepSawTransient = true;
|
|
1456
1733
|
this.sweepTransientCause = cause;
|
|
1457
|
-
const name =
|
|
1734
|
+
const name = path4.basename(cmd);
|
|
1458
1735
|
if (!this.sweepUnreachable.includes(name)) {
|
|
1459
1736
|
this.sweepUnreachable.push(name);
|
|
1460
1737
|
}
|
|
@@ -1626,15 +1903,15 @@ Original error: ${stderr}`;
|
|
|
1626
1903
|
}
|
|
1627
1904
|
// --- Shared helpers for temp-dir rule scans ---
|
|
1628
1905
|
prepareTempScan(ruleId, ruleYaml) {
|
|
1629
|
-
const sessionDir =
|
|
1906
|
+
const sessionDir = fs4.mkdtempSync(path4.join(scannerReportParentDir(), `pi-lens-temp-${ruleId}-`));
|
|
1630
1907
|
try {
|
|
1631
|
-
const rulesSubdir =
|
|
1632
|
-
const configFile =
|
|
1633
|
-
|
|
1634
|
-
|
|
1908
|
+
const rulesSubdir = path4.join(sessionDir, "rules");
|
|
1909
|
+
const configFile = path4.join(sessionDir, ".sgconfig.yml");
|
|
1910
|
+
fs4.mkdirSync(rulesSubdir, { recursive: true });
|
|
1911
|
+
fs4.writeFileSync(configFile, `ruleDirs:
|
|
1635
1912
|
- ./rules
|
|
1636
1913
|
`);
|
|
1637
|
-
|
|
1914
|
+
fs4.writeFileSync(path4.join(rulesSubdir, `${ruleId}.yml`), ruleYaml);
|
|
1638
1915
|
return { sessionDir, configFile };
|
|
1639
1916
|
} catch (error) {
|
|
1640
1917
|
this.cleanupTempScan(sessionDir);
|
|
@@ -1643,18 +1920,18 @@ Original error: ${stderr}`;
|
|
|
1643
1920
|
}
|
|
1644
1921
|
cleanupTempScan(sessionDir) {
|
|
1645
1922
|
try {
|
|
1646
|
-
|
|
1923
|
+
fs4.rmSync(sessionDir, { recursive: true, force: true });
|
|
1647
1924
|
} catch (err) {
|
|
1648
1925
|
this.log(`Cleanup failed: ${err.message}`);
|
|
1649
1926
|
}
|
|
1650
1927
|
}
|
|
1651
1928
|
/** The scan anchor for one `dir` argument; see {@link SgScanAnchor}. */
|
|
1652
1929
|
sgScanAnchor(dir) {
|
|
1653
|
-
const absolute =
|
|
1654
|
-
const isDirectory =
|
|
1655
|
-
let treeRoot = isDirectory ? absolute :
|
|
1656
|
-
if (!
|
|
1657
|
-
treeRoot = [...walkUpDirs(treeRoot)].find((dir2) =>
|
|
1930
|
+
const absolute = path4.resolve(dir);
|
|
1931
|
+
const isDirectory = fs4.existsSync(absolute) && fs4.statSync(absolute).isDirectory();
|
|
1932
|
+
let treeRoot = isDirectory ? absolute : path4.dirname(absolute);
|
|
1933
|
+
if (!fs4.existsSync(treeRoot)) {
|
|
1934
|
+
treeRoot = [...walkUpDirs(treeRoot)].find((dir2) => fs4.existsSync(dir2)) ?? treeRoot;
|
|
1658
1935
|
}
|
|
1659
1936
|
const isolationCwd = this.sgSpawnOptions?.cwd;
|
|
1660
1937
|
if (isolationCwd !== void 0) {
|
|
@@ -1664,7 +1941,7 @@ Original error: ${stderr}`;
|
|
|
1664
1941
|
excludeArgs: findNearestContaining(treeRoot, [".git"]) ? [] : sgExcludeArgsForProject(absolute)
|
|
1665
1942
|
};
|
|
1666
1943
|
}
|
|
1667
|
-
const relative10 =
|
|
1944
|
+
const relative10 = path4.relative(treeRoot, absolute) || ".";
|
|
1668
1945
|
return {
|
|
1669
1946
|
cwd: treeRoot,
|
|
1670
1947
|
scanArg: relative10,
|
|
@@ -1733,7 +2010,7 @@ Original error: ${stderr}`;
|
|
|
1733
2010
|
let sessionDir;
|
|
1734
2011
|
try {
|
|
1735
2012
|
({ sessionDir } = this.prepareTempScan(ruleId, ruleYaml));
|
|
1736
|
-
const configFile =
|
|
2013
|
+
const configFile = path4.join(sessionDir, ".sgconfig.yml");
|
|
1737
2014
|
const anchor = this.sgScanAnchor(dir);
|
|
1738
2015
|
const result = await this.spawnResolved(this.getSgCommand(), [
|
|
1739
2016
|
"scan",
|
|
@@ -1769,7 +2046,7 @@ Original error: ${stderr}`;
|
|
|
1769
2046
|
let sessionDir;
|
|
1770
2047
|
try {
|
|
1771
2048
|
({ sessionDir } = this.prepareTempScan(ruleId, ruleYaml));
|
|
1772
|
-
const configFile =
|
|
2049
|
+
const configFile = path4.join(sessionDir, ".sgconfig.yml");
|
|
1773
2050
|
const command = this.getSgCommand();
|
|
1774
2051
|
const anchor = this.sgScanAnchor(dir);
|
|
1775
2052
|
const scanArgs = [
|
|
@@ -1883,7 +2160,7 @@ function reportAstGrepRulesHealth(bundledRuleDir) {
|
|
|
1883
2160
|
reportBundledResourceDirHealth("ast-grep-rules-dir-missing", bundledRuleDir, health, "ast-grep rule descriptions");
|
|
1884
2161
|
}
|
|
1885
2162
|
function matchedFilePath(file) {
|
|
1886
|
-
return normalizeFilePath(
|
|
2163
|
+
return normalizeFilePath(path5.resolve(process.cwd(), file));
|
|
1887
2164
|
}
|
|
1888
2165
|
function recordAstGrepApply(matches, { lineage, toolCallId, sessionId } = {}) {
|
|
1889
2166
|
const bridge = getMutationBridge();
|
|
@@ -2050,8 +2327,8 @@ var AstGrepClient = class {
|
|
|
2050
2327
|
usingBundledRuleDirFallback;
|
|
2051
2328
|
rulesHealthReportedGeneration;
|
|
2052
2329
|
constructor(ruleDir, verbose = false) {
|
|
2053
|
-
const projectRuleDir =
|
|
2054
|
-
const hasProjectRuleDir =
|
|
2330
|
+
const projectRuleDir = path5.join(process.cwd(), "rules");
|
|
2331
|
+
const hasProjectRuleDir = fs5.existsSync(projectRuleDir);
|
|
2055
2332
|
this.usingBundledRuleDirFallback = !ruleDir && !hasProjectRuleDir;
|
|
2056
2333
|
this.ruleDir = ruleDir || (hasProjectRuleDir ? projectRuleDir : resolvePackagePath(import.meta.url, "rules"));
|
|
2057
2334
|
this.log = verbose ? createSubsystemLogger("ast-grep") : () => {
|
|
@@ -2207,10 +2484,10 @@ var AstGrepClient = class {
|
|
|
2207
2484
|
* Dump the parsed tree-sitter AST for a snippet using ast-grep CLI.
|
|
2208
2485
|
*/
|
|
2209
2486
|
async dumpAst(source, lang, options = {}) {
|
|
2210
|
-
const tmpDir =
|
|
2211
|
-
const tmpFile =
|
|
2487
|
+
const tmpDir = fs5.mkdtempSync(path5.join(scannerReportParentDir(), "pi-lens-ast-dump-"));
|
|
2488
|
+
const tmpFile = path5.join(tmpDir, `snippet.${lang.replace(/[^a-z0-9_-]/gi, "") || "txt"}`);
|
|
2212
2489
|
try {
|
|
2213
|
-
|
|
2490
|
+
fs5.writeFileSync(tmpFile, source, "utf-8");
|
|
2214
2491
|
const mode = options.includeAnonymous ? "cst" : "ast";
|
|
2215
2492
|
const result = await this.runner.execRaw([
|
|
2216
2493
|
"run",
|
|
@@ -2229,7 +2506,7 @@ var AstGrepClient = class {
|
|
|
2229
2506
|
error: result.error || result.stderr.trim() || result.stdout.trim() || `ast-grep did not return a debug AST for language ${lang}`
|
|
2230
2507
|
};
|
|
2231
2508
|
} finally {
|
|
2232
|
-
|
|
2509
|
+
fs5.rmSync(tmpDir, { recursive: true, force: true });
|
|
2233
2510
|
}
|
|
2234
2511
|
}
|
|
2235
2512
|
async validatePattern(pattern, lang, options) {
|
|
@@ -2237,10 +2514,10 @@ var AstGrepClient = class {
|
|
|
2237
2514
|
if (shapeError)
|
|
2238
2515
|
return { valid: false, error: shapeError };
|
|
2239
2516
|
const snippet = validationSnippetFor(lang);
|
|
2240
|
-
const tmpDir =
|
|
2241
|
-
const tmpFile =
|
|
2517
|
+
const tmpDir = fs5.mkdtempSync(path5.join(scannerReportParentDir(), "pi-lens-sg-validate-"));
|
|
2518
|
+
const tmpFile = path5.join(tmpDir, `snippet.${snippet.ext}`);
|
|
2242
2519
|
try {
|
|
2243
|
-
|
|
2520
|
+
fs5.writeFileSync(tmpFile, snippet.source, "utf-8");
|
|
2244
2521
|
const args = ["run", "-p", pattern, "--lang", lang, "--json=compact"];
|
|
2245
2522
|
if (options?.selector)
|
|
2246
2523
|
args.push("--selector", options.selector);
|
|
@@ -2273,7 +2550,7 @@ var AstGrepClient = class {
|
|
|
2273
2550
|
};
|
|
2274
2551
|
} finally {
|
|
2275
2552
|
try {
|
|
2276
|
-
|
|
2553
|
+
fs5.rmSync(tmpDir, { recursive: true, force: true });
|
|
2277
2554
|
} catch {
|
|
2278
2555
|
}
|
|
2279
2556
|
}
|
|
@@ -2284,9 +2561,9 @@ var AstGrepClient = class {
|
|
|
2284
2561
|
return { valid: false, error: shapeError };
|
|
2285
2562
|
const language = extractRuleLanguage(ruleYaml) ?? "typescript";
|
|
2286
2563
|
const snippet = validationSnippetFor(language);
|
|
2287
|
-
const tmpDir =
|
|
2564
|
+
const tmpDir = fs5.mkdtempSync(path5.join(scannerReportParentDir(), "pi-lens-sg-rule-"));
|
|
2288
2565
|
try {
|
|
2289
|
-
|
|
2566
|
+
fs5.writeFileSync(path5.join(tmpDir, `snippet.${snippet.ext}`), snippet.source, "utf-8");
|
|
2290
2567
|
const result = await this.tempScanDetailed(tmpDir, ruleYaml, options);
|
|
2291
2568
|
if (result.failure || result.error) {
|
|
2292
2569
|
return {
|
|
@@ -2299,7 +2576,7 @@ var AstGrepClient = class {
|
|
|
2299
2576
|
return { valid: false, error: String(err) };
|
|
2300
2577
|
} finally {
|
|
2301
2578
|
try {
|
|
2302
|
-
|
|
2579
|
+
fs5.rmSync(tmpDir, { recursive: true, force: true });
|
|
2303
2580
|
} catch {
|
|
2304
2581
|
}
|
|
2305
2582
|
}
|
|
@@ -2580,21 +2857,21 @@ message: found
|
|
|
2580
2857
|
};
|
|
2581
2858
|
|
|
2582
2859
|
// dist/clients/lens-engine.js
|
|
2583
|
-
import * as
|
|
2860
|
+
import * as path29 from "node:path";
|
|
2584
2861
|
|
|
2585
2862
|
// dist/clients/project-diagnostics/scanner.js
|
|
2586
|
-
import * as
|
|
2587
|
-
import * as
|
|
2588
|
-
import * as
|
|
2863
|
+
import * as fs7 from "node:fs";
|
|
2864
|
+
import * as os2 from "node:os";
|
|
2865
|
+
import * as path7 from "node:path";
|
|
2589
2866
|
|
|
2590
2867
|
// dist/clients/project-diagnostics/cache.js
|
|
2591
|
-
import * as
|
|
2592
|
-
import * as
|
|
2868
|
+
import * as fs6 from "node:fs";
|
|
2869
|
+
import * as path6 from "node:path";
|
|
2593
2870
|
var PROJECT_DIAGNOSTICS_CACHE_VERSION = 3;
|
|
2594
2871
|
var SNAPSHOT_CACHE_FILE = "project-diagnostics.json";
|
|
2595
2872
|
var DELTA_CACHE_FILE = "project-diagnostics-delta.json";
|
|
2596
2873
|
function cachePath(cwd, fileName) {
|
|
2597
|
-
return
|
|
2874
|
+
return path6.join(getProjectDataDir(cwd), "cache", fileName);
|
|
2598
2875
|
}
|
|
2599
2876
|
function loadProjectDiagnosticsSnapshot(cwd) {
|
|
2600
2877
|
return readJsonCache(cachePath(cwd, SNAPSHOT_CACHE_FILE), (parsed) => {
|
|
@@ -2610,7 +2887,7 @@ function loadProjectDiagnosticsSnapshot(cwd) {
|
|
|
2610
2887
|
}
|
|
2611
2888
|
function saveProjectDiagnosticsSnapshot(cwd, snapshot) {
|
|
2612
2889
|
const filePath = cachePath(cwd, SNAPSHOT_CACHE_FILE);
|
|
2613
|
-
|
|
2890
|
+
fs6.mkdirSync(path6.dirname(filePath), { recursive: true });
|
|
2614
2891
|
writeFileAtomic(filePath, JSON.stringify(snapshot, null, 2));
|
|
2615
2892
|
}
|
|
2616
2893
|
function loadProjectDiagnosticsDeltaReport(cwd) {
|
|
@@ -2627,7 +2904,7 @@ function loadProjectDiagnosticsDeltaReport(cwd) {
|
|
|
2627
2904
|
}
|
|
2628
2905
|
function writeProjectDiagnosticsDeltaReport(cwd, report) {
|
|
2629
2906
|
const filePath = cachePath(cwd, DELTA_CACHE_FILE);
|
|
2630
|
-
|
|
2907
|
+
fs6.mkdirSync(path6.dirname(filePath), { recursive: true });
|
|
2631
2908
|
writeFileAtomic(filePath, JSON.stringify(report, null, 2));
|
|
2632
2909
|
}
|
|
2633
2910
|
function reconcileProjectDiagnosticsSnapshot(snapshot) {
|
|
@@ -2642,7 +2919,7 @@ function reconcileProjectDiagnosticsSnapshot(snapshot) {
|
|
|
2642
2919
|
let stale;
|
|
2643
2920
|
let stat;
|
|
2644
2921
|
try {
|
|
2645
|
-
stat =
|
|
2922
|
+
stat = fs6.statSync(filePath);
|
|
2646
2923
|
} catch {
|
|
2647
2924
|
stat = void 0;
|
|
2648
2925
|
}
|
|
@@ -2651,7 +2928,7 @@ function reconcileProjectDiagnosticsSnapshot(snapshot) {
|
|
|
2651
2928
|
stale = true;
|
|
2652
2929
|
if (stat.size === fingerprint2.sizeBytes) {
|
|
2653
2930
|
try {
|
|
2654
|
-
stale = hashDiagnosticContent(
|
|
2931
|
+
stale = hashDiagnosticContent(fs6.readFileSync(filePath, "utf-8")) !== fingerprint2.contentHash;
|
|
2655
2932
|
} catch {
|
|
2656
2933
|
stale = true;
|
|
2657
2934
|
}
|
|
@@ -2695,7 +2972,7 @@ function normalizeSemantic(diagnostic) {
|
|
|
2695
2972
|
}
|
|
2696
2973
|
function fromDispatchDiagnostic(diagnostic, runner) {
|
|
2697
2974
|
return {
|
|
2698
|
-
filePath:
|
|
2975
|
+
filePath: path7.resolve(diagnostic.filePath),
|
|
2699
2976
|
line: diagnostic.line,
|
|
2700
2977
|
column: diagnostic.column,
|
|
2701
2978
|
severity: normalizeSeverity(diagnostic.severity),
|
|
@@ -2798,14 +3075,14 @@ async function scanFileMajorRules(cwd, files, signal) {
|
|
|
2798
3075
|
}
|
|
2799
3076
|
if (isTestFile(filePath))
|
|
2800
3077
|
continue;
|
|
2801
|
-
const ext =
|
|
3078
|
+
const ext = path7.extname(filePath);
|
|
2802
3079
|
const grammarId = TREE_SITTER_EXT_TO_LANG[ext];
|
|
2803
3080
|
const langId = grammarId && hasTreeSitterRules(grammarId) ? grammarId : void 0;
|
|
2804
3081
|
const factEligible = isJstsFactFile(filePath);
|
|
2805
3082
|
let astGrepLang;
|
|
2806
3083
|
if (sgModule && canHandle(filePath)) {
|
|
2807
3084
|
try {
|
|
2808
|
-
if (
|
|
3085
|
+
if (fs7.statSync(filePath).size <= AST_GREP_MAX_FILE_BYTES) {
|
|
2809
3086
|
astGrepLang = getLang(filePath, sgModule);
|
|
2810
3087
|
}
|
|
2811
3088
|
} catch {
|
|
@@ -2818,7 +3095,7 @@ async function scanFileMajorRules(cwd, files, signal) {
|
|
|
2818
3095
|
let content;
|
|
2819
3096
|
let contentBytes;
|
|
2820
3097
|
try {
|
|
2821
|
-
const buf =
|
|
3098
|
+
const buf = fs7.readFileSync(filePath);
|
|
2822
3099
|
contentBytes = buf.length;
|
|
2823
3100
|
content = buf.toString("utf-8");
|
|
2824
3101
|
} catch {
|
|
@@ -2877,7 +3154,7 @@ async function scanFileMajorRules(cwd, files, signal) {
|
|
|
2877
3154
|
} finally {
|
|
2878
3155
|
facts.dropFileFacts(filePath);
|
|
2879
3156
|
}
|
|
2880
|
-
await new Promise((
|
|
3157
|
+
await new Promise((resolve32) => setImmediate(resolve32));
|
|
2881
3158
|
}
|
|
2882
3159
|
if (wasmAborted) {
|
|
2883
3160
|
astGrep.length = 0;
|
|
@@ -2928,9 +3205,9 @@ async function scanFileMajorRules(cwd, files, signal) {
|
|
|
2928
3205
|
};
|
|
2929
3206
|
}
|
|
2930
3207
|
async function scanProjectDiagnostics(options) {
|
|
2931
|
-
const cwd =
|
|
3208
|
+
const cwd = path7.resolve(options.cwd);
|
|
2932
3209
|
const { signal } = options;
|
|
2933
|
-
if (!options.files && isAtOrAboveHomeDir(realpathOrResolve(cwd), realpathOrResolve(options.homeDir ??
|
|
3210
|
+
if (!options.files && isAtOrAboveHomeDir(realpathOrResolve(cwd), realpathOrResolve(options.homeDir ?? os2.homedir()))) {
|
|
2934
3211
|
return {
|
|
2935
3212
|
version: PROJECT_DIAGNOSTICS_CACHE_VERSION,
|
|
2936
3213
|
cwd,
|
|
@@ -3015,13 +3292,13 @@ async function scanProjectDiagnostics(options) {
|
|
|
3015
3292
|
|
|
3016
3293
|
// dist/clients/mcp/review.js
|
|
3017
3294
|
import { spawn } from "node:child_process";
|
|
3018
|
-
import { existsSync as
|
|
3019
|
-
import { join as
|
|
3295
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
3296
|
+
import { join as join7 } from "node:path";
|
|
3020
3297
|
function resolveRebuildScript(serverFilePath) {
|
|
3021
3298
|
return toPosix(serverFilePath).includes("/dist/") ? "build:dist" : "build";
|
|
3022
3299
|
}
|
|
3023
3300
|
function analyzeFileFresh(workerPath, file, cwd, options = {}, timeoutMs = 12e4) {
|
|
3024
|
-
return new Promise((
|
|
3301
|
+
return new Promise((resolve32) => {
|
|
3025
3302
|
const args = [workerPath, `--file=${file}`, `--cwd=${cwd}`];
|
|
3026
3303
|
if (options.flags)
|
|
3027
3304
|
args.push(`--flags=${JSON.stringify(options.flags)}`);
|
|
@@ -3031,7 +3308,7 @@ function analyzeFileFresh(workerPath, file, cwd, options = {}, timeoutMs = 12e4)
|
|
|
3031
3308
|
stdio: ["ignore", "pipe", "pipe"]
|
|
3032
3309
|
});
|
|
3033
3310
|
} catch (err) {
|
|
3034
|
-
|
|
3311
|
+
resolve32({
|
|
3035
3312
|
error: `failed to fork worker: ${err instanceof Error ? err.message : String(err)}`
|
|
3036
3313
|
});
|
|
3037
3314
|
return;
|
|
@@ -3044,7 +3321,7 @@ function analyzeFileFresh(workerPath, file, cwd, options = {}, timeoutMs = 12e4)
|
|
|
3044
3321
|
return;
|
|
3045
3322
|
settled = true;
|
|
3046
3323
|
clearTimeout(timer);
|
|
3047
|
-
|
|
3324
|
+
resolve32(outcome);
|
|
3048
3325
|
};
|
|
3049
3326
|
const timer = setTimeout(() => {
|
|
3050
3327
|
child.kill();
|
|
@@ -3102,7 +3379,7 @@ function analyzeFileFresh(workerPath, file, cwd, options = {}, timeoutMs = 12e4)
|
|
|
3102
3379
|
}
|
|
3103
3380
|
function canRebuildPiLens(repoRoot) {
|
|
3104
3381
|
const inNodeModules = /(^|[\\/])node_modules([\\/]|$)/i.test(repoRoot);
|
|
3105
|
-
return !inNodeModules &&
|
|
3382
|
+
return !inNodeModules && existsSync5(join7(repoRoot, "tsconfig.dist.json"));
|
|
3106
3383
|
}
|
|
3107
3384
|
var REBUILD_UNAVAILABLE_MESSAGE = "pilens_rebuild is unavailable in an installed pi-lens package. Rebuilding is only safe from a source checkout containing tsconfig.dist.json; reinstall or update pi-lens through your package manager instead.";
|
|
3108
3385
|
async function runRebuild(repoRoot, script, timeoutMs = 3e5) {
|
|
@@ -3151,7 +3428,7 @@ function summarizeScan(diagnostics) {
|
|
|
3151
3428
|
|
|
3152
3429
|
// dist/clients/mcp/session.js
|
|
3153
3430
|
import * as crypto from "node:crypto";
|
|
3154
|
-
import * as
|
|
3431
|
+
import * as fs18 from "node:fs";
|
|
3155
3432
|
|
|
3156
3433
|
// dist/clients/bootstrap.js
|
|
3157
3434
|
var residentClients = null;
|
|
@@ -3208,28 +3485,28 @@ async function buildBootstrapClients() {
|
|
|
3208
3485
|
}
|
|
3209
3486
|
}
|
|
3210
3487
|
const [ruffClient, biomeClient, knipClient, todoScanner, jscpdClient, depChecker, testRunnerClient, complexityClient, goClient, govulncheckClient, gitleaksClient, trivyClient, opengrepClient, rustClient, agentBehaviorClient2, deadCodeClients] = await Promise.all([
|
|
3211
|
-
load("ruff", async () => new (await import("../chunk-
|
|
3212
|
-
load("biome", async () => new (await import("../chunk-
|
|
3213
|
-
load("knip", async () => new (await import("../chunk-
|
|
3214
|
-
load("todo", async () => new (await import("../chunk-
|
|
3215
|
-
load("jscpd", async () => new (await import("../chunk-
|
|
3216
|
-
load("dependency-checker", async () => new (await import("../chunk-
|
|
3217
|
-
load("test-runner", async () => new (await import("../chunk-
|
|
3218
|
-
load("complexity", async () => new (await import("../chunk-
|
|
3488
|
+
load("ruff", async () => new (await import("../chunk-YL6JQTWC.js")).RuffClient()),
|
|
3489
|
+
load("biome", async () => new (await import("../chunk-4X3ML2UQ.js")).BiomeClient()),
|
|
3490
|
+
load("knip", async () => new (await import("../chunk-F2SAP2FM.js")).KnipClient()),
|
|
3491
|
+
load("todo", async () => new (await import("../chunk-5BI5YP57.js")).TodoScanner()),
|
|
3492
|
+
load("jscpd", async () => new (await import("../chunk-UPAFSETJ.js")).JscpdClient()),
|
|
3493
|
+
load("dependency-checker", async () => new (await import("../chunk-TB5MGZLS.js")).DependencyChecker()),
|
|
3494
|
+
load("test-runner", async () => new (await import("../chunk-TTK37D7R.js")).TestRunnerClient()),
|
|
3495
|
+
load("complexity", async () => new (await import("../chunk-2K7BUOKS.js")).ComplexityClient()),
|
|
3219
3496
|
// The process-wide singleton, NOT a fresh instance (#2455 fix round 4,
|
|
3220
3497
|
// F2). `handleSessionStart` reads this object for its "Active tools"
|
|
3221
3498
|
// line while `resetGoAvailability` re-arms the singleton's latch; a
|
|
3222
3499
|
// second instance here meant the reset never reached the surface a
|
|
3223
3500
|
// user actually sees.
|
|
3224
|
-
load("go", async () => (await import("../chunk-
|
|
3225
|
-
load("govulncheck", async () => new (await import("../chunk-
|
|
3226
|
-
load("gitleaks", async () => new (await import("../chunk-
|
|
3227
|
-
load("trivy", async () => new (await import("../chunk-
|
|
3228
|
-
load("opengrep", async () => new (await import("../chunk-
|
|
3501
|
+
load("go", async () => (await import("../chunk-IUM2Q7NF.js")).goClient),
|
|
3502
|
+
load("govulncheck", async () => new (await import("../chunk-D3KLF5CD.js")).GovulncheckClient()),
|
|
3503
|
+
load("gitleaks", async () => new (await import("../chunk-OLXBUTJR.js")).GitleaksClient()),
|
|
3504
|
+
load("trivy", async () => new (await import("../chunk-TJOYHAXJ.js")).TrivyClient()),
|
|
3505
|
+
load("opengrep", async () => new (await import("../chunk-OZGEHOSG.js")).OpengrepClient()),
|
|
3229
3506
|
// The process-wide singleton, for the same reason as "go" above.
|
|
3230
|
-
load("rust", async () => (await import("../chunk-
|
|
3231
|
-
load("agent-behavior", async () => (await import("../chunk-
|
|
3232
|
-
loadList("dead-code", async () => (await import("../chunk-
|
|
3507
|
+
load("rust", async () => (await import("../chunk-GR2QDWH5.js")).rustClient),
|
|
3508
|
+
load("agent-behavior", async () => (await import("../chunk-AWMFBPGJ.js")).agentBehaviorClient),
|
|
3509
|
+
loadList("dead-code", async () => (await import("../chunk-COGU5KQJ.js")).getDeadCodeClients())
|
|
3233
3510
|
]);
|
|
3234
3511
|
if (failures.length > 0)
|
|
3235
3512
|
await logBootstrapFailures(failures);
|
|
@@ -3315,7 +3592,7 @@ function resetAnalyzerBootstrapSessionState() {
|
|
|
3315
3592
|
}
|
|
3316
3593
|
|
|
3317
3594
|
// dist/clients/formatters-lazy.js
|
|
3318
|
-
var lazyFormatters = createLazyImport(() => import("../chunk-
|
|
3595
|
+
var lazyFormatters = createLazyImport(() => import("../chunk-OFKKMXWM.js"));
|
|
3319
3596
|
function warmFormatters() {
|
|
3320
3597
|
return lazyFormatters.get();
|
|
3321
3598
|
}
|
|
@@ -3334,14 +3611,14 @@ function resetFormatService() {
|
|
|
3334
3611
|
|
|
3335
3612
|
// dist/clients/runtime-coordinator.js
|
|
3336
3613
|
import { randomBytes } from "node:crypto";
|
|
3337
|
-
import * as
|
|
3338
|
-
import * as
|
|
3614
|
+
import * as fs9 from "node:fs";
|
|
3615
|
+
import * as path9 from "node:path";
|
|
3339
3616
|
|
|
3340
3617
|
// dist/clients/project-changes.js
|
|
3341
|
-
import * as
|
|
3342
|
-
import * as
|
|
3618
|
+
import * as fs8 from "node:fs";
|
|
3619
|
+
import * as path8 from "node:path";
|
|
3343
3620
|
function getProjectChangeLogPath(cwd) {
|
|
3344
|
-
return
|
|
3621
|
+
return path8.join(getProjectDataDir(cwd), "change-log.jsonl");
|
|
3345
3622
|
}
|
|
3346
3623
|
function parseChangeLine(line) {
|
|
3347
3624
|
try {
|
|
@@ -3377,7 +3654,7 @@ function parseChangeLog(logPath, content) {
|
|
|
3377
3654
|
function readProjectChanges(cwd) {
|
|
3378
3655
|
const logPath = getProjectChangeLogPath(cwd);
|
|
3379
3656
|
try {
|
|
3380
|
-
return parseChangeLog(logPath,
|
|
3657
|
+
return parseChangeLog(logPath, fs8.readFileSync(logPath, "utf-8"));
|
|
3381
3658
|
} catch {
|
|
3382
3659
|
return [];
|
|
3383
3660
|
}
|
|
@@ -3385,7 +3662,7 @@ function readProjectChanges(cwd) {
|
|
|
3385
3662
|
async function readProjectChangesAsync(cwd) {
|
|
3386
3663
|
const logPath = getProjectChangeLogPath(cwd);
|
|
3387
3664
|
try {
|
|
3388
|
-
return parseChangeLog(logPath, await
|
|
3665
|
+
return parseChangeLog(logPath, await fs8.promises.readFile(logPath, "utf-8"));
|
|
3389
3666
|
} catch {
|
|
3390
3667
|
return [];
|
|
3391
3668
|
}
|
|
@@ -3393,7 +3670,7 @@ async function readProjectChangesAsync(cwd) {
|
|
|
3393
3670
|
var _sequenceFoldCountForTests = 0;
|
|
3394
3671
|
function foldEntry(entry, fileSeqByPath) {
|
|
3395
3672
|
_sequenceFoldCountForTests++;
|
|
3396
|
-
const key = normalizeMapKey(
|
|
3673
|
+
const key = normalizeMapKey(path8.resolve(entry.filePath));
|
|
3397
3674
|
fileSeqByPath.set(key, Math.max(fileSeqByPath.get(key) ?? 0, entry.fileSeq));
|
|
3398
3675
|
}
|
|
3399
3676
|
function fullReplay(entries) {
|
|
@@ -3441,7 +3718,7 @@ async function readLatestProjectSequenceAsync(cwd, base) {
|
|
|
3441
3718
|
function readChangeLogMaxSeq(logPath) {
|
|
3442
3719
|
let fd;
|
|
3443
3720
|
try {
|
|
3444
|
-
fd =
|
|
3721
|
+
fd = fs8.openSync(logPath, "r");
|
|
3445
3722
|
} catch (err) {
|
|
3446
3723
|
if (err.code === "ENOENT")
|
|
3447
3724
|
return 0;
|
|
@@ -3449,10 +3726,10 @@ function readChangeLogMaxSeq(logPath) {
|
|
|
3449
3726
|
}
|
|
3450
3727
|
try {
|
|
3451
3728
|
const cursor = changeLogCursors.get(logPath) ?? { bytes: 0, maxSeq: 0 };
|
|
3452
|
-
const size =
|
|
3729
|
+
const size = fs8.fstatSync(fd).size;
|
|
3453
3730
|
if (size > cursor.bytes) {
|
|
3454
3731
|
const tail = Buffer.alloc(size - cursor.bytes);
|
|
3455
|
-
const read =
|
|
3732
|
+
const read = fs8.readSync(fd, tail, 0, tail.length, cursor.bytes);
|
|
3456
3733
|
const complete = tail.subarray(0, read).lastIndexOf(10) + 1;
|
|
3457
3734
|
for (const line of tail.subarray(0, complete).toString("utf-8").split("\n")) {
|
|
3458
3735
|
const entry = line.trim() ? parseChangeLine(line) : void 0;
|
|
@@ -3464,7 +3741,7 @@ function readChangeLogMaxSeq(logPath) {
|
|
|
3464
3741
|
changeLogCursors.set(logPath, cursor);
|
|
3465
3742
|
return cursor.maxSeq;
|
|
3466
3743
|
} finally {
|
|
3467
|
-
|
|
3744
|
+
fs8.closeSync(fd);
|
|
3468
3745
|
}
|
|
3469
3746
|
}
|
|
3470
3747
|
var CHANGE_LOG_LOCK = { staleMs: 5e3, waitMs: 500 };
|
|
@@ -3473,14 +3750,14 @@ function appendProjectChangeAllocated(cwd, build) {
|
|
|
3473
3750
|
}
|
|
3474
3751
|
function appendProjectChangesAllocated(cwd, buildAll) {
|
|
3475
3752
|
const logPath = getProjectChangeLogPath(cwd);
|
|
3476
|
-
|
|
3753
|
+
fs8.mkdirSync(path8.dirname(logPath), { recursive: true });
|
|
3477
3754
|
readChangeLogMaxSeq(logPath);
|
|
3478
3755
|
const append = (locked) => {
|
|
3479
3756
|
const entries = buildAll(readChangeLogMaxSeq(logPath));
|
|
3480
3757
|
if (entries.length === 0)
|
|
3481
3758
|
return;
|
|
3482
3759
|
const payload = entries.map((entry) => JSON.stringify(locked ? entry : { ...entry, unlocked: true })).join("\n");
|
|
3483
|
-
|
|
3760
|
+
fs8.appendFileSync(logPath, `${payload}
|
|
3484
3761
|
`, "utf-8");
|
|
3485
3762
|
};
|
|
3486
3763
|
const result = withGenerationLockSync(`${logPath}.locks`, CHANGE_LOG_LOCK, () => append(true));
|
|
@@ -3610,7 +3887,7 @@ function recordViewIncomplete(cwd, cause) {
|
|
|
3610
3887
|
const why = `the change log reached seq ${cause.logMaxSeq} while this runtime was at ${cause.ownSeq} (${cause.ownSeq === 0 ? "a sibling process, or a timed-out session_start read that seeded 0; see snapshot-sequence-read-timeout" : "a sibling process logged above it"})`;
|
|
3611
3888
|
recordDegradationOnce({
|
|
3612
3889
|
kind: "snapshot-view-incomplete",
|
|
3613
|
-
subject:
|
|
3890
|
+
subject: path9.resolve(cwd),
|
|
3614
3891
|
reason: `snapshots are stamped incomplete (never fresh) until the next seed from the change log: ${why}`
|
|
3615
3892
|
});
|
|
3616
3893
|
}
|
|
@@ -3624,10 +3901,13 @@ var MAX_OWED_ANCHORS = 16;
|
|
|
3624
3901
|
var TOOL_CALL_ATTRIBUTION_CAPACITY = 256;
|
|
3625
3902
|
var TOOL_CALL_ATTRIBUTION_TTL_MS = 5 * 6e4;
|
|
3626
3903
|
var BLOCKER_FULL_DELIVERY_CAP = 3;
|
|
3627
|
-
function narrowedRecord(existing, kept) {
|
|
3904
|
+
function narrowedRecord(existing, kept, root) {
|
|
3628
3905
|
return {
|
|
3629
3906
|
...existing,
|
|
3630
|
-
summary: formatDiagnostics(kept, "blocking"
|
|
3907
|
+
summary: formatDiagnostics(kept, "blocking", void 0, {
|
|
3908
|
+
editedFile: existing.filePath,
|
|
3909
|
+
root
|
|
3910
|
+
}).trim(),
|
|
3631
3911
|
diagnostics: kept,
|
|
3632
3912
|
sources: inlineBlockerSources(kept),
|
|
3633
3913
|
lines: inlineBlockerLines(kept, existing.filePath)
|
|
@@ -3949,12 +4229,12 @@ var RuntimeCoordinator = class {
|
|
|
3949
4229
|
* the map is already what the policy just decided.
|
|
3950
4230
|
*/
|
|
3951
4231
|
applyInlineBlockerPolicyVerdicts(suppressedFilePaths, of) {
|
|
3952
|
-
const suppressed = new Set(suppressedFilePaths.map((filePath) =>
|
|
4232
|
+
const suppressed = new Set(suppressedFilePaths.map((filePath) => path9.resolve(filePath)));
|
|
3953
4233
|
let changed = 0;
|
|
3954
4234
|
for (const [key, entry] of this._pendingInlineBlockers.entries()) {
|
|
3955
4235
|
if (of && !this.ownedBy(entry, of.sessionId))
|
|
3956
4236
|
continue;
|
|
3957
|
-
const policySuppressed = suppressed.has(
|
|
4237
|
+
const policySuppressed = suppressed.has(path9.resolve(entry.filePath));
|
|
3958
4238
|
if ((entry.policySuppressed ?? false) === policySuppressed)
|
|
3959
4239
|
continue;
|
|
3960
4240
|
this._pendingInlineBlockers.set(key, { ...entry, policySuppressed });
|
|
@@ -4131,7 +4411,7 @@ var RuntimeCoordinator = class {
|
|
|
4131
4411
|
sessionId: this.turnSession(args.sessionId),
|
|
4132
4412
|
turnIndex: this.turnIndex,
|
|
4133
4413
|
source: args.source,
|
|
4134
|
-
filePath:
|
|
4414
|
+
filePath: path9.resolve(args.filePath),
|
|
4135
4415
|
fileSeq: logged.fileSeq,
|
|
4136
4416
|
changedRange: args.changedRange
|
|
4137
4417
|
};
|
|
@@ -4179,7 +4459,7 @@ var RuntimeCoordinator = class {
|
|
|
4179
4459
|
sessionId: this.telemetrySessionId,
|
|
4180
4460
|
turnIndex: this.turnIndex,
|
|
4181
4461
|
source: args.source,
|
|
4182
|
-
filePath:
|
|
4462
|
+
filePath: path9.resolve(paths[index]),
|
|
4183
4463
|
fileSeq: bump.fileSeq
|
|
4184
4464
|
}));
|
|
4185
4465
|
});
|
|
@@ -4362,7 +4642,7 @@ var RuntimeCoordinator = class {
|
|
|
4362
4642
|
this._fileSeq.clear();
|
|
4363
4643
|
this._fileLastProjectSeq.clear();
|
|
4364
4644
|
for (const [filePath, seq] of fileSeqByPath ?? []) {
|
|
4365
|
-
this._fileSeq.set(normalizeMapKey(
|
|
4645
|
+
this._fileSeq.set(normalizeMapKey(path9.resolve(filePath)), Math.max(0, seq));
|
|
4366
4646
|
}
|
|
4367
4647
|
}
|
|
4368
4648
|
/**
|
|
@@ -4380,14 +4660,14 @@ var RuntimeCoordinator = class {
|
|
|
4380
4660
|
this._projectSeq = Math.max(this._projectSeq, Math.floor(projectSeq));
|
|
4381
4661
|
this._viewLogEntries = Math.max(this._viewLogEntries, logEntries);
|
|
4382
4662
|
for (const [filePath, seq] of fileSeqByPath) {
|
|
4383
|
-
const key = normalizeMapKey(
|
|
4663
|
+
const key = normalizeMapKey(path9.resolve(filePath));
|
|
4384
4664
|
this._fileSeq.set(key, Math.max(this._fileSeq.get(key) ?? 0, seq));
|
|
4385
4665
|
}
|
|
4386
4666
|
if (projectSeq >= this._viewMissingThrough)
|
|
4387
4667
|
this._viewMissingThrough = 0;
|
|
4388
4668
|
}
|
|
4389
4669
|
bumpFileSeq(filePath, logMaxSeq = 0) {
|
|
4390
|
-
const key = normalizeMapKey(
|
|
4670
|
+
const key = normalizeMapKey(path9.resolve(filePath));
|
|
4391
4671
|
if (logMaxSeq > this._projectSeq) {
|
|
4392
4672
|
this._projectSeq = logMaxSeq;
|
|
4393
4673
|
this._viewMissingThrough = Math.max(this._viewMissingThrough, logMaxSeq);
|
|
@@ -4414,7 +4694,7 @@ var RuntimeCoordinator = class {
|
|
|
4414
4694
|
return changed;
|
|
4415
4695
|
}
|
|
4416
4696
|
getFileSeq(filePath) {
|
|
4417
|
-
return this._fileSeq.get(normalizeMapKey(
|
|
4697
|
+
return this._fileSeq.get(normalizeMapKey(path9.resolve(filePath))) ?? 0;
|
|
4418
4698
|
}
|
|
4419
4699
|
getFileSeqEntries() {
|
|
4420
4700
|
return [...this._fileSeq.entries()];
|
|
@@ -4450,7 +4730,7 @@ var RuntimeCoordinator = class {
|
|
|
4450
4730
|
return this._startupScansInFlight.has(name);
|
|
4451
4731
|
}
|
|
4452
4732
|
formatPipelineCrashNotice(filePath, err) {
|
|
4453
|
-
const key =
|
|
4733
|
+
const key = path9.resolve(filePath);
|
|
4454
4734
|
const count = (this._pipelineCrashCounts.get(key) ?? 0) + 1;
|
|
4455
4735
|
this._pipelineCrashCounts.set(key, count);
|
|
4456
4736
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -4460,7 +4740,7 @@ var RuntimeCoordinator = class {
|
|
|
4460
4740
|
return "";
|
|
4461
4741
|
return [
|
|
4462
4742
|
"\u26A0\uFE0F pi-lens pipeline crashed while analyzing this write.",
|
|
4463
|
-
`File: ${
|
|
4743
|
+
`File: ${path9.basename(filePath)} | crash count this session: ${count}`,
|
|
4464
4744
|
`Error: ${shortMessage}`,
|
|
4465
4745
|
"Recovery: LSP service was reset. If this repeats, rerun with --no-lsp and report the file + stack."
|
|
4466
4746
|
].join("\n");
|
|
@@ -4557,8 +4837,8 @@ var RuntimeCoordinator = class {
|
|
|
4557
4837
|
});
|
|
4558
4838
|
return entry;
|
|
4559
4839
|
});
|
|
4560
|
-
const timeout = new Promise((
|
|
4561
|
-
setTimeout(
|
|
4840
|
+
const timeout = new Promise((resolve32) => {
|
|
4841
|
+
setTimeout(resolve32, maxWaitMs).unref?.();
|
|
4562
4842
|
});
|
|
4563
4843
|
await Promise.race([
|
|
4564
4844
|
Promise.allSettled(tracked.map((t) => t.promise)),
|
|
@@ -4700,7 +4980,10 @@ var RuntimeCoordinator = class {
|
|
|
4700
4980
|
} : {},
|
|
4701
4981
|
...this.recordSession(sessionId)
|
|
4702
4982
|
},
|
|
4703
|
-
summary: formatDiagnostics(diagnostics, "blocking"
|
|
4983
|
+
summary: formatDiagnostics(diagnostics, "blocking", void 0, {
|
|
4984
|
+
editedFile: filePath,
|
|
4985
|
+
root: this.projectRoot || void 0
|
|
4986
|
+
}).trim(),
|
|
4704
4987
|
diagnostics,
|
|
4705
4988
|
// The same two derivations the pipeline's writer uses: `lines` keeps only
|
|
4706
4989
|
// this file's own rows, `sources` pins an untagged finding as "unknown".
|
|
@@ -4799,7 +5082,7 @@ var RuntimeCoordinator = class {
|
|
|
4799
5082
|
this._pendingInlineBlockers.delete(key);
|
|
4800
5083
|
return retired.length;
|
|
4801
5084
|
}
|
|
4802
|
-
this._pendingInlineBlockers.set(key, narrowedRecord(existing, kept));
|
|
5085
|
+
this._pendingInlineBlockers.set(key, narrowedRecord(existing, kept, this.projectRoot || void 0));
|
|
4803
5086
|
return retired.length;
|
|
4804
5087
|
}
|
|
4805
5088
|
/**
|
|
@@ -5204,7 +5487,7 @@ var RuntimeCoordinator = class {
|
|
|
5204
5487
|
this._pendingInlineBlockers.delete(key);
|
|
5205
5488
|
return true;
|
|
5206
5489
|
}
|
|
5207
|
-
this._pendingInlineBlockers.set(key, narrowedRecord(existing, kept));
|
|
5490
|
+
this._pendingInlineBlockers.set(key, narrowedRecord(existing, kept, this.projectRoot || void 0));
|
|
5208
5491
|
return true;
|
|
5209
5492
|
}
|
|
5210
5493
|
/**
|
|
@@ -5269,7 +5552,7 @@ var RuntimeCoordinator = class {
|
|
|
5269
5552
|
this.noteResolvedBlockerFile(existing, void 0, true);
|
|
5270
5553
|
this._pendingInlineBlockers.delete(key);
|
|
5271
5554
|
} else {
|
|
5272
|
-
this._pendingInlineBlockers.set(key, narrowedRecord(existing, kept));
|
|
5555
|
+
this._pendingInlineBlockers.set(key, narrowedRecord(existing, kept, this.projectRoot || void 0));
|
|
5273
5556
|
}
|
|
5274
5557
|
}
|
|
5275
5558
|
return changed;
|
|
@@ -5291,7 +5574,7 @@ var RuntimeCoordinator = class {
|
|
|
5291
5574
|
* to retire.
|
|
5292
5575
|
*/
|
|
5293
5576
|
retireForeignRowsOfMissingFiles(of) {
|
|
5294
|
-
return this.retireForeignRows("cited-file-missing", (row) =>
|
|
5577
|
+
return this.retireForeignRows("cited-file-missing", (row) => path9.isAbsolute(row.filePath) && !fs9.existsSync(row.filePath), void 0, of);
|
|
5295
5578
|
}
|
|
5296
5579
|
/**
|
|
5297
5580
|
* #3218 criterion 2: a retirement no turn_end has delivered yet. The
|
|
@@ -5336,7 +5619,7 @@ var RuntimeCoordinator = class {
|
|
|
5336
5619
|
reconcileInlineBlockers() {
|
|
5337
5620
|
const survivors = [];
|
|
5338
5621
|
for (const [displayPath, value] of this._pendingInlineBlockers.entries()) {
|
|
5339
|
-
if (
|
|
5622
|
+
if (fs9.existsSync(displayPath))
|
|
5340
5623
|
survivors.push([displayPath, value]);
|
|
5341
5624
|
}
|
|
5342
5625
|
if (survivors.length !== this._pendingInlineBlockers.size) {
|
|
@@ -5791,7 +6074,7 @@ var RuntimeCoordinator = class {
|
|
|
5791
6074
|
this.requeueDeferredFormatFiles(records2, capFormatFailures);
|
|
5792
6075
|
}
|
|
5793
6076
|
shouldWarmLspOnRead(filePath, maxAgeMs = 12e4) {
|
|
5794
|
-
const state = this._lspReadWarmState.get(
|
|
6077
|
+
const state = this._lspReadWarmState.get(path9.resolve(filePath));
|
|
5795
6078
|
if (!state)
|
|
5796
6079
|
return true;
|
|
5797
6080
|
if (state.status === "warming")
|
|
@@ -5799,26 +6082,26 @@ var RuntimeCoordinator = class {
|
|
|
5799
6082
|
return Date.now() - state.ts > maxAgeMs;
|
|
5800
6083
|
}
|
|
5801
6084
|
markLspReadWarmStarted(filePath) {
|
|
5802
|
-
this._lspReadWarmState.set(
|
|
6085
|
+
this._lspReadWarmState.set(path9.resolve(filePath), {
|
|
5803
6086
|
status: "warming",
|
|
5804
6087
|
ts: Date.now()
|
|
5805
6088
|
});
|
|
5806
6089
|
}
|
|
5807
6090
|
markLspReadWarmCompleted(filePath) {
|
|
5808
|
-
this._lspReadWarmState.set(
|
|
6091
|
+
this._lspReadWarmState.set(path9.resolve(filePath), {
|
|
5809
6092
|
status: "ready",
|
|
5810
6093
|
ts: Date.now()
|
|
5811
6094
|
});
|
|
5812
6095
|
}
|
|
5813
6096
|
clearLspReadWarmState(filePath) {
|
|
5814
|
-
this._lspReadWarmState.delete(
|
|
6097
|
+
this._lspReadWarmState.delete(path9.resolve(filePath));
|
|
5815
6098
|
}
|
|
5816
6099
|
};
|
|
5817
6100
|
|
|
5818
6101
|
// dist/clients/runtime-session.js
|
|
5819
6102
|
import * as nodeFs from "node:fs";
|
|
5820
|
-
import * as
|
|
5821
|
-
import * as
|
|
6103
|
+
import * as os3 from "node:os";
|
|
6104
|
+
import * as path14 from "node:path";
|
|
5822
6105
|
|
|
5823
6106
|
// dist/clients/message-end-attribution.js
|
|
5824
6107
|
var lastStableSessionId;
|
|
@@ -5831,10 +6114,10 @@ function rotateMessageEndAttribution() {
|
|
|
5831
6114
|
}
|
|
5832
6115
|
|
|
5833
6116
|
// dist/clients/dead-code-logger.js
|
|
5834
|
-
import * as
|
|
6117
|
+
import * as path10 from "node:path";
|
|
5835
6118
|
var LOG_DIR = getGlobalPiLensLogDir();
|
|
5836
|
-
var LOG_FILE =
|
|
5837
|
-
var LOG_BACKUP_FILE =
|
|
6119
|
+
var LOG_FILE = path10.join(LOG_DIR, "dead-code.log");
|
|
6120
|
+
var LOG_BACKUP_FILE = path10.join(LOG_DIR, "dead-code.log.1");
|
|
5838
6121
|
var MAX_LOG_BYTES = Math.max(128 * 1024, Number.parseInt(process.env.PI_LENS_DEAD_CODE_LOG_MAX_BYTES ?? "1048576", 10) || 1048576);
|
|
5839
6122
|
var writer = createNdjsonLogger({
|
|
5840
6123
|
filePath: LOG_FILE,
|
|
@@ -5853,8 +6136,8 @@ function isPrintMode(argv = process.argv) {
|
|
|
5853
6136
|
}
|
|
5854
6137
|
|
|
5855
6138
|
// dist/clients/rules-scanner.js
|
|
5856
|
-
import * as
|
|
5857
|
-
import * as
|
|
6139
|
+
import * as fs10 from "node:fs";
|
|
6140
|
+
import * as path11 from "node:path";
|
|
5858
6141
|
var RULE_DIRS = [
|
|
5859
6142
|
{ dir: ".claude/rules", source: ".claude/rules" },
|
|
5860
6143
|
{ dir: ".agents/rules", source: ".agents/rules" }
|
|
@@ -5870,22 +6153,22 @@ function findMarkdownFiles(dir, baseDir, depth = 0, collected = { count: 0 }) {
|
|
|
5870
6153
|
const results = [];
|
|
5871
6154
|
if (depth > RULES_SCAN_MAX_DEPTH)
|
|
5872
6155
|
return results;
|
|
5873
|
-
if (!
|
|
6156
|
+
if (!fs10.existsSync(dir))
|
|
5874
6157
|
return results;
|
|
5875
|
-
const entries =
|
|
6158
|
+
const entries = fs10.readdirSync(dir, { withFileTypes: true });
|
|
5876
6159
|
for (const entry of entries) {
|
|
5877
6160
|
if (collected.count >= RULES_SCAN_MAX_FILES)
|
|
5878
6161
|
break;
|
|
5879
|
-
const fullPath =
|
|
6162
|
+
const fullPath = path11.join(dir, entry.name);
|
|
5880
6163
|
if (entry.isDirectory()) {
|
|
5881
6164
|
results.push(...findMarkdownFiles(fullPath, baseDir, depth + 1, collected));
|
|
5882
6165
|
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
5883
6166
|
collected.count += 1;
|
|
5884
6167
|
results.push({
|
|
5885
|
-
source:
|
|
6168
|
+
source: path11.relative(baseDir, dir) || path11.basename(baseDir),
|
|
5886
6169
|
name: entry.name,
|
|
5887
6170
|
filePath: fullPath,
|
|
5888
|
-
relativePath: toPosix(
|
|
6171
|
+
relativePath: toPosix(path11.relative(baseDir, fullPath))
|
|
5889
6172
|
});
|
|
5890
6173
|
}
|
|
5891
6174
|
}
|
|
@@ -5894,9 +6177,9 @@ function findMarkdownFiles(dir, baseDir, depth = 0, collected = { count: 0 }) {
|
|
|
5894
6177
|
function scanProjectRules(cwd) {
|
|
5895
6178
|
const rules = [];
|
|
5896
6179
|
for (const { dir, source } of RULE_DIRS) {
|
|
5897
|
-
const dirPath =
|
|
5898
|
-
if (
|
|
5899
|
-
const found = findMarkdownFiles(dirPath,
|
|
6180
|
+
const dirPath = path11.join(cwd, dir);
|
|
6181
|
+
if (fs10.existsSync(dirPath)) {
|
|
6182
|
+
const found = findMarkdownFiles(dirPath, path11.join(cwd, dir));
|
|
5900
6183
|
for (const rule of found) {
|
|
5901
6184
|
rules.push({
|
|
5902
6185
|
source,
|
|
@@ -5908,8 +6191,8 @@ function scanProjectRules(cwd) {
|
|
|
5908
6191
|
}
|
|
5909
6192
|
}
|
|
5910
6193
|
for (const { file, source } of RULE_FILES) {
|
|
5911
|
-
const filePath =
|
|
5912
|
-
if (
|
|
6194
|
+
const filePath = path11.join(cwd, file);
|
|
6195
|
+
if (fs10.existsSync(filePath)) {
|
|
5913
6196
|
rules.push({
|
|
5914
6197
|
source,
|
|
5915
6198
|
name: file,
|
|
@@ -5925,8 +6208,8 @@ function scanProjectRules(cwd) {
|
|
|
5925
6208
|
}
|
|
5926
6209
|
|
|
5927
6210
|
// dist/clients/smells-rollup.js
|
|
5928
|
-
import * as
|
|
5929
|
-
import * as
|
|
6211
|
+
import * as fs11 from "node:fs";
|
|
6212
|
+
import * as path12 from "node:path";
|
|
5930
6213
|
var SMELLS_TAIL_BYTES_PER_FILE = 64 * 1024;
|
|
5931
6214
|
var SMELLS_ROLLING_WINDOW_MS = 24 * 60 * 6e4;
|
|
5932
6215
|
var SMELLS_THRESHOLDS = {
|
|
@@ -5941,18 +6224,18 @@ var SMELL_KEYS = ["staleCtxEmitFailed", "opengrepRespawn"];
|
|
|
5941
6224
|
function tailReadText(filePath, maxBytes) {
|
|
5942
6225
|
let fd;
|
|
5943
6226
|
try {
|
|
5944
|
-
fd =
|
|
6227
|
+
fd = fs11.openSync(filePath, "r");
|
|
5945
6228
|
} catch {
|
|
5946
6229
|
return "";
|
|
5947
6230
|
}
|
|
5948
6231
|
try {
|
|
5949
|
-
const size =
|
|
6232
|
+
const size = fs11.fstatSync(fd).size;
|
|
5950
6233
|
const readBytes2 = Math.min(size, maxBytes);
|
|
5951
6234
|
if (readBytes2 <= 0)
|
|
5952
6235
|
return "";
|
|
5953
6236
|
const start = size - readBytes2;
|
|
5954
6237
|
const buf = Buffer.alloc(readBytes2);
|
|
5955
|
-
|
|
6238
|
+
fs11.readSync(fd, buf, 0, readBytes2, start);
|
|
5956
6239
|
const text = buf.toString("utf8");
|
|
5957
6240
|
if (start <= 0)
|
|
5958
6241
|
return text;
|
|
@@ -5962,7 +6245,7 @@ function tailReadText(filePath, maxBytes) {
|
|
|
5962
6245
|
return "";
|
|
5963
6246
|
} finally {
|
|
5964
6247
|
try {
|
|
5965
|
-
|
|
6248
|
+
fs11.closeSync(fd);
|
|
5966
6249
|
} catch {
|
|
5967
6250
|
}
|
|
5968
6251
|
}
|
|
@@ -5999,8 +6282,8 @@ function isOpengrepRespawn(entry) {
|
|
|
5999
6282
|
}
|
|
6000
6283
|
function countRecentSmells(root = getGlobalPiLensLogDir(), sessionStartMs) {
|
|
6001
6284
|
const sinceMs = sessionStartMs ?? Date.now() - SMELLS_ROLLING_WINDOW_MS;
|
|
6002
|
-
const busTail = tailReadText(
|
|
6003
|
-
const latencyTail = tailReadText(
|
|
6285
|
+
const busTail = tailReadText(path12.join(root, "bus-events.log"), SMELLS_TAIL_BYTES_PER_FILE);
|
|
6286
|
+
const latencyTail = tailReadText(path12.join(root, "latency.log"), SMELLS_TAIL_BYTES_PER_FILE);
|
|
6004
6287
|
return {
|
|
6005
6288
|
staleCtxEmitFailed: countMatchingLines(busTail, isStaleCtxEmitFailed, sinceMs),
|
|
6006
6289
|
opengrepRespawn: countMatchingLines(latencyTail, isOpengrepRespawn, sinceMs)
|
|
@@ -6097,10 +6380,10 @@ function emitSituationalDeadWeight() {
|
|
|
6097
6380
|
}
|
|
6098
6381
|
|
|
6099
6382
|
// dist/clients/deferred-test-targets.js
|
|
6100
|
-
import * as
|
|
6383
|
+
import * as path13 from "node:path";
|
|
6101
6384
|
var TEST_RUNNER_MAX_PERSISTED_TARGETS = 64;
|
|
6102
6385
|
function deferralEntryKey(entry) {
|
|
6103
|
-
return `${entry.sessionId ?? ""}\0${normalizeMapKey(
|
|
6386
|
+
return `${entry.sessionId ?? ""}\0${normalizeMapKey(path13.resolve(entry.testFile))}`;
|
|
6104
6387
|
}
|
|
6105
6388
|
function mergeDeferredTargets(existing, incoming) {
|
|
6106
6389
|
const byKey = /* @__PURE__ */ new Map();
|
|
@@ -6190,9 +6473,9 @@ function logHostReadyDelay(deps, cwd) {
|
|
|
6190
6473
|
});
|
|
6191
6474
|
}
|
|
6192
6475
|
function resolveSnapshotRoot(cwd) {
|
|
6193
|
-
const resolvedCwd =
|
|
6476
|
+
const resolvedCwd = path14.resolve(cwd);
|
|
6194
6477
|
const nearest = findNearestProjectRoot(resolvedCwd);
|
|
6195
|
-
if (!nearest || isAtOrAboveHomeDir(realpathOrResolve(nearest), realpathOrResolve(
|
|
6478
|
+
if (!nearest || isAtOrAboveHomeDir(realpathOrResolve(nearest), realpathOrResolve(os3.homedir()))) {
|
|
6196
6479
|
return resolvedCwd;
|
|
6197
6480
|
}
|
|
6198
6481
|
return nearest;
|
|
@@ -6442,7 +6725,7 @@ async function igniteWarmFiles(cwd, warmFiles, runtime, sessionGeneration, dbg)
|
|
|
6442
6725
|
for (const relPath of warmFiles) {
|
|
6443
6726
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
6444
6727
|
return;
|
|
6445
|
-
const filePath =
|
|
6728
|
+
const filePath = path14.isAbsolute(relPath) ? relPath : path14.resolve(cwd, relPath);
|
|
6446
6729
|
if (!nodeFs.existsSync(filePath)) {
|
|
6447
6730
|
dbg(`session_start lsp-warm: not found: ${relPath}`);
|
|
6448
6731
|
errors++;
|
|
@@ -6473,8 +6756,8 @@ async function igniteDominantLanguageWarm(cwd, runtime, sessionGeneration, dbg)
|
|
|
6473
6756
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
6474
6757
|
return;
|
|
6475
6758
|
const lspService = (await loadLspService()).getLSPService();
|
|
6476
|
-
const { collectSourceFilesAsync } = await import("../chunk-
|
|
6477
|
-
const { CODE_KINDS, detectFileKind: detectFileKind2 } = await import("../chunk-
|
|
6759
|
+
const { collectSourceFilesAsync } = await import("../chunk-KQF7VT26.js");
|
|
6760
|
+
const { CODE_KINDS, detectFileKind: detectFileKind2 } = await import("../chunk-QJA33VD5.js");
|
|
6478
6761
|
const files = await collectSourceFilesAsync(cwd, {
|
|
6479
6762
|
inspectGeneratedHeaders: false
|
|
6480
6763
|
});
|
|
@@ -6508,7 +6791,7 @@ async function igniteDominantLanguageWarm(cwd, runtime, sessionGeneration, dbg)
|
|
|
6508
6791
|
clientScope: "primary",
|
|
6509
6792
|
maxClientWaitMs: 2e3
|
|
6510
6793
|
});
|
|
6511
|
-
dbg(`session_start lsp-warm: dominant=${kind} via ${
|
|
6794
|
+
dbg(`session_start lsp-warm: dominant=${kind} via ${path14.basename(sample)}`);
|
|
6512
6795
|
return;
|
|
6513
6796
|
}
|
|
6514
6797
|
dbg("session_start lsp-warm: no dominant-language LSP file found to warm");
|
|
@@ -6518,6 +6801,10 @@ async function igniteDominantLanguageWarm(cwd, runtime, sessionGeneration, dbg)
|
|
|
6518
6801
|
}
|
|
6519
6802
|
function firePreinstallDefaults(ensureTool, dbg, startupDefaults) {
|
|
6520
6803
|
for (const tool of startupDefaults) {
|
|
6804
|
+
if (!shouldAutoInstallTool(tool)) {
|
|
6805
|
+
dbg(`session_start preinstall ${tool}: skipped (installer entry does not opt in)`);
|
|
6806
|
+
continue;
|
|
6807
|
+
}
|
|
6521
6808
|
const startedAt = Date.now();
|
|
6522
6809
|
dbg(`session_start preinstall ${tool}: start`);
|
|
6523
6810
|
ensureTool(tool).then((toolPath) => {
|
|
@@ -6548,7 +6835,7 @@ function scheduleManagedToolRefresh(dbg, rulePack) {
|
|
|
6548
6835
|
managedToolRefreshTimer = void 0;
|
|
6549
6836
|
void (async () => {
|
|
6550
6837
|
try {
|
|
6551
|
-
const refresh = await import("../chunk-
|
|
6838
|
+
const refresh = await import("../chunk-RURPX2YV.js");
|
|
6552
6839
|
const outcome = await refresh.runManagedToolRefresh(void 0, {
|
|
6553
6840
|
rulePack
|
|
6554
6841
|
});
|
|
@@ -6568,7 +6855,7 @@ function scheduleManagedToolRefresh(dbg, rulePack) {
|
|
|
6568
6855
|
managedToolRefreshTimer = timer;
|
|
6569
6856
|
}
|
|
6570
6857
|
async function probePrettierInstall(ensureTool, dbg, analysisRoot) {
|
|
6571
|
-
const pkgPath =
|
|
6858
|
+
const pkgPath = path14.join(analysisRoot, "package.json");
|
|
6572
6859
|
try {
|
|
6573
6860
|
const raw = await nodeFs.promises.readFile(pkgPath, "utf-8");
|
|
6574
6861
|
const pkg = JSON.parse(raw);
|
|
@@ -6598,7 +6885,7 @@ function scanOneTodoFile(scanner, filePath, items) {
|
|
|
6598
6885
|
async function collectTodoBaselineItems(scanner, analysisRoot, stillCurrent) {
|
|
6599
6886
|
const items = [];
|
|
6600
6887
|
try {
|
|
6601
|
-
const { getSourceFilesAsync } = await import("../chunk-
|
|
6888
|
+
const { getSourceFilesAsync } = await import("../chunk-R5XVJ6AN.js");
|
|
6602
6889
|
const files = await getSourceFilesAsync(analysisRoot, true);
|
|
6603
6890
|
if (!stillCurrent())
|
|
6604
6891
|
return items;
|
|
@@ -6627,7 +6914,7 @@ async function buildOrRefreshWordIndex(args) {
|
|
|
6627
6914
|
const snapshot = loadProjectSnapshot(snapshotRoot);
|
|
6628
6915
|
const snapshotLoadMs = Date.now() - snapshotLoadStartMs;
|
|
6629
6916
|
if (snapshot?.wordIndex) {
|
|
6630
|
-
const { deserializeWordIndex, refreshWordIndexIncrementally, countWordIndexPostingEntries: countWordIndexPostingEntries2, estimateWordIndexResidentBytes: estimateWordIndexResidentBytes2, notifyWordIndexPublished: notifyWordIndexPublished2 } = await import("../chunk-
|
|
6917
|
+
const { deserializeWordIndex, refreshWordIndexIncrementally, countWordIndexPostingEntries: countWordIndexPostingEntries2, estimateWordIndexResidentBytes: estimateWordIndexResidentBytes2, notifyWordIndexPublished: notifyWordIndexPublished2 } = await import("../chunk-3JJ4OAJI.js");
|
|
6631
6918
|
const deserializeStartMs = Date.now();
|
|
6632
6919
|
const index = deserializeWordIndex(snapshot.wordIndex);
|
|
6633
6920
|
const deserializeMs = Date.now() - deserializeStartMs;
|
|
@@ -6700,7 +6987,7 @@ async function buildOrRefreshWordIndex(args) {
|
|
|
6700
6987
|
}
|
|
6701
6988
|
}
|
|
6702
6989
|
}
|
|
6703
|
-
const { buildWordIndexAsync, collectWordIndexDocs, countWordIndexPostingEntries, estimateWordIndexResidentBytes, notifyWordIndexPublished } = await import("../chunk-
|
|
6990
|
+
const { buildWordIndexAsync, collectWordIndexDocs, countWordIndexPostingEntries, estimateWordIndexResidentBytes, notifyWordIndexPublished } = await import("../chunk-3JJ4OAJI.js");
|
|
6704
6991
|
const docs = await collectWordIndexDocs(analysisRoot, () => runtime.isCurrentSession(sessionGeneration), rebuildPreflightFiles);
|
|
6705
6992
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
6706
6993
|
return;
|
|
@@ -6785,7 +7072,7 @@ function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analy
|
|
|
6785
7072
|
const delay = STARTUP_TASK_DEFER_MS[name] ?? 0;
|
|
6786
7073
|
dbg(`session_start task ${name}: scheduled deferMs=${delay}`);
|
|
6787
7074
|
runtime.markStartupScanInFlight(name, sessionGeneration);
|
|
6788
|
-
const completion = new Promise((
|
|
7075
|
+
const completion = new Promise((resolve32) => {
|
|
6789
7076
|
const fire = () => {
|
|
6790
7077
|
const startedAt = Date.now();
|
|
6791
7078
|
dbg(`session_start task ${name}: start queuedMs=${startedAt - queuedAt}`);
|
|
@@ -6797,7 +7084,7 @@ function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analy
|
|
|
6797
7084
|
}).finally(() => {
|
|
6798
7085
|
runtime.clearStartupScanInFlight(name, sessionGeneration);
|
|
6799
7086
|
dbg(`session_start task ${name}: end`);
|
|
6800
|
-
|
|
7087
|
+
resolve32();
|
|
6801
7088
|
});
|
|
6802
7089
|
};
|
|
6803
7090
|
if (delay > 0) {
|
|
@@ -6873,7 +7160,7 @@ function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analy
|
|
|
6873
7160
|
if (await jscpdClient.ensureAvailable()) {
|
|
6874
7161
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
6875
7162
|
return;
|
|
6876
|
-
const isTsProject = nodeFs.existsSync(
|
|
7163
|
+
const isTsProject = nodeFs.existsSync(path14.join(analysisRoot, "tsconfig.json"));
|
|
6877
7164
|
const scannerKey = isTsProject ? "jscpd-ts" : "jscpd";
|
|
6878
7165
|
const cached = cacheManager2.readCache(scannerKey, analysisRoot);
|
|
6879
7166
|
if (cached) {
|
|
@@ -7079,9 +7366,9 @@ function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analy
|
|
|
7079
7366
|
});
|
|
7080
7367
|
let callGraphIdentity;
|
|
7081
7368
|
const callGraphTask = runTask("call-graph", async () => {
|
|
7082
|
-
const { FactStore: FactStore2 } = await import("../chunk-
|
|
7083
|
-
const { buildOrUpdateGraph, extractSymbolsAndRefsFromGraph, getReviewGraphCacheIdentity } = await import("../chunk-
|
|
7084
|
-
const { buildCallGraph, saveCallGraph, loadCallGraph: loadCallGraph2 } = await import("../chunk-
|
|
7369
|
+
const { FactStore: FactStore2 } = await import("../chunk-ZEUF7BIN.js");
|
|
7370
|
+
const { buildOrUpdateGraph, extractSymbolsAndRefsFromGraph, getReviewGraphCacheIdentity } = await import("../chunk-MY4XNNTX.js");
|
|
7371
|
+
const { buildCallGraph, saveCallGraph, loadCallGraph: loadCallGraph2 } = await import("../chunk-ZDWNFZJ2.js");
|
|
7085
7372
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
7086
7373
|
return;
|
|
7087
7374
|
const startMs = Date.now();
|
|
@@ -7122,7 +7409,7 @@ function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analy
|
|
|
7122
7409
|
return;
|
|
7123
7410
|
if (!runtime.callGraph)
|
|
7124
7411
|
return;
|
|
7125
|
-
const { buildCodebaseModel, saveCodebaseModel, DEFAULT_CODEBASE_MODEL_TOKEN_BUDGET } = await import("../chunk-
|
|
7412
|
+
const { buildCodebaseModel, saveCodebaseModel, DEFAULT_CODEBASE_MODEL_TOKEN_BUDGET } = await import("../chunk-N4AJVFRF.js");
|
|
7126
7413
|
if (!callGraphIdentity)
|
|
7127
7414
|
return;
|
|
7128
7415
|
const model = buildCodebaseModel(runtime.callGraph, analysisRoot, DEFAULT_CODEBASE_MODEL_TOKEN_BUDGET, callGraphIdentity);
|
|
@@ -7211,7 +7498,6 @@ function resetSessionScopedState(cwd, sessionStartMs = Date.now()) {
|
|
|
7211
7498
|
resetRustAvailability();
|
|
7212
7499
|
resetPsScriptAnalyzerAvailability();
|
|
7213
7500
|
resetInstallRetryLatches();
|
|
7214
|
-
resetLazyInstallAttempts();
|
|
7215
7501
|
resetDirectLspCommandAvailability();
|
|
7216
7502
|
resetLSPCaseSensitivityState();
|
|
7217
7503
|
resetResolvedPathCache();
|
|
@@ -7331,8 +7617,8 @@ async function handleSessionStart(deps) {
|
|
|
7331
7617
|
try {
|
|
7332
7618
|
warmupDbg("warmup: starting background warmup");
|
|
7333
7619
|
const scanContextStartedAt = Date.now();
|
|
7334
|
-
const startupScanModule = await import("../chunk-
|
|
7335
|
-
const languageProfileModule = await import("../chunk-
|
|
7620
|
+
const startupScanModule = await import("../chunk-JBDZVOFL.js");
|
|
7621
|
+
const languageProfileModule = await import("../chunk-MGVVYYKW.js");
|
|
7336
7622
|
const warmupSnapshotRoot = resolveSnapshotRoot(warmupCwd);
|
|
7337
7623
|
const cachedSnapshot = loadProjectSnapshot(warmupSnapshotRoot);
|
|
7338
7624
|
warmupOwnSnapshotRead = cachedSnapshot ? {
|
|
@@ -7344,7 +7630,7 @@ async function handleSessionStart(deps) {
|
|
|
7344
7630
|
const cachedVerdict = cachedSnapshot?.startupScan;
|
|
7345
7631
|
let scan;
|
|
7346
7632
|
if (cachedVerdict && startupScanModule.isStartupScanVerdictFresh(cachedVerdict)) {
|
|
7347
|
-
scan = { ...cachedVerdict, cwd:
|
|
7633
|
+
scan = { ...cachedVerdict, cwd: path14.resolve(warmupCwd) };
|
|
7348
7634
|
warmupDbg(`warmup: scan-context reused from cache (canWarm=${scan.canWarmCaches}${scan.reason ? `, reason=${scan.reason}` : ""})`);
|
|
7349
7635
|
} else {
|
|
7350
7636
|
scan = await startupScanModule.resolveStartupScanContextAsync(warmupCwd);
|
|
@@ -7487,27 +7773,35 @@ async function handleSessionStart(deps) {
|
|
|
7487
7773
|
});
|
|
7488
7774
|
const cleanupCwd = ctxCwd ?? process.cwd();
|
|
7489
7775
|
setImmediate(() => {
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7776
|
+
void (async () => {
|
|
7777
|
+
const logCleanupStartedAt = Date.now();
|
|
7778
|
+
try {
|
|
7779
|
+
const logCleanup = await runLogCleanup(dbg, {
|
|
7780
|
+
cwd: cleanupCwd,
|
|
7781
|
+
// The same id the turn-end arm persists session state under
|
|
7782
|
+
// (index.ts's persistScope call), so the sweep exempts the
|
|
7783
|
+
// file a live session saves into.
|
|
7784
|
+
currentSessionId: deps.runtime.telemetrySessionId
|
|
7785
|
+
});
|
|
7786
|
+
logLatency({
|
|
7787
|
+
type: "phase",
|
|
7788
|
+
phase: "session_start_log_cleanup",
|
|
7789
|
+
filePath: cleanupCwd,
|
|
7790
|
+
startedAt: new Date(logCleanupStartedAt).toISOString(),
|
|
7791
|
+
durationMs: Date.now() - logCleanupStartedAt,
|
|
7792
|
+
metadata: {
|
|
7793
|
+
mode: startupMode,
|
|
7794
|
+
reason: deps.sessionReason,
|
|
7795
|
+
deferred: true
|
|
7796
|
+
}
|
|
7797
|
+
});
|
|
7798
|
+
if (logCleanup.cleaned > 0 || logCleanup.rotated > 0) {
|
|
7799
|
+
notify(`\u{1F9F9} ${logCleanup.report}`, "info");
|
|
7503
7800
|
}
|
|
7504
|
-
})
|
|
7505
|
-
|
|
7506
|
-
notify(`\u{1F9F9} ${logCleanup.report}`, "info");
|
|
7801
|
+
} catch (err) {
|
|
7802
|
+
dbg(`session_start: deferred log cleanup failed: ${err}`);
|
|
7507
7803
|
}
|
|
7508
|
-
}
|
|
7509
|
-
dbg(`session_start: deferred log cleanup failed: ${err}`);
|
|
7510
|
-
}
|
|
7804
|
+
})();
|
|
7511
7805
|
});
|
|
7512
7806
|
dbg(`session_start startup mode: ${startupMode}`);
|
|
7513
7807
|
if (deps.keepSharedLsp) {
|
|
@@ -7521,7 +7815,7 @@ async function handleSessionStart(deps) {
|
|
|
7521
7815
|
const cwd = ctxCwd ?? process.cwd();
|
|
7522
7816
|
const projectDataDir = getProjectDataDir(cwd);
|
|
7523
7817
|
for (const migration of drainProjectDataDirMigrations()) {
|
|
7524
|
-
const targetName =
|
|
7818
|
+
const targetName = path14.basename(migration.to);
|
|
7525
7819
|
const hash = targetName.match(/([0-9a-f]{8})$/)?.[1] ?? "unknown";
|
|
7526
7820
|
if (migration.outcome === "ephemeral") {
|
|
7527
7821
|
recordDegradationOnce({
|
|
@@ -7540,11 +7834,11 @@ async function handleSessionStart(deps) {
|
|
|
7540
7834
|
const globalDir = getGlobalPiLensDir();
|
|
7541
7835
|
void sweepAtomicWriteStages([
|
|
7542
7836
|
projectDataDir,
|
|
7543
|
-
|
|
7544
|
-
|
|
7837
|
+
path14.join(projectDataDir, "cache"),
|
|
7838
|
+
path14.join(projectDataDir, "sessions"),
|
|
7545
7839
|
globalDir,
|
|
7546
|
-
|
|
7547
|
-
|
|
7840
|
+
path14.join(globalDir, "bin"),
|
|
7841
|
+
path14.join(globalDir, "tools")
|
|
7548
7842
|
]).catch(() => {
|
|
7549
7843
|
});
|
|
7550
7844
|
void sweepDeadEphemeralDataDirs({ isPidAlive: realIsPidAlive }).catch(() => {
|
|
@@ -7626,7 +7920,7 @@ async function handleSessionStart(deps) {
|
|
|
7626
7920
|
if (allowBootstrapTasks && !getFlag("no-lsp")) {
|
|
7627
7921
|
const cleaned = cleanStaleTsBuildInfo(ctxCwd ?? process.cwd());
|
|
7628
7922
|
if (cleaned.length > 0) {
|
|
7629
|
-
notify(`\u{1F9F9} Deleted stale TypeScript build cache (${cleaned.map((f) =>
|
|
7923
|
+
notify(`\u{1F9F9} Deleted stale TypeScript build cache (${cleaned.map((f) => path14.basename(f)).join(", ")}) \u2014 phantom errors suppressed.`, "warning");
|
|
7630
7924
|
dbg(`session_start: cleaned stale tsbuildinfo: ${cleaned.join(", ")}`);
|
|
7631
7925
|
}
|
|
7632
7926
|
}
|
|
@@ -7643,7 +7937,7 @@ async function handleSessionStart(deps) {
|
|
|
7643
7937
|
const startupScanSource = cachedStartupScan ? "snapshot" : "computed";
|
|
7644
7938
|
let startupScan;
|
|
7645
7939
|
if (cachedStartupScan) {
|
|
7646
|
-
startupScan = { ...cachedStartupScan, cwd:
|
|
7940
|
+
startupScan = { ...cachedStartupScan, cwd: path14.resolve(cwd) };
|
|
7647
7941
|
} else {
|
|
7648
7942
|
const scanContextStartedAt = Date.now();
|
|
7649
7943
|
startupScan = resolveStartupScanContext(cwd);
|
|
@@ -7850,19 +8144,19 @@ function emitSmellsSessionStartLine(dbg, sessionStartMs) {
|
|
|
7850
8144
|
}
|
|
7851
8145
|
|
|
7852
8146
|
// dist/clients/runtime-turn.js
|
|
7853
|
-
import * as
|
|
7854
|
-
import * as
|
|
8147
|
+
import * as fs17 from "node:fs";
|
|
8148
|
+
import * as path25 from "node:path";
|
|
7855
8149
|
|
|
7856
8150
|
// dist/clients/actionable-warnings.js
|
|
7857
8151
|
import { createHash } from "node:crypto";
|
|
7858
|
-
import * as
|
|
7859
|
-
import * as
|
|
8152
|
+
import * as fs12 from "node:fs";
|
|
8153
|
+
import * as path16 from "node:path";
|
|
7860
8154
|
|
|
7861
8155
|
// dist/clients/actionable-warnings-logger.js
|
|
7862
|
-
import * as
|
|
8156
|
+
import * as path15 from "node:path";
|
|
7863
8157
|
var AW_LOG_DIR = getGlobalPiLensLogDir();
|
|
7864
|
-
var AW_LOG_FILE =
|
|
7865
|
-
var AW_LOG_BACKUP_FILE =
|
|
8158
|
+
var AW_LOG_FILE = path15.join(AW_LOG_DIR, "actionable-warnings.log");
|
|
8159
|
+
var AW_LOG_BACKUP_FILE = path15.join(AW_LOG_DIR, "actionable-warnings.log.1");
|
|
7866
8160
|
var MAX_LOG_BYTES2 = Math.max(128 * 1024, Number.parseInt(process.env.PI_LENS_AW_LOG_MAX_BYTES ?? "1048576", 10) || 1048576);
|
|
7867
8161
|
var writer2 = createNdjsonLogger({
|
|
7868
8162
|
filePath: AW_LOG_FILE,
|
|
@@ -7897,7 +8191,7 @@ function createActionableWarningId(args) {
|
|
|
7897
8191
|
});
|
|
7898
8192
|
}
|
|
7899
8193
|
function legacyActionableWarningId(args) {
|
|
7900
|
-
const rel = toPosix(
|
|
8194
|
+
const rel = toPosix(path16.relative(args.cwd, args.filePath));
|
|
7901
8195
|
const legacyRelativeFile = rel && !rel.startsWith("..") ? rel : normalizeMapKey(args.filePath);
|
|
7902
8196
|
const parts = [
|
|
7903
8197
|
legacyRelativeFile,
|
|
@@ -7943,16 +8237,16 @@ function deserializeSuppressionState(contents) {
|
|
|
7943
8237
|
}
|
|
7944
8238
|
}
|
|
7945
8239
|
function readSuppressionState(cwd) {
|
|
7946
|
-
const statePath =
|
|
8240
|
+
const statePath = path16.join(getProjectDataDir(cwd), "cache", "actionable-warning-state.json");
|
|
7947
8241
|
try {
|
|
7948
|
-
return deserializeSuppressionState(
|
|
8242
|
+
return deserializeSuppressionState(fs12.readFileSync(statePath, "utf8"));
|
|
7949
8243
|
} catch {
|
|
7950
8244
|
return {};
|
|
7951
8245
|
}
|
|
7952
8246
|
}
|
|
7953
8247
|
function updateWarningState(cwd, warnings) {
|
|
7954
|
-
const statePath =
|
|
7955
|
-
|
|
8248
|
+
const statePath = path16.join(getProjectDataDir(cwd), "cache", "actionable-warning-state.json");
|
|
8249
|
+
fs12.mkdirSync(path16.dirname(statePath), { recursive: true });
|
|
7956
8250
|
const hook = beforeWarningStateLockForTests;
|
|
7957
8251
|
beforeWarningStateLockForTests = null;
|
|
7958
8252
|
hook?.();
|
|
@@ -8097,7 +8391,7 @@ function boundedNumber(value, fallback) {
|
|
|
8097
8391
|
return value !== void 0 && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
8098
8392
|
}
|
|
8099
8393
|
async function buildActionableWarningsReport(args) {
|
|
8100
|
-
const cwd =
|
|
8394
|
+
const cwd = path16.resolve(args.cwd);
|
|
8101
8395
|
const records2 = [...args.dispatchWarnings];
|
|
8102
8396
|
const lspService = getLSPService();
|
|
8103
8397
|
const excludeServerIds = args.getFlag ? configDisabledAuxiliaryLspServerIds(args.getFlag) : void 0;
|
|
@@ -8120,7 +8414,7 @@ async function buildActionableWarningsReport(args) {
|
|
|
8120
8414
|
const eligible = [];
|
|
8121
8415
|
let outsideRoot = 0;
|
|
8122
8416
|
for (const file of args.files) {
|
|
8123
|
-
const filePath =
|
|
8417
|
+
const filePath = path16.resolve(cwd, file);
|
|
8124
8418
|
if (normalizeMapKey(filePath) === normalizeMapKey(cwd) || !isUnderDir(filePath, cwd)) {
|
|
8125
8419
|
outsideRoot++;
|
|
8126
8420
|
logActionableWarningsEvent({
|
|
@@ -8156,7 +8450,7 @@ async function buildActionableWarningsReport(args) {
|
|
|
8156
8450
|
const primed = [];
|
|
8157
8451
|
const cold = [];
|
|
8158
8452
|
for (const filePath of capped) {
|
|
8159
|
-
const content =
|
|
8453
|
+
const content = fs12.existsSync(filePath) ? fs12.readFileSync(filePath, "utf-8") : void 0;
|
|
8160
8454
|
const contentHash = content !== void 0 ? createHash("sha256").update(content).digest("hex") : void 0;
|
|
8161
8455
|
const cached = contentHash !== void 0 ? lspService.getLastKnownDiagnostics(filePath, contentHash) : void 0;
|
|
8162
8456
|
(cached !== void 0 ? primed : cold).push({
|
|
@@ -8232,7 +8526,7 @@ async function buildActionableWarningsReport(args) {
|
|
|
8232
8526
|
}
|
|
8233
8527
|
};
|
|
8234
8528
|
const deferredWork = (async () => {
|
|
8235
|
-
await new Promise((
|
|
8529
|
+
await new Promise((resolve32) => setTimeout(resolve32, 0));
|
|
8236
8530
|
const deferredRecords = [...carried];
|
|
8237
8531
|
const deferredDeadline = Date.now() + ACTIONABLE_WARNINGS_DEFERRED_BUDGET_MS;
|
|
8238
8532
|
deferredDeps.deadlineAt = deferredDeadline;
|
|
@@ -8615,7 +8909,7 @@ function publishActionableWarningsReport(cacheManager2, cwd, report, opts = {})
|
|
|
8615
8909
|
const reason = `${merged.droppedFiles.length} carried-forward entries: findings are LOST on this channel; ${cause} (files: ${merged.droppedFiles.slice(0, 3).join(", ")}${merged.droppedFiles.length > 3 ? ", ..." : ""})`;
|
|
8616
8910
|
incrementDegradationCount({
|
|
8617
8911
|
kind: "actionable-warnings-inband-superseded",
|
|
8618
|
-
subject: `${
|
|
8912
|
+
subject: `${path16.resolve(cwd)}:inband-carry-superseded`,
|
|
8619
8913
|
reason
|
|
8620
8914
|
});
|
|
8621
8915
|
opts.dbg?.(`actionable_warnings: in-band publish dropped ${merged.droppedFiles.length} superseded carried-forward file entry/entries (${merged.droppedFiles.slice(0, 3).join(", ")}${merged.droppedFiles.length > 3 ? ", ..." : ""})`);
|
|
@@ -8667,7 +8961,7 @@ function writeDeferredActionableWarningsReport(args) {
|
|
|
8667
8961
|
if (droppedFiles.length > 0) {
|
|
8668
8962
|
incrementDegradationCount({
|
|
8669
8963
|
kind: "actionable-warnings-deferred-superseded",
|
|
8670
|
-
subject: `${
|
|
8964
|
+
subject: `${path16.resolve(args.cwd)}:deferred-file-superseded`,
|
|
8671
8965
|
reason: `${droppedFiles.length} changed file(s): warnings are LOST; unchanged files were merged into the persisted report (files: ${droppedFiles.slice(0, 3).join(", ")}${droppedFiles.length > 3 ? ", ..." : ""})`
|
|
8672
8966
|
});
|
|
8673
8967
|
args.dbg?.(`turn_end: deferred actionable-warnings dropped ${droppedFiles.length} superseded file entry/entries`);
|
|
@@ -8676,7 +8970,7 @@ function writeDeferredActionableWarningsReport(args) {
|
|
|
8676
8970
|
return { mergedFiles, droppedFiles: droppedFiles.length };
|
|
8677
8971
|
}
|
|
8678
8972
|
function getActionableWarningsHistoryPath(cwd) {
|
|
8679
|
-
return
|
|
8973
|
+
return path16.join(getProjectDataDir(cwd), "actionable-warnings.jsonl");
|
|
8680
8974
|
}
|
|
8681
8975
|
function appendActionableWarningsHistory(cwd, report) {
|
|
8682
8976
|
const entries = [];
|
|
@@ -8715,8 +9009,8 @@ function appendActionableWarningsHistory(cwd, report) {
|
|
|
8715
9009
|
return;
|
|
8716
9010
|
const historyPath = getActionableWarningsHistoryPath(cwd);
|
|
8717
9011
|
try {
|
|
8718
|
-
|
|
8719
|
-
|
|
9012
|
+
fs12.mkdirSync(path16.dirname(historyPath), { recursive: true });
|
|
9013
|
+
fs12.appendFileSync(historyPath, `${entries.map((entry) => JSON.stringify(entry)).join("\n")}
|
|
8720
9014
|
`, "utf8");
|
|
8721
9015
|
} catch {
|
|
8722
9016
|
}
|
|
@@ -8753,8 +9047,8 @@ ${fileList}${more}` : void 0,
|
|
|
8753
9047
|
}
|
|
8754
9048
|
|
|
8755
9049
|
// dist/clients/code-quality-warnings.js
|
|
8756
|
-
import * as
|
|
8757
|
-
import * as
|
|
9050
|
+
import * as fs13 from "node:fs";
|
|
9051
|
+
import * as path17 from "node:path";
|
|
8758
9052
|
var TIER_BUDGET_ORDER = [
|
|
8759
9053
|
"warning",
|
|
8760
9054
|
"info",
|
|
@@ -8768,7 +9062,7 @@ function lineInModifiedRanges2(line, ranges) {
|
|
|
8768
9062
|
return ranges.some((range) => line >= range.start - 2 && line <= range.end + 2);
|
|
8769
9063
|
}
|
|
8770
9064
|
function buildCodeQualityWarningsReport(args) {
|
|
8771
|
-
const cwd =
|
|
9065
|
+
const cwd = path17.resolve(args.cwd);
|
|
8772
9066
|
const maxWarnings = Math.max(1, args.maxWarnings ?? 50);
|
|
8773
9067
|
const byId = /* @__PURE__ */ new Map();
|
|
8774
9068
|
for (const warning of args.warnings) {
|
|
@@ -8832,7 +9126,7 @@ function writeCodeQualityWarningsReport(cacheManager2, cwd, report) {
|
|
|
8832
9126
|
cacheManager2.writeCache("code-quality-warnings", report, cwd);
|
|
8833
9127
|
}
|
|
8834
9128
|
function getCodeQualityWarningsHistoryPath(cwd) {
|
|
8835
|
-
return
|
|
9129
|
+
return path17.join(getProjectDataDir(cwd), "code-quality-warnings.jsonl");
|
|
8836
9130
|
}
|
|
8837
9131
|
function appendCodeQualityWarningsHistory(cwd, report) {
|
|
8838
9132
|
const warnings = report.files.flatMap((file) => file.warnings.map((warning) => ({
|
|
@@ -8857,8 +9151,8 @@ function appendCodeQualityWarningsHistory(cwd, report) {
|
|
|
8857
9151
|
return;
|
|
8858
9152
|
const historyPath = getCodeQualityWarningsHistoryPath(cwd);
|
|
8859
9153
|
try {
|
|
8860
|
-
|
|
8861
|
-
|
|
9154
|
+
fs13.mkdirSync(path17.dirname(historyPath), { recursive: true });
|
|
9155
|
+
fs13.appendFileSync(historyPath, `${warnings.map((entry) => JSON.stringify(entry)).join("\n")}
|
|
8862
9156
|
`, "utf8");
|
|
8863
9157
|
} catch {
|
|
8864
9158
|
}
|
|
@@ -8890,11 +9184,10 @@ function formatCodeQualityWarningsAdvisory(report, cwd, host = "pi") {
|
|
|
8890
9184
|
|
|
8891
9185
|
// dist/clients/git-guard.js
|
|
8892
9186
|
import * as nodeFs2 from "node:fs";
|
|
8893
|
-
import * as
|
|
9187
|
+
import * as path18 from "node:path";
|
|
8894
9188
|
|
|
8895
9189
|
// dist/clients/deferred-runner-blockers.js
|
|
8896
|
-
import * as
|
|
8897
|
-
import { resolve as resolve10 } from "node:path";
|
|
9190
|
+
import * as fs14 from "node:fs";
|
|
8898
9191
|
function judgeDeferredRunnerFindings(pending2, cwd, options = {}) {
|
|
8899
9192
|
const findings = (pending2.result?.diagnostics ?? []).flatMap((d) => d.runnerFault === true ? [] : [d]);
|
|
8900
9193
|
if (findings.length === 0) {
|
|
@@ -8935,7 +9228,7 @@ function judgeDeferredRunnerFindings(pending2, cwd, options = {}) {
|
|
|
8935
9228
|
};
|
|
8936
9229
|
}
|
|
8937
9230
|
function recordDeferredRunnerBlockers(runtime, pending2, survivors, bytes) {
|
|
8938
|
-
const blocking = stampLineHashes(withoutLaneCopies(runtime, pending2, survivors).flatMap((d) => d.semantic === "blocking" ? [{ ...d, runnerId: d.runnerId ?? pending2.runnerId }] : []), bytes?.toString("utf-8"), (d) => !d.filePath ||
|
|
9231
|
+
const blocking = stampLineHashes(withoutLaneCopies(runtime, pending2, survivors).flatMap((d) => d.semantic === "blocking" ? [{ ...d, runnerId: d.runnerId ?? pending2.runnerId }] : []), bytes?.toString("utf-8"), (d) => !d.filePath || pathsEqual(d.filePath, pending2.filePath));
|
|
8939
9232
|
if (blocking.length === 0)
|
|
8940
9233
|
return 0;
|
|
8941
9234
|
const recorded = runtime.recordDeferredInlineBlockers(
|
|
@@ -8989,7 +9282,7 @@ function withoutLaneCopies(runtime, pending2, findings) {
|
|
|
8989
9282
|
}
|
|
8990
9283
|
function readBytes(filePath) {
|
|
8991
9284
|
try {
|
|
8992
|
-
return
|
|
9285
|
+
return fs14.readFileSync(filePath);
|
|
8993
9286
|
} catch {
|
|
8994
9287
|
return void 0;
|
|
8995
9288
|
}
|
|
@@ -8997,7 +9290,7 @@ function readBytes(filePath) {
|
|
|
8997
9290
|
|
|
8998
9291
|
// dist/clients/git-guard.js
|
|
8999
9292
|
function resolveGuardPath(filePath, cwd) {
|
|
9000
|
-
return
|
|
9293
|
+
return path18.resolve(cwd, filePath);
|
|
9001
9294
|
}
|
|
9002
9295
|
function guardPathKey(filePath, cwd) {
|
|
9003
9296
|
return advisoryPathKey(filePath, cwd);
|
|
@@ -9653,10 +9946,10 @@ function dedupeSecretFindings(findings, cwd) {
|
|
|
9653
9946
|
}
|
|
9654
9947
|
|
|
9655
9948
|
// dist/clients/project-diagnostics/runner-adapters/govulncheck.js
|
|
9656
|
-
import * as
|
|
9949
|
+
import * as path19 from "node:path";
|
|
9657
9950
|
function govulncheckFindingToProjectDiagnostic(cwd, finding) {
|
|
9658
9951
|
const frame = finding.trace?.find((f) => f.filename);
|
|
9659
|
-
const filePath = frame?.filename ?
|
|
9952
|
+
const filePath = frame?.filename ? path19.isAbsolute(frame.filename) ? frame.filename : path19.resolve(cwd, frame.filename) : cwd;
|
|
9660
9953
|
const fix = finding.fixedVersion ? ` (fixed in ${finding.fixedVersion})` : "";
|
|
9661
9954
|
return {
|
|
9662
9955
|
filePath,
|
|
@@ -9740,12 +10033,12 @@ var govulncheckLane = {
|
|
|
9740
10033
|
};
|
|
9741
10034
|
|
|
9742
10035
|
// dist/clients/project-diagnostics/runner-adapters/gitleaks.js
|
|
9743
|
-
import * as
|
|
10036
|
+
import * as path20 from "node:path";
|
|
9744
10037
|
function gitleaksFindingToProjectDiagnostic(cwd, finding) {
|
|
9745
10038
|
const statusSuffix = finding.pathStatus ? ` [git: ${finding.pathStatus}]` : "";
|
|
9746
10039
|
const isBlocking2 = finding.pathStatus !== "scratch" && finding.pathStatus !== "ignored" && finding.pathStatus !== "nested-repository";
|
|
9747
10040
|
return {
|
|
9748
|
-
filePath:
|
|
10041
|
+
filePath: path20.isAbsolute(finding.file) ? finding.file : path20.resolve(cwd, finding.file),
|
|
9749
10042
|
line: finding.startLine,
|
|
9750
10043
|
severity: isBlocking2 ? "error" : "info",
|
|
9751
10044
|
semantic: isBlocking2 ? "blocking" : "none",
|
|
@@ -9763,9 +10056,9 @@ function gitleaksResultToProjectDiagnostics(cwd, result) {
|
|
|
9763
10056
|
}
|
|
9764
10057
|
|
|
9765
10058
|
// dist/clients/project-diagnostics/runner-adapters/trivy.js
|
|
9766
|
-
import * as
|
|
10059
|
+
import * as path21 from "node:path";
|
|
9767
10060
|
function trivyFindingToProjectDiagnostic(cwd, finding) {
|
|
9768
|
-
const filePath = finding.target ?
|
|
10061
|
+
const filePath = finding.target ? path21.isAbsolute(finding.target) ? finding.target : path21.resolve(cwd, finding.target) : cwd;
|
|
9769
10062
|
const version = finding.installedVersion ? `@${finding.installedVersion}` : "";
|
|
9770
10063
|
const fix = finding.fixedVersion ? ` (fixed in ${finding.fixedVersion})` : "";
|
|
9771
10064
|
return {
|
|
@@ -9782,7 +10075,7 @@ function trivyFindingToProjectDiagnostic(cwd, finding) {
|
|
|
9782
10075
|
}
|
|
9783
10076
|
function trivySecretFindingToProjectDiagnostic(cwd, finding) {
|
|
9784
10077
|
return {
|
|
9785
|
-
filePath:
|
|
10078
|
+
filePath: path21.isAbsolute(finding.file) ? finding.file : path21.resolve(cwd, finding.file),
|
|
9786
10079
|
line: finding.line,
|
|
9787
10080
|
severity: "error",
|
|
9788
10081
|
semantic: "blocking",
|
|
@@ -10002,7 +10295,7 @@ function stillReportedParked(parked, current, keyOf, offeredKeys) {
|
|
|
10002
10295
|
}
|
|
10003
10296
|
|
|
10004
10297
|
// dist/clients/knip-scan-roots.js
|
|
10005
|
-
import { resolve as
|
|
10298
|
+
import { resolve as resolve14 } from "node:path";
|
|
10006
10299
|
var MAX_KNIP_ROOTS_PER_TURN = 3;
|
|
10007
10300
|
function resolveKnipScanRoots(sessionCwd, modifiedFiles) {
|
|
10008
10301
|
const session = resolveGitCheckout(sessionCwd);
|
|
@@ -10012,7 +10305,7 @@ function resolveKnipScanRoots(sessionCwd, modifiedFiles) {
|
|
|
10012
10305
|
let sessionOwnsEdit = false;
|
|
10013
10306
|
const linked = [];
|
|
10014
10307
|
for (const file of modifiedFiles) {
|
|
10015
|
-
const owner = resolveLinkedWorktreeOwner(session,
|
|
10308
|
+
const owner = resolveLinkedWorktreeOwner(session, resolve14(sessionCwd, file));
|
|
10016
10309
|
if (owner === null) {
|
|
10017
10310
|
sessionOwnsEdit = true;
|
|
10018
10311
|
} else if (!linked.some((known) => pathsEqual(known.root, owner.root))) {
|
|
@@ -10028,7 +10321,7 @@ function resolveKnipScanRoots(sessionCwd, modifiedFiles) {
|
|
|
10028
10321
|
}
|
|
10029
10322
|
|
|
10030
10323
|
// dist/clients/project-diagnostics/runner-adapters/dead-code.js
|
|
10031
|
-
import * as
|
|
10324
|
+
import * as path22 from "node:path";
|
|
10032
10325
|
function deadCodeRunnerId(language) {
|
|
10033
10326
|
return `dead-code-${language}`;
|
|
10034
10327
|
}
|
|
@@ -10044,7 +10337,7 @@ function deadCodeMessage(issue) {
|
|
|
10044
10337
|
function deadCodeIssueToProjectDiagnostic(cwd, issue, language) {
|
|
10045
10338
|
const blocking = issue.category === "unlisted";
|
|
10046
10339
|
return {
|
|
10047
|
-
filePath: issue.file ?
|
|
10340
|
+
filePath: issue.file ? path22.isAbsolute(issue.file) ? issue.file : path22.resolve(cwd, issue.file) : cwd,
|
|
10048
10341
|
line: issue.line,
|
|
10049
10342
|
severity: blocking ? "error" : "warning",
|
|
10050
10343
|
semantic: blocking ? "blocking" : "warning",
|
|
@@ -10068,11 +10361,11 @@ function deadCodeResultToProjectDiagnostics(cwd, result) {
|
|
|
10068
10361
|
}
|
|
10069
10362
|
|
|
10070
10363
|
// dist/clients/project-diagnostics/runner-adapters/knip.js
|
|
10071
|
-
import * as
|
|
10364
|
+
import * as path23 from "node:path";
|
|
10072
10365
|
function knipIssueFile(cwd, issue) {
|
|
10073
10366
|
if (!issue.file)
|
|
10074
10367
|
return cwd;
|
|
10075
|
-
return
|
|
10368
|
+
return path23.isAbsolute(issue.file) ? issue.file : path23.resolve(cwd, issue.file);
|
|
10076
10369
|
}
|
|
10077
10370
|
function knipIssueMessage(issue) {
|
|
10078
10371
|
if (issue.type === "unlisted") {
|
|
@@ -10160,14 +10453,14 @@ function emitLensTurnFindings(payload) {
|
|
|
10160
10453
|
}
|
|
10161
10454
|
|
|
10162
10455
|
// dist/clients/test-target-roots.js
|
|
10163
|
-
import { dirname as
|
|
10456
|
+
import { dirname as dirname8 } from "node:path";
|
|
10164
10457
|
function createTurnEndTestRoots(sessionCwd) {
|
|
10165
10458
|
const session = resolveGitCheckout(sessionCwd);
|
|
10166
10459
|
const ownerByDir = /* @__PURE__ */ new Map();
|
|
10167
10460
|
return (absoluteFile) => {
|
|
10168
10461
|
if (session === null)
|
|
10169
10462
|
return sessionCwd;
|
|
10170
|
-
const dir =
|
|
10463
|
+
const dir = dirname8(absoluteFile);
|
|
10171
10464
|
let owner = ownerByDir.get(dir);
|
|
10172
10465
|
if (owner === void 0) {
|
|
10173
10466
|
owner = resolveLinkedWorktreeOwner(session, absoluteFile);
|
|
@@ -10231,7 +10524,7 @@ function sweepInlineBlockerPastEof(runtime, cwd, options) {
|
|
|
10231
10524
|
}
|
|
10232
10525
|
|
|
10233
10526
|
// dist/clients/persistent-reverify.js
|
|
10234
|
-
import * as
|
|
10527
|
+
import * as fs15 from "node:fs";
|
|
10235
10528
|
var MAX_REVERIFY_FILES = 4;
|
|
10236
10529
|
var REVERIFY_BUDGET_MS = 3e3;
|
|
10237
10530
|
var TOUCH_SOURCE = "persistent_reverify";
|
|
@@ -10249,7 +10542,7 @@ function selectPersistentReverifyFiles(report, nowMs = Date.now()) {
|
|
|
10249
10542
|
continue;
|
|
10250
10543
|
let mtimeMs;
|
|
10251
10544
|
try {
|
|
10252
|
-
mtimeMs =
|
|
10545
|
+
mtimeMs = fs15.statSync(entry.filePath).mtimeMs;
|
|
10253
10546
|
} catch {
|
|
10254
10547
|
continue;
|
|
10255
10548
|
}
|
|
@@ -10291,7 +10584,7 @@ async function runPersistentReverify(args) {
|
|
|
10291
10584
|
processed += 1;
|
|
10292
10585
|
let content;
|
|
10293
10586
|
try {
|
|
10294
|
-
content =
|
|
10587
|
+
content = fs15.readFileSync(entry.filePath, "utf-8");
|
|
10295
10588
|
} catch {
|
|
10296
10589
|
outcomes.push({
|
|
10297
10590
|
filePath: entry.filePath,
|
|
@@ -10408,11 +10701,11 @@ async function runPersistentReverify(args) {
|
|
|
10408
10701
|
}
|
|
10409
10702
|
|
|
10410
10703
|
// dist/clients/inline-blocker-dispositions.js
|
|
10411
|
-
import * as
|
|
10412
|
-
import * as
|
|
10704
|
+
import * as fs16 from "node:fs";
|
|
10705
|
+
import * as path24 from "node:path";
|
|
10413
10706
|
function readCurrentContent(filePath) {
|
|
10414
10707
|
try {
|
|
10415
|
-
return
|
|
10708
|
+
return fs16.readFileSync(filePath, "utf-8");
|
|
10416
10709
|
} catch {
|
|
10417
10710
|
return "";
|
|
10418
10711
|
}
|
|
@@ -10435,7 +10728,7 @@ function applyInlineBlockerPolicy(record, cwd) {
|
|
|
10435
10728
|
unstructured: true
|
|
10436
10729
|
};
|
|
10437
10730
|
}
|
|
10438
|
-
const inProject = (file) =>
|
|
10731
|
+
const inProject = (file) => path24.resolve(cwd, file);
|
|
10439
10732
|
const resolved = diagnostics.map((diagnostic) => ({
|
|
10440
10733
|
...diagnostic,
|
|
10441
10734
|
filePath: inProject(diagnostic.filePath)
|
|
@@ -10455,7 +10748,10 @@ function applyInlineBlockerPolicy(record, cwd) {
|
|
|
10455
10748
|
});
|
|
10456
10749
|
const dropped = diagnostics.length - kept.length;
|
|
10457
10750
|
return {
|
|
10458
|
-
body: kept.length === 0 ? void 0 : formatDiagnostics(kept, "blocking"
|
|
10751
|
+
body: kept.length === 0 ? void 0 : formatDiagnostics(kept, "blocking", void 0, {
|
|
10752
|
+
editedFile: filePath,
|
|
10753
|
+
root: cwd
|
|
10754
|
+
}).trim(),
|
|
10459
10755
|
candidates: diagnostics.length,
|
|
10460
10756
|
kept: kept.length,
|
|
10461
10757
|
suppressed: dropped,
|
|
@@ -10611,7 +10907,7 @@ async function runTestTargetsBounded(args) {
|
|
|
10611
10907
|
});
|
|
10612
10908
|
void pool.catch(() => {
|
|
10613
10909
|
});
|
|
10614
|
-
await new Promise((
|
|
10910
|
+
await new Promise((resolve32) => {
|
|
10615
10911
|
let settled = false;
|
|
10616
10912
|
const finish = (reason) => {
|
|
10617
10913
|
if (settled)
|
|
@@ -10623,7 +10919,7 @@ async function runTestTargetsBounded(args) {
|
|
|
10623
10919
|
batchAbort.abort();
|
|
10624
10920
|
clearTimeout(timer);
|
|
10625
10921
|
args.signal?.removeEventListener("abort", onAbort);
|
|
10626
|
-
|
|
10922
|
+
resolve32();
|
|
10627
10923
|
};
|
|
10628
10924
|
const onAbort = () => finish("abort");
|
|
10629
10925
|
const timer = setTimeout(() => finish("budget"), budgetMs);
|
|
@@ -10797,16 +11093,6 @@ function getShortenedLspIdleResetMs() {
|
|
|
10797
11093
|
function getEffectiveLspIdleResetMs() {
|
|
10798
11094
|
return isSubagentSession() || shouldShortenLspIdleTimeout() ? getShortenedLspIdleResetMs() : getBaseLspIdleResetMs();
|
|
10799
11095
|
}
|
|
10800
|
-
function cancelLSPIdleReset() {
|
|
10801
|
-
if (lspIdleResetTimeout) {
|
|
10802
|
-
clearTimeout(lspIdleResetTimeout);
|
|
10803
|
-
lspIdleResetTimeout = null;
|
|
10804
|
-
}
|
|
10805
|
-
if (pendingSweepRearm) {
|
|
10806
|
-
pendingSweepRearm.cancelled = true;
|
|
10807
|
-
pendingSweepRearm = null;
|
|
10808
|
-
}
|
|
10809
|
-
}
|
|
10810
11096
|
function capTurnEndMessage(content, held = 0) {
|
|
10811
11097
|
const maxLines = RUNTIME_CONFIG.turnEnd.maxLines;
|
|
10812
11098
|
const maxChars = RUNTIME_CONFIG.turnEnd.maxChars;
|
|
@@ -10967,6 +11253,24 @@ async function handleTurnEnd(deps) {
|
|
|
10967
11253
|
}
|
|
10968
11254
|
const ownFiles = Object.keys(turnState.files);
|
|
10969
11255
|
const files = ownFiles;
|
|
11256
|
+
const armLspIdleReset = () => {
|
|
11257
|
+
const idleResetMs = getEffectiveLspIdleResetMs();
|
|
11258
|
+
dbg(`turn_end: ${files.length} modified file(s), scheduling LSP idle reset (${idleResetMs / 1e3}s)`);
|
|
11259
|
+
if (getFlag("no-lsp"))
|
|
11260
|
+
return;
|
|
11261
|
+
const sessionGeneration = runtime.sessionGeneration;
|
|
11262
|
+
scheduleLSPIdleReset(resetLSPService2, idleResetMs, {
|
|
11263
|
+
isCurrentSession: () => runtime.isCurrentSession(sessionGeneration),
|
|
11264
|
+
// #2157 fix round 2: a secondary (subagent) evaluation's own timer
|
|
11265
|
+
// must not release the primary's shared fleet — see the option's
|
|
11266
|
+
// doc comment on `scheduleLSPIdleReset`.
|
|
11267
|
+
isPrimarySession: () => {
|
|
11268
|
+
const activePrimarySessionId = getActiveSessionId();
|
|
11269
|
+
return activePrimarySessionId === void 0 || activePrimarySessionId === runtime.telemetrySessionId;
|
|
11270
|
+
},
|
|
11271
|
+
onError: (err) => dbg(`lsp idle reset failed: ${err}`)
|
|
11272
|
+
});
|
|
11273
|
+
};
|
|
10970
11274
|
let widgetDemotedFindingsRetired = 0;
|
|
10971
11275
|
for (const wPath of drainRenderedDependencyDriftFilePaths()) {
|
|
10972
11276
|
const deliveryCount = incrementWidgetDependencyDriftDelivery(wPath);
|
|
@@ -10992,30 +11296,13 @@ async function handleTurnEnd(deps) {
|
|
|
10992
11296
|
if (getFlag("lens-guard") && !runtime.gitGuardHasBlockers) {
|
|
10993
11297
|
retireSettledGitGuardRecord(runtime, cacheManager2, cwd, sessionId);
|
|
10994
11298
|
}
|
|
10995
|
-
|
|
10996
|
-
dbg(`turn_end: no modified files, scheduling LSP idle reset (${idleResetMs / 1e3}s)`);
|
|
10997
|
-
if (!getFlag("no-lsp")) {
|
|
10998
|
-
const sessionGeneration = runtime.sessionGeneration;
|
|
10999
|
-
scheduleLSPIdleReset(resetLSPService2, idleResetMs, {
|
|
11000
|
-
isCurrentSession: () => runtime.isCurrentSession(sessionGeneration),
|
|
11001
|
-
// #2157 fix round 2: a secondary (subagent) evaluation's own timer
|
|
11002
|
-
// must not release the primary's shared fleet — see the option's
|
|
11003
|
-
// doc comment on `scheduleLSPIdleReset`.
|
|
11004
|
-
isPrimarySession: () => {
|
|
11005
|
-
const activePrimarySessionId = getActiveSessionId();
|
|
11006
|
-
return activePrimarySessionId === void 0 || activePrimarySessionId === runtime.telemetrySessionId;
|
|
11007
|
-
},
|
|
11008
|
-
onError: (err) => dbg(`lsp idle reset failed: ${err}`)
|
|
11009
|
-
});
|
|
11010
|
-
}
|
|
11299
|
+
armLspIdleReset();
|
|
11011
11300
|
resetFormatService2();
|
|
11012
11301
|
if (pendingRunnerFindingsSize() === 0 && !runtime.hasResolvedBlockerFiles() && (runtime.getInlineBlockersSnapshot({ sessionId }).length === 0 || readLastDelivery(cacheManager2, cwd)?.sessionId !== (sessionId ?? runtime.telemetrySessionId)))
|
|
11013
11302
|
return;
|
|
11014
11303
|
}
|
|
11015
|
-
if (files.length > 0 &&
|
|
11016
|
-
|
|
11017
|
-
dbg("turn_end: cancelled pending LSP idle reset (active editing)");
|
|
11018
|
-
}
|
|
11304
|
+
if (files.length > 0 && !isSecondarySession)
|
|
11305
|
+
armLspIdleReset();
|
|
11019
11306
|
dbg(`turn_end: ${files.length} file(s) modified, cycles: ${turnState.turnCycles}/${turnState.maxCycles}, access: ${access}, owner: ${gateOwnerLabel}`);
|
|
11020
11307
|
if (cacheManager2.isMaxCyclesExceeded(cwd, turnStateSessionId)) {
|
|
11021
11308
|
dbg("turn_end: max cycles exceeded, clearing state and forcing through");
|
|
@@ -11378,11 +11665,11 @@ ${policy.body}`;
|
|
|
11378
11665
|
const changedSince = runtime.getFilesChangedSince(originSeq);
|
|
11379
11666
|
if (changedSince.length > 0) {
|
|
11380
11667
|
const changedSet = new Set(changedSince);
|
|
11381
|
-
const primaryKey = normalizeMapKey(
|
|
11668
|
+
const primaryKey = normalizeMapKey(path25.resolve(run.filePath));
|
|
11382
11669
|
const neighborKeys = [
|
|
11383
11670
|
...(run.result?.neighbors ?? []).map((n) => n.filePath),
|
|
11384
11671
|
...run.selectedNeighborPaths ?? []
|
|
11385
|
-
].map((filePath) => normalizeMapKey(
|
|
11672
|
+
].map((filePath) => normalizeMapKey(path25.resolve(filePath)));
|
|
11386
11673
|
const supersededByOwnFile = changedSet.has(primaryKey) || neighborKeys.some((k) => changedSet.has(k));
|
|
11387
11674
|
if (supersededByOwnFile) {
|
|
11388
11675
|
logCascade({
|
|
@@ -11425,7 +11712,7 @@ ${policy.body}`;
|
|
|
11425
11712
|
const cascadeTurn = runtime.turnIndex;
|
|
11426
11713
|
const editedKeys = /* @__PURE__ */ new Set();
|
|
11427
11714
|
for (const file of files) {
|
|
11428
|
-
const absolute =
|
|
11715
|
+
const absolute = path25.resolve(cwd, file);
|
|
11429
11716
|
editedKeys.add(normalizeMapKey(absolute));
|
|
11430
11717
|
forgetCascadePendingNeighbor(absolute);
|
|
11431
11718
|
}
|
|
@@ -12492,12 +12779,12 @@ ${lines.join("\n")}`;
|
|
|
12492
12779
|
const madgeFiles = cacheManager2.getFilesForMadge(cwd, turnStateSessionId);
|
|
12493
12780
|
if (madgeFiles.length > 0) {
|
|
12494
12781
|
dbg(`turn_end: madge checking ${madgeFiles.length} file(s) for circular deps`);
|
|
12495
|
-
const absFiles = madgeFiles.map((file) =>
|
|
12782
|
+
const absFiles = madgeFiles.map((file) => path25.resolve(cwd, file));
|
|
12496
12783
|
const batch = await depChecker.checkFilesBatch(absFiles, cwd);
|
|
12497
12784
|
const depResults = batch.results;
|
|
12498
12785
|
madgeStats = batch.stats;
|
|
12499
12786
|
for (const file of madgeFiles) {
|
|
12500
|
-
const absPath =
|
|
12787
|
+
const absPath = path25.resolve(cwd, file);
|
|
12501
12788
|
const depResult = depResults.get(absPath);
|
|
12502
12789
|
if (!depResult)
|
|
12503
12790
|
continue;
|
|
@@ -12533,7 +12820,7 @@ ${lines.join("\n")}`;
|
|
|
12533
12820
|
}
|
|
12534
12821
|
for (const result of cascadeResults) {
|
|
12535
12822
|
for (const neighbor of result.neighbors) {
|
|
12536
|
-
const abs =
|
|
12823
|
+
const abs = path25.isAbsolute(neighbor.filePath) ? neighbor.filePath : resolveRunnerPath(cwd, neighbor.filePath);
|
|
12537
12824
|
const key = normalizeMapKey(abs);
|
|
12538
12825
|
if (seenCandidateKeys.has(key))
|
|
12539
12826
|
continue;
|
|
@@ -12545,7 +12832,7 @@ ${lines.join("\n")}`;
|
|
|
12545
12832
|
const carriedDeferred = priorTestCache?.deferredTargets ?? [];
|
|
12546
12833
|
const turnSessionId = sessionId ?? runtime.telemetrySessionId;
|
|
12547
12834
|
const isThisSession = (entry) => entry.sessionId === turnSessionId;
|
|
12548
|
-
const entryPathKey = (entry) => normalizeMapKey(
|
|
12835
|
+
const entryPathKey = (entry) => normalizeMapKey(path25.resolve(cwd, entry.testFile));
|
|
12549
12836
|
const retiredCarry = (priorTestCache?.retiredTargets ?? []).filter(isThisSession);
|
|
12550
12837
|
const retiredKeys = new Set(retiredCarry.map(entryPathKey));
|
|
12551
12838
|
const resolvedDeferralKeys = /* @__PURE__ */ new Set();
|
|
@@ -12579,7 +12866,7 @@ ${lines.join("\n")}`;
|
|
|
12579
12866
|
let redispatchedDeferred = 0;
|
|
12580
12867
|
let retiredThisTurn = 0;
|
|
12581
12868
|
for (const carried of carriedDeferred) {
|
|
12582
|
-
const testFile =
|
|
12869
|
+
const testFile = path25.resolve(cwd, carried.testFile);
|
|
12583
12870
|
const carriedKey = normalizeMapKey(testFile);
|
|
12584
12871
|
if (!isThisSession(carried)) {
|
|
12585
12872
|
foreignDeferred++;
|
|
@@ -12612,7 +12899,7 @@ ${lines.join("\n")}`;
|
|
|
12612
12899
|
}
|
|
12613
12900
|
const config = RUNNERS[carried.runner];
|
|
12614
12901
|
const carriedRoot = testRootFor(testFile);
|
|
12615
|
-
if (!config || isExcludedTestTarget(testFile, carriedRoot) || !
|
|
12902
|
+
if (!config || isExcludedTestTarget(testFile, carriedRoot) || !fs17.existsSync(testFile)) {
|
|
12616
12903
|
resolvedDeferralKeys.add(carriedKey);
|
|
12617
12904
|
deadDeferred++;
|
|
12618
12905
|
continue;
|
|
@@ -12692,7 +12979,7 @@ ${lines.join("\n")}`;
|
|
|
12692
12979
|
dbg(`turn_end: ${display} \u2192 test target excluded by the built-in turn-end policy, skipping spawn (${toRunnerDisplayPath(cwd, target.testFile)})`);
|
|
12693
12980
|
continue;
|
|
12694
12981
|
}
|
|
12695
|
-
if (!
|
|
12982
|
+
if (!fs17.existsSync(target.testFile)) {
|
|
12696
12983
|
missingTargetFiles++;
|
|
12697
12984
|
dbg(`turn_end: ${display} \u2192 test file missing, skipping spawn (${toRunnerDisplayPath(cwd, target.testFile)})`);
|
|
12698
12985
|
continue;
|
|
@@ -12918,7 +13205,7 @@ ${lines.join("\n")}`;
|
|
|
12918
13205
|
const { file, runner, passed, failed, duration, error } = r.value;
|
|
12919
13206
|
if (failed > 0)
|
|
12920
13207
|
hasRealFailure = true;
|
|
12921
|
-
const shortFile =
|
|
13208
|
+
const shortFile = path25.basename(file);
|
|
12922
13209
|
const elapsed = formatRunDurationMs(duration);
|
|
12923
13210
|
const verdict = failed > 0 ? "FAIL" : "PASS";
|
|
12924
13211
|
const summary = isRunnerErrorResult(r.value) ? passed > 0 ? `error: ${error} (${passed} passed before)` : `error: ${error}` : `${verdict} ${passed}p/${failed}f (${elapsed})`;
|
|
@@ -13092,8 +13379,8 @@ ${lines.join("\n")}`;
|
|
|
13092
13379
|
} else {
|
|
13093
13380
|
const callGraphStart = Date.now();
|
|
13094
13381
|
try {
|
|
13095
|
-
const { impact, formatImpact, parseSymbolKey } = await import("../chunk-
|
|
13096
|
-
const { callGraphImpactToProjectDiagnostics } = await import("../chunk-
|
|
13382
|
+
const { impact, formatImpact, parseSymbolKey } = await import("../chunk-ZDWNFZJ2.js");
|
|
13383
|
+
const { callGraphImpactToProjectDiagnostics } = await import("../chunk-LEQTVRSV.js");
|
|
13097
13384
|
const impactLines = [];
|
|
13098
13385
|
let callGraphDispositionSuppressed = 0;
|
|
13099
13386
|
const impactFindings = [];
|
|
@@ -13461,7 +13748,7 @@ ${impactLines.join("\n")}`;
|
|
|
13461
13748
|
if (!lateAuxContentRead) {
|
|
13462
13749
|
lateAuxContentRead = true;
|
|
13463
13750
|
try {
|
|
13464
|
-
lateAuxContentValue =
|
|
13751
|
+
lateAuxContentValue = fs17.readFileSync(lateAuxPath, "utf-8");
|
|
13465
13752
|
} catch {
|
|
13466
13753
|
lateAuxContentValue = void 0;
|
|
13467
13754
|
}
|
|
@@ -13676,7 +13963,7 @@ ${lines.join("\n")}`;
|
|
|
13676
13963
|
}
|
|
13677
13964
|
});
|
|
13678
13965
|
}
|
|
13679
|
-
const unresolvedKeys = new Set(unresolvedBlockers.map((record) => normalizeMapKey(
|
|
13966
|
+
const unresolvedKeys = new Set(unresolvedBlockers.map((record) => normalizeMapKey(path25.resolve(record.filePath))));
|
|
13680
13967
|
const formatResolvedTail = (dropped) => `\u2026 and ${dropped} more`;
|
|
13681
13968
|
const resolvedTailMax = formatResolvedTail(Number.MAX_SAFE_INTEGER).length;
|
|
13682
13969
|
const resolvedShareChars = Math.floor(RUNTIME_CONFIG.turnEnd.maxChars * RESOLVED_SHARE_OF_CHARS) - resolvedTailMax;
|
|
@@ -13701,7 +13988,7 @@ ${lines.join("\n")}`;
|
|
|
13701
13988
|
let resolvedChars = 0;
|
|
13702
13989
|
let resolvedCount = 0;
|
|
13703
13990
|
const { files: resolvedBlockerFileList, dropped: resolvedBlockerFilesDropped } = runtime.consumeResolvedBlockerFiles((entry) => {
|
|
13704
|
-
if (unresolvedKeys.has(normalizeMapKey(
|
|
13991
|
+
if (unresolvedKeys.has(normalizeMapKey(path25.resolve(entry.filePath))))
|
|
13705
13992
|
return true;
|
|
13706
13993
|
const cost = formatResolvedLine(entry).length + 1;
|
|
13707
13994
|
if (resolvedCount > 0 && (resolvedCount >= resolvedLineBudget || resolvedChars + cost > resolvedCharBudget))
|
|
@@ -13872,7 +14159,7 @@ ${raw}`
|
|
|
13872
14159
|
projectSeqStart: runtime.turnStartProjectSeq,
|
|
13873
14160
|
projectSeqEnd: runtime.projectSeq,
|
|
13874
14161
|
fileSeqByPath: Object.fromEntries(runtime.getFileSeqEntries().map(([filePath, seq]) => [
|
|
13875
|
-
normalizeMapKey(
|
|
14162
|
+
normalizeMapKey(path25.resolve(filePath)),
|
|
13876
14163
|
seq
|
|
13877
14164
|
])),
|
|
13878
14165
|
fileContentHashes: {},
|
|
@@ -13911,7 +14198,7 @@ ${raw}`
|
|
|
13911
14198
|
repeatStaged = repeatContent !== void 0;
|
|
13912
14199
|
const fileSeqByPath2 = {};
|
|
13913
14200
|
for (const [filePath, seq] of runtime.getFileSeqEntries()) {
|
|
13914
|
-
fileSeqByPath2[normalizeMapKey(
|
|
14201
|
+
fileSeqByPath2[normalizeMapKey(path25.resolve(filePath))] = seq;
|
|
13915
14202
|
}
|
|
13916
14203
|
const { stored: existingGuard, carried, dropped } = readTurnEndGuardRecord(cacheManager2, runtime, cwd, sessionId);
|
|
13917
14204
|
const deliveredCitedFiles = holdPlan.reachedParts.flatMap((part) => provenanceCitations.get(part.raw) ?? []);
|
|
@@ -14140,10 +14427,10 @@ var TurnEndQueue = class {
|
|
|
14140
14427
|
if (this.pending.length >= 1) {
|
|
14141
14428
|
return Promise.reject(new Error("turn_end queue is busy"));
|
|
14142
14429
|
}
|
|
14143
|
-
return new Promise((
|
|
14430
|
+
return new Promise((resolve32, reject) => {
|
|
14144
14431
|
const item = {
|
|
14145
14432
|
work,
|
|
14146
|
-
resolve:
|
|
14433
|
+
resolve: resolve32,
|
|
14147
14434
|
reject,
|
|
14148
14435
|
timer: setTimeout(() => {
|
|
14149
14436
|
const index = this.pending.indexOf(item);
|
|
@@ -14190,7 +14477,7 @@ async function runTurnEndNowImpl(cwd, files = [], deferredDelivery = false) {
|
|
|
14190
14477
|
const abs = resolveHostToolPath(file, cwd);
|
|
14191
14478
|
let lineCount3 = 1;
|
|
14192
14479
|
try {
|
|
14193
|
-
lineCount3 =
|
|
14480
|
+
lineCount3 = fs18.readFileSync(abs, "utf8").split("\n").length;
|
|
14194
14481
|
} catch {
|
|
14195
14482
|
continue;
|
|
14196
14483
|
}
|
|
@@ -14328,8 +14615,8 @@ function acknowledgeTurnEnd(cwd, deliveryId) {
|
|
|
14328
14615
|
}
|
|
14329
14616
|
|
|
14330
14617
|
// dist/clients/module-report.js
|
|
14331
|
-
import * as
|
|
14332
|
-
import * as
|
|
14618
|
+
import * as fs19 from "node:fs";
|
|
14619
|
+
import * as path26 from "node:path";
|
|
14333
14620
|
|
|
14334
14621
|
// dist/clients/middle-man-analysis.js
|
|
14335
14622
|
var SELF_TOKEN = {
|
|
@@ -14906,7 +15193,7 @@ function blastReadArgs(graph, normalizedFile) {
|
|
|
14906
15193
|
return { path: normalizedFile, offset: 1, limit };
|
|
14907
15194
|
}
|
|
14908
15195
|
async function computeBlastRadius(graph, normalizedPath, projectRoot, maxDepth) {
|
|
14909
|
-
const { computeTransitiveImpact } = await import("../chunk-
|
|
15196
|
+
const { computeTransitiveImpact } = await import("../chunk-JTHEUTW7.js");
|
|
14910
15197
|
const result = computeTransitiveImpact(graph, normalizedPath, { maxDepth });
|
|
14911
15198
|
const byFile = /* @__PURE__ */ new Map();
|
|
14912
15199
|
for (const hit of result.hits) {
|
|
@@ -15496,11 +15783,11 @@ async function moduleReport(file, cwd, options) {
|
|
|
15496
15783
|
const startedAt = Date.now();
|
|
15497
15784
|
const maxRefs = normalizeMaxRefsPerSymbol(options?.maxRefsPerSymbol);
|
|
15498
15785
|
const maxCallGraphEntries = Math.min(CALL_GRAPH_MAX_ENTRY_CAP, Math.max(1, Math.floor(options?.maxCallGraphEntries ?? CALL_GRAPH_DEFAULT_ENTRY_CAP)));
|
|
15499
|
-
const absPath =
|
|
15786
|
+
const absPath = path26.resolve(cwd, file);
|
|
15500
15787
|
const normalizedPath = normalizeMapKey(absPath);
|
|
15501
15788
|
let content;
|
|
15502
15789
|
try {
|
|
15503
|
-
content =
|
|
15790
|
+
content = fs19.readFileSync(absPath, "utf-8");
|
|
15504
15791
|
} catch {
|
|
15505
15792
|
return unavailableReport(toDisplayPath(absPath, cwd));
|
|
15506
15793
|
}
|
|
@@ -15523,7 +15810,7 @@ async function moduleReport(file, cwd, options) {
|
|
|
15523
15810
|
let callGraphIdentity;
|
|
15524
15811
|
let revisionDriftNote;
|
|
15525
15812
|
try {
|
|
15526
|
-
const { getCachedReviewGraph, getReviewGraphCacheIdentity, getReviewGraphSizeSkipVerdict, getReviewGraphRevisionDrift, formatReviewGraphRevisionDriftNote: formatReviewGraphRevisionDriftNote2 } = await import("../chunk-
|
|
15813
|
+
const { getCachedReviewGraph, getReviewGraphCacheIdentity, getReviewGraphSizeSkipVerdict, getReviewGraphRevisionDrift, formatReviewGraphRevisionDriftNote: formatReviewGraphRevisionDriftNote2 } = await import("../chunk-MY4XNNTX.js");
|
|
15527
15814
|
graph = getCachedReviewGraph(cwd);
|
|
15528
15815
|
graphFileCap = getReviewGraphSizeSkipVerdict(cwd)?.maxFileCount;
|
|
15529
15816
|
const drift = graph ? getReviewGraphRevisionDrift(cwd) : void 0;
|
|
@@ -15925,7 +16212,7 @@ function suggestSimilarNames(candidates, target) {
|
|
|
15925
16212
|
async function readSymbol(file, symbolName, cwd, options = {}) {
|
|
15926
16213
|
const { kind: symbolKindFilter } = options;
|
|
15927
16214
|
const startedAt = Date.now();
|
|
15928
|
-
const absPath =
|
|
16215
|
+
const absPath = path26.resolve(cwd, file);
|
|
15929
16216
|
const log = (found) => {
|
|
15930
16217
|
logLatency({
|
|
15931
16218
|
type: "phase",
|
|
@@ -15937,7 +16224,7 @@ async function readSymbol(file, symbolName, cwd, options = {}) {
|
|
|
15937
16224
|
};
|
|
15938
16225
|
let content;
|
|
15939
16226
|
try {
|
|
15940
|
-
content =
|
|
16227
|
+
content = fs19.readFileSync(absPath, "utf-8");
|
|
15941
16228
|
} catch (err) {
|
|
15942
16229
|
log(false);
|
|
15943
16230
|
return {
|
|
@@ -16129,7 +16416,7 @@ function enclosingOutline(selected, symbols, callbacks, filters, filePath) {
|
|
|
16129
16416
|
}
|
|
16130
16417
|
async function readEnclosing(file, line, cwd, options) {
|
|
16131
16418
|
const startedAt = Date.now();
|
|
16132
|
-
const absPath =
|
|
16419
|
+
const absPath = path26.resolve(cwd, file);
|
|
16133
16420
|
const targetLine = Math.max(1, Math.floor(line));
|
|
16134
16421
|
const maxLines = options?.maxLines !== void 0 && Number.isFinite(options.maxLines) ? Math.max(1, Math.floor(options.maxLines)) : void 0;
|
|
16135
16422
|
const aroundLine = options?.aroundLine !== void 0 && Number.isFinite(options.aroundLine) ? options.aroundLine : void 0;
|
|
@@ -16144,7 +16431,7 @@ async function readEnclosing(file, line, cwd, options) {
|
|
|
16144
16431
|
};
|
|
16145
16432
|
let content;
|
|
16146
16433
|
try {
|
|
16147
|
-
content =
|
|
16434
|
+
content = fs19.readFileSync(absPath, "utf-8");
|
|
16148
16435
|
} catch {
|
|
16149
16436
|
log(false);
|
|
16150
16437
|
return { found: false, path: absPath, line: targetLine };
|
|
@@ -16307,7 +16594,7 @@ async function readEnclosing(file, line, cwd, options) {
|
|
|
16307
16594
|
}
|
|
16308
16595
|
|
|
16309
16596
|
// dist/clients/project-report.js
|
|
16310
|
-
import * as
|
|
16597
|
+
import * as path27 from "node:path";
|
|
16311
16598
|
var DEFAULT_LIMIT = 10;
|
|
16312
16599
|
var STALE_THRESHOLD_MS = 15 * 6e4;
|
|
16313
16600
|
var LOW_COVERAGE_THRESHOLD = 0.8;
|
|
@@ -16453,7 +16740,7 @@ function roleFor(graph, filePath) {
|
|
|
16453
16740
|
return top.length > 0 ? top.map((s) => s.name).join(", ") : void 0;
|
|
16454
16741
|
}
|
|
16455
16742
|
async function computeHubs(graph, degrees, cwd, limit, focusTerms) {
|
|
16456
|
-
const { computeTransitiveImpact } = await import("../chunk-
|
|
16743
|
+
const { computeTransitiveImpact } = await import("../chunk-JTHEUTW7.js");
|
|
16457
16744
|
const ranked = [...graph.fileNodes.entries()].map(([filePath, fileNodeId]) => ({
|
|
16458
16745
|
filePath,
|
|
16459
16746
|
fileNodeId,
|
|
@@ -16691,7 +16978,7 @@ function computeDeadWeight(graph, degrees, entryPointFiles, cwd, limit) {
|
|
|
16691
16978
|
}
|
|
16692
16979
|
var inFlightGraphBuilds = /* @__PURE__ */ new Set();
|
|
16693
16980
|
function triggerBackgroundGraphBuild(cwd, deps) {
|
|
16694
|
-
const key = normalizeMapKey(
|
|
16981
|
+
const key = normalizeMapKey(path27.resolve(cwd));
|
|
16695
16982
|
if (inFlightGraphBuilds.has(key))
|
|
16696
16983
|
return "already_running";
|
|
16697
16984
|
const deduped = deps.isGraphBuildInFlight(key, []);
|
|
@@ -16704,7 +16991,7 @@ function triggerBackgroundGraphBuild(cwd, deps) {
|
|
|
16704
16991
|
async function projectReport(cwd, options) {
|
|
16705
16992
|
const limit = clampLimit(options?.limit);
|
|
16706
16993
|
const focusTerms = normalizeFocus2(options?.focus);
|
|
16707
|
-
const { getCachedReviewGraph, getReviewGraphSizeSkipVerdict, getLastReviewGraphBuildAttempt, buildOrUpdateGraph, isGraphBuildInFlight, getReviewGraphRevisionDrift } = await import("../chunk-
|
|
16994
|
+
const { getCachedReviewGraph, getReviewGraphSizeSkipVerdict, getLastReviewGraphBuildAttempt, buildOrUpdateGraph, isGraphBuildInFlight, getReviewGraphRevisionDrift } = await import("../chunk-MY4XNNTX.js");
|
|
16708
16995
|
let graph;
|
|
16709
16996
|
try {
|
|
16710
16997
|
graph = getCachedReviewGraph(cwd);
|
|
@@ -16727,7 +17014,7 @@ async function projectReport(cwd, options) {
|
|
|
16727
17014
|
};
|
|
16728
17015
|
}
|
|
16729
17016
|
const previousAttempt = getLastReviewGraphBuildAttempt(cwd);
|
|
16730
|
-
const { FactStore: FactStore2 } = await import("../chunk-
|
|
17017
|
+
const { FactStore: FactStore2 } = await import("../chunk-ZEUF7BIN.js");
|
|
16731
17018
|
const trigger = triggerBackgroundGraphBuild(cwd, {
|
|
16732
17019
|
buildOrUpdateGraph,
|
|
16733
17020
|
isGraphBuildInFlight,
|
|
@@ -16917,8 +17204,9 @@ function fmtPct(n) {
|
|
|
16917
17204
|
}
|
|
16918
17205
|
|
|
16919
17206
|
// dist/clients/effective-config.js
|
|
16920
|
-
import * as
|
|
16921
|
-
import * as
|
|
17207
|
+
import * as os4 from "node:os";
|
|
17208
|
+
import * as path28 from "node:path";
|
|
17209
|
+
var TOOL_SWITCH_POINTER = /^\/tools\/[^/]+\/enabled$/;
|
|
16922
17210
|
function isEffectiveFileViewError(file) {
|
|
16923
17211
|
return "error" in file;
|
|
16924
17212
|
}
|
|
@@ -16989,24 +17277,40 @@ function decidedByOrNothing(entry) {
|
|
|
16989
17277
|
}
|
|
16990
17278
|
async function effectiveConfig(options = {}) {
|
|
16991
17279
|
const cwd = options.cwd ?? process.cwd();
|
|
16992
|
-
const homeDir = options.homeDir ??
|
|
16993
|
-
const resolveAt = (dir) => resolvePiLensConfig({
|
|
17280
|
+
const homeDir = options.homeDir ?? os4.homedir();
|
|
17281
|
+
const resolveAt = (dir, excludeLegacyProjectDocuments = false) => resolvePiLensConfig({
|
|
16994
17282
|
cwd: dir,
|
|
16995
17283
|
globalDir: getGlobalPiLensDir(),
|
|
16996
17284
|
// Production resolution for the global tier — see loadLSPConfig's
|
|
16997
17285
|
// comment (global-config-location PR, refs #2457).
|
|
16998
17286
|
globalConfigPath: getPiLensGlobalConfigPath(),
|
|
16999
|
-
homeDir
|
|
17287
|
+
homeDir,
|
|
17288
|
+
excludeLegacyProjectDocuments
|
|
17000
17289
|
});
|
|
17001
17290
|
const requestedFile = options.file === void 0 ? void 0 : resolveHostToolPath(options.file, cwd);
|
|
17002
17291
|
const fileOutsideCwd = requestedFile !== void 0 && !isSameOrWithin(cwd, requestedFile);
|
|
17003
17292
|
const absolute = fileOutsideCwd ? void 0 : requestedFile;
|
|
17004
|
-
const
|
|
17293
|
+
const resolutionRoot = absolute === void 0 ? cwd : path28.dirname(absolute);
|
|
17294
|
+
const resolution = resolveAt(resolutionRoot);
|
|
17295
|
+
const policyResolution = holdsCanonicalProjectConfig(resolutionRoot, homeDir) && resolution.documents.some((document) => document.location.legacy) ? resolveAt(resolutionRoot, true) : resolution;
|
|
17296
|
+
const globalDocument = resolution.documents.find((document) => document.tier === "global" && !document.location.legacy);
|
|
17297
|
+
const globalValue = globalDocument === void 0 ? void 0 : resolveOnePiLensConfigDocument(globalDocument).value;
|
|
17298
|
+
const projectRaw = peekPiLensProjectConfig(cwd).raw;
|
|
17299
|
+
const reportedProvenance = /* @__PURE__ */ new Map();
|
|
17300
|
+
for (const [pointer, entry] of resolution.provenance) {
|
|
17301
|
+
if (!TOOL_SWITCH_POINTER.test(entry.key)) {
|
|
17302
|
+
reportedProvenance.set(pointer, entry);
|
|
17303
|
+
}
|
|
17304
|
+
}
|
|
17305
|
+
const reportedResolution = {
|
|
17306
|
+
...resolution,
|
|
17307
|
+
provenance: reportedProvenance
|
|
17308
|
+
};
|
|
17005
17309
|
const resolved = {
|
|
17006
17310
|
value: resolution.value,
|
|
17007
|
-
provenance:
|
|
17311
|
+
provenance: reportedResolution.provenance
|
|
17008
17312
|
};
|
|
17009
|
-
const summary = summarizeConfigResolution(
|
|
17313
|
+
const summary = summarizeConfigResolution(reportedResolution, homeDir);
|
|
17010
17314
|
const homeRelativeCwd = homeRelativePath(cwd, homeDir);
|
|
17011
17315
|
const lspProblems = newLspConfigProblems();
|
|
17012
17316
|
lspConfigOf(resolution.value, lspProblems);
|
|
@@ -17022,12 +17326,12 @@ async function effectiveConfig(options = {}) {
|
|
|
17022
17326
|
// `disabledServerRecords` (#5141).
|
|
17023
17327
|
recordCounts: countBy([
|
|
17024
17328
|
...resolution.records,
|
|
17025
|
-
...disabledRunnersOf(
|
|
17329
|
+
...disabledRunnersOf(policyResolution).records,
|
|
17026
17330
|
...disabledServerRecords(resolution, lspProblems)
|
|
17027
17331
|
], (record) => record.code),
|
|
17028
17332
|
tools: LENS_TOOL_NAMES.map((name) => ({
|
|
17029
17333
|
name,
|
|
17030
|
-
enabled: resolveLensToolEnabled(name,
|
|
17334
|
+
enabled: resolveLensToolEnabled(name, globalValue, projectRaw, options.noTools)
|
|
17031
17335
|
})),
|
|
17032
17336
|
...fileOutsideCwd ? {
|
|
17033
17337
|
file: {
|
|
@@ -17036,7 +17340,7 @@ async function effectiveConfig(options = {}) {
|
|
|
17036
17340
|
} : absolute === void 0 ? {} : {
|
|
17037
17341
|
file: await fileView(
|
|
17038
17342
|
absolute,
|
|
17039
|
-
|
|
17343
|
+
policyResolution,
|
|
17040
17344
|
resolved,
|
|
17041
17345
|
homeDir,
|
|
17042
17346
|
cwd,
|
|
@@ -17208,10 +17512,10 @@ function buildSymbolSearchFileFilter(cwd, options) {
|
|
|
17208
17512
|
};
|
|
17209
17513
|
}
|
|
17210
17514
|
function scopeEntryKeys(cwd, paths) {
|
|
17211
|
-
return new Set(paths.map((entry) => normalizeEphemeralMapKey(
|
|
17515
|
+
return new Set(paths.map((entry) => normalizeEphemeralMapKey(path29.resolve(cwd, entry))));
|
|
17212
17516
|
}
|
|
17213
17517
|
function fileIsInScope(file, scope) {
|
|
17214
|
-
let key = normalizeEphemeralMapKey(
|
|
17518
|
+
let key = normalizeEphemeralMapKey(path29.resolve(file));
|
|
17215
17519
|
for (; ; ) {
|
|
17216
17520
|
if (scope.has(key))
|
|
17217
17521
|
return true;
|
|
@@ -17238,7 +17542,7 @@ function unknownLangRefusal(query, lang) {
|
|
|
17238
17542
|
}
|
|
17239
17543
|
function annotateSymbolSearchHitsWithGraph(hits, centrality, graph) {
|
|
17240
17544
|
for (const hit of hits) {
|
|
17241
|
-
const normalized = normalizeMapKey(
|
|
17545
|
+
const normalized = normalizeMapKey(path29.resolve(hit.file));
|
|
17242
17546
|
const fanIn = centrality.get(hit.file) ?? 0;
|
|
17243
17547
|
let complexity;
|
|
17244
17548
|
for (const symbolId of graph.symbolNodesByFile.get(normalized) ?? []) {
|
|
@@ -17302,7 +17606,7 @@ async function symbolSearch(query, cwd, limit = 20, options = {}) {
|
|
|
17302
17606
|
let centrality;
|
|
17303
17607
|
let results;
|
|
17304
17608
|
try {
|
|
17305
|
-
centrality = centralityFromReverseDeps(index, snapshot?.reverseDeps, (file) => normalizeMapKey(
|
|
17609
|
+
centrality = centralityFromReverseDeps(index, snapshot?.reverseDeps, (file) => normalizeMapKey(path29.resolve(file)));
|
|
17306
17610
|
const fileFilter = buildSymbolSearchFileFilter(cwd, options);
|
|
17307
17611
|
results = searchWordIndex(index, query, {
|
|
17308
17612
|
limit: effectiveLimit,
|
|
@@ -17313,7 +17617,7 @@ async function symbolSearch(query, cwd, limit = 20, options = {}) {
|
|
|
17313
17617
|
warmLease.release();
|
|
17314
17618
|
}
|
|
17315
17619
|
const hits = results.map(toSymbolSearchHit);
|
|
17316
|
-
const { getCachedReviewGraph } = await import("../chunk-
|
|
17620
|
+
const { getCachedReviewGraph } = await import("../chunk-MY4XNNTX.js");
|
|
17317
17621
|
const graph = getCachedReviewGraph(cwd);
|
|
17318
17622
|
if (graph)
|
|
17319
17623
|
annotateSymbolSearchHitsWithGraph(hits, centrality, graph);
|
|
@@ -17331,7 +17635,7 @@ function coverageLine(coverage) {
|
|
|
17331
17635
|
return `Index covers ${coverage.files} files${coverage.truncated ? " (capped \u2014 results may be incomplete)" : ""}.`;
|
|
17332
17636
|
}
|
|
17333
17637
|
function formatSymbolSearchRow(hit, position, cwd) {
|
|
17334
|
-
const file =
|
|
17638
|
+
const file = path29.relative(cwd, hit.file);
|
|
17335
17639
|
if (hit.kind === "file")
|
|
17336
17640
|
return ` ${position}. ${file}`;
|
|
17337
17641
|
const annotations = hit.annotations;
|
|
@@ -17359,7 +17663,7 @@ function renderCompactSymbolSearch(result, options) {
|
|
|
17359
17663
|
footer.push(options.stalenessNote);
|
|
17360
17664
|
const top = hits[0];
|
|
17361
17665
|
if (top) {
|
|
17362
|
-
footer.push(`Next: ${options.reportTool ?? "module_report"} ${
|
|
17666
|
+
footer.push(`Next: ${options.reportTool ?? "module_report"} ${path29.relative(options.cwd, top.file)}`);
|
|
17363
17667
|
}
|
|
17364
17668
|
if (footer.length > 0)
|
|
17365
17669
|
sections.push(footer.join("\n"));
|
|
@@ -17367,16 +17671,16 @@ function renderCompactSymbolSearch(result, options) {
|
|
|
17367
17671
|
}
|
|
17368
17672
|
|
|
17369
17673
|
// dist/tools/ast-grep-replace.js
|
|
17370
|
-
import * as
|
|
17674
|
+
import * as path33 from "node:path";
|
|
17371
17675
|
|
|
17372
17676
|
// dist/clients/deps/typebox.js
|
|
17373
17677
|
import { Type } from "typebox";
|
|
17374
17678
|
|
|
17375
17679
|
// dist/clients/ast-grep-tool-logger.js
|
|
17376
|
-
import * as
|
|
17680
|
+
import * as path30 from "node:path";
|
|
17377
17681
|
var AG_LOG_DIR = getGlobalPiLensLogDir();
|
|
17378
|
-
var AG_LOG_FILE =
|
|
17379
|
-
var AG_LOG_BACKUP_FILE =
|
|
17682
|
+
var AG_LOG_FILE = path30.join(AG_LOG_DIR, "ast-grep-tools.log");
|
|
17683
|
+
var AG_LOG_BACKUP_FILE = path30.join(AG_LOG_DIR, "ast-grep-tools.log.1");
|
|
17380
17684
|
var MAX_LOG_BYTES3 = Math.max(128 * 1024, Number.parseInt(process.env.PI_LENS_AST_GREP_LOG_MAX_BYTES ?? "1048576", 10) || 1048576);
|
|
17381
17685
|
var writer3 = createNdjsonLogger({
|
|
17382
17686
|
filePath: AG_LOG_FILE,
|
|
@@ -17554,19 +17858,19 @@ function canonicalLanguage(lang) {
|
|
|
17554
17858
|
}
|
|
17555
17859
|
|
|
17556
17860
|
// dist/tools/shared.js
|
|
17557
|
-
import * as
|
|
17558
|
-
import * as
|
|
17861
|
+
import * as os5 from "node:os";
|
|
17862
|
+
import * as path32 from "node:path";
|
|
17559
17863
|
|
|
17560
17864
|
// dist/clients/path-globs.js
|
|
17561
|
-
import * as
|
|
17562
|
-
import * as
|
|
17865
|
+
import * as fs20 from "node:fs";
|
|
17866
|
+
import * as path31 from "node:path";
|
|
17563
17867
|
function fileMatchesPathGlobs(file, cwd, globs) {
|
|
17564
|
-
const rel =
|
|
17565
|
-
const abs =
|
|
17868
|
+
const rel = path31.relative(cwd, file).split(path31.sep).join("/");
|
|
17869
|
+
const abs = path31.resolve(file).split(path31.sep).join("/");
|
|
17566
17870
|
const options = { dot: true, nocase: process.platform === "win32" };
|
|
17567
17871
|
const matches = (candidate, pattern) => minimatch(candidate, pattern, options) || minimatch(candidate, `${pattern}/**`, options);
|
|
17568
17872
|
return globs.some((raw) => {
|
|
17569
|
-
const within =
|
|
17873
|
+
const within = path31.isAbsolute(raw) ? relativeInside(cwd, raw) : void 0;
|
|
17570
17874
|
if (within !== void 0)
|
|
17571
17875
|
return matches(rel, toPosix(within) || "**");
|
|
17572
17876
|
const pattern = toPosix(raw);
|
|
@@ -17577,10 +17881,10 @@ function hasGlobMagic(text) {
|
|
|
17577
17881
|
return /[*?[{]/.test(text);
|
|
17578
17882
|
}
|
|
17579
17883
|
async function isGlobEntry(resolved, cwd) {
|
|
17580
|
-
const spelled = relativeInside(
|
|
17884
|
+
const spelled = relativeInside(path31.resolve(cwd), resolved) ?? resolved;
|
|
17581
17885
|
if (!hasGlobMagic(spelled))
|
|
17582
17886
|
return false;
|
|
17583
|
-
return
|
|
17887
|
+
return fs20.promises.lstat(resolved).then(() => false, (refusal) => {
|
|
17584
17888
|
return refusal.code === "ENOENT" || refusal.code === "ENOTDIR";
|
|
17585
17889
|
});
|
|
17586
17890
|
}
|
|
@@ -17589,13 +17893,13 @@ function literalRoot(cwd, relative10) {
|
|
|
17589
17893
|
for (const segment of relative10.split("/")) {
|
|
17590
17894
|
if (hasGlobMagic(segment))
|
|
17591
17895
|
break;
|
|
17592
|
-
root =
|
|
17896
|
+
root = path31.join(root, segment);
|
|
17593
17897
|
}
|
|
17594
17898
|
return root;
|
|
17595
17899
|
}
|
|
17596
17900
|
async function expandPathsEntry(entry, cwd, budget, options = {}) {
|
|
17597
|
-
const cwdAbsolute =
|
|
17598
|
-
const absolute =
|
|
17901
|
+
const cwdAbsolute = path31.resolve(cwd);
|
|
17902
|
+
const absolute = path31.resolve(cwdAbsolute, entry);
|
|
17599
17903
|
if (!await isGlobEntry(absolute, cwdAbsolute))
|
|
17600
17904
|
return { entries: [absolute], root: cwdAbsolute };
|
|
17601
17905
|
const relative10 = relativeInside(cwdAbsolute, absolute);
|
|
@@ -17697,7 +18001,7 @@ async function readPathsArgument(raw, options) {
|
|
|
17697
18001
|
const base = options.cwd || ".";
|
|
17698
18002
|
const absent = options.absent ?? "none";
|
|
17699
18003
|
if (raw === void 0 || raw === null) {
|
|
17700
|
-
return { entries: absent === "cwd" ? [
|
|
18004
|
+
return { entries: absent === "cwd" ? [path32.resolve(base)] : [] };
|
|
17701
18005
|
}
|
|
17702
18006
|
if (!Array.isArray(raw))
|
|
17703
18007
|
return { entries: [], refusal: "paths must be an array of strings" };
|
|
@@ -17760,7 +18064,7 @@ function defaultedCwdHomeRefusal(paths, cwd) {
|
|
|
17760
18064
|
if (paths?.length)
|
|
17761
18065
|
return void 0;
|
|
17762
18066
|
const spelling = cwd || ".";
|
|
17763
|
-
if (!isAtOrAboveHomeDir(realpathOrResolve(spelling), realpathOrResolve(
|
|
18067
|
+
if (!isAtOrAboveHomeDir(realpathOrResolve(spelling), realpathOrResolve(os5.homedir())))
|
|
17764
18068
|
return void 0;
|
|
17765
18069
|
return {
|
|
17766
18070
|
reason: "defaulted cwd resolves at or above home directory",
|
|
@@ -17963,7 +18267,7 @@ function createAstGrepReplaceTool(astGrepClient2, captureLineage, getFlag) {
|
|
|
17963
18267
|
};
|
|
17964
18268
|
}
|
|
17965
18269
|
const searchPaths = pathsRead.entries;
|
|
17966
|
-
const sessionRoot =
|
|
18270
|
+
const sessionRoot = path33.resolve(ctx.cwd ?? process.cwd());
|
|
17967
18271
|
if (applyFlag && getFlag?.("no-autofix", sessionRoot)) {
|
|
17968
18272
|
const reason = "ast_grep_replace refused: apply is disabled by the no-autofix flag (autofix.enabled=false); a preview with apply: false is still allowed";
|
|
17969
18273
|
logOutcome("error", { errorRaw: reason });
|
|
@@ -18786,10 +19090,10 @@ ${hint}` : `${output}${paginationNote}`;
|
|
|
18786
19090
|
}
|
|
18787
19091
|
|
|
18788
19092
|
// dist/tools/lens-diagnostics.js
|
|
18789
|
-
import { promises as
|
|
19093
|
+
import { promises as fs24 } from "node:fs";
|
|
18790
19094
|
import * as fsSync from "node:fs";
|
|
18791
|
-
import * as
|
|
18792
|
-
import * as
|
|
19095
|
+
import * as os8 from "node:os";
|
|
19096
|
+
import * as path40 from "node:path";
|
|
18793
19097
|
|
|
18794
19098
|
// dist/clients/project-diagnostics/extractors.js
|
|
18795
19099
|
var WARM_TRIGGER = {
|
|
@@ -18847,14 +19151,14 @@ function reasonFromAvailabilityVerdict(tool, verdict) {
|
|
|
18847
19151
|
}
|
|
18848
19152
|
|
|
18849
19153
|
// dist/clients/project-diagnostics/fresh-fetch.js
|
|
18850
|
-
import * as
|
|
18851
|
-
import * as
|
|
18852
|
-
import * as
|
|
19154
|
+
import * as fs22 from "node:fs";
|
|
19155
|
+
import * as os6 from "node:os";
|
|
19156
|
+
import * as path38 from "node:path";
|
|
18853
19157
|
|
|
18854
19158
|
// dist/clients/project-diagnostics/runner-adapters/jscpd.js
|
|
18855
|
-
import * as
|
|
19159
|
+
import * as path34 from "node:path";
|
|
18856
19160
|
function resolveClonePath(cwd, file) {
|
|
18857
|
-
return
|
|
19161
|
+
return path34.isAbsolute(file) ? file : path34.resolve(cwd, file);
|
|
18858
19162
|
}
|
|
18859
19163
|
function jscpdCloneToProjectDiagnostics(cwd, clone) {
|
|
18860
19164
|
const a = resolveClonePath(cwd, clone.fileA);
|
|
@@ -18867,7 +19171,7 @@ function jscpdCloneToProjectDiagnostics(cwd, clone) {
|
|
|
18867
19171
|
tool: "jscpd",
|
|
18868
19172
|
runner: "jscpd",
|
|
18869
19173
|
rule: "jscpd:duplicate",
|
|
18870
|
-
message: `Duplicate code (${clone.lines} lines) \u2014 also at ${
|
|
19174
|
+
message: `Duplicate code (${clone.lines} lines) \u2014 also at ${path34.relative(cwd, otherFile)}:${otherLine}`,
|
|
18871
19175
|
source: "project-scan"
|
|
18872
19176
|
});
|
|
18873
19177
|
return [
|
|
@@ -18882,16 +19186,16 @@ function jscpdResultToProjectDiagnostics(cwd, result) {
|
|
|
18882
19186
|
}
|
|
18883
19187
|
|
|
18884
19188
|
// dist/clients/project-diagnostics/runner-adapters/madge.js
|
|
18885
|
-
import * as
|
|
19189
|
+
import * as path35 from "node:path";
|
|
18886
19190
|
function resolveCyclePath(cwd, file) {
|
|
18887
|
-
return
|
|
19191
|
+
return path35.isAbsolute(file) ? file : path35.resolve(cwd, file);
|
|
18888
19192
|
}
|
|
18889
19193
|
function cycleMembers(dep) {
|
|
18890
19194
|
return dep.path.length > 0 ? dep.path : [dep.file];
|
|
18891
19195
|
}
|
|
18892
19196
|
function circularDepToProjectDiagnostics(cwd, dep) {
|
|
18893
19197
|
const members = cycleMembers(dep);
|
|
18894
|
-
const rendered = `${members.map((f) =>
|
|
19198
|
+
const rendered = `${members.map((f) => path35.basename(f)).join(" \u2192 ")} \u2192 ${path35.basename(members[0] ?? "")}`;
|
|
18895
19199
|
return members.map((file) => ({
|
|
18896
19200
|
filePath: resolveCyclePath(cwd, file),
|
|
18897
19201
|
severity: "warning",
|
|
@@ -18917,7 +19221,7 @@ function circularDepsToProjectDiagnostics(cwd, circular) {
|
|
|
18917
19221
|
}
|
|
18918
19222
|
|
|
18919
19223
|
// dist/clients/project-diagnostics/runner-adapters/opengrep.js
|
|
18920
|
-
import * as
|
|
19224
|
+
import * as path36 from "node:path";
|
|
18921
19225
|
function severityFor(raw) {
|
|
18922
19226
|
switch (raw.toUpperCase()) {
|
|
18923
19227
|
case "ERROR":
|
|
@@ -18932,7 +19236,7 @@ function opengrepFindingToProjectDiagnostic(cwd, finding) {
|
|
|
18932
19236
|
const { severity, blocking } = severityFor(finding.severity);
|
|
18933
19237
|
const cweSuffix = finding.cwe?.length ? ` (${finding.cwe[0]})` : "";
|
|
18934
19238
|
return {
|
|
18935
|
-
filePath:
|
|
19239
|
+
filePath: path36.isAbsolute(finding.path) ? finding.path : path36.resolve(cwd, finding.path),
|
|
18936
19240
|
line: finding.startLine,
|
|
18937
19241
|
column: finding.startCol,
|
|
18938
19242
|
severity,
|
|
@@ -18951,8 +19255,8 @@ function opengrepResultToProjectDiagnostics(cwd, result) {
|
|
|
18951
19255
|
}
|
|
18952
19256
|
|
|
18953
19257
|
// dist/clients/project-diagnostics/runner-adapters/runner-findings.js
|
|
18954
|
-
import * as
|
|
18955
|
-
import * as
|
|
19258
|
+
import * as fs21 from "node:fs";
|
|
19259
|
+
import * as path37 from "node:path";
|
|
18956
19260
|
function failureMessage(failure) {
|
|
18957
19261
|
const firstLine2 = failure.message.split("\n")[0]?.slice(0, 300) ?? "";
|
|
18958
19262
|
return firstLine2 ? `${failure.name}: ${firstLine2}` : failure.name;
|
|
@@ -19018,7 +19322,7 @@ function testRunnerFindingsToProjectDiagnostics(cache, cwd, runtime) {
|
|
|
19018
19322
|
return [];
|
|
19019
19323
|
const validation = cwd ? validateAdvisoryProvenance(cache, cwd, runtime) : { status: "unknown", reasons: ["validation-context-missing"] };
|
|
19020
19324
|
const root = cwd ?? process.cwd();
|
|
19021
|
-
const missingKeys = new Set((cache.provenance?.files ?? []).filter((file) => !
|
|
19325
|
+
const missingKeys = new Set((cache.provenance?.files ?? []).filter((file) => !fs21.existsSync(path37.resolve(root, file.path))).map((file) => advisoryPathKey(file.path, root)));
|
|
19022
19326
|
const historical = cache.superseded === true || cache.stale === true || validation.status !== "current";
|
|
19023
19327
|
return cache.results.filter((result) => !missingKeys.has(advisoryPathKey(result.file, root))).flatMap((result) => testResultToProjectDiagnostics(result, historical)).map((diagnostic) => historical ? {
|
|
19024
19328
|
...diagnostic,
|
|
@@ -19048,12 +19352,12 @@ function laneObservedAtMs(scannedAt, startedAtMs) {
|
|
|
19048
19352
|
return parseScannedAtMs(scannedAt) ?? startedAtMs;
|
|
19049
19353
|
}
|
|
19050
19354
|
async function fetchFreshProjectDiagnostics(cacheManager2, cwd, clients, signal, options = {}) {
|
|
19051
|
-
const requestedRoot = options.analysisRoot === void 0 ? cwd :
|
|
19355
|
+
const requestedRoot = options.analysisRoot === void 0 ? cwd : path38.resolve(cwd, options.analysisRoot);
|
|
19052
19356
|
let analysisRoot;
|
|
19053
19357
|
let analysisRootValidation;
|
|
19054
19358
|
if (options.analysisRoot !== void 0) {
|
|
19055
19359
|
try {
|
|
19056
|
-
if (!
|
|
19360
|
+
if (!fs22.statSync(requestedRoot).isDirectory()) {
|
|
19057
19361
|
throw new Error("is not a directory");
|
|
19058
19362
|
}
|
|
19059
19363
|
analysisRoot = realpathOrResolve(requestedRoot);
|
|
@@ -19087,7 +19391,7 @@ async function fetchFreshProjectDiagnostics(cacheManager2, cwd, clients, signal,
|
|
|
19087
19391
|
analysisRoot = realpathOrResolve(cwd);
|
|
19088
19392
|
}
|
|
19089
19393
|
const unsafeRootReason = "the analysis root resolves at or above the home directory; heavyweight analyzers refuse to walk from there (#747)";
|
|
19090
|
-
const homeRoot = realpathOrResolve(options.homeDir ??
|
|
19394
|
+
const homeRoot = realpathOrResolve(options.homeDir ?? os6.homedir());
|
|
19091
19395
|
if (options.analysisRoot !== void 0) {
|
|
19092
19396
|
const unsafeExplicitRoot = !isSameOrWithin(homeRoot, analysisRoot) || isSameOrWithin(analysisRoot, homeRoot);
|
|
19093
19397
|
analysisRootValidation = unsafeExplicitRoot ? {
|
|
@@ -19211,11 +19515,11 @@ async function fetchFreshProjectDiagnostics(cacheManager2, cwd, clients, signal,
|
|
|
19211
19515
|
// jscpd — duplicate code detection. Cache key varies with TS-project
|
|
19212
19516
|
// detection, exactly mirroring session_start's own logic.
|
|
19213
19517
|
task("jscpd", async () => {
|
|
19214
|
-
if (!await clients.jscpdClient.ensureAvailable()) {
|
|
19518
|
+
if (!await clients.jscpdClient.ensureAvailable(analysisRoot)) {
|
|
19215
19519
|
markCold("jscpd", reasonFromAvailabilityVerdict("jscpd", clients.jscpdClient.getAvailabilityVerdict?.()));
|
|
19216
19520
|
return;
|
|
19217
19521
|
}
|
|
19218
|
-
const isTsProject =
|
|
19522
|
+
const isTsProject = fs22.existsSync(path38.join(analysisRoot, "tsconfig.json"));
|
|
19219
19523
|
const scannerKey = isTsProject ? "jscpd-ts" : "jscpd";
|
|
19220
19524
|
const startMs = Date.now();
|
|
19221
19525
|
const result = await clients.jscpdClient.scan(analysisRoot, void 0, void 0, isTsProject);
|
|
@@ -19522,13 +19826,13 @@ function makeProgressReporter(onUpdate, label, throttleMs = 250) {
|
|
|
19522
19826
|
}
|
|
19523
19827
|
|
|
19524
19828
|
// dist/tools/lsp-diagnostics.js
|
|
19525
|
-
import * as
|
|
19526
|
-
import * as
|
|
19829
|
+
import * as fs23 from "node:fs";
|
|
19830
|
+
import * as path39 from "node:path";
|
|
19527
19831
|
|
|
19528
19832
|
// dist/clients/out-of-band-changes.js
|
|
19529
19833
|
import { promises as fsp } from "node:fs";
|
|
19530
|
-
import * as
|
|
19531
|
-
import { basename as
|
|
19834
|
+
import * as os7 from "node:os";
|
|
19835
|
+
import { basename as basename8, join as join19, relative as relative7 } from "node:path";
|
|
19532
19836
|
|
|
19533
19837
|
// dist/clients/disk-changes.js
|
|
19534
19838
|
var DISK_CHANGE_ORIGINS = [
|
|
@@ -19855,7 +20159,7 @@ var INSTALL_MARKERS = [
|
|
|
19855
20159
|
".yarn-integrity"
|
|
19856
20160
|
];
|
|
19857
20161
|
var VENV_LIB_DIR = "lib";
|
|
19858
|
-
var VENV_WINDOWS_SITE_PACKAGES =
|
|
20162
|
+
var VENV_WINDOWS_SITE_PACKAGES = join19("Lib", "site-packages");
|
|
19859
20163
|
var VENV_INTERPRETER_DIRS_MAX = 4;
|
|
19860
20164
|
var DECLARATION_WALK_MAX_DIRS = 4096;
|
|
19861
20165
|
var DECLARATION_WALK_MAX_FILES = 2048;
|
|
@@ -19877,23 +20181,23 @@ function demandsWalk(trigger, walk) {
|
|
|
19877
20181
|
}
|
|
19878
20182
|
var fingerprint = (stat) => `${stat.ino}:${stat.size}:${stat.mtimeMs}`;
|
|
19879
20183
|
var fingerprintChangedAt = (print) => Number(print.slice(print.lastIndexOf(":") + 1));
|
|
19880
|
-
var isBelowRootConfig = (filePath) => BELOW_ROOT_CONFIG_FILE_NAMES.has(
|
|
20184
|
+
var isBelowRootConfig = (filePath) => BELOW_ROOT_CONFIG_FILE_NAMES.has(basename8(filePath));
|
|
19881
20185
|
function diffServerConfigs(root, before, after) {
|
|
19882
|
-
return diffDeclarations(new Map([...before].map(([name, print]) => [
|
|
20186
|
+
return diffDeclarations(new Map([...before].map(([name, print]) => [join19(root, name), print])), new Map([...after].map(([name, print]) => [join19(root, name), print])));
|
|
19883
20187
|
}
|
|
19884
20188
|
async function readVenvInstallParts(root, listed) {
|
|
19885
20189
|
const targets = [];
|
|
19886
20190
|
for (const name of PROJECT_VENV_DIR_NAMES) {
|
|
19887
20191
|
if (!listed.has(name))
|
|
19888
20192
|
continue;
|
|
19889
|
-
const venvRoot =
|
|
20193
|
+
const venvRoot = join19(root, name);
|
|
19890
20194
|
targets.push({
|
|
19891
20195
|
label: `${name}/${VENV_WINDOWS_SITE_PACKAGES}`,
|
|
19892
|
-
dir:
|
|
20196
|
+
dir: join19(venvRoot, VENV_WINDOWS_SITE_PACKAGES)
|
|
19893
20197
|
});
|
|
19894
20198
|
let interpreters;
|
|
19895
20199
|
try {
|
|
19896
|
-
interpreters = await fsp.readdir(
|
|
20200
|
+
interpreters = await fsp.readdir(join19(venvRoot, VENV_LIB_DIR), {
|
|
19897
20201
|
withFileTypes: true
|
|
19898
20202
|
});
|
|
19899
20203
|
} catch {
|
|
@@ -19904,7 +20208,7 @@ async function readVenvInstallParts(root, listed) {
|
|
|
19904
20208
|
for (const interpreter of interpreterDirs) {
|
|
19905
20209
|
targets.push({
|
|
19906
20210
|
label: `${name}/${VENV_LIB_DIR}/${interpreter.name}/site-packages`,
|
|
19907
|
-
dir:
|
|
20211
|
+
dir: join19(venvRoot, VENV_LIB_DIR, interpreter.name, "site-packages")
|
|
19908
20212
|
});
|
|
19909
20213
|
}
|
|
19910
20214
|
}
|
|
@@ -19938,7 +20242,7 @@ async function readInstallStamp(root) {
|
|
|
19938
20242
|
names.push(`node_modules/${marker}`);
|
|
19939
20243
|
let link;
|
|
19940
20244
|
try {
|
|
19941
|
-
link = await fsp.lstat(
|
|
20245
|
+
link = await fsp.lstat(join19(root, "node_modules"));
|
|
19942
20246
|
} catch {
|
|
19943
20247
|
link = void 0;
|
|
19944
20248
|
}
|
|
@@ -19954,7 +20258,7 @@ async function readInstallStamp(root) {
|
|
|
19954
20258
|
const [statted, venvParts] = await Promise.all([
|
|
19955
20259
|
Promise.all([...names, ...configNames].map(async (name) => {
|
|
19956
20260
|
try {
|
|
19957
|
-
const stat = await fsp.stat(
|
|
20261
|
+
const stat = await fsp.stat(join19(root, name));
|
|
19958
20262
|
return {
|
|
19959
20263
|
part: `${name}=${fingerprint(stat)}`,
|
|
19960
20264
|
changedAt: stat.mtimeMs
|
|
@@ -20009,11 +20313,11 @@ async function walkDeclarations(root) {
|
|
|
20009
20313
|
for (const entry of entries) {
|
|
20010
20314
|
if (entry.isDirectory()) {
|
|
20011
20315
|
if (!isExcludedDirName(entry.name))
|
|
20012
|
-
queue.push(
|
|
20316
|
+
queue.push(join19(dir, entry.name));
|
|
20013
20317
|
} else if (entry.isFile() && (DECLARATION_FILE.test(entry.name) || // #5501 r3: a member manifest below the root. The root's own are
|
|
20014
20318
|
// statted with the install stamp, so the walk skips them.
|
|
20015
20319
|
dir !== root && BELOW_ROOT_CONFIG_FILE_NAMES.has(entry.name))) {
|
|
20016
|
-
found.push(
|
|
20320
|
+
found.push(join19(dir, entry.name));
|
|
20017
20321
|
}
|
|
20018
20322
|
}
|
|
20019
20323
|
if (found.length > DECLARATION_WALK_MAX_FILES)
|
|
@@ -20092,7 +20396,7 @@ function firstLookFreshConfigs(root, rootConfigs, walked, since) {
|
|
|
20092
20396
|
const fresh = [];
|
|
20093
20397
|
for (const [name, print] of rootConfigs ?? [])
|
|
20094
20398
|
if (fingerprintChangedAt(print) >= floor)
|
|
20095
|
-
fresh.push({ filePath:
|
|
20399
|
+
fresh.push({ filePath: join19(root, name), type: 2 });
|
|
20096
20400
|
for (const [filePath, print] of walked ?? [])
|
|
20097
20401
|
if (isBelowRootConfig(filePath) && fingerprintChangedAt(print) >= floor)
|
|
20098
20402
|
fresh.push({ filePath, type: 2 });
|
|
@@ -20109,7 +20413,7 @@ function earliestOverlappingLaunch(root, clients) {
|
|
|
20109
20413
|
function lookForOutOfBandChanges(root, trigger, runtime, options = {}) {
|
|
20110
20414
|
if (options.signal?.aborted)
|
|
20111
20415
|
return Promise.resolve();
|
|
20112
|
-
const homeRoot = isAtOrAboveHomeDir(realpathOrResolve(root), realpathOrResolve(
|
|
20416
|
+
const homeRoot = isAtOrAboveHomeDir(realpathOrResolve(root), realpathOrResolve(os7.homedir()));
|
|
20113
20417
|
if (homeRoot)
|
|
20114
20418
|
recordDegradationOnce({
|
|
20115
20419
|
kind: "lsp-declaration-look-capped",
|
|
@@ -20354,7 +20658,7 @@ async function collectFiles(dir, extensions, maxFiles, isIgnored = () => false)
|
|
|
20354
20658
|
return;
|
|
20355
20659
|
let entries;
|
|
20356
20660
|
try {
|
|
20357
|
-
entries = await
|
|
20661
|
+
entries = await fs23.promises.readdir(current, { withFileTypes: true });
|
|
20358
20662
|
} catch {
|
|
20359
20663
|
return;
|
|
20360
20664
|
}
|
|
@@ -20363,11 +20667,11 @@ async function collectFiles(dir, extensions, maxFiles, isIgnored = () => false)
|
|
|
20363
20667
|
return;
|
|
20364
20668
|
if (entry.isSymbolicLink())
|
|
20365
20669
|
continue;
|
|
20366
|
-
const full =
|
|
20670
|
+
const full = path39.join(current, entry.name);
|
|
20367
20671
|
if (entry.isDirectory()) {
|
|
20368
20672
|
if (!isExcludedDirName(entry.name) && !isIgnored(full, true))
|
|
20369
20673
|
await walk(full);
|
|
20370
|
-
} else if (entry.isFile() && extensions.includes(
|
|
20674
|
+
} else if (entry.isFile() && extensions.includes(path39.extname(full))) {
|
|
20371
20675
|
if (isIgnored(full, false))
|
|
20372
20676
|
continue;
|
|
20373
20677
|
files.push(full);
|
|
@@ -20484,7 +20788,7 @@ function createLspDiagnosticsTool(nextWriteIndex, onConfirmedNoBlockers, getServ
|
|
|
20484
20788
|
const absPath = normalizeMapKey(typedParams.pathAlreadyResolved === true ? rawPath : resolveHostToolPath(rawPath, cwd));
|
|
20485
20789
|
let stat;
|
|
20486
20790
|
try {
|
|
20487
|
-
stat =
|
|
20791
|
+
stat = fs23.statSync(absPath);
|
|
20488
20792
|
} catch {
|
|
20489
20793
|
return {
|
|
20490
20794
|
content: [
|
|
@@ -20536,7 +20840,7 @@ async function collectDiagnosticsForFile(absPath, lspService, scanRoot, waitMs,
|
|
|
20536
20840
|
let content;
|
|
20537
20841
|
let touched;
|
|
20538
20842
|
try {
|
|
20539
|
-
content =
|
|
20843
|
+
content = fs23.readFileSync(absPath, "utf-8");
|
|
20540
20844
|
const contentLimit = explicitQuery ? exceedsExplicitQueryLimits(content) : exceedsLspSyncLimits(content);
|
|
20541
20845
|
if (contentLimit.tooLarge) {
|
|
20542
20846
|
const reason = `file too large for LSP diagnostics (${contentLimit.reason})`;
|
|
@@ -20813,7 +21117,7 @@ async function collectFileDiagnosticResult(file, severity, lspService, waitMs, n
|
|
|
20813
21117
|
const scannedAt = Date.now();
|
|
20814
21118
|
let stat;
|
|
20815
21119
|
try {
|
|
20816
|
-
stat =
|
|
21120
|
+
stat = fs23.statSync(file);
|
|
20817
21121
|
if (!stat.isFile()) {
|
|
20818
21122
|
return { file, diagnostics: [], error: `${file}: not a file` };
|
|
20819
21123
|
}
|
|
@@ -21385,7 +21689,7 @@ async function expandPathsToFiles(cwd, rawPaths, pathsAlreadyResolved = false) {
|
|
|
21385
21689
|
const abs = normalizeMapKey(pathsAlreadyResolved ? entry : resolveHostToolPath(entry, cwd));
|
|
21386
21690
|
let stat;
|
|
21387
21691
|
try {
|
|
21388
|
-
stat =
|
|
21692
|
+
stat = fs23.statSync(abs);
|
|
21389
21693
|
} catch {
|
|
21390
21694
|
}
|
|
21391
21695
|
if (stat?.isDirectory()) {
|
|
@@ -21593,7 +21897,7 @@ async function runDirectoryDiagnostics(absPath, severity, lspService, options) {
|
|
|
21593
21897
|
reason: batchOutcomeReason(result)
|
|
21594
21898
|
}));
|
|
21595
21899
|
const auxiliaryOnlyLine = auxiliaryOnlyFindingsLine(results);
|
|
21596
|
-
const tooLargeLines = renderBatchOutcomeLines(outcomeDetails, (file) =>
|
|
21900
|
+
const tooLargeLines = renderBatchOutcomeLines(outcomeDetails, (file) => path39.relative(absPath, file));
|
|
21597
21901
|
const withheldDirectory = mergeWithheld(results.map((r) => r.withheldCompile));
|
|
21598
21902
|
const withheldDisclosure = withheldCompileNote(withheldDirectory);
|
|
21599
21903
|
let text;
|
|
@@ -21635,7 +21939,7 @@ async function runDirectoryDiagnostics(absPath, severity, lspService, options) {
|
|
|
21635
21939
|
];
|
|
21636
21940
|
const toRelative = (d) => ({
|
|
21637
21941
|
...d,
|
|
21638
|
-
file:
|
|
21942
|
+
file: path39.relative(absPath, d.file)
|
|
21639
21943
|
});
|
|
21640
21944
|
if (primaryDisplay.length > 0) {
|
|
21641
21945
|
lines.push(`Primary findings (${primaryDisplay.length}):`);
|
|
@@ -21668,7 +21972,7 @@ async function runDirectoryDiagnostics(absPath, severity, lspService, options) {
|
|
|
21668
21972
|
filesScanned: filesToProcess.length,
|
|
21669
21973
|
capped: wasCapped,
|
|
21670
21974
|
diagnostics: display.map((d) => ({
|
|
21671
|
-
file:
|
|
21975
|
+
file: path39.relative(absPath, d.file),
|
|
21672
21976
|
line: d.line,
|
|
21673
21977
|
character: d.character,
|
|
21674
21978
|
severity: d.severity,
|
|
@@ -21743,7 +22047,7 @@ async function findFullScanBindingMismatches(results) {
|
|
|
21743
22047
|
result.boundToCurrentDisk !== true && result.contentHash !== void 0
|
|
21744
22048
|
) {
|
|
21745
22049
|
try {
|
|
21746
|
-
const content = await
|
|
22050
|
+
const content = await fs24.readFile(result.filePath, "utf-8");
|
|
21747
22051
|
if (hashDiagnosticContent(content) !== result.contentHash) {
|
|
21748
22052
|
mismatched.add(result);
|
|
21749
22053
|
}
|
|
@@ -21753,7 +22057,7 @@ async function findFullScanBindingMismatches(results) {
|
|
|
21753
22057
|
sinceYield += 1;
|
|
21754
22058
|
if (sinceYield >= FULL_SCAN_BINDING_YIELD_EVERY) {
|
|
21755
22059
|
sinceYield = 0;
|
|
21756
|
-
await new Promise((
|
|
22060
|
+
await new Promise((resolve32) => setImmediate(resolve32));
|
|
21757
22061
|
}
|
|
21758
22062
|
}
|
|
21759
22063
|
return mismatched;
|
|
@@ -21803,7 +22107,7 @@ function createLensDiagnosticsTool(cacheManager2, getCwd, getLspService = getLSP
|
|
|
21803
22107
|
const files2 = details.filesChecked ?? details.filesScanned ?? 0;
|
|
21804
22108
|
const noun = count === 1 ? "diagnostic" : "diagnostics";
|
|
21805
22109
|
const filePath = typeof details?.filePath === "string" ? details.filePath : Array.isArray(args?.paths) && args.paths.length === 1 && typeof args.paths[0] === "string" ? args.paths[0] : void 0;
|
|
21806
|
-
const singleFile = (details?.mode === "file" || files2 === 1) && typeof filePath === "string" ? ` ${
|
|
22110
|
+
const singleFile = (details?.mode === "file" || files2 === 1) && typeof filePath === "string" ? ` ${path40.basename(filePath)}` : "";
|
|
21807
22111
|
const scope = files2 > 1 ? ` across ${files2} files` : singleFile;
|
|
21808
22112
|
if (isError)
|
|
21809
22113
|
return `lens_diagnostics lsp \u2014 ${text.split("\n")[0] ?? "error"}`;
|
|
@@ -22101,7 +22405,7 @@ function appendProjectDiagnosticsDeltaLines(groups, cwd, report, severity, inclu
|
|
|
22101
22405
|
const diagnostics = [...gated.live, ...gated.stale];
|
|
22102
22406
|
const byFile = /* @__PURE__ */ new Map();
|
|
22103
22407
|
for (const diagnostic of diagnostics) {
|
|
22104
|
-
const filePath =
|
|
22408
|
+
const filePath = path40.resolve(diagnostic.filePath);
|
|
22105
22409
|
const bucket = byFile.get(filePath) ?? [];
|
|
22106
22410
|
bucket.push(diagnostic);
|
|
22107
22411
|
byFile.set(filePath, bucket);
|
|
@@ -22396,7 +22700,7 @@ Summary (turn delta): ${aw} actionable warning${aw === 1 ? "" : "s"} \xB7 ${cq}
|
|
|
22396
22700
|
function createCurrentIgnoreFilter(cwd) {
|
|
22397
22701
|
try {
|
|
22398
22702
|
const matcher = getProjectIgnoreMatcher(cwd);
|
|
22399
|
-
return (filePath) => !matcher.isIgnored(
|
|
22703
|
+
return (filePath) => !matcher.isIgnored(path40.resolve(filePath), false);
|
|
22400
22704
|
} catch {
|
|
22401
22705
|
return () => true;
|
|
22402
22706
|
}
|
|
@@ -22426,9 +22730,9 @@ function resolvePathsScope(entries) {
|
|
|
22426
22730
|
}
|
|
22427
22731
|
const fileKeys = new Set(fileEntries.map((f) => normalizeFilePath(f)));
|
|
22428
22732
|
const dirPrefixes = dirEntries.map((d) => normalizeFilePath(d));
|
|
22429
|
-
const includeExplicitFile = (filePath) => fileKeys.has(normalizeFilePath(
|
|
22733
|
+
const includeExplicitFile = (filePath) => fileKeys.has(normalizeFilePath(path40.resolve(filePath)));
|
|
22430
22734
|
const includeFile = (filePath) => {
|
|
22431
|
-
const key = normalizeFilePath(
|
|
22735
|
+
const key = normalizeFilePath(path40.resolve(filePath));
|
|
22432
22736
|
if (fileKeys.has(key))
|
|
22433
22737
|
return true;
|
|
22434
22738
|
return dirPrefixes.some((prefix) => isWithinForm(key, prefix));
|
|
@@ -22449,7 +22753,7 @@ function pathsScopeCacheOnlyNote(scope) {
|
|
|
22449
22753
|
function pathsScopeMissingNote(scope) {
|
|
22450
22754
|
if (!scope || scope.missing.length === 0)
|
|
22451
22755
|
return "";
|
|
22452
|
-
const shown2 = scope.missing.slice(0, 10).map((p) =>
|
|
22756
|
+
const shown2 = scope.missing.slice(0, 10).map((p) => path40.basename(p));
|
|
22453
22757
|
const more = scope.missing.length > shown2.length ? ` (+${scope.missing.length - shown2.length} more)` : "";
|
|
22454
22758
|
return `
|
|
22455
22759
|
|
|
@@ -22740,7 +23044,7 @@ function mergeDiagnosticsWithWidgetSummaries(widgetSummaries, lspResults, projec
|
|
|
22740
23044
|
byFile.set(fileKey, summarizeDiagnostics(existing?.filePath ?? filePath, diagnostics, existing?.hasFinalSnapshot ?? true, existing));
|
|
22741
23045
|
};
|
|
22742
23046
|
for (const summary of widgetSummaries) {
|
|
22743
|
-
const filePath =
|
|
23047
|
+
const filePath = path40.resolve(summary.filePath);
|
|
22744
23048
|
const fileKey = normalizeMapKey(summary.filePath);
|
|
22745
23049
|
if (authoritativeLspFiles?.has(fileKey))
|
|
22746
23050
|
continue;
|
|
@@ -22769,7 +23073,7 @@ function mergeDiagnosticsWithWidgetSummaries(widgetSummaries, lspResults, projec
|
|
|
22769
23073
|
}
|
|
22770
23074
|
}
|
|
22771
23075
|
for (const result of lspResults) {
|
|
22772
|
-
const filePath =
|
|
23076
|
+
const filePath = path40.resolve(result.filePath);
|
|
22773
23077
|
for (const diagnostic of result.diagnostics ?? []) {
|
|
22774
23078
|
addDiagnostic(filePath, {
|
|
22775
23079
|
...lspDiagnosticToWidget(diagnostic),
|
|
@@ -22789,12 +23093,12 @@ function mergeDiagnosticsWithWidgetSummaries(widgetSummaries, lspResults, projec
|
|
|
22789
23093
|
});
|
|
22790
23094
|
}
|
|
22791
23095
|
for (const diagnostic of projectSnapshot?.diagnostics ?? []) {
|
|
22792
|
-
addDiagnostic(
|
|
23096
|
+
addDiagnostic(path40.resolve(diagnostic.filePath), projectDiagnosticToWidget(diagnostic, diagnostic.filePath));
|
|
22793
23097
|
}
|
|
22794
23098
|
for (const diagnostic of deltaDiagnostics) {
|
|
22795
23099
|
const widget = projectDiagnosticToWidget(diagnostic, diagnostic.filePath);
|
|
22796
23100
|
const observedAt = widget.observedAt ?? deltaObservedAt;
|
|
22797
|
-
addDiagnostic(
|
|
23101
|
+
addDiagnostic(path40.resolve(diagnostic.filePath), {
|
|
22798
23102
|
...widget,
|
|
22799
23103
|
...observedAt !== void 0 && { observedAt }
|
|
22800
23104
|
});
|
|
@@ -22807,7 +23111,7 @@ async function applyInlineSuppressionsToSummaries(summaries, cwd, policyMap, dis
|
|
|
22807
23111
|
return summary;
|
|
22808
23112
|
let content;
|
|
22809
23113
|
try {
|
|
22810
|
-
content = await
|
|
23114
|
+
content = await fs24.readFile(summary.filePath, "utf8");
|
|
22811
23115
|
} catch {
|
|
22812
23116
|
const policyKept2 = applyRulePolicy(summary.diagnostics, policyMap, {
|
|
22813
23117
|
root: cwd,
|
|
@@ -23036,7 +23340,7 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
23036
23340
|
unreconciledFiles.add(fileKey);
|
|
23037
23341
|
recordDegradationOnce({
|
|
23038
23342
|
kind: "diagnostic-retained-unreconciled",
|
|
23039
|
-
subject: `${
|
|
23343
|
+
subject: `${path40.resolve(result2.filePath)}:lsp`,
|
|
23040
23344
|
reason: "confirmed diagnostic result could not replace retained widget state"
|
|
23041
23345
|
});
|
|
23042
23346
|
}
|
|
@@ -23044,7 +23348,7 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
23044
23348
|
unreconciledFiles.add(fileKey);
|
|
23045
23349
|
recordDegradationOnce({
|
|
23046
23350
|
kind: "diagnostic-retained-unreconciled",
|
|
23047
|
-
subject: `${
|
|
23351
|
+
subject: `${path40.resolve(result2.filePath)}:lsp`,
|
|
23048
23352
|
reason: "confirmed diagnostic result failed during widget reconciliation"
|
|
23049
23353
|
});
|
|
23050
23354
|
}
|
|
@@ -23240,7 +23544,7 @@ test-runner coverage is edit-scoped, NOT a full-project run: its findings only r
|
|
|
23240
23544
|
const failedNote = failedAnalyzers.length > 0 ? `
|
|
23241
23545
|
|
|
23242
23546
|
failed (ran, but no trustworthy result): ${failedAnalyzers.map(({ id, summary }) => `${id} \u2014 ${summary}`).join(", ")}. These analyzers were not cached and will be retried; absence of their findings is NOT a clean verdict.` : "";
|
|
23243
|
-
const walkUnsafeRoot = explicitFiles === void 0 && isAtOrAboveHomeDir(realpathOrResolve(cwd), realpathOrResolve(
|
|
23547
|
+
const walkUnsafeRoot = explicitFiles === void 0 && isAtOrAboveHomeDir(realpathOrResolve(cwd), realpathOrResolve(os8.homedir()));
|
|
23244
23548
|
const walkUnsafeRootNote = walkUnsafeRoot ? `
|
|
23245
23549
|
|
|
23246
23550
|
project file walk skipped: the working directory resolves at or above the home directory, so the cheap project scan and the LSP workspace sweep would each enumerate every unrelated tree under it. Re-run from inside a project directory. Absence of their findings is NOT a clean verdict.` : "";
|
|
@@ -23788,7 +24092,7 @@ ${JSON.stringify(view)}`
|
|
|
23788
24092
|
}
|
|
23789
24093
|
|
|
23790
24094
|
// dist/tools/module-report.js
|
|
23791
|
-
import * as
|
|
24095
|
+
import * as path41 from "node:path";
|
|
23792
24096
|
function resolveFile(filePath, cwd) {
|
|
23793
24097
|
return resolveHostToolPath(filePath, cwd || ".");
|
|
23794
24098
|
}
|
|
@@ -23859,7 +24163,7 @@ function createModuleReportTool(getProjectRoot) {
|
|
|
23859
24163
|
content: [
|
|
23860
24164
|
{
|
|
23861
24165
|
type: "text",
|
|
23862
|
-
text: `Module report failed for ${
|
|
24166
|
+
text: `Module report failed for ${path41.basename(absFile)}: ${errorMessage2(err)}`
|
|
23863
24167
|
}
|
|
23864
24168
|
],
|
|
23865
24169
|
isError: true,
|
|
@@ -23947,7 +24251,7 @@ function createReadSymbolTool(getProjectRoot, recordSymbolRead) {
|
|
|
23947
24251
|
content: [
|
|
23948
24252
|
{
|
|
23949
24253
|
type: "text",
|
|
23950
|
-
text: `Read symbol failed for ${
|
|
24254
|
+
text: `Read symbol failed for ${path41.basename(absFile)}: ${errorMessage2(err)}`
|
|
23951
24255
|
}
|
|
23952
24256
|
],
|
|
23953
24257
|
isError: true,
|
|
@@ -23957,7 +24261,7 @@ function createReadSymbolTool(getProjectRoot, recordSymbolRead) {
|
|
|
23957
24261
|
if (!result.found) {
|
|
23958
24262
|
const warningSuffix = result.warnings?.length ? ` Warnings: ${result.warnings.join("; ")}` : "";
|
|
23959
24263
|
const suggestionSuffix = result.suggestions?.length ? ` Did you mean: ${result.suggestions.join(", ")}?` : " Use module_report to list available symbols.";
|
|
23960
|
-
const text = result.error ? `Could not inspect ${
|
|
24264
|
+
const text = result.error ? `Could not inspect ${path41.basename(absFile)}: ${result.error}${warningSuffix}` : `Symbol "${params.symbol}" not found in ${path41.basename(absFile)}.${suggestionSuffix}${warningSuffix}`;
|
|
23961
24265
|
return {
|
|
23962
24266
|
content: [{ type: "text", text }],
|
|
23963
24267
|
isError: true,
|
|
@@ -23971,7 +24275,7 @@ function createReadSymbolTool(getProjectRoot, recordSymbolRead) {
|
|
|
23971
24275
|
}
|
|
23972
24276
|
const readRecorded = recordReadCoverage(recordSymbolRead, result, "read_symbol_guard_error", toolCallId, ctx);
|
|
23973
24277
|
const ambiguityNote = result.ambiguous ? ` (${result.ambiguous.count} matches \u2014 returned the ${result.kind}; pass \`kind\` to disambiguate: ${result.ambiguous.kinds.join(", ")})` : "";
|
|
23974
|
-
const header = `${result.kind} ${result.name}${ambiguityNote} ${
|
|
24278
|
+
const header = `${result.kind} ${result.name}${ambiguityNote} ${path41.basename(result.path)}:${result.startLine}-${result.endLine}`;
|
|
23975
24279
|
const guardWarning = readRecorded ? "" : "\n\nWarning: read coverage recording failed; the returned body may not satisfy the edit guard.";
|
|
23976
24280
|
return {
|
|
23977
24281
|
content: [
|
|
@@ -24047,7 +24351,7 @@ function createReadEnclosingTool(getProjectRoot, recordSymbolRead) {
|
|
|
24047
24351
|
content: [
|
|
24048
24352
|
{
|
|
24049
24353
|
type: "text",
|
|
24050
|
-
text: `Read enclosing failed for ${
|
|
24354
|
+
text: `Read enclosing failed for ${path41.basename(absFile)}:${params.line}: ${errorMessage2(err)}`
|
|
24051
24355
|
}
|
|
24052
24356
|
],
|
|
24053
24357
|
isError: true,
|
|
@@ -24060,7 +24364,7 @@ function createReadEnclosingTool(getProjectRoot, recordSymbolRead) {
|
|
|
24060
24364
|
|
|
24061
24365
|
Nested outline:
|
|
24062
24366
|
${JSON.stringify(result.outline)}` : "";
|
|
24063
|
-
const text = result.error ? `Could not read enclosing range in ${
|
|
24367
|
+
const text = result.error ? `Could not read enclosing range in ${path41.basename(absFile)}:${result.line}: ${result.error}${warningSuffix}${outlineSuffix}` : `No enclosing symbol/callback found in ${path41.basename(absFile)}:${result.line}.${warningSuffix}`;
|
|
24064
24368
|
return {
|
|
24065
24369
|
content: [{ type: "text", text }],
|
|
24066
24370
|
isError: true,
|
|
@@ -24082,7 +24386,7 @@ ${JSON.stringify(result.outline)}` : "";
|
|
|
24082
24386
|
}
|
|
24083
24387
|
const readRecorded = recordReadCoverage(recordSymbolRead, result, "read_enclosing_guard_error", toolCallId, ctx);
|
|
24084
24388
|
const range = result.partial ? `${result.startLine}-${result.endLine} (partial of ${result.enclosingStartLine}-${result.enclosingEndLine})` : `${result.startLine}-${result.endLine}`;
|
|
24085
|
-
const header = `${result.kind} ${result.name} ${
|
|
24389
|
+
const header = `${result.kind} ${result.name} ${path41.basename(result.path)}:${range}`;
|
|
24086
24390
|
const guardWarning = readRecorded ? "" : "\n\nWarning: read coverage recording failed; the returned body may not satisfy the edit guard.";
|
|
24087
24391
|
return {
|
|
24088
24392
|
content: [
|
|
@@ -24217,7 +24521,7 @@ function createSymbolSearchTool(getProjectRoot) {
|
|
|
24217
24521
|
|
|
24218
24522
|
// dist/tools/lsp-navigation.js
|
|
24219
24523
|
import * as nodeFs4 from "node:fs";
|
|
24220
|
-
import * as
|
|
24524
|
+
import * as path42 from "node:path";
|
|
24221
24525
|
import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
24222
24526
|
|
|
24223
24527
|
// dist/tools/lsp-structured-output.js
|
|
@@ -25043,7 +25347,7 @@ function noServerAnsweredText(filePath) {
|
|
|
25043
25347
|
const { disabledServerIds, fallbackServerIds } = disabledPrimaries(filePath);
|
|
25044
25348
|
const cause = primaryUnavailableCause([...fallbackServerIds, ...disabledServerIds], disabledServerIds, fallbackServerIds);
|
|
25045
25349
|
const who = disabledServerIds.length > 0 ? `Primary LSP (${disabledServerIds.join(", ")}) did not answer` : "no language server answered";
|
|
25046
|
-
return `No LSP server available for ${
|
|
25350
|
+
return `No LSP server available for ${path42.basename(filePath)}: ${who} (${PRIMARY_UNAVAILABLE_CAUSE[cause]}).`;
|
|
25047
25351
|
}
|
|
25048
25352
|
function emptyReasonForOperation(operation) {
|
|
25049
25353
|
if (operation === "signatureHelp")
|
|
@@ -25392,7 +25696,7 @@ function collectSearchReadsForOperation(operation, result, callHierarchyItem) {
|
|
|
25392
25696
|
}
|
|
25393
25697
|
function formatCapabilities(snapshots, filePath) {
|
|
25394
25698
|
if (snapshots.length === 0) {
|
|
25395
|
-
return filePath ? `No active LSP server for ${
|
|
25699
|
+
return filePath ? `No active LSP server for ${path42.basename(filePath)}. Open/touch the file first or run another LSP operation to start the server.` : "No active LSP servers in this session.";
|
|
25396
25700
|
}
|
|
25397
25701
|
const rows = [
|
|
25398
25702
|
["definition", (s) => !!s.operationSupport.definition],
|
|
@@ -25422,7 +25726,7 @@ function formatCapabilities(snapshots, filePath) {
|
|
|
25422
25726
|
];
|
|
25423
25727
|
const lines = [];
|
|
25424
25728
|
for (const snapshot of snapshots) {
|
|
25425
|
-
const label = filePath ? `${snapshot.serverId} (${
|
|
25729
|
+
const label = filePath ? `${snapshot.serverId} (${path42.basename(filePath)})` : `${snapshot.serverId} (${snapshot.root})`;
|
|
25426
25730
|
lines.push(label);
|
|
25427
25731
|
for (const [name, supported, note] of rows) {
|
|
25428
25732
|
const suffix = note ? ` (${note})` : "";
|
|
@@ -25782,7 +26086,7 @@ function createLspNavigationTool(getFlag, mutationDeps) {
|
|
|
25782
26086
|
content: [
|
|
25783
26087
|
{
|
|
25784
26088
|
type: "text",
|
|
25785
|
-
text: `No LSP server available for ${
|
|
26089
|
+
text: `No LSP server available for ${path42.basename(filePath)}: ${NO_SERVER_REASON}.`
|
|
25786
26090
|
}
|
|
25787
26091
|
],
|
|
25788
26092
|
isError: true
|
|
@@ -25872,7 +26176,7 @@ ${JSON.stringify(result3)}${timedOutNote}${unavailableNote}${suppressedNote}${wi
|
|
|
25872
26176
|
const pythonCompileTargets = new Map(compileVerdictTargets.map((entry) => [entry.trackedFile, entry.target]));
|
|
25873
26177
|
let snapshotSuppressed = 0;
|
|
25874
26178
|
const snapshotWithheldEntries = [];
|
|
25875
|
-
const result2 = Array.from(allDiagnostics.entries()).map(([trackedFile, { diags, ts }]) => {
|
|
26179
|
+
const result2 = Array.from(allDiagnostics.entries()).map(([trackedFile, { diags, ts, closed }]) => {
|
|
25876
26180
|
let kept = diags;
|
|
25877
26181
|
if (diags.length > 0) {
|
|
25878
26182
|
const policy = applyProbeFindingPolicy(trackedFile, diags, policyCwd, readFileContent(trackedFile), "all", "lsp_navigation", pythonCompileTargets.get(trackedFile));
|
|
@@ -25884,12 +26188,17 @@ ${JSON.stringify(result3)}${timedOutNote}${unavailableNote}${suppressedNote}${wi
|
|
|
25884
26188
|
filePath: trackedFile,
|
|
25885
26189
|
diagnostics: kept,
|
|
25886
26190
|
count: kept.length,
|
|
25887
|
-
lag: formatCacheAgeLabel(ts)
|
|
26191
|
+
lag: formatCacheAgeLabel(ts),
|
|
26192
|
+
// #5700: the open-document cap closed this file on its server,
|
|
26193
|
+
// which no longer re-checks it; a touch opens it again.
|
|
26194
|
+
...closed && { closed: true }
|
|
25888
26195
|
};
|
|
25889
26196
|
});
|
|
25890
26197
|
const snapshotSuppressedLine = dispositionSuppressedLine(snapshotSuppressed);
|
|
25891
26198
|
const snapshotWithheld = mergeWithheld(snapshotWithheldEntries);
|
|
25892
26199
|
const snapshotWithheldLine = withheldCompileNote(snapshotWithheld);
|
|
26200
|
+
const closedRows = result2.reduce((count, row) => count + (row.closed ? 1 : 0), 0);
|
|
26201
|
+
const snapshotClosedLine = closedRows > 0 ? `${closedRows} file(s) with closed: true were closed on their server by the open-document cap; their rows are the last findings, not a re-check. Provide path to check one again.` : void 0;
|
|
25893
26202
|
const noteMap2 = {
|
|
25894
26203
|
"push-only": "Note: push-only tracked diagnostics snapshot (not full workspace pull diagnostics).",
|
|
25895
26204
|
pull: "Note: tracked diagnostics snapshot from active clients. Provide path to force file-level diagnostics collection"
|
|
@@ -25902,7 +26211,8 @@ ${JSON.stringify(result3)}${timedOutNote}${unavailableNote}${suppressedNote}${wi
|
|
|
25902
26211
|
text: `${note}
|
|
25903
26212
|
${JSON.stringify(result2)}${snapshotSuppressedLine ? `
|
|
25904
26213
|
Note: ${snapshotSuppressedLine}` : ""}${snapshotWithheldLine ? `
|
|
25905
|
-
Note: ${snapshotWithheldLine}` : ""}`
|
|
26214
|
+
Note: ${snapshotWithheldLine}` : ""}${snapshotClosedLine ? `
|
|
26215
|
+
Note: ${snapshotClosedLine}` : ""}`
|
|
25906
26216
|
}
|
|
25907
26217
|
],
|
|
25908
26218
|
details: {
|
|
@@ -25947,7 +26257,7 @@ Note: ${snapshotWithheldLine}` : ""}`
|
|
|
25947
26257
|
content: [
|
|
25948
26258
|
{
|
|
25949
26259
|
type: "text",
|
|
25950
|
-
text: disabledPrimaries(filePath).disabledServerIds.length > 0 ? noServerAnsweredText(filePath) : `No LSP server available for ${
|
|
26260
|
+
text: disabledPrimaries(filePath).disabledServerIds.length > 0 ? noServerAnsweredText(filePath) : `No LSP server available for ${path42.basename(filePath)}: ${NO_SERVER_REASON}.`
|
|
25951
26261
|
}
|
|
25952
26262
|
],
|
|
25953
26263
|
isError: true
|
|
@@ -25967,7 +26277,7 @@ Note: ${snapshotWithheldLine}` : ""}`
|
|
|
25967
26277
|
content: [
|
|
25968
26278
|
{
|
|
25969
26279
|
type: "text",
|
|
25970
|
-
text: `LSP server for ${
|
|
26280
|
+
text: `LSP server for ${path42.basename(filePath)} does not advertise support for ${operation}`
|
|
25971
26281
|
}
|
|
25972
26282
|
],
|
|
25973
26283
|
isError: true,
|
|
@@ -26021,7 +26331,7 @@ Note: ${snapshotWithheldLine}` : ""}`
|
|
|
26021
26331
|
const msg = err instanceof Error ? err.message : String(err);
|
|
26022
26332
|
if (rawPath && /No Project/i.test(msg)) {
|
|
26023
26333
|
await openFileBestEffort(lspService, filePath);
|
|
26024
|
-
await new Promise((
|
|
26334
|
+
await new Promise((resolve32) => setTimeout(resolve32, 120));
|
|
26025
26335
|
const retryRaw = await lspService.workspaceSymbol(query ?? "", filePath);
|
|
26026
26336
|
const retrySymbols = (Array.isArray(retryRaw) ? retryRaw : [retryRaw]).filter((s) => typeof s === "object" && s !== null);
|
|
26027
26337
|
return dedupeWorkspaceSymbols(retrySymbols);
|
|
@@ -26276,7 +26586,7 @@ Note: ${snapshotWithheldLine}` : ""}`
|
|
|
26276
26586
|
isError: true
|
|
26277
26587
|
}, { operation, filePath, failureKind: "no_server", resultCount: 0 });
|
|
26278
26588
|
}
|
|
26279
|
-
const fileCtx = filePath ? " at " +
|
|
26589
|
+
const fileCtx = filePath ? " at " + path42.basename(filePath) : "";
|
|
26280
26590
|
const lineCtx = line ? ":" + line + ":" + character : "";
|
|
26281
26591
|
let output = isEmpty ? "No results for " + operation + fileCtx + lineCtx : JSON.stringify(result);
|
|
26282
26592
|
if (isEmpty && operation === "workspaceSymbol" && !rawPath) {
|
|
@@ -26466,10 +26776,10 @@ Not run: ${reasons.join("; ")}.`
|
|
|
26466
26776
|
}
|
|
26467
26777
|
|
|
26468
26778
|
// dist/mcp/build-staleness.js
|
|
26469
|
-
import * as
|
|
26779
|
+
import * as fs25 from "node:fs";
|
|
26470
26780
|
var realStat = (targetPath) => {
|
|
26471
26781
|
try {
|
|
26472
|
-
return
|
|
26782
|
+
return fs25.statSync(targetPath);
|
|
26473
26783
|
} catch {
|
|
26474
26784
|
return void 0;
|
|
26475
26785
|
}
|
|
@@ -26573,11 +26883,11 @@ function resolveDefaultCwd() {
|
|
|
26573
26883
|
const fromArg = process.argv.find((arg) => arg.startsWith("--cwd="))?.slice("--cwd=".length);
|
|
26574
26884
|
return fromArg ?? process.env.PI_LENS_MCP_CWD ?? process.cwd();
|
|
26575
26885
|
}
|
|
26576
|
-
var DEFAULT_CWD =
|
|
26886
|
+
var DEFAULT_CWD = path43.resolve(resolveDefaultCwd());
|
|
26577
26887
|
var lspReadyCwds = /* @__PURE__ */ new Set();
|
|
26578
26888
|
var SERVER_FILE = fileURLToPath3(import.meta.url);
|
|
26579
|
-
var SERVER_DIR =
|
|
26580
|
-
var WORKER_PATH =
|
|
26889
|
+
var SERVER_DIR = path43.dirname(SERVER_FILE);
|
|
26890
|
+
var WORKER_PATH = path43.join(SERVER_DIR, "worker.js");
|
|
26581
26891
|
var REBUILD_SCRIPT = resolveRebuildScript(SERVER_FILE);
|
|
26582
26892
|
var STALENESS_STAT_PATH = process.env.PI_LENS_MCP_STALENESS_STAT_PATH ?? SERVER_FILE;
|
|
26583
26893
|
var BUILD_STAMP = computeBuildStamp(STALENESS_STAT_PATH);
|
|
@@ -26598,21 +26908,21 @@ function isWarmBuildStale() {
|
|
|
26598
26908
|
}
|
|
26599
26909
|
function findRepoRoot(start) {
|
|
26600
26910
|
for (const dir of walkUpDirs(start, { maxDepth: 6 })) {
|
|
26601
|
-
const pkgPath =
|
|
26602
|
-
if (
|
|
26911
|
+
const pkgPath = path43.join(dir, "package.json");
|
|
26912
|
+
if (fs26.existsSync(pkgPath)) {
|
|
26603
26913
|
try {
|
|
26604
|
-
const pkg = JSON.parse(
|
|
26914
|
+
const pkg = JSON.parse(fs26.readFileSync(pkgPath, "utf8"));
|
|
26605
26915
|
if (pkg.name === "pi-lens")
|
|
26606
26916
|
return dir;
|
|
26607
26917
|
} catch {
|
|
26608
26918
|
}
|
|
26609
26919
|
}
|
|
26610
26920
|
}
|
|
26611
|
-
return
|
|
26921
|
+
return path43.resolve(start, "..", "..");
|
|
26612
26922
|
}
|
|
26613
|
-
var REPO_ROOT = process.env.PI_LENS_MCP_REPO_ROOT ?
|
|
26923
|
+
var REPO_ROOT = process.env.PI_LENS_MCP_REPO_ROOT ? path43.resolve(process.env.PI_LENS_MCP_REPO_ROOT) : findRepoRoot(SERVER_DIR);
|
|
26614
26924
|
async function ensureReady(cwd) {
|
|
26615
|
-
const normalized =
|
|
26925
|
+
const normalized = path43.resolve(cwd);
|
|
26616
26926
|
if (!shouldInitializeSessionRoot(normalized, lspReadyCwds)) {
|
|
26617
26927
|
return;
|
|
26618
26928
|
}
|
|
@@ -26658,12 +26968,12 @@ function getAutoSessionStatus() {
|
|
|
26658
26968
|
}
|
|
26659
26969
|
var IPC_PATH = ipcPathForCwd(DEFAULT_CWD);
|
|
26660
26970
|
function rejectForeignTurnCwd(route, cwd) {
|
|
26661
|
-
const message = `${route} cwd outside this server's workspace: ${
|
|
26971
|
+
const message = `${route} cwd outside this server's workspace: ${path43.resolve(cwd)} not within ${DEFAULT_CWD}`;
|
|
26662
26972
|
console.error(`[pi-lens-mcp] rejected ${message}`);
|
|
26663
26973
|
return message;
|
|
26664
26974
|
}
|
|
26665
26975
|
function isWithinServerWorkspace(cwd) {
|
|
26666
|
-
return isUnderDir(
|
|
26976
|
+
return isUnderDir(path43.resolve(cwd), DEFAULT_CWD);
|
|
26667
26977
|
}
|
|
26668
26978
|
function startIpcServer() {
|
|
26669
26979
|
const bound = boundUnixSocketPath(IPC_PATH);
|
|
@@ -27021,7 +27331,7 @@ function enabledToolsForCwd(cwd) {
|
|
|
27021
27331
|
function formatAnalyze(result, cwd, mode, servedBy) {
|
|
27022
27332
|
const lspNote = result.lsp ? ` \xB7 lsp ${result.lsp.diagnosticCount} (${result.lsp.status}${result.lsp.failureKind ? `: ${result.lsp.failureKind}` : ""}, ${result.lsp.durationMs}ms)` : "";
|
|
27023
27333
|
const notChecked = verdictUncheckedReason(result.verdict);
|
|
27024
|
-
const summary = `${
|
|
27334
|
+
const summary = `${path43.relative(cwd, result.filePath) || result.filePath} [${mode}] \u2014 ${result.counts.blockers} blocking, ${result.counts.warnings} warning(s), ${result.counts.advisories} advisory(ies), ${result.counts.diagnostics} total` + // #5287: zero counts beside a check that never completed are not a clean
|
|
27025
27335
|
// file, so the summary says so beside them.
|
|
27026
27336
|
// A worker reply from an older build carries no verdict (the facade casts
|
|
27027
27337
|
// it unvalidated), which the shared reader also treats as unchecked.
|
|
@@ -27162,7 +27472,7 @@ ${outcome.output}`, {
|
|
|
27162
27472
|
}
|
|
27163
27473
|
const { deduped, byRule, byFile } = summarizeScan(snapshot.diagnostics);
|
|
27164
27474
|
const topRules = Object.entries(byRule).sort((a, b) => b[1] - a[1]);
|
|
27165
|
-
const topFiles = Object.entries(byFile).sort((a, b) => b[1] - a[1]).slice(0, 15).map(([file, count]) => ({ file:
|
|
27475
|
+
const topFiles = Object.entries(byFile).sort((a, b) => b[1] - a[1]).slice(0, 15).map(([file, count]) => ({ file: path43.relative(cwd, file), count }));
|
|
27166
27476
|
const summaryLines = [
|
|
27167
27477
|
`Scanned ${snapshot.filesScanned} file(s) [${snapshot.runners.join(", ")}] \u2192 ${deduped.length} unique diagnostic(s)` + (snapshot.diagnostics.length !== deduped.length ? ` (${snapshot.diagnostics.length} raw, ${snapshot.diagnostics.length - deduped.length} duplicate)` : ""),
|
|
27168
27478
|
...topRules.slice(0, 12).map(([rule, count]) => ` ${count}\xD7 ${rule}`)
|
|
@@ -27298,7 +27608,7 @@ ${graphStaleness}` : rendered;
|
|
|
27298
27608
|
const result = await readSymbol(file, symbol, cwd, { kind });
|
|
27299
27609
|
if (!result.found && result.error) {
|
|
27300
27610
|
return {
|
|
27301
|
-
...renderToolText(`Could not inspect ${
|
|
27611
|
+
...renderToolText(`Could not inspect ${path43.basename(file)}: ${result.error}`, {
|
|
27302
27612
|
found: false,
|
|
27303
27613
|
error: result.error,
|
|
27304
27614
|
...result.warnings ? { warnings: result.warnings } : {}
|
|
@@ -27309,7 +27619,7 @@ ${graphStaleness}` : rendered;
|
|
|
27309
27619
|
if (!result.found) {
|
|
27310
27620
|
const suggestionSuffix = result.suggestions?.length ? ` Did you mean: ${result.suggestions.join(", ")}?` : " Use pilens_module_report to list symbols.";
|
|
27311
27621
|
return {
|
|
27312
|
-
...renderToolText(`Symbol "${symbol}" not found in ${
|
|
27622
|
+
...renderToolText(`Symbol "${symbol}" not found in ${path43.basename(file)}.${suggestionSuffix}`, {
|
|
27313
27623
|
found: false,
|
|
27314
27624
|
...result.suggestions ? { suggestions: result.suggestions } : {},
|
|
27315
27625
|
...result.warnings ? { warnings: result.warnings } : {}
|
|
@@ -27319,7 +27629,7 @@ ${graphStaleness}` : rendered;
|
|
|
27319
27629
|
}
|
|
27320
27630
|
const sigSuffix = result.signature ? ` ${result.signature}` : "";
|
|
27321
27631
|
const ambiguityNote = result.ambiguous ? ` (${result.ambiguous.count} matches \u2014 returned the ${result.kind}; pass \`kind\` to disambiguate: ${result.ambiguous.kinds.join(", ")})` : "";
|
|
27322
|
-
const header = `${result.kind} ${result.name}${ambiguityNote}${sigSuffix} ${
|
|
27632
|
+
const header = `${result.kind} ${result.name}${ambiguityNote}${sigSuffix} ${path43.relative(cwd, result.path)}:${result.startLine}-${result.endLine}`;
|
|
27323
27633
|
return {
|
|
27324
27634
|
content: [
|
|
27325
27635
|
{
|
|
@@ -27360,14 +27670,14 @@ ${result.source ?? ""}`
|
|
|
27360
27670
|
|
|
27361
27671
|
Nested outline:
|
|
27362
27672
|
${JSON.stringify(result.outline)}` : "";
|
|
27363
|
-
const text = result.error ? `Could not read enclosing range in ${
|
|
27673
|
+
const text = result.error ? `Could not read enclosing range in ${path43.basename(file)}:${result.line}: ${result.error}${warningSuffix}${outlineSuffix}` : `No enclosing symbol/callback found in ${path43.basename(file)}:${result.line}.${warningSuffix}`;
|
|
27364
27674
|
return {
|
|
27365
27675
|
...renderToolText(text, { found: false, line: result.line }),
|
|
27366
27676
|
isError: true
|
|
27367
27677
|
};
|
|
27368
27678
|
}
|
|
27369
27679
|
const range = result.partial ? `${result.startLine}-${result.endLine} (partial of ${result.enclosingStartLine}-${result.enclosingEndLine})` : `${result.startLine}-${result.endLine}`;
|
|
27370
|
-
const header = `${result.kind} ${result.name} ${
|
|
27680
|
+
const header = `${result.kind} ${result.name} ${path43.relative(cwd, result.path)}:${range}`;
|
|
27371
27681
|
return {
|
|
27372
27682
|
content: [
|
|
27373
27683
|
{
|
|
@@ -27402,7 +27712,7 @@ ${result.source ?? ""}`
|
|
|
27402
27712
|
]),
|
|
27403
27713
|
...renderLspBrokenStatusLines(brokenServers),
|
|
27404
27714
|
...renderDegradationLines(degradations),
|
|
27405
|
-
last ? `Last dispatch: ${
|
|
27715
|
+
last ? `Last dispatch: ${path43.basename(last.filePath)} \u2014 ${last.totalDurationMs}ms, ${last.totalDiagnostics} diagnostic(s)` : "Last dispatch: none yet",
|
|
27406
27716
|
`Diagnostics this session: ${stats.totalShown} shown \xB7 ${stats.totalAutoFixed} auto-fixed \xB7 ${stats.totalUnresolved} unresolved`,
|
|
27407
27717
|
autoSession ? `Auto session_start: ${autoSession.succeeded ? "succeeded" : autoSession.error ? "FAILED" : autoSession.attempted ? "in progress" : "not yet attempted"}${autoSession.firedAt ? ` (fired ${autoSession.firedAt})` : ""}${autoSession.error ? ` \u2014 ${autoSession.error}` : ""}` : "Auto session_start: disabled (PI_LENS_MCP_AUTO_SESSION not set)",
|
|
27408
27718
|
turnEnd ? `Stop-hook turn-end: ${turnEnd.ran} ran \xB7 ${turnEnd.skipped} skipped${turnEnd.lastRunAt ? ` (last ran ${turnEnd.lastRunAt})` : ""}${turnEnd.lastSkipReason ? ` \u2014 last skip: ${turnEnd.lastSkipReason}${turnEnd.lastSkipAt ? ` at ${turnEnd.lastSkipAt}` : ""}` : ""}` : "Stop-hook turn-end: no activity recorded (hook not installed, or no Stop yet)",
|
|
@@ -27471,7 +27781,7 @@ ${result.source ?? ""}`
|
|
|
27471
27781
|
const limit = typeof args.limit === "number" && Number.isFinite(args.limit) ? Math.max(1, Math.floor(args.limit)) : 5;
|
|
27472
27782
|
const fileFilter = typeof args.file === "string" ? args.file : void 0;
|
|
27473
27783
|
const recent = recentLatency(limit, fileFilter);
|
|
27474
|
-
const summary = recent.length === 0 ? "No dispatch latency reports yet." : recent.map((report) => `${
|
|
27784
|
+
const summary = recent.length === 0 ? "No dispatch latency reports yet." : recent.map((report) => `${path43.basename(report.filePath)}: ${report.totalDurationMs}ms (${report.totalDiagnostics} diag${report.stoppedEarly ? ", stopped early" : ""})`).join("\n");
|
|
27475
27785
|
return renderToolText(summary, recent);
|
|
27476
27786
|
}
|
|
27477
27787
|
if (name === "pilens_session_start") {
|
|
@@ -27664,4 +27974,5 @@ process.stdin.on("end", () => {
|
|
|
27664
27974
|
void flushExtensionLog().finally(() => process.exit(0));
|
|
27665
27975
|
});
|
|
27666
27976
|
startIpcServer();
|
|
27977
|
+
void sweepOrphans();
|
|
27667
27978
|
console.error(`[pi-lens-mcp] ready (cwd=${DEFAULT_CWD})`);
|