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
@@ -1,23 +1,23 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  resolveToolCwd
4
- } from "./chunk-DEL2U6CM.js";
4
+ } from "./chunk-MT6BVNFW.js";
5
5
  import {
6
6
  allAvailableGlobalBinDirs,
7
7
  installArgs,
8
8
  pmBinary,
9
9
  resolveNodePackageManager
10
- } from "./chunk-5VSF4UUQ.js";
10
+ } from "./chunk-Z7IGUAXL.js";
11
11
  import {
12
12
  probeToolAsync
13
- } from "./chunk-3KAZU3VR.js";
13
+ } from "./chunk-ARD426WI.js";
14
14
  import {
15
15
  TRANSIENT_MAX_COOLDOWN_MS,
16
16
  classifyProbeFailure,
17
17
  createAvailabilityLatch,
18
18
  logAvailabilityDecision,
19
19
  startHostStallSampler
20
- } from "./chunk-P63GXC37.js";
20
+ } from "./chunk-5APMQ2IJ.js";
21
21
  import {
22
22
  acquireBoundedPidFileLock,
23
23
  acquireQuarantinePidFileLock,
@@ -25,52 +25,50 @@ import {
25
25
  getGlobalPiLensDir,
26
26
  heartbeatIntervalMs,
27
27
  isLockContention,
28
+ isUntrustedProjectPath,
28
29
  ownsTopGeneration,
29
30
  recordGenerationTakeover,
30
31
  recordLegacyLockHeld,
32
+ recordProjectCommandRefusal,
31
33
  releaseGeneration,
32
34
  resetSafeSpawnWindowsCommandCache,
33
35
  safeSpawnAsync,
34
36
  startGenerationHeartbeat,
35
37
  tryAcquireGeneration
36
- } from "./chunk-KUA4OJ5Y.js";
38
+ } from "./chunk-Q3UZHW6N.js";
37
39
  import {
38
40
  assertInstallAllowed,
39
- projectTrustDenialReason
40
- } from "./chunk-M2IFVFWU.js";
41
- import {
42
- DEFAULT_MAX_OUTPUT_BYTES,
43
- createBoundedOutputSink,
41
+ getProjectTrustGeneration,
42
+ projectTrustDenialReason,
44
43
  writeFileAtomic,
45
44
  writeFileAtomicAsync
46
- } from "./chunk-2EECBNC5.js";
45
+ } from "./chunk-MN7MHUXQ.js";
47
46
  import {
48
47
  getDegradationLedgerGeneration,
49
48
  incrementDegradationCount,
50
49
  recordDegradationOnce
51
- } from "./chunk-J64T55EI.js";
50
+ } from "./chunk-ZQ6NZZTB.js";
52
51
  import {
53
52
  logExtension
54
- } from "./chunk-POMLXPMY.js";
53
+ } from "./chunk-KXF5R4UN.js";
55
54
  import {
56
55
  createNdjsonLogger,
57
56
  getGlobalPiLensLogDir,
58
57
  getMaxLogSizeMB,
59
58
  isTestMode
60
- } from "./chunk-YNE3RP52.js";
61
- import {
62
- BoundedLruCache
63
- } from "./chunk-ABBOA7UD.js";
59
+ } from "./chunk-VSFLRN5Y.js";
64
60
  import {
61
+ BoundedLruCache,
65
62
  findLocalToolConfig,
66
- isFullyQualified
67
- } from "./chunk-3RKP3FMS.js";
63
+ isFullyQualified,
64
+ isUnderDir,
65
+ realpathOrResolve
66
+ } from "./chunk-PQJFG24Z.js";
68
67
  import {
69
68
  __require
70
69
  } from "./chunk-NXL4FFQQ.js";
71
70
 
72
71
  // dist/clients/installer/index.js
73
- import { spawn } from "node:child_process";
74
72
  import { existsSync, readFileSync as readFileSync2, statSync, unlinkSync, writeFileSync } from "node:fs";
75
73
  import fs2 from "node:fs/promises";
76
74
  import { createHash, randomUUID } from "node:crypto";
