pi-lens 4.4.4 → 4.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/CHANGELOG.md +477 -0
  2. package/README.md +45 -3
  3. package/config/biome/core.jsonc +3 -3
  4. package/config/dependency-cruiser-eager-allowlist.json +1 -0
  5. package/dist/{chunk-UBOQLVT2.js → chunk-2DDDCJDL.js} +4 -4
  6. package/dist/{chunk-RKKOYPRA.js → chunk-2DMLM3ZO.js} +13 -15
  7. package/dist/chunk-2F47TQOA.js +73 -0
  8. package/dist/{chunk-O4NWQT6I.js → chunk-2PHMIAKO.js} +4 -4
  9. package/dist/{chunk-DGUKIYSI.js → chunk-2RLWJO5K.js} +8 -10
  10. package/dist/{chunk-S67KYG37.js → chunk-2X4VLOCC.js} +2 -2
  11. package/dist/{chunk-TIQ2PKDW.js → chunk-3MYEA7QD.js} +4 -4
  12. package/dist/{chunk-3DA2JDOL.js → chunk-3WEPUD2V.js} +551 -203
  13. package/dist/{chunk-AMERCH6V.js → chunk-4AVZ3TG7.js} +15 -16
  14. package/dist/{chunk-IYNJ6YPZ.js → chunk-4PCQCU47.js} +4 -4
  15. package/dist/chunk-4WX4CTUE.js +57 -0
  16. package/dist/{chunk-P63GXC37.js → chunk-5APMQ2IJ.js} +31 -4
  17. package/dist/{chunk-ZIVJBOO3.js → chunk-5CV5ITZF.js} +2 -2
  18. package/dist/{chunk-6DLWKFEX.js → chunk-5ZR3APIM.js} +41 -42
  19. package/dist/{chunk-XTBDCR27.js → chunk-63RIVFQI.js} +4 -4
  20. package/dist/{chunk-GSLNCYGG.js → chunk-75SY4F24.js} +13 -14
  21. package/dist/{chunk-U44DJXQP.js → chunk-7RQXA5GG.js} +15 -18
  22. package/dist/chunk-A3YNG5KP.js +45 -0
  23. package/dist/{chunk-5OFV52AM.js → chunk-AE37FEGH.js} +1 -1
  24. package/dist/{chunk-BWD5EPKO.js → chunk-AMXIUN2R.js} +4 -6
  25. package/dist/{chunk-3KAZU3VR.js → chunk-ARD426WI.js} +2 -2
  26. package/dist/{chunk-BW5KFIQC.js → chunk-AWQWXSW4.js} +1 -0
  27. package/dist/{chunk-YH5MVY2U.js → chunk-BHUWL2Y3.js} +7 -7
  28. package/dist/{chunk-CT4MN5IU.js → chunk-BI5LAQ3Y.js} +353 -359
  29. package/dist/{chunk-KAPJINKN.js → chunk-BM5GS6ZH.js} +2 -2
  30. package/dist/{chunk-TLX72JTG.js → chunk-BWYQUPOS.js} +1 -1
  31. package/dist/chunk-CFRQMBGP.js +49 -0
  32. package/dist/{chunk-RMLC67LF.js → chunk-CJYKEW2L.js} +2 -30
  33. package/dist/chunk-CKEQFGLT.js +32 -0
  34. package/dist/{chunk-IWDLU6K3.js → chunk-DC4CFXM5.js} +4 -6
  35. package/dist/{chunk-ZVUL7QYY.js → chunk-DMSLNKF7.js} +29 -32
  36. package/dist/{chunk-KN35K52N.js → chunk-DQXSPYRI.js} +3 -3
  37. package/dist/{chunk-HYGZEMX6.js → chunk-EVDGNG4F.js} +11 -5
  38. package/dist/{chunk-SRYEJNES.js → chunk-F5Z6URKM.js} +2 -2
  39. package/dist/{chunk-UMS2MFPZ.js → chunk-F6X3YJWD.js} +2 -3
  40. package/dist/{chunk-XYURS6EN.js → chunk-FA5LDARD.js} +15 -17
  41. package/dist/{chunk-24AKHFGP.js → chunk-FFL3A2VP.js} +6 -6
  42. package/dist/chunk-FJIVKLPH.js +31 -0
  43. package/dist/chunk-G2B7F6ZU.js +88 -0
  44. package/dist/{chunk-US7ECLD7.js → chunk-GAACZY6R.js} +131 -41
  45. package/dist/{chunk-MZGQNL3Y.js → chunk-GMTFDAOK.js} +12 -13
  46. package/dist/{chunk-VOOAPROD.js → chunk-GNSIWBAT.js} +3 -3
  47. package/dist/chunk-GTAI2J6U.js +27 -0
  48. package/dist/{chunk-RVK72CZX.js → chunk-GZE7WOI4.js} +1362 -459
  49. package/dist/{chunk-IUE7SSKV.js → chunk-H7HTEQUZ.js} +13 -7
  50. package/dist/{chunk-EUXZEFTV.js → chunk-HK6JVFZC.js} +3 -3
  51. package/dist/chunk-IPDG45G5.js +26 -0
  52. package/dist/{chunk-5HSRT26B.js → chunk-J6JP25XU.js} +16 -15
  53. package/dist/{chunk-HWCCCQNX.js → chunk-JL6CXUMW.js} +13 -6
  54. package/dist/{chunk-EBC36LNN.js → chunk-K2YGBXOA.js} +17 -17
  55. package/dist/{chunk-WMYE35PX.js → chunk-KLQVC3XC.js} +7 -5
  56. package/dist/{chunk-ATKJFDQN.js → chunk-KSR7RGQY.js} +12 -14
  57. package/dist/{chunk-POMLXPMY.js → chunk-KXF5R4UN.js} +1 -1
  58. package/dist/{chunk-LLJNQKQW.js → chunk-LEJOJDXL.js} +20 -13
  59. package/dist/{chunk-JUKMK5Y4.js → chunk-MA77RSFN.js} +10 -11
  60. package/dist/{chunk-GAQ7OQG6.js → chunk-MKVZQUEG.js} +85 -96
  61. package/dist/{chunk-2EECBNC5.js → chunk-MN7MHUXQ.js} +75 -0
  62. package/dist/{chunk-DEL2U6CM.js → chunk-MT6BVNFW.js} +16 -14
  63. package/dist/chunk-NDMCVUYK.js +507 -0
  64. package/dist/{chunk-HRNHZA3N.js → chunk-NIU2IPC5.js} +12 -16
  65. package/dist/{chunk-AGSS7277.js → chunk-NNKXDXXS.js} +7 -24
  66. package/dist/{chunk-V35JG4JB.js → chunk-OJLTLYHB.js} +152 -334
  67. package/dist/{chunk-J6MPGQTS.js → chunk-OLAWH5UQ.js} +81 -15
  68. package/dist/{chunk-T57LYLZT.js → chunk-OOU2WZZE.js} +1 -1
  69. package/dist/{chunk-CYRKQRPM.js → chunk-OSTKYB55.js} +2 -4
  70. package/dist/chunk-P4QNXS6I.js +27 -0
  71. package/dist/chunk-PKES3ISE.js +297 -0
  72. package/dist/{chunk-ROYSX2S5.js → chunk-PO45POGF.js} +2 -2
  73. package/dist/{chunk-T7FEBKXN.js → chunk-PPIBVH4R.js} +7 -9
  74. package/dist/{chunk-3RKP3FMS.js → chunk-PQJFG24Z.js} +295 -23
  75. package/dist/{chunk-KUA4OJ5Y.js → chunk-Q3UZHW6N.js} +846 -350
  76. package/dist/{chunk-N5FLEO7W.js → chunk-Q4EMRFNA.js} +37 -37
  77. package/dist/{chunk-5IUSNGOC.js → chunk-Q4FCYCRE.js} +28 -21
  78. package/dist/chunk-Q6D6VMI4.js +22 -0
  79. package/dist/{chunk-UZ2XCLYS.js → chunk-QGSTQH4D.js} +8 -8
  80. package/dist/{chunk-DUO2TU77.js → chunk-RZOXUSPC.js} +10 -4
  81. package/dist/{chunk-JMYYOTQG.js → chunk-S26LC76R.js} +13 -1
  82. package/dist/{chunk-GMX5OS7B.js → chunk-S67UJDGQ.js} +11 -12
  83. package/dist/chunk-SCIUNBPF.js +44 -0
  84. package/dist/{chunk-RKBXZN3A.js → chunk-SJJYRZB4.js} +2 -2
  85. package/dist/chunk-SXGD4ANG.js +25 -0
  86. package/dist/{chunk-YCWYO6TQ.js → chunk-T7FTXGS3.js} +48 -45
  87. package/dist/{chunk-FM4RDMKT.js → chunk-TIQJPRDD.js} +115 -61
  88. package/dist/{chunk-XHJBS436.js → chunk-TIYGSODX.js} +25 -25
  89. package/dist/{chunk-S2HEXIWI.js → chunk-U2SDMG7C.js} +10 -6
  90. package/dist/{chunk-2KXTHF3M.js → chunk-U6OC3QEM.js} +253 -33
  91. package/dist/{chunk-AWSCPCN2.js → chunk-UCGQT677.js} +19 -19
  92. package/dist/chunk-UHGF5UT5.js +32 -0
  93. package/dist/{chunk-JW3YWBVB.js → chunk-UN4TEBWN.js} +17 -19
  94. package/dist/{chunk-ZHH37KZL.js → chunk-V3APN3DY.js} +17 -17
  95. package/dist/{chunk-ED36RF6Y.js → chunk-V63BC55Q.js} +1 -1
  96. package/dist/{chunk-XBJVAEEO.js → chunk-VG5JS5SW.js} +3 -2
  97. package/dist/{chunk-W66O5E25.js → chunk-VPBIMOAQ.js} +13 -15
  98. package/dist/chunk-VQH24FIP.js +37 -0
  99. package/dist/{chunk-YNE3RP52.js → chunk-VSFLRN5Y.js} +8 -1
  100. package/dist/{chunk-7D6L4MTX.js → chunk-W2V54OCL.js} +3 -3
  101. package/dist/{chunk-2FN63LPV.js → chunk-W5LGKNET.js} +13 -14
  102. package/dist/{chunk-IQWN5JCP.js → chunk-W5R5SABV.js} +13 -14
  103. package/dist/{chunk-R3T7CLQ2.js → chunk-WIZWZR4C.js} +41 -41
  104. package/dist/{chunk-TOY6QKOH.js → chunk-WQOIR3QY.js} +17 -17
  105. package/dist/{chunk-Y6GZHWSJ.js → chunk-XAIT2YGS.js} +6 -6
  106. package/dist/chunk-XCUHKYCQ.js +23 -0
  107. package/dist/{chunk-GSM5UU7A.js → chunk-XQCSWV2G.js} +44 -35
  108. package/dist/{chunk-OHKJ7PQF.js → chunk-YBSONGSZ.js} +43 -39
  109. package/dist/{chunk-GXFV6MYU.js → chunk-YISME6ON.js} +72 -39
  110. package/dist/chunk-YRD4ISED.js +30 -0
  111. package/dist/{chunk-SD4I7ZO4.js → chunk-YSBHPOY6.js} +43 -53
  112. package/dist/{chunk-QBFBRV2B.js → chunk-Z2XAOKHK.js} +4 -2
  113. package/dist/{chunk-5VSF4UUQ.js → chunk-Z7IGUAXL.js} +34 -39
  114. package/dist/{chunk-MPNJLASA.js → chunk-ZKXQKGWZ.js} +10 -13
  115. package/dist/{chunk-J64T55EI.js → chunk-ZQ6NZZTB.js} +75 -9
  116. package/dist/chunk-ZUUI3ZSA.js +38 -0
  117. package/dist/{chunk-7HXE67BN.js → chunk-ZYNI26MI.js} +2 -2
  118. package/dist/index.js +32674 -27567
  119. package/dist/mcp/analyze-cli.js +11 -12
  120. package/dist/mcp/cli.js +46 -45
  121. package/dist/mcp/server.js +1210 -574
  122. package/dist/mcp/worker.js +65 -65
  123. package/dist/probes/installer.js +21 -23
  124. package/docs/adr/0010-trace-validation-session-lifecycle.md +390 -0
  125. package/docs/adr/README.md +1 -0
  126. package/docs/agent-tools.md +28 -7
  127. package/docs/ast-grep_rules_catalog.md +5 -3
  128. package/docs/configuration.md +12 -1
  129. package/docs/defect-shapes.md +738 -0
  130. package/docs/engineering-principles.md +12 -0
  131. package/docs/environment-variables.md +20 -0
  132. package/docs/features.md +16 -1
  133. package/docs/globalconfig.md +37 -8
  134. package/docs/invariants/caches-stores.md +30 -0
  135. package/docs/invariants/dispatch-runners.md +164 -0
  136. package/docs/invariants/git-guard-host.md +53 -0
  137. package/docs/invariants/language-config.md +31 -0
  138. package/docs/invariants/lsp-trust-exec.md +286 -0
  139. package/docs/invariants/paths-os.md +59 -0
  140. package/docs/invariants/session-telemetry.md +74 -0
  141. package/docs/lsp-capability-matrix.md +105 -12
  142. package/docs/lsp-idle-eviction.md +37 -18
  143. package/docs/pi-lens-fixer.md +24 -2
  144. package/docs/pi-lens-investigator.md +14 -0
  145. package/docs/pi-lens-merge-policy.md +32 -17
  146. package/docs/pi-lens-monitor.md +66 -10
  147. package/docs/pi-lens-orchestration.md +41 -0
  148. package/docs/pi-lens-release.md +20 -0
  149. package/docs/pi-lens-retro.md +5 -4
  150. package/docs/pi-lens-reviewer.md +54 -7
  151. package/docs/pi-lens-subagent.md +10 -3
  152. package/docs/release-qa-baseline.md +19 -7
  153. package/docs/servercapabilities.md +47 -47
  154. package/docs/settings.md +9 -5
  155. package/docs/subagent-compat.md +1 -1
  156. package/docs/usage.md +1 -0
  157. package/package.json +8 -5
  158. package/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +17 -0
  159. package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-js-test.yml +86 -0
  160. package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-test.yml +86 -0
  161. package/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +15 -0
  162. package/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +9 -4
  163. package/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +119 -0
  164. package/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +119 -0
  165. package/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +13 -2
  166. package/rules/rule-catalog.json +25 -1
  167. package/scripts/analyze-pi-lens-logs.mjs +15 -5
  168. package/scripts/lib/is-main-module.mjs +27 -0
  169. package/scripts/lib/scratch-home-env.mjs +21 -0
  170. package/scripts/rpc-load-check.mjs +4 -6
  171. package/scripts/warm-loader-cache.mjs +2 -5
  172. package/dist/chunk-3PTHXJXR.js +0 -28
  173. package/dist/chunk-3QED2P4V.js +0 -31
  174. package/dist/chunk-5WRPDP2A.js +0 -47
  175. package/dist/chunk-ABBOA7UD.js +0 -157
  176. package/dist/chunk-CUHSHSB6.js +0 -273
  177. package/dist/chunk-GL5LUMZE.js +0 -51
  178. package/dist/chunk-HAD7QRQI.js +0 -30
  179. package/dist/chunk-JORED7EX.js +0 -44
  180. package/dist/chunk-KYUB6QDC.js +0 -72
  181. package/dist/chunk-LZSEQW6A.js +0 -57
  182. package/dist/chunk-M2IFVFWU.js +0 -79
  183. package/dist/chunk-M2UD3LPU.js +0 -88
  184. package/dist/chunk-MBKQHGA7.js +0 -39
  185. package/dist/chunk-R7YOCSNV.js +0 -23
  186. package/dist/chunk-SKAMFC7A.js +0 -28
  187. package/dist/chunk-SYE6T2EB.js +0 -28
  188. package/dist/chunk-TRETHTQO.js +0 -26
  189. package/dist/chunk-UA7ZXYDR.js +0 -184
  190. package/dist/chunk-XTFDJI3T.js +0 -24
  191. package/dist/chunk-Z3CCVDUB.js +0 -76
