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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
calcCyclomaticComplexity,
|
|
4
|
+
functionFactProvider
|
|
5
|
+
} from "./chunk-ZPJM7DID.js";
|
|
6
|
+
import "./chunk-G224FADB.js";
|
|
7
|
+
import "./chunk-5W3R6LFT.js";
|
|
8
|
+
import "./chunk-YWWG4AQA.js";
|
|
9
|
+
import "./chunk-Z54ZSOBZ.js";
|
|
10
|
+
import "./chunk-2Y6OJRSI.js";
|
|
11
|
+
import "./chunk-WUY4BZEP.js";
|
|
12
|
+
import "./chunk-GTDSYEA2.js";
|
|
13
|
+
import "./chunk-NLIVE7L6.js";
|
|
14
|
+
import "./chunk-5LRUKYFA.js";
|
|
15
|
+
import "./chunk-TPYYEDP5.js";
|
|
16
|
+
import "./chunk-GYRZ72R4.js";
|
|
17
|
+
import "./chunk-KJJAVH3X.js";
|
|
18
|
+
import "./chunk-ZSUX7KEM.js";
|
|
19
|
+
import "./chunk-EIKRZ32J.js";
|
|
20
|
+
import "./chunk-FWZRGGGY.js";
|
|
21
|
+
import "./chunk-N3PLNNCW.js";
|
|
22
|
+
import "./chunk-S26LC76R.js";
|
|
23
|
+
import "./chunk-XWFIHYCH.js";
|
|
24
|
+
import "./chunk-TVZRLTG6.js";
|
|
25
|
+
import "./chunk-LJDODBBZ.js";
|
|
26
|
+
import "./chunk-EWXXLS26.js";
|
|
27
|
+
import "./chunk-NXL4FFQQ.js";
|
|
28
|
+
export {
|
|
29
|
+
calcCyclomaticComplexity,
|
|
30
|
+
functionFactProvider
|
|
31
|
+
};
|
|
@@ -4,12 +4,22 @@ import {
|
|
|
4
4
|
reserveManagedToolRefreshSlot
|
|
5
5
|
} from "./chunk-UXVNL3D7.js";
|
|
6
6
|
import {
|
|
7
|
-
|
|
7
|
+
stripAnsi
|
|
8
|
+
} from "./chunk-6HWVI6MI.js";
|
|
9
|
+
import {
|
|
10
|
+
OPENGREP_REGISTRY_PACK_URL,
|
|
11
|
+
cachedOpengrepPackPath
|
|
12
|
+
} from "./chunk-UL5SXQVX.js";
|
|
13
|
+
import {
|
|
14
|
+
HOOK_WALL_BUDGET_MS
|
|
15
|
+
} from "./chunk-CKEQFGLT.js";
|
|
16
|
+
import {
|
|
8
17
|
bounded
|
|
9
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-NLIVE7L6.js";
|
|
10
19
|
import {
|
|
11
20
|
acquireManagedInstallGate,
|
|
12
21
|
commitDurableStoreAsync,
|
|
22
|
+
findManagedToolBinary,
|
|
13
23
|
getManagedToolsDir,
|
|
14
24
|
getRefreshableManagedTools,
|
|
15
25
|
invalidateManagedToolResolution,
|
|
@@ -19,42 +29,45 @@ import {
|
|
|
19
29
|
refreshManagedTool,
|
|
20
30
|
resolveManagedNpmBinPath,
|
|
21
31
|
verifyToolBinary
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
32
|
+
} from "./chunk-IL7K66ZQ.js";
|
|
33
|
+
import "./chunk-4FHUGDKU.js";
|
|
24
34
|
import {
|
|
25
35
|
pmBinary,
|
|
26
36
|
resolveNodePackageManager,
|
|
27
37
|
updateArgs
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
31
|
-
import "./chunk-
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import "./chunk-
|
|
34
|
-
import "./chunk-
|
|
38
|
+
} from "./chunk-K4SZB56V.js";
|
|
39
|
+
import "./chunk-XI34NWDI.js";
|
|
40
|
+
import "./chunk-5LRUKYFA.js";
|
|
41
|
+
import "./chunk-63NMUNYP.js";
|
|
42
|
+
import "./chunk-CG5V25HX.js";
|
|
43
|
+
import "./chunk-PP2A5V2T.js";
|
|
44
|
+
import "./chunk-S55TEC7I.js";
|
|
35
45
|
import {
|
|
36
46
|
safeSpawnAsync
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import "./chunk-
|
|
47
|
+
} from "./chunk-TPYYEDP5.js";
|
|
48
|
+
import "./chunk-AWQWXSW4.js";
|
|
39
49
|
import "./chunk-QYF5S6P6.js";
|
|
40
|
-
import "./chunk-
|
|
41
|
-
import "./chunk-
|
|
42
|
-
import "./chunk-
|
|
43
|
-
import
|
|
44
|
-
|
|
50
|
+
import "./chunk-GYRZ72R4.js";
|
|
51
|
+
import "./chunk-KJJAVH3X.js";
|
|
52
|
+
import "./chunk-ZSUX7KEM.js";
|
|
53
|
+
import {
|
|
54
|
+
writeFileAtomicAsync
|
|
55
|
+
} from "./chunk-EIKRZ32J.js";
|
|
45
56
|
import {
|
|
46
57
|
recordDegradationOnce
|
|
47
|
-
} from "./chunk-
|
|
48
|
-
import "./chunk-
|
|
49
|
-
import "./chunk-
|
|
50
|
-
import "./chunk-
|
|
51
|
-
import
|
|
58
|
+
} from "./chunk-FWZRGGGY.js";
|
|
59
|
+
import "./chunk-N3PLNNCW.js";
|
|
60
|
+
import "./chunk-S26LC76R.js";
|
|
61
|
+
import "./chunk-XWFIHYCH.js";
|
|
62
|
+
import {
|
|
63
|
+
isTestMode
|
|
64
|
+
} from "./chunk-TVZRLTG6.js";
|
|
52
65
|
import "./chunk-LJDODBBZ.js";
|
|
53
|
-
import "./chunk-
|
|
54
|
-
import "./chunk-N2H3ZPZY.js";
|
|
66
|
+
import "./chunk-EWXXLS26.js";
|
|
55
67
|
import "./chunk-NXL4FFQQ.js";
|
|
56
68
|
|
|
57
69
|
// dist/clients/installer/managed-tool-refresh.js
|
|
70
|
+
import * as crypto from "node:crypto";
|
|
58
71
|
import * as fs from "node:fs/promises";
|
|
59
72
|
import * as path from "node:path";
|
|
60
73
|
var STATE_FILENAME = ".refresh-state.json";
|
|
@@ -142,10 +155,10 @@ async function readManagedToolRefreshState() {
|
|
|
142
155
|
return { status: "unreadable", reason: err.message };
|
|
143
156
|
}
|
|
144
157
|
}
|
|
145
|
-
async function writeRefreshStamp(toolId, entry) {
|
|
158
|
+
async function writeRefreshStamp(toolId, entry, options = {}) {
|
|
146
159
|
try {
|
|
147
160
|
await fs.mkdir(getManagedToolsDir(), { recursive: true });
|
|
148
|
-
await commitDurableStoreAsync({
|
|
161
|
+
const committed = await commitDurableStoreAsync({
|
|
149
162
|
path: getManagedToolRefreshStatePath(),
|
|
150
163
|
deserialize: (contents) => {
|
|
151
164
|
if (contents === void 0)
|
|
@@ -157,6 +170,10 @@ async function writeRefreshStamp(toolId, entry) {
|
|
|
157
170
|
}
|
|
158
171
|
},
|
|
159
172
|
merge: (disk) => {
|
|
173
|
+
const current = disk.tools[toolId];
|
|
174
|
+
if (options.retainNewerSuccess === true && entry.failed === true && current !== void 0 && current.failed !== true && current.checkedAt >= entry.checkedAt) {
|
|
175
|
+
return disk;
|
|
176
|
+
}
|
|
160
177
|
disk.tools[toolId] = entry;
|
|
161
178
|
return disk;
|
|
162
179
|
},
|
|
@@ -170,6 +187,9 @@ async function writeRefreshStamp(toolId, entry) {
|
|
|
170
187
|
logSessionStart(`managed-tool-refresh ${toolId}: stamp deferred because another process owns the lock`);
|
|
171
188
|
}
|
|
172
189
|
});
|
|
190
|
+
if (committed !== void 0 && committed.tools[toolId] !== entry) {
|
|
191
|
+
logSessionStart(`managed-tool-refresh ${toolId}: kept a newer successful stamp (checkedAt ${committed.tools[toolId]?.checkedAt ?? "unknown"}) \u2014 this failure does not replace it`);
|
|
192
|
+
}
|
|
173
193
|
} catch (err) {
|
|
174
194
|
recordDegradationOnce({
|
|
175
195
|
kind: "managed-tool-refresh",
|
|
@@ -303,7 +323,7 @@ async function refreshNonNpmOne(candidate, entry, now) {
|
|
|
303
323
|
// Deliberately NOT carrying `entry.etag` forward: a stamp that replays
|
|
304
324
|
// the validator of a run whose download failed would get a 304 next
|
|
305
325
|
// time and skip the install that never happened.
|
|
306
|
-
});
|
|
326
|
+
}, { retainNewerSuccess: true });
|
|
307
327
|
return {
|
|
308
328
|
toolId: candidate.toolId,
|
|
309
329
|
strategy: candidate.strategy,
|
|
@@ -405,7 +425,7 @@ async function performNpmRefresh(candidate, packageName, now) {
|
|
|
405
425
|
checkedAt: now,
|
|
406
426
|
failed: true,
|
|
407
427
|
...onDisk !== void 0 && { version: onDisk }
|
|
408
|
-
});
|
|
428
|
+
}, { retainNewerSuccess: true });
|
|
409
429
|
return {
|
|
410
430
|
toolId: candidate.toolId,
|
|
411
431
|
strategy: "npm",
|
|
@@ -446,7 +466,7 @@ async function performNpmRefresh(candidate, packageName, now) {
|
|
|
446
466
|
checkedAt: now,
|
|
447
467
|
failed: true,
|
|
448
468
|
...currentVersion !== void 0 && { version: currentVersion }
|
|
449
|
-
});
|
|
469
|
+
}, { retainNewerSuccess: true });
|
|
450
470
|
return {
|
|
451
471
|
toolId: candidate.toolId,
|
|
452
472
|
strategy: "npm",
|
|
@@ -479,13 +499,17 @@ async function performNpmRefresh(candidate, packageName, now) {
|
|
|
479
499
|
var refreshInFlight = null;
|
|
480
500
|
var noopTap = () => {
|
|
481
501
|
};
|
|
482
|
-
function runManagedToolRefresh(now = Date.now()) {
|
|
502
|
+
function runManagedToolRefresh(now = Date.now(), options = {}) {
|
|
483
503
|
const joined = refreshInFlight;
|
|
484
504
|
if (joined) {
|
|
485
505
|
logSessionStart("managed-tool-refresh: joining the refresh already in flight");
|
|
486
506
|
return joined;
|
|
487
507
|
}
|
|
488
|
-
const run = executeManagedToolRefresh(now, noopTap).
|
|
508
|
+
const run = executeManagedToolRefresh(now, noopTap).then(async (outcome) => {
|
|
509
|
+
if (options.rulePack !== false)
|
|
510
|
+
await refreshOpengrepRulePack(now);
|
|
511
|
+
return outcome;
|
|
512
|
+
}).finally(() => {
|
|
489
513
|
refreshInFlight = null;
|
|
490
514
|
});
|
|
491
515
|
refreshInFlight = run;
|
|
@@ -565,7 +589,7 @@ async function executeManagedToolRefresh(now, tap = noopTap) {
|
|
|
565
589
|
version: result.currentVersion
|
|
566
590
|
},
|
|
567
591
|
...result.ok ? {} : { failed: true }
|
|
568
|
-
}), {
|
|
592
|
+
}, { retainNewerSuccess: true }), {
|
|
569
593
|
ms: HOOK_WALL_BUDGET_MS.session_start,
|
|
570
594
|
// The unref'd timer runs after session_start returns, so no
|
|
571
595
|
// live turn signal belongs to this background refresh.
|
|
@@ -589,9 +613,205 @@ async function executeManagedToolRefresh(now, tap = noopTap) {
|
|
|
589
613
|
releaseReservation();
|
|
590
614
|
}
|
|
591
615
|
}
|
|
616
|
+
var OPENGREP_PACK_STAMP_ID = "opengrep-rules";
|
|
617
|
+
var PACK_FETCH_TIMEOUT_MS = 6e4;
|
|
618
|
+
var PACK_VALIDATE_TIMEOUT_MS = 18e4;
|
|
619
|
+
var PACK_MAX_BYTES = 16 * 1024 * 1024;
|
|
620
|
+
var PACK_MIN_RULES = 100;
|
|
621
|
+
function opengrepPackUrl() {
|
|
622
|
+
if (isTestMode()) {
|
|
623
|
+
return process.env.PI_LENS_TEST_OPENGREP_PACK_URL;
|
|
624
|
+
}
|
|
625
|
+
return OPENGREP_REGISTRY_PACK_URL;
|
|
626
|
+
}
|
|
627
|
+
async function downloadOpengrepPack(url) {
|
|
628
|
+
const res = await fetch(url, {
|
|
629
|
+
signal: AbortSignal.timeout(PACK_FETCH_TIMEOUT_MS),
|
|
630
|
+
// `identity` is load-bearing: semgrep.dev/c/auto answers a client that
|
|
631
|
+
// accepts gzip (Node's fetch does by default) with the rule set as JSON,
|
|
632
|
+
// and one that does not with YAML (measured 2026-10-23). The CLI loads
|
|
633
|
+
// either from a `.yaml` file; the language server loads the JSON as zero
|
|
634
|
+
// rules and publishes empty diagnostics, which would turn a cached pack
|
|
635
|
+
// into a silent clean scan.
|
|
636
|
+
headers: { "User-Agent": "pi-lens/1.0", "Accept-Encoding": "identity" }
|
|
637
|
+
});
|
|
638
|
+
if (!res.ok)
|
|
639
|
+
throw new Error(`HTTP ${res.status}`);
|
|
640
|
+
if (!res.body)
|
|
641
|
+
throw new Error("empty response body");
|
|
642
|
+
const chunks = [];
|
|
643
|
+
let total = 0;
|
|
644
|
+
const reader = res.body.getReader();
|
|
645
|
+
for (; ; ) {
|
|
646
|
+
const { done, value } = await reader.read();
|
|
647
|
+
if (done)
|
|
648
|
+
break;
|
|
649
|
+
total += value.byteLength;
|
|
650
|
+
if (total > PACK_MAX_BYTES) {
|
|
651
|
+
await reader.cancel();
|
|
652
|
+
throw new Error(`body exceeds ${PACK_MAX_BYTES} bytes`);
|
|
653
|
+
}
|
|
654
|
+
chunks.push(value);
|
|
655
|
+
}
|
|
656
|
+
const bytes = Buffer.concat(chunks);
|
|
657
|
+
if (bytes.toString("utf-8", 0, 64).trimStart().startsWith("{"))
|
|
658
|
+
throw new Error("registry answered JSON, not the YAML rule file");
|
|
659
|
+
return bytes;
|
|
660
|
+
}
|
|
661
|
+
async function validateOpengrepPack(binary, candidate) {
|
|
662
|
+
const spawned = await safeSpawnAsync(binary, ["scan", "--validate", "--config", candidate, "--disable-version-check"], {
|
|
663
|
+
cwd: path.dirname(candidate),
|
|
664
|
+
timeout: PACK_VALIDATE_TIMEOUT_MS,
|
|
665
|
+
ignoreAmbientSignal: true,
|
|
666
|
+
lifetimeCoupled: true
|
|
667
|
+
});
|
|
668
|
+
if (spawned.status !== 0) {
|
|
669
|
+
const detail = spawned.stderr.trim() || spawned.failure || `exit ${spawned.status}`;
|
|
670
|
+
return `opengrep --validate failed: ${detail}`.slice(0, 240);
|
|
671
|
+
}
|
|
672
|
+
const count = /(\d+) rule\(s\)/.exec(stripAnsi(`${spawned.stdout}
|
|
673
|
+
${spawned.stderr}`));
|
|
674
|
+
const rules = count ? Number(count[1]) : 0;
|
|
675
|
+
if (rules < PACK_MIN_RULES) {
|
|
676
|
+
return `opengrep --validate reported ${count ? rules : "no"} rules (floor ${PACK_MIN_RULES})`;
|
|
677
|
+
}
|
|
678
|
+
return void 0;
|
|
679
|
+
}
|
|
680
|
+
var PACK_CANDIDATE_MAX_AGE_MS = 60 * 60 * 1e3;
|
|
681
|
+
async function sweepStaleCandidates(finalPath) {
|
|
682
|
+
const dir = path.dirname(finalPath);
|
|
683
|
+
const prefix = `${path.basename(finalPath)}.candidate-`;
|
|
684
|
+
try {
|
|
685
|
+
for (const name of await fs.readdir(dir)) {
|
|
686
|
+
if (!name.startsWith(prefix))
|
|
687
|
+
continue;
|
|
688
|
+
const file = path.join(dir, name);
|
|
689
|
+
const { mtimeMs } = await fs.stat(file);
|
|
690
|
+
if (Date.now() - mtimeMs > PACK_CANDIDATE_MAX_AGE_MS)
|
|
691
|
+
await fs.rm(file, { force: true });
|
|
692
|
+
}
|
|
693
|
+
} catch (err) {
|
|
694
|
+
logSessionStart(`managed-tool-refresh ${OPENGREP_PACK_STAMP_ID}: could not sweep stale candidates (${err.message})`);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
async function refreshOpengrepRulePack(now = Date.now()) {
|
|
698
|
+
try {
|
|
699
|
+
if (process.env.PI_LENS_DISABLE_TOOL_REFRESH === "1")
|
|
700
|
+
return "skipped";
|
|
701
|
+
const url = opengrepPackUrl();
|
|
702
|
+
if (!url)
|
|
703
|
+
return "skipped";
|
|
704
|
+
const binary = await findManagedToolBinary("opengrep");
|
|
705
|
+
if (!binary)
|
|
706
|
+
return "skipped";
|
|
707
|
+
const read = await readManagedToolRefreshState();
|
|
708
|
+
if (read.status === "unreadable") {
|
|
709
|
+
recordDegradationOnce({
|
|
710
|
+
kind: "managed-tool-refresh",
|
|
711
|
+
subject: "refresh-state",
|
|
712
|
+
reason: `refresh state unreadable (${read.reason}); skipping refresh this session`
|
|
713
|
+
});
|
|
714
|
+
return "skipped";
|
|
715
|
+
}
|
|
716
|
+
const entry = read.state.tools[OPENGREP_PACK_STAMP_ID];
|
|
717
|
+
if (entry && now - entry.checkedAt < (entry.failed ? retryIntervalMs() : refreshIntervalMs())) {
|
|
718
|
+
return "skipped";
|
|
719
|
+
}
|
|
720
|
+
const declined = async (phase) => {
|
|
721
|
+
logSessionStart(`managed-tool-refresh ${OPENGREP_PACK_STAMP_ID}: declined (${phase}) \u2014 no stamp written, retried next session`);
|
|
722
|
+
return "declined";
|
|
723
|
+
};
|
|
724
|
+
const pre = await acquireManagedInstallGate(`managed tool refresh: ${OPENGREP_PACK_STAMP_ID}`);
|
|
725
|
+
if (!pre.ok)
|
|
726
|
+
return declined(pre.reason ?? "unknown");
|
|
727
|
+
await pre.release?.();
|
|
728
|
+
const finalPath = cachedOpengrepPackPath();
|
|
729
|
+
const candidate = `${finalPath}.candidate-${process.pid}-${crypto.randomBytes(4).toString("hex")}`;
|
|
730
|
+
const startedAt = Date.now();
|
|
731
|
+
try {
|
|
732
|
+
await fs.mkdir(path.dirname(finalPath), { recursive: true });
|
|
733
|
+
await sweepStaleCandidates(finalPath);
|
|
734
|
+
const bytes = await downloadOpengrepPack(url);
|
|
735
|
+
const digest = crypto.createHash("sha256").update(bytes).digest("hex");
|
|
736
|
+
let current;
|
|
737
|
+
try {
|
|
738
|
+
current = await fs.readFile(finalPath);
|
|
739
|
+
} catch (err) {
|
|
740
|
+
if (err.code !== "ENOENT")
|
|
741
|
+
throw err;
|
|
742
|
+
}
|
|
743
|
+
if (current && crypto.createHash("sha256").update(current).digest("hex") === digest) {
|
|
744
|
+
await writeRefreshStamp(OPENGREP_PACK_STAMP_ID, {
|
|
745
|
+
checkedAt: now,
|
|
746
|
+
version: digest.slice(0, 12)
|
|
747
|
+
});
|
|
748
|
+
logSessionStart(`managed-tool-refresh ${OPENGREP_PACK_STAMP_ID}: unchanged at ${digest.slice(0, 12)} (${Date.now() - startedAt}ms)`);
|
|
749
|
+
return "unchanged";
|
|
750
|
+
}
|
|
751
|
+
await writeFileAtomicAsync(candidate, bytes, { bestEffort: false });
|
|
752
|
+
const rejected = await validateOpengrepPack(binary, candidate);
|
|
753
|
+
if (rejected)
|
|
754
|
+
throw new Error(rejected);
|
|
755
|
+
const swap = await acquireManagedInstallGate(`managed tool refresh: ${OPENGREP_PACK_STAMP_ID} (swap)`);
|
|
756
|
+
if (!swap.ok)
|
|
757
|
+
return await declined(swap.reason ?? "unknown");
|
|
758
|
+
try {
|
|
759
|
+
const after = await readManagedToolRefreshState();
|
|
760
|
+
const latest = after.status === "ok" ? after.state.tools[OPENGREP_PACK_STAMP_ID] : void 0;
|
|
761
|
+
if (latest && !latest.failed && latest.checkedAt !== entry?.checkedAt) {
|
|
762
|
+
logSessionStart(`managed-tool-refresh ${OPENGREP_PACK_STAMP_ID}: another process refreshed first \u2014 keeping its pack`);
|
|
763
|
+
return "skipped";
|
|
764
|
+
}
|
|
765
|
+
await fs.rename(candidate, finalPath);
|
|
766
|
+
await writeRefreshStamp(OPENGREP_PACK_STAMP_ID, {
|
|
767
|
+
checkedAt: now,
|
|
768
|
+
version: digest.slice(0, 12)
|
|
769
|
+
});
|
|
770
|
+
} finally {
|
|
771
|
+
await swap.release?.();
|
|
772
|
+
}
|
|
773
|
+
logSessionStart(`managed-tool-refresh ${OPENGREP_PACK_STAMP_ID}: cached pack now ${digest.slice(0, 12)} (${bytes.byteLength} bytes, ${Date.now() - startedAt}ms)`);
|
|
774
|
+
return "refreshed";
|
|
775
|
+
} catch (err) {
|
|
776
|
+
const reason = err.message;
|
|
777
|
+
recordDegradationOnce({
|
|
778
|
+
kind: "managed-tool-refresh",
|
|
779
|
+
subject: OPENGREP_PACK_STAMP_ID,
|
|
780
|
+
reason: `rule pack refresh failed: ${reason}`
|
|
781
|
+
});
|
|
782
|
+
logSessionStart(`managed-tool-refresh ${OPENGREP_PACK_STAMP_ID}: refresh failed after ${Date.now() - startedAt}ms \u2014 keeping the current pack (${reason})`);
|
|
783
|
+
await writeRefreshStamp(
|
|
784
|
+
OPENGREP_PACK_STAMP_ID,
|
|
785
|
+
{
|
|
786
|
+
checkedAt: now,
|
|
787
|
+
failed: true,
|
|
788
|
+
...entry?.version !== void 0 && { version: entry.version }
|
|
789
|
+
},
|
|
790
|
+
// A winner that stamped while this attempt was validating keeps its
|
|
791
|
+
// `{checkedAt, version}` and its weekly cadence (shape 21).
|
|
792
|
+
{ retainNewerSuccess: true }
|
|
793
|
+
);
|
|
794
|
+
return "failed";
|
|
795
|
+
} finally {
|
|
796
|
+
try {
|
|
797
|
+
await fs.rm(candidate, { force: true });
|
|
798
|
+
} catch (err) {
|
|
799
|
+
logSessionStart(`managed-tool-refresh ${OPENGREP_PACK_STAMP_ID}: could not remove ${candidate} (${err.message})`);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
} catch (err) {
|
|
803
|
+
recordDegradationOnce({
|
|
804
|
+
kind: "managed-tool-refresh",
|
|
805
|
+
subject: OPENGREP_PACK_STAMP_ID,
|
|
806
|
+
reason: `rule pack refresh threw: ${err.message}`
|
|
807
|
+
});
|
|
808
|
+
return "failed";
|
|
809
|
+
}
|
|
810
|
+
}
|
|
592
811
|
export {
|
|
593
812
|
getManagedToolRefreshStatePath,
|
|
594
813
|
readManagedToolRefreshState,
|
|
814
|
+
refreshOpengrepRulePack,
|
|
595
815
|
runManagedToolRefresh,
|
|
596
816
|
runManagedToolRefreshForExploration,
|
|
597
817
|
selectStaleTools,
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
_getWarmWordIndexCacheStateForTests,
|
|
4
|
+
_resetWarmWordIndexCacheForTests,
|
|
5
|
+
acquireWarmWordIndex,
|
|
6
|
+
analyzeFile,
|
|
7
|
+
summarizeWarningTiers
|
|
8
|
+
} from "./chunk-4ODSZ35Z.js";
|
|
9
|
+
import "./chunk-K2GUZ4DN.js";
|
|
10
|
+
import "./chunk-3WCEHYOI.js";
|
|
11
|
+
import "./chunk-VIDEKABZ.js";
|
|
12
|
+
import "./chunk-T4NGVFYI.js";
|
|
13
|
+
import "./chunk-YSDPVDFC.js";
|
|
14
|
+
import "./chunk-UCVMSOXF.js";
|
|
15
|
+
import "./chunk-RG3MXTRI.js";
|
|
16
|
+
import "./chunk-7FLRUH6B.js";
|
|
17
|
+
import "./chunk-KPVLQHCZ.js";
|
|
18
|
+
import "./chunk-QT66NEYN.js";
|
|
19
|
+
import "./chunk-Y5KTA2OB.js";
|
|
20
|
+
import "./chunk-YKVDBNPO.js";
|
|
21
|
+
import "./chunk-Q4BKKOVC.js";
|
|
22
|
+
import "./chunk-2SDHYHHO.js";
|
|
23
|
+
import "./chunk-COOUUC5W.js";
|
|
24
|
+
import "./chunk-SNEUMLM7.js";
|
|
25
|
+
import "./chunk-ZPJM7DID.js";
|
|
26
|
+
import "./chunk-G224FADB.js";
|
|
27
|
+
import "./chunk-EXVXBSGN.js";
|
|
28
|
+
import "./chunk-3MED75HT.js";
|
|
29
|
+
import "./chunk-SJHC3BCZ.js";
|
|
30
|
+
import "./chunk-MEFLGBCS.js";
|
|
31
|
+
import "./chunk-XIMYZ3JA.js";
|
|
32
|
+
import "./chunk-7ZS7MC24.js";
|
|
33
|
+
import "./chunk-6XSESGWD.js";
|
|
34
|
+
import "./chunk-3SNDVPOR.js";
|
|
35
|
+
import "./chunk-JWOVP5BL.js";
|
|
36
|
+
import "./chunk-2LDMXL2M.js";
|
|
37
|
+
import "./chunk-5W3R6LFT.js";
|
|
38
|
+
import "./chunk-FEDWAYDS.js";
|
|
39
|
+
import "./chunk-CPZ5JJW6.js";
|
|
40
|
+
import "./chunk-7IYC4ENJ.js";
|
|
41
|
+
import "./chunk-KX56K73G.js";
|
|
42
|
+
import "./chunk-YWWG4AQA.js";
|
|
43
|
+
import "./chunk-Z54ZSOBZ.js";
|
|
44
|
+
import "./chunk-2Y6OJRSI.js";
|
|
45
|
+
import "./chunk-WUY4BZEP.js";
|
|
46
|
+
import "./chunk-GTDSYEA2.js";
|
|
47
|
+
import "./chunk-6HWVI6MI.js";
|
|
48
|
+
import "./chunk-UL5SXQVX.js";
|
|
49
|
+
import "./chunk-CKEQFGLT.js";
|
|
50
|
+
import "./chunk-NLIVE7L6.js";
|
|
51
|
+
import "./chunk-IEBJF3PN.js";
|
|
52
|
+
import "./chunk-UO66IMVP.js";
|
|
53
|
+
import "./chunk-Q42LJANT.js";
|
|
54
|
+
import "./chunk-APFJKOP6.js";
|
|
55
|
+
import "./chunk-2BEMIWEW.js";
|
|
56
|
+
import "./chunk-IJYGIDF4.js";
|
|
57
|
+
import "./chunk-IL7K66ZQ.js";
|
|
58
|
+
import "./chunk-4FHUGDKU.js";
|
|
59
|
+
import "./chunk-K4SZB56V.js";
|
|
60
|
+
import "./chunk-XI34NWDI.js";
|
|
61
|
+
import "./chunk-5LRUKYFA.js";
|
|
62
|
+
import "./chunk-63NMUNYP.js";
|
|
63
|
+
import "./chunk-CG5V25HX.js";
|
|
64
|
+
import "./chunk-PP2A5V2T.js";
|
|
65
|
+
import "./chunk-S55TEC7I.js";
|
|
66
|
+
import "./chunk-TPYYEDP5.js";
|
|
67
|
+
import "./chunk-AWQWXSW4.js";
|
|
68
|
+
import "./chunk-QYF5S6P6.js";
|
|
69
|
+
import "./chunk-GYRZ72R4.js";
|
|
70
|
+
import "./chunk-KJJAVH3X.js";
|
|
71
|
+
import "./chunk-ZSUX7KEM.js";
|
|
72
|
+
import "./chunk-EIKRZ32J.js";
|
|
73
|
+
import "./chunk-FWZRGGGY.js";
|
|
74
|
+
import "./chunk-N3PLNNCW.js";
|
|
75
|
+
import "./chunk-S26LC76R.js";
|
|
76
|
+
import "./chunk-XWFIHYCH.js";
|
|
77
|
+
import "./chunk-TVZRLTG6.js";
|
|
78
|
+
import "./chunk-LJDODBBZ.js";
|
|
79
|
+
import "./chunk-NFNVDDGB.js";
|
|
80
|
+
import "./chunk-EWXXLS26.js";
|
|
81
|
+
import "./chunk-NXL4FFQQ.js";
|
|
82
|
+
export {
|
|
83
|
+
_getWarmWordIndexCacheStateForTests,
|
|
84
|
+
_resetWarmWordIndexCacheForTests,
|
|
85
|
+
acquireWarmWordIndex,
|
|
86
|
+
analyzeFile,
|
|
87
|
+
summarizeWarningTiers
|
|
88
|
+
};
|
|
@@ -3,31 +3,29 @@ import {
|
|
|
3
3
|
shouldRecurseIntoDir,
|
|
4
4
|
walkTreeRecursiveSync,
|
|
5
5
|
walkTreeStackAsync
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-S55TEC7I.js";
|
|
7
7
|
import {
|
|
8
8
|
getProjectIgnoreMatcher
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TPYYEDP5.js";
|
|
10
10
|
import {
|
|
11
11
|
KIND_EXTENSIONS,
|
|
12
12
|
isCodeKindFile
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-GYRZ72R4.js";
|
|
14
14
|
import {
|
|
15
15
|
classifyGeneratedOrArtifactDetailed,
|
|
16
16
|
isDeclarationFile
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-KJJAVH3X.js";
|
|
18
18
|
import {
|
|
19
19
|
logLatency
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-XWFIHYCH.js";
|
|
21
21
|
import {
|
|
22
22
|
toPositiveFinite
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import {
|
|
25
|
-
BoundedLruCache
|
|
26
|
-
} from "./chunk-ABBOA7UD.js";
|
|
23
|
+
} from "./chunk-TVZRLTG6.js";
|
|
27
24
|
import {
|
|
25
|
+
BoundedLruCache,
|
|
28
26
|
normalizeEphemeralMapKey,
|
|
29
27
|
normalizeFilePath
|
|
30
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-EWXXLS26.js";
|
|
31
29
|
|
|
32
30
|
// dist/clients/source-filter.js
|
|
33
31
|
import * as fs2 from "node:fs";
|
|
@@ -110,14 +108,15 @@ function slowFsDegradationNotice() {
|
|
|
110
108
|
function createArtifactProbeCache() {
|
|
111
109
|
return /* @__PURE__ */ new Map();
|
|
112
110
|
}
|
|
113
|
-
function probeExists(filePath, cache) {
|
|
111
|
+
function probeExists(filePath, cache, siblings) {
|
|
112
|
+
const exists = () => (!siblings || siblings.mayContain(filePath)) && fs2.existsSync(filePath);
|
|
114
113
|
if (!cache)
|
|
115
|
-
return
|
|
114
|
+
return exists();
|
|
116
115
|
const key = normalizeEphemeralMapKey(filePath);
|
|
117
116
|
const cached = cache.get(key);
|
|
118
117
|
if (cached !== void 0)
|
|
119
118
|
return cached;
|
|
120
|
-
const result =
|
|
119
|
+
const result = exists();
|
|
121
120
|
cache.set(key, result);
|
|
122
121
|
return result;
|
|
123
122
|
}
|
|
@@ -225,9 +224,9 @@ function getBasename(filePath) {
|
|
|
225
224
|
function getDir(filePath) {
|
|
226
225
|
return path2.dirname(filePath);
|
|
227
226
|
}
|
|
228
|
-
function findSourceSibling(filePath, probeCache) {
|
|
227
|
+
function findSourceSibling(filePath, probeCache, siblings) {
|
|
229
228
|
for (const candidate of sourceTwinCandidates(filePath)) {
|
|
230
|
-
if (probeExists(candidate, probeCache))
|
|
229
|
+
if (probeExists(candidate, probeCache, siblings))
|
|
231
230
|
return candidate;
|
|
232
231
|
}
|
|
233
232
|
const ext = path2.extname(filePath).toLowerCase();
|
|
@@ -236,7 +235,7 @@ function findSourceSibling(filePath, probeCache) {
|
|
|
236
235
|
for (const [sourceExt, shadowedExts] of Object.entries(SOURCE_PRECEDENCE)) {
|
|
237
236
|
if (!sourceExtsForCompiledExt(sourceExt).length && shadowedExts.includes(ext)) {
|
|
238
237
|
const siblingPath = path2.join(dir, base + sourceExt);
|
|
239
|
-
if (probeExists(siblingPath, probeCache))
|
|
238
|
+
if (probeExists(siblingPath, probeCache, siblings))
|
|
240
239
|
return siblingPath;
|
|
241
240
|
}
|
|
242
241
|
}
|
|
@@ -245,8 +244,8 @@ function findSourceSibling(filePath, probeCache) {
|
|
|
245
244
|
function sourceExtsForCompiledExt(sourceExt) {
|
|
246
245
|
return sourceExt === ".ts" || sourceExt === ".tsx" || sourceExt === ".mts" || sourceExt === ".cts" ? [sourceExt] : [];
|
|
247
246
|
}
|
|
248
|
-
function isBuildArtifact(filePath, probeCache) {
|
|
249
|
-
return findSourceSibling(filePath, probeCache) !== null;
|
|
247
|
+
function isBuildArtifact(filePath, probeCache, siblings) {
|
|
248
|
+
return findSourceSibling(filePath, probeCache, siblings) !== null;
|
|
250
249
|
}
|
|
251
250
|
function filterSourceFiles(filePaths, options) {
|
|
252
251
|
const keep = [];
|
|
@@ -279,7 +278,7 @@ function resolveCollectionConfig(rootDir, options, config) {
|
|
|
279
278
|
options
|
|
280
279
|
};
|
|
281
280
|
}
|
|
282
|
-
function classifyEntry(entry, fullPath, cfg, probeCache, skipCounters) {
|
|
281
|
+
function classifyEntry(entry, fullPath, cfg, probeCache, skipCounters, siblings) {
|
|
283
282
|
const { ignoreMatcher, extraExcludePatterns, extensions, options } = cfg;
|
|
284
283
|
if (entry.isDirectory()) {
|
|
285
284
|
const canRecurse = shouldRecurseIntoDir(
|
|
@@ -307,7 +306,7 @@ function classifyEntry(entry, fullPath, cfg, probeCache, skipCounters) {
|
|
|
307
306
|
return {};
|
|
308
307
|
if (ignoreMatcher.isIgnored(fullPath, false))
|
|
309
308
|
return {};
|
|
310
|
-
if (isBuildArtifact(fullPath, probeCache)) {
|
|
309
|
+
if (isBuildArtifact(fullPath, probeCache, siblings)) {
|
|
311
310
|
if (skipCounters)
|
|
312
311
|
skipCounters.buildArtifactSkips += 1;
|
|
313
312
|
return {};
|
|
@@ -349,12 +348,12 @@ function collectSourceFilesWithBudget(dir, options) {
|
|
|
349
348
|
const probeCache = createArtifactProbeCache();
|
|
350
349
|
const budget = createEntryBudget(cfg.maxScanEntries);
|
|
351
350
|
const skipCounters = createSourceWalkSkipCounters();
|
|
352
|
-
walkTreeRecursiveSync(rootDir, (entry, fullPath) => {
|
|
351
|
+
walkTreeRecursiveSync(rootDir, (entry, fullPath, siblings) => {
|
|
353
352
|
if (kept.isFull())
|
|
354
353
|
return "stop";
|
|
355
354
|
if (!chargeEntryBudget(budget))
|
|
356
355
|
return "stop";
|
|
357
|
-
const { recurseInto, keepFile } = classifyEntry(entry, fullPath, cfg, probeCache, skipCounters);
|
|
356
|
+
const { recurseInto, keepFile } = classifyEntry(entry, fullPath, cfg, probeCache, skipCounters, siblings);
|
|
358
357
|
if (recurseInto)
|
|
359
358
|
return "recurse";
|
|
360
359
|
if (keepFile)
|
|
@@ -369,7 +368,8 @@ function collectSourceFilesWithBudget(dir, options) {
|
|
|
369
368
|
buildArtifactSkips: skipCounters.buildArtifactSkips,
|
|
370
369
|
generatedDirSkips: skipCounters.generatedDirSkips,
|
|
371
370
|
generatedNameOverrides: skipCounters.generatedNameOverrides,
|
|
372
|
-
generatedNameOnlySkips: skipCounters.generatedNameOnlySkips
|
|
371
|
+
generatedNameOnlySkips: skipCounters.generatedNameOnlySkips,
|
|
372
|
+
entriesVisited: budget.visited
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
375
|
function collectSourceFiles(dir, options) {
|
|
@@ -385,11 +385,11 @@ async function collectSourceFilesWithBudgetAsync(dir, options) {
|
|
|
385
385
|
const probeCache = createArtifactProbeCache();
|
|
386
386
|
const budget = createEntryBudget(cfg.maxScanEntries);
|
|
387
387
|
const skipCounters = createSourceWalkSkipCounters();
|
|
388
|
-
await walkTreeStackAsync(rootDir, (entry, fullPath) => {
|
|
388
|
+
await walkTreeStackAsync(rootDir, (entry, fullPath, siblings) => {
|
|
389
389
|
options?.onEntryVisited?.();
|
|
390
390
|
if (!chargeEntryBudget(budget))
|
|
391
391
|
return "stop";
|
|
392
|
-
const { recurseInto, keepFile } = classifyEntry(entry, fullPath, cfg, probeCache, skipCounters);
|
|
392
|
+
const { recurseInto, keepFile } = classifyEntry(entry, fullPath, cfg, probeCache, skipCounters, siblings);
|
|
393
393
|
if (recurseInto)
|
|
394
394
|
return "recurse";
|
|
395
395
|
if (keepFile) {
|
|
@@ -417,7 +417,8 @@ async function collectSourceFilesWithBudgetAsync(dir, options) {
|
|
|
417
417
|
buildArtifactSkips: skipCounters.buildArtifactSkips,
|
|
418
418
|
generatedDirSkips: skipCounters.generatedDirSkips,
|
|
419
419
|
generatedNameOverrides: skipCounters.generatedNameOverrides,
|
|
420
|
-
generatedNameOnlySkips: skipCounters.generatedNameOnlySkips
|
|
420
|
+
generatedNameOnlySkips: skipCounters.generatedNameOnlySkips,
|
|
421
|
+
entriesVisited: budget.visited
|
|
421
422
|
};
|
|
422
423
|
}
|
|
423
424
|
function getFilterStats(allFiles, filteredFiles) {
|