pi-lens 4.4.3 → 4.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/CHANGELOG.md +721 -0
  2. package/README.md +25 -3
  3. package/config/dependency-cruiser-eager-allowlist.json +1 -0
  4. package/dist/chunk-22Y2BM7H.js +23 -0
  5. package/dist/{chunk-WU567RSC.js → chunk-27VWVB23.js} +16 -14
  6. package/dist/{chunk-FLKWCIZH.js → chunk-2FYKETQJ.js} +10 -6
  7. package/dist/{chunk-MQLUAEOC.js → chunk-2LDMXL2M.js} +2 -2
  8. package/dist/{chunk-YSZNHOBY.js → chunk-2SDHYHHO.js} +17 -17
  9. package/dist/chunk-2Y6OJRSI.js +38 -0
  10. package/dist/chunk-3SNDVPOR.js +507 -0
  11. package/dist/{chunk-EJIUXPBX.js → chunk-3WCEHYOI.js} +1 -1
  12. package/dist/chunk-44X7VIKR.js +73 -0
  13. package/dist/{chunk-Q7DUK4LX.js → chunk-4FHUGDKU.js} +16 -14
  14. package/dist/{chunk-H6MF6EVN.js → chunk-4ODSZ35Z.js} +1498 -534
  15. package/dist/{chunk-ZGDGW2V3.js → chunk-4U7GDSZQ.js} +2 -2
  16. package/dist/chunk-54NIOJJZ.js +25 -0
  17. package/dist/{chunk-ZWFS3OEF.js → chunk-5DKE4HGX.js} +38 -37
  18. package/dist/{chunk-VRZP76YM.js → chunk-5LRUKYFA.js} +34 -4
  19. package/dist/{chunk-QOBUHWHX.js → chunk-63NMUNYP.js} +12 -16
  20. package/dist/{chunk-VWCXW2E7.js → chunk-6XSESGWD.js} +13 -6
  21. package/dist/{chunk-QGQ5CCCG.js → chunk-72J27ICO.js} +2 -3
  22. package/dist/{chunk-CSHFH5IN.js → chunk-7FLRUH6B.js} +1 -1
  23. package/dist/chunk-7IYC4ENJ.js +297 -0
  24. package/dist/chunk-7WWQAW5P.js +30 -0
  25. package/dist/{chunk-EU63SDCG.js → chunk-7ZS7MC24.js} +885 -451
  26. package/dist/{chunk-KBG47GHP.js → chunk-AHWA4AKM.js} +18 -12
  27. package/dist/{chunk-FMSO6RDZ.js → chunk-AI3GP74G.js} +17 -19
  28. package/dist/chunk-APFJKOP6.js +67 -0
  29. package/dist/{chunk-RXCOMYPY.js → chunk-ASRAO7KG.js} +31 -33
  30. package/dist/{chunk-BW5KFIQC.js → chunk-AWQWXSW4.js} +1 -0
  31. package/dist/{chunk-QILIYSJF.js → chunk-CG5V25HX.js} +1 -1
  32. package/dist/chunk-CKEQFGLT.js +32 -0
  33. package/dist/{chunk-RPLINGVB.js → chunk-COOUUC5W.js} +6 -6
  34. package/dist/{chunk-GBPP5P7X.js → chunk-CPZ5JJW6.js} +4 -4
  35. package/dist/{chunk-OCAGUNBC.js → chunk-DS2USX5G.js} +13 -15
  36. package/dist/chunk-EA2ZRG44.js +27 -0
  37. package/dist/{chunk-ZHFZWTZV.js → chunk-EDMLIW6W.js} +13 -14
  38. package/dist/{chunk-2EECBNC5.js → chunk-EIKRZ32J.js} +75 -0
  39. package/dist/chunk-EKNWOL2I.js +27 -0
  40. package/dist/{chunk-CMMHNUZ2.js → chunk-ELZRSR5N.js} +65 -43
  41. package/dist/{chunk-BKE7E7TC.js → chunk-EN5AM7PX.js} +11 -12
  42. package/dist/{chunk-N2H3ZPZY.js → chunk-EWXXLS26.js} +227 -24
  43. package/dist/chunk-EX4EXBW7.js +37 -0
  44. package/dist/{chunk-YYOIQFRS.js → chunk-EXVXBSGN.js} +130 -52
  45. package/dist/{chunk-6GFRNVYR.js → chunk-F7BO6FWH.js} +12 -13
  46. package/dist/chunk-FEDWAYDS.js +2485 -0
  47. package/dist/{chunk-JAU72XNY.js → chunk-FWZRGGGY.js} +73 -9
  48. package/dist/{chunk-GXW6K4YJ.js → chunk-G224FADB.js} +1 -1
  49. package/dist/chunk-G5UCJFT7.js +26 -0
  50. package/dist/{chunk-67WMNWEE.js → chunk-GLW3YDZZ.js} +22 -13
  51. package/dist/{chunk-724UL2TJ.js → chunk-GTDSYEA2.js} +72 -39
  52. package/dist/{chunk-PHDMFAKM.js → chunk-GYRZ72R4.js} +10 -4
  53. package/dist/chunk-HYVXA3BB.js +49 -0
  54. package/dist/{chunk-SAEFPSB6.js → chunk-IEBJF3PN.js} +23 -15
  55. package/dist/chunk-IJYGIDF4.js +186 -0
  56. package/dist/{chunk-ACXEQZOU.js → chunk-IL7K66ZQ.js} +101 -109
  57. package/dist/{chunk-ZXYDQ3TZ.js → chunk-JWOVP5BL.js} +50 -19
  58. package/dist/{chunk-OXXKQCSV.js → chunk-K2GUZ4DN.js} +4 -4
  59. package/dist/{chunk-AW7R2GWG.js → chunk-K4SZB56V.js} +39 -39
  60. package/dist/{chunk-WOA4LN2R.js → chunk-KCBRHV5E.js} +3 -3
  61. package/dist/{chunk-3W7IEVVL.js → chunk-KFXCL4OV.js} +47 -45
  62. package/dist/{chunk-2BBLFX75.js → chunk-KJJAVH3X.js} +81 -15
  63. package/dist/{chunk-VCHXCQFG.js → chunk-KPVLQHCZ.js} +4 -6
  64. package/dist/{chunk-P7266HLM.js → chunk-KX56K73G.js} +10 -13
  65. package/dist/{chunk-VSSBEUFT.js → chunk-LMCTHJ2H.js} +19 -19
  66. package/dist/{chunk-IBGIOBEE.js → chunk-MEFLGBCS.js} +69 -8
  67. package/dist/{chunk-TYM6OUIT.js → chunk-MKPCELNI.js} +17 -17
  68. package/dist/{chunk-XTMJ7XDT.js → chunk-N3PLNNCW.js} +1 -1
  69. package/dist/chunk-N5FBM25N.js +22 -0
  70. package/dist/{chunk-CHOW74WE.js → chunk-NFNVDDGB.js} +7 -12
  71. package/dist/{chunk-52FUZI6K.js → chunk-NLIVE7L6.js} +2 -30
  72. package/dist/{chunk-SS36ZX4J.js → chunk-OMJ3OFBJ.js} +6 -6
  73. package/dist/{chunk-4W4VLAPJ.js → chunk-OZNCKLOX.js} +13 -14
  74. package/dist/chunk-P5XUGPIX.js +31 -0
  75. package/dist/{chunk-5UCAH366.js → chunk-PJXNTPB2.js} +253 -33
  76. package/dist/chunk-PKOXJIVT.js +88 -0
  77. package/dist/{chunk-6C7JWPCP.js → chunk-PP2A5V2T.js} +27 -26
  78. package/dist/{chunk-L3BLXZG7.js → chunk-Q42LJANT.js} +31 -70
  79. package/dist/{chunk-AB3YYG6N.js → chunk-Q4BKKOVC.js} +8 -8
  80. package/dist/{chunk-3EFKIGZN.js → chunk-QT66NEYN.js} +4 -4
  81. package/dist/{chunk-3VPVG5SU.js → chunk-RCHO5W7M.js} +19 -18
  82. package/dist/{chunk-77M37OKR.js → chunk-RG3MXTRI.js} +7 -7
  83. package/dist/chunk-RG7OODGM.js +57 -0
  84. package/dist/{chunk-T6CPIZNT.js → chunk-RU34BA4D.js} +44 -39
  85. package/dist/{chunk-JMYYOTQG.js → chunk-S26LC76R.js} +13 -1
  86. package/dist/{chunk-5NGR67U5.js → chunk-S55TEC7I.js} +33 -5
  87. package/dist/{chunk-M6HSLBWY.js → chunk-SJHC3BCZ.js} +7956 -8047
  88. package/dist/{chunk-XCJN5IJU.js → chunk-SNEUMLM7.js} +4 -4
  89. package/dist/{chunk-UZ3TUTRV.js → chunk-T4NGVFYI.js} +2 -2
  90. package/dist/{chunk-2VUQMUMT.js → chunk-THEXI2QO.js} +49 -43
  91. package/dist/{chunk-R3PCY3YS.js → chunk-TL2TCJYL.js} +15 -16
  92. package/dist/{chunk-C34ZXZ7O.js → chunk-TPYYEDP5.js} +838 -352
  93. package/dist/{chunk-AOHZU2BM.js → chunk-TVZRLTG6.js} +8 -1
  94. package/dist/{chunk-XMSXXAHW.js → chunk-UCVMSOXF.js} +2 -2
  95. package/dist/chunk-UL5SXQVX.js +32 -0
  96. package/dist/{chunk-GAEGEPOC.js → chunk-UO66IMVP.js} +2 -2
  97. package/dist/{chunk-N3X6Q4YT.js → chunk-UVY4TOJH.js} +3 -3
  98. package/dist/{chunk-2CD5RS6M.js → chunk-VIDEKABZ.js} +23 -2
  99. package/dist/{chunk-JSQFTSC6.js → chunk-VITFDI3O.js} +13 -14
  100. package/dist/{chunk-YIUAVF7E.js → chunk-VUAVE3QC.js} +42 -42
  101. package/dist/{chunk-QOZXJ4NA.js → chunk-WUY4BZEP.js} +21 -20
  102. package/dist/{chunk-VCO24T4L.js → chunk-X3UTCXAA.js} +43 -53
  103. package/dist/chunk-XHDBJODR.js +45 -0
  104. package/dist/{chunk-MXGY6KPT.js → chunk-XHLK33VM.js} +28 -21
  105. package/dist/{chunk-RWWYJ623.js → chunk-XI34NWDI.js} +2 -2
  106. package/dist/{chunk-QQNQ7SJW.js → chunk-XWFIHYCH.js} +12 -4
  107. package/dist/{chunk-6SDEP3AJ.js → chunk-Y2TPADJR.js} +10 -11
  108. package/dist/{chunk-MRXKYPCS.js → chunk-Y5KTA2OB.js} +17 -17
  109. package/dist/{chunk-7DYBLXYA.js → chunk-YKVDBNPO.js} +11 -5
  110. package/dist/{chunk-2B73ZPOK.js → chunk-YSDPVDFC.js} +3 -3
  111. package/dist/chunk-YWNO5Q4R.js +44 -0
  112. package/dist/{chunk-QHJ6DQ2R.js → chunk-YWWG4AQA.js} +165 -32
  113. package/dist/{chunk-3JNKMP3B.js → chunk-YXDCRUKQ.js} +4 -4
  114. package/dist/{chunk-UXGETRP4.js → chunk-YXGRRORB.js} +16 -17
  115. package/dist/{chunk-SQ4TVJBR.js → chunk-ZAPSUBLU.js} +13 -7
  116. package/dist/{chunk-76MWC2K6.js → chunk-ZPJM7DID.js} +90 -97
  117. package/dist/{chunk-XVF2VVXP.js → chunk-ZSUX7KEM.js} +16 -15
  118. package/dist/index.js +31038 -20893
  119. package/dist/mcp/analyze-cli.js +11 -11
  120. package/dist/mcp/cli.js +47 -43
  121. package/dist/mcp/server.js +2188 -906
  122. package/dist/mcp/worker.js +66 -63
  123. package/dist/probes/installer.js +21 -23
  124. package/dist/workers/project-snapshot-persist-worker.js +28 -9
  125. package/dist/workers/review-graph-persist-worker.js +1 -1
  126. package/docs/adr/0010-trace-validation-session-lifecycle.md +390 -0
  127. package/docs/adr/README.md +1 -0
  128. package/docs/ast-grep_rules_catalog.md +5 -3
  129. package/docs/configuration.md +20 -0
  130. package/docs/engineering-principles.md +44 -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/lsp-capability-matrix.md +105 -12
  135. package/docs/lsp-idle-eviction.md +44 -36
  136. package/docs/pi-lens-fixer.md +139 -14
  137. package/docs/pi-lens-investigator.md +14 -0
  138. package/docs/pi-lens-merge-policy.md +120 -17
  139. package/docs/pi-lens-monitor.md +71 -9
  140. package/docs/pi-lens-retro.md +6 -3
  141. package/docs/pi-lens-reviewer.md +160 -5
  142. package/docs/pi-lens-subagent.md +29 -14
  143. package/docs/release-qa-baseline.md +21 -7
  144. package/docs/servercapabilities.md +53 -63
  145. package/docs/settings.md +9 -5
  146. package/docs/subagent-compat.md +1 -1
  147. package/docs/usage.md +1 -0
  148. package/package.json +9 -5
  149. package/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +17 -0
  150. package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-js-test.yml +86 -0
  151. package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-test.yml +86 -0
  152. package/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +15 -0
  153. package/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +9 -4
  154. package/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +119 -0
  155. package/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +119 -0
  156. package/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +13 -2
  157. package/rules/rule-catalog.json +25 -1
  158. package/scripts/analyze-pi-lens-logs.mjs +15 -5
  159. package/scripts/download-grammars.js +40 -7
  160. package/scripts/lib/is-main-module.mjs +27 -0
  161. package/scripts/lib/latency-log-phases.mjs +95 -0
  162. package/scripts/lib/scratch-home-env.mjs +21 -0
  163. package/scripts/rpc-load-check.mjs +568 -81
  164. package/scripts/warm-loader-cache.mjs +2 -5
  165. package/dist/chunk-23WOO7TX.js +0 -23
  166. package/dist/chunk-3YN6V5TV.js +0 -85
  167. package/dist/chunk-466Z26MG.js +0 -30
  168. package/dist/chunk-4UNXBNE2.js +0 -24
  169. package/dist/chunk-6STA6Z7I.js +0 -47
  170. package/dist/chunk-ABBOA7UD.js +0 -157
  171. package/dist/chunk-BRGDSBJE.js +0 -28
  172. package/dist/chunk-EC47DWFA.js +0 -56
  173. package/dist/chunk-FCSOVF55.js +0 -273
  174. package/dist/chunk-IZSHAIJ7.js +0 -26
  175. package/dist/chunk-KDERNTCQ.js +0 -28
  176. package/dist/chunk-KSX3TXSZ.js +0 -69
  177. package/dist/chunk-LOP6GRPH.js +0 -31
  178. package/dist/chunk-PNQDPDRC.js +0 -184
  179. package/dist/chunk-UOPVJQ4N.js +0 -103
  180. package/dist/chunk-XAGLWMJ4.js +0 -51
  181. package/dist/chunk-XIJZVPD5.js +0 -39
  182. package/dist/chunk-Z3CCVDUB.js +0 -76
  183. package/dist/chunk-Z527N6YQ.js +0 -28
  184. package/dist/chunk-ZANLILYD.js +0 -79
  185. /package/dist/{chunk-FC4RP4I2.js → chunk-6HWVI6MI.js} +0 -0