@@ -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-GXFV6MYU.js";
8
+ } from "./chunk-ZUUI3ZSA.js";
10
9
  import {
11
10
  getPackageRoot,
12
11
  js_yaml_default,
13
12
  resolvePackagePath
14
- } from "./chunk-FM4RDMKT.js";
13
+ } from "./chunk-TIQJPRDD.js";
14
+ import {
15
+ EXTENSION_TO_GRAMMAR
16
+ } from "./chunk-YISME6ON.js";
17
+ import {
18
+ withTimeout
19
+ } from "./chunk-CJYKEW2L.js";
15
20
  import {
16
21
  transientRetryDelayMs
17
- } from "./chunk-P63GXC37.js";
22
+ } from "./chunk-5APMQ2IJ.js";
18
23
  import {
19
24
  getProjectIgnoreMatcher,
20
25
  isExcludedDirName
21
- } from "./chunk-KUA4OJ5Y.js";
26
+ } from "./chunk-Q3UZHW6N.js";
22
27
  import {
23
28
  notifyUserDegradation
24
- } from "./chunk-J6MPGQTS.js";
29
+ } from "./chunk-OLAWH5UQ.js";
25
30
  import {
26
31
  assertInstallAllowed,
27
- getProjectTrustGeneration
28
- } from "./chunk-M2IFVFWU.js";
29
- import {
32
+ getProjectTrustGeneration,
30
33
  writeFileAtomic
31
- } from "./chunk-2EECBNC5.js";
34
+ } from "./chunk-MN7MHUXQ.js";
32
35
  import {
33
36
  compareOrdinal,
34
37
  escapeRegExp,
@@ -36,20 +39,22 @@ import {
36
39
  incrementDegradationCount,
37
40
  recordDegradation,
38
41
  recordDegradationOnce
39
- } from "./chunk-J64T55EI.js";
42
+ } from "./chunk-ZQ6NZZTB.js";
43
+ import {
44
+ logLatency
45
+ } from "./chunk-Z2XAOKHK.js";
40
46
  import {
41
47
  createNdjsonLogger,
42
48
  getGlobalPiLensLogDir,
43
49
  getMaxLogSizeMB,
44
50
  isTestMode
45
- } from "./chunk-YNE3RP52.js";
46
- import {
47
- BoundedFifoMap
48
- } from "./chunk-ABBOA7UD.js";
51
+ } from "./chunk-VSFLRN5Y.js";
49
52
  import {
53
+ BoundedFifoMap,
50
54
  normalizeFilePath,
51
- normalizeLoggedPath
52
- } from "./chunk-3RKP3FMS.js";
55
+ normalizeLoggedPath,
56
+ walkUpDirs
57
+ } from "./chunk-PQJFG24Z.js";
53
58
 
