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,36 +1,36 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
3
  resolveOpengrepConfig
4
- } from "./chunk-HWCCCQNX.js";
4
+ } from "./chunk-JL6CXUMW.js";
5
5
  import {
6
+ PYTHON_COMPILE_VERDICT_SERVER_ID,
6
7
  augmentPythonEnvironment,
7
8
  detectPythonEnvironment,
8
- detectPythonVenv,
9
9
  pythonEnvironmentToolCandidates
10
- } from "./chunk-CUHSHSB6.js";
11
- import {
12
- resolveGitCheckout,
13
- resolveLinkedWorktreeOwner
14
- } from "./chunk-UA7ZXYDR.js";
10
+ } from "./chunk-NDMCVUYK.js";
15
11
  import {
16
12
  hasCargoWorkspaceTable,
17
13
  readCargoWorkspaceExclude,
18
14
  readCargoWorkspaceMembers,
19
15
  readTextFileOrUndefined
20
- } from "./chunk-MPNJLASA.js";
16
+ } from "./chunk-ZKXQKGWZ.js";
21
17
  import {
22
- extensionsForLanguage,
23
18
  getUserRuleRoot,
24
19
  ruleCorpusFingerprintForCycle
25
- } from "./chunk-GXFV6MYU.js";
20
+ } from "./chunk-ZUUI3ZSA.js";
26
21
  import {
27
22
  load,
28
23
  resolvePackagePath
29
- } from "./chunk-FM4RDMKT.js";
24
+ } from "./chunk-TIQJPRDD.js";
25
+ import {
26
+ extensionsForLanguage
27
+ } from "./chunk-YISME6ON.js";
28
+ import {
29
+ HOOK_WALL_BUDGET_MS
30
+ } from "./chunk-CKEQFGLT.js";
30
31
  import {
31
- HOOK_WALL_BUDGET_MS,
32
32
  bounded
33
- } from "./chunk-RMLC67LF.js";
33
+ } from "./chunk-CJYKEW2L.js";
34
34
  import {
35
35
  ensureTool,
36
36
  findManagedToolBinary,
@@ -40,22 +40,25 @@ import {
40
40
  isZizmorAuditTarget,
41
41
  logSessionStart,
42
42
  resolveZizmorGitHubToken
43
- } from "./chunk-GAQ7OQG6.js";
43
+ } from "./chunk-MKVZQUEG.js";
44
44
  import {
45
45
  resolveToolCwd
46
- } from "./chunk-DEL2U6CM.js";
46
+ } from "./chunk-MT6BVNFW.js";
47
47
  import {
48
48
  commandSearchReachesProject,
49
49
  findGlobalBinary,
50
50
  isProjectLocalBinPath
51
- } from "./chunk-5VSF4UUQ.js";
51
+ } from "./chunk-Z7IGUAXL.js";
52
52
  import {
53
53
  classifyProbeFailure,
54
54
  createAvailabilityLatch,
55
55
  describeInstallAttempt,
56
56
  logAvailabilityDecision,
57
57
  startHostStallSampler
58
- } from "./chunk-P63GXC37.js";
58
+ } from "./chunk-5APMQ2IJ.js";
59
+ import {
60
+ readDirEntriesSafeAsync
61
+ } from "./chunk-VG5JS5SW.js";
59
62
  import {
60
63
  OWNER_TAG_ENV,
61
64
  SpawnFailureError,
@@ -68,18 +71,29 @@ import {
68
71
  hasSpawnFailureKind,
69
72
  holdOwnChildPid,
70
73
  isCommandAvailableAsync,
74
+ isExcludedDirName,
71
75
  isPathIgnoredByProject,
72
76
  isPiLensInternalPath,
77
+ isSessionRepositoryPath,
78
+ isUntrustedProjectPath,
79
+ mergeWindowsEnvironment,
73
80
  ownerTagForChildren,
81
+ recordProjectCommandRefusal,
82
+ resolveGitCheckout,
83
+ resolveLinkedWorktreeOwner,
84
+ resolveSearchPathCommand,
74
85
  resolveWindowsCommandForEnvironment,
75
- safeSpawnAsync
76
- } from "./chunk-KUA4OJ5Y.js";
86
+ safeSpawn,
87
+ safeSpawnAsync,
88
+ statIsFile,
89
+ trustScopedEnvironment
90
+ } from "./chunk-Q3UZHW6N.js";
77
91
  import {
78
92
  DOTNET_CSHARP_ROOT_MARKERS,
79
93
  DOTNET_FSHARP_ROOT_MARKERS,
80
94
  KIND_EXTENSIONS,
81
95
  LEAN_ROOT_MARKERS
82
- } from "./chunk-DUO2TU77.js";
96
+ } from "./chunk-RZOXUSPC.js";
83
97
  import {
84
98
  isRepoTier,
85
99
  lspSectionOf,
@@ -89,46 +103,46 @@ import {
89
103
  reportPiLensConfigRecords,
90
104
  resolvePiLensConfig,
91
105
  summarizeConfigResolution
92
- } from "./chunk-J6MPGQTS.js";
106
+ } from "./chunk-OLAWH5UQ.js";
93
107
  import {
94
108
  FRESHNESS_CADENCE_MS,
95
109
  LSP_NAMESPACE_KEY,
110
+ dirMtimeIsRacy,
96
111
  dirMtimeRecordsAsync,
97
112
  dirMtimesStillFreshAsync,
98
113
  getPiLensGlobalConfigPath,
99
114
  unknownDirMtimeRecords
100
- } from "./chunk-5HSRT26B.js";
115
+ } from "./chunk-J6JP25XU.js";
101
116
  import {
117
+ getProjectTrustGeneration,
102
118
  getProjectTrustState
103
- } from "./chunk-M2IFVFWU.js";
119
+ } from "./chunk-MN7MHUXQ.js";
104
120
  import {
105
121
  getDegradationLedgerGeneration,
106
122
  incrementDegradationCount,
107
123
  recordDegradationOnce
108
- } from "./chunk-J64T55EI.js";
124
+ } from "./chunk-ZQ6NZZTB.js";
109
125
  import {
110
126
  logExtension
111
- } from "./chunk-POMLXPMY.js";
127
+ } from "./chunk-KXF5R4UN.js";
112
128
  import {
113
129
  claimPhaseOncePerSession,
114
130
  currentSessionRecordId,
115
131
  logLatency,
116
132
  releasePhaseClaim
117
- } from "./chunk-QBFBRV2B.js";
133
+ } from "./chunk-Z2XAOKHK.js";
118
134
  import {
119
135
  getGlobalPiLensLogDir,
120
136
  getProcessSingleton,
121
137
  isTestMode,
122
138
  redactSecrets
123
- } from "./chunk-YNE3RP52.js";
139
+ } from "./chunk-VSFLRN5Y.js";
124
140
  import {
125
141
  STAGE_TMP_PATTERN
126
142
  } from "./chunk-LJDODBBZ.js";
127
143
  import {
128
144
  BoundedFifoMap,
129
- BoundedLruCache
130
- } from "./chunk-ABBOA7UD.js";
131
- import {
145
+ BoundedLruCache,
132
146
  CARGO_WORKSPACE_MEMBER_DIALECT,
133
147
  direntsHaveMarkerGlobMatch,
134
148
  findLocalToolConfig,
@@ -142,11 +156,9 @@ import {
142
156
  normalizeFilePath,
143
157
  normalizeMapKey,
144
158
  pathsEqual,
159
+ realpathOrResolve,
145
160
  toPosix
146
- } from "./chunk-3RKP3FMS.js";
147
- import {
148
- __require
149
- } from "./chunk-NXL4FFQQ.js";
161
+ } from "./chunk-PQJFG24Z.js";
150
162
 
151
163
  // dist/clients/analysis-root.js
152
164
  import * as fs from "node:fs";
@@ -184,28 +196,11 @@ function nearestProjectRoot(filePath) {
184
196
  }
185
197
  return hasProjectMarker(filesystemRoot) ? filesystemRoot : void 0;
186
198
  }