@@ -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-VWCXW2E7.js";
4
+ } from "./chunk-6XSESGWD.js";
5
5
  import {
6
+ PYTHON_COMPILE_VERDICT_SERVER_ID,
6
7
  augmentPythonEnvironment,
7
8
  detectPythonEnvironment,
8
- detectPythonVenv,
9
9
  pythonEnvironmentToolCandidates
10
- } from "./chunk-FCSOVF55.js";
10
+ } from "./chunk-3SNDVPOR.js";
11
11
  import {
12
- resolveGitCheckout,
13
- resolveLinkedWorktreeOwner
14
- } from "./chunk-PNQDPDRC.js";
12
+ hasCargoWorkspaceTable,
13
+ readCargoWorkspaceExclude,
14
+ readCargoWorkspaceMembers,
15
+ readTextFileOrUndefined
16
+ } from "./chunk-KX56K73G.js";
15
17
  import {
16
- extensionsForLanguage,
17
18
  getUserRuleRoot,
18
19
  ruleCorpusFingerprintForCycle
19
- } from "./chunk-724UL2TJ.js";
20
+ } from "./chunk-2Y6OJRSI.js";
20
21
  import {
21
22
  load,
22
23
  resolvePackagePath
23
- } from "./chunk-QOZXJ4NA.js";
24
+ } from "./chunk-WUY4BZEP.js";
24
25
  import {
25
- hasCargoWorkspaceTable,
26
- readCargoWorkspaceExclude,
27
- readCargoWorkspaceMembers,
28
- readTextFileOrUndefined
29
- } from "./chunk-P7266HLM.js";
26
+ extensionsForLanguage
27
+ } from "./chunk-GTDSYEA2.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-52FUZI6K.js";
33
+ } from "./chunk-NLIVE7L6.js";
34
34
  import {
35
35
  ensureTool,
36
36
  findManagedToolBinary,
@@ -40,44 +40,60 @@ import {
40
40
  isZizmorAuditTarget,
41
41
  logSessionStart,
42
42
  resolveZizmorGitHubToken
43
- } from "./chunk-ACXEQZOU.js";
43
+ } from "./chunk-IL7K66ZQ.js";
44
44
  import {
45
45
  resolveToolCwd
46
- } from "./chunk-Q7DUK4LX.js";
46
+ } from "./chunk-4FHUGDKU.js";
47
47
  import {
48
+ commandSearchReachesProject,
48
49
  findGlobalBinary,
49
50
  isProjectLocalBinPath
50
- } from "./chunk-AW7R2GWG.js";
51
+ } from "./chunk-K4SZB56V.js";
51
52
  import {
52
53
  classifyProbeFailure,
53
54
  createAvailabilityLatch,
54
55
  describeInstallAttempt,
55
56
  logAvailabilityDecision,
56
57
  startHostStallSampler
57
- } from "./chunk-VRZP76YM.js";
58
+ } from "./chunk-5LRUKYFA.js";
59
+ import {
60
+ readDirEntriesSafeAsync
61
+ } from "./chunk-S55TEC7I.js";
58
62
  import {
59
63
  OWNER_TAG_ENV,
60
64
  SpawnFailureError,
61
65
  classifySpawnFailure,
62
66
  createGenerationSource,
63
67
  ephemeralStagingRoot,
68
+ findCommandAsync,
64
69
  getGlobalPiLensDir,
65
70
  getProjectIgnoreGlobs,
66
71
  hasSpawnFailureKind,
67
72
  holdOwnChildPid,
68
73
  isCommandAvailableAsync,
74
+ isExcludedDirName,
69
75
  isPathIgnoredByProject,
70
76
  isPiLensInternalPath,
77
+ isSessionRepositoryPath,
78
+ isUntrustedProjectPath,
79
+ mergeWindowsEnvironment,
71
80
  ownerTagForChildren,
81
+ recordProjectCommandRefusal,
82
+ resolveGitCheckout,
83
+ resolveLinkedWorktreeOwner,
84
+ resolveSearchPathCommand,
72
85
  resolveWindowsCommandForEnvironment,
73
- safeSpawnAsync
74
- } from "./chunk-C34ZXZ7O.js";
86
+ safeSpawn,
87
+ safeSpawnAsync,
88
+ statIsFile,
89
+ trustScopedEnvironment
90
+ } from "./chunk-TPYYEDP5.js";
75
91
  import {
76
92
  DOTNET_CSHARP_ROOT_MARKERS,
77
93
  DOTNET_FSHARP_ROOT_MARKERS,
78
94
  KIND_EXTENSIONS,
79
95
  LEAN_ROOT_MARKERS
80
- } from "./chunk-PHDMFAKM.js";
96
+ } from "./chunk-GYRZ72R4.js";
81
97
  import {
82
98
  isRepoTier,
83
99
  lspSectionOf,
@@ -87,46 +103,46 @@ import {
87
103
  reportPiLensConfigRecords,
88
104
  resolvePiLensConfig,
89
105
  summarizeConfigResolution
90
- } from "./chunk-2BBLFX75.js";
106
+ } from "./chunk-KJJAVH3X.js";
91
107
  import {
92
108
  FRESHNESS_CADENCE_MS,
93
109
  LSP_NAMESPACE_KEY,
110
+ dirMtimeIsRacy,
94
111
  dirMtimeRecordsAsync,
95
112
  dirMtimesStillFreshAsync,
96
113
  getPiLensGlobalConfigPath,
97
114
  unknownDirMtimeRecords
98
- } from "./chunk-XVF2VVXP.js";
115
+ } from "./chunk-ZSUX7KEM.js";
99
116
  import {
117
+ getProjectTrustGeneration,
100
118
  getProjectTrustState
101
- } from "./chunk-ZANLILYD.js";
119
+ } from "./chunk-EIKRZ32J.js";
102
120
  import {
103
121
  getDegradationLedgerGeneration,
104
122
  incrementDegradationCount,
105
123
  recordDegradationOnce
106
- } from "./chunk-JAU72XNY.js";
124
+ } from "./chunk-FWZRGGGY.js";
107
125
  import {
108
126
  logExtension
109
- } from "./chunk-XTMJ7XDT.js";
127
+ } from "./chunk-N3PLNNCW.js";
110
128
  import {
111
129
  claimPhaseOncePerSession,
112
130
  currentSessionRecordId,
113
131
  logLatency,
114
132
  releasePhaseClaim
115
- } from "./chunk-QQNQ7SJW.js";
133
+ } from "./chunk-XWFIHYCH.js";
116
134
  import {
117
135
  getGlobalPiLensLogDir,
118
136
  getProcessSingleton,
119
137
  isTestMode,
120
138
  redactSecrets
121
- } from "./chunk-AOHZU2BM.js";
139
+ } from "./chunk-TVZRLTG6.js";
122
140
  import {
123
141
  STAGE_TMP_PATTERN
124
142
  } from "./chunk-LJDODBBZ.js";
125
143
  import {
126
144
  BoundedFifoMap,
127
- BoundedLruCache
128
- } from "./chunk-ABBOA7UD.js";
129
- import {
145
+ BoundedLruCache,
130
146
  CARGO_WORKSPACE_MEMBER_DIALECT,
131
147
  direntsHaveMarkerGlobMatch,
132
148
  findLocalToolConfig,
@@ -140,11 +156,9 @@ import {
140
156
  normalizeFilePath,
141
157
  normalizeMapKey,
142
158
  pathsEqual,
159
+ realpathOrResolve,
143
160
  toPosix
144
- } from "./chunk-N2H3ZPZY.js";
145
- import {
146
- __require
147
- } from "./chunk-NXL4FFQQ.js";
161
+ } from "./chunk-EWXXLS26.js";
148
162
 
149
163
  // dist/clients/analysis-root.js
150
164
  import * as fs from "node:fs";
@@ -182,28 +196,11 @@ function nearestProjectRoot(filePath) {
182
196
  }
183
197
  return hasProjectMarker(filesystemRoot) ? filesystemRoot : void 0;
184
198
  }