@@ -331,6 +329,8 @@ async function resolveGitHubToken(envKeys = ["GITHUB_TOKEN", "GH_TOKEN"], option
331
329
  // dist/clients/installer/index.js
332
330
  var _installerRequire = createRequire(import.meta.url);
333
331
  var TOOLS_DIR = path3.join(getGlobalPiLensDir(), "tools");
332
+ var USER_BASE_PROBE_TIMEOUT_MS = 5e3;
333
+ var ARCHIVE_COMMAND_TIMEOUT_MS = 12e4;
334
334
  var INSTALL_LOCK_PATH = path3.join(TOOLS_DIR, ".install.lock");
335
335
  var INSTALL_LOCK_GENERATIONS = `${INSTALL_LOCK_PATH}s`;
336
336
  var activeInstallLocks = /* @__PURE__ */ new Set();
@@ -465,7 +465,24 @@ async function acquireInstallLock() {
465
465
  reason: `timed out after ${timeoutMs}ms waiting for shared tools install lock (${installLockOwner()})`
466
466
  };
467
467
  }
468
- var GITHUB_BIN_DIR = path3.join(getGlobalPiLensDir(), "bin");
468
+ var GLOBAL_HOME_DIR = getGlobalPiLensDir();
469
+ var GITHUB_BIN_DIR = path3.join(GLOBAL_HOME_DIR, "bin");
470
+ var GITHUB_BIN_DIR_PINNED = Boolean(process.env.PI_LENS_HOME?.trim());
471
+ function assertManagedBinDirInsidePinnedHome(toolId) {
472
+ if (!GITHUB_BIN_DIR_PINNED)
473
+ return;
474
+ const home = realpathOrResolve(GLOBAL_HOME_DIR);
475
+ const bin = realpathOrResolve(GITHUB_BIN_DIR);
476
+ if (isUnderDir(bin, home))
477
+ return;
478
+ const reason = `bin directory escapes the pinned PI_LENS_HOME: ${GITHUB_BIN_DIR} resolves to ${bin}, outside ${home}; refusing to write through the link`;
479
+ recordDegradationOnce({
480
+ kind: "managed-tool-install",
481
+ subject: `${toolId}:bin-dir-escape`,
482
+ reason
483
+ });
484
+ throw new Error(reason);
485
+ }
469
486
  var DEBUG = process.env.PI_LENS_DEBUG === "1" || process.argv.includes("--debug");
