pi-lens 4.4.3 → 4.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +721 -0
- package/README.md +25 -3
- package/config/dependency-cruiser-eager-allowlist.json +1 -0
- package/dist/chunk-22Y2BM7H.js +23 -0
- package/dist/{chunk-WU567RSC.js → chunk-27VWVB23.js} +16 -14
- package/dist/{chunk-FLKWCIZH.js → chunk-2FYKETQJ.js} +10 -6
- package/dist/{chunk-MQLUAEOC.js → chunk-2LDMXL2M.js} +2 -2
- package/dist/{chunk-YSZNHOBY.js → chunk-2SDHYHHO.js} +17 -17
- package/dist/chunk-2Y6OJRSI.js +38 -0
- package/dist/chunk-3SNDVPOR.js +507 -0
- package/dist/{chunk-EJIUXPBX.js → chunk-3WCEHYOI.js} +1 -1
- package/dist/chunk-44X7VIKR.js +73 -0
- package/dist/{chunk-Q7DUK4LX.js → chunk-4FHUGDKU.js} +16 -14
- package/dist/{chunk-H6MF6EVN.js → chunk-4ODSZ35Z.js} +1498 -534
- package/dist/{chunk-ZGDGW2V3.js → chunk-4U7GDSZQ.js} +2 -2
- package/dist/chunk-54NIOJJZ.js +25 -0
- package/dist/{chunk-ZWFS3OEF.js → chunk-5DKE4HGX.js} +38 -37
- package/dist/{chunk-VRZP76YM.js → chunk-5LRUKYFA.js} +34 -4
- package/dist/{chunk-QOBUHWHX.js → chunk-63NMUNYP.js} +12 -16
- package/dist/{chunk-VWCXW2E7.js → chunk-6XSESGWD.js} +13 -6
- package/dist/{chunk-QGQ5CCCG.js → chunk-72J27ICO.js} +2 -3
- package/dist/{chunk-CSHFH5IN.js → chunk-7FLRUH6B.js} +1 -1
- package/dist/chunk-7IYC4ENJ.js +297 -0
- package/dist/chunk-7WWQAW5P.js +30 -0
- package/dist/{chunk-EU63SDCG.js → chunk-7ZS7MC24.js} +885 -451
- package/dist/{chunk-KBG47GHP.js → chunk-AHWA4AKM.js} +18 -12
- package/dist/{chunk-FMSO6RDZ.js → chunk-AI3GP74G.js} +17 -19
- package/dist/chunk-APFJKOP6.js +67 -0
- package/dist/{chunk-RXCOMYPY.js → chunk-ASRAO7KG.js} +31 -33
- package/dist/{chunk-BW5KFIQC.js → chunk-AWQWXSW4.js} +1 -0
- package/dist/{chunk-QILIYSJF.js → chunk-CG5V25HX.js} +1 -1
- package/dist/chunk-CKEQFGLT.js +32 -0
- package/dist/{chunk-RPLINGVB.js → chunk-COOUUC5W.js} +6 -6
- package/dist/{chunk-GBPP5P7X.js → chunk-CPZ5JJW6.js} +4 -4
- package/dist/{chunk-OCAGUNBC.js → chunk-DS2USX5G.js} +13 -15
- package/dist/chunk-EA2ZRG44.js +27 -0
- package/dist/{chunk-ZHFZWTZV.js → chunk-EDMLIW6W.js} +13 -14
- package/dist/{chunk-2EECBNC5.js → chunk-EIKRZ32J.js} +75 -0
- package/dist/chunk-EKNWOL2I.js +27 -0
- package/dist/{chunk-CMMHNUZ2.js → chunk-ELZRSR5N.js} +65 -43
- package/dist/{chunk-BKE7E7TC.js → chunk-EN5AM7PX.js} +11 -12
- package/dist/{chunk-N2H3ZPZY.js → chunk-EWXXLS26.js} +227 -24
- package/dist/chunk-EX4EXBW7.js +37 -0
- package/dist/{chunk-YYOIQFRS.js → chunk-EXVXBSGN.js} +130 -52
- package/dist/{chunk-6GFRNVYR.js → chunk-F7BO6FWH.js} +12 -13
- package/dist/chunk-FEDWAYDS.js +2485 -0
- package/dist/{chunk-JAU72XNY.js → chunk-FWZRGGGY.js} +73 -9
- package/dist/{chunk-GXW6K4YJ.js → chunk-G224FADB.js} +1 -1
- package/dist/chunk-G5UCJFT7.js +26 -0
- package/dist/{chunk-67WMNWEE.js → chunk-GLW3YDZZ.js} +22 -13
- package/dist/{chunk-724UL2TJ.js → chunk-GTDSYEA2.js} +72 -39
- package/dist/{chunk-PHDMFAKM.js → chunk-GYRZ72R4.js} +10 -4
- package/dist/chunk-HYVXA3BB.js +49 -0
- package/dist/{chunk-SAEFPSB6.js → chunk-IEBJF3PN.js} +23 -15
- package/dist/chunk-IJYGIDF4.js +186 -0
- package/dist/{chunk-ACXEQZOU.js → chunk-IL7K66ZQ.js} +101 -109
- package/dist/{chunk-ZXYDQ3TZ.js → chunk-JWOVP5BL.js} +50 -19
- package/dist/{chunk-OXXKQCSV.js → chunk-K2GUZ4DN.js} +4 -4
- package/dist/{chunk-AW7R2GWG.js → chunk-K4SZB56V.js} +39 -39
- package/dist/{chunk-WOA4LN2R.js → chunk-KCBRHV5E.js} +3 -3
- package/dist/{chunk-3W7IEVVL.js → chunk-KFXCL4OV.js} +47 -45
- package/dist/{chunk-2BBLFX75.js → chunk-KJJAVH3X.js} +81 -15
- package/dist/{chunk-VCHXCQFG.js → chunk-KPVLQHCZ.js} +4 -6
- package/dist/{chunk-P7266HLM.js → chunk-KX56K73G.js} +10 -13
- package/dist/{chunk-VSSBEUFT.js → chunk-LMCTHJ2H.js} +19 -19
- package/dist/{chunk-IBGIOBEE.js → chunk-MEFLGBCS.js} +69 -8
- package/dist/{chunk-TYM6OUIT.js → chunk-MKPCELNI.js} +17 -17
- package/dist/{chunk-XTMJ7XDT.js → chunk-N3PLNNCW.js} +1 -1
- package/dist/chunk-N5FBM25N.js +22 -0
- package/dist/{chunk-CHOW74WE.js → chunk-NFNVDDGB.js} +7 -12
- package/dist/{chunk-52FUZI6K.js → chunk-NLIVE7L6.js} +2 -30
- package/dist/{chunk-SS36ZX4J.js → chunk-OMJ3OFBJ.js} +6 -6
- package/dist/{chunk-4W4VLAPJ.js → chunk-OZNCKLOX.js} +13 -14
- package/dist/chunk-P5XUGPIX.js +31 -0
- package/dist/{chunk-5UCAH366.js → chunk-PJXNTPB2.js} +253 -33
- package/dist/chunk-PKOXJIVT.js +88 -0
- package/dist/{chunk-6C7JWPCP.js → chunk-PP2A5V2T.js} +27 -26
- package/dist/{chunk-L3BLXZG7.js → chunk-Q42LJANT.js} +31 -70
- package/dist/{chunk-AB3YYG6N.js → chunk-Q4BKKOVC.js} +8 -8
- package/dist/{chunk-3EFKIGZN.js → chunk-QT66NEYN.js} +4 -4
- package/dist/{chunk-3VPVG5SU.js → chunk-RCHO5W7M.js} +19 -18
- package/dist/{chunk-77M37OKR.js → chunk-RG3MXTRI.js} +7 -7
- package/dist/chunk-RG7OODGM.js +57 -0
- package/dist/{chunk-T6CPIZNT.js → chunk-RU34BA4D.js} +44 -39
- package/dist/{chunk-JMYYOTQG.js → chunk-S26LC76R.js} +13 -1
- package/dist/{chunk-5NGR67U5.js → chunk-S55TEC7I.js} +33 -5
- package/dist/{chunk-M6HSLBWY.js → chunk-SJHC3BCZ.js} +7956 -8047
- package/dist/{chunk-XCJN5IJU.js → chunk-SNEUMLM7.js} +4 -4
- package/dist/{chunk-UZ3TUTRV.js → chunk-T4NGVFYI.js} +2 -2
- package/dist/{chunk-2VUQMUMT.js → chunk-THEXI2QO.js} +49 -43
- package/dist/{chunk-R3PCY3YS.js → chunk-TL2TCJYL.js} +15 -16
- package/dist/{chunk-C34ZXZ7O.js → chunk-TPYYEDP5.js} +838 -352
- package/dist/{chunk-AOHZU2BM.js → chunk-TVZRLTG6.js} +8 -1
- package/dist/{chunk-XMSXXAHW.js → chunk-UCVMSOXF.js} +2 -2
- package/dist/chunk-UL5SXQVX.js +32 -0
- package/dist/{chunk-GAEGEPOC.js → chunk-UO66IMVP.js} +2 -2
- package/dist/{chunk-N3X6Q4YT.js → chunk-UVY4TOJH.js} +3 -3
- package/dist/{chunk-2CD5RS6M.js → chunk-VIDEKABZ.js} +23 -2
- package/dist/{chunk-JSQFTSC6.js → chunk-VITFDI3O.js} +13 -14
- package/dist/{chunk-YIUAVF7E.js → chunk-VUAVE3QC.js} +42 -42
- package/dist/{chunk-QOZXJ4NA.js → chunk-WUY4BZEP.js} +21 -20
- package/dist/{chunk-VCO24T4L.js → chunk-X3UTCXAA.js} +43 -53
- package/dist/chunk-XHDBJODR.js +45 -0
- package/dist/{chunk-MXGY6KPT.js → chunk-XHLK33VM.js} +28 -21
- package/dist/{chunk-RWWYJ623.js → chunk-XI34NWDI.js} +2 -2
- package/dist/{chunk-QQNQ7SJW.js → chunk-XWFIHYCH.js} +12 -4
- package/dist/{chunk-6SDEP3AJ.js → chunk-Y2TPADJR.js} +10 -11
- package/dist/{chunk-MRXKYPCS.js → chunk-Y5KTA2OB.js} +17 -17
- package/dist/{chunk-7DYBLXYA.js → chunk-YKVDBNPO.js} +11 -5
- package/dist/{chunk-2B73ZPOK.js → chunk-YSDPVDFC.js} +3 -3
- package/dist/chunk-YWNO5Q4R.js +44 -0
- package/dist/{chunk-QHJ6DQ2R.js → chunk-YWWG4AQA.js} +165 -32
- package/dist/{chunk-3JNKMP3B.js → chunk-YXDCRUKQ.js} +4 -4
- package/dist/{chunk-UXGETRP4.js → chunk-YXGRRORB.js} +16 -17
- package/dist/{chunk-SQ4TVJBR.js → chunk-ZAPSUBLU.js} +13 -7
- package/dist/{chunk-76MWC2K6.js → chunk-ZPJM7DID.js} +90 -97
- package/dist/{chunk-XVF2VVXP.js → chunk-ZSUX7KEM.js} +16 -15
- package/dist/index.js +31038 -20893
- package/dist/mcp/analyze-cli.js +11 -11
- package/dist/mcp/cli.js +47 -43
- package/dist/mcp/server.js +2188 -906
- package/dist/mcp/worker.js +66 -63
- package/dist/probes/installer.js +21 -23
- package/dist/workers/project-snapshot-persist-worker.js +28 -9
- package/dist/workers/review-graph-persist-worker.js +1 -1
- package/docs/adr/0010-trace-validation-session-lifecycle.md +390 -0
- package/docs/adr/README.md +1 -0
- package/docs/ast-grep_rules_catalog.md +5 -3
- package/docs/configuration.md +20 -0
- package/docs/engineering-principles.md +44 -0
- package/docs/environment-variables.md +20 -0
- package/docs/features.md +16 -1
- package/docs/globalconfig.md +37 -8
- package/docs/lsp-capability-matrix.md +105 -12
- package/docs/lsp-idle-eviction.md +44 -36
- package/docs/pi-lens-fixer.md +139 -14
- package/docs/pi-lens-investigator.md +14 -0
- package/docs/pi-lens-merge-policy.md +120 -17
- package/docs/pi-lens-monitor.md +71 -9
- package/docs/pi-lens-retro.md +6 -3
- package/docs/pi-lens-reviewer.md +160 -5
- package/docs/pi-lens-subagent.md +29 -14
- package/docs/release-qa-baseline.md +21 -7
- package/docs/servercapabilities.md +53 -63
- package/docs/settings.md +9 -5
- package/docs/subagent-compat.md +1 -1
- package/docs/usage.md +1 -0
- package/package.json +9 -5
- package/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +17 -0
- package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-js-test.yml +86 -0
- package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-test.yml +86 -0
- package/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +15 -0
- package/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +9 -4
- package/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +119 -0
- package/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +119 -0
- package/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +13 -2
- package/rules/rule-catalog.json +25 -1
- package/scripts/analyze-pi-lens-logs.mjs +15 -5
- package/scripts/download-grammars.js +40 -7
- package/scripts/lib/is-main-module.mjs +27 -0
- package/scripts/lib/latency-log-phases.mjs +95 -0
- package/scripts/lib/scratch-home-env.mjs +21 -0
- package/scripts/rpc-load-check.mjs +568 -81
- package/scripts/warm-loader-cache.mjs +2 -5
- package/dist/chunk-23WOO7TX.js +0 -23
- package/dist/chunk-3YN6V5TV.js +0 -85
- package/dist/chunk-466Z26MG.js +0 -30
- package/dist/chunk-4UNXBNE2.js +0 -24
- package/dist/chunk-6STA6Z7I.js +0 -47
- package/dist/chunk-ABBOA7UD.js +0 -157
- package/dist/chunk-BRGDSBJE.js +0 -28
- package/dist/chunk-EC47DWFA.js +0 -56
- package/dist/chunk-FCSOVF55.js +0 -273
- package/dist/chunk-IZSHAIJ7.js +0 -26
- package/dist/chunk-KDERNTCQ.js +0 -28
- package/dist/chunk-KSX3TXSZ.js +0 -69
- package/dist/chunk-LOP6GRPH.js +0 -31
- package/dist/chunk-PNQDPDRC.js +0 -184
- package/dist/chunk-UOPVJQ4N.js +0 -103
- package/dist/chunk-XAGLWMJ4.js +0 -51
- package/dist/chunk-XIJZVPD5.js +0 -39
- package/dist/chunk-Z3CCVDUB.js +0 -76
- package/dist/chunk-Z527N6YQ.js +0 -28
- package/dist/chunk-ZANLILYD.js +0 -79
- /package/dist/{chunk-FC4RP4I2.js → chunk-6HWVI6MI.js} +0 -0
|
@@ -3,32 +3,35 @@ import {
|
|
|
3
3
|
resolveWebTreeSitterPackageDir
|
|
4
4
|
} from "./chunk-Z54ZSOBZ.js";
|
|
5
5
|
import {
|
|
6
|
-
EXTENSION_TO_GRAMMAR,
|
|
7
6
|
getUserRuleRoot,
|
|
8
7
|
ruleCorpusFingerprintForCycle
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-2Y6OJRSI.js";
|
|
10
9
|
import {
|
|
11
10
|
getPackageRoot,
|
|
12
11
|
js_yaml_default,
|
|
13
12
|
resolvePackagePath
|
|
14
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-WUY4BZEP.js";
|
|
14
|
+
import {
|
|
15
|
+
EXTENSION_TO_GRAMMAR
|
|
16
|
+
} from "./chunk-GTDSYEA2.js";
|
|
17
|
+
import {
|
|
18
|
+
withTimeout
|
|
19
|
+
} from "./chunk-NLIVE7L6.js";
|
|
15
20
|
import {
|
|
16
21
|
transientRetryDelayMs
|
|
17
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-5LRUKYFA.js";
|
|
18
23
|
import {
|
|
19
24
|
getProjectIgnoreMatcher,
|
|
20
25
|
isExcludedDirName
|
|
21
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-TPYYEDP5.js";
|
|
22
27
|
import {
|
|
23
28
|
notifyUserDegradation
|
|
24
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-KJJAVH3X.js";
|
|
25
30
|
import {
|
|
26
31
|
assertInstallAllowed,
|
|
27
|
-
getProjectTrustGeneration
|
|
28
|
-
} from "./chunk-ZANLILYD.js";
|
|
29
|
-
import {
|
|
32
|
+
getProjectTrustGeneration,
|
|
30
33
|
writeFileAtomic
|
|
31
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-EIKRZ32J.js";
|
|
32
35
|
import {
|
|
33
36
|
compareOrdinal,
|
|
34
37
|
escapeRegExp,
|
|
@@ -36,20 +39,21 @@ import {
|
|
|
36
39
|
incrementDegradationCount,
|
|
37
40
|
recordDegradation,
|
|
38
41
|
recordDegradationOnce
|
|
39
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-FWZRGGGY.js";
|
|
43
|
+
import {
|
|
44
|
+
logLatency
|
|
45
|
+
} from "./chunk-XWFIHYCH.js";
|
|
40
46
|
import {
|
|
41
47
|
createNdjsonLogger,
|
|
42
48
|
getGlobalPiLensLogDir,
|
|
43
49
|
getMaxLogSizeMB,
|
|
44
50
|
isTestMode
|
|
45
|
-
} from "./chunk-
|
|
46
|
-
import {
|
|
47
|
-
BoundedFifoMap
|
|
48
|
-
} from "./chunk-ABBOA7UD.js";
|
|
51
|
+
} from "./chunk-TVZRLTG6.js";
|
|
49
52
|
import {
|
|
53
|
+
BoundedFifoMap,
|
|
50
54
|
normalizeFilePath,
|
|
51
55
|
normalizeLoggedPath
|
|
52
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-EWXXLS26.js";
|
|
53
57
|
|
|
54
58
|
// dist/clients/tree-sitter-logger.js
|
|
55
59
|
import * as path from "node:path";
|
|
@@ -319,17 +323,18 @@ function shortHash(hash) {
|
|
|
319
323
|
const hex = hash.startsWith("sha256:") ? hash.slice("sha256:".length) : hash;
|
|
320
324
|
return `sha256:${hex.slice(0, 12)}\u2026`;
|
|
321
325
|
}
|
|
322
|
-
async function downloadGrammarDetailed(destDir, filename) {
|
|
326
|
+
async function downloadGrammarDetailed(destDir, filename, options = {}) {
|
|
323
327
|
if (isVendoredGrammar(filename))
|
|
324
328
|
return vendoredGrammarRefusal(filename);
|
|
329
|
+
const stall = options.stallMs === void 0 ? void 0 : armStallBound(options.stallMs);
|
|
325
330
|
try {
|
|
326
331
|
fs.mkdirSync(destDir, { recursive: true });
|
|
327
|
-
const res = await fetch(grammarSourceUrl(filename));
|
|
332
|
+
const res = await fetch(grammarSourceUrl(filename), stall ? { signal: stall.signal } : void 0);
|
|
328
333
|
if (!res.ok) {
|
|
329
334
|
const retryable = res.status !== 404 && res.status !== 410;
|
|
330
335
|
return { ok: false, retryable };
|
|
331
336
|
}
|
|
332
|
-
const data =
|
|
337
|
+
const data = await readResponseBody(res, stall);
|
|
333
338
|
if (!hasWasmMagic(data)) {
|
|
334
339
|
return { ok: false, retryable: true, reason: describeNonWasmBody(data) };
|
|
335
340
|
}
|
|
@@ -358,7 +363,43 @@ async function downloadGrammarDetailed(destDir, filename) {
|
|
|
358
363
|
writeFileAtomic(path2.join(destDir, filename), data, { bestEffort: false });
|
|
359
364
|
return { ok: true, retryable: true };
|
|
360
365
|
} catch {
|
|
366
|
+
if (stall?.signal.aborted) {
|
|
367
|
+
return {
|
|
368
|
+
ok: false,
|
|
369
|
+
retryable: true,
|
|
370
|
+
reason: `No bytes arrived for ${options.stallMs} ms \u2014 a stalled transfer.`
|
|
371
|
+
};
|
|
372
|
+
}
|
|
361
373
|
return { ok: false, retryable: true };
|
|
374
|
+
} finally {
|
|
375
|
+
stall?.dispose();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
var GRAMMAR_STALL_MS = 15e3;
|
|
379
|
+
var GRAMMAR_LOAD_TIMEOUT_MS = 3e4;
|
|
380
|
+
function armStallBound(ms) {
|
|
381
|
+
const controller = new AbortController();
|
|
382
|
+
const timer = setTimeout(() => controller.abort(), ms);
|
|
383
|
+
timer.unref();
|
|
384
|
+
return {
|
|
385
|
+
signal: controller.signal,
|
|
386
|
+
touch: () => {
|
|
387
|
+
timer.refresh();
|
|
388
|
+
},
|
|
389
|
+
dispose: () => clearTimeout(timer)
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
async function readResponseBody(res, stall) {
|
|
393
|
+
if (!stall || !res.body)
|
|
394
|
+
return Buffer.from(await res.arrayBuffer());
|
|
395
|
+
const reader = res.body.getReader();
|
|
396
|
+
const chunks = [];
|
|
397
|
+
for (; ; ) {
|
|
398
|
+
const { done, value } = await reader.read();
|
|
399
|
+
if (done)
|
|
400
|
+
return Buffer.concat(chunks);
|
|
401
|
+
stall.touch();
|
|
402
|
+
chunks.push(value);
|
|
362
403
|
}
|
|
363
404
|
}
|
|
364
405
|
|
|
@@ -1484,7 +1525,18 @@ function getBundledQueriesRootHealth() {
|
|
|
1484
1525
|
const generation = getDegradationLedgerGeneration();
|
|
1485
1526
|
if (cachedBundledQueriesRootHealth === void 0 || cachedBundledQueriesRootHealthGeneration !== generation) {
|
|
1486
1527
|
cachedBundledQueriesRootHealthGeneration = generation;
|
|
1487
|
-
|
|
1528
|
+
const health = classifyBundledResourceDir(BUNDLED_QUERIES_ROOT);
|
|
1529
|
+
cachedBundledQueriesRootHealth = health;
|
|
1530
|
+
logLatency({
|
|
1531
|
+
type: "phase",
|
|
1532
|
+
phase: "tree_sitter_queries_root_checked",
|
|
1533
|
+
filePath: BUNDLED_QUERIES_ROOT,
|
|
1534
|
+
durationMs: 0,
|
|
1535
|
+
metadata: {
|
|
1536
|
+
status: health.status,
|
|
1537
|
+
entryCount: health.status === "healthy" ? health.entryCount : 0
|
|
1538
|
+
}
|
|
1539
|
+
});
|
|
1488
1540
|
}
|
|
1489
1541
|
return cachedBundledQueriesRootHealth;
|
|
1490
1542
|
}
|
|
@@ -1981,6 +2033,9 @@ function createParserCounters() {
|
|
|
1981
2033
|
parserFailures: 0
|
|
1982
2034
|
};
|
|
1983
2035
|
}
|
|
2036
|
+
function isGrammarLoadTimeout(err) {
|
|
2037
|
+
return err instanceof Error && err.message === `Timeout after ${GRAMMAR_LOAD_TIMEOUT_MS}ms`;
|
|
2038
|
+
}
|
|
1984
2039
|
function grammarWriteBlockedReason(dir) {
|
|
1985
2040
|
let probe = dir;
|
|
1986
2041
|
while (!fs5.existsSync(probe)) {
|
|
@@ -2110,6 +2165,8 @@ var TreeSitterClient = class _TreeSitterClient {
|
|
|
2110
2165
|
* (the `transientRetryDelayMs` shape from availability-policy.ts) instead
|
|
2111
2166
|
* of latching for the process lifetime. */
|
|
2112
2167
|
grammarRetryAtMs = /* @__PURE__ */ new Map();
|
|
2168
|
+
/** Instance field so a test can shorten it without waiting out the real bound. */
|
|
2169
|
+
grammarStallMs = GRAMMAR_STALL_MS;
|
|
2113
2170
|
/**
|
|
2114
2171
|
* Grammar path → the `size:mtimeMs` stamp at which its wasm preamble was
|
|
2115
2172
|
* verified (#1548). A POSITIVE-only memo, so the steady-state resolve costs
|
|
@@ -2634,6 +2691,10 @@ var TreeSitterClient = class _TreeSitterClient {
|
|
|
2634
2691
|
* `vendor/grammars` comes first because it is the ONLY source for a grammar
|
|
2635
2692
|
* we build ourselves (`VENDORED_GRAMMARS`) — nothing downloads into the
|
|
2636
2693
|
* later dirs for it, so a miss here is a miss everywhere.
|
|
2694
|
+
*
|
|
2695
|
+
* Public so the Vitest grammar prefetch (`tests/support/prewarm-grammars.ts`)
|
|
2696
|
+
* counts a grammar as present exactly where this resolver would find it
|
|
2697
|
+
* (#4342), instead of keeping its own copy of the list.
|
|
2637
2698
|
*/
|
|
2638
2699
|
grammarSourceDirs() {
|
|
2639
2700
|
const dirs = [];
|
|
@@ -2944,7 +3005,7 @@ var TreeSitterClient = class _TreeSitterClient {
|
|
|
2944
3005
|
);
|
|
2945
3006
|
return false;
|
|
2946
3007
|
}
|
|
2947
|
-
const { ok, retryable, reason } = await downloadGrammarDetailed(dir, grammarFile);
|
|
3008
|
+
const { ok, retryable, reason } = await downloadGrammarDetailed(dir, grammarFile, { stallMs: this.grammarStallMs });
|
|
2948
3009
|
if (ok) {
|
|
2949
3010
|
if (!this.grammarsDir)
|
|
2950
3011
|
this.grammarsDir = dir;
|
|
@@ -2981,7 +3042,7 @@ var TreeSitterClient = class _TreeSitterClient {
|
|
|
2981
3042
|
this.grammarFailureAttempts.set(grammarFile, attempts);
|
|
2982
3043
|
const retryDelayMs = retryable ? transientRetryDelayMs(attempts, "probe-timeout") : void 0;
|
|
2983
3044
|
this.grammarRetryAtMs.set(grammarFile, retryDelayMs === void 0 ? Number.POSITIVE_INFINITY : Date.now() + retryDelayMs);
|
|
2984
|
-
const remedy = cause === "write-dir-unresolvable" ? `This is a packaging/module-resolution fault, not a download problem: reinstall pi-lens so its web-tree-sitter dependency is present, or drop the wasm into pi-lens's own grammars/ directory.` : cause === "write-dir-unwritable" ? `This is a filesystem-permission fault, not a download problem: make that directory writable for the user pi-lens runs as, or reinstall pi-lens as that user.` : retryable ? `if the problem persists, allow the package manager's build scripts (pnpm approve-builds / bun trustedDependencies) or restore network access.` : `Fix: reinstall with a manager that runs postinstall, allow its build scripts (pnpm approve-builds / bun trustedDependencies), or restore network access.`;
|
|
3045
|
+
const remedy = cause === "write-dir-unresolvable" ? `This is a packaging/module-resolution fault, not a download problem: reinstall pi-lens so its web-tree-sitter dependency is present, or drop the wasm into pi-lens's own grammars/ directory.` : cause === "write-dir-unwritable" ? `This is a filesystem-permission fault, not a download problem: make that directory writable for the user pi-lens runs as, or reinstall pi-lens as that user.` : cause === "load-timed-out" ? `This is a local hang while loading the grammar, not a download problem: if it keeps timing out, restart pi and attach the tree-sitter log to a bug report.` : retryable ? `if the problem persists, allow the package manager's build scripts (pnpm approve-builds / bun trustedDependencies) or restore network access.` : `Fix: reinstall with a manager that runs postinstall, allow its build scripts (pnpm approve-builds / bun trustedDependencies), or restore network access.`;
|
|
2985
3046
|
const unavailable = `tree-sitter grammar '${grammarFile}' is unavailable \u2014 symbol search, module reports and structural rules for this language will be degraded. ${detail} ` + (retryable ? `pi-lens will retry automatically in ${Math.round(retryDelayMs / 1e3)}s; ` : `The grammar source reports it does not exist (not a network problem), so this will not resolve on retry. `) + remedy;
|
|
2986
3047
|
logTreeSitterDiagnostic({
|
|
2987
3048
|
subsystem: "tree-sitter-client",
|
|
@@ -3007,7 +3068,8 @@ var TreeSitterClient = class _TreeSitterClient {
|
|
|
3007
3068
|
// failures used to share one string, so the ledger could not tell an
|
|
3008
3069
|
// offline laptop from a captive portal serving HTML — the two need
|
|
3009
3070
|
// different user actions, and the ledger is what a bug report shows.
|
|
3010
|
-
|
|
3071
|
+
// A hung load of a file already on disk is not a download failure (#4224).
|
|
3072
|
+
reason: cause === "load-timed-out" ? `grammar load timed out \u2014 retryable (${detail.trim()})` : retryable ? `runtime grammar download failed \u2014 retryable (${detail.trim()})` : `runtime grammar download failed \u2014 durable (${detail.trim()})`
|
|
3011
3073
|
});
|
|
3012
3074
|
this.refreshGrammarSessionLatches();
|
|
3013
3075
|
const notifyKey = retryDelayMs ?? -1;
|
|
@@ -3045,7 +3107,7 @@ var TreeSitterClient = class _TreeSitterClient {
|
|
|
3045
3107
|
* redownload land the identical bytes and spin the ladder against a file
|
|
3046
3108
|
* that can never pass.
|
|
3047
3109
|
*/
|
|
3048
|
-
recordGrammarLoadFailure(grammarPath, grammarFile, err) {
|
|
3110
|
+
recordGrammarLoadFailure(grammarPath, grammarFile, err, cause) {
|
|
3049
3111
|
const stamp = grammarFileStamp(grammarPath);
|
|
3050
3112
|
this.verifiedGrammarPaths.delete(grammarPath);
|
|
3051
3113
|
if (stamp)
|
|
@@ -3054,16 +3116,73 @@ var TreeSitterClient = class _TreeSitterClient {
|
|
|
3054
3116
|
logTreeSitterDiagnostic({
|
|
3055
3117
|
subsystem: "tree-sitter-client",
|
|
3056
3118
|
level: "warn",
|
|
3057
|
-
message: `Language.load failed for ${grammarPath} even though the wasm preamble check passed (${message}) \u2014 most likely a truncated download (#1564). Treating the grammar as missing so the next demand re-fetches it.`,
|
|
3119
|
+
message: cause === "load-timed-out" ? `Language.load did not settle for ${grammarPath} (${message}) \u2014 a hang in the local load of a file that passed the wasm preamble check, with no sign of a truncated download. Treating the grammar as missing so the next demand re-fetches it.` : `Language.load failed for ${grammarPath} even though the wasm preamble check passed (${message}) \u2014 most likely a truncated download (#1564). Treating the grammar as missing so the next demand re-fetches it.`,
|
|
3058
3120
|
metadata: { grammarFile, path: grammarPath, outcome: "load-failed" }
|
|
3059
3121
|
});
|
|
3060
3122
|
this.recordGrammarFailure(
|
|
3061
3123
|
grammarFile,
|
|
3062
3124
|
`Language.load failed on a resolved grammar file (${message}).`,
|
|
3063
3125
|
/* retryable */
|
|
3064
|
-
true
|
|
3126
|
+
true,
|
|
3127
|
+
cause
|
|
3065
3128
|
);
|
|
3066
3129
|
}
|
|
3130
|
+
/**
|
|
3131
|
+
* Watch a `Language.load` that the bound abandoned (#4224). web-tree-sitter
|
|
3132
|
+
* gives the load no abort, so it keeps running and settles later, and
|
|
3133
|
+
* `withDeadline` hands that late settle to a catch that records nothing.
|
|
3134
|
+
* Mirrors #1716's late-answer watch on a timed-out nav request.
|
|
3135
|
+
*
|
|
3136
|
+
* Every late failure is logged once to `tree-sitter.log`. Then:
|
|
3137
|
+
*
|
|
3138
|
+
* - An Emscripten abort kills the runtime whenever it lands, so it reaches
|
|
3139
|
+
* the same latch an on-time abort does (AGENTS.md shape 60). A trap takes
|
|
3140
|
+
* the other arm, as it does on time: charged to the grammar, not the budget.
|
|
3141
|
+
* - Any other failure says the load ended rather than hung. It leaves one
|
|
3142
|
+
* bounded `grammar-blocked` record naming the grammar and the failure. The
|
|
3143
|
+
* timeout already notified the user and climbed the cooldown ladder for
|
|
3144
|
+
* this load, so neither happens again.
|
|
3145
|
+
* - A late success is dropped. The caller was answered null and the grammar
|
|
3146
|
+
* sits on its cooldown, so keeping the language would make the answer depend
|
|
3147
|
+
* on when the load happened to finish.
|
|
3148
|
+
*
|
|
3149
|
+
* One abandoned load has one watch, so a late settle is one record however
|
|
3150
|
+
* many callers joined the build that started it.
|
|
3151
|
+
*
|
|
3152
|
+
* No caller awaits the watch, so it ends in a logging catch: a handler that
|
|
3153
|
+
* throws (the host's `onWasmAbort` can) is written to `tree-sitter.log`
|
|
3154
|
+
* rather than escaping as an unhandled rejection.
|
|
3155
|
+
*/
|
|
3156
|
+
observeAbandonedLoad(loading, grammarPath, grammarFile) {
|
|
3157
|
+
loading.then(() => {
|
|
3158
|
+
this.dbg(`Abandoned Language.load for ${grammarFile} succeeded after the bound; ignored`);
|
|
3159
|
+
}, (late) => {
|
|
3160
|
+
const message = late instanceof Error ? late.message : String(late);
|
|
3161
|
+
logTreeSitterDiagnostic({
|
|
3162
|
+
subsystem: "tree-sitter-client",
|
|
3163
|
+
level: "warn",
|
|
3164
|
+
message: `Language.load for ${grammarPath} settled after its ${GRAMMAR_LOAD_TIMEOUT_MS}ms bound and failed (${message}).`,
|
|
3165
|
+
metadata: { grammarFile, outcome: "late-load-failed" }
|
|
3166
|
+
});
|
|
3167
|
+
if (classifyTreeSitterWasmError(late) === "abort") {
|
|
3168
|
+
this.reportWasmAbort(late);
|
|
3169
|
+
} else {
|
|
3170
|
+
incrementDegradationCount({
|
|
3171
|
+
kind: "grammar-blocked",
|
|
3172
|
+
subject: grammarFile,
|
|
3173
|
+
reason: `Language.load failed after its ${GRAMMAR_LOAD_TIMEOUT_MS}ms bound (${message}).`
|
|
3174
|
+
});
|
|
3175
|
+
}
|
|
3176
|
+
}).catch((handlerErr) => {
|
|
3177
|
+
const message = handlerErr instanceof Error ? handlerErr.message : String(handlerErr);
|
|
3178
|
+
logTreeSitterDiagnostic({
|
|
3179
|
+
subsystem: "tree-sitter-client",
|
|
3180
|
+
level: "warn",
|
|
3181
|
+
message: `The late-settle handler for Language.load of ${grammarPath} threw (${message}).`,
|
|
3182
|
+
metadata: { grammarFile, outcome: "late-load-handler-failed" }
|
|
3183
|
+
});
|
|
3184
|
+
});
|
|
3185
|
+
}
|
|
3067
3186
|
/** Initialize tree-sitter WASM runtime */
|
|
3068
3187
|
async init() {
|
|
3069
3188
|
if (this.wasmAborted)
|
|
@@ -3178,28 +3297,42 @@ var TreeSitterClient = class _TreeSitterClient {
|
|
|
3178
3297
|
this.dbg(`Grammar file not found: ${grammarPath}`);
|
|
3179
3298
|
return null;
|
|
3180
3299
|
}
|
|
3300
|
+
let loading;
|
|
3181
3301
|
try {
|
|
3182
3302
|
if (!this.LanguageLoader?.load) {
|
|
3183
3303
|
this.dbg(`LanguageLoader.load not available`);
|
|
3184
3304
|
return null;
|
|
3185
3305
|
}
|
|
3186
3306
|
this.dbg(`Calling Language.load...`);
|
|
3187
|
-
const
|
|
3307
|
+
const started = this.LanguageLoader.load(grammarPath);
|
|
3308
|
+
loading = started;
|
|
3309
|
+
const language = await withTimeout(started, GRAMMAR_LOAD_TIMEOUT_MS);
|
|
3188
3310
|
this.dbg(`Language loaded: ${language?.name || "unknown"}`);
|
|
3189
3311
|
if (language) {
|
|
3190
3312
|
this.languages.set(languageId, language);
|
|
3191
3313
|
}
|
|
3192
3314
|
return language;
|
|
3193
3315
|
} catch (err) {
|
|
3194
|
-
|
|
3195
|
-
this.reportWasmAbort(err);
|
|
3196
|
-
} else {
|
|
3197
|
-
this.recordGrammarLoadFailure(grammarPath, grammarFile, err);
|
|
3198
|
-
}
|
|
3316
|
+
this.recordLanguageLoadFailure(err, loading, grammarPath, grammarFile);
|
|
3199
3317
|
this.dbg(`Language load error: ${err}`);
|
|
3200
3318
|
return null;
|
|
3201
3319
|
}
|
|
3202
3320
|
}
|
|
3321
|
+
/**
|
|
3322
|
+
* The one place a failed `Language.load` is recorded, so every path out of
|
|
3323
|
+
* `loadLanguage`'s catch publishes something.
|
|
3324
|
+
*/
|
|
3325
|
+
recordLanguageLoadFailure(err, loading, grammarPath, grammarFile) {
|
|
3326
|
+
const abandoned = isGrammarLoadTimeout(err) ? loading : void 0;
|
|
3327
|
+
if (abandoned) {
|
|
3328
|
+
this.observeAbandonedLoad(abandoned, grammarPath, grammarFile);
|
|
3329
|
+
}
|
|
3330
|
+
if (classifyTreeSitterWasmError(err) === "abort") {
|
|
3331
|
+
this.reportWasmAbort(err);
|
|
3332
|
+
} else {
|
|
3333
|
+
this.recordGrammarLoadFailure(grammarPath, grammarFile, err, abandoned ? "load-timed-out" : void 0);
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3203
3336
|
/** Get or create parser for a language */
|
|
3204
3337
|
async getParser(languageId) {
|
|
3205
3338
|
if (this.wasmAborted)
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
getOwnedLspService,
|
|
5
5
|
peekOwnedLspService,
|
|
6
6
|
resetOwnedLspService
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-2LDMXL2M.js";
|
|
8
|
+
import "./chunk-XWFIHYCH.js";
|
|
9
|
+
import "./chunk-TVZRLTG6.js";
|
|
10
|
+
import "./chunk-EWXXLS26.js";
|
|
11
11
|
import "./chunk-NXL4FFQQ.js";
|
|
12
12
|
export {
|
|
13
13
|
configureLspServiceLifecycle,
|
|
@@ -44,26 +44,25 @@ import {
|
|
|
44
44
|
setProjectSnapshotPromotionSeamForTests,
|
|
45
45
|
terminateProjectSnapshotPersistWorkerForTests,
|
|
46
46
|
waitForProjectSnapshotPersistsForTests
|
|
47
|
-
} from "./chunk-
|
|
48
|
-
import "./chunk-
|
|
49
|
-
import "./chunk-
|
|
50
|
-
import "./chunk-Z3CCVDUB.js";
|
|
47
|
+
} from "./chunk-JWOVP5BL.js";
|
|
48
|
+
import "./chunk-IEBJF3PN.js";
|
|
49
|
+
import "./chunk-UO66IMVP.js";
|
|
51
50
|
import "./chunk-2BEMIWEW.js";
|
|
52
|
-
import "./chunk-
|
|
53
|
-
import "./chunk-
|
|
51
|
+
import "./chunk-IJYGIDF4.js";
|
|
52
|
+
import "./chunk-TPYYEDP5.js";
|
|
53
|
+
import "./chunk-AWQWXSW4.js";
|
|
54
54
|
import "./chunk-QYF5S6P6.js";
|
|
55
|
-
import "./chunk-
|
|
56
|
-
import "./chunk-
|
|
57
|
-
import "./chunk-
|
|
58
|
-
import "./chunk-
|
|
59
|
-
import "./chunk-
|
|
60
|
-
import "./chunk-
|
|
61
|
-
import "./chunk-
|
|
62
|
-
import "./chunk-
|
|
63
|
-
import "./chunk-
|
|
55
|
+
import "./chunk-GYRZ72R4.js";
|
|
56
|
+
import "./chunk-KJJAVH3X.js";
|
|
57
|
+
import "./chunk-ZSUX7KEM.js";
|
|
58
|
+
import "./chunk-EIKRZ32J.js";
|
|
59
|
+
import "./chunk-FWZRGGGY.js";
|
|
60
|
+
import "./chunk-N3PLNNCW.js";
|
|
61
|
+
import "./chunk-S26LC76R.js";
|
|
62
|
+
import "./chunk-XWFIHYCH.js";
|
|
63
|
+
import "./chunk-TVZRLTG6.js";
|
|
64
64
|
import "./chunk-LJDODBBZ.js";
|
|
65
|
-
import "./chunk-
|
|
66
|
-
import "./chunk-N2H3ZPZY.js";
|
|
65
|
+
import "./chunk-EWXXLS26.js";
|
|
67
66
|
import "./chunk-NXL4FFQQ.js";
|
|
68
67
|
export {
|
|
69
68
|
PROJECT_SNAPSHOT_MAX_WARM_ROOTS,
|
|
@@ -2,29 +2,31 @@ import { createRequire as __pilensCreateRequire } from "node:module"; const requ
|
|
|
2
2
|
import {
|
|
3
3
|
firstOutputLine,
|
|
4
4
|
spawnFailedWithNoOutput
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-T4NGVFYI.js";
|
|
6
6
|
import {
|
|
7
7
|
SecurityScanClient
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QT66NEYN.js";
|
|
9
9
|
import {
|
|
10
10
|
probeToolAsync
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-XI34NWDI.js";
|
|
12
12
|
import {
|
|
13
13
|
INSTALL_TRANSIENT_MAX_ATTEMPTS,
|
|
14
14
|
classifyProbeFailure,
|
|
15
15
|
describeProbeEvidence,
|
|
16
16
|
logAvailabilityDecision,
|
|
17
17
|
startHostStallSampler
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-5LRUKYFA.js";
|
|
19
19
|
import {
|
|
20
|
+
isUntrustedProjectPath,
|
|
21
|
+
recordProjectCommandRefusal,
|
|
20
22
|
safeSpawnAsync
|
|
21
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-TPYYEDP5.js";
|
|
22
24
|
import {
|
|
23
25
|
assertInstallAllowed
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-EIKRZ32J.js";
|
|
25
27
|
import {
|
|
26
28
|
recordDegradationOnce
|
|
27
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-FWZRGGGY.js";
|
|
28
30
|
|
|
29
31
|
// dist/clients/govulncheck-client.js
|
|
30
32
|
import * as fs from "node:fs";
|
|
@@ -213,6 +215,10 @@ var GovulncheckClient = class _GovulncheckClient extends SecurityScanClient {
|
|
|
213
215
|
for (const candidate of candidates) {
|
|
214
216
|
try {
|
|
215
217
|
if (fs.existsSync(candidate)) {
|
|
218
|
+
if (isUntrustedProjectPath(candidate)) {
|
|
219
|
+
recordProjectCommandRefusal(candidate);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
216
222
|
this.binaryPath = candidate;
|
|
217
223
|
this.available = true;
|
|
218
224
|
this.log(`govulncheck auto-installed at ${candidate}`);
|