187
- function realPathOrResolved(filePath) {
188
- const resolved = nodePath.resolve(filePath);
189
- let current = resolved;
190
- const missing = [];
191
- while (true) {
192
- try {
193
- const real = fs.realpathSync.native(current);
194
- return nodePath.join(real, ...missing.reverse());
195
- } catch {
196
- const parent = nodePath.dirname(current);
197
- if (parent === current)
198
- return resolved;
199
- missing.push(nodePath.basename(current));
200
- current = parent;
201
- }
202
- }
203
- }
204
199
  function resolveAnalysisRootPath(filePath, sessionRoot, homeDirOverride) {
205
- const resolved = realPathOrResolved(filePath);
206
- const session = realPathOrResolved(sessionRoot);
207
- const tmp = realPathOrResolved(os.tmpdir());
208
- const data = process.env.PI_LENS_HOME ? realPathOrResolved(process.env.PI_LENS_HOME) : void 0;
200
+ const resolved = realpathOrResolve(filePath);
201
+ const session = realpathOrResolve(sessionRoot);
202
+ const tmp = realpathOrResolve(os.tmpdir());
203
+ const data = process.env.PI_LENS_HOME ? realpathOrResolve(process.env.PI_LENS_HOME) : void 0;
209
204
  if (isVendorPath(resolved))
210
205
  return void 0;
211
206
  if (resolved === tmp || resolved === session || isUnderDir(session, resolved) || !isUnderDir(resolved, session) && (isPiLensInternalPath(resolved, session) || data !== void 0 && (resolved === data || isUnderDir(resolved, data))))
@@ -219,7 +214,7 @@ function resolveAnalysisRootPath(filePath, sessionRoot, homeDirOverride) {
219
214
  const candidate = nearestProjectRoot(resolved);
220
215
  if (!candidate || candidate === nodePath.parse(candidate).root)
221
216
  return void 0;
222
- const home = realPathOrResolved(homeDirOverride ?? os.homedir());
217
+ const home = realpathOrResolve(homeDirOverride ?? os.homedir());
223
218
  if (isAtOrAboveHomeDir(candidate, home))
224
219
  return void 0;
225
220
  if (candidate === tmp || isUnderDir(session, candidate))
@@ -228,20 +223,23 @@ function resolveAnalysisRootPath(filePath, sessionRoot, homeDirOverride) {
228
223
  return void 0;
229
224
  return candidate;
230
225
  }
231
- function resolveAnalysisRoot(filePath, sessionRoot, homeDirOverride) {
232
- const resolved = realPathOrResolved(filePath);
226
+ function classifyAnalysisRoot(filePath, sessionRoot, homeDirOverride) {
227
+ const resolved = realpathOrResolve(filePath);
233
228
  if (isVendorPath(resolved))
234
- return "none";
229
+ return { mode: "none", root: void 0 };
235
230
  const checkout = resolveGitCheckout(sessionRoot);
236
- if (checkout && resolveLinkedWorktreeOwner(checkout, resolved)) {
237
- return "linked-worktree";
238
- }
231
+ const owner = checkout ? resolveLinkedWorktreeOwner(checkout, resolved) : null;
232
+ if (owner)
233
+ return { mode: "linked-worktree", root: owner.root };
239
234
  const root = resolveAnalysisRootPath(filePath, sessionRoot, homeDirOverride);
240
235
  if (!root)
241
- return "none";
242
- if (root === nodePath.resolve(sessionRoot))
243
- return "session";
244
- return "adopted";
236
+ return { mode: "none", root: void 0 };
237
+ if (pathsEqual(root, sessionRoot))
238
+ return { mode: "session", root };
239
+ return { mode: "adopted", root };
240
+ }
241
+ function resolveAnalysisRoot(filePath, sessionRoot, homeDirOverride) {
242
+ return classifyAnalysisRoot(filePath, sessionRoot, homeDirOverride).mode;
245
243
  }
246
244
  function canWriteAnalysisRoot(mode) {
247
245
  return mode === "session" || mode === "linked-worktree";
@@ -607,6 +605,7 @@ function isAuxiliary(bearer) {
607
605
  return false;
608
606
  }
609
607
  }
608
+ var DEFAULT_RESEND_RECHECK = "unmeasured";
610
609
  var DEFAULT_NOTIFY_INFLIGHT_LIMIT = 8;
611
610
  var DEFAULT_REPLY_ORDERING = "unmeasured";
612
611
  function serverTraits(declaration) {
@@ -615,14 +614,16 @@ function serverTraits(declaration) {
615
614
  return {
616
615
  role: declaration.role,
617
616
  notifyInflightLimit: Math.floor(declaredLimit),
618
- replyOrdering: declaration.replyOrdering ?? DEFAULT_REPLY_ORDERING
617
+ replyOrdering: declaration.replyOrdering ?? DEFAULT_REPLY_ORDERING,
618
+ resendRecheck: declaration.resendRecheck ?? DEFAULT_RESEND_RECHECK
619
619
  };
620
620
  }
621
621
  const envLimit = Number(process.env.PI_LENS_LSP_AUX_NOTIFY_INFLIGHT);
622
622
  return {
623
623
  role: declaration.role,
624
624
  notifyInflightLimit: Number.isFinite(envLimit) && envLimit > 0 ? Math.floor(envLimit) : DEFAULT_NOTIFY_INFLIGHT_LIMIT,
625
- replyOrdering: declaration.replyOrdering ?? DEFAULT_REPLY_ORDERING
625
+ replyOrdering: declaration.replyOrdering ?? DEFAULT_REPLY_ORDERING,
626
+ resendRecheck: declaration.resendRecheck ?? DEFAULT_RESEND_RECHECK
626
627
  };
627
628
  }
628
629
 
@@ -644,7 +645,7 @@ function isKnownRunnerId(id) {
644
645
 
645
646
  // dist/clients/lsp/launch.js
646
647
  import { AsyncLocalStorage } from "node:async_hooks";
647
- import { execFileSync, spawn as nodeSpawn } from "node:child_process";
648
+ import { spawn as nodeSpawn } from "node:child_process";
648
649
  import fs4 from "node:fs";
649
650
  import os3 from "node:os";
650
651
  import path3 from "node:path";
@@ -750,22 +751,10 @@ function resolvePathValue(env) {
750
751
  return combinePathValuesForPlatform([env.PATH, env.Path, env.path]);
751
752
  }
752
753
  function runStderrGuardedProbe(command, args) {
753
- try {
754
- const { execFileSync: execFileSync2 } = __require("node:child_process");
755
- const out = execFileSync2(command, args, {
756
- timeout: 3e3,
757
- encoding: "utf8",
758
- // #2095 sibling: execFileSync inherits stderr to the parent by
759
- // default (only stdout is captured into `out`), so a failed
760
- // powershell.exe launch would print raw diagnostics into the pi
761
- // TUI even though the surrounding catch already returns "" (read as
762
- // "unknown" PATH by every caller). Pipe stderr instead of inheriting it.
763
- stdio: ["ignore", "pipe", "ignore"]
764
- });
765
- return out.trim();
766
- } catch {
754
+ const result = safeSpawn(command, args, { timeout: 3e3 });
755
+ if (result.error || result.status !== 0)
767
756
  return "";
768
- }
757
+ return result.stdout.trim();
769
758
  }
770
759
  function readWindowsRegistryPath() {
771
760
  return runStderrGuardedProbe("powershell.exe", [
@@ -838,15 +827,23 @@ function isCmdShimValid(cmdPath) {
838
827
  return true;
839
828
  }
840
829
  }
841
- function isMissingWindowsStartupCommand(command, spawnCommand, cwd, env) {
830
+ function windowsCommandPresence(evidence) {
831
+ const { command, spawnCommand } = evidence;
832
+ if (/\.(cmd|bat)$/i.test(spawnCommand) && isCmdShimValid(spawnCommand)) {
833
+ return "present";
834
+ }
835
+ if (evidence.isBareCommand) {
836
+ return evidence.scannedCommandPath !== void 0 || spawnCommand !== command ? "present" : "absent";
837
+ }
838
+ return statIsFile(spawnCommand) || resolveWindowsCommandForEnvironment(spawnCommand, evidence.cwd, evidence.env) ? "present" : "absent";
839
+ }
840
+ function isMissingWindowsStartupCommand(spawnCommand, presence) {
842
841
  if (!isWindows)
843
842
  return false;
844
843
  if (/\.(cmd|bat)$/i.test(spawnCommand) && !isCmdShimValid(spawnCommand)) {
845
844
  return true;
846
845
  }
847
- if (spawnCommand !== command)
848
- return false;
849
- return resolveWindowsCommandForEnvironment(command, cwd, env) === null;
846
+ return presence === "absent";
850
847
  }
851
848
  function bypassPs1OnWindows(ps1Path, args) {
852
849
  const cmdPath = `${ps1Path.slice(0, -4)}.cmd`;
@@ -871,29 +868,11 @@ function bypassPs1OnWindows(ps1Path, args) {
871
868
  }
872
869
  return void 0;
873
870
  }
874
- function findBinaryOnPath(command, env) {
875
- try {
876
- const result = execFileSync(isWindows ? "where" : "which", [command], {
877
- encoding: "utf-8",
878
- stdio: ["ignore", "pipe", "ignore"],
879
- env,
880
- // #1980 population sweep: this was the one synchronous
881
- // child-process site in the repo with no bound at all. It runs on
882
- // the LSP server spawn path, so an unresponsive `where`/`which` — a
883
- // stale network PATH entry is the classic cause — parked the event
884
- // loop with no ceiling, and read as ordinary compute in
885
- // `loop_block`. 5s matches `isCommandAvailable`/`findCommand` in
886
- // clients/safe-spawn.ts, which run these same two binaries.
887
- timeout: 5e3
888
- }).split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
889
- for (const candidate of result) {
890
- if (fs4.existsSync(candidate)) {
891
- return candidate;
892
- }
893
- }
894
- } catch {
871
+ function findBinaryOnPath(command, env, cwd) {
872
+ if (isWindows) {
873
+ return resolveWindowsCommandForEnvironment(command, cwd, env)?.resolvedPath;
895
874
  }
896
- return void 0;
875
+ return resolveSearchPathCommand(command, env.PATH, cwd);
897
876
  }
898
877
  var lspProjectCodePermission = new AsyncLocalStorage();
899
878
  function withLspProjectCodePermission(allowed, spawn) {
@@ -966,6 +945,8 @@ function recordUnresolvedTypeScriptCompiler(cwd, trust) {
966
945
  if (unknownProjectLocalNoticeGeneration === generation)
967
946
  return;
968
947
  unknownProjectLocalNoticeGeneration = generation;
948
+ if (trust !== "trusted" && sessionRepositoryHoldsCompiler(cwd))
949
+ return;
969
950
  logExtension({
970
951
  subsystem: "lsp-registry",
971
952
  level: "warn",
@@ -973,9 +954,23 @@ function recordUnresolvedTypeScriptCompiler(cwd, trust) {
973
954
  metadata: { field: "typescript-compiler" }
974
955
  });
975
956
  }
957
+ function sessionRepositoryHoldsCompiler(cwd) {
958
+ const found = findBinaryOnPath("tsc", process.env, cwd);
959
+ return found !== void 0 && isSessionRepositoryPath(found);
960
+ }
976
961
  function isProjectLocalLspBinary(resolvedCommand, cwd) {
977
962
  return isProjectLocalBinPath(resolvedCommand, cwd);
978
963
  }
964
+ function refuseProjectLookup(command, spawnCommand, cwd, env) {
965
+ const unresolved = spawnCommand === command;
966
+ if (unresolved && !isWindows)
967
+ return;
968
+ const owned = unresolved ? resolveWindowsCommandForEnvironment(command, cwd, mergeWindowsEnvironment(env, { PATH: cwd }))?.resolvedPath : spawnCommand;
969
+ if (owned === void 0 || !isUntrustedProjectPath(owned))
970
+ return;
971
+ recordProjectCommandRefusal(owned);
972
+ throw new SpawnFailureError("trust-refused", `LSP lookup refused: ${command} resolved inside the project and project trust is ${getProjectTrustState()}`, new Error(`project trust is ${getProjectTrustState()}`));
973
+ }
979
974
  function trySpawn(command, args, cwd, env, needsShell) {
980
975
  let proc;
981
976
  if (needsShell) {
@@ -1058,27 +1053,37 @@ async function launchLSP(command, args = [], options = {}) {
1058
1053
  const mergedEnv = { ...process.env, ...options.env };
1059
1054
  const augmentedPath = await buildAugmentedPath(resolvePathValue(mergedEnv));
1060
1055
  const ownerTag = await ownerTagForChildren({ timeoutMs: OWNER_TAG_READ_MS });
1061
- const env = {
1056
+ const env = trustScopedEnvironment({
1062
1057
  ...mergedEnv,
1063
1058
  PATH: augmentedPath,
1064
1059
  ...isWindows ? { Path: augmentedPath } : {}
1065
- };
1060
+ }, cwd);
1066
1061
  if (ownerTag === void 0)
1067
1062
  delete env[OWNER_TAG_ENV];
1068
1063
  else
1069
1064
  env[OWNER_TAG_ENV] = ownerTag;
1065
+ const isBareCommand = !isFullyQualified(command) && !command.includes(path3.sep) && !command.includes("/");
1070
1066
  const isRelativePath = !isFullyQualified(command) && (command.includes(path3.sep) || command.includes("/"));
1071
1067
  const explicitCommand = isRelativePath ? path3.resolve(cwd, command) : command;
1072
- const resolvedCommand = !isFullyQualified(command) && !command.includes(path3.sep) && !command.includes("/") ? findBinaryOnPath(command, env) ?? explicitCommand : explicitCommand;
1068
+ const scannedCommandPath = isBareCommand ? findBinaryOnPath(command, env, cwd) : void 0;
1069
+ const resolvedCommand = scannedCommandPath ?? explicitCommand;
1073
1070
  let needsShell = computeNeedsShell(resolvedCommand);
1074
1071
  let spawnCommand = resolvedCommand;
1075
- if (!isFullyQualified(command) && !command.includes(path3.sep) && !command.includes("/")) {
1072
+ if (isBareCommand) {
1076
1073
  const globalBinPath = await findGlobalBinary(command);
1077
1074
  if (globalBinPath) {
1078
1075
  spawnCommand = globalBinPath;
1079
1076
  needsShell = computeNeedsShell(spawnCommand);
1080
1077
  }
1081
1078
  }
1079
+ const commandPresence = isWindows ? windowsCommandPresence({
1080
+ command,
1081
+ spawnCommand,
1082
+ isBareCommand,
1083
+ scannedCommandPath,
1084
+ cwd,
1085
+ env
1086
+ }) : "absent";
1082
1087
  if (isProjectLocalLspBinary(spawnCommand, cwd)) {
1083
1088
  refuseUntrustedLspExecution({
1084
1089
  kind: "project-local-binary",
@@ -1087,6 +1092,8 @@ async function launchLSP(command, args = [], options = {}) {
1087
1092
  cwd
1088
1093
  });
1089
1094
  }
1095
+ if (isBareCommand)
1096
+ refuseProjectLookup(command, spawnCommand, cwd, env);
1090
1097
  if (isWindows && /\.(cmd|bat)$/i.test(spawnCommand) && !isCmdShimValid(spawnCommand)) {
1091
1098
  logSessionStart2(`lsp cmd-shim-invalid: ${spawnCommand} target missing \u2014 skipping candidate`);
1092
1099
  const cause = Object.assign(new Error(`LSP .cmd shim target not found: ${spawnCommand}`), { code: "ENOENT" });
@@ -1107,7 +1114,7 @@ async function launchLSP(command, args = [], options = {}) {
1107
1114
  try {
1108
1115
  proc = trySpawn(spawnCommand, args, cwd, env, needsShell);
1109
1116
  } catch (err) {
1110
- if (!isFullyQualified(command) && !command.includes(path3.sep) && !command.includes("/")) {
1117
+ if (isBareCommand) {
1111
1118
  const globalBinPath = await findGlobalBinary(command);
1112
1119
  if (globalBinPath && globalBinPath !== spawnCommand) {
1113
1120
  const needsShellGlobal = computeNeedsShell(globalBinPath);
@@ -1125,7 +1132,7 @@ async function launchLSP(command, args = [], options = {}) {
1125
1132
  if (proc.exitCode !== null || proc.killed) {
1126
1133
  const message = `LSP server ${command} exited immediately (code: ${proc.exitCode}). The binary may be missing or corrupted.`;
1127
1134
  const failure = new Error(message);
1128
- if (proc.exitCode === 1 && isMissingWindowsStartupCommand(command, spawnCommand, cwd, env)) {
1135
+ if (proc.exitCode === 1 && isMissingWindowsStartupCommand(spawnCommand, commandPresence)) {
1129
1136
  throw new SpawnFailureError("tool-not-found", message, failure);
1130
1137
  }
1131
1138
  throw failure;
@@ -1163,7 +1170,7 @@ async function launchLSP(command, args = [], options = {}) {
1163
1170
  const errorMsg = isWindowsCmd && code === 1 ? `npm .cmd shim failed (underlying binary not installed). Run 'npm install' in this project or use a global installation.` : `The binary may be missing or corrupted.`;
1164
1171
  const message = `LSP server ${command} exited immediately with code ${code}. ${errorMsg}${formatStartupStderr(startupStderr)}`;
1165
1172
  const failure = new Error(message);
1166
- if (code === 1 && isMissingWindowsStartupCommand(command, spawnCommand, cwd, env)) {
1173
+ if (code === 1 && isMissingWindowsStartupCommand(spawnCommand, commandPresence)) {
1167
1174
  reject(new SpawnFailureError("tool-not-found", message, failure));
1168
1175
  return;
1169
1176
  }
@@ -1447,6 +1454,7 @@ function normalizeWorkspacePath(cwd) {
1447
1454
  return path4.resolve(cwd);
1448
1455
  }
1449
1456
  var unknownTrustNoticeGeneration = -1;
1457
+ var serversForFileOverride;
1450
1458
  function sourceFor(provenance, key) {
1451
1459
  const direct = provenanceFor({ value: void 0, provenance }, key);
1452
1460
  if (direct)
@@ -1494,6 +1502,129 @@ function getConfigForFile(filePath) {
1494
1502
  function registerLSPConfig(config) {
1495
1503
  return compileLspRegistry(config, config.__provenance);
1496
1504
  }
1505
+ var OVERRIDE_COPY_TRAITS = {
1506
+ id: {
1507
+ keep: true,
1508
+ why: "Routing identity: the override is keyed by this id."
1509
+ },
1510
+ name: {
1511
+ keep: true,
1512
+ why: "Routing identity: how the entry is named in output."
1513
+ },
1514
+ extensions: {
1515
+ keep: true,
1516
+ why: "Routing: which files the entry serves; an override swaps the binary, not the language mapping."
1517
+ },
1518
+ role: {
1519
+ keep: true,
1520
+ why: "Routing: primary versus auxiliary selection is a policy of the entry, not a measurement."
1521
+ },
1522
+ root: {
1523
+ keep: true,
1524
+ why: "Routing: where the workspace is hosted; the override changes the binary only."
1525
+ },
1526
+ rootMarkers: {
1527
+ keep: true,
1528
+ why: "Routing: the marker table behind the shared root seam."
1529
+ },
1530
+ fallbackFor: {
1531
+ keep: true,
1532
+ why: "Routing: which preferred server this entry backs up."
1533
+ },
1534
+ pathFilter: {
1535
+ keep: true,
1536
+ why: "Routing: the candidacy gate beyond extensions."
1537
+ },
1538
+ executesProjectCode: {
1539
+ keep: true,
1540
+ why: "Protective: a true value refuses an untrusted spawn; resetting would widen."
1541
+ },
1542
+ looseFileRoot: {
1543
+ keep: true,
1544
+ why: "Protective: a decline keeps a home-directory walk from starting; resetting would widen."
1545
+ },
1546
+ spawnNeedsProjectFile: {
1547
+ keep: true,
1548
+ why: "Protective: a decline before spawn; wrongly kept it costs a spawn, never a verdict."
1549
+ },
1550
+ requiresProjectRoot: {
1551
+ keep: true,
1552
+ why: "Restrictive: only demotes an empty answer to unconfirmed."
1553
+ },
1554
+ availabilityKey: {
1555
+ keep: true,
1556
+ why: "Protective: the adopted-root project-local binary refusal reads it; resetting would widen."
1557
+ },
1558
+ projectLocalCommand: {
1559
+ keep: true,
1560
+ why: "Protective: the adopted-root project-local binary refusal reads it; resetting would widen."
1561
+ },
1562
+ settingsSection: {
1563
+ keep: true,
1564
+ why: "Documented (#4758): the section sits on the server so a command override keeps it."
1565
+ },
1566
+ initializeTimeoutMs: {
1567
+ keep: true,
1568
+ why: "Wait budget at or above the shared default; too short kills a slow-bootstrap server, too long only waits."
1569
+ },
1570
+ clientWaitTimeoutMs: {
1571
+ keep: true,
1572
+ why: "Wait budget; a longer wait costs time and never a wrong verdict."
1573
+ },
1574
+ notifyInflightLimit: {
1575
+ keep: true,
1576
+ why: "Ceiling that only lowers the shared default; a lower cap costs round trips, a higher one risks the stall it bounded."
1577
+ },
1578
+ idleEviction: {
1579
+ keep: false,
1580
+ why: "Reset to unmeasured (never evicted): 'transparent' needs per-server evidence."
1581
+ },
1582
+ replyOrdering: {
1583
+ keep: false,
1584
+ why: "Reset to unmeasured (barrier armed): the notify barrier's soundness rests on the measured ordering."
1585
+ },
1586
+ resendRecheck: {
1587
+ keep: false,
1588
+ why: "Reset to unmeasured (no re-send): a server that publishes nothing for unchanged bytes loses the answer (#4782)."
1589
+ },
1590
+ autoPropagateDiagnostics: {
1591
+ keep: false,
1592
+ why: "Reset (active touch of neighbours): an optimistic claim that the server pushes dependents."
1593
+ },
1594
+ autoInstall: {
1595
+ keep: false,
1596
+ why: "Reset: it installs the catalog binary, not the override's."
1597
+ },
1598
+ custom: {
1599
+ keep: false,
1600
+ why: "Reset: marks config-supplied rows; catalog rows never declare it."
1601
+ },
1602
+ command: {
1603
+ keep: false,
1604
+ why: "Reset: the custom-row command token; the override's command lives in its spawn."
1605
+ },
1606
+ covers: {
1607
+ keep: false,
1608
+ why: "Reset: the custom-row covers claim; catalog rows declare theirs in BUILTIN_SERVER_RUNNER_COVERS."
1609
+ },
1610
+ trustAllowed: {
1611
+ keep: false,
1612
+ why: "Set by the copy: the registry admitted the override's command."
1613
+ },
1614
+ spawn: {
1615
+ keep: false,
1616
+ why: "Set by the copy: launches the override's command."
1617
+ }
1618
+ };
1619
+ function keptOverrideTraits(server) {
1620
+ const kept = {};
1621
+ for (const [trait, value] of Object.entries(server)) {
1622
+ if (Object.hasOwn(OVERRIDE_COPY_TRAITS, trait) && OVERRIDE_COPY_TRAITS[trait].keep) {
1623
+ kept[trait] = value;
1624
+ }
1625
+ }
1626
+ return kept;
1627
+ }
1497
1628
  function compileLspRegistry(config, provenance = /* @__PURE__ */ new Map()) {
1498
1629
  const trust = getProjectTrustState();
1499
1630
  const customServers = [];
@@ -1551,10 +1682,11 @@ function compileLspRegistry(config, provenance = /* @__PURE__ */ new Map()) {
1551
1682
  const overriddenBuiltins = LSP_SERVERS.map((server) => {
1552
1683
  const override = serverOverrides.get(server.id);
1553
1684
  if (!override?.command)
1554
- return { ...server };
1685
+ return server;
1555
1686
  const argv = Array.isArray(override.command) ? override.command : [override.command, "--stdio"];
1556
1687
  return {
1557
- ...server,
1688
+ ...keptOverrideTraits(server),
1689
+ idleEviction: "unmeasured",
1558
1690
  trustAllowed: true,
1559
1691
  async spawn(root, options) {
1560
1692
  void options;
@@ -1565,7 +1697,7 @@ function compileLspRegistry(config, provenance = /* @__PURE__ */ new Map()) {
1565
1697
  cwd: root,
1566
1698
  env: override.env ? { ...process.env, ...override.env } : process.env
1567
1699
  });
1568
- return { process: proc };
1700
+ return { process: proc, launchVariant: "override" };
1569
1701
  }
1570
1702
  };
1571
1703
  });
@@ -1613,6 +1745,8 @@ function explainServersForFile(filePath, config = getConfigForFile(filePath)) {
1613
1745
  });
1614
1746
  }
1615
1747
  function getServersForFileWithConfig(filePath) {
1748
+ if (serversForFileOverride)
1749
+ return serversForFileOverride(filePath);
1616
1750
  const config = getConfigForFile(filePath);
1617
1751
  const { ext, base } = fileMatchKeys(filePath);
1618
1752
  return registeredServers(config, LSP_SERVERS).filter((server) => selectionReason(server, config, filePath, ext, base) === "selected");
@@ -1680,10 +1814,20 @@ var SERVER_DIAGNOSTIC_STRATEGIES = {
1680
1814
  debounceMs: 50,
1681
1815
  aggregateWaitMs: 1e3,
1682
1816
  expectSemanticSecondPush: false,
1683
- // #3310 / nightly run 37930006227: the clean TypeScript fixture
1684
- // published an empty pre-index result before its settled result.
1685
- // Hold that first publish so it cannot resolve a push wait as clean.
1686
- emptyFirstPublish: "indexing",
1817
+ // #4615: NO `emptyFirstPublish` marker. Measured 2026-10-20 over a raw
1818
+ // JSON-RPC wire against typescript-language-server@5.3.0 with
1819
+ // typescript@5.9.3: the DIRTY fixture's first publish already carries
1820
+ // the finding (code 2322) — `direct`, so holding it can only delay the
1821
+ // answer — and a CLEAN file's only publish is an EMPTY settled answer
1822
+ // (one publish, nothing after it, nothing on the edit). The hold
1823
+ // swallows that answer, so a first clean touch stays unconfirmed and
1824
+ // spends the full `aggregateWaitMs` budget for a verdict the server had
1825
+ // already sent. The `empty-first` this row used to carry was measured on
1826
+ // the `typescript-clean` fixture, whose publish trace was scoped by
1827
+ // server id alone while five live fixtures share "typescript": a foreign
1828
+ // client's late publish decided the class (#4615). The axis is defined on
1829
+ // a DIRTY file and docs/lsp-capability-matrix.md now records this row's
1830
+ // measured `direct`; a `clean: true` fixture can never be its source.
1687
1831
  // Tier 3 (#458): typescript-language-server publishes nothing on a
1688
1832
  // clean→clean edit (docs/lsp-capability-matrix.md, re-confirmed
1689
1833
  // 2026-07-12). It's the lone core-set tier-3 server, which is exactly
@@ -1735,7 +1879,10 @@ var SERVER_DIAGNOSTIC_STRATEGIES = {
1735
1879
  },
1736
1880
  // Opengrep security scanner (cross-language LSP). It pushes an EMPTY result
1737
1881
  // during the one-time rule-load window at startup, then the real scan after
1738
- // `semgrep/rulesRefreshed` — so never seed the first push. Push-only (no pull
1882
+ // `semgrep/rulesRefreshed` — so never seed the first push, and hold that
1883
+ // empty publish (`emptyUntilRulesRefreshed`, #4763): without the hold it
1884
+ // ended the touch as "answered" and the findings arrived after the wait.
1885
+ // Push-only (no pull
1739
1886
  // diagnostics). Warm per-file scan ~1.3s; the first touch in a session may
1740
1887
  // also pay rule-load (~3.5s cold). aggregateWaitMs is 3500: it's this
1741
1888
  // server's OWN deadline, bounded by the per-edit caller cap as a ceiling
@@ -1752,7 +1899,8 @@ var SERVER_DIAGNOSTIC_STRATEGIES = {
1752
1899
  expectSemanticSecondPush: false,
1753
1900
  // Opengrep re-scans only on a fresh didOpen — didChange is a no-op for it.
1754
1901
  reopenOnResync: true,
1755
- rescansOnSave: true
1902
+ rescansOnSave: true,
1903
+ emptyUntilRulesRefreshed: true
1756
1904
  },
1757
1905
  // ast-grep structural linter (sgconfig-gated auxiliary LSP). Push-only,
1758
1906
  // compiles the project rules on the first scan of a session, and — like
@@ -1920,25 +2068,24 @@ var SERVER_DIAGNOSTIC_STRATEGIES = {
1920
2068
  // #3484: the fence reply (+2..4 ms) precedes the publish (~+1 s).
1921
2069
  diagnosticsFence: "reply-first"
1922
2070
  },
1923
- // terraform-ls (#3310). The nightly tool-smoke measurement was identical
1924
- // on 2026-09-27, 2026-09-28, and 2026-09-29:
1925
- //
1926
- // [terraform] clean-behavior=publishes-unversioned (tier 2*)
1927
- // dirtyPubs=2(v:0) cleanPubs=2(v:0) first-publish=empty-first
1928
- // provisional pre-index publish
1929
- //
1930
- // The first empty, unversioned publish is the cold-index artifact, so hold
1931
- // it once and let terraform-ls's next publish resolve the wait. A held
1932
- // clean-only trace therefore reaches the caller as unanswered/indeterminate
1933
- // at the wait ceiling rather than a false clean, by design (#3310). The
1934
- // marker is measured policy, not a blanket rule for Tier 2* push servers.
2071
+ // terraform-ls: NO `emptyFirstPublish` marker (#4615). The earlier
2072
+ // `empty-first` reading (2026-09-27..29, and the nightlies 2026-10-17..20)
2073
+ // came from a probe that counted terraform-ls's EMPTY set for the
2074
+ // WORKSPACE DIRECTORY URI. terraform-ls publishes that set in the same
2075
+ // ~1 ms burst as the file's own finding, and the probe's drainer kept rows
2076
+ // by server id only, so the directory row was read as the file's first
2077
+ // publish. Scoped to the fixture's own document, the first publish carries
2078
+ // the finding: `direct` (terraform-ls 0.39.0, 16/16 cold runs). The hold
2079
+ // was also a no-op for a dirty file: the one-shot hold is spent on the
2080
+ // directory row or an unrelated `.tf` file, never on the finding. On a
2081
+ // clean `.tf` file it could swallow the file's own `[]`, which costs a
2082
+ // wait to the ceiling (inferred from code, not probed).
1935
2083
  terraform: {
1936
2084
  seedFirstPush: false,
1937
2085
  pullRetryBudgetMs: 0,
1938
2086
  debounceMs: 150,
1939
2087
  aggregateWaitMs: 1500,
1940
- expectSemanticSecondPush: false,
1941
- emptyFirstPublish: "indexing"
2088
+ expectSemanticSecondPush: false
1942
2089
  },
1943
2090
  // yaml-language-server (#3484): the default strategy plus the measured
1944
2091
  // fence order — reply +3..6 ms, publish +207..242 ms after didChange.
@@ -2038,10 +2185,90 @@ var DEFAULT_STRATEGY = {
2038
2185
  aggregateWaitMs: 1500,
2039
2186
  expectSemanticSecondPush: false
2040
2187
  };
2188
+ var OVERRIDE_STRATEGY_FIELDS = {
2189
+ seedFirstPush: {
2190
+ keep: "reset",
2191
+ why: "True takes the first push as complete (optimistic); the default waits for the settle."
2192
+ },
2193
+ pullRetryBudgetMs: {
2194
+ keep: "longer",
2195
+ why: "A retry budget; zero skips the pull retry, so never shorter than the default."
2196
+ },
2197
+ debounceMs: {
2198
+ keep: "longer",
2199
+ why: "A settle window; a shorter one reads sooner, so never shorter than the default."
2200
+ },
2201
+ aggregateWaitMs: {
2202
+ keep: "longer",
2203
+ why: "A wait budget measured on the catalog binary (opengrep cold scan 3.5 s); never shorter than the default."
2204
+ },
2205
+ expectSemanticSecondPush: {
2206
+ keep: "inherit",
2207
+ why: "Adds a second pull after an empty fast first pull; the default reads that empty answer."
2208
+ },
2209
+ reopenOnResync: {
2210
+ keep: "inherit",
2211
+ why: "Re-opens an edited document for a scanner that ignores didChange; dropping it loses every later finding."
2212
+ },
2213
+ rescansOnSave: {
2214
+ keep: "inherit",
2215
+ why: "Expects the publish a save triggers; at worst the wait times out as unconfirmed."
2216
+ },
2217
+ emptyUntilRulesRefreshed: {
2218
+ keep: "inherit",
2219
+ why: "Holds the empty publish before the rules load; dropping it reads that empty as clean."
2220
+ },
2221
+ publishesOnClose: {
2222
+ keep: "inherit",
2223
+ why: "Drops the version-less close-time empty publish; dropping it lets a stale empty overwrite a real answer."
2224
+ },
2225
+ emptyFirstPublish: {
2226
+ keep: "inherit",
2227
+ why: "Holds the empty pre-index first publish (#3310); dropping it reads that empty as clean."
2228
+ },
2229
+ diagnosticsFence: {
2230
+ keep: "inherit",
2231
+ why: "Drops version-less publishes that predate the edit; the worst case is a timeout, never a false clean."
2232
+ },
2233
+ silentOnClean: {
2234
+ keep: "reset",
2235
+ why: "True skips the in-lane wait on a clean transition (optimistic); the default waits in full."
2236
+ },
2237
+ workspaceIndexing: {
2238
+ keep: "reset",
2239
+ why: "True shortens later same-sweep waits (optimistic); the default pays the full budget every touch."
2240
+ },
2241
+ workspaceIndexingWarmWaitMs: {
2242
+ keep: "reset",
2243
+ why: "Read only with workspaceIndexing, so it resets with it."
2244
+ }
2245
+ };
2246
+ function overrideStrategy(serverId) {
2247
+ const row = SERVER_DIAGNOSTIC_STRATEGIES[serverId];
2248
+ if (!row)
2249
+ return DEFAULT_STRATEGY;
2250
+ const strategy = { ...DEFAULT_STRATEGY };
2251
+ for (const [field, value] of Object.entries(row)) {
2252
+ if (!Object.hasOwn(OVERRIDE_STRATEGY_FIELDS, field))
2253
+ continue;
2254
+ const keep = OVERRIDE_STRATEGY_FIELDS[field].keep;
2255
+ if (keep === "inherit")
2256
+ Object.assign(strategy, { [field]: value });
2257
+ else if (keep === "longer" && typeof value === "number") {
2258
+ const floor = DEFAULT_STRATEGY[field];
2259
+ if (typeof floor === "number") {
2260
+ Object.assign(strategy, { [field]: Math.max(value, floor) });
2261
+ }
2262
+ }
2263
+ }
2264
+ return strategy;
2265
+ }
2041
2266
  function getStrategy(serverId, launchVariant) {
2042
2267
  if (serverId === "typescript" && launchVariant === "native-ts7") {
2043
2268
  return NATIVE_TS7_DIAGNOSTIC_STRATEGY;
2044
2269
  }
2270
+ if (launchVariant === "override")
2271
+ return overrideStrategy(serverId);
2045
2272
  return SERVER_DIAGNOSTIC_STRATEGIES[serverId] ?? DEFAULT_STRATEGY;
2046
2273
  }
2047
2274
 
@@ -2307,6 +2534,7 @@ var _cachedEnv;
2307
2534
  var javaAvailabilityLatch = createAvailabilityLatch();
2308
2535
  var inFlightJavaProbe = null;
2309
2536
  function probeJavaOnPath() {
2537
+ const trustGeneration = getProjectTrustGeneration();
2310
2538
  const memo = javaAvailabilityLatch.read();
2311
2539
  if (memo !== null) {
2312
2540
  if (javaAvailabilityLatch.getOutcome() === "transient") {
@@ -2327,12 +2555,14 @@ function probeJavaOnPath() {
2327
2555
  }
2328
2556
  return Promise.resolve(memo);
2329
2557
  }
2330
- if (inFlightJavaProbe)
2331
- return inFlightJavaProbe;
2332
- inFlightJavaProbe = runJavaProbe().finally(() => {
2333
- inFlightJavaProbe = null;
2558
+ if (inFlightJavaProbe?.trustGeneration === trustGeneration)
2559
+ return inFlightJavaProbe.promise;
2560
+ const promise = runJavaProbe().finally(() => {
2561
+ if (inFlightJavaProbe?.promise === promise)
2562
+ inFlightJavaProbe = null;
2334
2563
  });
2335
- return inFlightJavaProbe;
2564
+ inFlightJavaProbe = { trustGeneration, promise };
2565
+ return promise;
2336
2566
  }
2337
2567
  async function runJavaProbe() {
2338
2568
  const finder = process.platform === "win32" ? "where" : "which";
@@ -2383,11 +2613,12 @@ async function runJavaProbe() {
2383
2613
  return outcome === "transient" ? void 0 : false;
2384
2614
  }
2385
2615
  async function resolveJavaRuntimeEnv() {
2386
- if (_cachedEnv)
2616
+ if (_cachedEnv?.trustGeneration === getProjectTrustGeneration())
2387
2617
  return _cachedEnv.value;
2618
+ const trustGeneration = getProjectTrustGeneration();
2388
2619
  const javaOnPath = await probeJavaOnPath();
2389
2620
  if (javaOnPath === true) {
2390
- _cachedEnv = { value: void 0 };
2621
+ _cachedEnv = { value: void 0, trustGeneration };
2391
2622
  return void 0;
2392
2623
  }
2393
2624
  const home = discoverJdkHome();
@@ -2398,12 +2629,13 @@ async function resolveJavaRuntimeEnv() {
2398
2629
  value: {
2399
2630
  JAVA_HOME: home,
2400
2631
  PATH: binDir + path6.delimiter + currentPath
2401
- }
2632
+ },
2633
+ trustGeneration
2402
2634
  };
2403
2635
  return _cachedEnv.value;
2404
2636
  }
2405
2637
  if (javaOnPath === false) {
2406
- _cachedEnv = { value: void 0 };
2638
+ _cachedEnv = { value: void 0, trustGeneration };
2407
2639
  }
2408
2640
  return void 0;
2409
2641
  }
@@ -2423,7 +2655,7 @@ function withRootMarkers(root, markers) {
2423
2655
  root.rootMarkers = markers;
2424
2656
  return root;
2425
2657
  }
2426
- function describeRootFallback(fallback) {
2658
+ function describeRootFallback(fallback, hosted = true) {
2427
2659
  const tail = "so pi-lens cannot confirm the server analysed the file";
2428
2660
  if (fallback.cause === "failed") {
2429
2661
  return `${fallback.serverName}: resolving the project root for this file failed, ${tail}`;
@@ -2431,7 +2663,9 @@ function describeRootFallback(fallback) {
2431
2663
  if (fallback.cause === "unselected") {
2432
2664
  return `${fallback.serverName}: found ${fallback.marker} for this file but pi-lens did not select it as the project root (a test-fixture or git-ignored directory is never used as one), ${tail}`;
2433
2665
  }
2434
- return `${fallback.serverName}: no project root found for this file (looked for ${fallback.rootMarkers.join(" / ")}); the server was started at the file's directory and may not have analysed it`;
2666
+ const bound = !hosted && fallback.searchBound !== void 0 ? `, including a bounded search of ${fallback.searchBound} directories below it` : "";
2667
+ const none = `${fallback.serverName}: no project root found for this file (looked for ${fallback.rootMarkers.join(" / ")}${bound})`;
2668
+ return hosted ? `${none}; the server was started at the file's directory and may not have analysed it` : none;
2435
2669
  }
2436
2670
  async function resolveLspServerCwd(server, filePath, sessionCwd, onRootFailure, onRootFallback) {
2437
2671
  const stagingRoot = ephemeralStagingRoot(filePath);
@@ -2477,7 +2711,10 @@ async function resolveLspServerCwd(server, filePath, sessionCwd, onRootFailure,
2477
2711
  rootMarkers: rootMarkers ?? [],
2478
2712
  requiresProjectRoot: server.requiresProjectRoot === true,
2479
2713
  cause: rootFailed ? "failed" : refusedMarker !== void 0 ? "unselected" : "none",
2480
- ...refusedMarker !== void 0 && { marker: refusedMarker }
2714
+ ...refusedMarker !== void 0 && { marker: refusedMarker },
2715
+ ...server.spawnNeedsProjectFile === true && {
2716
+ searchBound: PROJECT_FILE_SEARCH_MAX_DIRS
2717
+ }
2481
2718
  });
2482
2719
  }
2483
2720
  return fallbackCwd?.cwd;
@@ -2530,7 +2767,8 @@ var PROJECT_BOUNDARY_MARKERS = [
2530
2767
  "settings.gradle.kts",
2531
2768
  "mix.exs",
2532
2769
  "pubspec.yaml",
2533
- "Package.swift"
2770
+ "Package.swift",
2771
+ "buildServer.json"
2534
2772
  ];
2535
2773
  var PYTHON_BOUNDARY_MARKERS = /* @__PURE__ */ new Set([
2536
2774
  "setup.py",
@@ -2595,7 +2833,7 @@ function enforceLspRootCeiling(root, sessionCwd, filePath) {
2595
2833
  if (filePath && !isSameOrWithin(resolvedCwd, pathApi.resolve(filePath))) {
2596
2834
  return resolvedRoot;
2597
2835
  }
2598
- if (isSameOrWithin(resolvedCwd, resolvedRoot))
2836
+ if (isSameOrWithin(resolvedCwd, resolvedRoot) || isUnderDir(resolvedRoot, resolvedCwd))
2599
2837
  return resolvedRoot;
2600
2838
  const logKey = `${normalizeMapKey(resolvedCwd)}:${normalizeMapKey(resolvedRoot)}`;
2601
2839
  if (!loggedRootCeilingClamps.has(logKey)) {
@@ -2628,46 +2866,61 @@ function hasFixtureConvention(dir) {
2628
2866
  function hasAtomicStageSegment(dir) {
2629
2867
  return pathSegments(dir).some((segment) => STAGE_TMP_PATTERN.test(segment));
2630
2868
  }
2631
- async function findGitBoundary(dir) {
2869
+ async function findGitBoundary(dir, memo) {
2632
2870
  let current = path7.resolve(dir);
2633
2871
  const fsRoot = path7.parse(current).root;
2872
+ const visited = [];
2873
+ let found;
2634
2874
  while (true) {
2635
- if (await markerExists(current, ".git"))
2636
- return current;
2875
+ const key = normalizeMapKey(current);
2876
+ if (memo?.has(key)) {
2877
+ found = memo.get(key);
2878
+ break;
2879
+ }
2880
+ visited.push(key);
2881
+ if (await markerExists(current, ".git")) {
2882
+ found = current;
2883
+ break;
2884
+ }
2637
2885
  if (current === fsRoot)
2638
- return void 0;
2886
+ break;
2639
2887
  current = path7.dirname(current);
2640
2888
  }
2889
+ for (const seen of visited)
2890
+ memo?.set(seen, found);
2891
+ return found;
2641
2892
  }
2642
- async function isExcludedLspRoot(dir) {
2893
+ async function isExcludedLspRoot(dir, gitBoundaries) {
2643
2894
  const candidate = path7.resolve(dir);
2644
2895
  if (hasFixtureConvention(candidate) || hasAtomicStageSegment(candidate))
2645
2896
  return true;
2646
- const gitRoot = await findGitBoundary(candidate);
2897
+ const gitRoot = await findGitBoundary(candidate, gitBoundaries);
2647
2898
  if (!gitRoot || gitRoot === candidate)
2648
2899
  return false;
2649
2900
  if (getProjectIgnoreGlobs(gitRoot).length === 0)
2650
2901
  return false;
2651
2902
  return isPathIgnoredByProject(candidate, gitRoot, true);
2652
2903
  }
2653
- async function nearestNonExcludedFallbackRoot(candidate) {
2654
- if (!await isExcludedLspRoot(candidate))
2655
- return path7.resolve(candidate);
2656
- let current = path7.dirname(path7.resolve(candidate));
2904
+ async function nearestNonExcludedFallbackRoot(candidate, stopDir) {
2905
+ let current = path7.resolve(candidate);
2906
+ const startDir = current;
2657
2907
  const fsRoot = path7.parse(current).root;
2658
2908
  let nearestAllowed;
2909
+ const gitBoundaries = /* @__PURE__ */ new Map();
2659
2910
  while (true) {
2660
- if (!await isExcludedLspRoot(current)) {
2911
+ if (!await isExcludedLspRoot(current, gitBoundaries)) {
2661
2912
  nearestAllowed ??= current;
2662
2913
  for (const marker of FALLBACK_PROJECT_MARKERS) {
2663
2914
  if (await markerExists(current, marker))
2664
2915
  return current;
2665
2916
  }
2666
2917
  }
2667
- if (current === fsRoot)
2918
+ if (current === fsRoot || normalizeEphemeralMapKey(current) === stopDir)
2668
2919
  break;
2669
2920
  current = path7.dirname(current);
2670
2921
  }
2922
+ if (stopDir !== void 0)
2923
+ return nearestAllowed ?? startDir;
2671
2924
  return nearestAllowed ?? fsRoot;
2672
2925
  }
2673
2926
  function isLspInstallDisabled() {
@@ -3164,7 +3417,7 @@ function piAgentExtensionsRootKey(file) {
3164
3417
  return dirKey.slice(0, index + marker.length);
3165
3418
  }
3166
3419
  function IgnoreHomeRoot(primary) {
3167
- const homeKey = normalizeEphemeralMapKey(path7.resolve(os7.homedir()));
3420
+ const homeKey = normalizeEphemeralMapKey(realpathOrResolve(os7.homedir()));
3168
3421
  return withRootMarkers(async (file) => {
3169
3422
  const root = await primary(file);
3170
3423
  if (!root)
@@ -3241,8 +3494,37 @@ function PriorityRoot(markerGroups, excludePatterns, stopDir) {
3241
3494
  }
3242
3495
  var FileDirRoot = async (file) => {
3243
3496
  const candidate = path7.resolve(path7.dirname(file));
3244
- return nearestNonExcludedFallbackRoot(candidate);
3497
+ return nearestNonExcludedFallbackRoot(candidate, piAgentExtensionsRootKey(file));
3245
3498
  };
3499
+ function declinesLooseFileRoot(server, root) {
3500
+ if (server.looseFileRoot !== "decline")
3501
+ return false;
3502
+ return isAtOrAboveHomeDir(realpathOrResolve(root), realpathOrResolve(os7.homedir()));
3503
+ }
3504
+ var PROJECT_FILE_SEARCH_MAX_DIRS = 128;
3505
+ async function declinesProjectlessRoot(server, root) {
3506
+ if (server.spawnNeedsProjectFile !== true)
3507
+ return false;
3508
+ const markers = server.rootMarkers ?? server.root.rootMarkers ?? [];
3509
+ const queue = [root];
3510
+ for (let visited = 0; visited < PROJECT_FILE_SEARCH_MAX_DIRS; visited++) {
3511
+ const dir = queue.shift();
3512
+ if (dir === void 0)
3513
+ break;
3514
+ for (const marker of markers) {
3515
+ if (await markerExists(dir, marker))
3516
+ return false;
3517
+ }
3518
+ for (const entry of await readDirEntriesSafeAsync(dir)) {
3519
+ if (visited + queue.length + 1 >= PROJECT_FILE_SEARCH_MAX_DIRS)
3520
+ break;
3521
+ if (entry.isDirectory() && !isExcludedDirName(entry.name)) {
3522
+ queue.push(path7.join(dir, entry.name));
3523
+ }
3524
+ }
3525
+ }
3526
+ return true;
3527
+ }
3246
3528
  function RootWithFallback(primary, fallback = FileDirRoot) {
3247
3529
  return withRootMarkers(async (file) => {
3248
3530
  const primaryRoot = await primary(file);
@@ -3307,8 +3589,9 @@ function NearestRoot(includePatterns, excludePatterns, stopDir) {
3307
3589
  subdirPatterns.push(pattern);
3308
3590
  }
3309
3591
  return withRootMarkers(async (file) => {
3310
- const startDir = path7.resolve(path7.dirname(file));
3311
- const dirKey = normalizeMapKey(startDir);
3592
+ const identity = realpathOrResolve(file);
3593
+ const startDir = path7.dirname(identity);
3594
+ const dirKey = normalizeEphemeralMapKey(startDir);
3312
3595
  const cached = cache.get(dirKey);
3313
3596
  if (cached !== void 0 && Date.now() - cached.walkedAt < FRESHNESS_CADENCE_MS && await bounded(dirMtimesStillFreshAsync(cached.probedDirs), rootMtimeBound("lsp-root-memo-freshness")) === true)
3314
3597
  return cached.root;
@@ -3320,7 +3603,7 @@ function NearestRoot(includePatterns, excludePatterns, stopDir) {
3320
3603
  const promise = (async () => {
3321
3604
  let currentDir = startDir;
3322
3605
  const fsRoot = path7.parse(currentDir).root;
3323
- const stop = stopDir ? path7.resolve(stopDir) : fsRoot;
3606
+ const stop = stopDir ? realpathOrResolve(stopDir) : fsRoot;
3324
3607
  while (true) {
3325
3608
  if (stop !== fsRoot && currentDir.startsWith(stop + path7.sep) === false && currentDir !== stop) {
3326
3609
  break;
@@ -3345,8 +3628,8 @@ function NearestRoot(includePatterns, excludePatterns, stopDir) {
3345
3628
  }
3346
3629
  }
3347
3630
  for (const pattern of includePatterns) {
3348
- if (await markerExists(currentDir, pattern) && (pattern !== ".git" || currentDir !== os7.tmpdir()) && !await isExcludedLspRoot(currentDir)) {
3349
- return enforceLspRootCeiling(currentDir, process.cwd(), file);
3631
+ if (await markerExists(currentDir, pattern) && (pattern !== ".git" || currentDir !== realpathOrResolve(os7.tmpdir())) && !await isExcludedLspRoot(currentDir)) {
3632
+ return enforceLspRootCeiling(currentDir, process.cwd(), identity);
3350
3633
  }
3351
3634
  }
3352
3635
  if (currentDir === stop || currentDir === fsRoot) {
@@ -3359,7 +3642,7 @@ function NearestRoot(includePatterns, excludePatterns, stopDir) {
3359
3642
  inFlight.set(dirKey, promise);
3360
3643
  try {
3361
3644
  const result = await promise;
3362
- if (result !== void 0)
3645
+ if (result !== void 0 && !probedDirs.some((r) => dirMtimeIsRacy(r.mtimeMs, walkedAt)))
3363
3646
  cache.set(dirKey, { root: result, probedDirs, walkedAt });
3364
3647
  return result;
3365
3648
  } finally {
@@ -3593,7 +3876,16 @@ function dotnetToolCandidates(tool) {
3593
3876
  ].filter(Boolean);
3594
3877
  }
3595
3878
  function binExeVariants(dir, tool) {
3596
- return process.platform === "win32" ? [path7.join(dir, `${tool}.exe`), path7.join(dir, tool)] : [path7.join(dir, tool)];
3879
+ const variants = process.platform === "win32" ? [path7.join(dir, `${tool}.exe`), path7.join(dir, tool)] : [path7.join(dir, tool)];
3880
+ const admitted = [];
3881
+ for (const candidate of variants) {
3882
+ if (existsSync3(candidate) && isUntrustedProjectPath(candidate)) {
3883
+ recordProjectCommandRefusal(candidate);
3884
+ continue;
3885
+ }
3886
+ admitted.push(candidate);
3887
+ }
3888
+ return admitted;
3597
3889
  }
3598
3890
  function goBinCandidates(tool) {
3599
3891
  const gopath = process.env.GOPATH?.split(path7.delimiter)[0] || path7.join(os7.homedir(), "go");
@@ -3660,8 +3952,10 @@ async function findTypeScriptProjectRoot(file) {
3660
3952
  return isSameOrWithin(toolingRoot, configRoot) ? configRoot : toolingRoot;
3661
3953
  }
3662
3954
  async function findExtensionBoundedRoot(file, extensionRootKey) {
3663
- const startDir = path7.resolve(path7.dirname(file));
3664
- let currentDir = startDir;
3955
+ const identity = realpathOrResolve(file);
3956
+ const insideBoundary = isUnderDir(identity, extensionRootKey);
3957
+ const boundaryKey = insideBoundary ? normalizeEphemeralMapKey(realpathOrResolve(extensionRootKey)) : extensionRootKey;
3958
+ let currentDir = path7.dirname(insideBoundary ? identity : path7.resolve(file));
3665
3959
  const configMarkers = tsConfigMarkersForFile(file);
3666
3960
  while (true) {
3667
3961
  for (const pattern of configMarkers) {
@@ -3679,7 +3973,7 @@ async function findExtensionBoundedRoot(file, extensionRootKey) {
3679
3973
  }
3680
3974
  }
3681
3975
  const currentKey = normalizeEphemeralMapKey(path7.resolve(currentDir));
3682
- if (currentKey === extensionRootKey)
3976
+ if (currentKey === boundaryKey)
3683
3977
  return void 0;
3684
3978
  const parent = path7.dirname(currentDir);
3685
3979
  if (parent === currentDir)
@@ -3701,7 +3995,7 @@ async function hasAgentLevelProjectMarker(extensionRootKey) {
3701
3995
  return false;
3702
3996
  }
3703
3997
  var TypeScriptRoot = withRootMarkers(DenoExcludeRoot(async (file) => {
3704
- const extensionRootKey = piAgentExtensionsRootKey(file);
3998
+ const extensionRootKey = piAgentExtensionsRootKey(file) ?? piAgentExtensionsRootKey(realpathOrResolve(file));
3705
3999
  if (extensionRootKey) {
3706
4000
  const bounded2 = await findExtensionBoundedRoot(file, extensionRootKey);
3707
4001
  if (bounded2)
@@ -3720,6 +4014,11 @@ var TypeScriptServer = {
3720
4014
  id: "typescript",
3721
4015
  idleEviction: "transparent",
3722
4016
  role: "language",
4017
+ // #4782: typescript-language-server 5.3.0 (tsserver 5.9.3) answered every
4018
+ // unchanged-bytes re-send after a delayed dependency 10/10 (measured; see
4019
+ // LspResendRecheck). The native TS 7.0.2 launch is read by pull, which
4020
+ // answers in stream order: 20/20 fresh with the re-send, none inconclusive.
4021
+ resendRecheck: "rechecks",
3723
4022
  name: "TypeScript Language Server",
3724
4023
  projectLocalCommand: "typescript-language-server",
3725
4024
  extensions: JS_TS_LSP_EXTENSIONS,
@@ -3793,10 +4092,25 @@ var DenoServer = {
3793
4092
  }, options?.allowInstall);
3794
4093
  }
3795
4094
  };
4095
+ function pyrightInitialization(pythonPath) {
4096
+ return {
4097
+ python: {
4098
+ ...pythonPath ? { pythonPath } : {},
4099
+ analysis: { diagnosticMode: "openFilesOnly" }
4100
+ }
4101
+ };
4102
+ }
3796
4103
  var PythonServer = {
3797
4104
  id: "python",
3798
4105
  idleEviction: "transparent",
3799
4106
  role: "language",
4107
+ // #4782: every binary this row launches answers an unchanged-bytes
4108
+ // didChange for its new version (measured; see LspResendRecheck): pyright
4109
+ // 1.1.414, basedpyright 1.40.2 (idle 3/3, burst under load 6/6) and ty
4110
+ // 0.0.91 (idle 3/3, burst 6/6, burst under load 6/6). ty never re-checks a
4111
+ // dependent on its own after the dependency changes, so it needs the re-send
4112
+ // most.
4113
+ resendRecheck: "rechecks",
3800
4114
  name: "Pyright Language Server",
3801
4115
  extensions: KIND_EXTENSIONS["python"],
3802
4116
  root: RootWithFallback(createRootDetector([
@@ -3810,12 +4124,9 @@ var PythonServer = {
3810
4124
  ])),
3811
4125
  async spawn(root, options) {
3812
4126
  const pythonEnvironment = await detectPythonEnvironment(root);
3813
- const env = augmentPythonEnvironment(await getToolEnvironment(), pythonEnvironment);
4127
+ const toolEnvironment = await getToolEnvironment();
4128
+ const env = augmentPythonEnvironment(toolEnvironment, pythonEnvironment);
3814
4129
  let source = "direct";
3815
- const pyrightInit = (pythonPath) => ({
3816
- ...pythonPath ? { pythonPath } : {},
3817
- openFilesOnly: true
3818
- });
3819
4130
  const projectPyright = await resolveAndLaunch({
3820
4131
  candidates: [
3821
4132
  ...pythonEnvironmentToolCandidates(pythonEnvironment, "pyright-langserver"),
@@ -3831,7 +4142,7 @@ var PythonServer = {
3831
4142
  return {
3832
4143
  process: projectPyright.process,
3833
4144
  source: projectPyright.source,
3834
- initialization: pyrightInit(pythonEnvironment?.pythonPath)
4145
+ initialization: pyrightInitialization(pythonEnvironment?.pythonPath)
3835
4146
  };
3836
4147
  }
3837
4148
  const projectTy = await resolveAndLaunch({
@@ -3853,7 +4164,7 @@ var PythonServer = {
3853
4164
  return {
3854
4165
  process: pathPyright.process,
3855
4166
  source: pathPyright.source,
3856
- initialization: pyrightInit(pythonEnvironment?.pythonPath)
4167
+ initialization: pyrightInitialization(pythonEnvironment?.pythonPath)
3857
4168
  };
3858
4169
  }
3859
4170
  const pathTy = await resolveAndLaunch({
@@ -3884,12 +4195,14 @@ var PythonServer = {
3884
4195
  return {
3885
4196
  process: resolved.process,
3886
4197
  source,
3887
- initialization: pyrightInit(pythonEnvironment?.pythonPath)
4198
+ initialization: pyrightInitialization(pythonEnvironment?.pythonPath)
3888
4199
  };
3889
4200
  }
3890
4201
  };
3891
4202
  var PythonJediServer = {
3892
- id: "python-jedi",
4203
+ // One identity: `isJediCompileVerdictOutranked` matches `compile` rows by
4204
+ // this id, so the rule and the registration cannot drift (#4638).
4205
+ id: PYTHON_COMPILE_VERDICT_SERVER_ID,
3893
4206
  idleEviction: "transparent",
3894
4207
  role: "language",
3895
4208
  name: "Jedi Language Server",
@@ -3905,19 +4218,39 @@ var PythonJediServer = {
3905
4218
  "poetry.lock"
3906
4219
  ])),
3907
4220
  async spawn(root, options) {
4221
+ const pythonEnvironment = await detectPythonEnvironment(root);
4222
+ const toolEnvironment = await getToolEnvironment();
4223
+ const env = augmentPythonEnvironment(toolEnvironment, pythonEnvironment);
4224
+ const initialization = pythonEnvironment ? { workspace: { environmentPath: pythonEnvironment.pythonPath } } : {};
4225
+ if (pythonEnvironment) {
4226
+ try {
4227
+ const projectLaunched = await resolveAndLaunch({
4228
+ candidates: pythonEnvironmentToolCandidates(pythonEnvironment, "jedi-language-server"),
4229
+ args: [],
4230
+ cwd: root,
4231
+ env
4232
+ }, options?.allowInstall);
4233
+ if (projectLaunched)
4234
+ return { ...projectLaunched, initialization };
4235
+ } catch (err) {
4236
+ recordDegradationOnce({
4237
+ kind: "python-project-launch-failed",
4238
+ subject: root,
4239
+ reason: `jedi could not launch from the project interpreter ${pythonEnvironment.pythonPath}: ${err instanceof Error ? err.message : String(err)}`,
4240
+ metadata: { tool: "jedi-language-server" }
4241
+ });
4242
+ }
4243
+ }
3908
4244
  const launched = await resolveAndLaunch({
3909
4245
  candidates: ["jedi-language-server"],
3910
4246
  args: [],
3911
4247
  cwd: root,
4248
+ env: toolEnvironment,
3912
4249
  managedToolId: "jedi-language-server"
3913
4250
  }, options?.allowInstall);
3914
4251
  if (!launched)
3915
4252
  return void 0;
3916
- const pythonPath = await detectPythonVenv(root);
3917
- return {
3918
- ...launched,
3919
- initialization: pythonPath ? { workspace: { environmentPath: pythonPath } } : {}
3920
- };
4253
+ return { ...launched, initialization };
3921
4254
  }
3922
4255
  };
3923
4256
  var GoServer = {
@@ -4059,6 +4392,7 @@ var RustServer = {
4059
4392
  // Measured (#3750): rust-analyzer answers an empty result for a detached file.
4060
4393
  requiresProjectRoot: true,
4061
4394
  name: "rust-analyzer",
4395
+ settingsSection: "rust-analyzer",
4062
4396
  executesProjectCode: true,
4063
4397
  extensions: KIND_EXTENSIONS["rust"],
4064
4398
  // No FileDirRoot fallback (#201): rust-analyzer is a heavy workspace server
@@ -4210,6 +4544,8 @@ var CSharpServer = {
4210
4544
  role: "language",
4211
4545
  // Documented (#3750): csharp-ls needs a solution or project.
4212
4546
  requiresProjectRoot: true,
4547
+ // Measured (#4806): with none below its cwd csharp-ls aborts the process.
4548
+ spawnNeedsProjectFile: true,
4213
4549
  name: "csharp-ls",
4214
4550
  executesProjectCode: true,
4215
4551
  extensions: KIND_EXTENSIONS["csharp"],
@@ -4322,7 +4658,9 @@ var SwiftServer = createInteractiveServer({
4322
4658
  name: "SourceKit-LSP",
4323
4659
  executesProjectCode: true,
4324
4660
  extensions: KIND_EXTENSIONS["swift"],
4325
- root: createRootDetector(["Package.swift"]),
4661
+ // buildServer.json: the BSP config sourcekit-lsp reads for Xcode projects
4662
+ // (xcode-build-server); without it as a root each file is checked alone (#4854).
4663
+ root: createRootDetector(["Package.swift", "buildServer.json"]),
4326
4664
  language: "swift",
4327
4665
  command: "sourcekit-lsp"
4328
4666
  });
@@ -4662,7 +5000,7 @@ var DockerServer = {
4662
5000
  };
4663
5001
  var DockerOfficialServer = {
4664
5002
  id: "docker-official",
4665
- idleEviction: "unmeasured",
5003
+ idleEviction: "transparent",
4666
5004
  role: "language",
4667
5005
  name: "Docker Language Server (official)",
4668
5006
  fallbackFor: "docker",
@@ -4942,8 +5280,11 @@ var OpengrepServer = {
4942
5280
  extensions: OPENGREP_EXTENSIONS,
4943
5281
  // Stable per-repo root so ONE warm server serves the whole project (a
4944
5282
  // per-directory root would spawn a fresh server — and re-pay rule load —
4945
- // for every folder).
4946
- root: RootWithFallback(NearestRoot([".git"]), async () => process.cwd()),
5283
+ // for every folder). A loose file needs no project config, so it is hosted
5284
+ // at its own directory (#4760): the `$HOME`-cwd fallback rooted the scanner
5285
+ // at the whole home tree, where its workspace walk never finished.
5286
+ root: RootWithFallback(NearestRoot([".git"])),
5287
+ looseFileRoot: "decline",
4947
5288
  availabilityKey: "opengrep",
4948
5289
  // Rule compilation can take a few seconds on the first scan of a session.
4949
5290
  initializeTimeoutMs: 15e3,
@@ -4995,7 +5336,8 @@ var AstGrepServer = {
4995
5336
  // sgconfig the spawn launches with `--config <shipped baseline>` so the team's
4996
5337
  // rules still run; the napi runner steps aside when this server is available
4997
5338
  // (it falls back to napi when the ast-grep binary is absent — Gate B).
4998
- root: RootWithFallback(createRootDetector(["sgconfig.yml", "sgconfig.yaml"]), RootWithFallback(NearestRoot([".git"]), async () => process.cwd())),
5339
+ root: RootWithFallback(createRootDetector(["sgconfig.yml", "sgconfig.yaml"]), RootWithFallback(NearestRoot([".git"]))),
5340
+ looseFileRoot: "decline",
4999
5341
  availabilityKey: "ast-grep",
5000
5342
  // #1714: the one auxiliary with a measured wedge ceiling. A `lens_diagnostics
5001
5343
  // mode=full` sweep of 225 files drove this server into an unrecoverable stall
@@ -5035,14 +5377,16 @@ var AstGrepServer = {
5035
5377
  var ZIZMOR_EXTENSIONS = KIND_EXTENSIONS["yaml"];
5036
5378
  var ZizmorServer = {
5037
5379
  id: "zizmor",
5038
- idleEviction: "unmeasured",
5380
+ idleEviction: "transparent",
5039
5381
  role: "auxiliary",
5040
5382
  name: "zizmor Actions Security Scanner",
5041
5383
  extensions: ZIZMOR_EXTENSIONS,
5042
5384
  pathFilter: isZizmorAuditTarget,
5043
5385
  // Stable per-repo root so ONE warm server serves the whole project (like
5044
- // Opengrep) — config + workflow discovery is repo-relative.
5045
- root: RootWithFallback(NearestRoot([".git"]), async () => process.cwd()),
5386
+ // Opengrep) — config + workflow discovery is repo-relative. A loose file is
5387
+ // hosted at its own directory (#4760), never at the session cwd.
5388
+ root: RootWithFallback(NearestRoot([".git"])),
5389
+ looseFileRoot: "decline",
5046
5390
  availabilityKey: "zizmor",
5047
5391
  async spawn(root, options) {
5048
5392
  const ghToken = await resolveZizmorGitHubToken();
@@ -5088,8 +5432,10 @@ var TyposServer = {
5088
5432
  name: "typos Spell Checker",
5089
5433
  extensions: TYPOS_EXTENSIONS,
5090
5434
  // Stable per-repo root so ONE warm server serves the whole project (like the
5091
- // other auxiliaries) — typos.toml discovery is repo-relative.
5092
- root: RootWithFallback(NearestRoot([".git"]), async () => process.cwd()),
5435
+ // other auxiliaries) — typos.toml discovery is repo-relative. A loose file is
5436
+ // hosted at its own directory (#4760), never at the session cwd.
5437
+ root: RootWithFallback(NearestRoot([".git"])),
5438
+ looseFileRoot: "decline",
5093
5439
  availabilityKey: "typos-lsp",
5094
5440
  async spawn(root, options) {
5095
5441
  const launched = await resolveAndLaunch({
@@ -5268,6 +5614,8 @@ export {
5268
5614
  resetLspLaunchAvailabilityGeneration,
5269
5615
  resetDirectLspCommandAvailability,
5270
5616
  isDirectLspCommandTemporarilyUnavailable,
5617
+ declinesLooseFileRoot,
5618
+ declinesProjectlessRoot,
5271
5619
  resetClassicTsRepairGuard,
5272
5620
  LSP_SERVERS,
5273
5621
  getServerById,