470
487
  function installerPlatform() {
471
488
  const override = process.env.PI_LENS_TEST_PLATFORM;
@@ -734,8 +751,8 @@ var TOOLS = [
734
751
  checkCommand: "jscpd",
735
752
  checkArgs: ["--version"],
736
753
  installStrategy: "npm",
737
- packageName: "jscpd@5.4.1",
738
- // v5.4.1 is the repository's exact devDependency; the v4 packaging defect that required the older v5.0.12 pin is gone, and parseReport() reads the unchanged clone-report fields.
754
+ packageName: "jscpd@5.4.2",
755
+ // v5.4.2 is the repository's exact devDependency; the v4 packaging defect that required the older v5.0.12 pin is gone, and parseReport() reads the unchanged clone-report fields.
739
756
  binaryName: "jscpd"
740
757
  },
741
758
  // Structural search and dead code detection
@@ -2091,12 +2108,16 @@ async function isCommandAvailable(command, _args) {
2091
2108
  if (!dir)
2092
2109
  continue;
2093
2110
  for (const name of names) {
2094
- const candidate = path3.join(dir, name);
2111
+ const candidate = isWindows ? path3.join(dir, name) : `${dir}${path3.sep}${name}`;
2095
2112
  try {
2096
2113
  const stat = statSync(candidate);
2097
- if (stat.isFile() && stat.size > 0) {
2098
- return true;
2114
+ if (!stat.isFile() || stat.size === 0)
2115
+ continue;
2116
+ if (isUntrustedProjectPath(candidate)) {
2117
+ recordProjectCommandRefusal(candidate);
2118
+ continue;
2099
2119
  }
2120
+ return true;
2100
2121
  } catch {
2101
2122
  }
2102
2123
  }
@@ -2104,7 +2125,8 @@ async function isCommandAvailable(command, _args) {
2104
2125
  return false;
2105
2126
  }
2106
2127
  async function isSpawnableCommand(command) {
2107
- if (/[\\/]/.test(command)) {
2128
+ const namesPath = installerPlatform() === "win32" ? /[\\/]/.test(command) : command.includes("/");
2129
+ if (namesPath) {
2108
2130
  try {
2109
2131
  const stat = statSync(command);
2110
2132
  return stat.isFile() && stat.size > 0;
@@ -2112,7 +2134,7 @@ async function isSpawnableCommand(command) {
2112
2134
  return false;
2113
2135
  }
2114
2136
  }
2115
- const memoKey = `${command}:${hashSync(process.env.PATH || "")}`;
2137
+ const memoKey = `${getProjectTrustGeneration()}:${command}:${hashSync(process.env.PATH || "")}`;
2116
2138
  if (pathWalkMemo.has(memoKey))
2117
2139
  return pathWalkMemo.get(memoKey) ?? false;
2118
2140
  const isSpawnable = await isCommandAvailable(command);
@@ -2557,6 +2579,10 @@ async function findNpmGlobalToolPath(binaryName, onTransient, verificationArgs =
2557
2579
  for (const candidate of candidates) {
2558
2580
  try {
2559
2581
  await fs2.access(candidate);
2582
+ if (isUntrustedProjectPath(candidate)) {
2583
+ recordProjectCommandRefusal(candidate);
2584
+ continue;
2585
+ }
2560
2586
  if (await verifyToolBinary(candidate, void 0, onTransient, verificationTimeoutMs, verificationArgs)) {
2561
2587
  return candidate;
2562
2588
  }
@@ -2621,6 +2647,10 @@ async function findPipUserToolPath(binaryName, onTransient, verificationArgs = [
2621
2647
  for (const candidate of candidates) {
2622
2648
  try {
2623
2649
  await fs2.access(candidate);
2650
+ if (isUntrustedProjectPath(candidate)) {
2651
+ recordProjectCommandRefusal(candidate);
2652
+ continue;
2653
+ }
2624
2654
  if (await verifyToolBinary(candidate, void 0, onTransient, verificationTimeoutMs, verificationArgs)) {
2625
2655
  return candidate;
2626
2656
  }
@@ -2631,22 +2661,18 @@ async function findPipUserToolPath(binaryName, onTransient, verificationArgs = [
2631
2661
  }
2632
2662
  return void 0;
2633
2663
  }
2634
- function userBaseProbeResult(command, code, stdout) {
2635
- if (stdout.truncated) {
2636
- recordDegradationOnce({
2637
- kind: "spawn-output-cap-truncated",
2638
- subject: `user-base-probe:${command}`,
2639
- reason: `\`${command} -m site --user-base\` reached the ${DEFAULT_MAX_OUTPUT_BYTES}-byte default cap after ${stdout.observedBytes} bytes; the probed user base is unusable`,
2640
- metadata: {
2641
- capBytes: DEFAULT_MAX_OUTPUT_BYTES,
2642
- capSource: "default",
2643
- observedBytes: stdout.observedBytes,
2644
- killed: false
2645
- }
2646
- });
2664
+ function userBaseProbeResult(result) {
2665
+ if (result.outputTruncated || result.error || result.status !== 0)
2647
2666
  return "";
2648
- }
2649
- return code === 0 ? stdout.text.trim() : "";
2667
+ return result.stdout.trim();
2668
+ }
2669
+ async function probeUserBase(command) {
2670
+ return userBaseProbeResult(await safeSpawnAsync(command, ["-m", "site", "--user-base"], {
2671
+ timeout: USER_BASE_PROBE_TIMEOUT_MS,
2672
+ cwd: os.homedir(),
2673
+ ignoreAmbientSignal: true,
2674
+ lifetimeCoupled: true
2675
+ }));
2650
2676
  }
2651
2677
  async function getPythonUserBaseCandidates() {
2652
2678
  const candidates = [];
@@ -2673,24 +2699,7 @@ async function getPythonUserBaseCandidates() {
2673
2699
  { command: "python", args: ["-m", "site", "--user-base"] }
2674
2700
  ];
2675
2701
  for (const probe of probes) {
2676
- const userBase = await new Promise((resolve) => {
2677
- const isWin = process.platform === "win32";
2678
- const spawnCmd = isWin ? [probe.command, ...probe.args].join(" ") : probe.command;
2679
- let proc;
2680
- try {
2681
- proc = spawn(spawnCmd, isWin ? [] : probe.args, {
2682
- stdio: ["ignore", "pipe", "pipe"],
2683
- shell: isWin
2684
- });
2685
- } catch {
2686
- resolve("");
2687
- return;
2688
- }
2689
- const stdout = createBoundedOutputSink();
2690
- proc.stdout?.on("data", (data) => stdout.append(data));
2691
- proc.on("exit", (code) => resolve(userBaseProbeResult(probe.command, code, stdout)));
2692
- proc.on("error", () => resolve(""));
2693
- });
2702
+ const userBase = await probeUserBase(probe.command);
2694
2703
  add(userBase);
2695
2704
  }
2696
2705
  return candidates;
@@ -2770,22 +2779,14 @@ async function httpsGet(url, maxRedirects = 5, headers = {}) {
2770
2779
  }
2771
2780
  return response.body;
2772
2781
  }
2773
- function runCommand(command, args, cwd) {
2774
- return new Promise((resolve) => {
2775
- let proc;
2776
- try {
2777
- proc = spawn(command, args, {
2778
- cwd,
2779
- stdio: "ignore",
2780
- shell: process.platform === "win32"
2781
- });
2782
- } catch {
2783
- resolve(false);
2784
- return;
2785
- }
2786
- proc.on("exit", (code) => resolve(code === 0));
2787
- proc.on("error", () => resolve(false));
2782
+ async function runCommand(command, args, cwd) {
2783
+ const result = await safeSpawnAsync(command, args, {
2784
+ cwd,
2785
+ timeout: ARCHIVE_COMMAND_TIMEOUT_MS,
2786
+ ignoreAmbientSignal: true,
2787
+ lifetimeCoupled: true
2788
2788
  });
2789
+ return !result.error && result.status === 0;
2789
2790
  }
2790
2791
  async function installGitHubTool(tool, prefetchedRelease) {
2791
2792
  const spec = tool.github;
@@ -2855,6 +2856,7 @@ async function installGitHubTool(tool, prefetchedRelease) {
2855
2856
  return void 0;
2856
2857
  }
2857
2858
  try {
2859
+ assertManagedBinDirInsidePinnedHome(tool.id);
2858
2860
  if (launcherRuntime) {
2859
2861
  const assetPath = path3.join(GITHUB_BIN_DIR, `${tool.id}${assetName.endsWith(".phar") ? ".phar" : ".jar"}`);
2860
2862
  await writeFileAtomicAsync(assetPath, assetBuffer, {
@@ -3422,6 +3424,7 @@ async function installMavenTool(tool) {
3422
3424
  }
3423
3425
  try {
3424
3426
  await fs2.mkdir(GITHUB_BIN_DIR, { recursive: true });
3427
+ assertManagedBinDirInsidePinnedHome(tool.id);
3425
3428
  const jarPath = path3.join(GITHUB_BIN_DIR, `${tool.id}.jar`);
3426
3429
  await writeFileAtomicAsync(jarPath, jarBuffer, { bestEffort: false });
3427
3430
  const launcherName = isWindows ? `${binaryName}.bat` : binaryName;
@@ -3645,10 +3648,11 @@ async function installArchiveTool(tool) {
3645
3648
  });
3646
3649
  return void 0;
3647
3650
  }
3651
+ await fs2.mkdir(GITHUB_BIN_DIR, { recursive: true });
3652
+ assertManagedBinDirInsidePinnedHome(tool.id);
3648
3653
  await swapExtractedDir(tool.id, tmpExtractDir, extractDir);
3649
3654
  const innerLauncher = path3.join(extractDir, ...launcherParts);
3650
3655
  const resolvedInner = isWindows ? `${innerLauncher}.bat` : innerLauncher;
3651
- await fs2.mkdir(GITHUB_BIN_DIR, { recursive: true });
3652
3656
  const launcherName = isWindows ? `${binaryName}.bat` : binaryName;
3653
3657
  const shimPath = path3.join(GITHUB_BIN_DIR, launcherName);
3654
3658
  if (isWindows) {
@@ -3979,22 +3983,7 @@ async function installPipTool(toolId, packageName, binaryName, options = {}) {
3979
3983
  const result = await run(candidate.command, args);
3980
3984
  const error = (result.error?.message ?? result.stderr).trim();
3981
3985
  if (result.status === 0) {
3982
- const base = await new Promise((resolve) => {
3983
- let probe;
3984
- try {
3985
- probe = spawn(candidate.command, ["-m", "site", "--user-base"], {
3986
- stdio: ["ignore", "pipe", "pipe"],
3987
- shell: isWindows
3988
- });
3989
- } catch {
3990
- resolve("");
3991
- return;
3992
- }
3993
- const stdout = createBoundedOutputSink();
3994
- probe.stdout?.on("data", (data) => stdout.append(data));
3995
- probe.on("exit", (code) => resolve(userBaseProbeResult(candidate.command, code, stdout)));
3996
- probe.on("error", () => resolve(""));
3997
- });
3986
+ const base = await probeUserBase(candidate.command);
3998
3987
  const binaryPath = base ? await addBinToPath(pipScriptsDir(base, installerPlatform())) : void 0;
3999
3988
  return succeeded("user", binaryPath ?? packageName);
4000
3989
  }
@@ -4060,7 +4049,7 @@ async function stampInstallResolution(toolId) {
4060
4049
  return;
4061
4050
  try {
4062
4051
  const resolutionId = lastInstallResolutionId.get(toolId);
4063
- const refresh = await import("./chunk-2KXTHF3M.js");
4052
+ const refresh = await import("./chunk-U6OC3QEM.js");
4064
4053
  await refresh.stampManagedToolInstall(toolId, resolutionId);
4065
4054
  } catch {
4066
4055
  }
@@ -4073,7 +4062,7 @@ async function finishInstallAttempt(toolId, ok, startedAt) {
4073
4062
  if (ok) {
4074
4063
  resetSafeSpawnWindowsCommandCache();
4075
4064
  try {
4076
- const { resetMadgeManagedPathMemo } = await import("./chunk-LZSEQW6A.js");
4065
+ const { resetMadgeManagedPathMemo } = await import("./chunk-4WX4CTUE.js");
4077
4066
  resetMadgeManagedPathMemo();
4078
4067
  } catch (err) {
4079
4068
  logSessionStart(`auto-install ${toolId}: madge memo reset failed: ${err.message}`);
@@ -4103,7 +4092,7 @@ async function installTool(toolId, ownsLock) {
4103
4092
  return false;
4104
4093
  const npmPath = await installNpmTool(tool.id, tool.packageName, tool.binaryName, tool.checkArgs, getToolVerificationTimeout(tool), packageEntryVerification(tool), ownsLock);
4105
4094
  if (npmPath !== void 0) {
4106
- await import("./chunk-2KXTHF3M.js").then((m) => m.stampManagedToolInstalled(tool.id, tool.packageName)).catch(() => {
4095
+ await import("./chunk-U6OC3QEM.js").then((m) => m.stampManagedToolInstalled(tool.id, tool.packageName)).catch(() => {
4107
4096
  });
4108
4097
  }
4109
4098
  return finishInstallAttempt(tool.id, npmPath !== void 0, startedAt);
@@ -1,8 +1,76 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
+ import {
3
+ recordDegradation
4
+ } from "./chunk-ZQ6NZZTB.js";
5
+ import {
6
+ logExtension
7
+ } from "./chunk-KXF5R4UN.js";
2
8
  import {
3
9
  stagePathFor
4
10
  } from "./chunk-LJDODBBZ.js";
5
11
 
12
+ // dist/clients/project-trust.js
13
+ var trustState = "unknown";
14
+ var installRefusalWarnings = /* @__PURE__ */ new Set();
15
+ var INSTALL_REFUSAL_WARNING_CAP = 200;
16
+ var trustGeneration = 0;
17
+ function getProjectTrustGeneration() {
18
+ return trustGeneration;
19
+ }
20
+ function latchProjectTrustState(next) {
21
+ if (next === trustState)
22
+ return;
23
+ trustState = next;
24
+ installRefusalWarnings.clear();
25
+ trustGeneration += 1;
26
+ }
27
+ function setProjectTrustState(next) {
28
+ const previous = trustState;
29
+ latchProjectTrustState(next);
30
+ if (previous !== next) {
31
+ logExtension({
32
+ subsystem: "project-trust",
33
+ level: "debug",
34
+ message: `project trust state transitioned: ${previous} -> ${next}`,
35
+ metadata: { previous, next }
36
+ });
37
+ }
38
+ }
39
+ function getProjectTrustState() {
40
+ return trustState;
41
+ }
42
+ function isToolInstallAllowedByTrust() {
43
+ return trustState !== "untrusted";
44
+ }
45
+ function assertInstallAllowed(context) {
46
+ if (isToolInstallAllowedByTrust())
47
+ return true;
48
+ recordDegradation({
49
+ kind: "trust-refusal",
50
+ subject: context,
51
+ reason: projectTrustDenialReason() ?? "project trust denied"
52
+ });
53
+ if (!installRefusalWarnings.has(context)) {
54
+ if (installRefusalWarnings.size >= INSTALL_REFUSAL_WARNING_CAP) {
55
+ installRefusalWarnings.clear();
56
+ }
57
+ installRefusalWarnings.add(context);
58
+ logExtension({
59
+ subsystem: "project-trust",
60
+ level: "warn",
61
+ message: `install/materialization blocked: ${context}`,
62
+ metadata: { context, trustState }
63
+ });
64
+ }
65
+ return false;
66
+ }
67
+ function isLspSpawnAllowedByTrust() {
68
+ return trustState !== "untrusted";
69
+ }
70
+ function projectTrustDenialReason() {
71
+ return trustState === "untrusted" ? "project is not trusted (host isProjectTrusted() === false)" : void 0;
72
+ }
73
+
6
74
  // dist/clients/atomic-write.js
7
75
  import * as fs from "node:fs";
8
76
  function writeFileAtomic(targetPath, data, options) {
@@ -80,6 +148,13 @@ function killedForOutputCap(result) {
80
148
  }
81
149
 
82
150
  export {
151
+ getProjectTrustGeneration,
152
+ setProjectTrustState,
153
+ getProjectTrustState,
154
+ isToolInstallAllowedByTrust,
155
+ assertInstallAllowed,
156
+ isLspSpawnAllowedByTrust,
157
+ projectTrustDenialReason,
83
158
  writeFileAtomic,
84
159
  writeFileAtomicAsync,
85
160
  DEFAULT_MAX_OUTPUT_BYTES,
@@ -1,26 +1,27 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  rootMarkersForFile
4
- } from "./chunk-HRNHZA3N.js";
4
+ } from "./chunk-NIU2IPC5.js";
5
5
  import {
6
6
  createGenerationMap,
7
7
  createGenerationSource
8
- } from "./chunk-KUA4OJ5Y.js";
8
+ } from "./chunk-Q3UZHW6N.js";
9
9
  import {
10
10
  getDegradationLedgerGeneration,
11
11
  recordDegradationOnce
12
- } from "./chunk-J64T55EI.js";
12
+ } from "./chunk-ZQ6NZZTB.js";
13
13
  import {
14
14
  logExtension
15
- } from "./chunk-POMLXPMY.js";
15
+ } from "./chunk-KXF5R4UN.js";
16
16
  import {
17
17
  isAtOrAboveHomeDir,
18
18
  isRealGitMarker,
19
19
  isUnderDir,
20
20
  isWindowsPath,
21
21
  nameMatchesMarkerGlob,
22
- normalizeEphemeralMapKey
23
- } from "./chunk-3RKP3FMS.js";
22
+ normalizeEphemeralMapKey,
23
+ realpathOrResolve
24
+ } from "./chunk-PQJFG24Z.js";
24
25
 
25
26
  // dist/clients/tool-cwd.js
26
27
  import * as os from "node:os";
@@ -180,11 +181,6 @@ function logRunnerAdvisoryOnce(ctx, tool, root, message) {
180
181
  ctx.log(message, "debug");
181
182
  }
182
183
  function resolveToolCwd(kind, tool, file, ctx) {
183
- const dispatchRoot = path.resolve(ctx.cwd ?? process.cwd());
184
- const absoluteFile = path.resolve(file);
185
- const fileDir = path.dirname(absoluteFile);
186
- const homeDir = ctx.homeDir ?? os.homedir();
187
- const insideDispatch = isUnderDir(absoluteFile, dispatchRoot);
188
184
  if (ctx.serverRoot) {
189
185
  const rootPath = isWindowsPath(ctx.serverRoot) ? path.win32 : path;
190
186
  const serverRoot = rootPath.resolve(ctx.serverRoot);
@@ -192,8 +188,14 @@ function resolveToolCwd(kind, tool, file, ctx) {
192
188
  emitResolution(kind, tool, serverRoot, "server-root");
193
189
  return { cwd: serverRoot };
194
190
  }
191
+ const dispatchRoot = path.resolve(ctx.cwd ?? process.cwd());
192
+ const absoluteFile = realpathOrResolve(file);
193
+ const fileDir = path.dirname(absoluteFile);
194
+ const homeDir = ctx.homeDir ?? os.homedir();
195
+ const homeCeiling = realpathOrResolve(homeDir);
196
+ const insideDispatch = isUnderDir(absoluteFile, dispatchRoot);
195
197
  const markers = markersFor(kind, tool, absoluteFile, ctx);
196
- const markerResult = markers.length ? findMarkerRoot(fileDir, markers, ctx.allowHomeMarker ? path.parse(homeDir).root : homeDir) : { root: null };
198
+ const markerResult = markers.length ? findMarkerRoot(fileDir, markers, ctx.allowHomeMarker ? path.parse(homeCeiling).root : homeCeiling) : { root: null };
197
199
  const markerRoot = markerResult.root;
198
200
  if (markerRoot && (insideDispatch ? isUnderDir(markerRoot, dispatchRoot) : true)) {
199
201
  const finalReason = `marker:${markerResult.marker ?? markers[0]}`;
@@ -206,11 +208,11 @@ function resolveToolCwd(kind, tool, file, ctx) {
206
208
  }
207
209
  const memo = ctx.toolCwdMemo;
208
210
  if (memo && memo.gitRoot === void 0) {
209
- const gitResult = findMarkerRoot(fileDir, [".git"], homeDir);
211
+ const gitResult = findMarkerRoot(fileDir, [".git"], homeCeiling);
210
212
  memo.gitRoot = gitResult.root && isRealGitMarker(path.join(gitResult.root, ".git")) ? gitResult.root : null;
211
213
  }
212
214
  const gitRoot = memo && memo.gitRoot !== void 0 ? memo.gitRoot : (() => {
213
- const gitResult = findMarkerRoot(fileDir, [".git"], homeDir);
215
+ const gitResult = findMarkerRoot(fileDir, [".git"], homeCeiling);
214
216
  return gitResult.root && isRealGitMarker(path.join(gitResult.root, ".git")) ? gitResult.root : null;
215
217
  })();
216
218
  if (gitRoot && (insideDispatch ? isUnderDir(gitRoot, dispatchRoot) : true)) {