54
59
  // dist/clients/tree-sitter-logger.js
55
60
  import * as path from "node:path";
@@ -372,6 +377,7 @@ async function downloadGrammarDetailed(destDir, filename, options = {}) {
372
377
  }
373
378
  }
374
379
  var GRAMMAR_STALL_MS = 15e3;
380
+ var GRAMMAR_LOAD_TIMEOUT_MS = 3e4;
375
381
  function armStallBound(ms) {
376
382
  const controller = new AbortController();
377
383
  const timer = setTimeout(() => controller.abort(), ms);
@@ -1520,7 +1526,18 @@ function getBundledQueriesRootHealth() {
1520
1526
  const generation = getDegradationLedgerGeneration();
1521
1527
  if (cachedBundledQueriesRootHealth === void 0 || cachedBundledQueriesRootHealthGeneration !== generation) {
1522
1528
  cachedBundledQueriesRootHealthGeneration = generation;
1523
- cachedBundledQueriesRootHealth = classifyBundledResourceDir(BUNDLED_QUERIES_ROOT);
1529
+ const health = classifyBundledResourceDir(BUNDLED_QUERIES_ROOT);
1530
+ cachedBundledQueriesRootHealth = health;
1531
+ logLatency({
1532
+ type: "phase",
1533
+ phase: "tree_sitter_queries_root_checked",
1534
+ filePath: BUNDLED_QUERIES_ROOT,
1535
+ durationMs: 0,
1536
+ metadata: {
1537
+ status: health.status,
1538
+ entryCount: health.status === "healthy" ? health.entryCount : 0
1539
+ }
1540
+ });
1524
1541
  }
1525
1542
  return cachedBundledQueriesRootHealth;
1526
1543
  }
@@ -2017,20 +2034,21 @@ function createParserCounters() {
2017
2034
  parserFailures: 0
2018
2035
  };
2019
2036
  }