185
- function realPathOrResolved(filePath) {
186
- const resolved = nodePath.resolve(filePath);
187
- let current = resolved;
188
- const missing = [];
189
- while (true) {
190
- try {
191
- const real = fs.realpathSync.native(current);
192
- return nodePath.join(real, ...missing.reverse());
193
- } catch {
194
- const parent = nodePath.dirname(current);
195
- if (parent === current)
196
- return resolved;
197
- missing.push(nodePath.basename(current));
198
- current = parent;
199
- }
200
- }
201
- }
202
199
  function resolveAnalysisRootPath(filePath, sessionRoot, homeDirOverride) {
203
- const resolved = realPathOrResolved(filePath);
204
- const session = realPathOrResolved(sessionRoot);
205
- const tmp = realPathOrResolved(os.tmpdir());
206
- 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;
207
204
  if (isVendorPath(resolved))
208
205
  return void 0;
209
206
  if (resolved === tmp || resolved === session || isUnderDir(session, resolved) || !isUnderDir(resolved, session) && (isPiLensInternalPath(resolved, session) || data !== void 0 && (resolved === data || isUnderDir(resolved, data))))
@@ -217,7 +214,7 @@ function resolveAnalysisRootPath(filePath, sessionRoot, homeDirOverride) {
217
214
  const candidate = nearestProjectRoot(resolved);
218
215
  if (!candidate || candidate === nodePath.parse(candidate).root)
219
216
  return void 0;
220
- const home = realPathOrResolved(homeDirOverride ?? os.homedir());
217
+ const home = realpathOrResolve(homeDirOverride ?? os.homedir());
221
218
  if (isAtOrAboveHomeDir(candidate, home))
222
219
  return void 0;
223
220
  if (candidate === tmp || isUnderDir(session, candidate))
@@ -226,36 +223,67 @@ function resolveAnalysisRootPath(filePath, sessionRoot, homeDirOverride) {
226
223
  return void 0;
227
224
  return candidate;
228
225
  }
229
- function resolveAnalysisRoot(filePath, sessionRoot, homeDirOverride) {
230
- const resolved = realPathOrResolved(filePath);
226
+ function classifyAnalysisRoot(filePath, sessionRoot, homeDirOverride) {
227
+ const resolved = realpathOrResolve(filePath);
231
228
  if (isVendorPath(resolved))
232
- return "none";
229
+ return { mode: "none", root: void 0 };
233
230
  const checkout = resolveGitCheckout(sessionRoot);
234
- if (checkout && resolveLinkedWorktreeOwner(checkout, resolved)) {
235
- return "linked-worktree";
236
- }
231
+ const owner = checkout ? resolveLinkedWorktreeOwner(checkout, resolved) : null;
232
+ if (owner)
233
+ return { mode: "linked-worktree", root: owner.root };
237
234
  const root = resolveAnalysisRootPath(filePath, sessionRoot, homeDirOverride);
238
235
  if (!root)
239
- return "none";
240
- if (root === nodePath.resolve(sessionRoot))
241
- return "session";
242
- 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;
243
243
  }
244
244
  function canWriteAnalysisRoot(mode) {
245
245
  return mode === "session" || mode === "linked-worktree";
246
246
  }
247
247
 
248
+ // dist/clients/lsp/file-server-match.js
249
+ import path from "node:path";
250
+ function fileMatchKeys(filePath) {
251
+ return {
252
+ ext: path.extname(filePath).toLowerCase(),
253
+ base: path.basename(filePath).toLowerCase()
254
+ };
255
+ }
256
+ function fileMatchReason(server, filePath, ext, base) {
257
+ let matched = false;
258
+ for (const value of server.extensions) {
259
+ const lower = value.toLowerCase();
260
+ if (lower === ext || lower === base) {
261
+ matched = true;
262
+ break;
263
+ }
264
+ }
265
+ if (!matched)
266
+ return "extension-mismatch";
267
+ if (server.pathFilter && !server.pathFilter(filePath))
268
+ return "path-filter";
269
+ return "selected";
270
+ }
271
+ function registeredServers(config, catalog) {
272
+ const builtins = config.registeredServers.length ? config.registeredServers : catalog;
273
+ return [...builtins, ...config.customServers];
274
+ }
275
+
248
276
  // dist/clients/lsp/server.js
249
277
  import { existsSync as existsSync3, mkdirSync as mkdirSync2, statSync as statSync4 } from "node:fs";
250
- import { access, readFile, readdir, stat } from "node:fs/promises";
278
+ import { access, readFile, readdir, realpath, stat } from "node:fs/promises";
251
279
  import os7 from "node:os";
252
- import path6 from "node:path";
280
+ import path7 from "node:path";
253
281
 
254
282
  // dist/clients/sgconfig.js
255
283
  import { createHash } from "node:crypto";
256
284
  import * as fs2 from "node:fs";
257
285
  import * as os2 from "node:os";
258
- import * as path from "node:path";
286
+ import * as path2 from "node:path";
259
287
  var SGCONFIG_NAMES = ["sgconfig.yml", "sgconfig.yaml"];
260
288
  function findLocalSgconfig(startDir) {
261
289
  return findLocalToolConfig(startDir, SGCONFIG_NAMES);
@@ -264,20 +292,20 @@ function canonicalDir(dir) {
264
292
  try {
265
293
  return fs2.realpathSync.native(dir);
266
294
  } catch {
267
- return path.resolve(dir);
295
+ return path2.resolve(dir);
268
296
  }
269
297
  }
270
298
  function getAstGrepRuleSources(projectRoot = process.cwd()) {
271
- const root = path.resolve(projectRoot || process.cwd());
299
+ const root = path2.resolve(projectRoot || process.cwd());
272
300
  const packageRoot = resolvePackagePath(import.meta.url);
273
301
  const candidates = [];
274
302
  if (canonicalDir(root) !== canonicalDir(packageRoot)) {
275
303
  candidates.push({
276
- dir: path.join(root, "rules", "ast-grep-rules", "rules"),
304
+ dir: path2.join(root, "rules", "ast-grep-rules", "rules"),
277
305
  origin: "project",
278
306
  tier: "primary"
279
307
  }, {
280
- dir: path.join(root, "rules", "ast-grep-rules", "coderabbit", "rules"),
308
+ dir: path2.join(root, "rules", "ast-grep-rules", "coderabbit", "rules"),
281
309
  origin: "project",
282
310
  tier: "secondary"
283
311
  });
@@ -285,21 +313,21 @@ function getAstGrepRuleSources(projectRoot = process.cwd()) {
285
313
  const userRoot = getUserRuleRoot();
286
314
  if (canonicalDir(userRoot) !== canonicalDir(root)) {
287
315
  candidates.push({
288
- dir: path.join(userRoot, "ast-grep-rules", "rules"),
316
+ dir: path2.join(userRoot, "ast-grep-rules", "rules"),
289
317
  origin: "user",
290
318
  tier: "primary"
291
319
  }, {
292
- dir: path.join(userRoot, "ast-grep-rules", "coderabbit", "rules"),
320
+ dir: path2.join(userRoot, "ast-grep-rules", "coderabbit", "rules"),
293
321
  origin: "user",
294
322
  tier: "secondary"
295
323
  });
296
324
  }
297
325
  candidates.push({
298
- dir: path.join(packageRoot, "rules", "ast-grep-rules", "rules"),
326
+ dir: path2.join(packageRoot, "rules", "ast-grep-rules", "rules"),
299
327
  origin: "bundled",
300
328
  tier: "primary"
301
329
  }, {
302
- dir: path.join(packageRoot, "rules", "ast-grep-rules", "coderabbit", "rules"),
330
+ dir: path2.join(packageRoot, "rules", "ast-grep-rules", "coderabbit", "rules"),
303
331
  origin: "bundled",
304
332
  tier: "secondary"
305
333
  });
@@ -323,7 +351,7 @@ function findYamlFiles(dir) {
323
351
  return files;
324
352
  }
325
353
  for (const entry of entries) {
326
- const full = path.join(dir, entry.name);
354
+ const full = path2.join(dir, entry.name);
327
355
  if (entry.isDirectory()) {
328
356
  files.push(...findYamlFiles(full));
329
357
  } else if (entry.isFile() && /\.ya?ml$/i.test(entry.name)) {
@@ -365,7 +393,7 @@ function snapshotRuleSource(source) {
365
393
  const hash = createHash("sha256");
366
394
  const files = [];
367
395
  for (const file of findYamlFiles(source.dir)) {
368
- const relativePath = path.relative(source.dir, file);
396
+ const relativePath = path2.relative(source.dir, file);
369
397
  hash.update(relativePath);
370
398
  hash.update("\0");
371
399
  let content;
@@ -408,7 +436,7 @@ function sourceFingerprint(sources) {
408
436
  return hash.digest("hex");
409
437
  }
410
438
  function getAstGrepRuleFingerprint(projectRoot = process.cwd(), options = {}) {
411
- const root = path.resolve(projectRoot || process.cwd());
439
+ const root = path2.resolve(projectRoot || process.cwd());
412
440
  return ruleCorpusFingerprintForCycle("ast-grep", root, (fingerprintRoot) => sourceFingerprint(getAstGrepRuleSources(fingerprintRoot).map(snapshotRuleSource)), options.force);
413
441
  }
414
442
  function materializeMergedRuleDir(sources, mergedDir) {
@@ -428,7 +456,7 @@ function materializeMergedRuleDir(sources, mergedDir) {
428
456
  });
429
457
  if (survivingDocuments.length === 0)
430
458
  continue;
431
- const destination = path.join(mergedDir, `source${sourceIndex}-${String(fileIndex).padStart(5, "0")}.yml`);
459
+ const destination = path2.join(mergedDir, `source${sourceIndex}-${String(fileIndex).padStart(5, "0")}.yml`);
432
460
  if (survivingDocuments.length === file.documents.length) {
433
461
  fs2.copyFileSync(file.file, destination);
434
462
  } else {
@@ -445,7 +473,7 @@ function rootArtifactKey(root) {
445
473
  return createHash("sha256").update(root).digest("hex").slice(0, 12);
446
474
  }
447
475
  function resolveBaselineSgconfig(projectRoot = process.cwd()) {
448
- const root = canonicalDir(path.resolve(projectRoot || process.cwd()));
476
+ const root = canonicalDir(path2.resolve(projectRoot || process.cwd()));
449
477
  const fingerprint = getAstGrepRuleFingerprint(root, { force: true });
450
478
  const cached = cachedBaselines.get(root);
451
479
  if (cached?.fingerprint === fingerprint && fs2.existsSync(cached.path) && fs2.existsSync(cached.mergedDir)) {
@@ -454,11 +482,11 @@ function resolveBaselineSgconfig(projectRoot = process.cwd()) {
454
482
  const sources = getAstGrepRuleSources(root).map(snapshotRuleSource);
455
483
  if (sources.length === 0)
456
484
  return void 0;
457
- const dir = path.join(os2.tmpdir(), "pi-lens-ast-grep");
485
+ const dir = path2.join(os2.tmpdir(), "pi-lens-ast-grep");
458
486
  fs2.mkdirSync(dir, { recursive: true });
459
487
  const artifactKey = rootArtifactKey(root);
460
- const file = path.join(dir, `baseline-${process.pid}-${artifactKey}.sgconfig.yml`);
461
- const mergedDir = path.join(dir, `baseline-${process.pid}-${artifactKey}.rules`);
488
+ const file = path2.join(dir, `baseline-${process.pid}-${artifactKey}.sgconfig.yml`);
489
+ const mergedDir = path2.join(dir, `baseline-${process.pid}-${artifactKey}.rules`);
462
490
  const protectedArtifacts = /* @__PURE__ */ new Set([file, mergedDir]);
463
491
  for (const baseline of cachedBaselines.values()) {
464
492
  protectedArtifacts.add(baseline.path);
@@ -466,7 +494,7 @@ function resolveBaselineSgconfig(projectRoot = process.cwd()) {
466
494
  }
467
495
  cleanupStaleBaselines(dir, protectedArtifacts);
468
496
  materializeMergedRuleDir(sources, mergedDir);
469
- const ruleDirForYaml = mergedDir.split(path.sep).join("/");
497
+ const ruleDirForYaml = mergedDir.split(path2.sep).join("/");
470
498
  fs2.writeFileSync(file, `ruleDirs:
471
499
  - ${JSON.stringify(ruleDirForYaml)}
472
500
  `);
@@ -488,7 +516,7 @@ function enforceBaselineEntryCap(dir, keep) {
488
516
  const isMergedDir = /^baseline-\d+(?:-[a-f0-9]+)?\.rules$/.test(name);
489
517
  if (!isConfig && !isMergedDir)
490
518
  continue;
491
- const full = path.join(dir, name);
519
+ const full = path2.join(dir, name);
492
520
  if (keep.has(full))
493
521
  continue;
494
522
  try {
@@ -536,7 +564,7 @@ function cleanupStaleBaselines(dir, keep) {
536
564
  const isMergedDir = /^baseline-\d+(?:-[a-f0-9]+)?\.rules$/.test(name);
537
565
  if (!isConfig && !isMergedDir)
538
566
  continue;
539
- const full = path.join(dir, name);
567
+ const full = path2.join(dir, name);
540
568
  if (keep.has(full))
541
569
  continue;
542
570
  try {
@@ -577,6 +605,7 @@ function isAuxiliary(bearer) {
577
605
  return false;
578
606
  }
579
607
  }
608
+ var DEFAULT_RESEND_RECHECK = "unmeasured";
580
609
  var DEFAULT_NOTIFY_INFLIGHT_LIMIT = 8;
581
610
  var DEFAULT_REPLY_ORDERING = "unmeasured";
582
611
  function serverTraits(declaration) {
@@ -585,20 +614,22 @@ function serverTraits(declaration) {
585
614
  return {
586
615
  role: declaration.role,
587
616
  notifyInflightLimit: Math.floor(declaredLimit),
588
- replyOrdering: declaration.replyOrdering ?? DEFAULT_REPLY_ORDERING
617
+ replyOrdering: declaration.replyOrdering ?? DEFAULT_REPLY_ORDERING,
618
+ resendRecheck: declaration.resendRecheck ?? DEFAULT_RESEND_RECHECK
589
619
  };
590
620
  }
591
621
  const envLimit = Number(process.env.PI_LENS_LSP_AUX_NOTIFY_INFLIGHT);
592
622
  return {
593
623
  role: declaration.role,
594
624
  notifyInflightLimit: Number.isFinite(envLimit) && envLimit > 0 ? Math.floor(envLimit) : DEFAULT_NOTIFY_INFLIGHT_LIMIT,
595
- replyOrdering: declaration.replyOrdering ?? DEFAULT_REPLY_ORDERING
625
+ replyOrdering: declaration.replyOrdering ?? DEFAULT_REPLY_ORDERING,
626
+ resendRecheck: declaration.resendRecheck ?? DEFAULT_RESEND_RECHECK
596
627
  };
597
628
  }
598
629
 
599
630
  // dist/clients/lsp/config.js
600
631
  import * as os4 from "node:os";
601
- import path3 from "node:path";
632
+ import path4 from "node:path";
602
633
 
603
634
  // dist/clients/dispatch/known-runner-ids.js
604
635
  var knownRunnerIds = /* @__PURE__ */ new Set();
@@ -614,10 +645,10 @@ function isKnownRunnerId(id) {
614
645
 
615
646
  // dist/clients/lsp/launch.js
616
647
  import { AsyncLocalStorage } from "node:async_hooks";
617
- import { execFileSync, spawn as nodeSpawn } from "node:child_process";
648
+ import { spawn as nodeSpawn } from "node:child_process";
618
649
  import fs4 from "node:fs";
619
650
  import os3 from "node:os";
620
- import path2 from "node:path";
651
+ import path3 from "node:path";
621
652
 
622
653
  // dist/clients/lsp/ruby-drive-dirs.js
623
654
  import * as fs3 from "node:fs";
@@ -667,9 +698,9 @@ function computeNeedsShell(resolvedCommand) {
667
698
  var DEFAULT_STARTUP_FAILURE_WINDOW_MS = 50;
668
699
  var WINDOWS_NAV_STARTUP_FAILURE_WINDOW_MS = 500;
669
700
  var SESSIONSTART_LOG_DIR = getGlobalPiLensLogDir();
670
- var SESSIONSTART_LOG = path2.join(SESSIONSTART_LOG_DIR, "sessionstart.log");
671
- var PI_LENS_BIN_DIR = path2.join(getGlobalPiLensDir(), "bin");
672
- var PI_LENS_TOOLS_BIN_DIR = path2.join(getGlobalPiLensDir(), "tools", "node_modules", ".bin");
701
+ var SESSIONSTART_LOG = path3.join(SESSIONSTART_LOG_DIR, "sessionstart.log");
702
+ var PI_LENS_BIN_DIR = path3.join(getGlobalPiLensDir(), "bin");
703
+ var PI_LENS_TOOLS_BIN_DIR = path3.join(getGlobalPiLensDir(), "tools", "node_modules", ".bin");
673
704
  function logSessionStart2(msg) {
674
705
  if (isTestMode()) {
675
706
  return;
@@ -698,8 +729,8 @@ function splitPathEntries(value, delimiter) {
698
729
  }
699
730
  function normalizePathEntry(entry, platform) {
700
731
  if (platform !== "win32")
701
- return path2.posix.normalize(entry);
702
- return path2.win32.normalize(entry).toLowerCase();
732
+ return path3.posix.normalize(entry);
733
+ return path3.win32.normalize(entry).toLowerCase();
703
734
  }
704
735
  function combinePathValuesForPlatform(values, platform = process.platform) {
705
736
  const unique = [];
@@ -720,22 +751,10 @@ function resolvePathValue(env) {
720
751
  return combinePathValuesForPlatform([env.PATH, env.Path, env.path]);
721
752
  }
722
753
  function runStderrGuardedProbe(command, args) {
723
- try {
724
- const { execFileSync: execFileSync2 } = __require("node:child_process");
725
- const out = execFileSync2(command, args, {
726
- timeout: 3e3,
727
- encoding: "utf8",
728
- // #2095 sibling: execFileSync inherits stderr to the parent by
729
- // default (only stdout is captured into `out`), so a failed
730
- // powershell.exe launch would print raw diagnostics into the pi
731
- // TUI even though the surrounding catch already returns "" (read as
732
- // "unknown" PATH by every caller). Pipe stderr instead of inheriting it.
733
- stdio: ["ignore", "pipe", "ignore"]
734
- });
735
- return out.trim();
736
- } catch {
754
+ const result = safeSpawn(command, args, { timeout: 3e3 });
755
+ if (result.error || result.status !== 0)
737
756
  return "";
738
- }
757
+ return result.stdout.trim();
739
758
  }
740
759
  function readWindowsRegistryPath() {
741
760
  return runStderrGuardedProbe("powershell.exe", [
@@ -754,27 +773,27 @@ function getLiveWindowsPath() {
754
773
  }
755
774
  async function buildAugmentedPath(basePath) {
756
775
  const candidates = [];
757
- const nodeDir = path2.dirname(process.execPath);
776
+ const nodeDir = path3.dirname(process.execPath);
758
777
  if (nodeDir) {
759
778
  candidates.push(nodeDir);
760
779
  }
761
780
  if (isWindows) {
762
781
  const home = os3.homedir();
763
- const driveRoot = path2.parse(home).root;
764
- candidates.push(path2.join(home, ".cargo", "bin"));
765
- candidates.push(path2.join(home, "go", "bin"));
766
- candidates.push(path2.join(home, ".dotnet", "tools"));
782
+ const driveRoot = path3.parse(home).root;
783
+ candidates.push(path3.join(home, ".cargo", "bin"));
784
+ candidates.push(path3.join(home, "go", "bin"));
785
+ candidates.push(path3.join(home, ".dotnet", "tools"));
767
786
  candidates.push(PI_LENS_BIN_DIR);
768
787
  candidates.push(PI_LENS_TOOLS_BIN_DIR);
769
- candidates.push(path2.join(driveRoot, "Program Files", "Go", "bin"));
770
- candidates.push(path2.join(driveRoot, "Go", "bin"));
788
+ candidates.push(path3.join(driveRoot, "Program Files", "Go", "bin"));
789
+ candidates.push(path3.join(driveRoot, "Go", "bin"));
771
790
  for (const entry of await getRubyVersionDirNamesAsync(driveRoot)) {
772
- candidates.push(path2.join(driveRoot, entry, "bin"));
791
+ candidates.push(path3.join(driveRoot, entry, "bin"));
773
792
  }
774
793
  }
775
794
  const effectiveBase = isWindows ? combinePathValuesForPlatform([basePath, getLiveWindowsPath()]) : basePath;
776
795
  const existing = /* @__PURE__ */ new Set();
777
- for (const entry of splitPathEntries(effectiveBase, path2.delimiter)) {
796
+ for (const entry of splitPathEntries(effectiveBase, path3.delimiter)) {
778
797
  if (!entry)
779
798
  continue;
780
799
  existing.add(normalizePathEntry(entry, process.platform));
@@ -792,8 +811,8 @@ async function buildAugmentedPath(basePath) {
792
811
  if (toAppend.length === 0)
793
812
  return basePath ?? "";
794
813
  if (!basePath)
795
- return toAppend.join(path2.delimiter);
796
- return `${basePath}${path2.delimiter}${toAppend.join(path2.delimiter)}`;
814
+ return toAppend.join(path3.delimiter);
815
+ return `${basePath}${path3.delimiter}${toAppend.join(path3.delimiter)}`;
797
816
  }
798
817
  function isCmdShimValid(cmdPath) {
799
818
  try {
@@ -801,22 +820,30 @@ function isCmdShimValid(cmdPath) {
801
820
  const match = content.match(/"%~dp0[/\\]\.\.[/\\]((?:[\w./@-]|\\)+\.(?:mjs|cjs|js))"/i);
802
821
  if (!match)
803
822
  return true;
804
- const relPath = match[1].replace(/[/\\]/g, path2.sep);
805
- const target = path2.resolve(path2.dirname(cmdPath), "..", relPath);
823
+ const relPath = match[1].replace(/[/\\]/g, path3.sep);
824
+ const target = path3.resolve(path3.dirname(cmdPath), "..", relPath);
806
825
  return fs4.existsSync(target);
807
826
  } catch {
808
827
  return true;
809
828
  }
810
829
  }
811
- 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) {
812
841
  if (!isWindows)
813
842
  return false;
814
843
  if (/\.(cmd|bat)$/i.test(spawnCommand) && !isCmdShimValid(spawnCommand)) {
815
844
  return true;
816
845
  }
817
- if (spawnCommand !== command)
818
- return false;
819
- return resolveWindowsCommandForEnvironment(command, cwd, env) === null;
846
+ return presence === "absent";
820
847
  }
821
848
  function bypassPs1OnWindows(ps1Path, args) {
822
849
  const cmdPath = `${ps1Path.slice(0, -4)}.cmd`;
@@ -827,8 +854,8 @@ function bypassPs1OnWindows(ps1Path, args) {
827
854
  const content = fs4.readFileSync(ps1Path, "utf-8");
828
855
  const match = content.match(/"\$basedir[/\\]\.\.[/\\]((?:[\w./@-]|\\)+\.(?:mjs|cjs|js))"/i);
829
856
  if (match) {
830
- const relPath = match[1].replace(/[/\\]/g, path2.sep);
831
- const jsPath = path2.resolve(path2.dirname(ps1Path), "..", relPath);
857
+ const relPath = match[1].replace(/[/\\]/g, path3.sep);
858
+ const jsPath = path3.resolve(path3.dirname(ps1Path), "..", relPath);
832
859
  if (fs4.existsSync(jsPath)) {
833
860
  return {
834
861
  command: process.execPath,
@@ -841,29 +868,11 @@ function bypassPs1OnWindows(ps1Path, args) {
841
868
  }
842
869
  return void 0;
843
870
  }
844
- function findBinaryOnPath(command, env) {
845
- try {
846
- const result = execFileSync(isWindows ? "where" : "which", [command], {
847
- encoding: "utf-8",
848
- stdio: ["ignore", "pipe", "ignore"],
849
- env,
850
- // #1980 population sweep: this was the one synchronous
851
- // child-process site in the repo with no bound at all. It runs on
852
- // the LSP server spawn path, so an unresponsive `where`/`which` — a
853
- // stale network PATH entry is the classic cause — parked the event
854
- // loop with no ceiling, and read as ordinary compute in
855
- // `loop_block`. 5s matches `isCommandAvailable`/`findCommand` in
856
- // clients/safe-spawn.ts, which run these same two binaries.
857
- timeout: 5e3
858
- }).split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
859
- for (const candidate of result) {
860
- if (fs4.existsSync(candidate)) {
861
- return candidate;
862
- }
863
- }
864
- } catch {
871
+ function findBinaryOnPath(command, env, cwd) {
872
+ if (isWindows) {
873
+ return resolveWindowsCommandForEnvironment(command, cwd, env)?.resolvedPath;
865
874
  }
866
- return void 0;
875
+ return resolveSearchPathCommand(command, env.PATH, cwd);
867
876
  }
868
877
  var lspProjectCodePermission = new AsyncLocalStorage();
869
878
  function withLspProjectCodePermission(allowed, spawn) {
@@ -872,7 +881,7 @@ function withLspProjectCodePermission(allowed, spawn) {
872
881
  var unknownProjectLocalNoticeGeneration = -1;
873
882
  function recordUntrustedLspExecution(request, trust) {
874
883
  const generation = getDegradationLedgerGeneration();
875
- const subject = request.kind === "project-code-server" ? `project-code-server:g${generation}:${request.serverId}:${request.root}` : `project-local-binary:g${generation}:${path2.basename(request.command)}`;
884
+ const subject = request.kind === "project-code-server" ? `project-code-server:g${generation}:${request.serverId}:${request.root}` : `project-local-binary:g${generation}:${path3.basename(request.command)}`;
876
885
  const metadata = request.kind === "project-code-server" ? {
877
886
  field: request.kind,
878
887
  serverId: request.serverId,
@@ -906,24 +915,62 @@ function refuseUntrustedLspExecution(request) {
906
915
  return;
907
916
  if (request.kind === "project-code-server")
908
917
  recordUntrustedLspExecution(request, trust);
909
- throw new SpawnFailureError("spawn-failed", `LSP ${request.kind === "project-code-server" ? "project-code server" : "project-local binary"} refused: project trust is ${trust}`, new Error(`project trust is ${trust}`));
918
+ throw new SpawnFailureError(request.kind === "project-local-binary" ? "trust-refused" : "spawn-failed", `LSP ${request.kind === "project-code-server" ? "project-code server" : "project-local binary"} refused: project trust is ${trust}`, new Error(`project trust is ${trust}`));
910
919
  }
911
920
  function admitProjectSuppliedTsserver(tsserverPath, cwd, projectSupplied, projectCodeAllowed = lspProjectCodePermission.getStore() ?? false) {
912
921
  const trust = getProjectTrustState();
913
922
  if (tsserverPath && (!projectSupplied || projectCodeAllowed && trust === "trusted"))
914
923
  return tsserverPath;
924
+ if (!tsserverPath) {
925
+ recordUnresolvedTypeScriptCompiler(cwd, trust);
926
+ return void 0;
927
+ }
915
928
  recordUntrustedLspExecution({
916
929
  kind: "project-local-binary",
917
- command: tsserverPath ?? "tsserver.js",
918
- resolvedCommand: tsserverPath ?? "tsserver.js",
930
+ command: tsserverPath,
931
+ resolvedCommand: tsserverPath,
919
932
  cwd,
920
- reason: tsserverPath ? "LSP execution refused: project compiler requires trusted session ownership" : "LSP execution refused: no admitted absolute TypeScript compiler"
933
+ reason: "LSP execution refused: project compiler requires trusted session ownership"
921
934
  }, trust);
922
935
  return void 0;
923
936
  }
937
+ function recordUnresolvedTypeScriptCompiler(cwd, trust) {
938
+ const generation = getDegradationLedgerGeneration();
939
+ recordDegradationOnce({
940
+ kind: "lsp-registry-decision",
941
+ subject: `typescript-compiler:g${generation}:${cwd}`,
942
+ reason: "LSP not started: no absolute TypeScript compiler (tsserver.js) was resolved",
943
+ metadata: { field: "typescript-compiler", trust }
944
+ });
945
+ if (unknownProjectLocalNoticeGeneration === generation)
946
+ return;
947
+ unknownProjectLocalNoticeGeneration = generation;
948
+ if (trust !== "trusted" && sessionRepositoryHoldsCompiler(cwd))
949
+ return;
950
+ logExtension({
951
+ subsystem: "lsp-registry",
952
+ level: "warn",
953
+ message: "TypeScript language server not started: no absolute TypeScript compiler (tsserver.js) could be resolved; install typescript in the project or let pi-lens install it",
954
+ metadata: { field: "typescript-compiler" }
955
+ });
956
+ }
957
+ function sessionRepositoryHoldsCompiler(cwd) {
958
+ const found = findBinaryOnPath("tsc", process.env, cwd);
959
+ return found !== void 0 && isSessionRepositoryPath(found);
960
+ }
924
961
  function isProjectLocalLspBinary(resolvedCommand, cwd) {
925
962
  return isProjectLocalBinPath(resolvedCommand, cwd);
926
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
+ }
927
974
  function trySpawn(command, args, cwd, env, needsShell) {
928
975
  let proc;
929
976
  if (needsShell) {
@@ -1006,27 +1053,37 @@ async function launchLSP(command, args = [], options = {}) {
1006
1053
  const mergedEnv = { ...process.env, ...options.env };
1007
1054
  const augmentedPath = await buildAugmentedPath(resolvePathValue(mergedEnv));
1008
1055
  const ownerTag = await ownerTagForChildren({ timeoutMs: OWNER_TAG_READ_MS });
1009
- const env = {
1056
+ const env = trustScopedEnvironment({
1010
1057
  ...mergedEnv,
1011
1058
  PATH: augmentedPath,
1012
1059
  ...isWindows ? { Path: augmentedPath } : {}
1013
- };
1060
+ }, cwd);
1014
1061
  if (ownerTag === void 0)
1015
1062
  delete env[OWNER_TAG_ENV];
1016
1063
  else
1017
1064
  env[OWNER_TAG_ENV] = ownerTag;
1018
- const isRelativePath = !isFullyQualified(command) && (command.includes(path2.sep) || command.includes("/"));
1019
- const explicitCommand = isRelativePath ? path2.resolve(cwd, command) : command;
1020
- const resolvedCommand = !isFullyQualified(command) && !command.includes(path2.sep) && !command.includes("/") ? findBinaryOnPath(command, env) ?? explicitCommand : explicitCommand;
1065
+ const isBareCommand = !isFullyQualified(command) && !command.includes(path3.sep) && !command.includes("/");
1066
+ const isRelativePath = !isFullyQualified(command) && (command.includes(path3.sep) || command.includes("/"));
1067
+ const explicitCommand = isRelativePath ? path3.resolve(cwd, command) : command;
1068
+ const scannedCommandPath = isBareCommand ? findBinaryOnPath(command, env, cwd) : void 0;
1069
+ const resolvedCommand = scannedCommandPath ?? explicitCommand;
1021
1070
  let needsShell = computeNeedsShell(resolvedCommand);
1022
1071
  let spawnCommand = resolvedCommand;
1023
- if (!isFullyQualified(command) && !command.includes(path2.sep) && !command.includes("/")) {
1072
+ if (isBareCommand) {
1024
1073
  const globalBinPath = await findGlobalBinary(command);
1025
1074
  if (globalBinPath) {
1026
1075
  spawnCommand = globalBinPath;
1027
1076
  needsShell = computeNeedsShell(spawnCommand);
1028
1077
  }
1029
1078
  }
1079
+ const commandPresence = isWindows ? windowsCommandPresence({
1080
+ command,
1081
+ spawnCommand,
1082
+ isBareCommand,
1083
+ scannedCommandPath,
1084
+ cwd,
1085
+ env
1086
+ }) : "absent";
1030
1087
  if (isProjectLocalLspBinary(spawnCommand, cwd)) {
1031
1088
  refuseUntrustedLspExecution({
1032
1089
  kind: "project-local-binary",
@@ -1035,6 +1092,8 @@ async function launchLSP(command, args = [], options = {}) {
1035
1092
  cwd
1036
1093
  });
1037
1094
  }
1095
+ if (isBareCommand)
1096
+ refuseProjectLookup(command, spawnCommand, cwd, env);
1038
1097
  if (isWindows && /\.(cmd|bat)$/i.test(spawnCommand) && !isCmdShimValid(spawnCommand)) {
1039
1098
  logSessionStart2(`lsp cmd-shim-invalid: ${spawnCommand} target missing \u2014 skipping candidate`);
1040
1099
  const cause = Object.assign(new Error(`LSP .cmd shim target not found: ${spawnCommand}`), { code: "ENOENT" });
@@ -1055,7 +1114,7 @@ async function launchLSP(command, args = [], options = {}) {
1055
1114
  try {
1056
1115
  proc = trySpawn(spawnCommand, args, cwd, env, needsShell);
1057
1116
  } catch (err) {
1058
- if (!isFullyQualified(command) && !command.includes(path2.sep) && !command.includes("/")) {
1117
+ if (isBareCommand) {
1059
1118
  const globalBinPath = await findGlobalBinary(command);
1060
1119
  if (globalBinPath && globalBinPath !== spawnCommand) {
1061
1120
  const needsShellGlobal = computeNeedsShell(globalBinPath);
@@ -1073,7 +1132,7 @@ async function launchLSP(command, args = [], options = {}) {
1073
1132
  if (proc.exitCode !== null || proc.killed) {
1074
1133
  const message = `LSP server ${command} exited immediately (code: ${proc.exitCode}). The binary may be missing or corrupted.`;
1075
1134
  const failure = new Error(message);
1076
- if (proc.exitCode === 1 && isMissingWindowsStartupCommand(command, spawnCommand, cwd, env)) {
1135
+ if (proc.exitCode === 1 && isMissingWindowsStartupCommand(spawnCommand, commandPresence)) {
1077
1136
  throw new SpawnFailureError("tool-not-found", message, failure);
1078
1137
  }
1079
1138
  throw failure;
@@ -1111,7 +1170,7 @@ async function launchLSP(command, args = [], options = {}) {
1111
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.`;
1112
1171
  const message = `LSP server ${command} exited immediately with code ${code}. ${errorMsg}${formatStartupStderr(startupStderr)}`;
1113
1172
  const failure = new Error(message);
1114
- if (code === 1 && isMissingWindowsStartupCommand(command, spawnCommand, cwd, env)) {
1173
+ if (code === 1 && isMissingWindowsStartupCommand(spawnCommand, commandPresence)) {
1115
1174
  reject(new SpawnFailureError("tool-not-found", message, failure));
1116
1175
  return;
1117
1176
  }
@@ -1161,7 +1220,7 @@ function asRecord(value) {
1161
1220
  }
1162
1221
  var CONFIG_RESOLVED_PHASE = "config_resolved";
1163
1222
  function configResolutionKey(cwd) {
1164
- return normalizeFilePath(path3.resolve(normalizeFilePath(cwd)));
1223
+ return normalizeFilePath(path4.resolve(normalizeFilePath(cwd)));
1165
1224
  }
1166
1225
  function publishConfigResolutionPending(cwd) {
1167
1226
  logSessionStart(`session_start config_resolution_pending session=${currentSessionRecordId()} root=${configResolutionKey(cwd)}`);
@@ -1392,9 +1451,10 @@ var EMPTY_CONFIG = {
1392
1451
  };
1393
1452
  var configInFlight = /* @__PURE__ */ new Map();
1394
1453
  function normalizeWorkspacePath(cwd) {
1395
- return path3.resolve(cwd);
1454
+ return path4.resolve(cwd);
1396
1455
  }
1397
1456
  var unknownTrustNoticeGeneration = -1;
1457
+ var serversForFileOverride;
1398
1458
  function sourceFor(provenance, key) {
1399
1459
  const direct = provenanceFor({ value: void 0, provenance }, key);
1400
1460
  if (direct)
@@ -1436,28 +1496,135 @@ function registryDecision(id, field, provenance, trust, allowed) {
1436
1496
  }
1437
1497
  }
1438
1498
  }
1439
- function isSameOrChildPath(filePath, candidateRoot) {
1440
- if (filePath === candidateRoot)
1441
- return true;
1442
- return filePath.startsWith(`${candidateRoot}${path3.sep}`);
1443
- }
1444
1499
  function getConfigForFile(filePath) {
1445
- const resolvedFilePath = path3.resolve(filePath);
1446
- let bestMatch;
1447
- for (const [root, config] of sessionRootConfigEntries()) {
1448
- if (config === void 0)
1449
- continue;
1450
- if (!isSameOrChildPath(resolvedFilePath, root))
1451
- continue;
1452
- if (!bestMatch || root.length > bestMatch.root.length) {
1453
- bestMatch = { root, config };
1454
- }
1455
- }
1456
- return bestMatch?.config ?? EMPTY_CONFIG;
1500
+ return sessionRootConfigForFile(filePath) ?? EMPTY_CONFIG;
1457
1501
  }
1458
1502
  function registerLSPConfig(config) {
1459
1503
  return compileLspRegistry(config, config.__provenance);
1460
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
+ }
1461
1628
  function compileLspRegistry(config, provenance = /* @__PURE__ */ new Map()) {
1462
1629
  const trust = getProjectTrustState();
1463
1630
  const customServers = [];
@@ -1515,10 +1682,11 @@ function compileLspRegistry(config, provenance = /* @__PURE__ */ new Map()) {
1515
1682
  const overriddenBuiltins = LSP_SERVERS.map((server) => {
1516
1683
  const override = serverOverrides.get(server.id);
1517
1684
  if (!override?.command)
1518
- return { ...server };
1685
+ return server;
1519
1686
  const argv = Array.isArray(override.command) ? override.command : [override.command, "--stdio"];
1520
1687
  return {
1521
- ...server,
1688
+ ...keptOverrideTraits(server),
1689
+ idleEviction: "unmeasured",
1522
1690
  trustAllowed: true,
1523
1691
  async spawn(root, options) {
1524
1692
  void options;
@@ -1529,7 +1697,7 @@ function compileLspRegistry(config, provenance = /* @__PURE__ */ new Map()) {
1529
1697
  cwd: root,
1530
1698
  env: override.env ? { ...process.env, ...override.env } : process.env
1531
1699
  });
1532
- return { process: proc };
1700
+ return { process: proc, launchVariant: "override" };
1533
1701
  }
1534
1702
  };
1535
1703
  });
@@ -1564,40 +1732,24 @@ async function initLSPConfig(cwd) {
1564
1732
  }
1565
1733
  }
1566
1734
  }
1567
- function registeredServers(config) {
1568
- const builtins = config.registeredServers.length ? config.registeredServers : LSP_SERVERS;
1569
- return [...builtins, ...config.customServers];
1570
- }
1571
1735
  function selectionReason(server, config, filePath, ext, base) {
1572
1736
  if (config.disabledServerIds.has(server.id))
1573
1737
  return "disabled-by-config";
1574
- let matched = false;
1575
- for (const value of server.extensions) {
1576
- const lower = value.toLowerCase();
1577
- if (lower === ext || lower === base) {
1578
- matched = true;
1579
- break;
1580
- }
1581
- }
1582
- if (!matched)
1583
- return "extension-mismatch";
1584
- if (server.pathFilter && !server.pathFilter(filePath))
1585
- return "path-filter";
1586
- return "selected";
1738
+ return fileMatchReason(server, filePath, ext, base);
1587
1739
  }
1588
1740
  function explainServersForFile(filePath, config = getConfigForFile(filePath)) {
1589
- const ext = path3.extname(filePath).toLowerCase();
1590
- const base = path3.basename(filePath).toLowerCase();
1591
- return registeredServers(config).map((server) => {
1741
+ const { ext, base } = fileMatchKeys(filePath);
1742
+ return registeredServers(config, LSP_SERVERS).map((server) => {
1592
1743
  const reason = selectionReason(server, config, filePath, ext, base);
1593
1744
  return { server, selected: reason === "selected", reason };
1594
1745
  });
1595
1746
  }
1596
1747
  function getServersForFileWithConfig(filePath) {
1748
+ if (serversForFileOverride)
1749
+ return serversForFileOverride(filePath);
1597
1750
  const config = getConfigForFile(filePath);
1598
- const ext = path3.extname(filePath).toLowerCase();
1599
- const base = path3.basename(filePath).toLowerCase();
1600
- return registeredServers(config).filter((server) => selectionReason(server, config, filePath, ext, base) === "selected");
1751
+ const { ext, base } = fileMatchKeys(filePath);
1752
+ return registeredServers(config, LSP_SERVERS).filter((server) => selectionReason(server, config, filePath, ext, base) === "selected");
1601
1753
  }
1602
1754
  function primaryServerEntry(filePath) {
1603
1755
  return getServersForFileWithConfig(filePath).find((s) => !isAuxiliary(s));
@@ -1662,10 +1814,20 @@ var SERVER_DIAGNOSTIC_STRATEGIES = {
1662
1814
  debounceMs: 50,
1663
1815
  aggregateWaitMs: 1e3,
1664
1816
  expectSemanticSecondPush: false,
1665
- // #3310 / nightly run 37930006227: the clean TypeScript fixture
1666
- // published an empty pre-index result before its settled result.
1667
- // Hold that first publish so it cannot resolve a push wait as clean.
1668
- 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.
1669
1831
  // Tier 3 (#458): typescript-language-server publishes nothing on a
1670
1832
  // clean→clean edit (docs/lsp-capability-matrix.md, re-confirmed
1671
1833
  // 2026-07-12). It's the lone core-set tier-3 server, which is exactly
@@ -1717,7 +1879,10 @@ var SERVER_DIAGNOSTIC_STRATEGIES = {
1717
1879
  },
1718
1880
  // Opengrep security scanner (cross-language LSP). It pushes an EMPTY result
1719
1881
  // during the one-time rule-load window at startup, then the real scan after
1720
- // `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
1721
1886
  // diagnostics). Warm per-file scan ~1.3s; the first touch in a session may
1722
1887
  // also pay rule-load (~3.5s cold). aggregateWaitMs is 3500: it's this
1723
1888
  // server's OWN deadline, bounded by the per-edit caller cap as a ceiling
@@ -1734,7 +1899,8 @@ var SERVER_DIAGNOSTIC_STRATEGIES = {
1734
1899
  expectSemanticSecondPush: false,
1735
1900
  // Opengrep re-scans only on a fresh didOpen — didChange is a no-op for it.
1736
1901
  reopenOnResync: true,
1737
- rescansOnSave: true
1902
+ rescansOnSave: true,
1903
+ emptyUntilRulesRefreshed: true
1738
1904
  },
1739
1905
  // ast-grep structural linter (sgconfig-gated auxiliary LSP). Push-only,
1740
1906
  // compiles the project rules on the first scan of a session, and — like
@@ -1902,25 +2068,24 @@ var SERVER_DIAGNOSTIC_STRATEGIES = {
1902
2068
  // #3484: the fence reply (+2..4 ms) precedes the publish (~+1 s).
1903
2069
  diagnosticsFence: "reply-first"
1904
2070
  },
1905
- // terraform-ls (#3310). The nightly tool-smoke measurement was identical
1906
- // on 2026-09-27, 2026-09-28, and 2026-09-29:
1907
- //
1908
- // [terraform] clean-behavior=publishes-unversioned (tier 2*)
1909
- // dirtyPubs=2(v:0) cleanPubs=2(v:0) first-publish=empty-first
1910
- // provisional pre-index publish
1911
- //
1912
- // The first empty, unversioned publish is the cold-index artifact, so hold
1913
- // it once and let terraform-ls's next publish resolve the wait. A held
1914
- // clean-only trace therefore reaches the caller as unanswered/indeterminate
1915
- // at the wait ceiling rather than a false clean, by design (#3310). The
1916
- // 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).
1917
2083
  terraform: {
1918
2084
  seedFirstPush: false,
1919
2085
  pullRetryBudgetMs: 0,
1920
2086
  debounceMs: 150,
1921
2087
  aggregateWaitMs: 1500,
1922
- expectSemanticSecondPush: false,
1923
- emptyFirstPublish: "indexing"
2088
+ expectSemanticSecondPush: false
1924
2089
  },
1925
2090
  // yaml-language-server (#3484): the default strategy plus the measured
1926
2091
  // fence order — reply +3..6 ms, publish +207..242 ms after didChange.
@@ -2020,10 +2185,90 @@ var DEFAULT_STRATEGY = {
2020
2185
  aggregateWaitMs: 1500,
2021
2186
  expectSemanticSecondPush: false
2022
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
+ }
2023
2266
  function getStrategy(serverId, launchVariant) {
2024
2267
  if (serverId === "typescript" && launchVariant === "native-ts7") {
2025
2268
  return NATIVE_TS7_DIAGNOSTIC_STRATEGY;
2026
2269
  }
2270
+ if (launchVariant === "override")
2271
+ return overrideStrategy(serverId);
2027
2272
  return SERVER_DIAGNOSTIC_STRATEGIES[serverId] ?? DEFAULT_STRATEGY;
2028
2273
  }
2029
2274
 
@@ -2067,14 +2312,14 @@ function classifyCascadeWaitTier(lspService, filePath, snapshots) {
2067
2312
  // dist/clients/lsp/lombok.js
2068
2313
  import * as fs5 from "node:fs";
2069
2314
  import * as os5 from "node:os";
2070
- import * as path4 from "node:path";
2315
+ import * as path5 from "node:path";
2071
2316
  var LOMBOK_ENV_KEYS = ["PI_LENS_LOMBOK_JAR", "LOMBOK_JAR"];
2072
2317
  var LOMBOK_PROJECT_FILES = [
2073
2318
  "lombok.config",
2074
2319
  "pom.xml",
2075
2320
  "build.gradle",
2076
2321
  "build.gradle.kts",
2077
- path4.join("gradle", "libs.versions.toml")
2322
+ path5.join("gradle", "libs.versions.toml")
2078
2323
  ];
2079
2324
  function fileExists(filePath) {
2080
2325
  if (!filePath)
@@ -2099,13 +2344,13 @@ function containsLombokDependency(text) {
2099
2344
  return /\borg\.projectlombok\b/i.test(text) || /<artifactId>\s*lombok\s*<\/artifactId>/i.test(text) || /\b(annotationProcessor|compileOnly|testCompileOnly|testAnnotationProcessor)\b[^\n]*\blombok\b/i.test(text);
2100
2345
  }
2101
2346
  function hasLombokProject(root) {
2102
- const lombokConfig = path4.join(root, "lombok.config");
2347
+ const lombokConfig = path5.join(root, "lombok.config");
2103
2348
  if (fileExists(lombokConfig))
2104
2349
  return true;
2105
2350
  for (const name of LOMBOK_PROJECT_FILES) {
2106
2351
  if (name === "lombok.config")
2107
2352
  continue;
2108
- const text = readTextIfSmall(path4.join(root, name));
2353
+ const text = readTextIfSmall(path5.join(root, name));
2109
2354
  if (text && containsLombokDependency(text))
2110
2355
  return true;
2111
2356
  }
@@ -2115,16 +2360,16 @@ function envJarCandidate(env) {
2115
2360
  for (const key of LOMBOK_ENV_KEYS) {
2116
2361
  const value = env[key]?.trim();
2117
2362
  if (fileExists(value))
2118
- return path4.resolve(value);
2363
+ return path5.resolve(value);
2119
2364
  }
2120
2365
  return void 0;
2121
2366
  }
2122
2367
  function localJarCandidates(root) {
2123
2368
  return [
2124
- path4.join(root, "lombok.jar"),
2125
- path4.join(root, ".lombok", "lombok.jar"),
2126
- path4.join(root, "lib", "lombok.jar"),
2127
- path4.join(root, "libs", "lombok.jar")
2369
+ path5.join(root, "lombok.jar"),
2370
+ path5.join(root, ".lombok", "lombok.jar"),
2371
+ path5.join(root, "lib", "lombok.jar"),
2372
+ path5.join(root, "libs", "lombok.jar")
2128
2373
  ];
2129
2374
  }
2130
2375
  function newestExistingJar(candidates) {
@@ -2143,17 +2388,17 @@ function newestExistingJar(candidates) {
2143
2388
  return best?.filePath;
2144
2389
  }
2145
2390
  function mavenLocalLombokJar(home = os5.homedir()) {
2146
- const base = path4.join(home, ".m2", "repository", "org", "projectlombok", "lombok");
2391
+ const base = path5.join(home, ".m2", "repository", "org", "projectlombok", "lombok");
2147
2392
  let versions = [];
2148
2393
  try {
2149
2394
  versions = fs5.readdirSync(base);
2150
2395
  } catch {
2151
2396
  return void 0;
2152
2397
  }
2153
- return newestExistingJar(versions.map((version) => path4.join(base, version, `lombok-${version}.jar`)));
2398
+ return newestExistingJar(versions.map((version) => path5.join(base, version, `lombok-${version}.jar`)));
2154
2399
  }
2155
2400
  function gradleCacheLombokJar(home = os5.homedir()) {
2156
- const base = path4.join(home, ".gradle", "caches", "modules-2", "files-2.1", "org.projectlombok", "lombok");
2401
+ const base = path5.join(home, ".gradle", "caches", "modules-2", "files-2.1", "org.projectlombok", "lombok");
2157
2402
  const candidates = [];
2158
2403
  let versions = [];
2159
2404
  try {
@@ -2162,7 +2407,7 @@ function gradleCacheLombokJar(home = os5.homedir()) {
2162
2407
  return void 0;
2163
2408
  }
2164
2409
  for (const version of versions) {
2165
- const versionDir = path4.join(base, version);
2410
+ const versionDir = path5.join(base, version);
2166
2411
  let hashes = [];
2167
2412
  try {
2168
2413
  hashes = fs5.readdirSync(versionDir);
@@ -2170,7 +2415,7 @@ function gradleCacheLombokJar(home = os5.homedir()) {
2170
2415
  continue;
2171
2416
  }
2172
2417
  for (const hash of hashes) {
2173
- candidates.push(path4.join(versionDir, hash, `lombok-${version}.jar`));
2418
+ candidates.push(path5.join(versionDir, hash, `lombok-${version}.jar`));
2174
2419
  }
2175
2420
  }
2176
2421
  return newestExistingJar(candidates);
@@ -2203,15 +2448,15 @@ function createLombokJdtlsArgs(root, baseEnv = process.env) {
2203
2448
  // dist/clients/lsp/jvm-runtime.js
2204
2449
  import { existsSync as existsSync2, readdirSync as readdirSync4 } from "node:fs";
2205
2450
  import os6 from "node:os";
2206
- import path5 from "node:path";
2451
+ import path6 from "node:path";
2207
2452
  var JAVA_EXE = process.platform === "win32" ? "java.exe" : "java";
2208
2453
  var JAVA_PROBE_TIMEOUT_MS = 5e3;
2209
2454
  var MIN_JAVA_MAJOR = 17;
2210
2455
  function jdkHomeFrom(dir) {
2211
- if (existsSync2(path5.join(dir, "bin", JAVA_EXE)))
2456
+ if (existsSync2(path6.join(dir, "bin", JAVA_EXE)))
2212
2457
  return dir;
2213
- const macHome = path5.join(dir, "Contents", "Home");
2214
- if (existsSync2(path5.join(macHome, "bin", JAVA_EXE)))
2458
+ const macHome = path6.join(dir, "Contents", "Home");
2459
+ if (existsSync2(path6.join(macHome, "bin", JAVA_EXE)))
2215
2460
  return macHome;
2216
2461
  return void 0;
2217
2462
  }
@@ -2224,7 +2469,7 @@ function parseMajorVersion(name) {
2224
2469
  }
2225
2470
  function childDirs(base) {
2226
2471
  try {
2227
- return readdirSync4(base, { withFileTypes: true }).filter((e) => e.isDirectory() || e.isSymbolicLink()).map((e) => path5.join(base, e.name));
2472
+ return readdirSync4(base, { withFileTypes: true }).filter((e) => e.isDirectory() || e.isSymbolicLink()).map((e) => path6.join(base, e.name));
2228
2473
  } catch {
2229
2474
  return [];
2230
2475
  }
@@ -2232,26 +2477,26 @@ function childDirs(base) {
2232
2477
  function candidateRoots() {
2233
2478
  const home = os6.homedir();
2234
2479
  const roots = [];
2235
- roots.push(path5.join(home, ".jdks"));
2236
- roots.push(path5.join(getGlobalPiLensDir(), "tools"));
2480
+ roots.push(path6.join(home, ".jdks"));
2481
+ roots.push(path6.join(getGlobalPiLensDir(), "tools"));
2237
2482
  if (process.platform === "win32") {
2238
2483
  const progFiles = [
2239
2484
  process.env.ProgramFiles,
2240
2485
  process.env["ProgramFiles(x86)"],
2241
2486
  process.env.ProgramW6432,
2242
- path5.join(process.env.LOCALAPPDATA ?? path5.join(home, "AppData", "Local"), "Programs")
2487
+ path6.join(process.env.LOCALAPPDATA ?? path6.join(home, "AppData", "Local"), "Programs")
2243
2488
  ].filter((p) => Boolean(p));
2244
2489
  for (const base of progFiles) {
2245
- roots.push(path5.join(base, "Eclipse Adoptium"));
2246
- roots.push(path5.join(base, "Java"));
2247
- roots.push(path5.join(base, "Microsoft"));
2248
- roots.push(path5.join(base, "Zulu"));
2249
- roots.push(path5.join(base, "Amazon Corretto"));
2250
- roots.push(path5.join(base, "BellSoft"));
2490
+ roots.push(path6.join(base, "Eclipse Adoptium"));
2491
+ roots.push(path6.join(base, "Java"));
2492
+ roots.push(path6.join(base, "Microsoft"));
2493
+ roots.push(path6.join(base, "Zulu"));
2494
+ roots.push(path6.join(base, "Amazon Corretto"));
2495
+ roots.push(path6.join(base, "BellSoft"));
2251
2496
  }
2252
2497
  } else if (process.platform === "darwin") {
2253
2498
  roots.push("/Library/Java/JavaVirtualMachines");
2254
- roots.push(path5.join(home, "Library", "Java", "JavaVirtualMachines"));
2499
+ roots.push(path6.join(home, "Library", "Java", "JavaVirtualMachines"));
2255
2500
  roots.push("/opt/homebrew/opt");
2256
2501
  roots.push("/usr/local/opt");
2257
2502
  } else {
@@ -2275,7 +2520,7 @@ function discoverJdkHome(roots = candidateRoots(), javaHome = process.env.JAVA_H
2275
2520
  continue;
2276
2521
  found.push({
2277
2522
  home: resolved,
2278
- major: parseMajorVersion(path5.basename(dir))
2523
+ major: parseMajorVersion(path6.basename(dir))
2279
2524
  });
2280
2525
  }
2281
2526
  }
@@ -2289,6 +2534,7 @@ var _cachedEnv;
2289
2534
  var javaAvailabilityLatch = createAvailabilityLatch();
2290
2535
  var inFlightJavaProbe = null;
2291
2536
  function probeJavaOnPath() {
2537
+ const trustGeneration = getProjectTrustGeneration();
2292
2538
  const memo = javaAvailabilityLatch.read();
2293
2539
  if (memo !== null) {
2294
2540
  if (javaAvailabilityLatch.getOutcome() === "transient") {
@@ -2309,12 +2555,14 @@ function probeJavaOnPath() {
2309
2555
  }
2310
2556
  return Promise.resolve(memo);
2311
2557
  }
2312
- if (inFlightJavaProbe)
2313
- return inFlightJavaProbe;
2314
- inFlightJavaProbe = runJavaProbe().finally(() => {
2315
- inFlightJavaProbe = null;
2558
+ if (inFlightJavaProbe?.trustGeneration === trustGeneration)
2559
+ return inFlightJavaProbe.promise;
2560
+ const promise = runJavaProbe().finally(() => {
2561
+ if (inFlightJavaProbe?.promise === promise)
2562
+ inFlightJavaProbe = null;
2316
2563
  });
2317
- return inFlightJavaProbe;
2564
+ inFlightJavaProbe = { trustGeneration, promise };
2565
+ return promise;
2318
2566
  }
2319
2567
  async function runJavaProbe() {
2320
2568
  const finder = process.platform === "win32" ? "where" : "which";
@@ -2365,27 +2613,29 @@ async function runJavaProbe() {
2365
2613
  return outcome === "transient" ? void 0 : false;
2366
2614
  }
2367
2615
  async function resolveJavaRuntimeEnv() {
2368
- if (_cachedEnv)
2616
+ if (_cachedEnv?.trustGeneration === getProjectTrustGeneration())
2369
2617
  return _cachedEnv.value;
2618
+ const trustGeneration = getProjectTrustGeneration();
2370
2619
  const javaOnPath = await probeJavaOnPath();
2371
2620
  if (javaOnPath === true) {
2372
- _cachedEnv = { value: void 0 };
2621
+ _cachedEnv = { value: void 0, trustGeneration };
2373
2622
  return void 0;
2374
2623
  }
2375
2624
  const home = discoverJdkHome();
2376
2625
  if (home) {
2377
- const binDir = path5.join(home, "bin");
2626
+ const binDir = path6.join(home, "bin");
2378
2627
  const currentPath = process.env.PATH ?? process.env.Path ?? "";
2379
2628
  _cachedEnv = {
2380
2629
  value: {
2381
2630
  JAVA_HOME: home,
2382
- PATH: binDir + path5.delimiter + currentPath
2383
- }
2631
+ PATH: binDir + path6.delimiter + currentPath
2632
+ },
2633
+ trustGeneration
2384
2634
  };
2385
2635
  return _cachedEnv.value;
2386
2636
  }
2387
2637
  if (javaOnPath === false) {
2388
- _cachedEnv = { value: void 0 };
2638
+ _cachedEnv = { value: void 0, trustGeneration };
2389
2639
  }
2390
2640
  return void 0;
2391
2641
  }
@@ -2405,7 +2655,7 @@ function withRootMarkers(root, markers) {
2405
2655
  root.rootMarkers = markers;
2406
2656
  return root;
2407
2657
  }
2408
- function describeRootFallback(fallback) {
2658
+ function describeRootFallback(fallback, hosted = true) {
2409
2659
  const tail = "so pi-lens cannot confirm the server analysed the file";
2410
2660
  if (fallback.cause === "failed") {
2411
2661
  return `${fallback.serverName}: resolving the project root for this file failed, ${tail}`;
@@ -2413,7 +2663,9 @@ function describeRootFallback(fallback) {
2413
2663
  if (fallback.cause === "unselected") {
2414
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}`;
2415
2665
  }
2416
- 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;
2417
2669
  }
2418
2670
  async function resolveLspServerCwd(server, filePath, sessionCwd, onRootFailure, onRootFallback) {
2419
2671
  const stagingRoot = ephemeralStagingRoot(filePath);
@@ -2435,7 +2687,7 @@ async function resolveLspServerCwd(server, filePath, sessionCwd, onRootFailure,
2435
2687
  rootFailed = true;
2436
2688
  onRootFailure?.(reason);
2437
2689
  }
2438
- const isFileDirFallback = serverRoot !== void 0 && rootMarkers?.length && path6.resolve(serverRoot) === path6.resolve(path6.dirname(filePath));
2690
+ const isFileDirFallback = serverRoot !== void 0 && rootMarkers?.length && path7.resolve(serverRoot) === path7.resolve(path7.dirname(filePath));
2439
2691
  if (!serverRoot || isFileDirFallback) {
2440
2692
  const probedMarker = onRootFallback && !rootFailed && rootMarkers?.length ? resolveToolCwd("lsp", server.id, filePath, {
2441
2693
  cwd: sessionCwd,
@@ -2444,7 +2696,7 @@ async function resolveLspServerCwd(server, filePath, sessionCwd, onRootFailure,
2444
2696
  }).marker : void 0;
2445
2697
  const refusedMarker = probedMarker !== void 0 && rootMarkers?.includes(probedMarker) ? probedMarker : void 0;
2446
2698
  const fallbackCwd = rootMarkers?.length ? resolveToolCwd("lsp", server.id, filePath, {
2447
- cwd: path6.dirname(path6.resolve(filePath)),
2699
+ cwd: path7.dirname(path7.resolve(filePath)),
2448
2700
  rootMarkers
2449
2701
  }) : void 0;
2450
2702
  if (!serverRoot) {
@@ -2459,7 +2711,10 @@ async function resolveLspServerCwd(server, filePath, sessionCwd, onRootFailure,
2459
2711
  rootMarkers: rootMarkers ?? [],
2460
2712
  requiresProjectRoot: server.requiresProjectRoot === true,
2461
2713
  cause: rootFailed ? "failed" : refusedMarker !== void 0 ? "unselected" : "none",
2462
- ...refusedMarker !== void 0 && { marker: refusedMarker }
2714
+ ...refusedMarker !== void 0 && { marker: refusedMarker },
2715
+ ...server.spawnNeedsProjectFile === true && {
2716
+ searchBound: PROJECT_FILE_SEARCH_MAX_DIRS
2717
+ }
2463
2718
  });
2464
2719
  }
2465
2720
  return fallbackCwd?.cwd;
@@ -2498,6 +2753,9 @@ var PROJECT_BOUNDARY_MARKERS = [
2498
2753
  "Cargo.toml",
2499
2754
  "Cargo.lock",
2500
2755
  "pyproject.toml",
2756
+ "setup.py",
2757
+ "setup.cfg",
2758
+ "requirements.txt",
2501
2759
  "uv.lock",
2502
2760
  "poetry.lock",
2503
2761
  "Pipfile",
@@ -2509,22 +2767,29 @@ var PROJECT_BOUNDARY_MARKERS = [
2509
2767
  "settings.gradle.kts",
2510
2768
  "mix.exs",
2511
2769
  "pubspec.yaml",
2512
- "Package.swift"
2770
+ "Package.swift",
2771
+ "buildServer.json"
2513
2772
  ];
2773
+ var PYTHON_BOUNDARY_MARKERS = /* @__PURE__ */ new Set([
2774
+ "setup.py",
2775
+ "setup.cfg",
2776
+ "requirements.txt"
2777
+ ]);
2778
+ var PYTHON_EXTENSIONS = new Set(extensionsForLanguage("python"));
2514
2779
  var loggedRootCeilingClamps = /* @__PURE__ */ new Set();
2515
2780
  var posixCaseInsensitiveByPath = /* @__PURE__ */ new Map();
2516
2781
  function posixFilesystemIsCaseInsensitive(root) {
2517
- const resolved = path6.resolve(root);
2782
+ const resolved = path7.resolve(root);
2518
2783
  const cached = posixCaseInsensitiveByPath.get(resolved);
2519
2784
  if (cached !== void 0)
2520
2785
  return cached;
2521
2786
  if (!existsSync3(resolved)) {
2522
2787
  return false;
2523
2788
  }
2524
- const name = path6.basename(resolved);
2789
+ const name = path7.basename(resolved);
2525
2790
  const alternate = name.toLowerCase() === name ? name.toUpperCase() : name.toLowerCase();
2526
2791
  let insensitive = false;
2527
- const alternatePath = path6.join(path6.dirname(resolved), alternate);
2792
+ const alternatePath = path7.join(path7.dirname(resolved), alternate);
2528
2793
  if (alternate !== name && existsSync3(alternatePath)) {
2529
2794
  try {
2530
2795
  const actual = statSync4(resolved);
@@ -2542,7 +2807,7 @@ function resetLSPCaseSensitivityState() {
2542
2807
  }
2543
2808
  function isSameOrWithin(ancestor, candidate, deps = {}) {
2544
2809
  const windowsShaped = isWindowsPath(ancestor) || isWindowsPath(candidate);
2545
- const pathApi = windowsShaped ? path6.win32 : path6;
2810
+ const pathApi = windowsShaped ? path7.win32 : path7;
2546
2811
  const resolvedAncestor = pathApi.resolve(ancestor);
2547
2812
  const resolvedCandidate = pathApi.resolve(candidate);
2548
2813
  let caseInsensitive = false;
@@ -2562,13 +2827,13 @@ function isSameOrWithin(ancestor, candidate, deps = {}) {
2562
2827
  }
2563
2828
  function enforceLspRootCeiling(root, sessionCwd, filePath) {
2564
2829
  const windowsShaped = isWindowsPath(root) || isWindowsPath(sessionCwd);
2565
- const pathApi = windowsShaped ? path6.win32 : path6;
2830
+ const pathApi = windowsShaped ? path7.win32 : path7;
2566
2831
  const resolvedRoot = pathApi.resolve(root);
2567
2832
  const resolvedCwd = pathApi.resolve(sessionCwd);
2568
2833
  if (filePath && !isSameOrWithin(resolvedCwd, pathApi.resolve(filePath))) {
2569
2834
  return resolvedRoot;
2570
2835
  }
2571
- if (isSameOrWithin(resolvedCwd, resolvedRoot))
2836
+ if (isSameOrWithin(resolvedCwd, resolvedRoot) || isUnderDir(resolvedRoot, resolvedCwd))
2572
2837
  return resolvedRoot;
2573
2838
  const logKey = `${normalizeMapKey(resolvedCwd)}:${normalizeMapKey(resolvedRoot)}`;
2574
2839
  if (!loggedRootCeilingClamps.has(logKey)) {
@@ -2577,18 +2842,20 @@ function enforceLspRootCeiling(root, sessionCwd, filePath) {
2577
2842
  }
2578
2843
  return resolvedCwd;
2579
2844
  }
2580
- async function hasProjectBoundaryMarker(dir) {
2845
+ async function hasProjectBoundaryMarker(dir, server) {
2581
2846
  if (await markerExists(dir, ".git"))
2582
2847
  return true;
2583
2848
  for (const marker of PROJECT_BOUNDARY_MARKERS) {
2849
+ if (PYTHON_BOUNDARY_MARKERS.has(marker) && !server.extensions.some((extension) => PYTHON_EXTENSIONS.has(extension)))
2850
+ continue;
2584
2851
  if (await markerExists(dir, marker))
2585
2852
  return true;
2586
2853
  }
2587
2854
  return false;
2588
2855
  }
2589
2856
  function pathSegments(dir) {
2590
- const parsed = path6.parse(path6.resolve(dir));
2591
- return path6.relative(parsed.root, path6.resolve(dir)).split(path6.sep).filter(Boolean).map((segment) => segment.toLowerCase());
2857
+ const parsed = path7.parse(path7.resolve(dir));
2858
+ return path7.relative(parsed.root, path7.resolve(dir)).split(path7.sep).filter(Boolean).map((segment) => segment.toLowerCase());
2592
2859
  }
2593
2860
  function hasFixtureConvention(dir) {
2594
2861
  const segments = pathSegments(dir);
@@ -2599,46 +2866,61 @@ function hasFixtureConvention(dir) {
2599
2866
  function hasAtomicStageSegment(dir) {
2600
2867
  return pathSegments(dir).some((segment) => STAGE_TMP_PATTERN.test(segment));
2601
2868
  }
2602
- async function findGitBoundary(dir) {
2603
- let current = path6.resolve(dir);
2604
- const fsRoot = path6.parse(current).root;
2869
+ async function findGitBoundary(dir, memo) {
2870
+ let current = path7.resolve(dir);
2871
+ const fsRoot = path7.parse(current).root;
2872
+ const visited = [];
2873
+ let found;
2605
2874
  while (true) {
2606
- if (await markerExists(current, ".git"))
2607
- 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
+ }
2608
2885
  if (current === fsRoot)
2609
- return void 0;
2610
- current = path6.dirname(current);
2886
+ break;
2887
+ current = path7.dirname(current);
2611
2888
  }
2889
+ for (const seen of visited)
2890
+ memo?.set(seen, found);
2891
+ return found;
2612
2892
  }
2613
- async function isExcludedLspRoot(dir) {
2614
- const candidate = path6.resolve(dir);
2893
+ async function isExcludedLspRoot(dir, gitBoundaries) {
2894
+ const candidate = path7.resolve(dir);
2615
2895
  if (hasFixtureConvention(candidate) || hasAtomicStageSegment(candidate))
2616
2896
  return true;
2617
- const gitRoot = await findGitBoundary(candidate);
2897
+ const gitRoot = await findGitBoundary(candidate, gitBoundaries);
2618
2898
  if (!gitRoot || gitRoot === candidate)
2619
2899
  return false;
2620
2900
  if (getProjectIgnoreGlobs(gitRoot).length === 0)
2621
2901
  return false;
2622
2902
  return isPathIgnoredByProject(candidate, gitRoot, true);
2623
2903
  }
2624
- async function nearestNonExcludedFallbackRoot(candidate) {
2625
- if (!await isExcludedLspRoot(candidate))
2626
- return path6.resolve(candidate);
2627
- let current = path6.dirname(path6.resolve(candidate));
2628
- const fsRoot = path6.parse(current).root;
2904
+ async function nearestNonExcludedFallbackRoot(candidate, stopDir) {
2905
+ let current = path7.resolve(candidate);
2906
+ const startDir = current;
2907
+ const fsRoot = path7.parse(current).root;
2629
2908
  let nearestAllowed;
2909
+ const gitBoundaries = /* @__PURE__ */ new Map();
2630
2910
  while (true) {
2631
- if (!await isExcludedLspRoot(current)) {
2911
+ if (!await isExcludedLspRoot(current, gitBoundaries)) {
2632
2912
  nearestAllowed ??= current;
2633
2913
  for (const marker of FALLBACK_PROJECT_MARKERS) {
2634
2914
  if (await markerExists(current, marker))
2635
2915
  return current;
2636
2916
  }
2637
2917
  }
2638
- if (current === fsRoot)
2918
+ if (current === fsRoot || normalizeEphemeralMapKey(current) === stopDir)
2639
2919
  break;
2640
- current = path6.dirname(current);
2920
+ current = path7.dirname(current);
2641
2921
  }
2922
+ if (stopDir !== void 0)
2923
+ return nearestAllowed ?? startDir;
2642
2924
  return nearestAllowed ?? fsRoot;
2643
2925
  }
2644
2926
  function isLspInstallDisabled() {
@@ -2678,7 +2960,7 @@ async function installEvidenceForLaunch(toolId, installed, attempt) {
2678
2960
  const confirmedManagedPath = await findManagedToolBinary(toolId);
2679
2961
  return {
2680
2962
  ...evidence,
2681
- binary: path6.basename(installed),
2963
+ binary: path7.basename(installed),
2682
2964
  ...confirmedManagedPath !== void 0 && pathsEqual(confirmedManagedPath, installed) && {
2683
2965
  source: "managed-dir"
2684
2966
  }
@@ -2731,7 +3013,7 @@ function markDirectLspCommandUnavailable(command) {
2731
3013
  directLspCommandUnavailableUntil.set(command, Date.now() + DIRECT_LSP_NEGATIVE_TTL_MS);
2732
3014
  directLspCommandSkipLoggedUntil.delete(command);
2733
3015
  }
2734
- var PI_LENS_BIN_DIR2 = path6.join(getGlobalPiLensDir(), "bin");
3016
+ var PI_LENS_BIN_DIR2 = path7.join(getGlobalPiLensDir(), "bin");
2735
3017
  async function resolveAndLaunch(spec, allowInstall) {
2736
3018
  const generation = lspLaunchAvailabilityGeneration.capture();
2737
3019
  const toolLabel = spec.managedToolId ?? spec.candidates[spec.candidates.length - 1] ?? "unknown";
@@ -2796,7 +3078,7 @@ async function resolveAndLaunch(spec, allowInstall) {
2796
3078
  producer: "lsp-launch",
2797
3079
  classifiedBy: "probe",
2798
3080
  evidence: {
2799
- binary: path6.basename(managedCandidate),
3081
+ binary: path7.basename(managedCandidate),
2800
3082
  source: "managed-dir",
2801
3083
  correctsLatchedRow: false
2802
3084
  }
@@ -2827,7 +3109,7 @@ async function resolveAndLaunch(spec, allowInstall) {
2827
3109
  logSessionStart(`lsp launch candidate failed tool=${toolLabel} idx=${failure.index} command=${failure.command} error=${failure.message}`);
2828
3110
  trackRuntimeFailure(failure.err);
2829
3111
  }
2830
- const hasOnlyRepairableCandidateFailures = candidateFailures.every((failure) => hasSpawnFailureKind(failure.err, "tool-not-found"));
3112
+ const hasOnlyRepairableCandidateFailures = candidateFailures.every((failure) => hasSpawnFailureKind(failure.err, "tool-not-found") || hasSpawnFailureKind(failure.err, "trust-refused"));
2831
3113
  if (!hasOnlyRepairableCandidateFailures) {
2832
3114
  if (lastRuntimeFailure)
2833
3115
  throw lastRuntimeFailure;
@@ -2846,14 +3128,19 @@ async function resolveAndLaunch(spec, allowInstall) {
2846
3128
  globalInstallDisabled: isLspInstallDisabled()
2847
3129
  }
2848
3130
  });
3131
+ if (lastRuntimeFailure)
3132
+ throw lastRuntimeFailure;
2849
3133
  return void 0;
2850
3134
  }
3135
+ const isRefusal = (failure) => hasSpawnFailureKind(failure.err, "trust-refused");
3136
+ const trustRefused = candidateFailures.some(isRefusal);
3137
+ const storeOnly = trustRefused && (candidateFailures.some((failure) => isRefusal(failure) && isSimpleCommand(failure.command)) || commandSearchReachesProject(spec.cwd));
2851
3138
  if (spec.managedToolId) {
2852
3139
  const failedCandidate = candidateFailures.at(-1);
2853
3140
  const classifiedFailure = classifyProbeFailure({
2854
3141
  error: failedCandidate?.err instanceof Error ? failedCandidate.err : void 0,
2855
3142
  spawnFailure: {
2856
- kind: hasSpawnFailureKind(failedCandidate?.err, "tool-not-found") ? "tool-not-found" : void 0
3143
+ kind: ["tool-not-found", "trust-refused"].find((kind) => hasSpawnFailureKind(failedCandidate?.err, kind))
2857
3144
  }
2858
3145
  }, { command: failedCandidate?.command });
2859
3146
  logAvailabilityDecision({
@@ -2867,10 +3154,18 @@ async function resolveAndLaunch(spec, allowInstall) {
2867
3154
  producer: "lsp-launch",
2868
3155
  evidence: classifiedFailure.evidence
2869
3156
  });
2870
- logSessionStart(`lsp launch ensure-tool start tool=${spec.managedToolId} cwd=${spec.cwd}`);
3157
+ if (storeOnly) {
3158
+ recordDegradationOnce({
3159
+ kind: "lsp-registry-decision",
3160
+ subject: `store-only-repair:${spec.managedToolId}`,
3161
+ reason: "LSP repair read only the pi-lens tool store: after a trust refusal a bare-name lookup reaches the project, so nothing was probed on PATH or installed",
3162
+ metadata: { field: "store-only-repair", tool: spec.managedToolId }
3163
+ });
3164
+ }
3165
+ logSessionStart(`lsp launch ensure-tool start tool=${spec.managedToolId} cwd=${spec.cwd} storeOnly=${storeOnly}`);
2871
3166
  const installStartedAt = Date.now();
2872
- const installed = await ensureTool(spec.managedToolId);
2873
- const installAttempt = captureInstallAttempt(spec.managedToolId);
3167
+ const installed = await (storeOnly ? getToolPath(spec.managedToolId, { storeOnly: true }) : ensureTool(spec.managedToolId));
3168
+ const installAttempt = storeOnly ? void 0 : captureInstallAttempt(spec.managedToolId);
2874
3169
  if (staleLaunch(generation, `${toolLabel}:ensureTool`)) {
2875
3170
  return void 0;
2876
3171
  }
@@ -3000,7 +3295,7 @@ async function resolveAndLaunch(spec, allowInstall) {
3000
3295
  }
3001
3296
  }
3002
3297
  }
3003
- const runtimeInstall = spec.runtimeInstall;
3298
+ const runtimeInstall = trustRefused ? void 0 : spec.runtimeInstall;
3004
3299
  const runtimeAvailable = runtimeInstall ? await isOnPath(runtimeInstall.runtimeCommand) : false;
3005
3300
  if (staleLaunch(generation, `${toolLabel}:runtimeAvailability`)) {
3006
3301
  return void 0;
@@ -3089,7 +3384,7 @@ async function resolveAndLaunchTreeBinary(spec, allowInstall) {
3089
3384
  return void 0;
3090
3385
  }
3091
3386
  const suffix = process.platform === "win32" ? ".exe" : "";
3092
- const binPath = path6.join(bundleDir, ...spec.binRelPath.split("/")) + suffix;
3387
+ const binPath = path7.join(bundleDir, ...spec.binRelPath.split("/")) + suffix;
3093
3388
  try {
3094
3389
  const proc = await launchLSP(binPath, spec.args, {
3095
3390
  cwd: spec.cwd,
@@ -3104,7 +3399,7 @@ async function resolveAndLaunchTreeBinary(spec, allowInstall) {
3104
3399
  }
3105
3400
  }
3106
3401
  function nodeBinLocalCandidates(root, baseName) {
3107
- const localBase = path6.join(root, "node_modules", ".bin", baseName);
3402
+ const localBase = path7.join(root, "node_modules", ".bin", baseName);
3108
3403
  if (process.platform === "win32") {
3109
3404
  return [`${localBase}.cmd`, `${localBase}.exe`];
3110
3405
  }
@@ -3114,7 +3409,7 @@ function nodeBinCandidates(root, baseName) {
3114
3409
  return [...nodeBinLocalCandidates(root, baseName), baseName];
3115
3410
  }
3116
3411
  function piAgentExtensionsRootKey(file) {
3117
- const dirKey = normalizeEphemeralMapKey(path6.dirname(path6.resolve(file)));
3412
+ const dirKey = normalizeEphemeralMapKey(path7.dirname(path7.resolve(file)));
3118
3413
  const marker = "/.pi/agent/extensions";
3119
3414
  const index = dirKey.indexOf(marker);
3120
3415
  if (index === -1)
@@ -3122,12 +3417,12 @@ function piAgentExtensionsRootKey(file) {
3122
3417
  return dirKey.slice(0, index + marker.length);
3123
3418
  }
3124
3419
  function IgnoreHomeRoot(primary) {
3125
- const homeKey = normalizeEphemeralMapKey(path6.resolve(os7.homedir()));
3420
+ const homeKey = normalizeEphemeralMapKey(realpathOrResolve(os7.homedir()));
3126
3421
  return withRootMarkers(async (file) => {
3127
3422
  const root = await primary(file);
3128
3423
  if (!root)
3129
3424
  return void 0;
3130
- return normalizeEphemeralMapKey(path6.resolve(root)) === homeKey ? void 0 : root;
3425
+ return normalizeEphemeralMapKey(path7.resolve(root)) === homeKey ? void 0 : root;
3131
3426
  }, primary.rootMarkers ?? []);
3132
3427
  }
3133
3428
  function rubyBinCandidates(baseName) {
@@ -3135,13 +3430,13 @@ function rubyBinCandidates(baseName) {
3135
3430
  const home = os7.homedir();
3136
3431
  const isWin = process.platform === "win32";
3137
3432
  const ext = isWin ? ".bat" : "";
3138
- candidates.push(path6.join(home, ".local", "share", "mise", "installs", "ruby", "bin", `${baseName}${ext}`));
3139
- candidates.push(path6.join(home, ".asdf", "installs", "ruby", "bin", `${baseName}${ext}`));
3433
+ candidates.push(path7.join(home, ".local", "share", "mise", "installs", "ruby", "bin", `${baseName}${ext}`));
3434
+ candidates.push(path7.join(home, ".asdf", "installs", "ruby", "bin", `${baseName}${ext}`));
3140
3435
  if (isWin) {
3141
- const driveRoot = path6.parse(home).root;
3436
+ const driveRoot = path7.parse(home).root;
3142
3437
  for (const entry of getRubyVersionDirNamesSync(driveRoot)) {
3143
- candidates.push(path6.join(driveRoot, entry, "bin", `${baseName}.bat`));
3144
- candidates.push(path6.join(driveRoot, entry, "bin", baseName));
3438
+ candidates.push(path7.join(driveRoot, entry, "bin", `${baseName}.bat`));
3439
+ candidates.push(path7.join(driveRoot, entry, "bin", baseName));
3145
3440
  }
3146
3441
  }
3147
3442
  return candidates;
@@ -3198,9 +3493,38 @@ function PriorityRoot(markerGroups, excludePatterns, stopDir) {
3198
3493
  }, markerGroups.flat());
3199
3494
  }
3200
3495
  var FileDirRoot = async (file) => {
3201
- const candidate = path6.resolve(path6.dirname(file));
3202
- return nearestNonExcludedFallbackRoot(candidate);
3496
+ const candidate = path7.resolve(path7.dirname(file));
3497
+ return nearestNonExcludedFallbackRoot(candidate, piAgentExtensionsRootKey(file));
3203
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
+ }
3204
3528
  function RootWithFallback(primary, fallback = FileDirRoot) {
3205
3529
  return withRootMarkers(async (file) => {
3206
3530
  const primaryRoot = await primary(file);
@@ -3220,16 +3544,16 @@ function markerProbeDir(dir, pattern) {
3220
3544
  const normalized = toPosix(pattern);
3221
3545
  const slash = normalized.lastIndexOf("/");
3222
3546
  const parentPattern = slash >= 0 ? normalized.slice(0, slash) : "";
3223
- return parentPattern ? path6.join(dir, ...parentPattern.split("/").filter(Boolean)) : dir;
3547
+ return parentPattern ? path7.join(dir, ...parentPattern.split("/").filter(Boolean)) : dir;
3224
3548
  }
3225
3549
  async function markerExists(dir, pattern) {
3226
3550
  if (!pattern.includes("*")) {
3227
3551
  try {
3228
- await stat(path6.join(dir, pattern));
3552
+ await stat(path7.join(dir, pattern));
3229
3553
  return true;
3230
3554
  } catch (err) {
3231
3555
  if (isPermissionFsError(err)) {
3232
- logSessionStart(`lsp root marker skipped: permission error stat ${path6.join(dir, pattern)}`);
3556
+ logSessionStart(`lsp root marker skipped: permission error stat ${path7.join(dir, pattern)}`);
3233
3557
  }
3234
3558
  return false;
3235
3559
  }
@@ -3265,8 +3589,9 @@ function NearestRoot(includePatterns, excludePatterns, stopDir) {
3265
3589
  subdirPatterns.push(pattern);
3266
3590
  }
3267
3591
  return withRootMarkers(async (file) => {
3268
- const startDir = path6.resolve(path6.dirname(file));
3269
- const dirKey = normalizeMapKey(startDir);
3592
+ const identity = realpathOrResolve(file);
3593
+ const startDir = path7.dirname(identity);
3594
+ const dirKey = normalizeEphemeralMapKey(startDir);
3270
3595
  const cached = cache.get(dirKey);
3271
3596
  if (cached !== void 0 && Date.now() - cached.walkedAt < FRESHNESS_CADENCE_MS && await bounded(dirMtimesStillFreshAsync(cached.probedDirs), rootMtimeBound("lsp-root-memo-freshness")) === true)
3272
3597
  return cached.root;
@@ -3277,10 +3602,10 @@ function NearestRoot(includePatterns, excludePatterns, stopDir) {
3277
3602
  const walkedAt = Date.now();
3278
3603
  const promise = (async () => {
3279
3604
  let currentDir = startDir;
3280
- const fsRoot = path6.parse(currentDir).root;
3281
- const stop = stopDir ? path6.resolve(stopDir) : fsRoot;
3605
+ const fsRoot = path7.parse(currentDir).root;
3606
+ const stop = stopDir ? realpathOrResolve(stopDir) : fsRoot;
3282
3607
  while (true) {
3283
- if (stop !== fsRoot && currentDir.startsWith(stop + path6.sep) === false && currentDir !== stop) {
3608
+ if (stop !== fsRoot && currentDir.startsWith(stop + path7.sep) === false && currentDir !== stop) {
3284
3609
  break;
3285
3610
  }
3286
3611
  const stepDirs = [
@@ -3298,26 +3623,26 @@ function NearestRoot(includePatterns, excludePatterns, stopDir) {
3298
3623
  }
3299
3624
  }
3300
3625
  if (excluded) {
3301
- currentDir = path6.dirname(currentDir);
3626
+ currentDir = path7.dirname(currentDir);
3302
3627
  continue;
3303
3628
  }
3304
3629
  }
3305
3630
  for (const pattern of includePatterns) {
3306
- if (await markerExists(currentDir, pattern) && (pattern !== ".git" || currentDir !== os7.tmpdir()) && !await isExcludedLspRoot(currentDir)) {
3307
- 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);
3308
3633
  }
3309
3634
  }
3310
3635
  if (currentDir === stop || currentDir === fsRoot) {
3311
3636
  break;
3312
3637
  }
3313
- currentDir = path6.dirname(currentDir);
3638
+ currentDir = path7.dirname(currentDir);
3314
3639
  }
3315
3640
  return void 0;
3316
3641
  })();
3317
3642
  inFlight.set(dirKey, promise);
3318
3643
  try {
3319
3644
  const result = await promise;
3320
- if (result !== void 0)
3645
+ if (result !== void 0 && !probedDirs.some((r) => dirMtimeIsRacy(r.mtimeMs, walkedAt)))
3321
3646
  cache.set(dirKey, { root: result, probedDirs, walkedAt });
3322
3647
  return result;
3323
3648
  } finally {
@@ -3352,17 +3677,17 @@ async function findAncestorFile(startDir, ...relativeSegments) {
3352
3677
  }
3353
3678
  async function findAncestorFileAmong(startDir, candidateSegmentLists) {
3354
3679
  const fs6 = await import("node:fs/promises");
3355
- let currentDir = path6.resolve(startDir);
3680
+ let currentDir = path7.resolve(startDir);
3356
3681
  while (!isAtOrAboveHomeDir(currentDir)) {
3357
3682
  for (const segments of candidateSegmentLists) {
3358
- const candidate = path6.join(currentDir, ...segments);
3683
+ const candidate = path7.join(currentDir, ...segments);
3359
3684
  try {
3360
3685
  await fs6.access(candidate);
3361
3686
  return candidate;
3362
3687
  } catch {
3363
3688
  }
3364
3689
  }
3365
- const parent = path6.dirname(currentDir);
3690
+ const parent = path7.dirname(currentDir);
3366
3691
  if (parent === currentDir)
3367
3692
  break;
3368
3693
  currentDir = parent;
@@ -3378,19 +3703,21 @@ function resetClassicTsRepairGuard() {
3378
3703
  classicTsRepairState().attempted = false;
3379
3704
  }
3380
3705
  function typescriptDirsForTsc(tscPath) {
3381
- const binDir = path6.dirname(tscPath);
3706
+ const binDir = path7.dirname(tscPath);
3382
3707
  return [
3383
- path6.join(binDir, "..", "typescript"),
3384
- path6.join(binDir, "..", "..", "typescript")
3708
+ path7.join(binDir, "..", "typescript"),
3709
+ path7.join(binDir, "..", "..", "typescript"),
3710
+ // Windows npm-global: `<prefix>/tsc.cmd` beside `<prefix>/node_modules`.
3711
+ path7.join(binDir, "node_modules", "typescript")
3385
3712
  ];
3386
3713
  }
3387
3714
  async function typescriptVersionForTsc(tscPath) {
3388
- if (!path6.isAbsolute(tscPath))
3715
+ if (!path7.isAbsolute(tscPath))
3389
3716
  return void 0;
3390
3717
  for (const dir of typescriptDirsForTsc(tscPath)) {
3391
3718
  let manifest;
3392
3719
  try {
3393
- manifest = await readFile(path6.join(dir, "package.json"), "utf8");
3720
+ manifest = await readFile(path7.join(dir, "package.json"), "utf8");
3394
3721
  } catch {
3395
3722
  continue;
3396
3723
  }
@@ -3412,15 +3739,28 @@ async function typescriptVersionForTsc(tscPath) {
3412
3739
  }
3413
3740
  return void 0;
3414
3741
  }
3742
+ async function hasTypescriptPackageDir(tscPath) {
3743
+ for (const dir of typescriptDirsForTsc(tscPath)) {
3744
+ if ((await stat(dir).catch(() => void 0))?.isDirectory())
3745
+ return true;
3746
+ }
3747
+ return false;
3748
+ }
3749
+ async function absoluteCommandPath(command) {
3750
+ if (!command || path7.isAbsolute(command))
3751
+ return command;
3752
+ const found = await findCommandAsync(command);
3753
+ return found ? realpath(found).catch(() => void 0) : void 0;
3754
+ }
3415
3755
  async function findTsserverPath(root, allowInstall, options) {
3416
3756
  const fs6 = await import("node:fs/promises");
3417
- const projectRoots = await Promise.all([root, options?.sessionRoot ?? process.cwd(), process.cwd()].map((dir) => fs6.realpath(dir).catch(() => path6.resolve(dir))));
3757
+ const projectRoots = await Promise.all([root, options?.sessionRoot ?? process.cwd(), process.cwd()].map((dir) => fs6.realpath(dir).catch(() => path7.resolve(dir))));
3418
3758
  const admitCandidate = async (candidate, projectSupplied) => {
3419
3759
  try {
3420
3760
  const real = await fs6.realpath(candidate);
3421
- if (path6.basename(real) !== "tsserver.js" || !(await fs6.stat(real)).isFile())
3761
+ if (path7.basename(real) !== "tsserver.js" || !(await fs6.stat(real)).isFile())
3422
3762
  return void 0;
3423
- const manifest = JSON.parse(await fs6.readFile(path6.join(path6.dirname(real), "..", "package.json"), "utf8"));
3763
+ const manifest = JSON.parse(await fs6.readFile(path7.join(path7.dirname(real), "..", "package.json"), "utf8"));
3424
3764
  if (typeof manifest?.version !== "string" || !manifest.version)
3425
3765
  return void 0;
3426
3766
  return admitProjectSuppliedTsserver(real, options?.sessionRoot ?? process.cwd(), projectSupplied || projectRoots.some((dir) => isUnderDir(real, dir)), options?.projectCodeAllowed);
@@ -3434,7 +3774,7 @@ async function findTsserverPath(root, allowInstall, options) {
3434
3774
  if (admittedAncestor)
3435
3775
  return admittedAncestor;
3436
3776
  }
3437
- const cwdCandidate = path6.join(process.cwd(), "node_modules", "typescript", "lib", "tsserver.js");
3777
+ const cwdCandidate = path7.join(process.cwd(), "node_modules", "typescript", "lib", "tsserver.js");
3438
3778
  try {
3439
3779
  await fs6.access(cwdCandidate);
3440
3780
  const admittedCwd = await admitCandidate(cwdCandidate, false);
@@ -3443,10 +3783,10 @@ async function findTsserverPath(root, allowInstall, options) {
3443
3783
  } catch {
3444
3784
  }
3445
3785
  const tsserverForTsc = async (tscPath) => {
3446
- if (!tscPath || !path6.isAbsolute(tscPath))
3786
+ if (!tscPath)
3447
3787
  return void 0;
3448
3788
  for (const dir of typescriptDirsForTsc(tscPath)) {
3449
- const candidate = path6.join(dir, "lib", "tsserver.js");
3789
+ const candidate = path7.join(dir, "lib", "tsserver.js");
3450
3790
  try {
3451
3791
  const admitted = await admitCandidate(candidate, false);
3452
3792
  if (admitted)
@@ -3457,29 +3797,28 @@ async function findTsserverPath(root, allowInstall, options) {
3457
3797
  return void 0;
3458
3798
  };
3459
3799
  const installAllowed = canInstall(allowInstall);
3460
- const discoveredTsc = await ensureTool("typescript", {
3461
- allowInstall: installAllowed
3462
- });
3800
+ const discoveredTsc = await absoluteCommandPath(await ensureTool("typescript", { allowInstall: installAllowed }));
3463
3801
  const discoveredTsserver = await tsserverForTsc(discoveredTsc);
3464
3802
  if (discoveredTsserver || !discoveredTsc || !installAllowed || classicTsRepairState().attempted) {
3465
3803
  return discoveredTsserver;
3466
3804
  }
3467
3805
  const discoveredVersion = await typescriptVersionForTsc(discoveredTsc);
3468
- if (!discoveredVersion || discoveredVersion.major < 7)
3806
+ const shim = !await hasTypescriptPackageDir(discoveredTsc);
3807
+ if (!shim && (!discoveredVersion || discoveredVersion.major < 7))
3469
3808
  return void 0;
3470
3809
  classicTsRepairState().attempted = true;
3471
- logSessionStart(`lsp typescript: managed compiler resolved to TypeScript ${discoveredVersion.version}, which ships no tsserver.js; reinstalling pinned classic fallback`);
3472
- const repairedTsc = await ensureTool("typescript", {
3810
+ logSessionStart(shim ? `lsp typescript: ${discoveredTsc} has no TypeScript package beside it; installing pinned classic fallback` : `lsp typescript: managed compiler resolved to TypeScript ${discoveredVersion?.version}, which ships no tsserver.js; reinstalling pinned classic fallback`);
3811
+ const repairedTsc = await absoluteCommandPath(await ensureTool("typescript", {
3473
3812
  allowInstall: true,
3474
3813
  forceReinstall: true
3475
- });
3814
+ }));
3476
3815
  return tsserverForTsc(repairedTsc);
3477
3816
  }
3478
3817
  async function findNativeTypeScriptLsp(root) {
3479
- let currentDir = path6.resolve(root);
3818
+ let currentDir = path7.resolve(root);
3480
3819
  while (!isAtOrAboveHomeDir(currentDir)) {
3481
- const typescriptDir = path6.join(currentDir, "node_modules", "typescript");
3482
- const packageJsonPath = path6.join(typescriptDir, "package.json");
3820
+ const typescriptDir = path7.join(currentDir, "node_modules", "typescript");
3821
+ const packageJsonPath = path7.join(typescriptDir, "package.json");
3483
3822
  let packageJsonText;
3484
3823
  try {
3485
3824
  packageJsonText = await readFile(packageJsonPath, "utf8");
@@ -3493,7 +3832,7 @@ async function findNativeTypeScriptLsp(root) {
3493
3832
  return void 0;
3494
3833
  } catch {
3495
3834
  }
3496
- const parent = path6.dirname(currentDir);
3835
+ const parent = path7.dirname(currentDir);
3497
3836
  if (parent === currentDir)
3498
3837
  return void 0;
3499
3838
  currentDir = parent;
@@ -3513,7 +3852,7 @@ async function findNativeTypeScriptLsp(root) {
3513
3852
  const major = /^\d+$/.test(majorText) ? Number(majorText) : Number.NaN;
3514
3853
  if (!Number.isFinite(major) || major < 7)
3515
3854
  return void 0;
3516
- const localTsc = path6.join(currentDir, "node_modules", ".bin", "tsc");
3855
+ const localTsc = path7.join(currentDir, "node_modules", ".bin", "tsc");
3517
3856
  const candidates = process.platform === "win32" ? [`${localTsc}.cmd`, `${localTsc}.exe`, localTsc] : [localTsc];
3518
3857
  for (const command of candidates) {
3519
3858
  try {
@@ -3529,23 +3868,32 @@ async function findNativeTypeScriptLsp(root) {
3529
3868
  function dotnetToolCandidates(tool) {
3530
3869
  const home = os7.homedir();
3531
3870
  return [
3532
- path6.join(PI_LENS_BIN_DIR2, `${tool}.exe`),
3533
- path6.join(PI_LENS_BIN_DIR2, tool),
3534
- path6.join(home, ".dotnet", "tools", `${tool}.exe`),
3535
- path6.join(home, ".dotnet", "tools", tool),
3871
+ path7.join(PI_LENS_BIN_DIR2, `${tool}.exe`),
3872
+ path7.join(PI_LENS_BIN_DIR2, tool),
3873
+ path7.join(home, ".dotnet", "tools", `${tool}.exe`),
3874
+ path7.join(home, ".dotnet", "tools", tool),
3536
3875
  tool
3537
3876
  ].filter(Boolean);
3538
3877
  }
3539
3878
  function binExeVariants(dir, tool) {
3540
- return process.platform === "win32" ? [path6.join(dir, `${tool}.exe`), path6.join(dir, tool)] : [path6.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;
3541
3889
  }
3542
3890
  function goBinCandidates(tool) {
3543
- const gopath = process.env.GOPATH?.split(path6.delimiter)[0] || path6.join(os7.homedir(), "go");
3544
- return [tool, ...binExeVariants(path6.join(gopath, "bin"), tool)];
3891
+ const gopath = process.env.GOPATH?.split(path7.delimiter)[0] || path7.join(os7.homedir(), "go");
3892
+ return [tool, ...binExeVariants(path7.join(gopath, "bin"), tool)];
3545
3893
  }
3546
3894
  function cargoBinCandidates(tool) {
3547
- const cargoHome = process.env.CARGO_HOME || path6.join(os7.homedir(), ".cargo");
3548
- return [tool, ...binExeVariants(path6.join(cargoHome, "bin"), tool)];
3895
+ const cargoHome = process.env.CARGO_HOME || path7.join(os7.homedir(), ".cargo");
3896
+ return [tool, ...binExeVariants(path7.join(cargoHome, "bin"), tool)];
3549
3897
  }
3550
3898
  async function tryGemInstall(gem) {
3551
3899
  const { join: join4 } = await import("node:path");
@@ -3583,7 +3931,7 @@ var TS_TOOLING_MARKERS = [
3583
3931
  ];
3584
3932
  var TS_FAMILY_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".mts", ".cts"]);
3585
3933
  function isTsFamilyFile(file) {
3586
- return TS_FAMILY_EXTENSIONS.has(path6.extname(file).toLowerCase());
3934
+ return TS_FAMILY_EXTENSIONS.has(path7.extname(file).toLowerCase());
3587
3935
  }
3588
3936
  function tsConfigMarkersForFile(file) {
3589
3937
  return isTsFamilyFile(file) ? ["tsconfig.json"] : TS_CONFIG_MARKERS;
@@ -3604,40 +3952,42 @@ async function findTypeScriptProjectRoot(file) {
3604
3952
  return isSameOrWithin(toolingRoot, configRoot) ? configRoot : toolingRoot;
3605
3953
  }
3606
3954
  async function findExtensionBoundedRoot(file, extensionRootKey) {
3607
- const startDir = path6.resolve(path6.dirname(file));
3608
- 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));
3609
3959
  const configMarkers = tsConfigMarkersForFile(file);
3610
3960
  while (true) {
3611
3961
  for (const pattern of configMarkers) {
3612
3962
  try {
3613
- await stat(path6.join(currentDir, pattern));
3963
+ await stat(path7.join(currentDir, pattern));
3614
3964
  return currentDir;
3615
3965
  } catch {
3616
3966
  }
3617
3967
  }
3618
3968
  for (const pattern of TS_TOOLING_MARKERS) {
3619
3969
  try {
3620
- await stat(path6.join(currentDir, pattern));
3970
+ await stat(path7.join(currentDir, pattern));
3621
3971
  return currentDir;
3622
3972
  } catch {
3623
3973
  }
3624
3974
  }
3625
- const currentKey = normalizeEphemeralMapKey(path6.resolve(currentDir));
3626
- if (currentKey === extensionRootKey)
3975
+ const currentKey = normalizeEphemeralMapKey(path7.resolve(currentDir));
3976
+ if (currentKey === boundaryKey)
3627
3977
  return void 0;
3628
- const parent = path6.dirname(currentDir);
3978
+ const parent = path7.dirname(currentDir);
3629
3979
  if (parent === currentDir)
3630
3980
  return void 0;
3631
3981
  currentDir = parent;
3632
3982
  }
3633
3983
  }
3634
3984
  async function hasAgentLevelProjectMarker(extensionRootKey) {
3635
- const agentDir = path6.dirname(extensionRootKey);
3985
+ const agentDir = path7.dirname(extensionRootKey);
3636
3986
  if (!agentDir || agentDir === extensionRootKey)
3637
3987
  return false;
3638
3988
  for (const pattern of [...TS_CONFIG_MARKERS, ...TS_TOOLING_MARKERS]) {
3639
3989
  try {
3640
- await stat(path6.join(agentDir, pattern));
3990
+ await stat(path7.join(agentDir, pattern));
3641
3991
  return true;
3642
3992
  } catch {
3643
3993
  }
@@ -3645,7 +3995,7 @@ async function hasAgentLevelProjectMarker(extensionRootKey) {
3645
3995
  return false;
3646
3996
  }
3647
3997
  var TypeScriptRoot = withRootMarkers(DenoExcludeRoot(async (file) => {
3648
- const extensionRootKey = piAgentExtensionsRootKey(file);
3998
+ const extensionRootKey = piAgentExtensionsRootKey(file) ?? piAgentExtensionsRootKey(realpathOrResolve(file));
3649
3999
  if (extensionRootKey) {
3650
4000
  const bounded2 = await findExtensionBoundedRoot(file, extensionRootKey);
3651
4001
  if (bounded2)
@@ -3664,6 +4014,11 @@ var TypeScriptServer = {
3664
4014
  id: "typescript",
3665
4015
  idleEviction: "transparent",
3666
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",
3667
4022
  name: "TypeScript Language Server",
3668
4023
  projectLocalCommand: "typescript-language-server",
3669
4024
  extensions: JS_TS_LSP_EXTENSIONS,
@@ -3737,10 +4092,25 @@ var DenoServer = {
3737
4092
  }, options?.allowInstall);
3738
4093
  }
3739
4094
  };
4095
+ function pyrightInitialization(pythonPath) {
4096
+ return {
4097
+ python: {
4098
+ ...pythonPath ? { pythonPath } : {},
4099
+ analysis: { diagnosticMode: "openFilesOnly" }
4100
+ }
4101
+ };
4102
+ }
3740
4103
  var PythonServer = {
3741
4104
  id: "python",
3742
4105
  idleEviction: "transparent",
3743
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",
3744
4114
  name: "Pyright Language Server",
3745
4115
  extensions: KIND_EXTENSIONS["python"],
3746
4116
  root: RootWithFallback(createRootDetector([
@@ -3754,12 +4124,9 @@ var PythonServer = {
3754
4124
  ])),
3755
4125
  async spawn(root, options) {
3756
4126
  const pythonEnvironment = await detectPythonEnvironment(root);
3757
- const env = augmentPythonEnvironment(await getToolEnvironment(), pythonEnvironment);
4127
+ const toolEnvironment = await getToolEnvironment();
4128
+ const env = augmentPythonEnvironment(toolEnvironment, pythonEnvironment);
3758
4129
  let source = "direct";
3759
- const pyrightInit = (pythonPath) => ({
3760
- ...pythonPath ? { pythonPath } : {},
3761
- openFilesOnly: true
3762
- });
3763
4130
  const projectPyright = await resolveAndLaunch({
3764
4131
  candidates: [
3765
4132
  ...pythonEnvironmentToolCandidates(pythonEnvironment, "pyright-langserver"),
@@ -3775,7 +4142,7 @@ var PythonServer = {
3775
4142
  return {
3776
4143
  process: projectPyright.process,
3777
4144
  source: projectPyright.source,
3778
- initialization: pyrightInit(pythonEnvironment?.pythonPath)
4145
+ initialization: pyrightInitialization(pythonEnvironment?.pythonPath)
3779
4146
  };
3780
4147
  }
3781
4148
  const projectTy = await resolveAndLaunch({
@@ -3797,7 +4164,7 @@ var PythonServer = {
3797
4164
  return {
3798
4165
  process: pathPyright.process,
3799
4166
  source: pathPyright.source,
3800
- initialization: pyrightInit(pythonEnvironment?.pythonPath)
4167
+ initialization: pyrightInitialization(pythonEnvironment?.pythonPath)
3801
4168
  };
3802
4169
  }
3803
4170
  const pathTy = await resolveAndLaunch({
@@ -3815,25 +4182,27 @@ var PythonServer = {
3815
4182
  if (!pyrightPath)
3816
4183
  return void 0;
3817
4184
  source = "managed";
3818
- const binDir = path6.dirname(pyrightPath);
4185
+ const binDir = path7.dirname(pyrightPath);
3819
4186
  const isWindows2 = process.platform === "win32";
3820
4187
  const managedCandidates = isWindows2 ? [
3821
- path6.join(binDir, "pyright-langserver.cmd"),
3822
- path6.join(binDir, "pyright-langserver"),
4188
+ path7.join(binDir, "pyright-langserver.cmd"),
4189
+ path7.join(binDir, "pyright-langserver"),
3823
4190
  "pyright-langserver"
3824
- ] : [path6.join(binDir, "pyright-langserver"), "pyright-langserver"];
4191
+ ] : [path7.join(binDir, "pyright-langserver"), "pyright-langserver"];
3825
4192
  const resolved = await resolveAndLaunch({ candidates: managedCandidates, args: ["--stdio"], cwd: root, env }, false);
3826
4193
  if (!resolved)
3827
4194
  return void 0;
3828
4195
  return {
3829
4196
  process: resolved.process,
3830
4197
  source,
3831
- initialization: pyrightInit(pythonEnvironment?.pythonPath)
4198
+ initialization: pyrightInitialization(pythonEnvironment?.pythonPath)
3832
4199
  };
3833
4200
  }
3834
4201
  };
3835
4202
  var PythonJediServer = {
3836
- 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,
3837
4206
  idleEviction: "transparent",
3838
4207
  role: "language",
3839
4208
  name: "Jedi Language Server",
@@ -3849,19 +4218,39 @@ var PythonJediServer = {
3849
4218
  "poetry.lock"
3850
4219
  ])),
3851
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
+ }
3852
4244
  const launched = await resolveAndLaunch({
3853
4245
  candidates: ["jedi-language-server"],
3854
4246
  args: [],
3855
4247
  cwd: root,
4248
+ env: toolEnvironment,
3856
4249
  managedToolId: "jedi-language-server"
3857
4250
  }, options?.allowInstall);
3858
4251
  if (!launched)
3859
4252
  return void 0;
3860
- const pythonPath = await detectPythonVenv(root);
3861
- return {
3862
- ...launched,
3863
- initialization: pythonPath ? { workspace: { environmentPath: pythonPath } } : {}
3864
- };
4253
+ return { ...launched, initialization };
3865
4254
  }
3866
4255
  };
3867
4256
  var GoServer = {
@@ -3890,7 +4279,7 @@ var GoServer = {
3890
4279
  }
3891
4280
  };
3892
4281
  function cargoWorkspaceDeclaresMember(workspaceContent, parentDir, childDir) {
3893
- const relativePath = path6.relative(parentDir, childDir).split(path6.sep).join("/");
4282
+ const relativePath = path7.relative(parentDir, childDir).split(path7.sep).join("/");
3894
4283
  if (relativePath === "" || relativePath.startsWith(".."))
3895
4284
  return false;
3896
4285
  const matches = (pattern) => matchesWorkspaceMemberPattern(pattern, relativePath, CARGO_WORKSPACE_MEMBER_DIALECT, () => recordDegradationOnce({
@@ -3904,7 +4293,7 @@ function cargoWorkspaceDeclaresMember(workspaceContent, parentDir, childDir) {
3904
4293
  return readCargoWorkspaceMembers(workspaceContent).some(matches);
3905
4294
  }
3906
4295
  function sessionHoistCeiling(sessionCwd, file) {
3907
- return isSameOrWithin(path6.resolve(sessionCwd), path6.resolve(file)) ? path6.resolve(sessionCwd) : void 0;
4296
+ return isSameOrWithin(path7.resolve(sessionCwd), path7.resolve(file)) ? path7.resolve(sessionCwd) : void 0;
3908
4297
  }
3909
4298
  function RustWorkspaceRoot() {
3910
4299
  const crateRoot = createRootDetector(["Cargo.toml", "Cargo.lock"]);
@@ -3915,14 +4304,14 @@ function RustWorkspaceRoot() {
3915
4304
  const sessionCwd = process.cwd();
3916
4305
  const stop = sessionHoistCeiling(sessionCwd, file);
3917
4306
  let current = root;
3918
- const fsRoot = path6.parse(current).root;
4307
+ const fsRoot = path7.parse(current).root;
3919
4308
  while (true) {
3920
4309
  if (stop !== void 0 && current === stop)
3921
4310
  break;
3922
- const parent = path6.dirname(current);
4311
+ const parent = path7.dirname(current);
3923
4312
  if (parent === current || parent === fsRoot)
3924
4313
  break;
3925
- const parentCargoPath = path6.join(parent, "Cargo.toml");
4314
+ const parentCargoPath = path7.join(parent, "Cargo.toml");
3926
4315
  const parentCargoContent = await readTextFileOrUndefined(parentCargoPath);
3927
4316
  if (parentCargoContent !== void 0 && hasCargoWorkspaceTable(parentCargoContent)) {
3928
4317
  if (cargoWorkspaceDeclaresMember(parentCargoContent, parent, root)) {
@@ -3950,9 +4339,9 @@ async function declaresMavenModule(parentDir, parentPomPath, childDir) {
3950
4339
  const modulesBlock = content.match(/<modules>([\s\S]*?)<\/modules>/);
3951
4340
  if (!modulesBlock)
3952
4341
  return false;
3953
- const resolvedChild = path6.resolve(childDir);
4342
+ const resolvedChild = path7.resolve(childDir);
3954
4343
  for (const match of modulesBlock[1].matchAll(/<module>\s*([^<]+?)\s*<\/module>/g)) {
3955
- if (pathsEqual(path6.resolve(parentDir, match[1]), resolvedChild))
4344
+ if (pathsEqual(path7.resolve(parentDir, match[1]), resolvedChild))
3956
4345
  return true;
3957
4346
  }
3958
4347
  return false;
@@ -3976,15 +4365,15 @@ function JavaWorkspaceRoot() {
3976
4365
  const stop = sessionHoistCeiling(sessionCwd, file);
3977
4366
  let current = root;
3978
4367
  let lastHop = root;
3979
- const fsRoot = path6.parse(current).root;
4368
+ const fsRoot = path7.parse(current).root;
3980
4369
  while (true) {
3981
4370
  if (stop !== void 0 && current === stop)
3982
4371
  break;
3983
- const parent = path6.dirname(current);
4372
+ const parent = path7.dirname(current);
3984
4373
  if (parent === current || parent === fsRoot)
3985
4374
  break;
3986
4375
  if (await markerExists(parent, "pom.xml")) {
3987
- const parentPom = path6.join(parent, "pom.xml");
4376
+ const parentPom = path7.join(parent, "pom.xml");
3988
4377
  if (!await declaresMavenModule(parent, parentPom, lastHop))
3989
4378
  break;
3990
4379
  current = parent;
@@ -4003,6 +4392,7 @@ var RustServer = {
4003
4392
  // Measured (#3750): rust-analyzer answers an empty result for a detached file.
4004
4393
  requiresProjectRoot: true,
4005
4394
  name: "rust-analyzer",
4395
+ settingsSection: "rust-analyzer",
4006
4396
  executesProjectCode: true,
4007
4397
  extensions: KIND_EXTENSIONS["rust"],
4008
4398
  // No FileDirRoot fallback (#201): rust-analyzer is a heavy workspace server
@@ -4090,17 +4480,17 @@ var PHPServer = {
4090
4480
  return {
4091
4481
  ...result,
4092
4482
  initialization: {
4093
- storagePath: path6.join(getGlobalPiLensDir(), "intelephense")
4483
+ storagePath: path7.join(getGlobalPiLensDir(), "intelephense")
4094
4484
  }
4095
4485
  };
4096
4486
  }
4097
4487
  };
4098
4488
  function buildPsesArgs(bundleDir) {
4099
- const script = path6.join(bundleDir, "PowerShellEditorServices", "Start-EditorServices.ps1");
4100
- const sessionDir = path6.join(getGlobalPiLensDir(), "pses", `${process.pid}-${Date.now()}`);
4489
+ const script = path7.join(bundleDir, "PowerShellEditorServices", "Start-EditorServices.ps1");
4490
+ const sessionDir = path7.join(getGlobalPiLensDir(), "pses", `${process.pid}-${Date.now()}`);
4101
4491
  mkdirSync2(sessionDir, { recursive: true });
4102
- const logPath = path6.join(sessionDir, "pses.log");
4103
- const sessionDetailsPath = path6.join(sessionDir, "session.json");
4492
+ const logPath = path7.join(sessionDir, "pses.log");
4493
+ const sessionDetailsPath = path7.join(sessionDir, "session.json");
4104
4494
  return [
4105
4495
  "-NoLogo",
4106
4496
  "-NoProfile",
@@ -4154,6 +4544,8 @@ var CSharpServer = {
4154
4544
  role: "language",
4155
4545
  // Documented (#3750): csharp-ls needs a solution or project.
4156
4546
  requiresProjectRoot: true,
4547
+ // Measured (#4806): with none below its cwd csharp-ls aborts the process.
4548
+ spawnNeedsProjectFile: true,
4157
4549
  name: "csharp-ls",
4158
4550
  executesProjectCode: true,
4159
4551
  extensions: KIND_EXTENSIONS["csharp"],
@@ -4266,7 +4658,9 @@ var SwiftServer = createInteractiveServer({
4266
4658
  name: "SourceKit-LSP",
4267
4659
  executesProjectCode: true,
4268
4660
  extensions: KIND_EXTENSIONS["swift"],
4269
- 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"]),
4270
4664
  language: "swift",
4271
4665
  command: "sourcekit-lsp"
4272
4666
  });
@@ -4606,7 +5000,7 @@ var DockerServer = {
4606
5000
  };
4607
5001
  var DockerOfficialServer = {
4608
5002
  id: "docker-official",
4609
- idleEviction: "unmeasured",
5003
+ idleEviction: "transparent",
4610
5004
  role: "language",
4611
5005
  name: "Docker Language Server (official)",
4612
5006
  fallbackFor: "docker",
@@ -4758,8 +5152,8 @@ var VueServer = {
4758
5152
  initializeTimeoutMs: 3e4,
4759
5153
  async spawn(root, options) {
4760
5154
  const tsserverPath = await findTsserverPath(root, options?.allowInstall, options);
4761
- const hasPackageJson = existsSync3(path6.join(root, "package.json"));
4762
- const hasNodeModules = existsSync3(path6.join(root, "node_modules"));
5155
+ const hasPackageJson = existsSync3(path7.join(root, "package.json"));
5156
+ const hasNodeModules = existsSync3(path7.join(root, "node_modules"));
4763
5157
  if (hasPackageJson && !hasNodeModules) {
4764
5158
  logSessionStart(`lsp vue: node_modules missing in ${root} \u2014 Vue navigation may be limited. Run: npm install (or pnpm/yarn install) in this project.`);
4765
5159
  }
@@ -4774,7 +5168,7 @@ var VueServer = {
4774
5168
  return {
4775
5169
  process: proc.process,
4776
5170
  source: proc.source,
4777
- initialization: tsserverPath ? { typescript: { tsdk: path6.dirname(tsserverPath) } } : void 0
5171
+ initialization: tsserverPath ? { typescript: { tsdk: path7.dirname(tsserverPath) } } : void 0
4778
5172
  };
4779
5173
  }
4780
5174
  };
@@ -4816,7 +5210,7 @@ var SvelteServer = {
4816
5210
  return {
4817
5211
  process: proc.process,
4818
5212
  source: proc.source,
4819
- initialization: tsserverPath ? { typescript: { tsdk: path6.dirname(tsserverPath) } } : void 0
5213
+ initialization: tsserverPath ? { typescript: { tsdk: path7.dirname(tsserverPath) } } : void 0
4820
5214
  };
4821
5215
  }
4822
5216
  };
@@ -4886,8 +5280,11 @@ var OpengrepServer = {
4886
5280
  extensions: OPENGREP_EXTENSIONS,
4887
5281
  // Stable per-repo root so ONE warm server serves the whole project (a
4888
5282
  // per-directory root would spawn a fresh server — and re-pay rule load —
4889
- // for every folder).
4890
- 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",
4891
5288
  availabilityKey: "opengrep",
4892
5289
  // Rule compilation can take a few seconds on the first scan of a session.
4893
5290
  initializeTimeoutMs: 15e3,
@@ -4939,7 +5336,8 @@ var AstGrepServer = {
4939
5336
  // sgconfig the spawn launches with `--config <shipped baseline>` so the team's
4940
5337
  // rules still run; the napi runner steps aside when this server is available
4941
5338
  // (it falls back to napi when the ast-grep binary is absent — Gate B).
4942
- 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",
4943
5341
  availabilityKey: "ast-grep",
4944
5342
  // #1714: the one auxiliary with a measured wedge ceiling. A `lens_diagnostics
4945
5343
  // mode=full` sweep of 225 files drove this server into an unrecoverable stall
@@ -4979,14 +5377,16 @@ var AstGrepServer = {
4979
5377
  var ZIZMOR_EXTENSIONS = KIND_EXTENSIONS["yaml"];
4980
5378
  var ZizmorServer = {
4981
5379
  id: "zizmor",
4982
- idleEviction: "unmeasured",
5380
+ idleEviction: "transparent",
4983
5381
  role: "auxiliary",
4984
5382
  name: "zizmor Actions Security Scanner",
4985
5383
  extensions: ZIZMOR_EXTENSIONS,
4986
5384
  pathFilter: isZizmorAuditTarget,
4987
5385
  // Stable per-repo root so ONE warm server serves the whole project (like
4988
- // Opengrep) — config + workflow discovery is repo-relative.
4989
- 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",
4990
5390
  availabilityKey: "zizmor",
4991
5391
  async spawn(root, options) {
4992
5392
  const ghToken = await resolveZizmorGitHubToken();
@@ -5032,8 +5432,10 @@ var TyposServer = {
5032
5432
  name: "typos Spell Checker",
5033
5433
  extensions: TYPOS_EXTENSIONS,
5034
5434
  // Stable per-repo root so ONE warm server serves the whole project (like the
5035
- // other auxiliaries) — typos.toml discovery is repo-relative.
5036
- 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",
5037
5439
  availabilityKey: "typos-lsp",
5038
5440
  async spawn(root, options) {
5039
5441
  const launched = await resolveAndLaunch({
@@ -5111,7 +5513,7 @@ function getServerById(id) {
5111
5513
  }
5112
5514
 
5113
5515
  // dist/clients/lsp/session-roots.js
5114
- import path7 from "node:path";
5516
+ import path8 from "node:path";
5115
5517
  var SESSION_ROOT_CAP = 128;
5116
5518
  var sessionRoots = new BoundedFifoMap(SESSION_ROOT_CAP);
5117
5519
  function noteEvictedRoots(evicted) {
@@ -5126,28 +5528,57 @@ function noteEvictedRoots(evicted) {
5126
5528
  return roots;
5127
5529
  }
5128
5530
  function registerSessionRoot(cwd) {
5129
- const root = path7.resolve(cwd);
5531
+ const root = path8.resolve(cwd);
5130
5532
  if (sessionRoots.has(root))
5131
5533
  return [];
5132
5534
  return noteEvictedRoots(sessionRoots.set(root, void 0));
5133
5535
  }
5134
5536
  function setSessionRootConfig(cwd, config) {
5135
- return noteEvictedRoots(sessionRoots.set(path7.resolve(cwd), config));
5537
+ return noteEvictedRoots(sessionRoots.set(path8.resolve(cwd), config));
5136
5538
  }
5137
- function sessionRootConfigEntries() {
5138
- return sessionRoots;
5539
+ function isSameOrChildPath(filePath, candidateRoot) {
5540
+ if (filePath === candidateRoot)
5541
+ return true;
5542
+ return filePath.startsWith(`${candidateRoot}${path8.sep}`);
5543
+ }
5544
+ function sessionRootConfigForFile(filePath) {
5545
+ const resolvedFilePath = path8.resolve(filePath);
5546
+ let bestMatch;
5547
+ for (const [root, config] of sessionRoots) {
5548
+ if (config === void 0)
5549
+ continue;
5550
+ if (!isSameOrChildPath(resolvedFilePath, root))
5551
+ continue;
5552
+ if (!bestMatch || root.length > bestMatch.root.length) {
5553
+ bestMatch = { root, config };
5554
+ }
5555
+ }
5556
+ return bestMatch?.config;
5557
+ }
5558
+ function disabledPrimaries(filePath) {
5559
+ const config = sessionRootConfigForFile(filePath);
5560
+ if (!config || config.disabledServerIds.size === 0)
5561
+ return { disabledServerIds: [], fallbackServerIds: [] };
5562
+ const { ext, base } = fileMatchKeys(filePath);
5563
+ const off = config.disabledServerIds;
5564
+ const primaries = registeredServers(config, LSP_SERVERS).filter((server) => !isAuxiliary(server) && fileMatchReason(server, filePath, ext, base) === "selected");
5565
+ const ownerOff = (server) => server.fallbackFor === void 0 || off.has(server.fallbackFor);
5566
+ return {
5567
+ disabledServerIds: primaries.filter((server) => off.has(server.id) && ownerOff(server)).map((server) => server.id),
5568
+ fallbackServerIds: primaries.filter((server) => server.fallbackFor !== void 0 && off.has(server.fallbackFor)).map((server) => server.id)
5569
+ };
5139
5570
  }
5140
5571
  function isSessionRootRegistered(cwd) {
5141
- return sessionRoots.has(path7.resolve(cwd));
5572
+ return sessionRoots.has(path8.resolve(cwd));
5142
5573
  }
5143
5574
  function shouldInitializeSessionRoot(cwd, readyRoots) {
5144
- const normalized = path7.resolve(cwd);
5575
+ const normalized = path8.resolve(cwd);
5145
5576
  return !readyRoots.has(normalized) || !isSessionRootRegistered(normalized);
5146
5577
  }
5147
5578
  function isOutsideAllSessionRoots(filePath) {
5148
5579
  if (sessionRoots.size === 0)
5149
5580
  return false;
5150
- const resolved = path7.resolve(filePath);
5581
+ const resolved = path8.resolve(filePath);
5151
5582
  for (const root of sessionRoots.keys()) {
5152
5583
  if (isSameOrWithin(root, resolved))
5153
5584
  return false;
@@ -5162,8 +5593,6 @@ export {
5162
5593
  findLocalTyposConfig,
5163
5594
  getAstGrepRuleSources,
5164
5595
  getAstGrepRuleFingerprint,
5165
- isAuxiliary,
5166
- serverTraits,
5167
5596
  registerRunnerId,
5168
5597
  withLspProjectCodePermission,
5169
5598
  refuseUntrustedLspExecution,
@@ -5171,6 +5600,11 @@ export {
5171
5600
  resolveAnalysisRoot,
5172
5601
  canWriteAnalysisRoot,
5173
5602
  BUILTIN_SERVER_RUNNER_COVERS,
5603
+ isAuxiliary,
5604
+ serverTraits,
5605
+ getStrategy,
5606
+ classifyServerWaitTier,
5607
+ classifyCascadeWaitTier,
5174
5608
  describeRootFallback,
5175
5609
  resolveLspServerCwd,
5176
5610
  resetLSPCaseSensitivityState,
@@ -5180,9 +5614,12 @@ export {
5180
5614
  resetLspLaunchAvailabilityGeneration,
5181
5615
  resetDirectLspCommandAvailability,
5182
5616
  isDirectLspCommandTemporarilyUnavailable,
5617
+ declinesLooseFileRoot,
5618
+ declinesProjectlessRoot,
5183
5619
  resetClassicTsRepairGuard,
5184
5620
  LSP_SERVERS,
5185
5621
  getServerById,
5622
+ disabledPrimaries,
5186
5623
  shouldInitializeSessionRoot,
5187
5624
  isOutsideAllSessionRoots,
5188
5625
  getSessionRootsForTelemetry,
@@ -5195,8 +5632,5 @@ export {
5195
5632
  getServersForFileWithConfig,
5196
5633
  primaryServerId,
5197
5634
  resolveLspCwdForFile,
5198
- getServerInitOverride,
5199
- getStrategy,
5200
- classifyServerWaitTier,
5201
- classifyCascadeWaitTier
5635
+ getServerInitOverride
5202
5636
  };