pi-lens 4.5.0 → 4.5.2
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-USER.md +12 -12
- package/CHANGELOG.md +253 -0
- package/README.md +11 -2
- package/config/dependency-cruiser-eager-allowlist.json +1 -0
- package/dist/{chunk-ZULZS2I6.js → chunk-2ERVW2UF.js} +1115 -423
- package/dist/{chunk-BBSDJTOV.js → chunk-2K7BUOKS.js} +13 -13
- package/dist/{chunk-I2FYOZNW.js → chunk-3JJ4OAJI.js} +10 -10
- package/dist/{chunk-5JB4WENL.js → chunk-3UHGSUVL.js} +1 -1
- package/dist/{chunk-W26QZ3OM.js → chunk-463WN3VP.js} +10 -10
- package/dist/{chunk-4IZZEN63.js → chunk-4X3ML2UQ.js} +31 -34
- package/dist/{chunk-I3NZVAMN.js → chunk-5BI5YP57.js} +10 -10
- package/dist/{chunk-7U36VQL6.js → chunk-5Z4XLUFF.js} +3 -3
- package/dist/{chunk-DCA2MXVQ.js → chunk-62AJH3IN.js} +51 -29
- package/dist/{chunk-37IDWT6O.js → chunk-6F34GMP7.js} +16 -14
- package/dist/{chunk-VSQT6IHZ.js → chunk-6LIUVGOR.js} +28 -4
- package/dist/{chunk-27JQHK7Y.js → chunk-6REF4GCO.js} +1 -1
- package/dist/{chunk-INBK3HIT.js → chunk-7KRR24GO.js} +3 -3
- package/dist/{chunk-OZQQ3AIR.js → chunk-7OMOMBEQ.js} +9 -9
- package/dist/{chunk-ARTYCUGF.js → chunk-7ZFXICNN.js} +123 -20
- package/dist/{chunk-K4Z7MK6T.js → chunk-ABKRQVOY.js} +28 -52
- package/dist/{chunk-C5PLBTNR.js → chunk-ANSLRJBG.js} +1 -1
- package/dist/{chunk-HRLF35WL.js → chunk-AWMFBPGJ.js} +9 -9
- package/dist/{chunk-CXQYK4YT.js → chunk-BG7KHGNX.js} +2 -2
- package/dist/{chunk-ZI7YHV6I.js → chunk-BK2R2223.js} +10 -8
- package/dist/chunk-BXXC6KRR.js +107 -0
- package/dist/{chunk-QMWKSYWB.js → chunk-CKJS2AUI.js} +4 -4
- package/dist/{chunk-PPQHMSPH.js → chunk-COGU5KQJ.js} +15 -15
- package/dist/{chunk-NHA5K226.js → chunk-CQNXALZJ.js} +27 -6
- package/dist/{chunk-KZ732ZVW.js → chunk-CSZESDPP.js} +1 -1
- package/dist/chunk-CZ5TCJPB.js +98 -0
- package/dist/{chunk-LOEJFTF2.js → chunk-D2LFEA5U.js} +9 -2
- package/dist/chunk-D3KLF5CD.js +50 -0
- package/dist/{chunk-4DAHGU3V.js → chunk-ENJ2M76Y.js} +31 -29
- package/dist/{chunk-ZQSSO7LO.js → chunk-EQKF6BAK.js} +3 -3
- package/dist/{chunk-PFJLYRO3.js → chunk-F2SAP2FM.js} +40 -47
- package/dist/{chunk-ADYQRETD.js → chunk-F6QAJXQV.js} +2 -2
- package/dist/chunk-GR2QDWH5.js +25 -0
- package/dist/{chunk-LVLPA32Q.js → chunk-GVE5VZYQ.js} +48 -11
- package/dist/{chunk-AZG5UJYY.js → chunk-GWZZOJD2.js} +1 -1
- package/dist/chunk-GZS6VPIE.js +27 -0
- package/dist/chunk-H4B4SC7I.js +71 -0
- package/dist/{chunk-YCR6ZYTE.js → chunk-HA6TUJOE.js} +1 -1
- package/dist/{chunk-DI4AZZNY.js → chunk-HKPJTI47.js} +2 -2
- package/dist/{chunk-O6LCSHHI.js → chunk-HPKC55MA.js} +1 -1
- package/dist/{chunk-LQQNFCQJ.js → chunk-I65CQLCG.js} +1 -1
- package/dist/{chunk-P5MSLVUW.js → chunk-IDKLWVKY.js} +11 -11
- package/dist/chunk-IUM2Q7NF.js +25 -0
- package/dist/{chunk-L6BDRYUK.js → chunk-J24IS3KZ.js} +5 -5
- package/dist/{chunk-KNSOA43J.js → chunk-J2DAHH4T.js} +2 -2
- package/dist/{chunk-7ZVTFLCC.js → chunk-JBDZVOFL.js} +11 -11
- package/dist/{chunk-HIJ4CHFF.js → chunk-JC6NFC57.js} +3 -3
- package/dist/{chunk-K7O6AHSJ.js → chunk-JTHEUTW7.js} +11 -11
- package/dist/{chunk-KXGTLAUW.js → chunk-JWW3ODBN.js} +2 -2
- package/dist/{chunk-HIRBC72R.js → chunk-K3ZIYLHT.js} +4 -4
- package/dist/{chunk-6GLMMGCX.js → chunk-KDPZA2UE.js} +2 -3
- package/dist/{chunk-AXAR5ZW2.js → chunk-KMY2OU4T.js} +553 -434
- package/dist/{chunk-DFKOA74L.js → chunk-KQF7VT26.js} +10 -10
- package/dist/{chunk-S6MCMD27.js → chunk-KVGA7X76.js} +3 -3
- package/dist/{chunk-74AMPWNC.js → chunk-KW7O72AK.js} +2 -2
- package/dist/{chunk-UN72ZAJ5.js → chunk-LEQTVRSV.js} +9 -9
- package/dist/{chunk-B42AIWPJ.js → chunk-LKPSBM6S.js} +3 -3
- package/dist/{chunk-R4L7KZ7R.js → chunk-LKW2HFSZ.js} +9 -9
- package/dist/{chunk-3PO4YYOX.js → chunk-LURFD4HD.js} +4240 -3734
- package/dist/{chunk-PQXUZYTQ.js → chunk-M6ELTECW.js} +4 -4
- package/dist/{chunk-3QXFUP6T.js → chunk-MGVVYYKW.js} +12 -12
- package/dist/{chunk-CZJGAOKL.js → chunk-MQBKGRSB.js} +7 -7
- package/dist/{chunk-NNEQOC3U.js → chunk-MVG2ZEAO.js} +9 -7
- package/dist/{chunk-VWEBZ2JV.js → chunk-MY4XNNTX.js} +39 -41
- package/dist/{chunk-RIH3UBK4.js → chunk-N4AJVFRF.js} +11 -11
- package/dist/{chunk-TKOFTLGB.js → chunk-OFKKMXWM.js} +31 -36
- package/dist/{chunk-3PAS2ERX.js → chunk-OFZE4ANN.js} +8 -8
- package/dist/chunk-OLXBUTJR.js +61 -0
- package/dist/{chunk-6CFSDLHE.js → chunk-OZGEHOSG.js} +38 -17
- package/dist/{chunk-3TSMQZG6.js → chunk-PKGOROPQ.js} +40 -2
- package/dist/{chunk-OLWGYBYT.js → chunk-Q6D5QKRG.js} +17 -17
- package/dist/{chunk-QE7BJQ6K.js → chunk-QECLJFHI.js} +12 -17
- package/dist/{chunk-RJ3APNIP.js → chunk-QJA33VD5.js} +4 -4
- package/dist/{chunk-MOAVEPC4.js → chunk-R5XVJ6AN.js} +11 -11
- package/dist/{chunk-ZRQMENT4.js → chunk-REZL4OM4.js} +1 -1
- package/dist/{chunk-PKWEBMCA.js → chunk-RK5RBREN.js} +251 -201
- package/dist/chunk-RP5ZQTHO.js +86 -0
- package/dist/{chunk-J2ZB5MDS.js → chunk-RURPX2YV.js} +23 -23
- package/dist/chunk-TB5MGZLS.js +53 -0
- package/dist/chunk-TC63XRYP.js +27 -0
- package/dist/chunk-TJOYHAXJ.js +69 -0
- package/dist/{chunk-Q7J3JYJ2.js → chunk-TRXKDCBP.js} +13 -13
- package/dist/{chunk-6E5QLMWI.js → chunk-TTK37D7R.js} +22 -23
- package/dist/{chunk-XDNWR7SG.js → chunk-UH3QHLR5.js} +2 -2
- package/dist/{chunk-SCU62JLX.js → chunk-UNTJJ7GN.js} +7 -7
- package/dist/{chunk-O2MHF7QM.js → chunk-UPAFSETJ.js} +58 -63
- package/dist/{chunk-PQF6YGYB.js → chunk-UX75PTQW.js} +50 -31
- package/dist/{chunk-TWEOJE3D.js → chunk-V353PYMK.js} +1233 -576
- package/dist/{chunk-CQY2HEH7.js → chunk-V4TFQY5G.js} +2 -2
- package/dist/{chunk-B2OXE4AH.js → chunk-VC3W54G3.js} +446 -293
- package/dist/{chunk-JGUDT5KD.js → chunk-VSBCJVPC.js} +5 -5
- package/dist/{chunk-5HBQL7DH.js → chunk-WAQQGXVV.js} +3 -3
- package/dist/{chunk-7DPXUPRF.js → chunk-WLEVWR7Y.js} +2 -2
- package/dist/{chunk-QE5DJ7MX.js → chunk-WPMPVP5I.js} +4 -4
- package/dist/{chunk-KNJH6WJQ.js → chunk-WXNLFOC2.js} +7 -7
- package/dist/{chunk-XSC3BCN3.js → chunk-Y3ZNOZZS.js} +6 -6
- package/dist/{chunk-VGRGW4UL.js → chunk-YL6JQTWC.js} +29 -32
- package/dist/{chunk-7CLWC2UH.js → chunk-YVE5Q2UU.js} +86 -217
- package/dist/{chunk-LGH2HHZG.js → chunk-YZNARDMM.js} +42 -28
- package/dist/{chunk-NGNBJIUO.js → chunk-ZDWNFZJ2.js} +8 -8
- package/dist/{chunk-X33QECRJ.js → chunk-ZEUF7BIN.js} +2 -2
- package/dist/{chunk-2H5GHZKC.js → chunk-ZIF4WLWR.js} +45 -25
- package/dist/{chunk-WLD6BGON.js → chunk-ZSPVF7KI.js} +231 -24
- package/dist/{chunk-SDYLT45T.js → chunk-ZX6OKBVO.js} +2 -2
- package/dist/index.js +10566 -6819
- package/dist/mcp/analyze-cli.js +8 -8
- package/dist/mcp/cli.js +39 -41
- package/dist/mcp/server.js +1083 -685
- package/dist/mcp/worker.js +68 -59
- package/dist/probes/installer.js +21 -22
- package/docs/ci-bot-pr-checks.md +18 -9
- package/docs/ci.md +7 -0
- package/docs/configuration.md +24 -10
- package/docs/defect-shapes.md +61 -30
- package/docs/environment-variables.md +18 -9
- package/docs/globalconfig.md +17 -0
- package/docs/invariants/dispatch-runners.md +22 -0
- package/docs/invariants/lsp-trust-exec.md +33 -3
- package/docs/lsp-capability-matrix.md +23 -10
- package/docs/lsp-idle-eviction.md +7 -1
- package/docs/module-report-read-symbol.md +6 -2
- package/docs/pi-lens-merge-policy.md +3 -2
- package/docs/pi-lens-orchestration.md +2 -1
- package/docs/pi-lens-subagent.md +2 -1
- package/docs/release-qa-baseline.md +22 -17
- package/docs/servercapabilities.md +1 -1
- package/docs/settings.md +10 -2
- package/docs/tools.md +1 -1
- package/docs/usage.md +1 -0
- package/package.json +3 -3
- package/dist/chunk-2H7NFZ4Q.js +0 -25
- package/dist/chunk-5YJXF2IS.js +0 -56
- package/dist/chunk-7WKVCZI4.js +0 -69
- package/dist/chunk-BKWFDWYM.js +0 -46
- package/dist/chunk-G53LBDNU.js +0 -255
- package/dist/chunk-GCSDF5IE.js +0 -27
- package/dist/chunk-H5API74E.js +0 -67
- package/dist/chunk-HBX55MWO.js +0 -27
- package/dist/chunk-JOIKBUQN.js +0 -88
- package/dist/chunk-M2YMBT5G.js +0 -73
- package/dist/chunk-MJRGPEQ5.js +0 -25
- package/dist/chunk-QV3JPCMK.js +0 -17
- package/dist/chunk-TFKN5EIR.js +0 -27
- package/dist/chunk-UNP6Y4JV.js +0 -38
package/dist/mcp/server.js
CHANGED
|
@@ -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,51 +117,53 @@ 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,
|
|
133
|
+
existingDependencyManifests,
|
|
134
134
|
trivyEvidenceFiles
|
|
135
|
-
} from "../chunk-
|
|
136
|
-
import "../chunk-
|
|
137
|
-
import "../chunk-
|
|
138
|
-
import "../chunk-
|
|
139
|
-
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";
|
|
140
140
|
import {
|
|
141
141
|
resetRustAvailability
|
|
142
|
-
} from "../chunk-
|
|
143
|
-
import "../chunk-
|
|
144
|
-
import "../chunk-
|
|
142
|
+
} from "../chunk-UH3QHLR5.js";
|
|
143
|
+
import "../chunk-CKJS2AUI.js";
|
|
144
|
+
import "../chunk-QECLJFHI.js";
|
|
145
145
|
import {
|
|
146
146
|
resetDispatchAvailabilityState,
|
|
147
|
-
resolveManagedToolClient
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
import "../chunk-
|
|
151
|
-
import "../chunk-
|
|
152
|
-
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";
|
|
153
154
|
import {
|
|
154
155
|
SYMBOL_KIND_NAMES,
|
|
155
156
|
captureReviewGraphStructuralIr,
|
|
156
157
|
formatReviewGraphRevisionDriftNote,
|
|
157
158
|
publishReviewGraphFileIr,
|
|
158
159
|
reviewGraphIrContentHash
|
|
159
|
-
} from "../chunk-
|
|
160
|
+
} from "../chunk-ENJ2M76Y.js";
|
|
160
161
|
import {
|
|
161
162
|
buildSymbolId
|
|
162
163
|
} from "../chunk-3MED75HT.js";
|
|
163
164
|
import "../chunk-PKLB2XJL.js";
|
|
164
165
|
import {
|
|
166
|
+
BELOW_ROOT_CONFIG_FILE_NAMES,
|
|
165
167
|
MAX_LATE_AUX_REARMS,
|
|
166
168
|
PAST_EOF_STALE_MARKER,
|
|
167
169
|
PRIMARY_UNAVAILABLE_CAUSE,
|
|
@@ -262,6 +264,8 @@ import {
|
|
|
262
264
|
runPerServerGroups,
|
|
263
265
|
scopeCell,
|
|
264
266
|
sessionCell,
|
|
267
|
+
sessionStateFileName,
|
|
268
|
+
sessionsDir,
|
|
265
269
|
setSessionLanguages,
|
|
266
270
|
shouldShortenLspIdleTimeout,
|
|
267
271
|
summarizeWorkspaceEdit,
|
|
@@ -272,7 +276,7 @@ import {
|
|
|
272
276
|
widgetDiagnosticUri,
|
|
273
277
|
writeOrderToken,
|
|
274
278
|
writeSourceFile
|
|
275
|
-
} from "../chunk-
|
|
279
|
+
} from "../chunk-V353PYMK.js";
|
|
276
280
|
import {
|
|
277
281
|
ANY_POSITION,
|
|
278
282
|
foldedFindingIdentity,
|
|
@@ -281,8 +285,9 @@ import {
|
|
|
281
285
|
primePersistedMutationAttribution,
|
|
282
286
|
resetMutationAttribution,
|
|
283
287
|
retainRecordedFindings,
|
|
288
|
+
sanitizeCorrelationId,
|
|
284
289
|
stableFindingId
|
|
285
|
-
} from "../chunk-
|
|
290
|
+
} from "../chunk-6LIUVGOR.js";
|
|
286
291
|
import {
|
|
287
292
|
mapWithConcurrency
|
|
288
293
|
} from "../chunk-XIMYZ3JA.js";
|
|
@@ -308,8 +313,7 @@ import {
|
|
|
308
313
|
resetLSPCaseSensitivityState,
|
|
309
314
|
resolveLspCwdForFile,
|
|
310
315
|
shouldInitializeSessionRoot
|
|
311
|
-
} from "../chunk-
|
|
312
|
-
import "../chunk-7WKVCZI4.js";
|
|
316
|
+
} from "../chunk-KMY2OU4T.js";
|
|
313
317
|
import {
|
|
314
318
|
PROJECT_VENV_DIR_NAMES,
|
|
315
319
|
PYTHON_DECLARATION_CONCURRENCY,
|
|
@@ -320,31 +324,15 @@ import {
|
|
|
320
324
|
isJediCompileVerdict,
|
|
321
325
|
partitionOutrankedPythonCompileVerdicts,
|
|
322
326
|
recordPythonCompileVerdictDrop,
|
|
323
|
-
resetBoundedTelemetry
|
|
324
|
-
} from "../chunk-2H5GHZKC.js";
|
|
325
|
-
import {
|
|
327
|
+
resetBoundedTelemetry,
|
|
326
328
|
scannerReportParentDir
|
|
327
|
-
} from "../chunk-
|
|
328
|
-
import {
|
|
329
|
-
PROJECT_SNAPSHOT_VERSION,
|
|
330
|
-
getProjectSnapshotLegacyPath,
|
|
331
|
-
getProjectSnapshotPath,
|
|
332
|
-
hydrateRuntimeFromProjectSnapshot,
|
|
333
|
-
hydrateRuntimeFromProjectSnapshotIfIdle,
|
|
334
|
-
isProjectSnapshotFresh,
|
|
335
|
-
isProjectSnapshotMetaStale,
|
|
336
|
-
loadProjectSnapshot,
|
|
337
|
-
loadProjectSnapshotExportsAndRules,
|
|
338
|
-
loadProjectSnapshotWithoutWordIndex,
|
|
339
|
-
readProjectSnapshotMeta,
|
|
340
|
-
saveRuntimeProjectSnapshot
|
|
341
|
-
} from "../chunk-NNEQOC3U.js";
|
|
329
|
+
} from "../chunk-ZIF4WLWR.js";
|
|
342
330
|
import {
|
|
343
331
|
SWEEP_IDLE_SAFETY_MARGIN_MS,
|
|
344
332
|
getFullScanWallClockMs,
|
|
345
333
|
isWorkspaceSweepActive,
|
|
346
334
|
runWhenWorkspaceSweepIdle
|
|
347
|
-
} from "../chunk-
|
|
335
|
+
} from "../chunk-I65CQLCG.js";
|
|
348
336
|
import "../chunk-5W3R6LFT.js";
|
|
349
337
|
import {
|
|
350
338
|
DEPENDENCY_DRIFT_MAX_DELIVERIES,
|
|
@@ -356,9 +344,9 @@ import {
|
|
|
356
344
|
resolveImportToFiles,
|
|
357
345
|
sweepInlineBlockerFreshness,
|
|
358
346
|
symbolExtractionGrammar
|
|
359
|
-
} from "../chunk-
|
|
360
|
-
import "../chunk-
|
|
361
|
-
import "../chunk-
|
|
347
|
+
} from "../chunk-7ZFXICNN.js";
|
|
348
|
+
import "../chunk-VSBCJVPC.js";
|
|
349
|
+
import "../chunk-BG7KHGNX.js";
|
|
362
350
|
import {
|
|
363
351
|
EXT_TO_LANG,
|
|
364
352
|
classifyTreeSitterWasmError,
|
|
@@ -371,15 +359,29 @@ import {
|
|
|
371
359
|
queryLoader,
|
|
372
360
|
reportBundledResourceDirHealth,
|
|
373
361
|
resolveTreeSitterLanguage
|
|
374
|
-
} from "../chunk-
|
|
362
|
+
} from "../chunk-6F34GMP7.js";
|
|
375
363
|
import "../chunk-Z54ZSOBZ.js";
|
|
376
364
|
import {
|
|
377
365
|
dump,
|
|
378
366
|
getUserRuleRoot,
|
|
379
367
|
resolvePackagePath
|
|
380
|
-
} from "../chunk-
|
|
368
|
+
} from "../chunk-EQKF6BAK.js";
|
|
381
369
|
import "../chunk-6HWVI6MI.js";
|
|
382
|
-
import "../chunk-
|
|
370
|
+
import "../chunk-GWZZOJD2.js";
|
|
371
|
+
import {
|
|
372
|
+
PROJECT_SNAPSHOT_VERSION,
|
|
373
|
+
getProjectSnapshotLegacyPath,
|
|
374
|
+
getProjectSnapshotPath,
|
|
375
|
+
hydrateRuntimeFromProjectSnapshot,
|
|
376
|
+
hydrateRuntimeFromProjectSnapshotIfIdle,
|
|
377
|
+
isProjectSnapshotFresh,
|
|
378
|
+
isProjectSnapshotMetaStale,
|
|
379
|
+
loadProjectSnapshot,
|
|
380
|
+
loadProjectSnapshotExportsAndRules,
|
|
381
|
+
loadProjectSnapshotWithoutWordIndex,
|
|
382
|
+
readProjectSnapshotMeta,
|
|
383
|
+
saveRuntimeProjectSnapshot
|
|
384
|
+
} from "../chunk-MVG2ZEAO.js";
|
|
383
385
|
import {
|
|
384
386
|
centralityFromReverseDeps,
|
|
385
387
|
getWordIndexBuildStatus,
|
|
@@ -388,26 +390,28 @@ import {
|
|
|
388
390
|
parseWordIndexQuery,
|
|
389
391
|
searchWordIndex,
|
|
390
392
|
triggerBackgroundWordIndexBuild
|
|
391
|
-
} from "../chunk-
|
|
393
|
+
} from "../chunk-IDKLWVKY.js";
|
|
392
394
|
import {
|
|
393
395
|
getProjectDiagnosticsScannerMaxFiles
|
|
394
|
-
} from "../chunk-
|
|
396
|
+
} from "../chunk-F6QAJXQV.js";
|
|
395
397
|
import {
|
|
396
398
|
SCAN_LANGUAGE_PRIORITY,
|
|
397
399
|
extensionsForLanguage,
|
|
398
400
|
resolveLanguage,
|
|
399
401
|
resolveLanguageScope
|
|
400
|
-
} from "../chunk-
|
|
402
|
+
} from "../chunk-HKPJTI47.js";
|
|
401
403
|
import {
|
|
402
404
|
WARM_TURN_END_SCHEMA_VERSION,
|
|
403
405
|
boundUnixSocketKeepsIdentity,
|
|
404
406
|
boundUnixSocketPath,
|
|
407
|
+
classifyIpcSocketName,
|
|
405
408
|
createWarmIpcLineReader,
|
|
406
409
|
createWarmIpcRequestQueue,
|
|
407
410
|
ipcPathForCwd,
|
|
411
|
+
probeIpcSocketListener,
|
|
408
412
|
readTurnEndStatus,
|
|
409
413
|
unlinkStaleUnixSocket
|
|
410
|
-
} from "../chunk-
|
|
414
|
+
} from "../chunk-PKGOROPQ.js";
|
|
411
415
|
import {
|
|
412
416
|
NO_SERVER_REASON,
|
|
413
417
|
cleanVerdict,
|
|
@@ -420,34 +424,34 @@ import {
|
|
|
420
424
|
import {
|
|
421
425
|
resolveRunnerPath,
|
|
422
426
|
toRunnerDisplayPath
|
|
423
|
-
} from "../chunk-
|
|
427
|
+
} from "../chunk-REZL4OM4.js";
|
|
428
|
+
import {
|
|
429
|
+
hashContentBytes,
|
|
430
|
+
hashFileBytes
|
|
431
|
+
} from "../chunk-CIA7X2PZ.js";
|
|
424
432
|
import "../chunk-2BEMIWEW.js";
|
|
425
433
|
import "../chunk-IJYGIDF4.js";
|
|
426
434
|
import {
|
|
427
435
|
commitDurableStore,
|
|
428
436
|
resetResolvedPathCache,
|
|
429
437
|
resetZizmorTokenAvailability
|
|
430
|
-
} from "../chunk-
|
|
438
|
+
} from "../chunk-VC3W54G3.js";
|
|
431
439
|
import {
|
|
432
440
|
readFileContent,
|
|
433
441
|
resolveToolCwd
|
|
434
|
-
} from "../chunk-
|
|
442
|
+
} from "../chunk-GVE5VZYQ.js";
|
|
435
443
|
import {
|
|
436
444
|
_resetPackageManagerCache,
|
|
437
445
|
findGlobalBinary,
|
|
438
446
|
pmBinary,
|
|
439
447
|
resolveNodePackageManager,
|
|
440
448
|
runScriptArgs
|
|
441
|
-
} from "../chunk-
|
|
449
|
+
} from "../chunk-YZNARDMM.js";
|
|
442
450
|
import {
|
|
443
451
|
getIsolatedNpxSpawnOptions,
|
|
444
452
|
probeToolAsync
|
|
445
|
-
} from "../chunk-
|
|
446
|
-
import
|
|
447
|
-
readJsonCache
|
|
448
|
-
} from "../chunk-TQWRH25U.js";
|
|
449
|
-
import "../chunk-UYXV5NIS.js";
|
|
450
|
-
import "../chunk-KNSOA43J.js";
|
|
453
|
+
} from "../chunk-JWW3ODBN.js";
|
|
454
|
+
import "../chunk-J2DAHH4T.js";
|
|
451
455
|
import {
|
|
452
456
|
classifyProbeFailure,
|
|
453
457
|
createAvailabilityLatch,
|
|
@@ -455,25 +459,30 @@ import {
|
|
|
455
459
|
logAvailabilityDecision,
|
|
456
460
|
resetInstallRetryLatches,
|
|
457
461
|
startHostStallSampler
|
|
458
|
-
} from "../chunk-
|
|
462
|
+
} from "../chunk-KDPZA2UE.js";
|
|
459
463
|
import {
|
|
460
464
|
canRunStartupHeavyScans,
|
|
461
465
|
detectProjectLanguageProfile,
|
|
462
466
|
getDefaultStartupTools
|
|
463
|
-
} from "../chunk-
|
|
464
|
-
import "../chunk-
|
|
467
|
+
} from "../chunk-Y3ZNOZZS.js";
|
|
468
|
+
import "../chunk-6REF4GCO.js";
|
|
465
469
|
import {
|
|
466
470
|
DEFAULT_MAX_SCAN_ENTRIES,
|
|
467
471
|
collectSourceFilesWithBudgetAsync,
|
|
468
472
|
getSlowFsVerdict,
|
|
469
473
|
isSlowFs,
|
|
470
474
|
slowFsDegradationNotice
|
|
471
|
-
} from "../chunk-
|
|
475
|
+
} from "../chunk-LKW2HFSZ.js";
|
|
472
476
|
import {
|
|
473
477
|
shouldRecurseIntoDir,
|
|
474
478
|
walkTreeStackAsync
|
|
475
|
-
} from "../chunk-
|
|
479
|
+
} from "../chunk-KW7O72AK.js";
|
|
480
|
+
import {
|
|
481
|
+
readJsonCache
|
|
482
|
+
} from "../chunk-TQWRH25U.js";
|
|
483
|
+
import "../chunk-UYXV5NIS.js";
|
|
476
484
|
import {
|
|
485
|
+
createProjectDataDirRootProbe,
|
|
477
486
|
displayProjectDataPath,
|
|
478
487
|
drainProjectDataDirMigrations,
|
|
479
488
|
getAmbientAbortSignal,
|
|
@@ -490,6 +499,7 @@ import {
|
|
|
490
499
|
isTestFile,
|
|
491
500
|
isWithinPathForm,
|
|
492
501
|
loadPiLensGlobalConfig,
|
|
502
|
+
projectDataBase,
|
|
493
503
|
realIsPidAlive,
|
|
494
504
|
resetProjectDataDirSessionState,
|
|
495
505
|
resetSafeSpawnWindowsCommandCache,
|
|
@@ -500,40 +510,40 @@ import {
|
|
|
500
510
|
subagentLightModeNotice,
|
|
501
511
|
sweepAtomicWriteStages,
|
|
502
512
|
sweepDeadEphemeralDataDirs,
|
|
513
|
+
sweepOrphans,
|
|
503
514
|
updateHeartbeat,
|
|
504
515
|
withGenerationLockSync
|
|
505
|
-
} from "../chunk-
|
|
516
|
+
} from "../chunk-LURFD4HD.js";
|
|
506
517
|
import {
|
|
507
518
|
createSingleFlight
|
|
508
|
-
} from "../chunk-
|
|
519
|
+
} from "../chunk-3UHGSUVL.js";
|
|
509
520
|
import {
|
|
510
521
|
createDeadline,
|
|
511
522
|
yieldIfOverBudget
|
|
512
523
|
} from "../chunk-QYF5S6P6.js";
|
|
513
|
-
import {
|
|
514
|
-
detectFileKind,
|
|
515
|
-
isJstsFactFile
|
|
516
|
-
} from "../chunk-CQY2HEH7.js";
|
|
517
524
|
import {
|
|
518
525
|
PathKeyedMap,
|
|
519
526
|
compareKeys,
|
|
520
527
|
detectFileRole,
|
|
521
528
|
loadPiLensProjectConfig,
|
|
522
529
|
lspSectionOf,
|
|
530
|
+
peekPiLensProjectConfig,
|
|
523
531
|
provenanceFor,
|
|
524
532
|
provenanceView,
|
|
533
|
+
resolveOnePiLensConfigDocument,
|
|
525
534
|
resolvePiLensConfig,
|
|
526
535
|
summarizeConfigResolution
|
|
527
|
-
} from "../chunk-
|
|
536
|
+
} from "../chunk-UX75PTQW.js";
|
|
537
|
+
import {
|
|
538
|
+
detectFileKind,
|
|
539
|
+
isJstsFactFile
|
|
540
|
+
} from "../chunk-V4TFQY5G.js";
|
|
528
541
|
import {
|
|
529
542
|
LSP_NAMESPACE_KEY,
|
|
530
543
|
getPiLensGlobalConfigPath,
|
|
544
|
+
holdsCanonicalProjectConfig,
|
|
531
545
|
resetWorkspaceTopology
|
|
532
|
-
} from "../chunk-
|
|
533
|
-
import {
|
|
534
|
-
hashContentBytes,
|
|
535
|
-
hashFileBytes
|
|
536
|
-
} from "../chunk-CIA7X2PZ.js";
|
|
546
|
+
} from "../chunk-D2LFEA5U.js";
|
|
537
547
|
import {
|
|
538
548
|
DEFAULT_MAX_OUTPUT_BYTES,
|
|
539
549
|
HOOK_WALL_BUDGET_MS,
|
|
@@ -549,7 +559,7 @@ import {
|
|
|
549
559
|
withBudget,
|
|
550
560
|
withDeadline,
|
|
551
561
|
writeFileAtomic
|
|
552
|
-
} from "../chunk-
|
|
562
|
+
} from "../chunk-463WN3VP.js";
|
|
553
563
|
import {
|
|
554
564
|
LENS_TOOL_NAMES,
|
|
555
565
|
TOOL_REGISTRY,
|
|
@@ -568,7 +578,7 @@ import {
|
|
|
568
578
|
resolveLensToolName,
|
|
569
579
|
toolRegistryEntryForMcp,
|
|
570
580
|
translateGuidanceToolNames
|
|
571
|
-
} from "../chunk-
|
|
581
|
+
} from "../chunk-CQNXALZJ.js";
|
|
572
582
|
import {
|
|
573
583
|
freshnessFromMtime
|
|
574
584
|
} from "../chunk-S26LC76R.js";
|
|
@@ -577,17 +587,18 @@ import {
|
|
|
577
587
|
claimPhaseOncePerSession,
|
|
578
588
|
createNdjsonLogger,
|
|
579
589
|
getGlobalPiLensLogDir,
|
|
590
|
+
getMaxLogSizeMB,
|
|
580
591
|
getProcessSingleton,
|
|
592
|
+
getRegisteredLogFiles,
|
|
581
593
|
isTestMode,
|
|
582
594
|
logLatency,
|
|
583
595
|
nonNegativeIntEnv,
|
|
584
|
-
runLogCleanup,
|
|
585
596
|
setTurnContextSession
|
|
586
|
-
} from "../chunk-
|
|
597
|
+
} from "../chunk-YVE5Q2UU.js";
|
|
587
598
|
import "../chunk-LJDODBBZ.js";
|
|
588
599
|
import {
|
|
589
600
|
FactStore
|
|
590
|
-
} from "../chunk-
|
|
601
|
+
} from "../chunk-HPKC55MA.js";
|
|
591
602
|
import {
|
|
592
603
|
BoundedFifoMap,
|
|
593
604
|
BoundedLruCache,
|
|
@@ -606,24 +617,294 @@ import {
|
|
|
606
617
|
realpathOrResolve,
|
|
607
618
|
relativeInside,
|
|
608
619
|
resolveHostToolPath,
|
|
620
|
+
rootsOverlap,
|
|
609
621
|
toPosix,
|
|
610
622
|
toProjectRelativePath,
|
|
611
623
|
uriToDiskPath,
|
|
612
624
|
uriToPath,
|
|
613
625
|
walkUpDirs
|
|
614
|
-
} from "../chunk-
|
|
626
|
+
} from "../chunk-ZSPVF7KI.js";
|
|
615
627
|
import "../chunk-NXL4FFQQ.js";
|
|
616
628
|
|
|
617
629
|
// dist/mcp/server.js
|
|
618
|
-
import * as
|
|
630
|
+
import * as fs26 from "node:fs";
|
|
619
631
|
import * as net from "node:net";
|
|
620
|
-
import * as
|
|
632
|
+
import * as path43 from "node:path";
|
|
621
633
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
622
634
|
|
|
623
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";
|
|
624
641
|
import * as fs from "node:fs";
|
|
642
|
+
import * as os from "node:os";
|
|
625
643
|
import * as path from "node:path";
|
|
626
|
-
|
|
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
|
|
627
908
|
var MAX_RESULT_BYTES = 40 * 1024;
|
|
628
909
|
var COMPLETE_MCP_RESULT_INPUT_BUDGET_BYTES = 8 * 1024 * 1024;
|
|
629
910
|
var FOOTER_MAX_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
|
|
@@ -662,8 +943,8 @@ function boundToolText(text, maxBytes = MAX_RESULT_BYTES) {
|
|
|
662
943
|
if (totalBytes <= maxBytes) {
|
|
663
944
|
return { text, truncated: false, omittedCharacters: 0 };
|
|
664
945
|
}
|
|
665
|
-
const fullOutputPath =
|
|
666
|
-
|
|
946
|
+
const fullOutputPath = path2.join(getGlobalPiLensLogDir(), spillResultLogName());
|
|
947
|
+
fs2.mkdirSync(path2.dirname(fullOutputPath), { recursive: true });
|
|
667
948
|
if (totalBytes > COMPLETE_MCP_RESULT_INPUT_BUDGET_BYTES) {
|
|
668
949
|
const omittedBytes = totalBytes - COMPLETE_MCP_RESULT_INPUT_BUDGET_BYTES;
|
|
669
950
|
recordDegradationOnce({
|
|
@@ -685,7 +966,7 @@ function boundToolText(text, maxBytes = MAX_RESULT_BYTES) {
|
|
|
685
966
|
|
|
686
967
|
`;
|
|
687
968
|
});
|
|
688
|
-
|
|
969
|
+
fs2.writeFileSync(fullOutputPath, logText.text, "utf8");
|
|
689
970
|
const output2 = renderHeadTail(logText.text, maxBytes, () => `
|
|
690
971
|
|
|
691
972
|
[incomplete: ${omittedBytes} bytes omitted, budget ${COMPLETE_MCP_RESULT_INPUT_BUDGET_BYTES}]
|
|
@@ -700,7 +981,7 @@ function boundToolText(text, maxBytes = MAX_RESULT_BYTES) {
|
|
|
700
981
|
fullOutputPath
|
|
701
982
|
};
|
|
702
983
|
}
|
|
703
|
-
|
|
984
|
+
fs2.writeFileSync(fullOutputPath, text, "utf8");
|
|
704
985
|
const output = renderHeadTail(text, maxBytes, (head, tail) => `
|
|
705
986
|
|
|
706
987
|
[${text.length - head - tail} characters omitted. Full output: ${fullOutputPath}]
|
|
@@ -919,16 +1200,16 @@ function baseName(p) {
|
|
|
919
1200
|
}
|
|
920
1201
|
|
|
921
1202
|
// dist/clients/ast-grep-client.js
|
|
922
|
-
import * as
|
|
923
|
-
import * as
|
|
1203
|
+
import * as fs5 from "node:fs";
|
|
1204
|
+
import * as path5 from "node:path";
|
|
924
1205
|
|
|
925
1206
|
// dist/clients/ast-grep-rule-manager.js
|
|
926
|
-
import * as
|
|
927
|
-
import * as
|
|
1207
|
+
import * as fs3 from "node:fs";
|
|
1208
|
+
import * as path3 from "node:path";
|
|
928
1209
|
function candidateAstGrepRulesPaths(ruleDir) {
|
|
929
1210
|
return [
|
|
930
|
-
|
|
931
|
-
|
|
1211
|
+
path3.join(ruleDir, "ast-grep-rules", "rules"),
|
|
1212
|
+
path3.join(ruleDir, "rules"),
|
|
932
1213
|
ruleDir
|
|
933
1214
|
];
|
|
934
1215
|
}
|
|
@@ -936,14 +1217,14 @@ function checkAstGrepRulesHealth(ruleDir) {
|
|
|
936
1217
|
const possiblePaths = candidateAstGrepRulesPaths(ruleDir);
|
|
937
1218
|
let rulesPath;
|
|
938
1219
|
for (const candidate of possiblePaths) {
|
|
939
|
-
if (
|
|
1220
|
+
if (fs3.existsSync(candidate)) {
|
|
940
1221
|
rulesPath = candidate;
|
|
941
1222
|
break;
|
|
942
1223
|
}
|
|
943
1224
|
}
|
|
944
1225
|
if (!rulesPath) {
|
|
945
1226
|
try {
|
|
946
|
-
|
|
1227
|
+
fs3.readdirSync(ruleDir);
|
|
947
1228
|
} catch (error) {
|
|
948
1229
|
const fsErrorCode = error?.code;
|
|
949
1230
|
if (fsErrorCode && fsErrorCode !== "ENOENT") {
|
|
@@ -954,7 +1235,7 @@ function checkAstGrepRulesHealth(ruleDir) {
|
|
|
954
1235
|
}
|
|
955
1236
|
let entries;
|
|
956
1237
|
try {
|
|
957
|
-
entries =
|
|
1238
|
+
entries = fs3.readdirSync(rulesPath).filter((f) => f.endsWith(".yml"));
|
|
958
1239
|
} catch (error) {
|
|
959
1240
|
const fsErrorCode = error?.code ?? "UNKNOWN";
|
|
960
1241
|
return { status: "unreadable", fsErrorCode };
|
|
@@ -982,12 +1263,12 @@ var AstGrepRuleManager = class {
|
|
|
982
1263
|
const rulesPaths = [];
|
|
983
1264
|
if (Array.isArray(this.ruleDir)) {
|
|
984
1265
|
for (const candidate of possiblePaths) {
|
|
985
|
-
if (
|
|
1266
|
+
if (fs3.existsSync(candidate))
|
|
986
1267
|
rulesPaths.push(candidate);
|
|
987
1268
|
}
|
|
988
1269
|
} else {
|
|
989
1270
|
for (const candidate of possiblePaths) {
|
|
990
|
-
if (!
|
|
1271
|
+
if (!fs3.existsSync(candidate))
|
|
991
1272
|
continue;
|
|
992
1273
|
rulesPaths.push(candidate);
|
|
993
1274
|
break;
|
|
@@ -1002,11 +1283,11 @@ var AstGrepRuleManager = class {
|
|
|
1002
1283
|
}
|
|
1003
1284
|
try {
|
|
1004
1285
|
for (const resolvedPath of rulesPaths) {
|
|
1005
|
-
const files =
|
|
1286
|
+
const files = fs3.readdirSync(resolvedPath).filter((f) => f.endsWith(".yml"));
|
|
1006
1287
|
this.log(`Loaded ${files.length} rule descriptions from ${resolvedPath}`);
|
|
1007
1288
|
for (const file of files) {
|
|
1008
|
-
const filePath =
|
|
1009
|
-
const content =
|
|
1289
|
+
const filePath = path3.join(resolvedPath, file);
|
|
1290
|
+
const content = fs3.readFileSync(filePath, "utf-8");
|
|
1010
1291
|
const rule = this.parseRuleYaml(content);
|
|
1011
1292
|
if (rule && !descriptions.has(rule.id))
|
|
1012
1293
|
descriptions.set(rule.id, rule);
|
|
@@ -1059,8 +1340,8 @@ var AstGrepRuleManager = class {
|
|
|
1059
1340
|
};
|
|
1060
1341
|
|
|
1061
1342
|
// dist/clients/sg-runner.js
|
|
1062
|
-
import * as
|
|
1063
|
-
import * as
|
|
1343
|
+
import * as fs4 from "node:fs";
|
|
1344
|
+
import * as path4 from "node:path";
|
|
1064
1345
|
function buildBashRunArgs(cmd, allArgs) {
|
|
1065
1346
|
return ["-c", '"$0" "$@"', cmd, ...allArgs];
|
|
1066
1347
|
}
|
|
@@ -1117,7 +1398,7 @@ function tryParseNonZeroSgMatches(result) {
|
|
|
1117
1398
|
function sgMatchesAtScanRoot(matches, scanCwd) {
|
|
1118
1399
|
return matches.map((match) => ({
|
|
1119
1400
|
...match,
|
|
1120
|
-
file:
|
|
1401
|
+
file: path4.resolve(scanCwd, match.file)
|
|
1121
1402
|
}));
|
|
1122
1403
|
}
|
|
1123
1404
|
var SgRunner = class {
|
|
@@ -1374,14 +1655,14 @@ var SgRunner = class {
|
|
|
1374
1655
|
pkgSuffixes.push("win32-arm64-msvc");
|
|
1375
1656
|
const searchRoots = [];
|
|
1376
1657
|
for (const dir of walkUpDirs(process.cwd(), { maxDepth: 5 })) {
|
|
1377
|
-
searchRoots.push(
|
|
1658
|
+
searchRoots.push(path4.join(dir, "node_modules"));
|
|
1378
1659
|
}
|
|
1379
1660
|
for (const suffix of pkgSuffixes) {
|
|
1380
1661
|
const pkgName = `@ast-grep/cli-${suffix}`;
|
|
1381
1662
|
for (const root of searchRoots) {
|
|
1382
|
-
const candidate =
|
|
1663
|
+
const candidate = path4.join(root, pkgName, exeName);
|
|
1383
1664
|
try {
|
|
1384
|
-
if (
|
|
1665
|
+
if (fs4.existsSync(candidate) && await this.probeCommand(candidate, [])) {
|
|
1385
1666
|
return candidate;
|
|
1386
1667
|
}
|
|
1387
1668
|
} catch {
|
|
@@ -1405,8 +1686,8 @@ var SgRunner = class {
|
|
|
1405
1686
|
if (!prefix)
|
|
1406
1687
|
return void 0;
|
|
1407
1688
|
for (const name of ["ast-grep", "sg"]) {
|
|
1408
|
-
const candidate =
|
|
1409
|
-
if (
|
|
1689
|
+
const candidate = path4.join(prefix, "bin", name);
|
|
1690
|
+
if (fs4.existsSync(candidate) && await this.probeCommand(candidate, [])) {
|
|
1410
1691
|
return candidate;
|
|
1411
1692
|
}
|
|
1412
1693
|
}
|
|
@@ -1450,7 +1731,7 @@ ${result.stderr}`)) {
|
|
|
1450
1731
|
} else {
|
|
1451
1732
|
this.sweepSawTransient = true;
|
|
1452
1733
|
this.sweepTransientCause = cause;
|
|
1453
|
-
const name =
|
|
1734
|
+
const name = path4.basename(cmd);
|
|
1454
1735
|
if (!this.sweepUnreachable.includes(name)) {
|
|
1455
1736
|
this.sweepUnreachable.push(name);
|
|
1456
1737
|
}
|
|
@@ -1622,15 +1903,15 @@ Original error: ${stderr}`;
|
|
|
1622
1903
|
}
|
|
1623
1904
|
// --- Shared helpers for temp-dir rule scans ---
|
|
1624
1905
|
prepareTempScan(ruleId, ruleYaml) {
|
|
1625
|
-
const sessionDir =
|
|
1906
|
+
const sessionDir = fs4.mkdtempSync(path4.join(scannerReportParentDir(), `pi-lens-temp-${ruleId}-`));
|
|
1626
1907
|
try {
|
|
1627
|
-
const rulesSubdir =
|
|
1628
|
-
const configFile =
|
|
1629
|
-
|
|
1630
|
-
|
|
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:
|
|
1631
1912
|
- ./rules
|
|
1632
1913
|
`);
|
|
1633
|
-
|
|
1914
|
+
fs4.writeFileSync(path4.join(rulesSubdir, `${ruleId}.yml`), ruleYaml);
|
|
1634
1915
|
return { sessionDir, configFile };
|
|
1635
1916
|
} catch (error) {
|
|
1636
1917
|
this.cleanupTempScan(sessionDir);
|
|
@@ -1639,18 +1920,18 @@ Original error: ${stderr}`;
|
|
|
1639
1920
|
}
|
|
1640
1921
|
cleanupTempScan(sessionDir) {
|
|
1641
1922
|
try {
|
|
1642
|
-
|
|
1923
|
+
fs4.rmSync(sessionDir, { recursive: true, force: true });
|
|
1643
1924
|
} catch (err) {
|
|
1644
1925
|
this.log(`Cleanup failed: ${err.message}`);
|
|
1645
1926
|
}
|
|
1646
1927
|
}
|
|
1647
1928
|
/** The scan anchor for one `dir` argument; see {@link SgScanAnchor}. */
|
|
1648
1929
|
sgScanAnchor(dir) {
|
|
1649
|
-
const absolute =
|
|
1650
|
-
const isDirectory =
|
|
1651
|
-
let treeRoot = isDirectory ? absolute :
|
|
1652
|
-
if (!
|
|
1653
|
-
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;
|
|
1654
1935
|
}
|
|
1655
1936
|
const isolationCwd = this.sgSpawnOptions?.cwd;
|
|
1656
1937
|
if (isolationCwd !== void 0) {
|
|
@@ -1660,10 +1941,10 @@ Original error: ${stderr}`;
|
|
|
1660
1941
|
excludeArgs: findNearestContaining(treeRoot, [".git"]) ? [] : sgExcludeArgsForProject(absolute)
|
|
1661
1942
|
};
|
|
1662
1943
|
}
|
|
1663
|
-
const
|
|
1944
|
+
const relative10 = path4.relative(treeRoot, absolute) || ".";
|
|
1664
1945
|
return {
|
|
1665
1946
|
cwd: treeRoot,
|
|
1666
|
-
scanArg:
|
|
1947
|
+
scanArg: relative10,
|
|
1667
1948
|
excludeArgs: sgExcludeArgsForProject(absolute)
|
|
1668
1949
|
};
|
|
1669
1950
|
}
|
|
@@ -1729,7 +2010,7 @@ Original error: ${stderr}`;
|
|
|
1729
2010
|
let sessionDir;
|
|
1730
2011
|
try {
|
|
1731
2012
|
({ sessionDir } = this.prepareTempScan(ruleId, ruleYaml));
|
|
1732
|
-
const configFile =
|
|
2013
|
+
const configFile = path4.join(sessionDir, ".sgconfig.yml");
|
|
1733
2014
|
const anchor = this.sgScanAnchor(dir);
|
|
1734
2015
|
const result = await this.spawnResolved(this.getSgCommand(), [
|
|
1735
2016
|
"scan",
|
|
@@ -1765,7 +2046,7 @@ Original error: ${stderr}`;
|
|
|
1765
2046
|
let sessionDir;
|
|
1766
2047
|
try {
|
|
1767
2048
|
({ sessionDir } = this.prepareTempScan(ruleId, ruleYaml));
|
|
1768
|
-
const configFile =
|
|
2049
|
+
const configFile = path4.join(sessionDir, ".sgconfig.yml");
|
|
1769
2050
|
const command = this.getSgCommand();
|
|
1770
2051
|
const anchor = this.sgScanAnchor(dir);
|
|
1771
2052
|
const scanArgs = [
|
|
@@ -1879,12 +2160,12 @@ function reportAstGrepRulesHealth(bundledRuleDir) {
|
|
|
1879
2160
|
reportBundledResourceDirHealth("ast-grep-rules-dir-missing", bundledRuleDir, health, "ast-grep rule descriptions");
|
|
1880
2161
|
}
|
|
1881
2162
|
function matchedFilePath(file) {
|
|
1882
|
-
return normalizeFilePath(
|
|
2163
|
+
return normalizeFilePath(path5.resolve(process.cwd(), file));
|
|
1883
2164
|
}
|
|
1884
2165
|
function recordAstGrepApply(matches, { lineage, toolCallId, sessionId } = {}) {
|
|
1885
2166
|
const bridge = getMutationBridge();
|
|
1886
2167
|
if (!bridge || matches.length === 0)
|
|
1887
|
-
return
|
|
2168
|
+
return;
|
|
1888
2169
|
const rangesByFile = /* @__PURE__ */ new Map();
|
|
1889
2170
|
for (const match of matches) {
|
|
1890
2171
|
const start = (match.range?.start?.line ?? 0) + 1;
|
|
@@ -1895,10 +2176,9 @@ function recordAstGrepApply(matches, { lineage, toolCallId, sessionId } = {}) {
|
|
|
1895
2176
|
else
|
|
1896
2177
|
rangesByFile.set(match.file, [[start, end]]);
|
|
1897
2178
|
}
|
|
1898
|
-
const accepted = [];
|
|
1899
2179
|
for (const [filePath, editRanges] of rangesByFile) {
|
|
1900
2180
|
const resolved = matchedFilePath(filePath);
|
|
1901
|
-
|
|
2181
|
+
bridge.recordMutation({
|
|
1902
2182
|
filePath: resolved,
|
|
1903
2183
|
kind: "edit",
|
|
1904
2184
|
editRanges,
|
|
@@ -1915,10 +2195,7 @@ function recordAstGrepApply(matches, { lineage, toolCallId, sessionId } = {}) {
|
|
|
1915
2195
|
// #4943: the calling session owns the deferred pass of what it rewrote.
|
|
1916
2196
|
...sessionId !== void 0 && { sessionId }
|
|
1917
2197
|
});
|
|
1918
|
-
if (recorded)
|
|
1919
|
-
accepted.push(resolved);
|
|
1920
2198
|
}
|
|
1921
|
-
return accepted;
|
|
1922
2199
|
}
|
|
1923
2200
|
function missingRootRefusal(options) {
|
|
1924
2201
|
return options?.sessionRoot === void 0 ? "ast_grep_replace refused: no session root to check the write against" : void 0;
|
|
@@ -1941,20 +2218,19 @@ async function applyRewrite(matches, options, write) {
|
|
|
1941
2218
|
if (refused.length > 0)
|
|
1942
2219
|
return { refused };
|
|
1943
2220
|
const before = /* @__PURE__ */ new Map();
|
|
1944
|
-
let appliedFiles = [];
|
|
1945
2221
|
const result = await writeSourceFile({
|
|
1946
2222
|
filePaths: files,
|
|
1947
2223
|
record: (exit) => {
|
|
1948
2224
|
const clean = exit.ok && exit.value.error === void 0;
|
|
1949
2225
|
const changed = clean ? files : files.filter((file) => hashOf(file) !== before.get(file));
|
|
1950
|
-
|
|
2226
|
+
recordAstGrepApply(matches.filter((match) => changed.includes(matchedFilePath(match.file))), options);
|
|
1951
2227
|
}
|
|
1952
2228
|
}, async () => {
|
|
1953
2229
|
for (const file of files)
|
|
1954
2230
|
before.set(file, hashOf(file));
|
|
1955
2231
|
return write();
|
|
1956
2232
|
});
|
|
1957
|
-
return { result
|
|
2233
|
+
return { result };
|
|
1958
2234
|
}
|
|
1959
2235
|
function extractDebugAst(raw) {
|
|
1960
2236
|
const lines = raw.split(/\r?\n/);
|
|
@@ -2051,8 +2327,8 @@ var AstGrepClient = class {
|
|
|
2051
2327
|
usingBundledRuleDirFallback;
|
|
2052
2328
|
rulesHealthReportedGeneration;
|
|
2053
2329
|
constructor(ruleDir, verbose = false) {
|
|
2054
|
-
const projectRuleDir =
|
|
2055
|
-
const hasProjectRuleDir =
|
|
2330
|
+
const projectRuleDir = path5.join(process.cwd(), "rules");
|
|
2331
|
+
const hasProjectRuleDir = fs5.existsSync(projectRuleDir);
|
|
2056
2332
|
this.usingBundledRuleDirFallback = !ruleDir && !hasProjectRuleDir;
|
|
2057
2333
|
this.ruleDir = ruleDir || (hasProjectRuleDir ? projectRuleDir : resolvePackagePath(import.meta.url, "rules"));
|
|
2058
2334
|
this.log = verbose ? createSubsystemLogger("ast-grep") : () => {
|
|
@@ -2116,7 +2392,6 @@ var AstGrepClient = class {
|
|
|
2116
2392
|
};
|
|
2117
2393
|
}
|
|
2118
2394
|
}
|
|
2119
|
-
const appliedFiles = [];
|
|
2120
2395
|
for (const scanPath of paths) {
|
|
2121
2396
|
let previewed = [];
|
|
2122
2397
|
if (apply) {
|
|
@@ -2127,8 +2402,7 @@ var AstGrepClient = class {
|
|
|
2127
2402
|
totalMatches: allMatches.length,
|
|
2128
2403
|
applied: false,
|
|
2129
2404
|
error: preCheck.error ?? "ast-grep preview failed",
|
|
2130
|
-
...preCheck.failure === "aborted" ? { aborted: true } : {}
|
|
2131
|
-
appliedFiles
|
|
2405
|
+
...preCheck.failure === "aborted" ? { aborted: true } : {}
|
|
2132
2406
|
};
|
|
2133
2407
|
}
|
|
2134
2408
|
if (preCheck.matches.length === 0) {
|
|
@@ -2136,8 +2410,7 @@ var AstGrepClient = class {
|
|
|
2136
2410
|
matches: [],
|
|
2137
2411
|
totalMatches: 0,
|
|
2138
2412
|
applied: false,
|
|
2139
|
-
stalePreview: true
|
|
2140
|
-
appliedFiles
|
|
2413
|
+
stalePreview: true
|
|
2141
2414
|
};
|
|
2142
2415
|
}
|
|
2143
2416
|
previewed = preCheck.matches;
|
|
@@ -2149,12 +2422,9 @@ var AstGrepClient = class {
|
|
|
2149
2422
|
matches: allMatches,
|
|
2150
2423
|
totalMatches: allMatches.length,
|
|
2151
2424
|
applied: false,
|
|
2152
|
-
error: outsideRootsText(applied.refused)
|
|
2153
|
-
appliedFiles
|
|
2425
|
+
error: outsideRootsText(applied.refused)
|
|
2154
2426
|
};
|
|
2155
2427
|
}
|
|
2156
|
-
if (applied !== null)
|
|
2157
|
-
appliedFiles.push(...applied.appliedFiles);
|
|
2158
2428
|
const result = applied === null ? await scan() : applied.result;
|
|
2159
2429
|
if (result.error) {
|
|
2160
2430
|
return {
|
|
@@ -2163,8 +2433,7 @@ var AstGrepClient = class {
|
|
|
2163
2433
|
applied: false,
|
|
2164
2434
|
error: result.error,
|
|
2165
2435
|
...result.aborted ? { aborted: true } : {},
|
|
2166
|
-
...result.writeStarted ? { writeStarted: true } : {}
|
|
2167
|
-
appliedFiles
|
|
2436
|
+
...result.writeStarted ? { writeStarted: true } : {}
|
|
2168
2437
|
};
|
|
2169
2438
|
}
|
|
2170
2439
|
allMatches.push(...result.matches);
|
|
@@ -2172,8 +2441,7 @@ var AstGrepClient = class {
|
|
|
2172
2441
|
return {
|
|
2173
2442
|
matches: allMatches,
|
|
2174
2443
|
totalMatches: allMatches.length,
|
|
2175
|
-
applied: apply
|
|
2176
|
-
appliedFiles
|
|
2444
|
+
applied: apply
|
|
2177
2445
|
};
|
|
2178
2446
|
}
|
|
2179
2447
|
/**
|
|
@@ -2216,10 +2484,10 @@ var AstGrepClient = class {
|
|
|
2216
2484
|
* Dump the parsed tree-sitter AST for a snippet using ast-grep CLI.
|
|
2217
2485
|
*/
|
|
2218
2486
|
async dumpAst(source, lang, options = {}) {
|
|
2219
|
-
const tmpDir =
|
|
2220
|
-
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"}`);
|
|
2221
2489
|
try {
|
|
2222
|
-
|
|
2490
|
+
fs5.writeFileSync(tmpFile, source, "utf-8");
|
|
2223
2491
|
const mode = options.includeAnonymous ? "cst" : "ast";
|
|
2224
2492
|
const result = await this.runner.execRaw([
|
|
2225
2493
|
"run",
|
|
@@ -2238,7 +2506,7 @@ var AstGrepClient = class {
|
|
|
2238
2506
|
error: result.error || result.stderr.trim() || result.stdout.trim() || `ast-grep did not return a debug AST for language ${lang}`
|
|
2239
2507
|
};
|
|
2240
2508
|
} finally {
|
|
2241
|
-
|
|
2509
|
+
fs5.rmSync(tmpDir, { recursive: true, force: true });
|
|
2242
2510
|
}
|
|
2243
2511
|
}
|
|
2244
2512
|
async validatePattern(pattern, lang, options) {
|
|
@@ -2246,10 +2514,10 @@ var AstGrepClient = class {
|
|
|
2246
2514
|
if (shapeError)
|
|
2247
2515
|
return { valid: false, error: shapeError };
|
|
2248
2516
|
const snippet = validationSnippetFor(lang);
|
|
2249
|
-
const tmpDir =
|
|
2250
|
-
const tmpFile =
|
|
2517
|
+
const tmpDir = fs5.mkdtempSync(path5.join(scannerReportParentDir(), "pi-lens-sg-validate-"));
|
|
2518
|
+
const tmpFile = path5.join(tmpDir, `snippet.${snippet.ext}`);
|
|
2251
2519
|
try {
|
|
2252
|
-
|
|
2520
|
+
fs5.writeFileSync(tmpFile, snippet.source, "utf-8");
|
|
2253
2521
|
const args = ["run", "-p", pattern, "--lang", lang, "--json=compact"];
|
|
2254
2522
|
if (options?.selector)
|
|
2255
2523
|
args.push("--selector", options.selector);
|
|
@@ -2282,7 +2550,7 @@ var AstGrepClient = class {
|
|
|
2282
2550
|
};
|
|
2283
2551
|
} finally {
|
|
2284
2552
|
try {
|
|
2285
|
-
|
|
2553
|
+
fs5.rmSync(tmpDir, { recursive: true, force: true });
|
|
2286
2554
|
} catch {
|
|
2287
2555
|
}
|
|
2288
2556
|
}
|
|
@@ -2293,9 +2561,9 @@ var AstGrepClient = class {
|
|
|
2293
2561
|
return { valid: false, error: shapeError };
|
|
2294
2562
|
const language = extractRuleLanguage(ruleYaml) ?? "typescript";
|
|
2295
2563
|
const snippet = validationSnippetFor(language);
|
|
2296
|
-
const tmpDir =
|
|
2564
|
+
const tmpDir = fs5.mkdtempSync(path5.join(scannerReportParentDir(), "pi-lens-sg-rule-"));
|
|
2297
2565
|
try {
|
|
2298
|
-
|
|
2566
|
+
fs5.writeFileSync(path5.join(tmpDir, `snippet.${snippet.ext}`), snippet.source, "utf-8");
|
|
2299
2567
|
const result = await this.tempScanDetailed(tmpDir, ruleYaml, options);
|
|
2300
2568
|
if (result.failure || result.error) {
|
|
2301
2569
|
return {
|
|
@@ -2308,7 +2576,7 @@ var AstGrepClient = class {
|
|
|
2308
2576
|
return { valid: false, error: String(err) };
|
|
2309
2577
|
} finally {
|
|
2310
2578
|
try {
|
|
2311
|
-
|
|
2579
|
+
fs5.rmSync(tmpDir, { recursive: true, force: true });
|
|
2312
2580
|
} catch {
|
|
2313
2581
|
}
|
|
2314
2582
|
}
|
|
@@ -2450,7 +2718,6 @@ var AstGrepClient = class {
|
|
|
2450
2718
|
error: outsideRootsText(applied.refused)
|
|
2451
2719
|
};
|
|
2452
2720
|
}
|
|
2453
|
-
const { appliedFiles } = applied;
|
|
2454
2721
|
if (applied.result.error) {
|
|
2455
2722
|
return {
|
|
2456
2723
|
matches: [],
|
|
@@ -2458,8 +2725,7 @@ var AstGrepClient = class {
|
|
|
2458
2725
|
truncated: false,
|
|
2459
2726
|
applied: false,
|
|
2460
2727
|
error: applied.result.error,
|
|
2461
|
-
writeStarted: true
|
|
2462
|
-
appliedFiles
|
|
2728
|
+
writeStarted: true
|
|
2463
2729
|
};
|
|
2464
2730
|
}
|
|
2465
2731
|
return {
|
|
@@ -2467,8 +2733,7 @@ var AstGrepClient = class {
|
|
|
2467
2733
|
totalMatches: preCheck.totalMatches,
|
|
2468
2734
|
truncated: preCheck.truncated,
|
|
2469
2735
|
applied: true,
|
|
2470
|
-
error: void 0
|
|
2471
|
-
appliedFiles
|
|
2736
|
+
error: void 0
|
|
2472
2737
|
};
|
|
2473
2738
|
}
|
|
2474
2739
|
/**
|
|
@@ -2592,21 +2857,21 @@ message: found
|
|
|
2592
2857
|
};
|
|
2593
2858
|
|
|
2594
2859
|
// dist/clients/lens-engine.js
|
|
2595
|
-
import * as
|
|
2860
|
+
import * as path29 from "node:path";
|
|
2596
2861
|
|
|
2597
2862
|
// dist/clients/project-diagnostics/scanner.js
|
|
2598
|
-
import * as
|
|
2599
|
-
import * as
|
|
2600
|
-
import * as
|
|
2863
|
+
import * as fs7 from "node:fs";
|
|
2864
|
+
import * as os2 from "node:os";
|
|
2865
|
+
import * as path7 from "node:path";
|
|
2601
2866
|
|
|
2602
2867
|
// dist/clients/project-diagnostics/cache.js
|
|
2603
|
-
import * as
|
|
2604
|
-
import * as
|
|
2868
|
+
import * as fs6 from "node:fs";
|
|
2869
|
+
import * as path6 from "node:path";
|
|
2605
2870
|
var PROJECT_DIAGNOSTICS_CACHE_VERSION = 3;
|
|
2606
2871
|
var SNAPSHOT_CACHE_FILE = "project-diagnostics.json";
|
|
2607
2872
|
var DELTA_CACHE_FILE = "project-diagnostics-delta.json";
|
|
2608
2873
|
function cachePath(cwd, fileName) {
|
|
2609
|
-
return
|
|
2874
|
+
return path6.join(getProjectDataDir(cwd), "cache", fileName);
|
|
2610
2875
|
}
|
|
2611
2876
|
function loadProjectDiagnosticsSnapshot(cwd) {
|
|
2612
2877
|
return readJsonCache(cachePath(cwd, SNAPSHOT_CACHE_FILE), (parsed) => {
|
|
@@ -2622,7 +2887,7 @@ function loadProjectDiagnosticsSnapshot(cwd) {
|
|
|
2622
2887
|
}
|
|
2623
2888
|
function saveProjectDiagnosticsSnapshot(cwd, snapshot) {
|
|
2624
2889
|
const filePath = cachePath(cwd, SNAPSHOT_CACHE_FILE);
|
|
2625
|
-
|
|
2890
|
+
fs6.mkdirSync(path6.dirname(filePath), { recursive: true });
|
|
2626
2891
|
writeFileAtomic(filePath, JSON.stringify(snapshot, null, 2));
|
|
2627
2892
|
}
|
|
2628
2893
|
function loadProjectDiagnosticsDeltaReport(cwd) {
|
|
@@ -2639,7 +2904,7 @@ function loadProjectDiagnosticsDeltaReport(cwd) {
|
|
|
2639
2904
|
}
|
|
2640
2905
|
function writeProjectDiagnosticsDeltaReport(cwd, report) {
|
|
2641
2906
|
const filePath = cachePath(cwd, DELTA_CACHE_FILE);
|
|
2642
|
-
|
|
2907
|
+
fs6.mkdirSync(path6.dirname(filePath), { recursive: true });
|
|
2643
2908
|
writeFileAtomic(filePath, JSON.stringify(report, null, 2));
|
|
2644
2909
|
}
|
|
2645
2910
|
function reconcileProjectDiagnosticsSnapshot(snapshot) {
|
|
@@ -2654,7 +2919,7 @@ function reconcileProjectDiagnosticsSnapshot(snapshot) {
|
|
|
2654
2919
|
let stale;
|
|
2655
2920
|
let stat;
|
|
2656
2921
|
try {
|
|
2657
|
-
stat =
|
|
2922
|
+
stat = fs6.statSync(filePath);
|
|
2658
2923
|
} catch {
|
|
2659
2924
|
stat = void 0;
|
|
2660
2925
|
}
|
|
@@ -2663,7 +2928,7 @@ function reconcileProjectDiagnosticsSnapshot(snapshot) {
|
|
|
2663
2928
|
stale = true;
|
|
2664
2929
|
if (stat.size === fingerprint2.sizeBytes) {
|
|
2665
2930
|
try {
|
|
2666
|
-
stale = hashDiagnosticContent(
|
|
2931
|
+
stale = hashDiagnosticContent(fs6.readFileSync(filePath, "utf-8")) !== fingerprint2.contentHash;
|
|
2667
2932
|
} catch {
|
|
2668
2933
|
stale = true;
|
|
2669
2934
|
}
|
|
@@ -2707,7 +2972,7 @@ function normalizeSemantic(diagnostic) {
|
|
|
2707
2972
|
}
|
|
2708
2973
|
function fromDispatchDiagnostic(diagnostic, runner) {
|
|
2709
2974
|
return {
|
|
2710
|
-
filePath:
|
|
2975
|
+
filePath: path7.resolve(diagnostic.filePath),
|
|
2711
2976
|
line: diagnostic.line,
|
|
2712
2977
|
column: diagnostic.column,
|
|
2713
2978
|
severity: normalizeSeverity(diagnostic.severity),
|
|
@@ -2810,14 +3075,14 @@ async function scanFileMajorRules(cwd, files, signal) {
|
|
|
2810
3075
|
}
|
|
2811
3076
|
if (isTestFile(filePath))
|
|
2812
3077
|
continue;
|
|
2813
|
-
const ext =
|
|
3078
|
+
const ext = path7.extname(filePath);
|
|
2814
3079
|
const grammarId = TREE_SITTER_EXT_TO_LANG[ext];
|
|
2815
3080
|
const langId = grammarId && hasTreeSitterRules(grammarId) ? grammarId : void 0;
|
|
2816
3081
|
const factEligible = isJstsFactFile(filePath);
|
|
2817
3082
|
let astGrepLang;
|
|
2818
3083
|
if (sgModule && canHandle(filePath)) {
|
|
2819
3084
|
try {
|
|
2820
|
-
if (
|
|
3085
|
+
if (fs7.statSync(filePath).size <= AST_GREP_MAX_FILE_BYTES) {
|
|
2821
3086
|
astGrepLang = getLang(filePath, sgModule);
|
|
2822
3087
|
}
|
|
2823
3088
|
} catch {
|
|
@@ -2830,7 +3095,7 @@ async function scanFileMajorRules(cwd, files, signal) {
|
|
|
2830
3095
|
let content;
|
|
2831
3096
|
let contentBytes;
|
|
2832
3097
|
try {
|
|
2833
|
-
const buf =
|
|
3098
|
+
const buf = fs7.readFileSync(filePath);
|
|
2834
3099
|
contentBytes = buf.length;
|
|
2835
3100
|
content = buf.toString("utf-8");
|
|
2836
3101
|
} catch {
|
|
@@ -2889,7 +3154,7 @@ async function scanFileMajorRules(cwd, files, signal) {
|
|
|
2889
3154
|
} finally {
|
|
2890
3155
|
facts.dropFileFacts(filePath);
|
|
2891
3156
|
}
|
|
2892
|
-
await new Promise((
|
|
3157
|
+
await new Promise((resolve32) => setImmediate(resolve32));
|
|
2893
3158
|
}
|
|
2894
3159
|
if (wasmAborted) {
|
|
2895
3160
|
astGrep.length = 0;
|
|
@@ -2940,9 +3205,9 @@ async function scanFileMajorRules(cwd, files, signal) {
|
|
|
2940
3205
|
};
|
|
2941
3206
|
}
|
|
2942
3207
|
async function scanProjectDiagnostics(options) {
|
|
2943
|
-
const cwd =
|
|
3208
|
+
const cwd = path7.resolve(options.cwd);
|
|
2944
3209
|
const { signal } = options;
|
|
2945
|
-
if (!options.files && isAtOrAboveHomeDir(realpathOrResolve(cwd), realpathOrResolve(options.homeDir ??
|
|
3210
|
+
if (!options.files && isAtOrAboveHomeDir(realpathOrResolve(cwd), realpathOrResolve(options.homeDir ?? os2.homedir()))) {
|
|
2946
3211
|
return {
|
|
2947
3212
|
version: PROJECT_DIAGNOSTICS_CACHE_VERSION,
|
|
2948
3213
|
cwd,
|
|
@@ -3027,13 +3292,13 @@ async function scanProjectDiagnostics(options) {
|
|
|
3027
3292
|
|
|
3028
3293
|
// dist/clients/mcp/review.js
|
|
3029
3294
|
import { spawn } from "node:child_process";
|
|
3030
|
-
import { existsSync as
|
|
3031
|
-
import { join as
|
|
3295
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
3296
|
+
import { join as join7 } from "node:path";
|
|
3032
3297
|
function resolveRebuildScript(serverFilePath) {
|
|
3033
3298
|
return toPosix(serverFilePath).includes("/dist/") ? "build:dist" : "build";
|
|
3034
3299
|
}
|
|
3035
3300
|
function analyzeFileFresh(workerPath, file, cwd, options = {}, timeoutMs = 12e4) {
|
|
3036
|
-
return new Promise((
|
|
3301
|
+
return new Promise((resolve32) => {
|
|
3037
3302
|
const args = [workerPath, `--file=${file}`, `--cwd=${cwd}`];
|
|
3038
3303
|
if (options.flags)
|
|
3039
3304
|
args.push(`--flags=${JSON.stringify(options.flags)}`);
|
|
@@ -3043,7 +3308,7 @@ function analyzeFileFresh(workerPath, file, cwd, options = {}, timeoutMs = 12e4)
|
|
|
3043
3308
|
stdio: ["ignore", "pipe", "pipe"]
|
|
3044
3309
|
});
|
|
3045
3310
|
} catch (err) {
|
|
3046
|
-
|
|
3311
|
+
resolve32({
|
|
3047
3312
|
error: `failed to fork worker: ${err instanceof Error ? err.message : String(err)}`
|
|
3048
3313
|
});
|
|
3049
3314
|
return;
|
|
@@ -3056,7 +3321,7 @@ function analyzeFileFresh(workerPath, file, cwd, options = {}, timeoutMs = 12e4)
|
|
|
3056
3321
|
return;
|
|
3057
3322
|
settled = true;
|
|
3058
3323
|
clearTimeout(timer);
|
|
3059
|
-
|
|
3324
|
+
resolve32(outcome);
|
|
3060
3325
|
};
|
|
3061
3326
|
const timer = setTimeout(() => {
|
|
3062
3327
|
child.kill();
|
|
@@ -3114,7 +3379,7 @@ function analyzeFileFresh(workerPath, file, cwd, options = {}, timeoutMs = 12e4)
|
|
|
3114
3379
|
}
|
|
3115
3380
|
function canRebuildPiLens(repoRoot) {
|
|
3116
3381
|
const inNodeModules = /(^|[\\/])node_modules([\\/]|$)/i.test(repoRoot);
|
|
3117
|
-
return !inNodeModules &&
|
|
3382
|
+
return !inNodeModules && existsSync5(join7(repoRoot, "tsconfig.dist.json"));
|
|
3118
3383
|
}
|
|
3119
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.";
|
|
3120
3385
|
async function runRebuild(repoRoot, script, timeoutMs = 3e5) {
|
|
@@ -3163,7 +3428,7 @@ function summarizeScan(diagnostics) {
|
|
|
3163
3428
|
|
|
3164
3429
|
// dist/clients/mcp/session.js
|
|
3165
3430
|
import * as crypto from "node:crypto";
|
|
3166
|
-
import * as
|
|
3431
|
+
import * as fs18 from "node:fs";
|
|
3167
3432
|
|
|
3168
3433
|
// dist/clients/bootstrap.js
|
|
3169
3434
|
var residentClients = null;
|
|
@@ -3220,28 +3485,28 @@ async function buildBootstrapClients() {
|
|
|
3220
3485
|
}
|
|
3221
3486
|
}
|
|
3222
3487
|
const [ruffClient, biomeClient, knipClient, todoScanner, jscpdClient, depChecker, testRunnerClient, complexityClient, goClient, govulncheckClient, gitleaksClient, trivyClient, opengrepClient, rustClient, agentBehaviorClient2, deadCodeClients] = await Promise.all([
|
|
3223
|
-
load("ruff", async () => new (await import("../chunk-
|
|
3224
|
-
load("biome", async () => new (await import("../chunk-
|
|
3225
|
-
load("knip", async () => new (await import("../chunk-
|
|
3226
|
-
load("todo", async () => new (await import("../chunk-
|
|
3227
|
-
load("jscpd", async () => new (await import("../chunk-
|
|
3228
|
-
load("dependency-checker", async () => new (await import("../chunk-
|
|
3229
|
-
load("test-runner", async () => new (await import("../chunk-
|
|
3230
|
-
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()),
|
|
3231
3496
|
// The process-wide singleton, NOT a fresh instance (#2455 fix round 4,
|
|
3232
3497
|
// F2). `handleSessionStart` reads this object for its "Active tools"
|
|
3233
3498
|
// line while `resetGoAvailability` re-arms the singleton's latch; a
|
|
3234
3499
|
// second instance here meant the reset never reached the surface a
|
|
3235
3500
|
// user actually sees.
|
|
3236
|
-
load("go", async () => (await import("../chunk-
|
|
3237
|
-
load("govulncheck", async () => new (await import("../chunk-
|
|
3238
|
-
load("gitleaks", async () => new (await import("../chunk-
|
|
3239
|
-
load("trivy", async () => new (await import("../chunk-
|
|
3240
|
-
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()),
|
|
3241
3506
|
// The process-wide singleton, for the same reason as "go" above.
|
|
3242
|
-
load("rust", async () => (await import("../chunk-
|
|
3243
|
-
load("agent-behavior", async () => (await import("../chunk-
|
|
3244
|
-
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())
|
|
3245
3510
|
]);
|
|
3246
3511
|
if (failures.length > 0)
|
|
3247
3512
|
await logBootstrapFailures(failures);
|
|
@@ -3327,7 +3592,7 @@ function resetAnalyzerBootstrapSessionState() {
|
|
|
3327
3592
|
}
|
|
3328
3593
|
|
|
3329
3594
|
// dist/clients/formatters-lazy.js
|
|
3330
|
-
var lazyFormatters = createLazyImport(() => import("../chunk-
|
|
3595
|
+
var lazyFormatters = createLazyImport(() => import("../chunk-OFKKMXWM.js"));
|
|
3331
3596
|
function warmFormatters() {
|
|
3332
3597
|
return lazyFormatters.get();
|
|
3333
3598
|
}
|
|
@@ -3346,14 +3611,14 @@ function resetFormatService() {
|
|
|
3346
3611
|
|
|
3347
3612
|
// dist/clients/runtime-coordinator.js
|
|
3348
3613
|
import { randomBytes } from "node:crypto";
|
|
3349
|
-
import * as
|
|
3350
|
-
import * as
|
|
3614
|
+
import * as fs9 from "node:fs";
|
|
3615
|
+
import * as path9 from "node:path";
|
|
3351
3616
|
|
|
3352
3617
|
// dist/clients/project-changes.js
|
|
3353
|
-
import * as
|
|
3354
|
-
import * as
|
|
3618
|
+
import * as fs8 from "node:fs";
|
|
3619
|
+
import * as path8 from "node:path";
|
|
3355
3620
|
function getProjectChangeLogPath(cwd) {
|
|
3356
|
-
return
|
|
3621
|
+
return path8.join(getProjectDataDir(cwd), "change-log.jsonl");
|
|
3357
3622
|
}
|
|
3358
3623
|
function parseChangeLine(line) {
|
|
3359
3624
|
try {
|
|
@@ -3389,7 +3654,7 @@ function parseChangeLog(logPath, content) {
|
|
|
3389
3654
|
function readProjectChanges(cwd) {
|
|
3390
3655
|
const logPath = getProjectChangeLogPath(cwd);
|
|
3391
3656
|
try {
|
|
3392
|
-
return parseChangeLog(logPath,
|
|
3657
|
+
return parseChangeLog(logPath, fs8.readFileSync(logPath, "utf-8"));
|
|
3393
3658
|
} catch {
|
|
3394
3659
|
return [];
|
|
3395
3660
|
}
|
|
@@ -3397,7 +3662,7 @@ function readProjectChanges(cwd) {
|
|
|
3397
3662
|
async function readProjectChangesAsync(cwd) {
|
|
3398
3663
|
const logPath = getProjectChangeLogPath(cwd);
|
|
3399
3664
|
try {
|
|
3400
|
-
return parseChangeLog(logPath, await
|
|
3665
|
+
return parseChangeLog(logPath, await fs8.promises.readFile(logPath, "utf-8"));
|
|
3401
3666
|
} catch {
|
|
3402
3667
|
return [];
|
|
3403
3668
|
}
|
|
@@ -3405,7 +3670,7 @@ async function readProjectChangesAsync(cwd) {
|
|
|
3405
3670
|
var _sequenceFoldCountForTests = 0;
|
|
3406
3671
|
function foldEntry(entry, fileSeqByPath) {
|
|
3407
3672
|
_sequenceFoldCountForTests++;
|
|
3408
|
-
const key = normalizeMapKey(
|
|
3673
|
+
const key = normalizeMapKey(path8.resolve(entry.filePath));
|
|
3409
3674
|
fileSeqByPath.set(key, Math.max(fileSeqByPath.get(key) ?? 0, entry.fileSeq));
|
|
3410
3675
|
}
|
|
3411
3676
|
function fullReplay(entries) {
|
|
@@ -3453,7 +3718,7 @@ async function readLatestProjectSequenceAsync(cwd, base) {
|
|
|
3453
3718
|
function readChangeLogMaxSeq(logPath) {
|
|
3454
3719
|
let fd;
|
|
3455
3720
|
try {
|
|
3456
|
-
fd =
|
|
3721
|
+
fd = fs8.openSync(logPath, "r");
|
|
3457
3722
|
} catch (err) {
|
|
3458
3723
|
if (err.code === "ENOENT")
|
|
3459
3724
|
return 0;
|
|
@@ -3461,10 +3726,10 @@ function readChangeLogMaxSeq(logPath) {
|
|
|
3461
3726
|
}
|
|
3462
3727
|
try {
|
|
3463
3728
|
const cursor = changeLogCursors.get(logPath) ?? { bytes: 0, maxSeq: 0 };
|
|
3464
|
-
const size =
|
|
3729
|
+
const size = fs8.fstatSync(fd).size;
|
|
3465
3730
|
if (size > cursor.bytes) {
|
|
3466
3731
|
const tail = Buffer.alloc(size - cursor.bytes);
|
|
3467
|
-
const read =
|
|
3732
|
+
const read = fs8.readSync(fd, tail, 0, tail.length, cursor.bytes);
|
|
3468
3733
|
const complete = tail.subarray(0, read).lastIndexOf(10) + 1;
|
|
3469
3734
|
for (const line of tail.subarray(0, complete).toString("utf-8").split("\n")) {
|
|
3470
3735
|
const entry = line.trim() ? parseChangeLine(line) : void 0;
|
|
@@ -3476,7 +3741,7 @@ function readChangeLogMaxSeq(logPath) {
|
|
|
3476
3741
|
changeLogCursors.set(logPath, cursor);
|
|
3477
3742
|
return cursor.maxSeq;
|
|
3478
3743
|
} finally {
|
|
3479
|
-
|
|
3744
|
+
fs8.closeSync(fd);
|
|
3480
3745
|
}
|
|
3481
3746
|
}
|
|
3482
3747
|
var CHANGE_LOG_LOCK = { staleMs: 5e3, waitMs: 500 };
|
|
@@ -3485,14 +3750,14 @@ function appendProjectChangeAllocated(cwd, build) {
|
|
|
3485
3750
|
}
|
|
3486
3751
|
function appendProjectChangesAllocated(cwd, buildAll) {
|
|
3487
3752
|
const logPath = getProjectChangeLogPath(cwd);
|
|
3488
|
-
|
|
3753
|
+
fs8.mkdirSync(path8.dirname(logPath), { recursive: true });
|
|
3489
3754
|
readChangeLogMaxSeq(logPath);
|
|
3490
3755
|
const append = (locked) => {
|
|
3491
3756
|
const entries = buildAll(readChangeLogMaxSeq(logPath));
|
|
3492
3757
|
if (entries.length === 0)
|
|
3493
3758
|
return;
|
|
3494
3759
|
const payload = entries.map((entry) => JSON.stringify(locked ? entry : { ...entry, unlocked: true })).join("\n");
|
|
3495
|
-
|
|
3760
|
+
fs8.appendFileSync(logPath, `${payload}
|
|
3496
3761
|
`, "utf-8");
|
|
3497
3762
|
};
|
|
3498
3763
|
const result = withGenerationLockSync(`${logPath}.locks`, CHANGE_LOG_LOCK, () => append(true));
|
|
@@ -3622,7 +3887,7 @@ function recordViewIncomplete(cwd, cause) {
|
|
|
3622
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"})`;
|
|
3623
3888
|
recordDegradationOnce({
|
|
3624
3889
|
kind: "snapshot-view-incomplete",
|
|
3625
|
-
subject:
|
|
3890
|
+
subject: path9.resolve(cwd),
|
|
3626
3891
|
reason: `snapshots are stamped incomplete (never fresh) until the next seed from the change log: ${why}`
|
|
3627
3892
|
});
|
|
3628
3893
|
}
|
|
@@ -3636,10 +3901,13 @@ var MAX_OWED_ANCHORS = 16;
|
|
|
3636
3901
|
var TOOL_CALL_ATTRIBUTION_CAPACITY = 256;
|
|
3637
3902
|
var TOOL_CALL_ATTRIBUTION_TTL_MS = 5 * 6e4;
|
|
3638
3903
|
var BLOCKER_FULL_DELIVERY_CAP = 3;
|
|
3639
|
-
function narrowedRecord(existing, kept) {
|
|
3904
|
+
function narrowedRecord(existing, kept, root) {
|
|
3640
3905
|
return {
|
|
3641
3906
|
...existing,
|
|
3642
|
-
summary: formatDiagnostics(kept, "blocking"
|
|
3907
|
+
summary: formatDiagnostics(kept, "blocking", void 0, {
|
|
3908
|
+
editedFile: existing.filePath,
|
|
3909
|
+
root
|
|
3910
|
+
}).trim(),
|
|
3643
3911
|
diagnostics: kept,
|
|
3644
3912
|
sources: inlineBlockerSources(kept),
|
|
3645
3913
|
lines: inlineBlockerLines(kept, existing.filePath)
|
|
@@ -3796,6 +4064,15 @@ var RuntimeCoordinator = class {
|
|
|
3796
4064
|
* widening stays separate because it outlives a blocked call's attribution.
|
|
3797
4065
|
*/
|
|
3798
4066
|
_readWidenings = new BoundedLruCache(TOOL_CALL_ATTRIBUTION_CAPACITY);
|
|
4067
|
+
/**
|
|
4068
|
+
* #5551: per tool call, the files `recordMutationOutcome` recorded for it
|
|
4069
|
+
* while its tool ran. Its `tool_result` takes the set and dispatches each
|
|
4070
|
+
* file, whatever the tool is named, so no producer reports its own writes
|
|
4071
|
+
* and no table admits it by name. A call with no `tool_result` (a blocked
|
|
4072
|
+
* call, a tool run outside pi) is evicted by the same bound as an
|
|
4073
|
+
* attribution; a set holds the files of one call.
|
|
4074
|
+
*/
|
|
4075
|
+
_callWrites = new BoundedLruCache(TOOL_CALL_ATTRIBUTION_CAPACITY);
|
|
3799
4076
|
/**
|
|
3800
4077
|
* #5120: a call whose `edits` were rewritten to the matched subset of a
|
|
3801
4078
|
* partly matching batch, keyed by that call's own `event.input`. pi hands
|
|
@@ -3911,6 +4188,7 @@ var RuntimeCoordinator = class {
|
|
|
3911
4188
|
this._pendingDeferredMutations.clear();
|
|
3912
4189
|
this._toolCallAttributions.clear();
|
|
3913
4190
|
this._readWidenings.clear();
|
|
4191
|
+
this._callWrites.clear();
|
|
3914
4192
|
this._lspReadWarmState.clear();
|
|
3915
4193
|
this._pendingInlineBlockers.clear();
|
|
3916
4194
|
this._owedRunners.clear();
|
|
@@ -3951,12 +4229,12 @@ var RuntimeCoordinator = class {
|
|
|
3951
4229
|
* the map is already what the policy just decided.
|
|
3952
4230
|
*/
|
|
3953
4231
|
applyInlineBlockerPolicyVerdicts(suppressedFilePaths, of) {
|
|
3954
|
-
const suppressed = new Set(suppressedFilePaths.map((filePath) =>
|
|
4232
|
+
const suppressed = new Set(suppressedFilePaths.map((filePath) => path9.resolve(filePath)));
|
|
3955
4233
|
let changed = 0;
|
|
3956
4234
|
for (const [key, entry] of this._pendingInlineBlockers.entries()) {
|
|
3957
4235
|
if (of && !this.ownedBy(entry, of.sessionId))
|
|
3958
4236
|
continue;
|
|
3959
|
-
const policySuppressed = suppressed.has(
|
|
4237
|
+
const policySuppressed = suppressed.has(path9.resolve(entry.filePath));
|
|
3960
4238
|
if ((entry.policySuppressed ?? false) === policySuppressed)
|
|
3961
4239
|
continue;
|
|
3962
4240
|
this._pendingInlineBlockers.set(key, { ...entry, policySuppressed });
|
|
@@ -4133,7 +4411,7 @@ var RuntimeCoordinator = class {
|
|
|
4133
4411
|
sessionId: this.turnSession(args.sessionId),
|
|
4134
4412
|
turnIndex: this.turnIndex,
|
|
4135
4413
|
source: args.source,
|
|
4136
|
-
filePath:
|
|
4414
|
+
filePath: path9.resolve(args.filePath),
|
|
4137
4415
|
fileSeq: logged.fileSeq,
|
|
4138
4416
|
changedRange: args.changedRange
|
|
4139
4417
|
};
|
|
@@ -4181,7 +4459,7 @@ var RuntimeCoordinator = class {
|
|
|
4181
4459
|
sessionId: this.telemetrySessionId,
|
|
4182
4460
|
turnIndex: this.turnIndex,
|
|
4183
4461
|
source: args.source,
|
|
4184
|
-
filePath:
|
|
4462
|
+
filePath: path9.resolve(paths[index]),
|
|
4185
4463
|
fileSeq: bump.fileSeq
|
|
4186
4464
|
}));
|
|
4187
4465
|
});
|
|
@@ -4364,7 +4642,7 @@ var RuntimeCoordinator = class {
|
|
|
4364
4642
|
this._fileSeq.clear();
|
|
4365
4643
|
this._fileLastProjectSeq.clear();
|
|
4366
4644
|
for (const [filePath, seq] of fileSeqByPath ?? []) {
|
|
4367
|
-
this._fileSeq.set(normalizeMapKey(
|
|
4645
|
+
this._fileSeq.set(normalizeMapKey(path9.resolve(filePath)), Math.max(0, seq));
|
|
4368
4646
|
}
|
|
4369
4647
|
}
|
|
4370
4648
|
/**
|
|
@@ -4382,14 +4660,14 @@ var RuntimeCoordinator = class {
|
|
|
4382
4660
|
this._projectSeq = Math.max(this._projectSeq, Math.floor(projectSeq));
|
|
4383
4661
|
this._viewLogEntries = Math.max(this._viewLogEntries, logEntries);
|
|
4384
4662
|
for (const [filePath, seq] of fileSeqByPath) {
|
|
4385
|
-
const key = normalizeMapKey(
|
|
4663
|
+
const key = normalizeMapKey(path9.resolve(filePath));
|
|
4386
4664
|
this._fileSeq.set(key, Math.max(this._fileSeq.get(key) ?? 0, seq));
|
|
4387
4665
|
}
|
|
4388
4666
|
if (projectSeq >= this._viewMissingThrough)
|
|
4389
4667
|
this._viewMissingThrough = 0;
|
|
4390
4668
|
}
|
|
4391
4669
|
bumpFileSeq(filePath, logMaxSeq = 0) {
|
|
4392
|
-
const key = normalizeMapKey(
|
|
4670
|
+
const key = normalizeMapKey(path9.resolve(filePath));
|
|
4393
4671
|
if (logMaxSeq > this._projectSeq) {
|
|
4394
4672
|
this._projectSeq = logMaxSeq;
|
|
4395
4673
|
this._viewMissingThrough = Math.max(this._viewMissingThrough, logMaxSeq);
|
|
@@ -4416,7 +4694,7 @@ var RuntimeCoordinator = class {
|
|
|
4416
4694
|
return changed;
|
|
4417
4695
|
}
|
|
4418
4696
|
getFileSeq(filePath) {
|
|
4419
|
-
return this._fileSeq.get(normalizeMapKey(
|
|
4697
|
+
return this._fileSeq.get(normalizeMapKey(path9.resolve(filePath))) ?? 0;
|
|
4420
4698
|
}
|
|
4421
4699
|
getFileSeqEntries() {
|
|
4422
4700
|
return [...this._fileSeq.entries()];
|
|
@@ -4452,7 +4730,7 @@ var RuntimeCoordinator = class {
|
|
|
4452
4730
|
return this._startupScansInFlight.has(name);
|
|
4453
4731
|
}
|
|
4454
4732
|
formatPipelineCrashNotice(filePath, err) {
|
|
4455
|
-
const key =
|
|
4733
|
+
const key = path9.resolve(filePath);
|
|
4456
4734
|
const count = (this._pipelineCrashCounts.get(key) ?? 0) + 1;
|
|
4457
4735
|
this._pipelineCrashCounts.set(key, count);
|
|
4458
4736
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -4462,7 +4740,7 @@ var RuntimeCoordinator = class {
|
|
|
4462
4740
|
return "";
|
|
4463
4741
|
return [
|
|
4464
4742
|
"\u26A0\uFE0F pi-lens pipeline crashed while analyzing this write.",
|
|
4465
|
-
`File: ${
|
|
4743
|
+
`File: ${path9.basename(filePath)} | crash count this session: ${count}`,
|
|
4466
4744
|
`Error: ${shortMessage}`,
|
|
4467
4745
|
"Recovery: LSP service was reset. If this repeats, rerun with --no-lsp and report the file + stack."
|
|
4468
4746
|
].join("\n");
|
|
@@ -4559,8 +4837,8 @@ var RuntimeCoordinator = class {
|
|
|
4559
4837
|
});
|
|
4560
4838
|
return entry;
|
|
4561
4839
|
});
|
|
4562
|
-
const timeout = new Promise((
|
|
4563
|
-
setTimeout(
|
|
4840
|
+
const timeout = new Promise((resolve32) => {
|
|
4841
|
+
setTimeout(resolve32, maxWaitMs).unref?.();
|
|
4564
4842
|
});
|
|
4565
4843
|
await Promise.race([
|
|
4566
4844
|
Promise.allSettled(tracked.map((t) => t.promise)),
|
|
@@ -4702,7 +4980,10 @@ var RuntimeCoordinator = class {
|
|
|
4702
4980
|
} : {},
|
|
4703
4981
|
...this.recordSession(sessionId)
|
|
4704
4982
|
},
|
|
4705
|
-
summary: formatDiagnostics(diagnostics, "blocking"
|
|
4983
|
+
summary: formatDiagnostics(diagnostics, "blocking", void 0, {
|
|
4984
|
+
editedFile: filePath,
|
|
4985
|
+
root: this.projectRoot || void 0
|
|
4986
|
+
}).trim(),
|
|
4706
4987
|
diagnostics,
|
|
4707
4988
|
// The same two derivations the pipeline's writer uses: `lines` keeps only
|
|
4708
4989
|
// this file's own rows, `sources` pins an untagged finding as "unknown".
|
|
@@ -4801,7 +5082,7 @@ var RuntimeCoordinator = class {
|
|
|
4801
5082
|
this._pendingInlineBlockers.delete(key);
|
|
4802
5083
|
return retired.length;
|
|
4803
5084
|
}
|
|
4804
|
-
this._pendingInlineBlockers.set(key, narrowedRecord(existing, kept));
|
|
5085
|
+
this._pendingInlineBlockers.set(key, narrowedRecord(existing, kept, this.projectRoot || void 0));
|
|
4805
5086
|
return retired.length;
|
|
4806
5087
|
}
|
|
4807
5088
|
/**
|
|
@@ -5206,7 +5487,7 @@ var RuntimeCoordinator = class {
|
|
|
5206
5487
|
this._pendingInlineBlockers.delete(key);
|
|
5207
5488
|
return true;
|
|
5208
5489
|
}
|
|
5209
|
-
this._pendingInlineBlockers.set(key, narrowedRecord(existing, kept));
|
|
5490
|
+
this._pendingInlineBlockers.set(key, narrowedRecord(existing, kept, this.projectRoot || void 0));
|
|
5210
5491
|
return true;
|
|
5211
5492
|
}
|
|
5212
5493
|
/**
|
|
@@ -5271,7 +5552,7 @@ var RuntimeCoordinator = class {
|
|
|
5271
5552
|
this.noteResolvedBlockerFile(existing, void 0, true);
|
|
5272
5553
|
this._pendingInlineBlockers.delete(key);
|
|
5273
5554
|
} else {
|
|
5274
|
-
this._pendingInlineBlockers.set(key, narrowedRecord(existing, kept));
|
|
5555
|
+
this._pendingInlineBlockers.set(key, narrowedRecord(existing, kept, this.projectRoot || void 0));
|
|
5275
5556
|
}
|
|
5276
5557
|
}
|
|
5277
5558
|
return changed;
|
|
@@ -5293,7 +5574,7 @@ var RuntimeCoordinator = class {
|
|
|
5293
5574
|
* to retire.
|
|
5294
5575
|
*/
|
|
5295
5576
|
retireForeignRowsOfMissingFiles(of) {
|
|
5296
|
-
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);
|
|
5297
5578
|
}
|
|
5298
5579
|
/**
|
|
5299
5580
|
* #3218 criterion 2: a retirement no turn_end has delivered yet. The
|
|
@@ -5338,7 +5619,7 @@ var RuntimeCoordinator = class {
|
|
|
5338
5619
|
reconcileInlineBlockers() {
|
|
5339
5620
|
const survivors = [];
|
|
5340
5621
|
for (const [displayPath, value] of this._pendingInlineBlockers.entries()) {
|
|
5341
|
-
if (
|
|
5622
|
+
if (fs9.existsSync(displayPath))
|
|
5342
5623
|
survivors.push([displayPath, value]);
|
|
5343
5624
|
}
|
|
5344
5625
|
if (survivors.length !== this._pendingInlineBlockers.size) {
|
|
@@ -5538,6 +5819,39 @@ var RuntimeCoordinator = class {
|
|
|
5538
5819
|
this._readWidenings.delete(toolCallId);
|
|
5539
5820
|
return widening;
|
|
5540
5821
|
}
|
|
5822
|
+
/**
|
|
5823
|
+
* #5551: `recordMutationOutcome` recorded `filePath` for this call. The
|
|
5824
|
+
* id is the producer's raw one (the tool's `execute` argument); the
|
|
5825
|
+
* `tool_result` reads it as `resolveToolCallCorrelationId` spells it, so
|
|
5826
|
+
* both sides key by `sanitizeCorrelationId` (a pi-ai `call_id|item_id`
|
|
5827
|
+
* host id differs raw versus sanitized; review r1 F1 on #5635). The
|
|
5828
|
+
* result is a no-op on an id already sanitized.
|
|
5829
|
+
*/
|
|
5830
|
+
noteCallWrite(rawToolCallId, filePath) {
|
|
5831
|
+
const toolCallId = sanitizeCorrelationId(rawToolCallId);
|
|
5832
|
+
if (toolCallId === void 0)
|
|
5833
|
+
return;
|
|
5834
|
+
const written = this._callWrites.get(toolCallId);
|
|
5835
|
+
if (written)
|
|
5836
|
+
written.add(filePath);
|
|
5837
|
+
else
|
|
5838
|
+
this._callWrites.set(toolCallId, /* @__PURE__ */ new Set([filePath]));
|
|
5839
|
+
}
|
|
5840
|
+
/** #5551: the files recorded for this call so far, in record order. */
|
|
5841
|
+
peekCallWrites(rawToolCallId) {
|
|
5842
|
+
const toolCallId = sanitizeCorrelationId(rawToolCallId);
|
|
5843
|
+
if (toolCallId === void 0)
|
|
5844
|
+
return [];
|
|
5845
|
+
return [...this._callWrites.get(toolCallId) ?? []];
|
|
5846
|
+
}
|
|
5847
|
+
/** #5551: one-shot claim of a call's files, as with an attribution. */
|
|
5848
|
+
takeCallWrites(rawToolCallId) {
|
|
5849
|
+
const written = this.peekCallWrites(rawToolCallId);
|
|
5850
|
+
const toolCallId = sanitizeCorrelationId(rawToolCallId);
|
|
5851
|
+
if (toolCallId !== void 0)
|
|
5852
|
+
this._callWrites.delete(toolCallId);
|
|
5853
|
+
return written;
|
|
5854
|
+
}
|
|
5541
5855
|
/** #3523: see {@link ToolCallAttribution.editInPlace}. */
|
|
5542
5856
|
markToolCallEditInPlace(toolCallId) {
|
|
5543
5857
|
const attribution = this._toolCallAttributions.get(toolCallId);
|
|
@@ -5760,7 +6074,7 @@ var RuntimeCoordinator = class {
|
|
|
5760
6074
|
this.requeueDeferredFormatFiles(records2, capFormatFailures);
|
|
5761
6075
|
}
|
|
5762
6076
|
shouldWarmLspOnRead(filePath, maxAgeMs = 12e4) {
|
|
5763
|
-
const state = this._lspReadWarmState.get(
|
|
6077
|
+
const state = this._lspReadWarmState.get(path9.resolve(filePath));
|
|
5764
6078
|
if (!state)
|
|
5765
6079
|
return true;
|
|
5766
6080
|
if (state.status === "warming")
|
|
@@ -5768,26 +6082,26 @@ var RuntimeCoordinator = class {
|
|
|
5768
6082
|
return Date.now() - state.ts > maxAgeMs;
|
|
5769
6083
|
}
|
|
5770
6084
|
markLspReadWarmStarted(filePath) {
|
|
5771
|
-
this._lspReadWarmState.set(
|
|
6085
|
+
this._lspReadWarmState.set(path9.resolve(filePath), {
|
|
5772
6086
|
status: "warming",
|
|
5773
6087
|
ts: Date.now()
|
|
5774
6088
|
});
|
|
5775
6089
|
}
|
|
5776
6090
|
markLspReadWarmCompleted(filePath) {
|
|
5777
|
-
this._lspReadWarmState.set(
|
|
6091
|
+
this._lspReadWarmState.set(path9.resolve(filePath), {
|
|
5778
6092
|
status: "ready",
|
|
5779
6093
|
ts: Date.now()
|
|
5780
6094
|
});
|
|
5781
6095
|
}
|
|
5782
6096
|
clearLspReadWarmState(filePath) {
|
|
5783
|
-
this._lspReadWarmState.delete(
|
|
6097
|
+
this._lspReadWarmState.delete(path9.resolve(filePath));
|
|
5784
6098
|
}
|
|
5785
6099
|
};
|
|
5786
6100
|
|
|
5787
6101
|
// dist/clients/runtime-session.js
|
|
5788
6102
|
import * as nodeFs from "node:fs";
|
|
5789
|
-
import * as
|
|
5790
|
-
import * as
|
|
6103
|
+
import * as os3 from "node:os";
|
|
6104
|
+
import * as path14 from "node:path";
|
|
5791
6105
|
|
|
5792
6106
|
// dist/clients/message-end-attribution.js
|
|
5793
6107
|
var lastStableSessionId;
|
|
@@ -5800,10 +6114,10 @@ function rotateMessageEndAttribution() {
|
|
|
5800
6114
|
}
|
|
5801
6115
|
|
|
5802
6116
|
// dist/clients/dead-code-logger.js
|
|
5803
|
-
import * as
|
|
6117
|
+
import * as path10 from "node:path";
|
|
5804
6118
|
var LOG_DIR = getGlobalPiLensLogDir();
|
|
5805
|
-
var LOG_FILE =
|
|
5806
|
-
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");
|
|
5807
6121
|
var MAX_LOG_BYTES = Math.max(128 * 1024, Number.parseInt(process.env.PI_LENS_DEAD_CODE_LOG_MAX_BYTES ?? "1048576", 10) || 1048576);
|
|
5808
6122
|
var writer = createNdjsonLogger({
|
|
5809
6123
|
filePath: LOG_FILE,
|
|
@@ -5822,8 +6136,8 @@ function isPrintMode(argv = process.argv) {
|
|
|
5822
6136
|
}
|
|
5823
6137
|
|
|
5824
6138
|
// dist/clients/rules-scanner.js
|
|
5825
|
-
import * as
|
|
5826
|
-
import * as
|
|
6139
|
+
import * as fs10 from "node:fs";
|
|
6140
|
+
import * as path11 from "node:path";
|
|
5827
6141
|
var RULE_DIRS = [
|
|
5828
6142
|
{ dir: ".claude/rules", source: ".claude/rules" },
|
|
5829
6143
|
{ dir: ".agents/rules", source: ".agents/rules" }
|
|
@@ -5839,22 +6153,22 @@ function findMarkdownFiles(dir, baseDir, depth = 0, collected = { count: 0 }) {
|
|
|
5839
6153
|
const results = [];
|
|
5840
6154
|
if (depth > RULES_SCAN_MAX_DEPTH)
|
|
5841
6155
|
return results;
|
|
5842
|
-
if (!
|
|
6156
|
+
if (!fs10.existsSync(dir))
|
|
5843
6157
|
return results;
|
|
5844
|
-
const entries =
|
|
6158
|
+
const entries = fs10.readdirSync(dir, { withFileTypes: true });
|
|
5845
6159
|
for (const entry of entries) {
|
|
5846
6160
|
if (collected.count >= RULES_SCAN_MAX_FILES)
|
|
5847
6161
|
break;
|
|
5848
|
-
const fullPath =
|
|
6162
|
+
const fullPath = path11.join(dir, entry.name);
|
|
5849
6163
|
if (entry.isDirectory()) {
|
|
5850
6164
|
results.push(...findMarkdownFiles(fullPath, baseDir, depth + 1, collected));
|
|
5851
6165
|
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
5852
6166
|
collected.count += 1;
|
|
5853
6167
|
results.push({
|
|
5854
|
-
source:
|
|
6168
|
+
source: path11.relative(baseDir, dir) || path11.basename(baseDir),
|
|
5855
6169
|
name: entry.name,
|
|
5856
6170
|
filePath: fullPath,
|
|
5857
|
-
relativePath: toPosix(
|
|
6171
|
+
relativePath: toPosix(path11.relative(baseDir, fullPath))
|
|
5858
6172
|
});
|
|
5859
6173
|
}
|
|
5860
6174
|
}
|
|
@@ -5863,9 +6177,9 @@ function findMarkdownFiles(dir, baseDir, depth = 0, collected = { count: 0 }) {
|
|
|
5863
6177
|
function scanProjectRules(cwd) {
|
|
5864
6178
|
const rules = [];
|
|
5865
6179
|
for (const { dir, source } of RULE_DIRS) {
|
|
5866
|
-
const dirPath =
|
|
5867
|
-
if (
|
|
5868
|
-
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));
|
|
5869
6183
|
for (const rule of found) {
|
|
5870
6184
|
rules.push({
|
|
5871
6185
|
source,
|
|
@@ -5877,8 +6191,8 @@ function scanProjectRules(cwd) {
|
|
|
5877
6191
|
}
|
|
5878
6192
|
}
|
|
5879
6193
|
for (const { file, source } of RULE_FILES) {
|
|
5880
|
-
const filePath =
|
|
5881
|
-
if (
|
|
6194
|
+
const filePath = path11.join(cwd, file);
|
|
6195
|
+
if (fs10.existsSync(filePath)) {
|
|
5882
6196
|
rules.push({
|
|
5883
6197
|
source,
|
|
5884
6198
|
name: file,
|
|
@@ -5894,8 +6208,8 @@ function scanProjectRules(cwd) {
|
|
|
5894
6208
|
}
|
|
5895
6209
|
|
|
5896
6210
|
// dist/clients/smells-rollup.js
|
|
5897
|
-
import * as
|
|
5898
|
-
import * as
|
|
6211
|
+
import * as fs11 from "node:fs";
|
|
6212
|
+
import * as path12 from "node:path";
|
|
5899
6213
|
var SMELLS_TAIL_BYTES_PER_FILE = 64 * 1024;
|
|
5900
6214
|
var SMELLS_ROLLING_WINDOW_MS = 24 * 60 * 6e4;
|
|
5901
6215
|
var SMELLS_THRESHOLDS = {
|
|
@@ -5910,18 +6224,18 @@ var SMELL_KEYS = ["staleCtxEmitFailed", "opengrepRespawn"];
|
|
|
5910
6224
|
function tailReadText(filePath, maxBytes) {
|
|
5911
6225
|
let fd;
|
|
5912
6226
|
try {
|
|
5913
|
-
fd =
|
|
6227
|
+
fd = fs11.openSync(filePath, "r");
|
|
5914
6228
|
} catch {
|
|
5915
6229
|
return "";
|
|
5916
6230
|
}
|
|
5917
6231
|
try {
|
|
5918
|
-
const size =
|
|
6232
|
+
const size = fs11.fstatSync(fd).size;
|
|
5919
6233
|
const readBytes2 = Math.min(size, maxBytes);
|
|
5920
6234
|
if (readBytes2 <= 0)
|
|
5921
6235
|
return "";
|
|
5922
6236
|
const start = size - readBytes2;
|
|
5923
6237
|
const buf = Buffer.alloc(readBytes2);
|
|
5924
|
-
|
|
6238
|
+
fs11.readSync(fd, buf, 0, readBytes2, start);
|
|
5925
6239
|
const text = buf.toString("utf8");
|
|
5926
6240
|
if (start <= 0)
|
|
5927
6241
|
return text;
|
|
@@ -5931,7 +6245,7 @@ function tailReadText(filePath, maxBytes) {
|
|
|
5931
6245
|
return "";
|
|
5932
6246
|
} finally {
|
|
5933
6247
|
try {
|
|
5934
|
-
|
|
6248
|
+
fs11.closeSync(fd);
|
|
5935
6249
|
} catch {
|
|
5936
6250
|
}
|
|
5937
6251
|
}
|
|
@@ -5968,8 +6282,8 @@ function isOpengrepRespawn(entry) {
|
|
|
5968
6282
|
}
|
|
5969
6283
|
function countRecentSmells(root = getGlobalPiLensLogDir(), sessionStartMs) {
|
|
5970
6284
|
const sinceMs = sessionStartMs ?? Date.now() - SMELLS_ROLLING_WINDOW_MS;
|
|
5971
|
-
const busTail = tailReadText(
|
|
5972
|
-
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);
|
|
5973
6287
|
return {
|
|
5974
6288
|
staleCtxEmitFailed: countMatchingLines(busTail, isStaleCtxEmitFailed, sinceMs),
|
|
5975
6289
|
opengrepRespawn: countMatchingLines(latencyTail, isOpengrepRespawn, sinceMs)
|
|
@@ -6066,10 +6380,10 @@ function emitSituationalDeadWeight() {
|
|
|
6066
6380
|
}
|
|
6067
6381
|
|
|
6068
6382
|
// dist/clients/deferred-test-targets.js
|
|
6069
|
-
import * as
|
|
6383
|
+
import * as path13 from "node:path";
|
|
6070
6384
|
var TEST_RUNNER_MAX_PERSISTED_TARGETS = 64;
|
|
6071
6385
|
function deferralEntryKey(entry) {
|
|
6072
|
-
return `${entry.sessionId ?? ""}\0${normalizeMapKey(
|
|
6386
|
+
return `${entry.sessionId ?? ""}\0${normalizeMapKey(path13.resolve(entry.testFile))}`;
|
|
6073
6387
|
}
|
|
6074
6388
|
function mergeDeferredTargets(existing, incoming) {
|
|
6075
6389
|
const byKey = /* @__PURE__ */ new Map();
|
|
@@ -6159,9 +6473,9 @@ function logHostReadyDelay(deps, cwd) {
|
|
|
6159
6473
|
});
|
|
6160
6474
|
}
|
|
6161
6475
|
function resolveSnapshotRoot(cwd) {
|
|
6162
|
-
const resolvedCwd =
|
|
6476
|
+
const resolvedCwd = path14.resolve(cwd);
|
|
6163
6477
|
const nearest = findNearestProjectRoot(resolvedCwd);
|
|
6164
|
-
if (!nearest || isAtOrAboveHomeDir(realpathOrResolve(nearest), realpathOrResolve(
|
|
6478
|
+
if (!nearest || isAtOrAboveHomeDir(realpathOrResolve(nearest), realpathOrResolve(os3.homedir()))) {
|
|
6165
6479
|
return resolvedCwd;
|
|
6166
6480
|
}
|
|
6167
6481
|
return nearest;
|
|
@@ -6411,7 +6725,7 @@ async function igniteWarmFiles(cwd, warmFiles, runtime, sessionGeneration, dbg)
|
|
|
6411
6725
|
for (const relPath of warmFiles) {
|
|
6412
6726
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
6413
6727
|
return;
|
|
6414
|
-
const filePath =
|
|
6728
|
+
const filePath = path14.isAbsolute(relPath) ? relPath : path14.resolve(cwd, relPath);
|
|
6415
6729
|
if (!nodeFs.existsSync(filePath)) {
|
|
6416
6730
|
dbg(`session_start lsp-warm: not found: ${relPath}`);
|
|
6417
6731
|
errors++;
|
|
@@ -6442,8 +6756,8 @@ async function igniteDominantLanguageWarm(cwd, runtime, sessionGeneration, dbg)
|
|
|
6442
6756
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
6443
6757
|
return;
|
|
6444
6758
|
const lspService = (await loadLspService()).getLSPService();
|
|
6445
|
-
const { collectSourceFilesAsync } = await import("../chunk-
|
|
6446
|
-
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");
|
|
6447
6761
|
const files = await collectSourceFilesAsync(cwd, {
|
|
6448
6762
|
inspectGeneratedHeaders: false
|
|
6449
6763
|
});
|
|
@@ -6477,7 +6791,7 @@ async function igniteDominantLanguageWarm(cwd, runtime, sessionGeneration, dbg)
|
|
|
6477
6791
|
clientScope: "primary",
|
|
6478
6792
|
maxClientWaitMs: 2e3
|
|
6479
6793
|
});
|
|
6480
|
-
dbg(`session_start lsp-warm: dominant=${kind} via ${
|
|
6794
|
+
dbg(`session_start lsp-warm: dominant=${kind} via ${path14.basename(sample)}`);
|
|
6481
6795
|
return;
|
|
6482
6796
|
}
|
|
6483
6797
|
dbg("session_start lsp-warm: no dominant-language LSP file found to warm");
|
|
@@ -6487,6 +6801,10 @@ async function igniteDominantLanguageWarm(cwd, runtime, sessionGeneration, dbg)
|
|
|
6487
6801
|
}
|
|
6488
6802
|
function firePreinstallDefaults(ensureTool, dbg, startupDefaults) {
|
|
6489
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
|
+
}
|
|
6490
6808
|
const startedAt = Date.now();
|
|
6491
6809
|
dbg(`session_start preinstall ${tool}: start`);
|
|
6492
6810
|
ensureTool(tool).then((toolPath) => {
|
|
@@ -6517,7 +6835,7 @@ function scheduleManagedToolRefresh(dbg, rulePack) {
|
|
|
6517
6835
|
managedToolRefreshTimer = void 0;
|
|
6518
6836
|
void (async () => {
|
|
6519
6837
|
try {
|
|
6520
|
-
const refresh = await import("../chunk-
|
|
6838
|
+
const refresh = await import("../chunk-RURPX2YV.js");
|
|
6521
6839
|
const outcome = await refresh.runManagedToolRefresh(void 0, {
|
|
6522
6840
|
rulePack
|
|
6523
6841
|
});
|
|
@@ -6537,7 +6855,7 @@ function scheduleManagedToolRefresh(dbg, rulePack) {
|
|
|
6537
6855
|
managedToolRefreshTimer = timer;
|
|
6538
6856
|
}
|
|
6539
6857
|
async function probePrettierInstall(ensureTool, dbg, analysisRoot) {
|
|
6540
|
-
const pkgPath =
|
|
6858
|
+
const pkgPath = path14.join(analysisRoot, "package.json");
|
|
6541
6859
|
try {
|
|
6542
6860
|
const raw = await nodeFs.promises.readFile(pkgPath, "utf-8");
|
|
6543
6861
|
const pkg = JSON.parse(raw);
|
|
@@ -6567,7 +6885,7 @@ function scanOneTodoFile(scanner, filePath, items) {
|
|
|
6567
6885
|
async function collectTodoBaselineItems(scanner, analysisRoot, stillCurrent) {
|
|
6568
6886
|
const items = [];
|
|
6569
6887
|
try {
|
|
6570
|
-
const { getSourceFilesAsync } = await import("../chunk-
|
|
6888
|
+
const { getSourceFilesAsync } = await import("../chunk-R5XVJ6AN.js");
|
|
6571
6889
|
const files = await getSourceFilesAsync(analysisRoot, true);
|
|
6572
6890
|
if (!stillCurrent())
|
|
6573
6891
|
return items;
|
|
@@ -6596,7 +6914,7 @@ async function buildOrRefreshWordIndex(args) {
|
|
|
6596
6914
|
const snapshot = loadProjectSnapshot(snapshotRoot);
|
|
6597
6915
|
const snapshotLoadMs = Date.now() - snapshotLoadStartMs;
|
|
6598
6916
|
if (snapshot?.wordIndex) {
|
|
6599
|
-
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");
|
|
6600
6918
|
const deserializeStartMs = Date.now();
|
|
6601
6919
|
const index = deserializeWordIndex(snapshot.wordIndex);
|
|
6602
6920
|
const deserializeMs = Date.now() - deserializeStartMs;
|
|
@@ -6669,7 +6987,7 @@ async function buildOrRefreshWordIndex(args) {
|
|
|
6669
6987
|
}
|
|
6670
6988
|
}
|
|
6671
6989
|
}
|
|
6672
|
-
const { buildWordIndexAsync, collectWordIndexDocs, countWordIndexPostingEntries, estimateWordIndexResidentBytes, notifyWordIndexPublished } = await import("../chunk-
|
|
6990
|
+
const { buildWordIndexAsync, collectWordIndexDocs, countWordIndexPostingEntries, estimateWordIndexResidentBytes, notifyWordIndexPublished } = await import("../chunk-3JJ4OAJI.js");
|
|
6673
6991
|
const docs = await collectWordIndexDocs(analysisRoot, () => runtime.isCurrentSession(sessionGeneration), rebuildPreflightFiles);
|
|
6674
6992
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
6675
6993
|
return;
|
|
@@ -6754,7 +7072,7 @@ function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analy
|
|
|
6754
7072
|
const delay = STARTUP_TASK_DEFER_MS[name] ?? 0;
|
|
6755
7073
|
dbg(`session_start task ${name}: scheduled deferMs=${delay}`);
|
|
6756
7074
|
runtime.markStartupScanInFlight(name, sessionGeneration);
|
|
6757
|
-
const completion = new Promise((
|
|
7075
|
+
const completion = new Promise((resolve32) => {
|
|
6758
7076
|
const fire = () => {
|
|
6759
7077
|
const startedAt = Date.now();
|
|
6760
7078
|
dbg(`session_start task ${name}: start queuedMs=${startedAt - queuedAt}`);
|
|
@@ -6766,7 +7084,7 @@ function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analy
|
|
|
6766
7084
|
}).finally(() => {
|
|
6767
7085
|
runtime.clearStartupScanInFlight(name, sessionGeneration);
|
|
6768
7086
|
dbg(`session_start task ${name}: end`);
|
|
6769
|
-
|
|
7087
|
+
resolve32();
|
|
6770
7088
|
});
|
|
6771
7089
|
};
|
|
6772
7090
|
if (delay > 0) {
|
|
@@ -6842,7 +7160,7 @@ function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analy
|
|
|
6842
7160
|
if (await jscpdClient.ensureAvailable()) {
|
|
6843
7161
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
6844
7162
|
return;
|
|
6845
|
-
const isTsProject = nodeFs.existsSync(
|
|
7163
|
+
const isTsProject = nodeFs.existsSync(path14.join(analysisRoot, "tsconfig.json"));
|
|
6846
7164
|
const scannerKey = isTsProject ? "jscpd-ts" : "jscpd";
|
|
6847
7165
|
const cached = cacheManager2.readCache(scannerKey, analysisRoot);
|
|
6848
7166
|
if (cached) {
|
|
@@ -7048,9 +7366,9 @@ function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analy
|
|
|
7048
7366
|
});
|
|
7049
7367
|
let callGraphIdentity;
|
|
7050
7368
|
const callGraphTask = runTask("call-graph", async () => {
|
|
7051
|
-
const { FactStore: FactStore2 } = await import("../chunk-
|
|
7052
|
-
const { buildOrUpdateGraph, extractSymbolsAndRefsFromGraph, getReviewGraphCacheIdentity } = await import("../chunk-
|
|
7053
|
-
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");
|
|
7054
7372
|
if (!runtime.isCurrentSession(sessionGeneration))
|
|
7055
7373
|
return;
|
|
7056
7374
|
const startMs = Date.now();
|
|
@@ -7091,7 +7409,7 @@ function scheduleStartupScansWithClients(deps, runtime, sessionGeneration, analy
|
|
|
7091
7409
|
return;
|
|
7092
7410
|
if (!runtime.callGraph)
|
|
7093
7411
|
return;
|
|
7094
|
-
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");
|
|
7095
7413
|
if (!callGraphIdentity)
|
|
7096
7414
|
return;
|
|
7097
7415
|
const model = buildCodebaseModel(runtime.callGraph, analysisRoot, DEFAULT_CODEBASE_MODEL_TOKEN_BUDGET, callGraphIdentity);
|
|
@@ -7180,7 +7498,6 @@ function resetSessionScopedState(cwd, sessionStartMs = Date.now()) {
|
|
|
7180
7498
|
resetRustAvailability();
|
|
7181
7499
|
resetPsScriptAnalyzerAvailability();
|
|
7182
7500
|
resetInstallRetryLatches();
|
|
7183
|
-
resetLazyInstallAttempts();
|
|
7184
7501
|
resetDirectLspCommandAvailability();
|
|
7185
7502
|
resetLSPCaseSensitivityState();
|
|
7186
7503
|
resetResolvedPathCache();
|
|
@@ -7300,8 +7617,8 @@ async function handleSessionStart(deps) {
|
|
|
7300
7617
|
try {
|
|
7301
7618
|
warmupDbg("warmup: starting background warmup");
|
|
7302
7619
|
const scanContextStartedAt = Date.now();
|
|
7303
|
-
const startupScanModule = await import("../chunk-
|
|
7304
|
-
const languageProfileModule = await import("../chunk-
|
|
7620
|
+
const startupScanModule = await import("../chunk-JBDZVOFL.js");
|
|
7621
|
+
const languageProfileModule = await import("../chunk-MGVVYYKW.js");
|
|
7305
7622
|
const warmupSnapshotRoot = resolveSnapshotRoot(warmupCwd);
|
|
7306
7623
|
const cachedSnapshot = loadProjectSnapshot(warmupSnapshotRoot);
|
|
7307
7624
|
warmupOwnSnapshotRead = cachedSnapshot ? {
|
|
@@ -7313,7 +7630,7 @@ async function handleSessionStart(deps) {
|
|
|
7313
7630
|
const cachedVerdict = cachedSnapshot?.startupScan;
|
|
7314
7631
|
let scan;
|
|
7315
7632
|
if (cachedVerdict && startupScanModule.isStartupScanVerdictFresh(cachedVerdict)) {
|
|
7316
|
-
scan = { ...cachedVerdict, cwd:
|
|
7633
|
+
scan = { ...cachedVerdict, cwd: path14.resolve(warmupCwd) };
|
|
7317
7634
|
warmupDbg(`warmup: scan-context reused from cache (canWarm=${scan.canWarmCaches}${scan.reason ? `, reason=${scan.reason}` : ""})`);
|
|
7318
7635
|
} else {
|
|
7319
7636
|
scan = await startupScanModule.resolveStartupScanContextAsync(warmupCwd);
|
|
@@ -7456,27 +7773,35 @@ async function handleSessionStart(deps) {
|
|
|
7456
7773
|
});
|
|
7457
7774
|
const cleanupCwd = ctxCwd ?? process.cwd();
|
|
7458
7775
|
setImmediate(() => {
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
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");
|
|
7472
7800
|
}
|
|
7473
|
-
})
|
|
7474
|
-
|
|
7475
|
-
notify(`\u{1F9F9} ${logCleanup.report}`, "info");
|
|
7801
|
+
} catch (err) {
|
|
7802
|
+
dbg(`session_start: deferred log cleanup failed: ${err}`);
|
|
7476
7803
|
}
|
|
7477
|
-
}
|
|
7478
|
-
dbg(`session_start: deferred log cleanup failed: ${err}`);
|
|
7479
|
-
}
|
|
7804
|
+
})();
|
|
7480
7805
|
});
|
|
7481
7806
|
dbg(`session_start startup mode: ${startupMode}`);
|
|
7482
7807
|
if (deps.keepSharedLsp) {
|
|
@@ -7490,7 +7815,7 @@ async function handleSessionStart(deps) {
|
|
|
7490
7815
|
const cwd = ctxCwd ?? process.cwd();
|
|
7491
7816
|
const projectDataDir = getProjectDataDir(cwd);
|
|
7492
7817
|
for (const migration of drainProjectDataDirMigrations()) {
|
|
7493
|
-
const targetName =
|
|
7818
|
+
const targetName = path14.basename(migration.to);
|
|
7494
7819
|
const hash = targetName.match(/([0-9a-f]{8})$/)?.[1] ?? "unknown";
|
|
7495
7820
|
if (migration.outcome === "ephemeral") {
|
|
7496
7821
|
recordDegradationOnce({
|
|
@@ -7509,11 +7834,11 @@ async function handleSessionStart(deps) {
|
|
|
7509
7834
|
const globalDir = getGlobalPiLensDir();
|
|
7510
7835
|
void sweepAtomicWriteStages([
|
|
7511
7836
|
projectDataDir,
|
|
7512
|
-
|
|
7513
|
-
|
|
7837
|
+
path14.join(projectDataDir, "cache"),
|
|
7838
|
+
path14.join(projectDataDir, "sessions"),
|
|
7514
7839
|
globalDir,
|
|
7515
|
-
|
|
7516
|
-
|
|
7840
|
+
path14.join(globalDir, "bin"),
|
|
7841
|
+
path14.join(globalDir, "tools")
|
|
7517
7842
|
]).catch(() => {
|
|
7518
7843
|
});
|
|
7519
7844
|
void sweepDeadEphemeralDataDirs({ isPidAlive: realIsPidAlive }).catch(() => {
|
|
@@ -7595,7 +7920,7 @@ async function handleSessionStart(deps) {
|
|
|
7595
7920
|
if (allowBootstrapTasks && !getFlag("no-lsp")) {
|
|
7596
7921
|
const cleaned = cleanStaleTsBuildInfo(ctxCwd ?? process.cwd());
|
|
7597
7922
|
if (cleaned.length > 0) {
|
|
7598
|
-
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");
|
|
7599
7924
|
dbg(`session_start: cleaned stale tsbuildinfo: ${cleaned.join(", ")}`);
|
|
7600
7925
|
}
|
|
7601
7926
|
}
|
|
@@ -7612,7 +7937,7 @@ async function handleSessionStart(deps) {
|
|
|
7612
7937
|
const startupScanSource = cachedStartupScan ? "snapshot" : "computed";
|
|
7613
7938
|
let startupScan;
|
|
7614
7939
|
if (cachedStartupScan) {
|
|
7615
|
-
startupScan = { ...cachedStartupScan, cwd:
|
|
7940
|
+
startupScan = { ...cachedStartupScan, cwd: path14.resolve(cwd) };
|
|
7616
7941
|
} else {
|
|
7617
7942
|
const scanContextStartedAt = Date.now();
|
|
7618
7943
|
startupScan = resolveStartupScanContext(cwd);
|
|
@@ -7819,19 +8144,19 @@ function emitSmellsSessionStartLine(dbg, sessionStartMs) {
|
|
|
7819
8144
|
}
|
|
7820
8145
|
|
|
7821
8146
|
// dist/clients/runtime-turn.js
|
|
7822
|
-
import * as
|
|
7823
|
-
import * as
|
|
8147
|
+
import * as fs17 from "node:fs";
|
|
8148
|
+
import * as path25 from "node:path";
|
|
7824
8149
|
|
|
7825
8150
|
// dist/clients/actionable-warnings.js
|
|
7826
8151
|
import { createHash } from "node:crypto";
|
|
7827
|
-
import * as
|
|
7828
|
-
import * as
|
|
8152
|
+
import * as fs12 from "node:fs";
|
|
8153
|
+
import * as path16 from "node:path";
|
|
7829
8154
|
|
|
7830
8155
|
// dist/clients/actionable-warnings-logger.js
|
|
7831
|
-
import * as
|
|
8156
|
+
import * as path15 from "node:path";
|
|
7832
8157
|
var AW_LOG_DIR = getGlobalPiLensLogDir();
|
|
7833
|
-
var AW_LOG_FILE =
|
|
7834
|
-
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");
|
|
7835
8160
|
var MAX_LOG_BYTES2 = Math.max(128 * 1024, Number.parseInt(process.env.PI_LENS_AW_LOG_MAX_BYTES ?? "1048576", 10) || 1048576);
|
|
7836
8161
|
var writer2 = createNdjsonLogger({
|
|
7837
8162
|
filePath: AW_LOG_FILE,
|
|
@@ -7866,7 +8191,7 @@ function createActionableWarningId(args) {
|
|
|
7866
8191
|
});
|
|
7867
8192
|
}
|
|
7868
8193
|
function legacyActionableWarningId(args) {
|
|
7869
|
-
const rel = toPosix(
|
|
8194
|
+
const rel = toPosix(path16.relative(args.cwd, args.filePath));
|
|
7870
8195
|
const legacyRelativeFile = rel && !rel.startsWith("..") ? rel : normalizeMapKey(args.filePath);
|
|
7871
8196
|
const parts = [
|
|
7872
8197
|
legacyRelativeFile,
|
|
@@ -7912,16 +8237,16 @@ function deserializeSuppressionState(contents) {
|
|
|
7912
8237
|
}
|
|
7913
8238
|
}
|
|
7914
8239
|
function readSuppressionState(cwd) {
|
|
7915
|
-
const statePath =
|
|
8240
|
+
const statePath = path16.join(getProjectDataDir(cwd), "cache", "actionable-warning-state.json");
|
|
7916
8241
|
try {
|
|
7917
|
-
return deserializeSuppressionState(
|
|
8242
|
+
return deserializeSuppressionState(fs12.readFileSync(statePath, "utf8"));
|
|
7918
8243
|
} catch {
|
|
7919
8244
|
return {};
|
|
7920
8245
|
}
|
|
7921
8246
|
}
|
|
7922
8247
|
function updateWarningState(cwd, warnings) {
|
|
7923
|
-
const statePath =
|
|
7924
|
-
|
|
8248
|
+
const statePath = path16.join(getProjectDataDir(cwd), "cache", "actionable-warning-state.json");
|
|
8249
|
+
fs12.mkdirSync(path16.dirname(statePath), { recursive: true });
|
|
7925
8250
|
const hook = beforeWarningStateLockForTests;
|
|
7926
8251
|
beforeWarningStateLockForTests = null;
|
|
7927
8252
|
hook?.();
|
|
@@ -8044,7 +8369,7 @@ async function boundedLspCall(call, deps) {
|
|
|
8044
8369
|
const remainingMs = deps.deadlineAt !== void 0 ? deps.deadlineAt - Date.now() : void 0;
|
|
8045
8370
|
if (remainingMs !== void 0 && remainingMs <= 0)
|
|
8046
8371
|
return void 0;
|
|
8047
|
-
const inner = bounded(call().then((value) => ({ value })), {
|
|
8372
|
+
const inner = bounded(() => call().then((value) => ({ value })), {
|
|
8048
8373
|
// Always the FULL per-trip budget -- never clamped to the loop's own
|
|
8049
8374
|
// residual. The residual is enforced below, off the ledger.
|
|
8050
8375
|
ms: deps.pullTimeoutMs,
|
|
@@ -8066,7 +8391,7 @@ function boundedNumber(value, fallback) {
|
|
|
8066
8391
|
return value !== void 0 && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
8067
8392
|
}
|
|
8068
8393
|
async function buildActionableWarningsReport(args) {
|
|
8069
|
-
const cwd =
|
|
8394
|
+
const cwd = path16.resolve(args.cwd);
|
|
8070
8395
|
const records2 = [...args.dispatchWarnings];
|
|
8071
8396
|
const lspService = getLSPService();
|
|
8072
8397
|
const excludeServerIds = args.getFlag ? configDisabledAuxiliaryLspServerIds(args.getFlag) : void 0;
|
|
@@ -8089,7 +8414,7 @@ async function buildActionableWarningsReport(args) {
|
|
|
8089
8414
|
const eligible = [];
|
|
8090
8415
|
let outsideRoot = 0;
|
|
8091
8416
|
for (const file of args.files) {
|
|
8092
|
-
const filePath =
|
|
8417
|
+
const filePath = path16.resolve(cwd, file);
|
|
8093
8418
|
if (normalizeMapKey(filePath) === normalizeMapKey(cwd) || !isUnderDir(filePath, cwd)) {
|
|
8094
8419
|
outsideRoot++;
|
|
8095
8420
|
logActionableWarningsEvent({
|
|
@@ -8125,7 +8450,7 @@ async function buildActionableWarningsReport(args) {
|
|
|
8125
8450
|
const primed = [];
|
|
8126
8451
|
const cold = [];
|
|
8127
8452
|
for (const filePath of capped) {
|
|
8128
|
-
const content =
|
|
8453
|
+
const content = fs12.existsSync(filePath) ? fs12.readFileSync(filePath, "utf-8") : void 0;
|
|
8129
8454
|
const contentHash = content !== void 0 ? createHash("sha256").update(content).digest("hex") : void 0;
|
|
8130
8455
|
const cached = contentHash !== void 0 ? lspService.getLastKnownDiagnostics(filePath, contentHash) : void 0;
|
|
8131
8456
|
(cached !== void 0 ? primed : cold).push({
|
|
@@ -8201,7 +8526,7 @@ async function buildActionableWarningsReport(args) {
|
|
|
8201
8526
|
}
|
|
8202
8527
|
};
|
|
8203
8528
|
const deferredWork = (async () => {
|
|
8204
|
-
await new Promise((
|
|
8529
|
+
await new Promise((resolve32) => setTimeout(resolve32, 0));
|
|
8205
8530
|
const deferredRecords = [...carried];
|
|
8206
8531
|
const deferredDeadline = Date.now() + ACTIONABLE_WARNINGS_DEFERRED_BUDGET_MS;
|
|
8207
8532
|
deferredDeps.deadlineAt = deferredDeadline;
|
|
@@ -8584,7 +8909,7 @@ function publishActionableWarningsReport(cacheManager2, cwd, report, opts = {})
|
|
|
8584
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 ? ", ..." : ""})`;
|
|
8585
8910
|
incrementDegradationCount({
|
|
8586
8911
|
kind: "actionable-warnings-inband-superseded",
|
|
8587
|
-
subject: `${
|
|
8912
|
+
subject: `${path16.resolve(cwd)}:inband-carry-superseded`,
|
|
8588
8913
|
reason
|
|
8589
8914
|
});
|
|
8590
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 ? ", ..." : ""})`);
|
|
@@ -8636,7 +8961,7 @@ function writeDeferredActionableWarningsReport(args) {
|
|
|
8636
8961
|
if (droppedFiles.length > 0) {
|
|
8637
8962
|
incrementDegradationCount({
|
|
8638
8963
|
kind: "actionable-warnings-deferred-superseded",
|
|
8639
|
-
subject: `${
|
|
8964
|
+
subject: `${path16.resolve(args.cwd)}:deferred-file-superseded`,
|
|
8640
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 ? ", ..." : ""})`
|
|
8641
8966
|
});
|
|
8642
8967
|
args.dbg?.(`turn_end: deferred actionable-warnings dropped ${droppedFiles.length} superseded file entry/entries`);
|
|
@@ -8645,7 +8970,7 @@ function writeDeferredActionableWarningsReport(args) {
|
|
|
8645
8970
|
return { mergedFiles, droppedFiles: droppedFiles.length };
|
|
8646
8971
|
}
|
|
8647
8972
|
function getActionableWarningsHistoryPath(cwd) {
|
|
8648
|
-
return
|
|
8973
|
+
return path16.join(getProjectDataDir(cwd), "actionable-warnings.jsonl");
|
|
8649
8974
|
}
|
|
8650
8975
|
function appendActionableWarningsHistory(cwd, report) {
|
|
8651
8976
|
const entries = [];
|
|
@@ -8684,8 +9009,8 @@ function appendActionableWarningsHistory(cwd, report) {
|
|
|
8684
9009
|
return;
|
|
8685
9010
|
const historyPath = getActionableWarningsHistoryPath(cwd);
|
|
8686
9011
|
try {
|
|
8687
|
-
|
|
8688
|
-
|
|
9012
|
+
fs12.mkdirSync(path16.dirname(historyPath), { recursive: true });
|
|
9013
|
+
fs12.appendFileSync(historyPath, `${entries.map((entry) => JSON.stringify(entry)).join("\n")}
|
|
8689
9014
|
`, "utf8");
|
|
8690
9015
|
} catch {
|
|
8691
9016
|
}
|
|
@@ -8722,8 +9047,8 @@ ${fileList}${more}` : void 0,
|
|
|
8722
9047
|
}
|
|
8723
9048
|
|
|
8724
9049
|
// dist/clients/code-quality-warnings.js
|
|
8725
|
-
import * as
|
|
8726
|
-
import * as
|
|
9050
|
+
import * as fs13 from "node:fs";
|
|
9051
|
+
import * as path17 from "node:path";
|
|
8727
9052
|
var TIER_BUDGET_ORDER = [
|
|
8728
9053
|
"warning",
|
|
8729
9054
|
"info",
|
|
@@ -8737,7 +9062,7 @@ function lineInModifiedRanges2(line, ranges) {
|
|
|
8737
9062
|
return ranges.some((range) => line >= range.start - 2 && line <= range.end + 2);
|
|
8738
9063
|
}
|
|
8739
9064
|
function buildCodeQualityWarningsReport(args) {
|
|
8740
|
-
const cwd =
|
|
9065
|
+
const cwd = path17.resolve(args.cwd);
|
|
8741
9066
|
const maxWarnings = Math.max(1, args.maxWarnings ?? 50);
|
|
8742
9067
|
const byId = /* @__PURE__ */ new Map();
|
|
8743
9068
|
for (const warning of args.warnings) {
|
|
@@ -8801,7 +9126,7 @@ function writeCodeQualityWarningsReport(cacheManager2, cwd, report) {
|
|
|
8801
9126
|
cacheManager2.writeCache("code-quality-warnings", report, cwd);
|
|
8802
9127
|
}
|
|
8803
9128
|
function getCodeQualityWarningsHistoryPath(cwd) {
|
|
8804
|
-
return
|
|
9129
|
+
return path17.join(getProjectDataDir(cwd), "code-quality-warnings.jsonl");
|
|
8805
9130
|
}
|
|
8806
9131
|
function appendCodeQualityWarningsHistory(cwd, report) {
|
|
8807
9132
|
const warnings = report.files.flatMap((file) => file.warnings.map((warning) => ({
|
|
@@ -8826,8 +9151,8 @@ function appendCodeQualityWarningsHistory(cwd, report) {
|
|
|
8826
9151
|
return;
|
|
8827
9152
|
const historyPath = getCodeQualityWarningsHistoryPath(cwd);
|
|
8828
9153
|
try {
|
|
8829
|
-
|
|
8830
|
-
|
|
9154
|
+
fs13.mkdirSync(path17.dirname(historyPath), { recursive: true });
|
|
9155
|
+
fs13.appendFileSync(historyPath, `${warnings.map((entry) => JSON.stringify(entry)).join("\n")}
|
|
8831
9156
|
`, "utf8");
|
|
8832
9157
|
} catch {
|
|
8833
9158
|
}
|
|
@@ -8859,11 +9184,10 @@ function formatCodeQualityWarningsAdvisory(report, cwd, host = "pi") {
|
|
|
8859
9184
|
|
|
8860
9185
|
// dist/clients/git-guard.js
|
|
8861
9186
|
import * as nodeFs2 from "node:fs";
|
|
8862
|
-
import * as
|
|
9187
|
+
import * as path18 from "node:path";
|
|
8863
9188
|
|
|
8864
9189
|
// dist/clients/deferred-runner-blockers.js
|
|
8865
|
-
import * as
|
|
8866
|
-
import { resolve as resolve10 } from "node:path";
|
|
9190
|
+
import * as fs14 from "node:fs";
|
|
8867
9191
|
function judgeDeferredRunnerFindings(pending2, cwd, options = {}) {
|
|
8868
9192
|
const findings = (pending2.result?.diagnostics ?? []).flatMap((d) => d.runnerFault === true ? [] : [d]);
|
|
8869
9193
|
if (findings.length === 0) {
|
|
@@ -8904,7 +9228,7 @@ function judgeDeferredRunnerFindings(pending2, cwd, options = {}) {
|
|
|
8904
9228
|
};
|
|
8905
9229
|
}
|
|
8906
9230
|
function recordDeferredRunnerBlockers(runtime, pending2, survivors, bytes) {
|
|
8907
|
-
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));
|
|
8908
9232
|
if (blocking.length === 0)
|
|
8909
9233
|
return 0;
|
|
8910
9234
|
const recorded = runtime.recordDeferredInlineBlockers(
|
|
@@ -8958,7 +9282,7 @@ function withoutLaneCopies(runtime, pending2, findings) {
|
|
|
8958
9282
|
}
|
|
8959
9283
|
function readBytes(filePath) {
|
|
8960
9284
|
try {
|
|
8961
|
-
return
|
|
9285
|
+
return fs14.readFileSync(filePath);
|
|
8962
9286
|
} catch {
|
|
8963
9287
|
return void 0;
|
|
8964
9288
|
}
|
|
@@ -8966,7 +9290,7 @@ function readBytes(filePath) {
|
|
|
8966
9290
|
|
|
8967
9291
|
// dist/clients/git-guard.js
|
|
8968
9292
|
function resolveGuardPath(filePath, cwd) {
|
|
8969
|
-
return
|
|
9293
|
+
return path18.resolve(cwd, filePath);
|
|
8970
9294
|
}
|
|
8971
9295
|
function guardPathKey(filePath, cwd) {
|
|
8972
9296
|
return advisoryPathKey(filePath, cwd);
|
|
@@ -9029,6 +9353,22 @@ function splitBlockerSections(blockerContent, blockingFiles, cwd) {
|
|
|
9029
9353
|
}
|
|
9030
9354
|
return { sections, unowned };
|
|
9031
9355
|
}
|
|
9356
|
+
var TEXT_LEVEL = 1 / 8;
|
|
9357
|
+
var SCOPE_NEUTRAL_COMMANDS = [
|
|
9358
|
+
"echo",
|
|
9359
|
+
"printf",
|
|
9360
|
+
"tail",
|
|
9361
|
+
"head",
|
|
9362
|
+
"cat",
|
|
9363
|
+
"grep",
|
|
9364
|
+
"wc",
|
|
9365
|
+
"true"
|
|
9366
|
+
];
|
|
9367
|
+
var READ_ONLY_COMMANDS = [
|
|
9368
|
+
...SCOPE_NEUTRAL_COMMANDS,
|
|
9369
|
+
"ls",
|
|
9370
|
+
"pwd"
|
|
9371
|
+
];
|
|
9032
9372
|
function isTurnEndFindingsCache(value) {
|
|
9033
9373
|
if (!value || typeof value !== "object")
|
|
9034
9374
|
return false;
|
|
@@ -9606,10 +9946,10 @@ function dedupeSecretFindings(findings, cwd) {
|
|
|
9606
9946
|
}
|
|
9607
9947
|
|
|
9608
9948
|
// dist/clients/project-diagnostics/runner-adapters/govulncheck.js
|
|
9609
|
-
import * as
|
|
9949
|
+
import * as path19 from "node:path";
|
|
9610
9950
|
function govulncheckFindingToProjectDiagnostic(cwd, finding) {
|
|
9611
9951
|
const frame = finding.trace?.find((f) => f.filename);
|
|
9612
|
-
const filePath = frame?.filename ?
|
|
9952
|
+
const filePath = frame?.filename ? path19.isAbsolute(frame.filename) ? frame.filename : path19.resolve(cwd, frame.filename) : cwd;
|
|
9613
9953
|
const fix = finding.fixedVersion ? ` (fixed in ${finding.fixedVersion})` : "";
|
|
9614
9954
|
return {
|
|
9615
9955
|
filePath,
|
|
@@ -9668,14 +10008,13 @@ function render(kept, ctx) {
|
|
|
9668
10008
|
report += ` \u2026 and ${kept.findings.length - findings.length} more
|
|
9669
10009
|
`;
|
|
9670
10010
|
}
|
|
10011
|
+
const callSites = kept.findings.flatMap((f) => {
|
|
10012
|
+
const callSite = f.trace.find((t) => t.filename)?.filename;
|
|
10013
|
+
return callSite === void 0 ? [] : [callSite];
|
|
10014
|
+
});
|
|
9671
10015
|
advisorySections.push({
|
|
9672
10016
|
part: report,
|
|
9673
|
-
cites: [
|
|
9674
|
-
...new Set(kept.findings.flatMap((f) => {
|
|
9675
|
-
const callSite = f.trace.find((t) => t.filename)?.filename;
|
|
9676
|
-
return callSite === void 0 ? [] : [callSite];
|
|
9677
|
-
}))
|
|
9678
|
-
]
|
|
10017
|
+
cites: [.../* @__PURE__ */ new Set([...callSites, ...goModuleFiles(ctx.cwd)])]
|
|
9679
10018
|
});
|
|
9680
10019
|
}
|
|
9681
10020
|
return {
|
|
@@ -9683,6 +10022,10 @@ function render(kept, ctx) {
|
|
|
9683
10022
|
dispositionSuppressed: { govulncheck: kept.suppressed }
|
|
9684
10023
|
};
|
|
9685
10024
|
}
|
|
10025
|
+
function goModuleFiles(cwd) {
|
|
10026
|
+
const goFiles = existingDependencyManifests(cwd).flatMap((file) => /[\\/]go\.(?:mod|sum)$/.test(file) ? [file] : []);
|
|
10027
|
+
return goFiles.some((file) => /[\\/]go\.mod$/.test(file)) ? goFiles : [];
|
|
10028
|
+
}
|
|
9686
10029
|
var govulncheckLane = {
|
|
9687
10030
|
collect,
|
|
9688
10031
|
gate,
|
|
@@ -9690,12 +10033,12 @@ var govulncheckLane = {
|
|
|
9690
10033
|
};
|
|
9691
10034
|
|
|
9692
10035
|
// dist/clients/project-diagnostics/runner-adapters/gitleaks.js
|
|
9693
|
-
import * as
|
|
10036
|
+
import * as path20 from "node:path";
|
|
9694
10037
|
function gitleaksFindingToProjectDiagnostic(cwd, finding) {
|
|
9695
10038
|
const statusSuffix = finding.pathStatus ? ` [git: ${finding.pathStatus}]` : "";
|
|
9696
10039
|
const isBlocking2 = finding.pathStatus !== "scratch" && finding.pathStatus !== "ignored" && finding.pathStatus !== "nested-repository";
|
|
9697
10040
|
return {
|
|
9698
|
-
filePath:
|
|
10041
|
+
filePath: path20.isAbsolute(finding.file) ? finding.file : path20.resolve(cwd, finding.file),
|
|
9699
10042
|
line: finding.startLine,
|
|
9700
10043
|
severity: isBlocking2 ? "error" : "info",
|
|
9701
10044
|
semantic: isBlocking2 ? "blocking" : "none",
|
|
@@ -9713,9 +10056,9 @@ function gitleaksResultToProjectDiagnostics(cwd, result) {
|
|
|
9713
10056
|
}
|
|
9714
10057
|
|
|
9715
10058
|
// dist/clients/project-diagnostics/runner-adapters/trivy.js
|
|
9716
|
-
import * as
|
|
10059
|
+
import * as path21 from "node:path";
|
|
9717
10060
|
function trivyFindingToProjectDiagnostic(cwd, finding) {
|
|
9718
|
-
const filePath = finding.target ?
|
|
10061
|
+
const filePath = finding.target ? path21.isAbsolute(finding.target) ? finding.target : path21.resolve(cwd, finding.target) : cwd;
|
|
9719
10062
|
const version = finding.installedVersion ? `@${finding.installedVersion}` : "";
|
|
9720
10063
|
const fix = finding.fixedVersion ? ` (fixed in ${finding.fixedVersion})` : "";
|
|
9721
10064
|
return {
|
|
@@ -9732,7 +10075,7 @@ function trivyFindingToProjectDiagnostic(cwd, finding) {
|
|
|
9732
10075
|
}
|
|
9733
10076
|
function trivySecretFindingToProjectDiagnostic(cwd, finding) {
|
|
9734
10077
|
return {
|
|
9735
|
-
filePath:
|
|
10078
|
+
filePath: path21.isAbsolute(finding.file) ? finding.file : path21.resolve(cwd, finding.file),
|
|
9736
10079
|
line: finding.line,
|
|
9737
10080
|
severity: "error",
|
|
9738
10081
|
semantic: "blocking",
|
|
@@ -9952,7 +10295,7 @@ function stillReportedParked(parked, current, keyOf, offeredKeys) {
|
|
|
9952
10295
|
}
|
|
9953
10296
|
|
|
9954
10297
|
// dist/clients/knip-scan-roots.js
|
|
9955
|
-
import { resolve as
|
|
10298
|
+
import { resolve as resolve14 } from "node:path";
|
|
9956
10299
|
var MAX_KNIP_ROOTS_PER_TURN = 3;
|
|
9957
10300
|
function resolveKnipScanRoots(sessionCwd, modifiedFiles) {
|
|
9958
10301
|
const session = resolveGitCheckout(sessionCwd);
|
|
@@ -9962,7 +10305,7 @@ function resolveKnipScanRoots(sessionCwd, modifiedFiles) {
|
|
|
9962
10305
|
let sessionOwnsEdit = false;
|
|
9963
10306
|
const linked = [];
|
|
9964
10307
|
for (const file of modifiedFiles) {
|
|
9965
|
-
const owner = resolveLinkedWorktreeOwner(session,
|
|
10308
|
+
const owner = resolveLinkedWorktreeOwner(session, resolve14(sessionCwd, file));
|
|
9966
10309
|
if (owner === null) {
|
|
9967
10310
|
sessionOwnsEdit = true;
|
|
9968
10311
|
} else if (!linked.some((known) => pathsEqual(known.root, owner.root))) {
|
|
@@ -9978,7 +10321,7 @@ function resolveKnipScanRoots(sessionCwd, modifiedFiles) {
|
|
|
9978
10321
|
}
|
|
9979
10322
|
|
|
9980
10323
|
// dist/clients/project-diagnostics/runner-adapters/dead-code.js
|
|
9981
|
-
import * as
|
|
10324
|
+
import * as path22 from "node:path";
|
|
9982
10325
|
function deadCodeRunnerId(language) {
|
|
9983
10326
|
return `dead-code-${language}`;
|
|
9984
10327
|
}
|
|
@@ -9994,7 +10337,7 @@ function deadCodeMessage(issue) {
|
|
|
9994
10337
|
function deadCodeIssueToProjectDiagnostic(cwd, issue, language) {
|
|
9995
10338
|
const blocking = issue.category === "unlisted";
|
|
9996
10339
|
return {
|
|
9997
|
-
filePath: issue.file ?
|
|
10340
|
+
filePath: issue.file ? path22.isAbsolute(issue.file) ? issue.file : path22.resolve(cwd, issue.file) : cwd,
|
|
9998
10341
|
line: issue.line,
|
|
9999
10342
|
severity: blocking ? "error" : "warning",
|
|
10000
10343
|
semantic: blocking ? "blocking" : "warning",
|
|
@@ -10018,11 +10361,11 @@ function deadCodeResultToProjectDiagnostics(cwd, result) {
|
|
|
10018
10361
|
}
|
|
10019
10362
|
|
|
10020
10363
|
// dist/clients/project-diagnostics/runner-adapters/knip.js
|
|
10021
|
-
import * as
|
|
10364
|
+
import * as path23 from "node:path";
|
|
10022
10365
|
function knipIssueFile(cwd, issue) {
|
|
10023
10366
|
if (!issue.file)
|
|
10024
10367
|
return cwd;
|
|
10025
|
-
return
|
|
10368
|
+
return path23.isAbsolute(issue.file) ? issue.file : path23.resolve(cwd, issue.file);
|
|
10026
10369
|
}
|
|
10027
10370
|
function knipIssueMessage(issue) {
|
|
10028
10371
|
if (issue.type === "unlisted") {
|
|
@@ -10110,14 +10453,14 @@ function emitLensTurnFindings(payload) {
|
|
|
10110
10453
|
}
|
|
10111
10454
|
|
|
10112
10455
|
// dist/clients/test-target-roots.js
|
|
10113
|
-
import { dirname as
|
|
10456
|
+
import { dirname as dirname8 } from "node:path";
|
|
10114
10457
|
function createTurnEndTestRoots(sessionCwd) {
|
|
10115
10458
|
const session = resolveGitCheckout(sessionCwd);
|
|
10116
10459
|
const ownerByDir = /* @__PURE__ */ new Map();
|
|
10117
10460
|
return (absoluteFile) => {
|
|
10118
10461
|
if (session === null)
|
|
10119
10462
|
return sessionCwd;
|
|
10120
|
-
const dir =
|
|
10463
|
+
const dir = dirname8(absoluteFile);
|
|
10121
10464
|
let owner = ownerByDir.get(dir);
|
|
10122
10465
|
if (owner === void 0) {
|
|
10123
10466
|
owner = resolveLinkedWorktreeOwner(session, absoluteFile);
|
|
@@ -10181,7 +10524,7 @@ function sweepInlineBlockerPastEof(runtime, cwd, options) {
|
|
|
10181
10524
|
}
|
|
10182
10525
|
|
|
10183
10526
|
// dist/clients/persistent-reverify.js
|
|
10184
|
-
import * as
|
|
10527
|
+
import * as fs15 from "node:fs";
|
|
10185
10528
|
var MAX_REVERIFY_FILES = 4;
|
|
10186
10529
|
var REVERIFY_BUDGET_MS = 3e3;
|
|
10187
10530
|
var TOUCH_SOURCE = "persistent_reverify";
|
|
@@ -10199,7 +10542,7 @@ function selectPersistentReverifyFiles(report, nowMs = Date.now()) {
|
|
|
10199
10542
|
continue;
|
|
10200
10543
|
let mtimeMs;
|
|
10201
10544
|
try {
|
|
10202
|
-
mtimeMs =
|
|
10545
|
+
mtimeMs = fs15.statSync(entry.filePath).mtimeMs;
|
|
10203
10546
|
} catch {
|
|
10204
10547
|
continue;
|
|
10205
10548
|
}
|
|
@@ -10241,7 +10584,7 @@ async function runPersistentReverify(args) {
|
|
|
10241
10584
|
processed += 1;
|
|
10242
10585
|
let content;
|
|
10243
10586
|
try {
|
|
10244
|
-
content =
|
|
10587
|
+
content = fs15.readFileSync(entry.filePath, "utf-8");
|
|
10245
10588
|
} catch {
|
|
10246
10589
|
outcomes.push({
|
|
10247
10590
|
filePath: entry.filePath,
|
|
@@ -10255,7 +10598,7 @@ async function runPersistentReverify(args) {
|
|
|
10255
10598
|
}
|
|
10256
10599
|
let touchedResult;
|
|
10257
10600
|
try {
|
|
10258
|
-
touchedResult = await bounded(args.lspService.touchFile(entry.filePath, content, {
|
|
10601
|
+
touchedResult = await bounded(() => args.lspService.touchFile(entry.filePath, content, {
|
|
10259
10602
|
diagnostics: "document",
|
|
10260
10603
|
collectDiagnostics: true,
|
|
10261
10604
|
source: TOUCH_SOURCE,
|
|
@@ -10282,15 +10625,17 @@ async function runPersistentReverify(args) {
|
|
|
10282
10625
|
}
|
|
10283
10626
|
touched += 1;
|
|
10284
10627
|
const unanswered = [];
|
|
10285
|
-
const enriched = await bounded(enrichFileFromLsp(args.cwd, buildArgs, { filePath: entry.filePath, cached: touchedResult.diags }, {
|
|
10628
|
+
const enriched = await bounded((signal) => enrichFileFromLsp(args.cwd, buildArgs, { filePath: entry.filePath, cached: touchedResult.diags }, {
|
|
10286
10629
|
lspService: args.lspService,
|
|
10287
10630
|
pullTimeoutMs: 2e3,
|
|
10288
10631
|
deadlineAt,
|
|
10289
|
-
|
|
10632
|
+
signal,
|
|
10290
10633
|
site: { hook: "turn_end", label: "persistent_reverify" },
|
|
10291
10634
|
unanswered
|
|
10292
10635
|
}), {
|
|
10293
10636
|
ms: Math.max(250, deadlineAt - Date.now()),
|
|
10637
|
+
// The hook's own signal is the bound's second half; the thunk's
|
|
10638
|
+
// `signal` above is what cancels the enrichment's requests.
|
|
10294
10639
|
signal: args.signal,
|
|
10295
10640
|
hook: "turn_end",
|
|
10296
10641
|
label: "persistent_reverify_enrich"
|
|
@@ -10356,11 +10701,11 @@ async function runPersistentReverify(args) {
|
|
|
10356
10701
|
}
|
|
10357
10702
|
|
|
10358
10703
|
// dist/clients/inline-blocker-dispositions.js
|
|
10359
|
-
import * as
|
|
10360
|
-
import * as
|
|
10704
|
+
import * as fs16 from "node:fs";
|
|
10705
|
+
import * as path24 from "node:path";
|
|
10361
10706
|
function readCurrentContent(filePath) {
|
|
10362
10707
|
try {
|
|
10363
|
-
return
|
|
10708
|
+
return fs16.readFileSync(filePath, "utf-8");
|
|
10364
10709
|
} catch {
|
|
10365
10710
|
return "";
|
|
10366
10711
|
}
|
|
@@ -10383,7 +10728,7 @@ function applyInlineBlockerPolicy(record, cwd) {
|
|
|
10383
10728
|
unstructured: true
|
|
10384
10729
|
};
|
|
10385
10730
|
}
|
|
10386
|
-
const inProject = (file) =>
|
|
10731
|
+
const inProject = (file) => path24.resolve(cwd, file);
|
|
10387
10732
|
const resolved = diagnostics.map((diagnostic) => ({
|
|
10388
10733
|
...diagnostic,
|
|
10389
10734
|
filePath: inProject(diagnostic.filePath)
|
|
@@ -10403,7 +10748,10 @@ function applyInlineBlockerPolicy(record, cwd) {
|
|
|
10403
10748
|
});
|
|
10404
10749
|
const dropped = diagnostics.length - kept.length;
|
|
10405
10750
|
return {
|
|
10406
|
-
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(),
|
|
10407
10755
|
candidates: diagnostics.length,
|
|
10408
10756
|
kept: kept.length,
|
|
10409
10757
|
suppressed: dropped,
|
|
@@ -10559,7 +10907,7 @@ async function runTestTargetsBounded(args) {
|
|
|
10559
10907
|
});
|
|
10560
10908
|
void pool.catch(() => {
|
|
10561
10909
|
});
|
|
10562
|
-
await new Promise((
|
|
10910
|
+
await new Promise((resolve32) => {
|
|
10563
10911
|
let settled = false;
|
|
10564
10912
|
const finish = (reason) => {
|
|
10565
10913
|
if (settled)
|
|
@@ -10571,7 +10919,7 @@ async function runTestTargetsBounded(args) {
|
|
|
10571
10919
|
batchAbort.abort();
|
|
10572
10920
|
clearTimeout(timer);
|
|
10573
10921
|
args.signal?.removeEventListener("abort", onAbort);
|
|
10574
|
-
|
|
10922
|
+
resolve32();
|
|
10575
10923
|
};
|
|
10576
10924
|
const onAbort = () => finish("abort");
|
|
10577
10925
|
const timer = setTimeout(() => finish("budget"), budgetMs);
|
|
@@ -10745,16 +11093,6 @@ function getShortenedLspIdleResetMs() {
|
|
|
10745
11093
|
function getEffectiveLspIdleResetMs() {
|
|
10746
11094
|
return isSubagentSession() || shouldShortenLspIdleTimeout() ? getShortenedLspIdleResetMs() : getBaseLspIdleResetMs();
|
|
10747
11095
|
}
|
|
10748
|
-
function cancelLSPIdleReset() {
|
|
10749
|
-
if (lspIdleResetTimeout) {
|
|
10750
|
-
clearTimeout(lspIdleResetTimeout);
|
|
10751
|
-
lspIdleResetTimeout = null;
|
|
10752
|
-
}
|
|
10753
|
-
if (pendingSweepRearm) {
|
|
10754
|
-
pendingSweepRearm.cancelled = true;
|
|
10755
|
-
pendingSweepRearm = null;
|
|
10756
|
-
}
|
|
10757
|
-
}
|
|
10758
11096
|
function capTurnEndMessage(content, held = 0) {
|
|
10759
11097
|
const maxLines = RUNTIME_CONFIG.turnEnd.maxLines;
|
|
10760
11098
|
const maxChars = RUNTIME_CONFIG.turnEnd.maxChars;
|
|
@@ -10915,6 +11253,24 @@ async function handleTurnEnd(deps) {
|
|
|
10915
11253
|
}
|
|
10916
11254
|
const ownFiles = Object.keys(turnState.files);
|
|
10917
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
|
+
};
|
|
10918
11274
|
let widgetDemotedFindingsRetired = 0;
|
|
10919
11275
|
for (const wPath of drainRenderedDependencyDriftFilePaths()) {
|
|
10920
11276
|
const deliveryCount = incrementWidgetDependencyDriftDelivery(wPath);
|
|
@@ -10940,30 +11296,13 @@ async function handleTurnEnd(deps) {
|
|
|
10940
11296
|
if (getFlag("lens-guard") && !runtime.gitGuardHasBlockers) {
|
|
10941
11297
|
retireSettledGitGuardRecord(runtime, cacheManager2, cwd, sessionId);
|
|
10942
11298
|
}
|
|
10943
|
-
|
|
10944
|
-
dbg(`turn_end: no modified files, scheduling LSP idle reset (${idleResetMs / 1e3}s)`);
|
|
10945
|
-
if (!getFlag("no-lsp")) {
|
|
10946
|
-
const sessionGeneration = runtime.sessionGeneration;
|
|
10947
|
-
scheduleLSPIdleReset(resetLSPService2, idleResetMs, {
|
|
10948
|
-
isCurrentSession: () => runtime.isCurrentSession(sessionGeneration),
|
|
10949
|
-
// #2157 fix round 2: a secondary (subagent) evaluation's own timer
|
|
10950
|
-
// must not release the primary's shared fleet — see the option's
|
|
10951
|
-
// doc comment on `scheduleLSPIdleReset`.
|
|
10952
|
-
isPrimarySession: () => {
|
|
10953
|
-
const activePrimarySessionId = getActiveSessionId();
|
|
10954
|
-
return activePrimarySessionId === void 0 || activePrimarySessionId === runtime.telemetrySessionId;
|
|
10955
|
-
},
|
|
10956
|
-
onError: (err) => dbg(`lsp idle reset failed: ${err}`)
|
|
10957
|
-
});
|
|
10958
|
-
}
|
|
11299
|
+
armLspIdleReset();
|
|
10959
11300
|
resetFormatService2();
|
|
10960
11301
|
if (pendingRunnerFindingsSize() === 0 && !runtime.hasResolvedBlockerFiles() && (runtime.getInlineBlockersSnapshot({ sessionId }).length === 0 || readLastDelivery(cacheManager2, cwd)?.sessionId !== (sessionId ?? runtime.telemetrySessionId)))
|
|
10961
11302
|
return;
|
|
10962
11303
|
}
|
|
10963
|
-
if (files.length > 0 &&
|
|
10964
|
-
|
|
10965
|
-
dbg("turn_end: cancelled pending LSP idle reset (active editing)");
|
|
10966
|
-
}
|
|
11304
|
+
if (files.length > 0 && !isSecondarySession)
|
|
11305
|
+
armLspIdleReset();
|
|
10967
11306
|
dbg(`turn_end: ${files.length} file(s) modified, cycles: ${turnState.turnCycles}/${turnState.maxCycles}, access: ${access}, owner: ${gateOwnerLabel}`);
|
|
10968
11307
|
if (cacheManager2.isMaxCyclesExceeded(cwd, turnStateSessionId)) {
|
|
10969
11308
|
dbg("turn_end: max cycles exceeded, clearing state and forcing through");
|
|
@@ -11326,11 +11665,11 @@ ${policy.body}`;
|
|
|
11326
11665
|
const changedSince = runtime.getFilesChangedSince(originSeq);
|
|
11327
11666
|
if (changedSince.length > 0) {
|
|
11328
11667
|
const changedSet = new Set(changedSince);
|
|
11329
|
-
const primaryKey = normalizeMapKey(
|
|
11668
|
+
const primaryKey = normalizeMapKey(path25.resolve(run.filePath));
|
|
11330
11669
|
const neighborKeys = [
|
|
11331
11670
|
...(run.result?.neighbors ?? []).map((n) => n.filePath),
|
|
11332
11671
|
...run.selectedNeighborPaths ?? []
|
|
11333
|
-
].map((filePath) => normalizeMapKey(
|
|
11672
|
+
].map((filePath) => normalizeMapKey(path25.resolve(filePath)));
|
|
11334
11673
|
const supersededByOwnFile = changedSet.has(primaryKey) || neighborKeys.some((k) => changedSet.has(k));
|
|
11335
11674
|
if (supersededByOwnFile) {
|
|
11336
11675
|
logCascade({
|
|
@@ -11373,7 +11712,7 @@ ${policy.body}`;
|
|
|
11373
11712
|
const cascadeTurn = runtime.turnIndex;
|
|
11374
11713
|
const editedKeys = /* @__PURE__ */ new Set();
|
|
11375
11714
|
for (const file of files) {
|
|
11376
|
-
const absolute =
|
|
11715
|
+
const absolute = path25.resolve(cwd, file);
|
|
11377
11716
|
editedKeys.add(normalizeMapKey(absolute));
|
|
11378
11717
|
forgetCascadePendingNeighbor(absolute);
|
|
11379
11718
|
}
|
|
@@ -12440,12 +12779,12 @@ ${lines.join("\n")}`;
|
|
|
12440
12779
|
const madgeFiles = cacheManager2.getFilesForMadge(cwd, turnStateSessionId);
|
|
12441
12780
|
if (madgeFiles.length > 0) {
|
|
12442
12781
|
dbg(`turn_end: madge checking ${madgeFiles.length} file(s) for circular deps`);
|
|
12443
|
-
const absFiles = madgeFiles.map((file) =>
|
|
12782
|
+
const absFiles = madgeFiles.map((file) => path25.resolve(cwd, file));
|
|
12444
12783
|
const batch = await depChecker.checkFilesBatch(absFiles, cwd);
|
|
12445
12784
|
const depResults = batch.results;
|
|
12446
12785
|
madgeStats = batch.stats;
|
|
12447
12786
|
for (const file of madgeFiles) {
|
|
12448
|
-
const absPath =
|
|
12787
|
+
const absPath = path25.resolve(cwd, file);
|
|
12449
12788
|
const depResult = depResults.get(absPath);
|
|
12450
12789
|
if (!depResult)
|
|
12451
12790
|
continue;
|
|
@@ -12481,7 +12820,7 @@ ${lines.join("\n")}`;
|
|
|
12481
12820
|
}
|
|
12482
12821
|
for (const result of cascadeResults) {
|
|
12483
12822
|
for (const neighbor of result.neighbors) {
|
|
12484
|
-
const abs =
|
|
12823
|
+
const abs = path25.isAbsolute(neighbor.filePath) ? neighbor.filePath : resolveRunnerPath(cwd, neighbor.filePath);
|
|
12485
12824
|
const key = normalizeMapKey(abs);
|
|
12486
12825
|
if (seenCandidateKeys.has(key))
|
|
12487
12826
|
continue;
|
|
@@ -12493,17 +12832,17 @@ ${lines.join("\n")}`;
|
|
|
12493
12832
|
const carriedDeferred = priorTestCache?.deferredTargets ?? [];
|
|
12494
12833
|
const turnSessionId = sessionId ?? runtime.telemetrySessionId;
|
|
12495
12834
|
const isThisSession = (entry) => entry.sessionId === turnSessionId;
|
|
12496
|
-
const entryPathKey = (entry) => normalizeMapKey(
|
|
12835
|
+
const entryPathKey = (entry) => normalizeMapKey(path25.resolve(cwd, entry.testFile));
|
|
12497
12836
|
const retiredCarry = (priorTestCache?.retiredTargets ?? []).filter(isThisSession);
|
|
12498
12837
|
const retiredKeys = new Set(retiredCarry.map(entryPathKey));
|
|
12499
12838
|
const resolvedDeferralKeys = /* @__PURE__ */ new Set();
|
|
12500
12839
|
const heldDeferred = [];
|
|
12501
12840
|
const boundPersisted = (entries, label) => {
|
|
12502
|
-
const
|
|
12503
|
-
if (
|
|
12841
|
+
const cappedTargets = boundDeferredTargets(entries, TEST_RUNNER_MAX_PERSISTED_TARGETS, isThisSession);
|
|
12842
|
+
if (cappedTargets.length !== entries.length) {
|
|
12504
12843
|
dbg(`turn_end: ${label} test target list held ${entries.length} entries, bounded to the newest ${TEST_RUNNER_MAX_PERSISTED_TARGETS} (oldest foreign-session rows dropped)`);
|
|
12505
12844
|
}
|
|
12506
|
-
return
|
|
12845
|
+
return cappedTargets;
|
|
12507
12846
|
};
|
|
12508
12847
|
const writeTestFindings = (record, ownDeferred) => {
|
|
12509
12848
|
const live = cacheManager2.readCache("test-runner-findings", cwd)?.data;
|
|
@@ -12527,7 +12866,7 @@ ${lines.join("\n")}`;
|
|
|
12527
12866
|
let redispatchedDeferred = 0;
|
|
12528
12867
|
let retiredThisTurn = 0;
|
|
12529
12868
|
for (const carried of carriedDeferred) {
|
|
12530
|
-
const testFile =
|
|
12869
|
+
const testFile = path25.resolve(cwd, carried.testFile);
|
|
12531
12870
|
const carriedKey = normalizeMapKey(testFile);
|
|
12532
12871
|
if (!isThisSession(carried)) {
|
|
12533
12872
|
foreignDeferred++;
|
|
@@ -12560,7 +12899,7 @@ ${lines.join("\n")}`;
|
|
|
12560
12899
|
}
|
|
12561
12900
|
const config = RUNNERS[carried.runner];
|
|
12562
12901
|
const carriedRoot = testRootFor(testFile);
|
|
12563
|
-
if (!config || isExcludedTestTarget(testFile, carriedRoot) || !
|
|
12902
|
+
if (!config || isExcludedTestTarget(testFile, carriedRoot) || !fs17.existsSync(testFile)) {
|
|
12564
12903
|
resolvedDeferralKeys.add(carriedKey);
|
|
12565
12904
|
deadDeferred++;
|
|
12566
12905
|
continue;
|
|
@@ -12640,7 +12979,7 @@ ${lines.join("\n")}`;
|
|
|
12640
12979
|
dbg(`turn_end: ${display} \u2192 test target excluded by the built-in turn-end policy, skipping spawn (${toRunnerDisplayPath(cwd, target.testFile)})`);
|
|
12641
12980
|
continue;
|
|
12642
12981
|
}
|
|
12643
|
-
if (!
|
|
12982
|
+
if (!fs17.existsSync(target.testFile)) {
|
|
12644
12983
|
missingTargetFiles++;
|
|
12645
12984
|
dbg(`turn_end: ${display} \u2192 test file missing, skipping spawn (${toRunnerDisplayPath(cwd, target.testFile)})`);
|
|
12646
12985
|
continue;
|
|
@@ -12866,7 +13205,7 @@ ${lines.join("\n")}`;
|
|
|
12866
13205
|
const { file, runner, passed, failed, duration, error } = r.value;
|
|
12867
13206
|
if (failed > 0)
|
|
12868
13207
|
hasRealFailure = true;
|
|
12869
|
-
const shortFile =
|
|
13208
|
+
const shortFile = path25.basename(file);
|
|
12870
13209
|
const elapsed = formatRunDurationMs(duration);
|
|
12871
13210
|
const verdict = failed > 0 ? "FAIL" : "PASS";
|
|
12872
13211
|
const summary = isRunnerErrorResult(r.value) ? passed > 0 ? `error: ${error} (${passed} passed before)` : `error: ${error}` : `${verdict} ${passed}p/${failed}f (${elapsed})`;
|
|
@@ -13040,8 +13379,8 @@ ${lines.join("\n")}`;
|
|
|
13040
13379
|
} else {
|
|
13041
13380
|
const callGraphStart = Date.now();
|
|
13042
13381
|
try {
|
|
13043
|
-
const { impact, formatImpact, parseSymbolKey } = await import("../chunk-
|
|
13044
|
-
const { callGraphImpactToProjectDiagnostics } = await import("../chunk-
|
|
13382
|
+
const { impact, formatImpact, parseSymbolKey } = await import("../chunk-ZDWNFZJ2.js");
|
|
13383
|
+
const { callGraphImpactToProjectDiagnostics } = await import("../chunk-LEQTVRSV.js");
|
|
13045
13384
|
const impactLines = [];
|
|
13046
13385
|
let callGraphDispositionSuppressed = 0;
|
|
13047
13386
|
const impactFindings = [];
|
|
@@ -13143,11 +13482,11 @@ ${impactLines.join("\n")}`;
|
|
|
13143
13482
|
if (persistedReport?.files?.some((entry) => entry.origin === "deferred")) {
|
|
13144
13483
|
const reverifyLspService = getLSPService();
|
|
13145
13484
|
if (reverifyLspService) {
|
|
13146
|
-
reverify = await bounded(runPersistentReverify({
|
|
13485
|
+
reverify = await bounded((signal) => runPersistentReverify({
|
|
13147
13486
|
report: persistedReport,
|
|
13148
13487
|
cwd,
|
|
13149
13488
|
lspService: reverifyLspService,
|
|
13150
|
-
signal
|
|
13489
|
+
signal
|
|
13151
13490
|
}), {
|
|
13152
13491
|
ms: HOOK_WALL_BUDGET_MS.turn_end,
|
|
13153
13492
|
signal: getAmbientAbortSignal(),
|
|
@@ -13409,7 +13748,7 @@ ${impactLines.join("\n")}`;
|
|
|
13409
13748
|
if (!lateAuxContentRead) {
|
|
13410
13749
|
lateAuxContentRead = true;
|
|
13411
13750
|
try {
|
|
13412
|
-
lateAuxContentValue =
|
|
13751
|
+
lateAuxContentValue = fs17.readFileSync(lateAuxPath, "utf-8");
|
|
13413
13752
|
} catch {
|
|
13414
13753
|
lateAuxContentValue = void 0;
|
|
13415
13754
|
}
|
|
@@ -13624,7 +13963,7 @@ ${lines.join("\n")}`;
|
|
|
13624
13963
|
}
|
|
13625
13964
|
});
|
|
13626
13965
|
}
|
|
13627
|
-
const unresolvedKeys = new Set(unresolvedBlockers.map((record) => normalizeMapKey(
|
|
13966
|
+
const unresolvedKeys = new Set(unresolvedBlockers.map((record) => normalizeMapKey(path25.resolve(record.filePath))));
|
|
13628
13967
|
const formatResolvedTail = (dropped) => `\u2026 and ${dropped} more`;
|
|
13629
13968
|
const resolvedTailMax = formatResolvedTail(Number.MAX_SAFE_INTEGER).length;
|
|
13630
13969
|
const resolvedShareChars = Math.floor(RUNTIME_CONFIG.turnEnd.maxChars * RESOLVED_SHARE_OF_CHARS) - resolvedTailMax;
|
|
@@ -13649,7 +13988,7 @@ ${lines.join("\n")}`;
|
|
|
13649
13988
|
let resolvedChars = 0;
|
|
13650
13989
|
let resolvedCount = 0;
|
|
13651
13990
|
const { files: resolvedBlockerFileList, dropped: resolvedBlockerFilesDropped } = runtime.consumeResolvedBlockerFiles((entry) => {
|
|
13652
|
-
if (unresolvedKeys.has(normalizeMapKey(
|
|
13991
|
+
if (unresolvedKeys.has(normalizeMapKey(path25.resolve(entry.filePath))))
|
|
13653
13992
|
return true;
|
|
13654
13993
|
const cost = formatResolvedLine(entry).length + 1;
|
|
13655
13994
|
if (resolvedCount > 0 && (resolvedCount >= resolvedLineBudget || resolvedChars + cost > resolvedCharBudget))
|
|
@@ -13820,7 +14159,7 @@ ${raw}`
|
|
|
13820
14159
|
projectSeqStart: runtime.turnStartProjectSeq,
|
|
13821
14160
|
projectSeqEnd: runtime.projectSeq,
|
|
13822
14161
|
fileSeqByPath: Object.fromEntries(runtime.getFileSeqEntries().map(([filePath, seq]) => [
|
|
13823
|
-
normalizeMapKey(
|
|
14162
|
+
normalizeMapKey(path25.resolve(filePath)),
|
|
13824
14163
|
seq
|
|
13825
14164
|
])),
|
|
13826
14165
|
fileContentHashes: {},
|
|
@@ -13859,7 +14198,7 @@ ${raw}`
|
|
|
13859
14198
|
repeatStaged = repeatContent !== void 0;
|
|
13860
14199
|
const fileSeqByPath2 = {};
|
|
13861
14200
|
for (const [filePath, seq] of runtime.getFileSeqEntries()) {
|
|
13862
|
-
fileSeqByPath2[normalizeMapKey(
|
|
14201
|
+
fileSeqByPath2[normalizeMapKey(path25.resolve(filePath))] = seq;
|
|
13863
14202
|
}
|
|
13864
14203
|
const { stored: existingGuard, carried, dropped } = readTurnEndGuardRecord(cacheManager2, runtime, cwd, sessionId);
|
|
13865
14204
|
const deliveredCitedFiles = holdPlan.reachedParts.flatMap((part) => provenanceCitations.get(part.raw) ?? []);
|
|
@@ -14088,10 +14427,10 @@ var TurnEndQueue = class {
|
|
|
14088
14427
|
if (this.pending.length >= 1) {
|
|
14089
14428
|
return Promise.reject(new Error("turn_end queue is busy"));
|
|
14090
14429
|
}
|
|
14091
|
-
return new Promise((
|
|
14430
|
+
return new Promise((resolve32, reject) => {
|
|
14092
14431
|
const item = {
|
|
14093
14432
|
work,
|
|
14094
|
-
resolve:
|
|
14433
|
+
resolve: resolve32,
|
|
14095
14434
|
reject,
|
|
14096
14435
|
timer: setTimeout(() => {
|
|
14097
14436
|
const index = this.pending.indexOf(item);
|
|
@@ -14138,7 +14477,7 @@ async function runTurnEndNowImpl(cwd, files = [], deferredDelivery = false) {
|
|
|
14138
14477
|
const abs = resolveHostToolPath(file, cwd);
|
|
14139
14478
|
let lineCount3 = 1;
|
|
14140
14479
|
try {
|
|
14141
|
-
lineCount3 =
|
|
14480
|
+
lineCount3 = fs18.readFileSync(abs, "utf8").split("\n").length;
|
|
14142
14481
|
} catch {
|
|
14143
14482
|
continue;
|
|
14144
14483
|
}
|
|
@@ -14276,8 +14615,8 @@ function acknowledgeTurnEnd(cwd, deliveryId) {
|
|
|
14276
14615
|
}
|
|
14277
14616
|
|
|
14278
14617
|
// dist/clients/module-report.js
|
|
14279
|
-
import * as
|
|
14280
|
-
import * as
|
|
14618
|
+
import * as fs19 from "node:fs";
|
|
14619
|
+
import * as path26 from "node:path";
|
|
14281
14620
|
|
|
14282
14621
|
// dist/clients/middle-man-analysis.js
|
|
14283
14622
|
var SELF_TOKEN = {
|
|
@@ -14662,7 +15001,8 @@ function toEntry(sym, normalizedPath, graph, maxRefs, projectRoot, fileKind) {
|
|
|
14662
15001
|
const complexity = typeof metadata.cyclomaticComplexity === "number" ? metadata.cyclomaticComplexity : void 0;
|
|
14663
15002
|
const fanout = graph ? (graph.edgesByFrom.get(symbolNodeId) ?? []).filter((edge) => edge.kind === "calls").length : void 0;
|
|
14664
15003
|
const nonPublic = sym.visibility === "private" || sym.visibility === "protected";
|
|
14665
|
-
const
|
|
15004
|
+
const answer = sym.isExported === true || node?.exported === true ? true : sym.isExported === void 0 && node?.exported === void 0 ? void 0 : false;
|
|
15005
|
+
const exported = answer === void 0 ? void 0 : answer && !nonPublic;
|
|
14666
15006
|
const flags = [];
|
|
14667
15007
|
if (sym.isAsync)
|
|
14668
15008
|
flags.push("async");
|
|
@@ -14678,7 +15018,7 @@ function toEntry(sym, normalizedPath, graph, maxRefs, projectRoot, fileKind) {
|
|
|
14678
15018
|
kind: sym.kind,
|
|
14679
15019
|
startLine,
|
|
14680
15020
|
endLine: endLine2,
|
|
14681
|
-
exported,
|
|
15021
|
+
...exported === void 0 ? {} : { exported },
|
|
14682
15022
|
...sym.visibility ? { visibility: sym.visibility } : {},
|
|
14683
15023
|
...sym.decorators?.length ? { decorators: sym.decorators } : {},
|
|
14684
15024
|
signature: sym.signature,
|
|
@@ -14737,7 +15077,8 @@ function projectModuleReport(report, projection) {
|
|
|
14737
15077
|
return {
|
|
14738
15078
|
...report,
|
|
14739
15079
|
api: report.api.map(stripEntryMetrics),
|
|
14740
|
-
internal: report.internal.map(stripEntryMetrics)
|
|
15080
|
+
internal: report.internal.map(stripEntryMetrics),
|
|
15081
|
+
...report.unclassified ? { unclassified: report.unclassified.map(stripEntryMetrics) } : {}
|
|
14741
15082
|
};
|
|
14742
15083
|
}
|
|
14743
15084
|
var PRESET_AXES = {
|
|
@@ -14852,7 +15193,7 @@ function blastReadArgs(graph, normalizedFile) {
|
|
|
14852
15193
|
return { path: normalizedFile, offset: 1, limit };
|
|
14853
15194
|
}
|
|
14854
15195
|
async function computeBlastRadius(graph, normalizedPath, projectRoot, maxDepth) {
|
|
14855
|
-
const { computeTransitiveImpact } = await import("../chunk-
|
|
15196
|
+
const { computeTransitiveImpact } = await import("../chunk-JTHEUTW7.js");
|
|
14856
15197
|
const result = computeTransitiveImpact(graph, normalizedPath, { maxDepth });
|
|
14857
15198
|
const byFile = /* @__PURE__ */ new Map();
|
|
14858
15199
|
for (const hit of result.hits) {
|
|
@@ -15442,11 +15783,11 @@ async function moduleReport(file, cwd, options) {
|
|
|
15442
15783
|
const startedAt = Date.now();
|
|
15443
15784
|
const maxRefs = normalizeMaxRefsPerSymbol(options?.maxRefsPerSymbol);
|
|
15444
15785
|
const maxCallGraphEntries = Math.min(CALL_GRAPH_MAX_ENTRY_CAP, Math.max(1, Math.floor(options?.maxCallGraphEntries ?? CALL_GRAPH_DEFAULT_ENTRY_CAP)));
|
|
15445
|
-
const absPath =
|
|
15786
|
+
const absPath = path26.resolve(cwd, file);
|
|
15446
15787
|
const normalizedPath = normalizeMapKey(absPath);
|
|
15447
15788
|
let content;
|
|
15448
15789
|
try {
|
|
15449
|
-
content =
|
|
15790
|
+
content = fs19.readFileSync(absPath, "utf-8");
|
|
15450
15791
|
} catch {
|
|
15451
15792
|
return unavailableReport(toDisplayPath(absPath, cwd));
|
|
15452
15793
|
}
|
|
@@ -15469,7 +15810,7 @@ async function moduleReport(file, cwd, options) {
|
|
|
15469
15810
|
let callGraphIdentity;
|
|
15470
15811
|
let revisionDriftNote;
|
|
15471
15812
|
try {
|
|
15472
|
-
const { getCachedReviewGraph, getReviewGraphCacheIdentity, getReviewGraphSizeSkipVerdict, getReviewGraphRevisionDrift, formatReviewGraphRevisionDriftNote: formatReviewGraphRevisionDriftNote2 } = await import("../chunk-
|
|
15813
|
+
const { getCachedReviewGraph, getReviewGraphCacheIdentity, getReviewGraphSizeSkipVerdict, getReviewGraphRevisionDrift, formatReviewGraphRevisionDriftNote: formatReviewGraphRevisionDriftNote2 } = await import("../chunk-MY4XNNTX.js");
|
|
15473
15814
|
graph = getCachedReviewGraph(cwd);
|
|
15474
15815
|
graphFileCap = getReviewGraphSizeSkipVerdict(cwd)?.maxFileCount;
|
|
15475
15816
|
const drift = graph ? getReviewGraphRevisionDrift(cwd) : void 0;
|
|
@@ -15490,8 +15831,17 @@ async function moduleReport(file, cwd, options) {
|
|
|
15490
15831
|
const entries = outlineSymbols.map((sym) => toEntry(sym, normalizedPath, graph, maxRefs, cwd, kind));
|
|
15491
15832
|
const topLevel = nestEntries(entries);
|
|
15492
15833
|
annotateMiddleMan(entries, content, languageId);
|
|
15493
|
-
const api =
|
|
15494
|
-
const internal =
|
|
15834
|
+
const api = [];
|
|
15835
|
+
const internal = [];
|
|
15836
|
+
const unclassified = [];
|
|
15837
|
+
for (const entry of topLevel) {
|
|
15838
|
+
if (entry.exported === void 0)
|
|
15839
|
+
unclassified.push(entry);
|
|
15840
|
+
else if (entry.exported)
|
|
15841
|
+
api.push(entry);
|
|
15842
|
+
else
|
|
15843
|
+
internal.push(entry);
|
|
15844
|
+
}
|
|
15495
15845
|
const warnings = [...extractionWarnings ?? []];
|
|
15496
15846
|
if (revisionDriftNote)
|
|
15497
15847
|
warnings.push(revisionDriftNote);
|
|
@@ -15539,13 +15889,14 @@ async function moduleReport(file, cwd, options) {
|
|
|
15539
15889
|
lineCount: lineCount3,
|
|
15540
15890
|
summary: {
|
|
15541
15891
|
imports: imports.external.length + imports.internal.length,
|
|
15542
|
-
exports: api.length,
|
|
15892
|
+
...unclassified.length > 0 && api.length + internal.length === 0 ? {} : { exports: api.length },
|
|
15543
15893
|
symbols: entries.length
|
|
15544
15894
|
},
|
|
15545
15895
|
imports,
|
|
15546
15896
|
...warnings.length > 0 ? { warnings } : {},
|
|
15547
15897
|
api,
|
|
15548
15898
|
internal,
|
|
15899
|
+
...unclassified.length > 0 ? { unclassified } : {},
|
|
15549
15900
|
callbacks,
|
|
15550
15901
|
callbackSupport: callbackSupportFor(languageId),
|
|
15551
15902
|
recommendedReads: rankRecommendedReads(entries, callbacks, 5, options?.focus),
|
|
@@ -15708,11 +16059,15 @@ function renderCompactModuleReport(report, options = {}) {
|
|
|
15708
16059
|
unavailable.push(provenanceLine(report, options.projection));
|
|
15709
16060
|
return unavailable.join("\n");
|
|
15710
16061
|
}
|
|
15711
|
-
const allEntries = [
|
|
16062
|
+
const allEntries = [
|
|
16063
|
+
...report.api,
|
|
16064
|
+
...report.internal,
|
|
16065
|
+
...report.unclassified ?? []
|
|
16066
|
+
];
|
|
15712
16067
|
const allRanges = allEntries.flatMap((e) => [e, ...e.members ?? []]);
|
|
15713
16068
|
const width = Math.max(5, ...allRanges.map((e) => `${e.startLine}-${e.endLine}`.length), ...report.callbacks.map((c) => `${c.startLine}-${c.endLine}`.length)) + 2;
|
|
15714
16069
|
const lines = [
|
|
15715
|
-
`${report.path} ${report.language ?? "?"} ${report.lineCount ?? "?"}L [${report.staleness}] \u2014 ${report.summary.symbols} symbols,
|
|
16070
|
+
`${report.path} ${report.language ?? "?"} ${report.lineCount ?? "?"}L [${report.staleness}] \u2014 ${report.summary.symbols} symbols, ` + (report.summary.exports === void 0 ? "" : `${report.summary.exports} exported, `) + `${report.summary.imports} imports${callbackSupportSuffix(report)}`
|
|
15716
16071
|
];
|
|
15717
16072
|
if (report.error)
|
|
15718
16073
|
lines.push(`INCOMPLETE: ${report.error}`);
|
|
@@ -15729,6 +16084,11 @@ function renderCompactModuleReport(report, options = {}) {
|
|
|
15729
16084
|
for (const entry of report.internal)
|
|
15730
16085
|
lines.push(...compactEntryLines(entry, width, " "));
|
|
15731
16086
|
}
|
|
16087
|
+
if (report.unclassified && report.unclassified.length > 0) {
|
|
16088
|
+
lines.push("SYMBOLS (visibility unknown):");
|
|
16089
|
+
for (const entry of report.unclassified)
|
|
16090
|
+
lines.push(...compactEntryLines(entry, width, " "));
|
|
16091
|
+
}
|
|
15732
16092
|
appendCallbacksSection(lines, report, width);
|
|
15733
16093
|
if (report.imports.external.length + report.imports.internal.length > 0) {
|
|
15734
16094
|
lines.push("IMPORTS:");
|
|
@@ -15852,7 +16212,7 @@ function suggestSimilarNames(candidates, target) {
|
|
|
15852
16212
|
async function readSymbol(file, symbolName, cwd, options = {}) {
|
|
15853
16213
|
const { kind: symbolKindFilter } = options;
|
|
15854
16214
|
const startedAt = Date.now();
|
|
15855
|
-
const absPath =
|
|
16215
|
+
const absPath = path26.resolve(cwd, file);
|
|
15856
16216
|
const log = (found) => {
|
|
15857
16217
|
logLatency({
|
|
15858
16218
|
type: "phase",
|
|
@@ -15864,7 +16224,7 @@ async function readSymbol(file, symbolName, cwd, options = {}) {
|
|
|
15864
16224
|
};
|
|
15865
16225
|
let content;
|
|
15866
16226
|
try {
|
|
15867
|
-
content =
|
|
16227
|
+
content = fs19.readFileSync(absPath, "utf-8");
|
|
15868
16228
|
} catch (err) {
|
|
15869
16229
|
log(false);
|
|
15870
16230
|
return {
|
|
@@ -16056,7 +16416,7 @@ function enclosingOutline(selected, symbols, callbacks, filters, filePath) {
|
|
|
16056
16416
|
}
|
|
16057
16417
|
async function readEnclosing(file, line, cwd, options) {
|
|
16058
16418
|
const startedAt = Date.now();
|
|
16059
|
-
const absPath =
|
|
16419
|
+
const absPath = path26.resolve(cwd, file);
|
|
16060
16420
|
const targetLine = Math.max(1, Math.floor(line));
|
|
16061
16421
|
const maxLines = options?.maxLines !== void 0 && Number.isFinite(options.maxLines) ? Math.max(1, Math.floor(options.maxLines)) : void 0;
|
|
16062
16422
|
const aroundLine = options?.aroundLine !== void 0 && Number.isFinite(options.aroundLine) ? options.aroundLine : void 0;
|
|
@@ -16071,7 +16431,7 @@ async function readEnclosing(file, line, cwd, options) {
|
|
|
16071
16431
|
};
|
|
16072
16432
|
let content;
|
|
16073
16433
|
try {
|
|
16074
|
-
content =
|
|
16434
|
+
content = fs19.readFileSync(absPath, "utf-8");
|
|
16075
16435
|
} catch {
|
|
16076
16436
|
log(false);
|
|
16077
16437
|
return { found: false, path: absPath, line: targetLine };
|
|
@@ -16234,7 +16594,7 @@ async function readEnclosing(file, line, cwd, options) {
|
|
|
16234
16594
|
}
|
|
16235
16595
|
|
|
16236
16596
|
// dist/clients/project-report.js
|
|
16237
|
-
import * as
|
|
16597
|
+
import * as path27 from "node:path";
|
|
16238
16598
|
var DEFAULT_LIMIT = 10;
|
|
16239
16599
|
var STALE_THRESHOLD_MS = 15 * 6e4;
|
|
16240
16600
|
var LOW_COVERAGE_THRESHOLD = 0.8;
|
|
@@ -16380,7 +16740,7 @@ function roleFor(graph, filePath) {
|
|
|
16380
16740
|
return top.length > 0 ? top.map((s) => s.name).join(", ") : void 0;
|
|
16381
16741
|
}
|
|
16382
16742
|
async function computeHubs(graph, degrees, cwd, limit, focusTerms) {
|
|
16383
|
-
const { computeTransitiveImpact } = await import("../chunk-
|
|
16743
|
+
const { computeTransitiveImpact } = await import("../chunk-JTHEUTW7.js");
|
|
16384
16744
|
const ranked = [...graph.fileNodes.entries()].map(([filePath, fileNodeId]) => ({
|
|
16385
16745
|
filePath,
|
|
16386
16746
|
fileNodeId,
|
|
@@ -16618,7 +16978,7 @@ function computeDeadWeight(graph, degrees, entryPointFiles, cwd, limit) {
|
|
|
16618
16978
|
}
|
|
16619
16979
|
var inFlightGraphBuilds = /* @__PURE__ */ new Set();
|
|
16620
16980
|
function triggerBackgroundGraphBuild(cwd, deps) {
|
|
16621
|
-
const key = normalizeMapKey(
|
|
16981
|
+
const key = normalizeMapKey(path27.resolve(cwd));
|
|
16622
16982
|
if (inFlightGraphBuilds.has(key))
|
|
16623
16983
|
return "already_running";
|
|
16624
16984
|
const deduped = deps.isGraphBuildInFlight(key, []);
|
|
@@ -16631,7 +16991,7 @@ function triggerBackgroundGraphBuild(cwd, deps) {
|
|
|
16631
16991
|
async function projectReport(cwd, options) {
|
|
16632
16992
|
const limit = clampLimit(options?.limit);
|
|
16633
16993
|
const focusTerms = normalizeFocus2(options?.focus);
|
|
16634
|
-
const { getCachedReviewGraph, getReviewGraphSizeSkipVerdict, getLastReviewGraphBuildAttempt, buildOrUpdateGraph, isGraphBuildInFlight, getReviewGraphRevisionDrift } = await import("../chunk-
|
|
16994
|
+
const { getCachedReviewGraph, getReviewGraphSizeSkipVerdict, getLastReviewGraphBuildAttempt, buildOrUpdateGraph, isGraphBuildInFlight, getReviewGraphRevisionDrift } = await import("../chunk-MY4XNNTX.js");
|
|
16635
16995
|
let graph;
|
|
16636
16996
|
try {
|
|
16637
16997
|
graph = getCachedReviewGraph(cwd);
|
|
@@ -16654,7 +17014,7 @@ async function projectReport(cwd, options) {
|
|
|
16654
17014
|
};
|
|
16655
17015
|
}
|
|
16656
17016
|
const previousAttempt = getLastReviewGraphBuildAttempt(cwd);
|
|
16657
|
-
const { FactStore: FactStore2 } = await import("../chunk-
|
|
17017
|
+
const { FactStore: FactStore2 } = await import("../chunk-ZEUF7BIN.js");
|
|
16658
17018
|
const trigger = triggerBackgroundGraphBuild(cwd, {
|
|
16659
17019
|
buildOrUpdateGraph,
|
|
16660
17020
|
isGraphBuildInFlight,
|
|
@@ -16844,8 +17204,9 @@ function fmtPct(n) {
|
|
|
16844
17204
|
}
|
|
16845
17205
|
|
|
16846
17206
|
// dist/clients/effective-config.js
|
|
16847
|
-
import * as
|
|
16848
|
-
import * as
|
|
17207
|
+
import * as os4 from "node:os";
|
|
17208
|
+
import * as path28 from "node:path";
|
|
17209
|
+
var TOOL_SWITCH_POINTER = /^\/tools\/[^/]+\/enabled$/;
|
|
16849
17210
|
function isEffectiveFileViewError(file) {
|
|
16850
17211
|
return "error" in file;
|
|
16851
17212
|
}
|
|
@@ -16916,24 +17277,40 @@ function decidedByOrNothing(entry) {
|
|
|
16916
17277
|
}
|
|
16917
17278
|
async function effectiveConfig(options = {}) {
|
|
16918
17279
|
const cwd = options.cwd ?? process.cwd();
|
|
16919
|
-
const homeDir = options.homeDir ??
|
|
16920
|
-
const resolveAt = (dir) => resolvePiLensConfig({
|
|
17280
|
+
const homeDir = options.homeDir ?? os4.homedir();
|
|
17281
|
+
const resolveAt = (dir, excludeLegacyProjectDocuments = false) => resolvePiLensConfig({
|
|
16921
17282
|
cwd: dir,
|
|
16922
17283
|
globalDir: getGlobalPiLensDir(),
|
|
16923
17284
|
// Production resolution for the global tier — see loadLSPConfig's
|
|
16924
17285
|
// comment (global-config-location PR, refs #2457).
|
|
16925
17286
|
globalConfigPath: getPiLensGlobalConfigPath(),
|
|
16926
|
-
homeDir
|
|
17287
|
+
homeDir,
|
|
17288
|
+
excludeLegacyProjectDocuments
|
|
16927
17289
|
});
|
|
16928
17290
|
const requestedFile = options.file === void 0 ? void 0 : resolveHostToolPath(options.file, cwd);
|
|
16929
17291
|
const fileOutsideCwd = requestedFile !== void 0 && !isSameOrWithin(cwd, requestedFile);
|
|
16930
17292
|
const absolute = fileOutsideCwd ? void 0 : requestedFile;
|
|
16931
|
-
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
|
+
};
|
|
16932
17309
|
const resolved = {
|
|
16933
17310
|
value: resolution.value,
|
|
16934
|
-
provenance:
|
|
17311
|
+
provenance: reportedResolution.provenance
|
|
16935
17312
|
};
|
|
16936
|
-
const summary = summarizeConfigResolution(
|
|
17313
|
+
const summary = summarizeConfigResolution(reportedResolution, homeDir);
|
|
16937
17314
|
const homeRelativeCwd = homeRelativePath(cwd, homeDir);
|
|
16938
17315
|
const lspProblems = newLspConfigProblems();
|
|
16939
17316
|
lspConfigOf(resolution.value, lspProblems);
|
|
@@ -16949,12 +17326,12 @@ async function effectiveConfig(options = {}) {
|
|
|
16949
17326
|
// `disabledServerRecords` (#5141).
|
|
16950
17327
|
recordCounts: countBy([
|
|
16951
17328
|
...resolution.records,
|
|
16952
|
-
...disabledRunnersOf(
|
|
17329
|
+
...disabledRunnersOf(policyResolution).records,
|
|
16953
17330
|
...disabledServerRecords(resolution, lspProblems)
|
|
16954
17331
|
], (record) => record.code),
|
|
16955
17332
|
tools: LENS_TOOL_NAMES.map((name) => ({
|
|
16956
17333
|
name,
|
|
16957
|
-
enabled: resolveLensToolEnabled(name,
|
|
17334
|
+
enabled: resolveLensToolEnabled(name, globalValue, projectRaw, options.noTools)
|
|
16958
17335
|
})),
|
|
16959
17336
|
...fileOutsideCwd ? {
|
|
16960
17337
|
file: {
|
|
@@ -16963,7 +17340,7 @@ async function effectiveConfig(options = {}) {
|
|
|
16963
17340
|
} : absolute === void 0 ? {} : {
|
|
16964
17341
|
file: await fileView(
|
|
16965
17342
|
absolute,
|
|
16966
|
-
|
|
17343
|
+
policyResolution,
|
|
16967
17344
|
resolved,
|
|
16968
17345
|
homeDir,
|
|
16969
17346
|
cwd,
|
|
@@ -17135,10 +17512,10 @@ function buildSymbolSearchFileFilter(cwd, options) {
|
|
|
17135
17512
|
};
|
|
17136
17513
|
}
|
|
17137
17514
|
function scopeEntryKeys(cwd, paths) {
|
|
17138
|
-
return new Set(paths.map((entry) => normalizeEphemeralMapKey(
|
|
17515
|
+
return new Set(paths.map((entry) => normalizeEphemeralMapKey(path29.resolve(cwd, entry))));
|
|
17139
17516
|
}
|
|
17140
17517
|
function fileIsInScope(file, scope) {
|
|
17141
|
-
let key = normalizeEphemeralMapKey(
|
|
17518
|
+
let key = normalizeEphemeralMapKey(path29.resolve(file));
|
|
17142
17519
|
for (; ; ) {
|
|
17143
17520
|
if (scope.has(key))
|
|
17144
17521
|
return true;
|
|
@@ -17165,7 +17542,7 @@ function unknownLangRefusal(query, lang) {
|
|
|
17165
17542
|
}
|
|
17166
17543
|
function annotateSymbolSearchHitsWithGraph(hits, centrality, graph) {
|
|
17167
17544
|
for (const hit of hits) {
|
|
17168
|
-
const normalized = normalizeMapKey(
|
|
17545
|
+
const normalized = normalizeMapKey(path29.resolve(hit.file));
|
|
17169
17546
|
const fanIn = centrality.get(hit.file) ?? 0;
|
|
17170
17547
|
let complexity;
|
|
17171
17548
|
for (const symbolId of graph.symbolNodesByFile.get(normalized) ?? []) {
|
|
@@ -17229,7 +17606,7 @@ async function symbolSearch(query, cwd, limit = 20, options = {}) {
|
|
|
17229
17606
|
let centrality;
|
|
17230
17607
|
let results;
|
|
17231
17608
|
try {
|
|
17232
|
-
centrality = centralityFromReverseDeps(index, snapshot?.reverseDeps, (file) => normalizeMapKey(
|
|
17609
|
+
centrality = centralityFromReverseDeps(index, snapshot?.reverseDeps, (file) => normalizeMapKey(path29.resolve(file)));
|
|
17233
17610
|
const fileFilter = buildSymbolSearchFileFilter(cwd, options);
|
|
17234
17611
|
results = searchWordIndex(index, query, {
|
|
17235
17612
|
limit: effectiveLimit,
|
|
@@ -17240,7 +17617,7 @@ async function symbolSearch(query, cwd, limit = 20, options = {}) {
|
|
|
17240
17617
|
warmLease.release();
|
|
17241
17618
|
}
|
|
17242
17619
|
const hits = results.map(toSymbolSearchHit);
|
|
17243
|
-
const { getCachedReviewGraph } = await import("../chunk-
|
|
17620
|
+
const { getCachedReviewGraph } = await import("../chunk-MY4XNNTX.js");
|
|
17244
17621
|
const graph = getCachedReviewGraph(cwd);
|
|
17245
17622
|
if (graph)
|
|
17246
17623
|
annotateSymbolSearchHitsWithGraph(hits, centrality, graph);
|
|
@@ -17258,7 +17635,7 @@ function coverageLine(coverage) {
|
|
|
17258
17635
|
return `Index covers ${coverage.files} files${coverage.truncated ? " (capped \u2014 results may be incomplete)" : ""}.`;
|
|
17259
17636
|
}
|
|
17260
17637
|
function formatSymbolSearchRow(hit, position, cwd) {
|
|
17261
|
-
const file =
|
|
17638
|
+
const file = path29.relative(cwd, hit.file);
|
|
17262
17639
|
if (hit.kind === "file")
|
|
17263
17640
|
return ` ${position}. ${file}`;
|
|
17264
17641
|
const annotations = hit.annotations;
|
|
@@ -17286,7 +17663,7 @@ function renderCompactSymbolSearch(result, options) {
|
|
|
17286
17663
|
footer.push(options.stalenessNote);
|
|
17287
17664
|
const top = hits[0];
|
|
17288
17665
|
if (top) {
|
|
17289
|
-
footer.push(`Next: ${options.reportTool ?? "module_report"} ${
|
|
17666
|
+
footer.push(`Next: ${options.reportTool ?? "module_report"} ${path29.relative(options.cwd, top.file)}`);
|
|
17290
17667
|
}
|
|
17291
17668
|
if (footer.length > 0)
|
|
17292
17669
|
sections.push(footer.join("\n"));
|
|
@@ -17294,16 +17671,16 @@ function renderCompactSymbolSearch(result, options) {
|
|
|
17294
17671
|
}
|
|
17295
17672
|
|
|
17296
17673
|
// dist/tools/ast-grep-replace.js
|
|
17297
|
-
import * as
|
|
17674
|
+
import * as path33 from "node:path";
|
|
17298
17675
|
|
|
17299
17676
|
// dist/clients/deps/typebox.js
|
|
17300
17677
|
import { Type } from "typebox";
|
|
17301
17678
|
|
|
17302
17679
|
// dist/clients/ast-grep-tool-logger.js
|
|
17303
|
-
import * as
|
|
17680
|
+
import * as path30 from "node:path";
|
|
17304
17681
|
var AG_LOG_DIR = getGlobalPiLensLogDir();
|
|
17305
|
-
var AG_LOG_FILE =
|
|
17306
|
-
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");
|
|
17307
17684
|
var MAX_LOG_BYTES3 = Math.max(128 * 1024, Number.parseInt(process.env.PI_LENS_AST_GREP_LOG_MAX_BYTES ?? "1048576", 10) || 1048576);
|
|
17308
17685
|
var writer3 = createNdjsonLogger({
|
|
17309
17686
|
filePath: AG_LOG_FILE,
|
|
@@ -17481,19 +17858,19 @@ function canonicalLanguage(lang) {
|
|
|
17481
17858
|
}
|
|
17482
17859
|
|
|
17483
17860
|
// dist/tools/shared.js
|
|
17484
|
-
import * as
|
|
17485
|
-
import * as
|
|
17861
|
+
import * as os5 from "node:os";
|
|
17862
|
+
import * as path32 from "node:path";
|
|
17486
17863
|
|
|
17487
17864
|
// dist/clients/path-globs.js
|
|
17488
|
-
import * as
|
|
17489
|
-
import * as
|
|
17865
|
+
import * as fs20 from "node:fs";
|
|
17866
|
+
import * as path31 from "node:path";
|
|
17490
17867
|
function fileMatchesPathGlobs(file, cwd, globs) {
|
|
17491
|
-
const rel =
|
|
17492
|
-
const abs =
|
|
17868
|
+
const rel = path31.relative(cwd, file).split(path31.sep).join("/");
|
|
17869
|
+
const abs = path31.resolve(file).split(path31.sep).join("/");
|
|
17493
17870
|
const options = { dot: true, nocase: process.platform === "win32" };
|
|
17494
17871
|
const matches = (candidate, pattern) => minimatch(candidate, pattern, options) || minimatch(candidate, `${pattern}/**`, options);
|
|
17495
17872
|
return globs.some((raw) => {
|
|
17496
|
-
const within =
|
|
17873
|
+
const within = path31.isAbsolute(raw) ? relativeInside(cwd, raw) : void 0;
|
|
17497
17874
|
if (within !== void 0)
|
|
17498
17875
|
return matches(rel, toPosix(within) || "**");
|
|
17499
17876
|
const pattern = toPosix(raw);
|
|
@@ -17504,32 +17881,32 @@ function hasGlobMagic(text) {
|
|
|
17504
17881
|
return /[*?[{]/.test(text);
|
|
17505
17882
|
}
|
|
17506
17883
|
async function isGlobEntry(resolved, cwd) {
|
|
17507
|
-
const spelled = relativeInside(
|
|
17884
|
+
const spelled = relativeInside(path31.resolve(cwd), resolved) ?? resolved;
|
|
17508
17885
|
if (!hasGlobMagic(spelled))
|
|
17509
17886
|
return false;
|
|
17510
|
-
return
|
|
17887
|
+
return fs20.promises.lstat(resolved).then(() => false, (refusal) => {
|
|
17511
17888
|
return refusal.code === "ENOENT" || refusal.code === "ENOTDIR";
|
|
17512
17889
|
});
|
|
17513
17890
|
}
|
|
17514
|
-
function literalRoot(cwd,
|
|
17891
|
+
function literalRoot(cwd, relative10) {
|
|
17515
17892
|
let root = cwd;
|
|
17516
|
-
for (const segment of
|
|
17893
|
+
for (const segment of relative10.split("/")) {
|
|
17517
17894
|
if (hasGlobMagic(segment))
|
|
17518
17895
|
break;
|
|
17519
|
-
root =
|
|
17896
|
+
root = path31.join(root, segment);
|
|
17520
17897
|
}
|
|
17521
17898
|
return root;
|
|
17522
17899
|
}
|
|
17523
17900
|
async function expandPathsEntry(entry, cwd, budget, options = {}) {
|
|
17524
|
-
const cwdAbsolute =
|
|
17525
|
-
const absolute =
|
|
17901
|
+
const cwdAbsolute = path31.resolve(cwd);
|
|
17902
|
+
const absolute = path31.resolve(cwdAbsolute, entry);
|
|
17526
17903
|
if (!await isGlobEntry(absolute, cwdAbsolute))
|
|
17527
17904
|
return { entries: [absolute], root: cwdAbsolute };
|
|
17528
|
-
const
|
|
17529
|
-
if (
|
|
17905
|
+
const relative10 = relativeInside(cwdAbsolute, absolute);
|
|
17906
|
+
if (relative10 === void 0) {
|
|
17530
17907
|
return { entries: [], refusal: "outside", root: cwdAbsolute };
|
|
17531
17908
|
}
|
|
17532
|
-
const root = literalRoot(cwdAbsolute,
|
|
17909
|
+
const root = literalRoot(cwdAbsolute, relative10);
|
|
17533
17910
|
const { signal } = options;
|
|
17534
17911
|
const matcher = getProjectIgnoreMatcher(cwdAbsolute);
|
|
17535
17912
|
const policy = { ignoreMatcher: matcher };
|
|
@@ -17624,7 +18001,7 @@ async function readPathsArgument(raw, options) {
|
|
|
17624
18001
|
const base = options.cwd || ".";
|
|
17625
18002
|
const absent = options.absent ?? "none";
|
|
17626
18003
|
if (raw === void 0 || raw === null) {
|
|
17627
|
-
return { entries: absent === "cwd" ? [
|
|
18004
|
+
return { entries: absent === "cwd" ? [path32.resolve(base)] : [] };
|
|
17628
18005
|
}
|
|
17629
18006
|
if (!Array.isArray(raw))
|
|
17630
18007
|
return { entries: [], refusal: "paths must be an array of strings" };
|
|
@@ -17687,7 +18064,7 @@ function defaultedCwdHomeRefusal(paths, cwd) {
|
|
|
17687
18064
|
if (paths?.length)
|
|
17688
18065
|
return void 0;
|
|
17689
18066
|
const spelling = cwd || ".";
|
|
17690
|
-
if (!isAtOrAboveHomeDir(realpathOrResolve(spelling), realpathOrResolve(
|
|
18067
|
+
if (!isAtOrAboveHomeDir(realpathOrResolve(spelling), realpathOrResolve(os5.homedir())))
|
|
17691
18068
|
return void 0;
|
|
17692
18069
|
return {
|
|
17693
18070
|
reason: "defaulted cwd resolves at or above home directory",
|
|
@@ -17890,7 +18267,7 @@ function createAstGrepReplaceTool(astGrepClient2, captureLineage, getFlag) {
|
|
|
17890
18267
|
};
|
|
17891
18268
|
}
|
|
17892
18269
|
const searchPaths = pathsRead.entries;
|
|
17893
|
-
const sessionRoot =
|
|
18270
|
+
const sessionRoot = path33.resolve(ctx.cwd ?? process.cwd());
|
|
17894
18271
|
if (applyFlag && getFlag?.("no-autofix", sessionRoot)) {
|
|
17895
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";
|
|
17896
18273
|
logOutcome("error", { errorRaw: reason });
|
|
@@ -17943,11 +18320,7 @@ function createAstGrepReplaceTool(astGrepClient2, captureLineage, getFlag) {
|
|
|
17943
18320
|
}
|
|
17944
18321
|
],
|
|
17945
18322
|
isError: true,
|
|
17946
|
-
|
|
17947
|
-
details: {
|
|
17948
|
-
stalePreview: true,
|
|
17949
|
-
appliedFiles: ruleResult.appliedFiles ?? []
|
|
17950
|
-
}
|
|
18323
|
+
details: { stalePreview: true }
|
|
17951
18324
|
};
|
|
17952
18325
|
}
|
|
17953
18326
|
if (ruleResult.error) {
|
|
@@ -17960,7 +18333,7 @@ function createAstGrepReplaceTool(astGrepClient2, captureLineage, getFlag) {
|
|
|
17960
18333
|
}
|
|
17961
18334
|
],
|
|
17962
18335
|
isError: true,
|
|
17963
|
-
details: {
|
|
18336
|
+
details: {}
|
|
17964
18337
|
};
|
|
17965
18338
|
}
|
|
17966
18339
|
const output2 = astGrepClient2.formatMatches(ruleResult.matches, !applyFlag, true, resultMaxItems);
|
|
@@ -17971,10 +18344,7 @@ function createAstGrepReplaceTool(astGrepClient2, captureLineage, getFlag) {
|
|
|
17971
18344
|
content: [{ type: "text", text: output2 }],
|
|
17972
18345
|
details: {
|
|
17973
18346
|
matchCount: ruleResult.matches.length,
|
|
17974
|
-
applied: applyFlag
|
|
17975
|
-
// #5239: the files the apply rewrote, for the `tool_result`
|
|
17976
|
-
// handler's dispatch.
|
|
17977
|
-
appliedFiles: ruleResult.appliedFiles ?? []
|
|
18347
|
+
applied: applyFlag
|
|
17978
18348
|
}
|
|
17979
18349
|
};
|
|
17980
18350
|
}
|
|
@@ -18004,9 +18374,7 @@ function createAstGrepReplaceTool(astGrepClient2, captureLineage, getFlag) {
|
|
|
18004
18374
|
return {
|
|
18005
18375
|
content: [{ type: "text", text: failureText(result) }],
|
|
18006
18376
|
isError: true,
|
|
18007
|
-
|
|
18008
|
-
// failed; they still dispatch, as the structural path's do.
|
|
18009
|
-
details: { appliedFiles: result.appliedFiles ?? [] }
|
|
18377
|
+
details: {}
|
|
18010
18378
|
};
|
|
18011
18379
|
}
|
|
18012
18380
|
const isDryRun = !applyFlag;
|
|
@@ -18027,10 +18395,7 @@ function createAstGrepReplaceTool(astGrepClient2, captureLineage, getFlag) {
|
|
|
18027
18395
|
matchCount: result.matches.length,
|
|
18028
18396
|
totalMatches: result.totalMatches,
|
|
18029
18397
|
truncated: result.truncated,
|
|
18030
|
-
applied: applyFlag
|
|
18031
|
-
// #5239: the files the apply rewrote, for the `tool_result`
|
|
18032
|
-
// handler's dispatch.
|
|
18033
|
-
appliedFiles: result.appliedFiles ?? []
|
|
18398
|
+
applied: applyFlag
|
|
18034
18399
|
}
|
|
18035
18400
|
};
|
|
18036
18401
|
}
|
|
@@ -18725,10 +19090,10 @@ ${hint}` : `${output}${paginationNote}`;
|
|
|
18725
19090
|
}
|
|
18726
19091
|
|
|
18727
19092
|
// dist/tools/lens-diagnostics.js
|
|
18728
|
-
import { promises as
|
|
19093
|
+
import { promises as fs24 } from "node:fs";
|
|
18729
19094
|
import * as fsSync from "node:fs";
|
|
18730
|
-
import * as
|
|
18731
|
-
import * as
|
|
19095
|
+
import * as os8 from "node:os";
|
|
19096
|
+
import * as path40 from "node:path";
|
|
18732
19097
|
|
|
18733
19098
|
// dist/clients/project-diagnostics/extractors.js
|
|
18734
19099
|
var WARM_TRIGGER = {
|
|
@@ -18786,14 +19151,14 @@ function reasonFromAvailabilityVerdict(tool, verdict) {
|
|
|
18786
19151
|
}
|
|
18787
19152
|
|
|
18788
19153
|
// dist/clients/project-diagnostics/fresh-fetch.js
|
|
18789
|
-
import * as
|
|
18790
|
-
import * as
|
|
18791
|
-
import * as
|
|
19154
|
+
import * as fs22 from "node:fs";
|
|
19155
|
+
import * as os6 from "node:os";
|
|
19156
|
+
import * as path38 from "node:path";
|
|
18792
19157
|
|
|
18793
19158
|
// dist/clients/project-diagnostics/runner-adapters/jscpd.js
|
|
18794
|
-
import * as
|
|
19159
|
+
import * as path34 from "node:path";
|
|
18795
19160
|
function resolveClonePath(cwd, file) {
|
|
18796
|
-
return
|
|
19161
|
+
return path34.isAbsolute(file) ? file : path34.resolve(cwd, file);
|
|
18797
19162
|
}
|
|
18798
19163
|
function jscpdCloneToProjectDiagnostics(cwd, clone) {
|
|
18799
19164
|
const a = resolveClonePath(cwd, clone.fileA);
|
|
@@ -18806,7 +19171,7 @@ function jscpdCloneToProjectDiagnostics(cwd, clone) {
|
|
|
18806
19171
|
tool: "jscpd",
|
|
18807
19172
|
runner: "jscpd",
|
|
18808
19173
|
rule: "jscpd:duplicate",
|
|
18809
|
-
message: `Duplicate code (${clone.lines} lines) \u2014 also at ${
|
|
19174
|
+
message: `Duplicate code (${clone.lines} lines) \u2014 also at ${path34.relative(cwd, otherFile)}:${otherLine}`,
|
|
18810
19175
|
source: "project-scan"
|
|
18811
19176
|
});
|
|
18812
19177
|
return [
|
|
@@ -18821,16 +19186,16 @@ function jscpdResultToProjectDiagnostics(cwd, result) {
|
|
|
18821
19186
|
}
|
|
18822
19187
|
|
|
18823
19188
|
// dist/clients/project-diagnostics/runner-adapters/madge.js
|
|
18824
|
-
import * as
|
|
19189
|
+
import * as path35 from "node:path";
|
|
18825
19190
|
function resolveCyclePath(cwd, file) {
|
|
18826
|
-
return
|
|
19191
|
+
return path35.isAbsolute(file) ? file : path35.resolve(cwd, file);
|
|
18827
19192
|
}
|
|
18828
19193
|
function cycleMembers(dep) {
|
|
18829
19194
|
return dep.path.length > 0 ? dep.path : [dep.file];
|
|
18830
19195
|
}
|
|
18831
19196
|
function circularDepToProjectDiagnostics(cwd, dep) {
|
|
18832
19197
|
const members = cycleMembers(dep);
|
|
18833
|
-
const rendered = `${members.map((f) =>
|
|
19198
|
+
const rendered = `${members.map((f) => path35.basename(f)).join(" \u2192 ")} \u2192 ${path35.basename(members[0] ?? "")}`;
|
|
18834
19199
|
return members.map((file) => ({
|
|
18835
19200
|
filePath: resolveCyclePath(cwd, file),
|
|
18836
19201
|
severity: "warning",
|
|
@@ -18856,7 +19221,7 @@ function circularDepsToProjectDiagnostics(cwd, circular) {
|
|
|
18856
19221
|
}
|
|
18857
19222
|
|
|
18858
19223
|
// dist/clients/project-diagnostics/runner-adapters/opengrep.js
|
|
18859
|
-
import * as
|
|
19224
|
+
import * as path36 from "node:path";
|
|
18860
19225
|
function severityFor(raw) {
|
|
18861
19226
|
switch (raw.toUpperCase()) {
|
|
18862
19227
|
case "ERROR":
|
|
@@ -18871,7 +19236,7 @@ function opengrepFindingToProjectDiagnostic(cwd, finding) {
|
|
|
18871
19236
|
const { severity, blocking } = severityFor(finding.severity);
|
|
18872
19237
|
const cweSuffix = finding.cwe?.length ? ` (${finding.cwe[0]})` : "";
|
|
18873
19238
|
return {
|
|
18874
|
-
filePath:
|
|
19239
|
+
filePath: path36.isAbsolute(finding.path) ? finding.path : path36.resolve(cwd, finding.path),
|
|
18875
19240
|
line: finding.startLine,
|
|
18876
19241
|
column: finding.startCol,
|
|
18877
19242
|
severity,
|
|
@@ -18890,8 +19255,8 @@ function opengrepResultToProjectDiagnostics(cwd, result) {
|
|
|
18890
19255
|
}
|
|
18891
19256
|
|
|
18892
19257
|
// dist/clients/project-diagnostics/runner-adapters/runner-findings.js
|
|
18893
|
-
import * as
|
|
18894
|
-
import * as
|
|
19258
|
+
import * as fs21 from "node:fs";
|
|
19259
|
+
import * as path37 from "node:path";
|
|
18895
19260
|
function failureMessage(failure) {
|
|
18896
19261
|
const firstLine2 = failure.message.split("\n")[0]?.slice(0, 300) ?? "";
|
|
18897
19262
|
return firstLine2 ? `${failure.name}: ${firstLine2}` : failure.name;
|
|
@@ -18957,7 +19322,7 @@ function testRunnerFindingsToProjectDiagnostics(cache, cwd, runtime) {
|
|
|
18957
19322
|
return [];
|
|
18958
19323
|
const validation = cwd ? validateAdvisoryProvenance(cache, cwd, runtime) : { status: "unknown", reasons: ["validation-context-missing"] };
|
|
18959
19324
|
const root = cwd ?? process.cwd();
|
|
18960
|
-
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)));
|
|
18961
19326
|
const historical = cache.superseded === true || cache.stale === true || validation.status !== "current";
|
|
18962
19327
|
return cache.results.filter((result) => !missingKeys.has(advisoryPathKey(result.file, root))).flatMap((result) => testResultToProjectDiagnostics(result, historical)).map((diagnostic) => historical ? {
|
|
18963
19328
|
...diagnostic,
|
|
@@ -18987,12 +19352,12 @@ function laneObservedAtMs(scannedAt, startedAtMs) {
|
|
|
18987
19352
|
return parseScannedAtMs(scannedAt) ?? startedAtMs;
|
|
18988
19353
|
}
|
|
18989
19354
|
async function fetchFreshProjectDiagnostics(cacheManager2, cwd, clients, signal, options = {}) {
|
|
18990
|
-
const requestedRoot = options.analysisRoot === void 0 ? cwd :
|
|
19355
|
+
const requestedRoot = options.analysisRoot === void 0 ? cwd : path38.resolve(cwd, options.analysisRoot);
|
|
18991
19356
|
let analysisRoot;
|
|
18992
19357
|
let analysisRootValidation;
|
|
18993
19358
|
if (options.analysisRoot !== void 0) {
|
|
18994
19359
|
try {
|
|
18995
|
-
if (!
|
|
19360
|
+
if (!fs22.statSync(requestedRoot).isDirectory()) {
|
|
18996
19361
|
throw new Error("is not a directory");
|
|
18997
19362
|
}
|
|
18998
19363
|
analysisRoot = realpathOrResolve(requestedRoot);
|
|
@@ -19026,7 +19391,7 @@ async function fetchFreshProjectDiagnostics(cacheManager2, cwd, clients, signal,
|
|
|
19026
19391
|
analysisRoot = realpathOrResolve(cwd);
|
|
19027
19392
|
}
|
|
19028
19393
|
const unsafeRootReason = "the analysis root resolves at or above the home directory; heavyweight analyzers refuse to walk from there (#747)";
|
|
19029
|
-
const homeRoot = realpathOrResolve(options.homeDir ??
|
|
19394
|
+
const homeRoot = realpathOrResolve(options.homeDir ?? os6.homedir());
|
|
19030
19395
|
if (options.analysisRoot !== void 0) {
|
|
19031
19396
|
const unsafeExplicitRoot = !isSameOrWithin(homeRoot, analysisRoot) || isSameOrWithin(analysisRoot, homeRoot);
|
|
19032
19397
|
analysisRootValidation = unsafeExplicitRoot ? {
|
|
@@ -19150,11 +19515,11 @@ async function fetchFreshProjectDiagnostics(cacheManager2, cwd, clients, signal,
|
|
|
19150
19515
|
// jscpd — duplicate code detection. Cache key varies with TS-project
|
|
19151
19516
|
// detection, exactly mirroring session_start's own logic.
|
|
19152
19517
|
task("jscpd", async () => {
|
|
19153
|
-
if (!await clients.jscpdClient.ensureAvailable()) {
|
|
19518
|
+
if (!await clients.jscpdClient.ensureAvailable(analysisRoot)) {
|
|
19154
19519
|
markCold("jscpd", reasonFromAvailabilityVerdict("jscpd", clients.jscpdClient.getAvailabilityVerdict?.()));
|
|
19155
19520
|
return;
|
|
19156
19521
|
}
|
|
19157
|
-
const isTsProject =
|
|
19522
|
+
const isTsProject = fs22.existsSync(path38.join(analysisRoot, "tsconfig.json"));
|
|
19158
19523
|
const scannerKey = isTsProject ? "jscpd-ts" : "jscpd";
|
|
19159
19524
|
const startMs = Date.now();
|
|
19160
19525
|
const result = await clients.jscpdClient.scan(analysisRoot, void 0, void 0, isTsProject);
|
|
@@ -19461,13 +19826,13 @@ function makeProgressReporter(onUpdate, label, throttleMs = 250) {
|
|
|
19461
19826
|
}
|
|
19462
19827
|
|
|
19463
19828
|
// dist/tools/lsp-diagnostics.js
|
|
19464
|
-
import * as
|
|
19465
|
-
import * as
|
|
19829
|
+
import * as fs23 from "node:fs";
|
|
19830
|
+
import * as path39 from "node:path";
|
|
19466
19831
|
|
|
19467
19832
|
// dist/clients/out-of-band-changes.js
|
|
19468
19833
|
import { promises as fsp } from "node:fs";
|
|
19469
|
-
import * as
|
|
19470
|
-
import { basename as
|
|
19834
|
+
import * as os7 from "node:os";
|
|
19835
|
+
import { basename as basename8, join as join19, relative as relative7 } from "node:path";
|
|
19471
19836
|
|
|
19472
19837
|
// dist/clients/disk-changes.js
|
|
19473
19838
|
var DISK_CHANGE_ORIGINS = [
|
|
@@ -19794,7 +20159,7 @@ var INSTALL_MARKERS = [
|
|
|
19794
20159
|
".yarn-integrity"
|
|
19795
20160
|
];
|
|
19796
20161
|
var VENV_LIB_DIR = "lib";
|
|
19797
|
-
var VENV_WINDOWS_SITE_PACKAGES =
|
|
20162
|
+
var VENV_WINDOWS_SITE_PACKAGES = join19("Lib", "site-packages");
|
|
19798
20163
|
var VENV_INTERPRETER_DIRS_MAX = 4;
|
|
19799
20164
|
var DECLARATION_WALK_MAX_DIRS = 4096;
|
|
19800
20165
|
var DECLARATION_WALK_MAX_FILES = 2048;
|
|
@@ -19815,22 +20180,24 @@ function demandsWalk(trigger, walk) {
|
|
|
19815
20180
|
return walk === "always" || trigger === "tool_result" && walk !== "interval";
|
|
19816
20181
|
}
|
|
19817
20182
|
var fingerprint = (stat) => `${stat.ino}:${stat.size}:${stat.mtimeMs}`;
|
|
20183
|
+
var fingerprintChangedAt = (print) => Number(print.slice(print.lastIndexOf(":") + 1));
|
|
20184
|
+
var isBelowRootConfig = (filePath) => BELOW_ROOT_CONFIG_FILE_NAMES.has(basename8(filePath));
|
|
19818
20185
|
function diffServerConfigs(root, before, after) {
|
|
19819
|
-
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])));
|
|
19820
20187
|
}
|
|
19821
20188
|
async function readVenvInstallParts(root, listed) {
|
|
19822
20189
|
const targets = [];
|
|
19823
20190
|
for (const name of PROJECT_VENV_DIR_NAMES) {
|
|
19824
20191
|
if (!listed.has(name))
|
|
19825
20192
|
continue;
|
|
19826
|
-
const venvRoot =
|
|
20193
|
+
const venvRoot = join19(root, name);
|
|
19827
20194
|
targets.push({
|
|
19828
20195
|
label: `${name}/${VENV_WINDOWS_SITE_PACKAGES}`,
|
|
19829
|
-
dir:
|
|
20196
|
+
dir: join19(venvRoot, VENV_WINDOWS_SITE_PACKAGES)
|
|
19830
20197
|
});
|
|
19831
20198
|
let interpreters;
|
|
19832
20199
|
try {
|
|
19833
|
-
interpreters = await fsp.readdir(
|
|
20200
|
+
interpreters = await fsp.readdir(join19(venvRoot, VENV_LIB_DIR), {
|
|
19834
20201
|
withFileTypes: true
|
|
19835
20202
|
});
|
|
19836
20203
|
} catch {
|
|
@@ -19841,7 +20208,7 @@ async function readVenvInstallParts(root, listed) {
|
|
|
19841
20208
|
for (const interpreter of interpreterDirs) {
|
|
19842
20209
|
targets.push({
|
|
19843
20210
|
label: `${name}/${VENV_LIB_DIR}/${interpreter.name}/site-packages`,
|
|
19844
|
-
dir:
|
|
20211
|
+
dir: join19(venvRoot, VENV_LIB_DIR, interpreter.name, "site-packages")
|
|
19845
20212
|
});
|
|
19846
20213
|
}
|
|
19847
20214
|
}
|
|
@@ -19875,7 +20242,7 @@ async function readInstallStamp(root) {
|
|
|
19875
20242
|
names.push(`node_modules/${marker}`);
|
|
19876
20243
|
let link;
|
|
19877
20244
|
try {
|
|
19878
|
-
link = await fsp.lstat(
|
|
20245
|
+
link = await fsp.lstat(join19(root, "node_modules"));
|
|
19879
20246
|
} catch {
|
|
19880
20247
|
link = void 0;
|
|
19881
20248
|
}
|
|
@@ -19891,7 +20258,7 @@ async function readInstallStamp(root) {
|
|
|
19891
20258
|
const [statted, venvParts] = await Promise.all([
|
|
19892
20259
|
Promise.all([...names, ...configNames].map(async (name) => {
|
|
19893
20260
|
try {
|
|
19894
|
-
const stat = await fsp.stat(
|
|
20261
|
+
const stat = await fsp.stat(join19(root, name));
|
|
19895
20262
|
return {
|
|
19896
20263
|
part: `${name}=${fingerprint(stat)}`,
|
|
19897
20264
|
changedAt: stat.mtimeMs
|
|
@@ -19946,9 +20313,11 @@ async function walkDeclarations(root) {
|
|
|
19946
20313
|
for (const entry of entries) {
|
|
19947
20314
|
if (entry.isDirectory()) {
|
|
19948
20315
|
if (!isExcludedDirName(entry.name))
|
|
19949
|
-
queue.push(
|
|
19950
|
-
} else if (entry.isFile() && DECLARATION_FILE.test(entry.name)
|
|
19951
|
-
|
|
20316
|
+
queue.push(join19(dir, entry.name));
|
|
20317
|
+
} else if (entry.isFile() && (DECLARATION_FILE.test(entry.name) || // #5501 r3: a member manifest below the root. The root's own are
|
|
20318
|
+
// statted with the install stamp, so the walk skips them.
|
|
20319
|
+
dir !== root && BELOW_ROOT_CONFIG_FILE_NAMES.has(entry.name))) {
|
|
20320
|
+
found.push(join19(dir, entry.name));
|
|
19952
20321
|
}
|
|
19953
20322
|
}
|
|
19954
20323
|
if (found.length > DECLARATION_WALK_MAX_FILES)
|
|
@@ -20020,10 +20389,31 @@ function diffDeclarations(before, after) {
|
|
|
20020
20389
|
changes.push({ filePath, type: 3 });
|
|
20021
20390
|
return changes;
|
|
20022
20391
|
}
|
|
20392
|
+
function firstLookFreshConfigs(root, rootConfigs, walked, since) {
|
|
20393
|
+
if (since === void 0 || since <= 0)
|
|
20394
|
+
return [];
|
|
20395
|
+
const floor = since - COARSE_MTIME_SLACK_MS;
|
|
20396
|
+
const fresh = [];
|
|
20397
|
+
for (const [name, print] of rootConfigs ?? [])
|
|
20398
|
+
if (fingerprintChangedAt(print) >= floor)
|
|
20399
|
+
fresh.push({ filePath: join19(root, name), type: 2 });
|
|
20400
|
+
for (const [filePath, print] of walked ?? [])
|
|
20401
|
+
if (isBelowRootConfig(filePath) && fingerprintChangedAt(print) >= floor)
|
|
20402
|
+
fresh.push({ filePath, type: 2 });
|
|
20403
|
+
return fresh;
|
|
20404
|
+
}
|
|
20405
|
+
function earliestOverlappingLaunch(root, clients) {
|
|
20406
|
+
const rootKey = normalizeMapKey(root);
|
|
20407
|
+
let earliest;
|
|
20408
|
+
for (const client of clients)
|
|
20409
|
+
if (rootsOverlap(normalizeMapKey(client.root), rootKey))
|
|
20410
|
+
earliest = earliest === void 0 ? client.spawnedAt : Math.min(earliest, client.spawnedAt);
|
|
20411
|
+
return earliest ?? 0;
|
|
20412
|
+
}
|
|
20023
20413
|
function lookForOutOfBandChanges(root, trigger, runtime, options = {}) {
|
|
20024
20414
|
if (options.signal?.aborted)
|
|
20025
20415
|
return Promise.resolve();
|
|
20026
|
-
const homeRoot = isAtOrAboveHomeDir(realpathOrResolve(root), realpathOrResolve(
|
|
20416
|
+
const homeRoot = isAtOrAboveHomeDir(realpathOrResolve(root), realpathOrResolve(os7.homedir()));
|
|
20027
20417
|
if (homeRoot)
|
|
20028
20418
|
recordDegradationOnce({
|
|
20029
20419
|
kind: "lsp-declaration-look-capped",
|
|
@@ -20111,10 +20501,17 @@ async function lookOnce(root, key, trigger, runtime, options, skipWalk) {
|
|
|
20111
20501
|
});
|
|
20112
20502
|
}
|
|
20113
20503
|
const installed = prior === void 0 ? firstLookSawInstall(install, options.since) : install.stamp !== prior.stamp;
|
|
20114
|
-
|
|
20504
|
+
const firstLookConfigs = prior === void 0 ? firstLookFreshConfigs(root, install.configs, observed?.declarations, options.since ?? (options.liveClients ? earliestOverlappingLaunch(root, options.liveClients()) : void 0)) : [];
|
|
20505
|
+
if (prior === void 0 && !installed && firstLookConfigs.length === 0)
|
|
20115
20506
|
return;
|
|
20116
|
-
const
|
|
20117
|
-
const
|
|
20507
|
+
const walkChanges = walkDue && !incomplete && declarations && prior?.declarations ? diffDeclarations(prior.declarations, declarations) : [];
|
|
20508
|
+
const changes = [];
|
|
20509
|
+
const configChanges = [
|
|
20510
|
+
...install.configs && prior?.configs ? diffServerConfigs(root, prior.configs, install.configs) : [],
|
|
20511
|
+
...firstLookConfigs
|
|
20512
|
+
];
|
|
20513
|
+
for (const change of walkChanges)
|
|
20514
|
+
(isBelowRootConfig(change.filePath) ? configChanges : changes).push(change);
|
|
20118
20515
|
if (!installed && changes.length === 0 && configChanges.length === 0)
|
|
20119
20516
|
return;
|
|
20120
20517
|
const at = Date.now();
|
|
@@ -20136,7 +20533,8 @@ async function lookOnce(root, key, trigger, runtime, options, skipWalk) {
|
|
|
20136
20533
|
trigger,
|
|
20137
20534
|
restarted,
|
|
20138
20535
|
// Which look produced this row: the root's FIRST look (no record yet,
|
|
20139
|
-
// so only
|
|
20536
|
+
// so only a live-client epoch can make it publish: `since`, #4532, or
|
|
20537
|
+
// `liveClients` for configs, #5501)
|
|
20140
20538
|
// or a later look compared against the recorded stamp. Both the
|
|
20141
20539
|
// session-cwd root and a live client's root write the same record,
|
|
20142
20540
|
// so this names the look, not the caller.
|
|
@@ -20147,8 +20545,10 @@ async function lookOnce(root, key, trigger, runtime, options, skipWalk) {
|
|
|
20147
20545
|
created: count(1),
|
|
20148
20546
|
changed: count(2),
|
|
20149
20547
|
deleted: count(3),
|
|
20150
|
-
// The server config files this look forwarded (#4532), by
|
|
20151
|
-
|
|
20548
|
+
// The server config files this look forwarded (#4532), by path from the
|
|
20549
|
+
// root: a member manifest below it (#5501 r3) is told apart by its
|
|
20550
|
+
// directory.
|
|
20551
|
+
configs: configChanges.map((change) => `${CHANGE_TYPE[change.type]}:${relative7(root, change.filePath).replaceAll("\\", "/")}`)
|
|
20152
20552
|
}
|
|
20153
20553
|
});
|
|
20154
20554
|
}
|
|
@@ -20258,7 +20658,7 @@ async function collectFiles(dir, extensions, maxFiles, isIgnored = () => false)
|
|
|
20258
20658
|
return;
|
|
20259
20659
|
let entries;
|
|
20260
20660
|
try {
|
|
20261
|
-
entries = await
|
|
20661
|
+
entries = await fs23.promises.readdir(current, { withFileTypes: true });
|
|
20262
20662
|
} catch {
|
|
20263
20663
|
return;
|
|
20264
20664
|
}
|
|
@@ -20267,11 +20667,11 @@ async function collectFiles(dir, extensions, maxFiles, isIgnored = () => false)
|
|
|
20267
20667
|
return;
|
|
20268
20668
|
if (entry.isSymbolicLink())
|
|
20269
20669
|
continue;
|
|
20270
|
-
const full =
|
|
20670
|
+
const full = path39.join(current, entry.name);
|
|
20271
20671
|
if (entry.isDirectory()) {
|
|
20272
20672
|
if (!isExcludedDirName(entry.name) && !isIgnored(full, true))
|
|
20273
20673
|
await walk(full);
|
|
20274
|
-
} else if (entry.isFile() && extensions.includes(
|
|
20674
|
+
} else if (entry.isFile() && extensions.includes(path39.extname(full))) {
|
|
20275
20675
|
if (isIgnored(full, false))
|
|
20276
20676
|
continue;
|
|
20277
20677
|
files.push(full);
|
|
@@ -20317,7 +20717,8 @@ function createLspDiagnosticsTool(nextWriteIndex, onConfirmedNoBlockers, getServ
|
|
|
20317
20717
|
}
|
|
20318
20718
|
await lookForOutOfBandChanges(cwd, "tool_call", void 0, {
|
|
20319
20719
|
walk: "always",
|
|
20320
|
-
signal
|
|
20720
|
+
signal,
|
|
20721
|
+
liveClients: () => lspService.livePrimaryClientRoots?.() ?? []
|
|
20321
20722
|
});
|
|
20322
20723
|
await lspService.sweepDocumentDrift({ force: true, full: true });
|
|
20323
20724
|
if (Array.isArray(typedParams.paths) && typedParams.paths.length > 0) {
|
|
@@ -20387,7 +20788,7 @@ function createLspDiagnosticsTool(nextWriteIndex, onConfirmedNoBlockers, getServ
|
|
|
20387
20788
|
const absPath = normalizeMapKey(typedParams.pathAlreadyResolved === true ? rawPath : resolveHostToolPath(rawPath, cwd));
|
|
20388
20789
|
let stat;
|
|
20389
20790
|
try {
|
|
20390
|
-
stat =
|
|
20791
|
+
stat = fs23.statSync(absPath);
|
|
20391
20792
|
} catch {
|
|
20392
20793
|
return {
|
|
20393
20794
|
content: [
|
|
@@ -20439,7 +20840,7 @@ async function collectDiagnosticsForFile(absPath, lspService, scanRoot, waitMs,
|
|
|
20439
20840
|
let content;
|
|
20440
20841
|
let touched;
|
|
20441
20842
|
try {
|
|
20442
|
-
content =
|
|
20843
|
+
content = fs23.readFileSync(absPath, "utf-8");
|
|
20443
20844
|
const contentLimit = explicitQuery ? exceedsExplicitQueryLimits(content) : exceedsLspSyncLimits(content);
|
|
20444
20845
|
if (contentLimit.tooLarge) {
|
|
20445
20846
|
const reason = `file too large for LSP diagnostics (${contentLimit.reason})`;
|
|
@@ -20589,8 +20990,13 @@ async function classifyEmptyResult(file, lspService) {
|
|
|
20589
20990
|
const snapshots = await lspService.getCapabilitySnapshots(file);
|
|
20590
20991
|
const tier = classifyCascadeWaitTier(lspService, file, snapshots);
|
|
20591
20992
|
return tier === "tier3-silent" ? "unconfirmed" : "clean";
|
|
20592
|
-
} catch {
|
|
20593
|
-
|
|
20993
|
+
} catch (cause) {
|
|
20994
|
+
recordDegradationOnce({
|
|
20995
|
+
kind: "lsp-empty-classification-failed",
|
|
20996
|
+
subject: file,
|
|
20997
|
+
reason: `the silent-on-clean classification of an empty answer failed (${cause instanceof Error ? cause.message : String(cause)}); the file reads unconfirmed, not clean`
|
|
20998
|
+
});
|
|
20999
|
+
return "unconfirmed";
|
|
20594
21000
|
}
|
|
20595
21001
|
}
|
|
20596
21002
|
async function primaryRootFallback(file, cwd) {
|
|
@@ -20599,20 +21005,14 @@ async function primaryRootFallback(file, cwd) {
|
|
|
20599
21005
|
return seen.find((fallback) => fallback.requiresProjectRoot);
|
|
20600
21006
|
}
|
|
20601
21007
|
async function resolveEmptyResult(file, lspService) {
|
|
20602
|
-
|
|
20603
|
-
const snapshots = await lspService.getCapabilitySnapshots(file);
|
|
20604
|
-
const tier = classifyCascadeWaitTier(lspService, file, snapshots);
|
|
20605
|
-
if (tier !== "tier3-silent") {
|
|
20606
|
-
return { confirmed: true, diagnostics: [] };
|
|
20607
|
-
}
|
|
20608
|
-
const syncDiagnostics = await attemptTsserverSyncDiagnostics(file, lspService);
|
|
20609
|
-
if (syncDiagnostics === void 0) {
|
|
20610
|
-
return { confirmed: false, diagnostics: [] };
|
|
20611
|
-
}
|
|
20612
|
-
return { confirmed: true, diagnostics: syncDiagnostics };
|
|
20613
|
-
} catch {
|
|
21008
|
+
if (await classifyEmptyResult(file, lspService) === "clean") {
|
|
20614
21009
|
return { confirmed: true, diagnostics: [] };
|
|
20615
21010
|
}
|
|
21011
|
+
const syncDiagnostics = await attemptTsserverSyncDiagnostics(file, lspService);
|
|
21012
|
+
if (syncDiagnostics === void 0) {
|
|
21013
|
+
return { confirmed: false, diagnostics: [] };
|
|
21014
|
+
}
|
|
21015
|
+
return { confirmed: true, diagnostics: syncDiagnostics };
|
|
20616
21016
|
}
|
|
20617
21017
|
function canTrustTouchConfirmation(file, serverScope, confirmedByTouch) {
|
|
20618
21018
|
return confirmedByTouch && (serverScope === "primary" || primaryServerId(file) !== "typescript");
|
|
@@ -20717,7 +21117,7 @@ async function collectFileDiagnosticResult(file, severity, lspService, waitMs, n
|
|
|
20717
21117
|
const scannedAt = Date.now();
|
|
20718
21118
|
let stat;
|
|
20719
21119
|
try {
|
|
20720
|
-
stat =
|
|
21120
|
+
stat = fs23.statSync(file);
|
|
20721
21121
|
if (!stat.isFile()) {
|
|
20722
21122
|
return { file, diagnostics: [], error: `${file}: not a file` };
|
|
20723
21123
|
}
|
|
@@ -21289,7 +21689,7 @@ async function expandPathsToFiles(cwd, rawPaths, pathsAlreadyResolved = false) {
|
|
|
21289
21689
|
const abs = normalizeMapKey(pathsAlreadyResolved ? entry : resolveHostToolPath(entry, cwd));
|
|
21290
21690
|
let stat;
|
|
21291
21691
|
try {
|
|
21292
|
-
stat =
|
|
21692
|
+
stat = fs23.statSync(abs);
|
|
21293
21693
|
} catch {
|
|
21294
21694
|
}
|
|
21295
21695
|
if (stat?.isDirectory()) {
|
|
@@ -21497,7 +21897,7 @@ async function runDirectoryDiagnostics(absPath, severity, lspService, options) {
|
|
|
21497
21897
|
reason: batchOutcomeReason(result)
|
|
21498
21898
|
}));
|
|
21499
21899
|
const auxiliaryOnlyLine = auxiliaryOnlyFindingsLine(results);
|
|
21500
|
-
const tooLargeLines = renderBatchOutcomeLines(outcomeDetails, (file) =>
|
|
21900
|
+
const tooLargeLines = renderBatchOutcomeLines(outcomeDetails, (file) => path39.relative(absPath, file));
|
|
21501
21901
|
const withheldDirectory = mergeWithheld(results.map((r) => r.withheldCompile));
|
|
21502
21902
|
const withheldDisclosure = withheldCompileNote(withheldDirectory);
|
|
21503
21903
|
let text;
|
|
@@ -21539,7 +21939,7 @@ async function runDirectoryDiagnostics(absPath, severity, lspService, options) {
|
|
|
21539
21939
|
];
|
|
21540
21940
|
const toRelative = (d) => ({
|
|
21541
21941
|
...d,
|
|
21542
|
-
file:
|
|
21942
|
+
file: path39.relative(absPath, d.file)
|
|
21543
21943
|
});
|
|
21544
21944
|
if (primaryDisplay.length > 0) {
|
|
21545
21945
|
lines.push(`Primary findings (${primaryDisplay.length}):`);
|
|
@@ -21572,7 +21972,7 @@ async function runDirectoryDiagnostics(absPath, severity, lspService, options) {
|
|
|
21572
21972
|
filesScanned: filesToProcess.length,
|
|
21573
21973
|
capped: wasCapped,
|
|
21574
21974
|
diagnostics: display.map((d) => ({
|
|
21575
|
-
file:
|
|
21975
|
+
file: path39.relative(absPath, d.file),
|
|
21576
21976
|
line: d.line,
|
|
21577
21977
|
character: d.character,
|
|
21578
21978
|
severity: d.severity,
|
|
@@ -21647,7 +22047,7 @@ async function findFullScanBindingMismatches(results) {
|
|
|
21647
22047
|
result.boundToCurrentDisk !== true && result.contentHash !== void 0
|
|
21648
22048
|
) {
|
|
21649
22049
|
try {
|
|
21650
|
-
const content = await
|
|
22050
|
+
const content = await fs24.readFile(result.filePath, "utf-8");
|
|
21651
22051
|
if (hashDiagnosticContent(content) !== result.contentHash) {
|
|
21652
22052
|
mismatched.add(result);
|
|
21653
22053
|
}
|
|
@@ -21657,7 +22057,7 @@ async function findFullScanBindingMismatches(results) {
|
|
|
21657
22057
|
sinceYield += 1;
|
|
21658
22058
|
if (sinceYield >= FULL_SCAN_BINDING_YIELD_EVERY) {
|
|
21659
22059
|
sinceYield = 0;
|
|
21660
|
-
await new Promise((
|
|
22060
|
+
await new Promise((resolve32) => setImmediate(resolve32));
|
|
21661
22061
|
}
|
|
21662
22062
|
}
|
|
21663
22063
|
return mismatched;
|
|
@@ -21707,7 +22107,7 @@ function createLensDiagnosticsTool(cacheManager2, getCwd, getLspService = getLSP
|
|
|
21707
22107
|
const files2 = details.filesChecked ?? details.filesScanned ?? 0;
|
|
21708
22108
|
const noun = count === 1 ? "diagnostic" : "diagnostics";
|
|
21709
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;
|
|
21710
|
-
const singleFile = (details?.mode === "file" || files2 === 1) && typeof filePath === "string" ? ` ${
|
|
22110
|
+
const singleFile = (details?.mode === "file" || files2 === 1) && typeof filePath === "string" ? ` ${path40.basename(filePath)}` : "";
|
|
21711
22111
|
const scope = files2 > 1 ? ` across ${files2} files` : singleFile;
|
|
21712
22112
|
if (isError)
|
|
21713
22113
|
return `lens_diagnostics lsp \u2014 ${text.split("\n")[0] ?? "error"}`;
|
|
@@ -22005,7 +22405,7 @@ function appendProjectDiagnosticsDeltaLines(groups, cwd, report, severity, inclu
|
|
|
22005
22405
|
const diagnostics = [...gated.live, ...gated.stale];
|
|
22006
22406
|
const byFile = /* @__PURE__ */ new Map();
|
|
22007
22407
|
for (const diagnostic of diagnostics) {
|
|
22008
|
-
const filePath =
|
|
22408
|
+
const filePath = path40.resolve(diagnostic.filePath);
|
|
22009
22409
|
const bucket = byFile.get(filePath) ?? [];
|
|
22010
22410
|
bucket.push(diagnostic);
|
|
22011
22411
|
byFile.set(filePath, bucket);
|
|
@@ -22300,7 +22700,7 @@ Summary (turn delta): ${aw} actionable warning${aw === 1 ? "" : "s"} \xB7 ${cq}
|
|
|
22300
22700
|
function createCurrentIgnoreFilter(cwd) {
|
|
22301
22701
|
try {
|
|
22302
22702
|
const matcher = getProjectIgnoreMatcher(cwd);
|
|
22303
|
-
return (filePath) => !matcher.isIgnored(
|
|
22703
|
+
return (filePath) => !matcher.isIgnored(path40.resolve(filePath), false);
|
|
22304
22704
|
} catch {
|
|
22305
22705
|
return () => true;
|
|
22306
22706
|
}
|
|
@@ -22330,9 +22730,9 @@ function resolvePathsScope(entries) {
|
|
|
22330
22730
|
}
|
|
22331
22731
|
const fileKeys = new Set(fileEntries.map((f) => normalizeFilePath(f)));
|
|
22332
22732
|
const dirPrefixes = dirEntries.map((d) => normalizeFilePath(d));
|
|
22333
|
-
const includeExplicitFile = (filePath) => fileKeys.has(normalizeFilePath(
|
|
22733
|
+
const includeExplicitFile = (filePath) => fileKeys.has(normalizeFilePath(path40.resolve(filePath)));
|
|
22334
22734
|
const includeFile = (filePath) => {
|
|
22335
|
-
const key = normalizeFilePath(
|
|
22735
|
+
const key = normalizeFilePath(path40.resolve(filePath));
|
|
22336
22736
|
if (fileKeys.has(key))
|
|
22337
22737
|
return true;
|
|
22338
22738
|
return dirPrefixes.some((prefix) => isWithinForm(key, prefix));
|
|
@@ -22353,7 +22753,7 @@ function pathsScopeCacheOnlyNote(scope) {
|
|
|
22353
22753
|
function pathsScopeMissingNote(scope) {
|
|
22354
22754
|
if (!scope || scope.missing.length === 0)
|
|
22355
22755
|
return "";
|
|
22356
|
-
const shown2 = scope.missing.slice(0, 10).map((p) =>
|
|
22756
|
+
const shown2 = scope.missing.slice(0, 10).map((p) => path40.basename(p));
|
|
22357
22757
|
const more = scope.missing.length > shown2.length ? ` (+${scope.missing.length - shown2.length} more)` : "";
|
|
22358
22758
|
return `
|
|
22359
22759
|
|
|
@@ -22644,7 +23044,7 @@ function mergeDiagnosticsWithWidgetSummaries(widgetSummaries, lspResults, projec
|
|
|
22644
23044
|
byFile.set(fileKey, summarizeDiagnostics(existing?.filePath ?? filePath, diagnostics, existing?.hasFinalSnapshot ?? true, existing));
|
|
22645
23045
|
};
|
|
22646
23046
|
for (const summary of widgetSummaries) {
|
|
22647
|
-
const filePath =
|
|
23047
|
+
const filePath = path40.resolve(summary.filePath);
|
|
22648
23048
|
const fileKey = normalizeMapKey(summary.filePath);
|
|
22649
23049
|
if (authoritativeLspFiles?.has(fileKey))
|
|
22650
23050
|
continue;
|
|
@@ -22673,7 +23073,7 @@ function mergeDiagnosticsWithWidgetSummaries(widgetSummaries, lspResults, projec
|
|
|
22673
23073
|
}
|
|
22674
23074
|
}
|
|
22675
23075
|
for (const result of lspResults) {
|
|
22676
|
-
const filePath =
|
|
23076
|
+
const filePath = path40.resolve(result.filePath);
|
|
22677
23077
|
for (const diagnostic of result.diagnostics ?? []) {
|
|
22678
23078
|
addDiagnostic(filePath, {
|
|
22679
23079
|
...lspDiagnosticToWidget(diagnostic),
|
|
@@ -22693,12 +23093,12 @@ function mergeDiagnosticsWithWidgetSummaries(widgetSummaries, lspResults, projec
|
|
|
22693
23093
|
});
|
|
22694
23094
|
}
|
|
22695
23095
|
for (const diagnostic of projectSnapshot?.diagnostics ?? []) {
|
|
22696
|
-
addDiagnostic(
|
|
23096
|
+
addDiagnostic(path40.resolve(diagnostic.filePath), projectDiagnosticToWidget(diagnostic, diagnostic.filePath));
|
|
22697
23097
|
}
|
|
22698
23098
|
for (const diagnostic of deltaDiagnostics) {
|
|
22699
23099
|
const widget = projectDiagnosticToWidget(diagnostic, diagnostic.filePath);
|
|
22700
23100
|
const observedAt = widget.observedAt ?? deltaObservedAt;
|
|
22701
|
-
addDiagnostic(
|
|
23101
|
+
addDiagnostic(path40.resolve(diagnostic.filePath), {
|
|
22702
23102
|
...widget,
|
|
22703
23103
|
...observedAt !== void 0 && { observedAt }
|
|
22704
23104
|
});
|
|
@@ -22711,7 +23111,7 @@ async function applyInlineSuppressionsToSummaries(summaries, cwd, policyMap, dis
|
|
|
22711
23111
|
return summary;
|
|
22712
23112
|
let content;
|
|
22713
23113
|
try {
|
|
22714
|
-
content = await
|
|
23114
|
+
content = await fs24.readFile(summary.filePath, "utf8");
|
|
22715
23115
|
} catch {
|
|
22716
23116
|
const policyKept2 = applyRulePolicy(summary.diagnostics, policyMap, {
|
|
22717
23117
|
root: cwd,
|
|
@@ -22940,7 +23340,7 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
22940
23340
|
unreconciledFiles.add(fileKey);
|
|
22941
23341
|
recordDegradationOnce({
|
|
22942
23342
|
kind: "diagnostic-retained-unreconciled",
|
|
22943
|
-
subject: `${
|
|
23343
|
+
subject: `${path40.resolve(result2.filePath)}:lsp`,
|
|
22944
23344
|
reason: "confirmed diagnostic result could not replace retained widget state"
|
|
22945
23345
|
});
|
|
22946
23346
|
}
|
|
@@ -22948,7 +23348,7 @@ async function formatFullMode(cwd, severity, lspService, cacheManager2, options
|
|
|
22948
23348
|
unreconciledFiles.add(fileKey);
|
|
22949
23349
|
recordDegradationOnce({
|
|
22950
23350
|
kind: "diagnostic-retained-unreconciled",
|
|
22951
|
-
subject: `${
|
|
23351
|
+
subject: `${path40.resolve(result2.filePath)}:lsp`,
|
|
22952
23352
|
reason: "confirmed diagnostic result failed during widget reconciliation"
|
|
22953
23353
|
});
|
|
22954
23354
|
}
|
|
@@ -23144,7 +23544,7 @@ test-runner coverage is edit-scoped, NOT a full-project run: its findings only r
|
|
|
23144
23544
|
const failedNote = failedAnalyzers.length > 0 ? `
|
|
23145
23545
|
|
|
23146
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.` : "";
|
|
23147
|
-
const walkUnsafeRoot = explicitFiles === void 0 && isAtOrAboveHomeDir(realpathOrResolve(cwd), realpathOrResolve(
|
|
23547
|
+
const walkUnsafeRoot = explicitFiles === void 0 && isAtOrAboveHomeDir(realpathOrResolve(cwd), realpathOrResolve(os8.homedir()));
|
|
23148
23548
|
const walkUnsafeRootNote = walkUnsafeRoot ? `
|
|
23149
23549
|
|
|
23150
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.` : "";
|
|
@@ -23692,7 +24092,7 @@ ${JSON.stringify(view)}`
|
|
|
23692
24092
|
}
|
|
23693
24093
|
|
|
23694
24094
|
// dist/tools/module-report.js
|
|
23695
|
-
import * as
|
|
24095
|
+
import * as path41 from "node:path";
|
|
23696
24096
|
function resolveFile(filePath, cwd) {
|
|
23697
24097
|
return resolveHostToolPath(filePath, cwd || ".");
|
|
23698
24098
|
}
|
|
@@ -23710,10 +24110,9 @@ function createModuleReportTool(getProjectRoot) {
|
|
|
23710
24110
|
if (isError || details?.available === false) {
|
|
23711
24111
|
return `module_report ${base} \u2014 unavailable`;
|
|
23712
24112
|
}
|
|
23713
|
-
const parts = [
|
|
23714
|
-
|
|
23715
|
-
`${details
|
|
23716
|
-
];
|
|
24113
|
+
const parts = [`${details?.symbols ?? 0} symbols`];
|
|
24114
|
+
if (details?.exports !== void 0)
|
|
24115
|
+
parts.push(`${details.exports} exports`);
|
|
23717
24116
|
if (details?.callbacks)
|
|
23718
24117
|
parts.push(`${details.callbacks} callbacks`);
|
|
23719
24118
|
const view = details?.view && details.view !== "summary-text" ? ` [${details.view}]` : "";
|
|
@@ -23764,7 +24163,7 @@ function createModuleReportTool(getProjectRoot) {
|
|
|
23764
24163
|
content: [
|
|
23765
24164
|
{
|
|
23766
24165
|
type: "text",
|
|
23767
|
-
text: `Module report failed for ${
|
|
24166
|
+
text: `Module report failed for ${path41.basename(absFile)}: ${errorMessage2(err)}`
|
|
23768
24167
|
}
|
|
23769
24168
|
],
|
|
23770
24169
|
isError: true,
|
|
@@ -23852,7 +24251,7 @@ function createReadSymbolTool(getProjectRoot, recordSymbolRead) {
|
|
|
23852
24251
|
content: [
|
|
23853
24252
|
{
|
|
23854
24253
|
type: "text",
|
|
23855
|
-
text: `Read symbol failed for ${
|
|
24254
|
+
text: `Read symbol failed for ${path41.basename(absFile)}: ${errorMessage2(err)}`
|
|
23856
24255
|
}
|
|
23857
24256
|
],
|
|
23858
24257
|
isError: true,
|
|
@@ -23862,7 +24261,7 @@ function createReadSymbolTool(getProjectRoot, recordSymbolRead) {
|
|
|
23862
24261
|
if (!result.found) {
|
|
23863
24262
|
const warningSuffix = result.warnings?.length ? ` Warnings: ${result.warnings.join("; ")}` : "";
|
|
23864
24263
|
const suggestionSuffix = result.suggestions?.length ? ` Did you mean: ${result.suggestions.join(", ")}?` : " Use module_report to list available symbols.";
|
|
23865
|
-
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}`;
|
|
23866
24265
|
return {
|
|
23867
24266
|
content: [{ type: "text", text }],
|
|
23868
24267
|
isError: true,
|
|
@@ -23876,7 +24275,7 @@ function createReadSymbolTool(getProjectRoot, recordSymbolRead) {
|
|
|
23876
24275
|
}
|
|
23877
24276
|
const readRecorded = recordReadCoverage(recordSymbolRead, result, "read_symbol_guard_error", toolCallId, ctx);
|
|
23878
24277
|
const ambiguityNote = result.ambiguous ? ` (${result.ambiguous.count} matches \u2014 returned the ${result.kind}; pass \`kind\` to disambiguate: ${result.ambiguous.kinds.join(", ")})` : "";
|
|
23879
|
-
const header = `${result.kind} ${result.name}${ambiguityNote} ${
|
|
24278
|
+
const header = `${result.kind} ${result.name}${ambiguityNote} ${path41.basename(result.path)}:${result.startLine}-${result.endLine}`;
|
|
23880
24279
|
const guardWarning = readRecorded ? "" : "\n\nWarning: read coverage recording failed; the returned body may not satisfy the edit guard.";
|
|
23881
24280
|
return {
|
|
23882
24281
|
content: [
|
|
@@ -23952,7 +24351,7 @@ function createReadEnclosingTool(getProjectRoot, recordSymbolRead) {
|
|
|
23952
24351
|
content: [
|
|
23953
24352
|
{
|
|
23954
24353
|
type: "text",
|
|
23955
|
-
text: `Read enclosing failed for ${
|
|
24354
|
+
text: `Read enclosing failed for ${path41.basename(absFile)}:${params.line}: ${errorMessage2(err)}`
|
|
23956
24355
|
}
|
|
23957
24356
|
],
|
|
23958
24357
|
isError: true,
|
|
@@ -23965,7 +24364,7 @@ function createReadEnclosingTool(getProjectRoot, recordSymbolRead) {
|
|
|
23965
24364
|
|
|
23966
24365
|
Nested outline:
|
|
23967
24366
|
${JSON.stringify(result.outline)}` : "";
|
|
23968
|
-
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}`;
|
|
23969
24368
|
return {
|
|
23970
24369
|
content: [{ type: "text", text }],
|
|
23971
24370
|
isError: true,
|
|
@@ -23987,7 +24386,7 @@ ${JSON.stringify(result.outline)}` : "";
|
|
|
23987
24386
|
}
|
|
23988
24387
|
const readRecorded = recordReadCoverage(recordSymbolRead, result, "read_enclosing_guard_error", toolCallId, ctx);
|
|
23989
24388
|
const range = result.partial ? `${result.startLine}-${result.endLine} (partial of ${result.enclosingStartLine}-${result.enclosingEndLine})` : `${result.startLine}-${result.endLine}`;
|
|
23990
|
-
const header = `${result.kind} ${result.name} ${
|
|
24389
|
+
const header = `${result.kind} ${result.name} ${path41.basename(result.path)}:${range}`;
|
|
23991
24390
|
const guardWarning = readRecorded ? "" : "\n\nWarning: read coverage recording failed; the returned body may not satisfy the edit guard.";
|
|
23992
24391
|
return {
|
|
23993
24392
|
content: [
|
|
@@ -24122,7 +24521,7 @@ function createSymbolSearchTool(getProjectRoot) {
|
|
|
24122
24521
|
|
|
24123
24522
|
// dist/tools/lsp-navigation.js
|
|
24124
24523
|
import * as nodeFs4 from "node:fs";
|
|
24125
|
-
import * as
|
|
24524
|
+
import * as path42 from "node:path";
|
|
24126
24525
|
import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
24127
24526
|
|
|
24128
24527
|
// dist/tools/lsp-structured-output.js
|
|
@@ -24948,7 +25347,7 @@ function noServerAnsweredText(filePath) {
|
|
|
24948
25347
|
const { disabledServerIds, fallbackServerIds } = disabledPrimaries(filePath);
|
|
24949
25348
|
const cause = primaryUnavailableCause([...fallbackServerIds, ...disabledServerIds], disabledServerIds, fallbackServerIds);
|
|
24950
25349
|
const who = disabledServerIds.length > 0 ? `Primary LSP (${disabledServerIds.join(", ")}) did not answer` : "no language server answered";
|
|
24951
|
-
return `No LSP server available for ${
|
|
25350
|
+
return `No LSP server available for ${path42.basename(filePath)}: ${who} (${PRIMARY_UNAVAILABLE_CAUSE[cause]}).`;
|
|
24952
25351
|
}
|
|
24953
25352
|
function emptyReasonForOperation(operation) {
|
|
24954
25353
|
if (operation === "signatureHelp")
|
|
@@ -25297,7 +25696,7 @@ function collectSearchReadsForOperation(operation, result, callHierarchyItem) {
|
|
|
25297
25696
|
}
|
|
25298
25697
|
function formatCapabilities(snapshots, filePath) {
|
|
25299
25698
|
if (snapshots.length === 0) {
|
|
25300
|
-
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.";
|
|
25301
25700
|
}
|
|
25302
25701
|
const rows = [
|
|
25303
25702
|
["definition", (s) => !!s.operationSupport.definition],
|
|
@@ -25327,7 +25726,7 @@ function formatCapabilities(snapshots, filePath) {
|
|
|
25327
25726
|
];
|
|
25328
25727
|
const lines = [];
|
|
25329
25728
|
for (const snapshot of snapshots) {
|
|
25330
|
-
const label = filePath ? `${snapshot.serverId} (${
|
|
25729
|
+
const label = filePath ? `${snapshot.serverId} (${path42.basename(filePath)})` : `${snapshot.serverId} (${snapshot.root})`;
|
|
25331
25730
|
lines.push(label);
|
|
25332
25731
|
for (const [name, supported, note] of rows) {
|
|
25333
25732
|
const suffix = note ? ` (${note})` : "";
|
|
@@ -25469,14 +25868,7 @@ function createLspNavigationTool(getFlag, mutationDeps) {
|
|
|
25469
25868
|
let mutationContext;
|
|
25470
25869
|
let requestedApply = false;
|
|
25471
25870
|
const workspaceScopeAttribution = {};
|
|
25472
|
-
const finalize = (
|
|
25473
|
-
const payload = mutationContext?.acceptedFiles && mutationContext.acceptedFiles.length > 0 ? {
|
|
25474
|
-
...unreported,
|
|
25475
|
-
details: {
|
|
25476
|
-
...unreported.details,
|
|
25477
|
-
appliedFiles: [...mutationContext.acceptedFiles]
|
|
25478
|
-
}
|
|
25479
|
-
} : unreported;
|
|
25871
|
+
const finalize = (payload, meta) => {
|
|
25480
25872
|
if (payload.isError && requestedApply && mutationContext && ["rename", "rename_file", "executeCommand"].includes(meta.operation)) {
|
|
25481
25873
|
recordLspMutationOutcome(mutationContext, "failed");
|
|
25482
25874
|
}
|
|
@@ -25610,7 +26002,6 @@ function createLspNavigationTool(getFlag, mutationDeps) {
|
|
|
25610
26002
|
cwd,
|
|
25611
26003
|
sessionId: ctx.sessionManager?.getSessionId?.(),
|
|
25612
26004
|
correlationId: newLspMutationCorrelationId(_toolCallId),
|
|
25613
|
-
acceptedFiles: [],
|
|
25614
26005
|
// #4187 R4-1: the call whose `tool_call` licensed the paths it
|
|
25615
26006
|
// named; the workspace edit's other files (a rename's importers)
|
|
25616
26007
|
// are unlicensed, so they end an authorship instead of advancing it.
|
|
@@ -25695,7 +26086,7 @@ function createLspNavigationTool(getFlag, mutationDeps) {
|
|
|
25695
26086
|
content: [
|
|
25696
26087
|
{
|
|
25697
26088
|
type: "text",
|
|
25698
|
-
text: `No LSP server available for ${
|
|
26089
|
+
text: `No LSP server available for ${path42.basename(filePath)}: ${NO_SERVER_REASON}.`
|
|
25699
26090
|
}
|
|
25700
26091
|
],
|
|
25701
26092
|
isError: true
|
|
@@ -25785,7 +26176,7 @@ ${JSON.stringify(result3)}${timedOutNote}${unavailableNote}${suppressedNote}${wi
|
|
|
25785
26176
|
const pythonCompileTargets = new Map(compileVerdictTargets.map((entry) => [entry.trackedFile, entry.target]));
|
|
25786
26177
|
let snapshotSuppressed = 0;
|
|
25787
26178
|
const snapshotWithheldEntries = [];
|
|
25788
|
-
const result2 = Array.from(allDiagnostics.entries()).map(([trackedFile, { diags, ts }]) => {
|
|
26179
|
+
const result2 = Array.from(allDiagnostics.entries()).map(([trackedFile, { diags, ts, closed }]) => {
|
|
25789
26180
|
let kept = diags;
|
|
25790
26181
|
if (diags.length > 0) {
|
|
25791
26182
|
const policy = applyProbeFindingPolicy(trackedFile, diags, policyCwd, readFileContent(trackedFile), "all", "lsp_navigation", pythonCompileTargets.get(trackedFile));
|
|
@@ -25797,12 +26188,17 @@ ${JSON.stringify(result3)}${timedOutNote}${unavailableNote}${suppressedNote}${wi
|
|
|
25797
26188
|
filePath: trackedFile,
|
|
25798
26189
|
diagnostics: kept,
|
|
25799
26190
|
count: kept.length,
|
|
25800
|
-
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 }
|
|
25801
26195
|
};
|
|
25802
26196
|
});
|
|
25803
26197
|
const snapshotSuppressedLine = dispositionSuppressedLine(snapshotSuppressed);
|
|
25804
26198
|
const snapshotWithheld = mergeWithheld(snapshotWithheldEntries);
|
|
25805
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;
|
|
25806
26202
|
const noteMap2 = {
|
|
25807
26203
|
"push-only": "Note: push-only tracked diagnostics snapshot (not full workspace pull diagnostics).",
|
|
25808
26204
|
pull: "Note: tracked diagnostics snapshot from active clients. Provide path to force file-level diagnostics collection"
|
|
@@ -25815,7 +26211,8 @@ ${JSON.stringify(result3)}${timedOutNote}${unavailableNote}${suppressedNote}${wi
|
|
|
25815
26211
|
text: `${note}
|
|
25816
26212
|
${JSON.stringify(result2)}${snapshotSuppressedLine ? `
|
|
25817
26213
|
Note: ${snapshotSuppressedLine}` : ""}${snapshotWithheldLine ? `
|
|
25818
|
-
Note: ${snapshotWithheldLine}` : ""}`
|
|
26214
|
+
Note: ${snapshotWithheldLine}` : ""}${snapshotClosedLine ? `
|
|
26215
|
+
Note: ${snapshotClosedLine}` : ""}`
|
|
25819
26216
|
}
|
|
25820
26217
|
],
|
|
25821
26218
|
details: {
|
|
@@ -25860,7 +26257,7 @@ Note: ${snapshotWithheldLine}` : ""}`
|
|
|
25860
26257
|
content: [
|
|
25861
26258
|
{
|
|
25862
26259
|
type: "text",
|
|
25863
|
-
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}.`
|
|
25864
26261
|
}
|
|
25865
26262
|
],
|
|
25866
26263
|
isError: true
|
|
@@ -25880,7 +26277,7 @@ Note: ${snapshotWithheldLine}` : ""}`
|
|
|
25880
26277
|
content: [
|
|
25881
26278
|
{
|
|
25882
26279
|
type: "text",
|
|
25883
|
-
text: `LSP server for ${
|
|
26280
|
+
text: `LSP server for ${path42.basename(filePath)} does not advertise support for ${operation}`
|
|
25884
26281
|
}
|
|
25885
26282
|
],
|
|
25886
26283
|
isError: true,
|
|
@@ -25934,7 +26331,7 @@ Note: ${snapshotWithheldLine}` : ""}`
|
|
|
25934
26331
|
const msg = err instanceof Error ? err.message : String(err);
|
|
25935
26332
|
if (rawPath && /No Project/i.test(msg)) {
|
|
25936
26333
|
await openFileBestEffort(lspService, filePath);
|
|
25937
|
-
await new Promise((
|
|
26334
|
+
await new Promise((resolve32) => setTimeout(resolve32, 120));
|
|
25938
26335
|
const retryRaw = await lspService.workspaceSymbol(query ?? "", filePath);
|
|
25939
26336
|
const retrySymbols = (Array.isArray(retryRaw) ? retryRaw : [retryRaw]).filter((s) => typeof s === "object" && s !== null);
|
|
25940
26337
|
return dedupeWorkspaceSymbols(retrySymbols);
|
|
@@ -26189,7 +26586,7 @@ Note: ${snapshotWithheldLine}` : ""}`
|
|
|
26189
26586
|
isError: true
|
|
26190
26587
|
}, { operation, filePath, failureKind: "no_server", resultCount: 0 });
|
|
26191
26588
|
}
|
|
26192
|
-
const fileCtx = filePath ? " at " +
|
|
26589
|
+
const fileCtx = filePath ? " at " + path42.basename(filePath) : "";
|
|
26193
26590
|
const lineCtx = line ? ":" + line + ":" + character : "";
|
|
26194
26591
|
let output = isEmpty ? "No results for " + operation + fileCtx + lineCtx : JSON.stringify(result);
|
|
26195
26592
|
if (isEmpty && operation === "workspaceSymbol" && !rawPath) {
|
|
@@ -26379,10 +26776,10 @@ Not run: ${reasons.join("; ")}.`
|
|
|
26379
26776
|
}
|
|
26380
26777
|
|
|
26381
26778
|
// dist/mcp/build-staleness.js
|
|
26382
|
-
import * as
|
|
26779
|
+
import * as fs25 from "node:fs";
|
|
26383
26780
|
var realStat = (targetPath) => {
|
|
26384
26781
|
try {
|
|
26385
|
-
return
|
|
26782
|
+
return fs25.statSync(targetPath);
|
|
26386
26783
|
} catch {
|
|
26387
26784
|
return void 0;
|
|
26388
26785
|
}
|
|
@@ -26486,11 +26883,11 @@ function resolveDefaultCwd() {
|
|
|
26486
26883
|
const fromArg = process.argv.find((arg) => arg.startsWith("--cwd="))?.slice("--cwd=".length);
|
|
26487
26884
|
return fromArg ?? process.env.PI_LENS_MCP_CWD ?? process.cwd();
|
|
26488
26885
|
}
|
|
26489
|
-
var DEFAULT_CWD =
|
|
26886
|
+
var DEFAULT_CWD = path43.resolve(resolveDefaultCwd());
|
|
26490
26887
|
var lspReadyCwds = /* @__PURE__ */ new Set();
|
|
26491
26888
|
var SERVER_FILE = fileURLToPath3(import.meta.url);
|
|
26492
|
-
var SERVER_DIR =
|
|
26493
|
-
var WORKER_PATH =
|
|
26889
|
+
var SERVER_DIR = path43.dirname(SERVER_FILE);
|
|
26890
|
+
var WORKER_PATH = path43.join(SERVER_DIR, "worker.js");
|
|
26494
26891
|
var REBUILD_SCRIPT = resolveRebuildScript(SERVER_FILE);
|
|
26495
26892
|
var STALENESS_STAT_PATH = process.env.PI_LENS_MCP_STALENESS_STAT_PATH ?? SERVER_FILE;
|
|
26496
26893
|
var BUILD_STAMP = computeBuildStamp(STALENESS_STAT_PATH);
|
|
@@ -26511,21 +26908,21 @@ function isWarmBuildStale() {
|
|
|
26511
26908
|
}
|
|
26512
26909
|
function findRepoRoot(start) {
|
|
26513
26910
|
for (const dir of walkUpDirs(start, { maxDepth: 6 })) {
|
|
26514
|
-
const pkgPath =
|
|
26515
|
-
if (
|
|
26911
|
+
const pkgPath = path43.join(dir, "package.json");
|
|
26912
|
+
if (fs26.existsSync(pkgPath)) {
|
|
26516
26913
|
try {
|
|
26517
|
-
const pkg = JSON.parse(
|
|
26914
|
+
const pkg = JSON.parse(fs26.readFileSync(pkgPath, "utf8"));
|
|
26518
26915
|
if (pkg.name === "pi-lens")
|
|
26519
26916
|
return dir;
|
|
26520
26917
|
} catch {
|
|
26521
26918
|
}
|
|
26522
26919
|
}
|
|
26523
26920
|
}
|
|
26524
|
-
return
|
|
26921
|
+
return path43.resolve(start, "..", "..");
|
|
26525
26922
|
}
|
|
26526
|
-
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);
|
|
26527
26924
|
async function ensureReady(cwd) {
|
|
26528
|
-
const normalized =
|
|
26925
|
+
const normalized = path43.resolve(cwd);
|
|
26529
26926
|
if (!shouldInitializeSessionRoot(normalized, lspReadyCwds)) {
|
|
26530
26927
|
return;
|
|
26531
26928
|
}
|
|
@@ -26571,12 +26968,12 @@ function getAutoSessionStatus() {
|
|
|
26571
26968
|
}
|
|
26572
26969
|
var IPC_PATH = ipcPathForCwd(DEFAULT_CWD);
|
|
26573
26970
|
function rejectForeignTurnCwd(route, cwd) {
|
|
26574
|
-
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}`;
|
|
26575
26972
|
console.error(`[pi-lens-mcp] rejected ${message}`);
|
|
26576
26973
|
return message;
|
|
26577
26974
|
}
|
|
26578
26975
|
function isWithinServerWorkspace(cwd) {
|
|
26579
|
-
return isUnderDir(
|
|
26976
|
+
return isUnderDir(path43.resolve(cwd), DEFAULT_CWD);
|
|
26580
26977
|
}
|
|
26581
26978
|
function startIpcServer() {
|
|
26582
26979
|
const bound = boundUnixSocketPath(IPC_PATH);
|
|
@@ -26934,7 +27331,7 @@ function enabledToolsForCwd(cwd) {
|
|
|
26934
27331
|
function formatAnalyze(result, cwd, mode, servedBy) {
|
|
26935
27332
|
const lspNote = result.lsp ? ` \xB7 lsp ${result.lsp.diagnosticCount} (${result.lsp.status}${result.lsp.failureKind ? `: ${result.lsp.failureKind}` : ""}, ${result.lsp.durationMs}ms)` : "";
|
|
26936
27333
|
const notChecked = verdictUncheckedReason(result.verdict);
|
|
26937
|
-
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
|
|
26938
27335
|
// file, so the summary says so beside them.
|
|
26939
27336
|
// A worker reply from an older build carries no verdict (the facade casts
|
|
26940
27337
|
// it unvalidated), which the shared reader also treats as unchecked.
|
|
@@ -27075,7 +27472,7 @@ ${outcome.output}`, {
|
|
|
27075
27472
|
}
|
|
27076
27473
|
const { deduped, byRule, byFile } = summarizeScan(snapshot.diagnostics);
|
|
27077
27474
|
const topRules = Object.entries(byRule).sort((a, b) => b[1] - a[1]);
|
|
27078
|
-
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 }));
|
|
27079
27476
|
const summaryLines = [
|
|
27080
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)` : ""),
|
|
27081
27478
|
...topRules.slice(0, 12).map(([rule, count]) => ` ${count}\xD7 ${rule}`)
|
|
@@ -27211,7 +27608,7 @@ ${graphStaleness}` : rendered;
|
|
|
27211
27608
|
const result = await readSymbol(file, symbol, cwd, { kind });
|
|
27212
27609
|
if (!result.found && result.error) {
|
|
27213
27610
|
return {
|
|
27214
|
-
...renderToolText(`Could not inspect ${
|
|
27611
|
+
...renderToolText(`Could not inspect ${path43.basename(file)}: ${result.error}`, {
|
|
27215
27612
|
found: false,
|
|
27216
27613
|
error: result.error,
|
|
27217
27614
|
...result.warnings ? { warnings: result.warnings } : {}
|
|
@@ -27222,7 +27619,7 @@ ${graphStaleness}` : rendered;
|
|
|
27222
27619
|
if (!result.found) {
|
|
27223
27620
|
const suggestionSuffix = result.suggestions?.length ? ` Did you mean: ${result.suggestions.join(", ")}?` : " Use pilens_module_report to list symbols.";
|
|
27224
27621
|
return {
|
|
27225
|
-
...renderToolText(`Symbol "${symbol}" not found in ${
|
|
27622
|
+
...renderToolText(`Symbol "${symbol}" not found in ${path43.basename(file)}.${suggestionSuffix}`, {
|
|
27226
27623
|
found: false,
|
|
27227
27624
|
...result.suggestions ? { suggestions: result.suggestions } : {},
|
|
27228
27625
|
...result.warnings ? { warnings: result.warnings } : {}
|
|
@@ -27232,7 +27629,7 @@ ${graphStaleness}` : rendered;
|
|
|
27232
27629
|
}
|
|
27233
27630
|
const sigSuffix = result.signature ? ` ${result.signature}` : "";
|
|
27234
27631
|
const ambiguityNote = result.ambiguous ? ` (${result.ambiguous.count} matches \u2014 returned the ${result.kind}; pass \`kind\` to disambiguate: ${result.ambiguous.kinds.join(", ")})` : "";
|
|
27235
|
-
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}`;
|
|
27236
27633
|
return {
|
|
27237
27634
|
content: [
|
|
27238
27635
|
{
|
|
@@ -27273,14 +27670,14 @@ ${result.source ?? ""}`
|
|
|
27273
27670
|
|
|
27274
27671
|
Nested outline:
|
|
27275
27672
|
${JSON.stringify(result.outline)}` : "";
|
|
27276
|
-
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}`;
|
|
27277
27674
|
return {
|
|
27278
27675
|
...renderToolText(text, { found: false, line: result.line }),
|
|
27279
27676
|
isError: true
|
|
27280
27677
|
};
|
|
27281
27678
|
}
|
|
27282
27679
|
const range = result.partial ? `${result.startLine}-${result.endLine} (partial of ${result.enclosingStartLine}-${result.enclosingEndLine})` : `${result.startLine}-${result.endLine}`;
|
|
27283
|
-
const header = `${result.kind} ${result.name} ${
|
|
27680
|
+
const header = `${result.kind} ${result.name} ${path43.relative(cwd, result.path)}:${range}`;
|
|
27284
27681
|
return {
|
|
27285
27682
|
content: [
|
|
27286
27683
|
{
|
|
@@ -27315,7 +27712,7 @@ ${result.source ?? ""}`
|
|
|
27315
27712
|
]),
|
|
27316
27713
|
...renderLspBrokenStatusLines(brokenServers),
|
|
27317
27714
|
...renderDegradationLines(degradations),
|
|
27318
|
-
last ? `Last dispatch: ${
|
|
27715
|
+
last ? `Last dispatch: ${path43.basename(last.filePath)} \u2014 ${last.totalDurationMs}ms, ${last.totalDiagnostics} diagnostic(s)` : "Last dispatch: none yet",
|
|
27319
27716
|
`Diagnostics this session: ${stats.totalShown} shown \xB7 ${stats.totalAutoFixed} auto-fixed \xB7 ${stats.totalUnresolved} unresolved`,
|
|
27320
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)",
|
|
27321
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)",
|
|
@@ -27384,7 +27781,7 @@ ${result.source ?? ""}`
|
|
|
27384
27781
|
const limit = typeof args.limit === "number" && Number.isFinite(args.limit) ? Math.max(1, Math.floor(args.limit)) : 5;
|
|
27385
27782
|
const fileFilter = typeof args.file === "string" ? args.file : void 0;
|
|
27386
27783
|
const recent = recentLatency(limit, fileFilter);
|
|
27387
|
-
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");
|
|
27388
27785
|
return renderToolText(summary, recent);
|
|
27389
27786
|
}
|
|
27390
27787
|
if (name === "pilens_session_start") {
|
|
@@ -27577,4 +27974,5 @@ process.stdin.on("end", () => {
|
|
|
27577
27974
|
void flushExtensionLog().finally(() => process.exit(0));
|
|
27578
27975
|
});
|
|
27579
27976
|
startIpcServer();
|
|
27977
|
+
void sweepOrphans();
|
|
27580
27978
|
console.error(`[pi-lens-mcp] ready (cwd=${DEFAULT_CWD})`);
|