2037
+ function isGrammarLoadTimeout(err) {
2038
+ return err instanceof Error && err.message === `Timeout after ${GRAMMAR_LOAD_TIMEOUT_MS}ms`;
2039
+ }
2020
2040
  function grammarWriteBlockedReason(dir) {
2021
- let probe = dir;
2022
- while (!fs5.existsSync(probe)) {
2023
- const parent = path4.dirname(probe);
2024
- if (parent === probe)
2025
- return "ENOENT";
2026
- probe = parent;
2027
- }
2028
- try {
2029
- fs5.accessSync(probe, fs5.constants.W_OK);
2030
- return void 0;
2031
- } catch (err) {
2032
- return err?.code ?? "EACCES";
2041
+ for (const candidate of walkUpDirs(dir)) {
2042
+ if (!fs5.existsSync(candidate))
2043
+ continue;
2044
+ try {
2045
+ fs5.accessSync(candidate, fs5.constants.W_OK);
2046
+ return void 0;
2047
+ } catch (err) {
2048
+ return err?.code ?? "EACCES";
2049
+ }
2033
2050
  }
2051
+ return "ENOENT";
2034
2052
  }
2035
2053
  function grammarFileStamp(filePath) {
2036
2054
  try {
@@ -3023,7 +3041,7 @@ var TreeSitterClient = class _TreeSitterClient {
3023
3041
  this.grammarFailureAttempts.set(grammarFile, attempts);
3024
3042
  const retryDelayMs = retryable ? transientRetryDelayMs(attempts, "probe-timeout") : void 0;
3025
3043
  this.grammarRetryAtMs.set(grammarFile, retryDelayMs === void 0 ? Number.POSITIVE_INFINITY : Date.now() + retryDelayMs);
3026
- 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.`;
3044
+ 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.`;
3027
3045
  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;
3028
3046
  logTreeSitterDiagnostic({
3029
3047
  subsystem: "tree-sitter-client",
@@ -3049,7 +3067,8 @@ var TreeSitterClient = class _TreeSitterClient {
3049
3067
  // failures used to share one string, so the ledger could not tell an
3050
3068
  // offline laptop from a captive portal serving HTML — the two need
3051
3069
  // different user actions, and the ledger is what a bug report shows.
3052
- reason: retryable ? `runtime grammar download failed \u2014 retryable (${detail.trim()})` : `runtime grammar download failed \u2014 durable (${detail.trim()})`
3070
+ // A hung load of a file already on disk is not a download failure (#4224).
3071
+ 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()})`
3053
3072
  });
3054
3073
  this.refreshGrammarSessionLatches();
3055
3074
  const notifyKey = retryDelayMs ?? -1;
@@ -3087,7 +3106,7 @@ var TreeSitterClient = class _TreeSitterClient {
3087
3106
  * redownload land the identical bytes and spin the ladder against a file
3088
3107
  * that can never pass.
3089
3108
  */
3090
- recordGrammarLoadFailure(grammarPath, grammarFile, err) {
3109
+ recordGrammarLoadFailure(grammarPath, grammarFile, err, cause) {
3091
3110
  const stamp = grammarFileStamp(grammarPath);
3092
3111
  this.verifiedGrammarPaths.delete(grammarPath);
3093
3112
  if (stamp)
@@ -3096,16 +3115,73 @@ var TreeSitterClient = class _TreeSitterClient {
3096
3115
  logTreeSitterDiagnostic({
3097
3116
  subsystem: "tree-sitter-client",
3098
3117
  level: "warn",
3099
- 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.`,
3118
+ 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.`,
3100
3119
  metadata: { grammarFile, path: grammarPath, outcome: "load-failed" }
3101
3120
  });
3102
3121
  this.recordGrammarFailure(
3103
3122
  grammarFile,
3104
3123
  `Language.load failed on a resolved grammar file (${message}).`,
3105
3124
  /* retryable */
3106
- true
3125
+ true,
3126
+ cause
3107
3127
  );
3108
3128
  }
3129
+ /**
3130
+ * Watch a `Language.load` that the bound abandoned (#4224). web-tree-sitter
3131
+ * gives the load no abort, so it keeps running and settles later, and
3132
+ * `withDeadline` hands that late settle to a catch that records nothing.
3133
+ * Mirrors #1716's late-answer watch on a timed-out nav request.
3134
+ *
3135
+ * Every late failure is logged once to `tree-sitter.log`. Then:
3136
+ *
3137
+ * - An Emscripten abort kills the runtime whenever it lands, so it reaches
3138
+ * the same latch an on-time abort does (AGENTS.md shape 60). A trap takes
3139
+ * the other arm, as it does on time: charged to the grammar, not the budget.
3140
+ * - Any other failure says the load ended rather than hung. It leaves one
3141
+ * bounded `grammar-blocked` record naming the grammar and the failure. The
3142
+ * timeout already notified the user and climbed the cooldown ladder for
3143
+ * this load, so neither happens again.
3144
+ * - A late success is dropped. The caller was answered null and the grammar
3145
+ * sits on its cooldown, so keeping the language would make the answer depend
3146
+ * on when the load happened to finish.
3147
+ *
3148
+ * One abandoned load has one watch, so a late settle is one record however
3149
+ * many callers joined the build that started it.
3150
+ *
3151
+ * No caller awaits the watch, so it ends in a logging catch: a handler that
3152
+ * throws (the host's `onWasmAbort` can) is written to `tree-sitter.log`
3153
+ * rather than escaping as an unhandled rejection.
3154
+ */
3155
+ observeAbandonedLoad(loading, grammarPath, grammarFile) {
3156
+ loading.then(() => {
3157
+ this.dbg(`Abandoned Language.load for ${grammarFile} succeeded after the bound; ignored`);
3158
+ }, (late) => {
3159
+ const message = late instanceof Error ? late.message : String(late);
3160
+ logTreeSitterDiagnostic({
3161
+ subsystem: "tree-sitter-client",
3162
+ level: "warn",
3163
+ message: `Language.load for ${grammarPath} settled after its ${GRAMMAR_LOAD_TIMEOUT_MS}ms bound and failed (${message}).`,
3164
+ metadata: { grammarFile, outcome: "late-load-failed" }
3165
+ });
3166
+ if (classifyTreeSitterWasmError(late) === "abort") {
3167
+ this.reportWasmAbort(late);
3168
+ } else {
3169
+ incrementDegradationCount({
3170
+ kind: "grammar-blocked",
3171
+ subject: grammarFile,
3172
+ reason: `Language.load failed after its ${GRAMMAR_LOAD_TIMEOUT_MS}ms bound (${message}).`
3173
+ });
3174
+ }
3175
+ }).catch((handlerErr) => {
3176
+ const message = handlerErr instanceof Error ? handlerErr.message : String(handlerErr);
3177
+ logTreeSitterDiagnostic({
3178
+ subsystem: "tree-sitter-client",
3179
+ level: "warn",
3180
+ message: `The late-settle handler for Language.load of ${grammarPath} threw (${message}).`,
3181
+ metadata: { grammarFile, outcome: "late-load-handler-failed" }
3182
+ });
3183
+ });
3184
+ }
3109
3185
  /** Initialize tree-sitter WASM runtime */
3110
3186
  async init() {
3111
3187
  if (this.wasmAborted)
@@ -3220,28 +3296,42 @@ var TreeSitterClient = class _TreeSitterClient {
3220
3296
  this.dbg(`Grammar file not found: ${grammarPath}`);
3221
3297
  return null;
3222
3298
  }
3299
+ let loading;
3223
3300
  try {
3224
3301
  if (!this.LanguageLoader?.load) {
3225
3302
  this.dbg(`LanguageLoader.load not available`);
3226
3303
  return null;
3227
3304
  }
3228
3305
  this.dbg(`Calling Language.load...`);
3229
- const language = await this.LanguageLoader.load(grammarPath);
3306
+ const started = this.LanguageLoader.load(grammarPath);
3307
+ loading = started;
3308
+ const language = await withTimeout(started, GRAMMAR_LOAD_TIMEOUT_MS);
3230
3309
  this.dbg(`Language loaded: ${language?.name || "unknown"}`);
3231
3310
  if (language) {
3232
3311
  this.languages.set(languageId, language);
3233
3312
  }
3234
3313
  return language;
3235
3314
  } catch (err) {
3236
- if (classifyTreeSitterWasmError(err) === "abort") {
3237
- this.reportWasmAbort(err);
3238
- } else {
3239
- this.recordGrammarLoadFailure(grammarPath, grammarFile, err);
3240
- }
3315
+ this.recordLanguageLoadFailure(err, loading, grammarPath, grammarFile);
3241
3316
  this.dbg(`Language load error: ${err}`);
3242
3317
  return null;
3243
3318
  }
3244
3319
  }
3320
+ /**
3321
+ * The one place a failed `Language.load` is recorded, so every path out of
3322
+ * `loadLanguage`'s catch publishes something.
3323
+ */
3324
+ recordLanguageLoadFailure(err, loading, grammarPath, grammarFile) {
3325
+ const abandoned = isGrammarLoadTimeout(err) ? loading : void 0;
3326
+ if (abandoned) {
3327
+ this.observeAbandonedLoad(abandoned, grammarPath, grammarFile);
3328
+ }
3329
+ if (classifyTreeSitterWasmError(err) === "abort") {
3330
+ this.reportWasmAbort(err);
3331
+ } else {
3332
+ this.recordGrammarLoadFailure(grammarPath, grammarFile, err, abandoned ? "load-timed-out" : void 0);
3333
+ }
3334
+ }
3245
3335
  /** Get or create parser for a language */
3246
3336
  async getParser(languageId) {
3247
3337
  if (this.wasmAborted)
@@ -1,23 +1,22 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  parseSymbolKey
4
- } from "./chunk-7D6L4MTX.js";
4
+ } from "./chunk-W2V54OCL.js";
5
5
  import {
6
6
  isTestRoleCollateral
7
- } from "./chunk-5OFV52AM.js";
7
+ } from "./chunk-AE37FEGH.js";
8
8
  import "./chunk-3MED75HT.js";
9
- import "./chunk-KUA4OJ5Y.js";
10
- import "./chunk-J6MPGQTS.js";
11
- import "./chunk-5HSRT26B.js";
12
- import "./chunk-2EECBNC5.js";
13
- import "./chunk-J64T55EI.js";
14
- import "./chunk-POMLXPMY.js";
15
- import "./chunk-JMYYOTQG.js";
16
- import "./chunk-QBFBRV2B.js";
17
- import "./chunk-YNE3RP52.js";
9
+ import "./chunk-Q3UZHW6N.js";
10
+ import "./chunk-OLAWH5UQ.js";
11
+ import "./chunk-J6JP25XU.js";
12
+ import "./chunk-MN7MHUXQ.js";
13
+ import "./chunk-ZQ6NZZTB.js";
14
+ import "./chunk-KXF5R4UN.js";
15
+ import "./chunk-S26LC76R.js";
16
+ import "./chunk-Z2XAOKHK.js";
17
+ import "./chunk-VSFLRN5Y.js";
18
18
  import "./chunk-LJDODBBZ.js";
19
- import "./chunk-ABBOA7UD.js";
20
- import "./chunk-3RKP3FMS.js";
19
+ import "./chunk-PQJFG24Z.js";
21
20
  import "./chunk-NXL4FFQQ.js";
22
21
 
23
22
  // dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  createSubsystemLogger
4
- } from "./chunk-POMLXPMY.js";
5
- import "./chunk-YNE3RP52.js";
6
- import "./chunk-3RKP3FMS.js";
4
+ } from "./chunk-KXF5R4UN.js";
5
+ import "./chunk-VSFLRN5Y.js";
6
+ import "./chunk-PQJFG24Z.js";
7
7
  import "./chunk-NXL4FFQQ.js";
8
8
 
9
9
  // dist/clients/metrics-client.js
@@ -0,0 +1,27 @@
1
+ import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
+ import {
3
+ GoClient,
4
+ goClient,
5
+ resetGoAvailability
6
+ } from "./chunk-PO45POGF.js";
7
+ import "./chunk-EVDGNG4F.js";
8
+ import "./chunk-ARD426WI.js";
9
+ import "./chunk-5APMQ2IJ.js";
10
+ import "./chunk-Q3UZHW6N.js";
11
+ import "./chunk-AWQWXSW4.js";
12
+ import "./chunk-OLAWH5UQ.js";
13
+ import "./chunk-J6JP25XU.js";
14
+ import "./chunk-MN7MHUXQ.js";
15
+ import "./chunk-ZQ6NZZTB.js";
16
+ import "./chunk-KXF5R4UN.js";
17
+ import "./chunk-S26LC76R.js";
18
+ import "./chunk-Z2XAOKHK.js";
19
+ import "./chunk-VSFLRN5Y.js";
20
+ import "./chunk-LJDODBBZ.js";
21
+ import "./chunk-PQJFG24Z.js";
22
+ import "./chunk-NXL4FFQQ.js";
23
+ export {
24
+ GoClient,
25
+ goClient,
26
+ resetGoAvailability
27
+ };