pi-lens 4.5.0 → 4.5.2

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 (148) hide show
  1. package/CHANGELOG-USER.md +12 -12
  2. package/CHANGELOG.md +253 -0
  3. package/README.md +11 -2
  4. package/config/dependency-cruiser-eager-allowlist.json +1 -0
  5. package/dist/{chunk-ZULZS2I6.js → chunk-2ERVW2UF.js} +1115 -423
  6. package/dist/{chunk-BBSDJTOV.js → chunk-2K7BUOKS.js} +13 -13
  7. package/dist/{chunk-I2FYOZNW.js → chunk-3JJ4OAJI.js} +10 -10
  8. package/dist/{chunk-5JB4WENL.js → chunk-3UHGSUVL.js} +1 -1
  9. package/dist/{chunk-W26QZ3OM.js → chunk-463WN3VP.js} +10 -10
  10. package/dist/{chunk-4IZZEN63.js → chunk-4X3ML2UQ.js} +31 -34
  11. package/dist/{chunk-I3NZVAMN.js → chunk-5BI5YP57.js} +10 -10
  12. package/dist/{chunk-7U36VQL6.js → chunk-5Z4XLUFF.js} +3 -3
  13. package/dist/{chunk-DCA2MXVQ.js → chunk-62AJH3IN.js} +51 -29
  14. package/dist/{chunk-37IDWT6O.js → chunk-6F34GMP7.js} +16 -14
  15. package/dist/{chunk-VSQT6IHZ.js → chunk-6LIUVGOR.js} +28 -4
  16. package/dist/{chunk-27JQHK7Y.js → chunk-6REF4GCO.js} +1 -1
  17. package/dist/{chunk-INBK3HIT.js → chunk-7KRR24GO.js} +3 -3
  18. package/dist/{chunk-OZQQ3AIR.js → chunk-7OMOMBEQ.js} +9 -9
  19. package/dist/{chunk-ARTYCUGF.js → chunk-7ZFXICNN.js} +123 -20
  20. package/dist/{chunk-K4Z7MK6T.js → chunk-ABKRQVOY.js} +28 -52
  21. package/dist/{chunk-C5PLBTNR.js → chunk-ANSLRJBG.js} +1 -1
  22. package/dist/{chunk-HRLF35WL.js → chunk-AWMFBPGJ.js} +9 -9
  23. package/dist/{chunk-CXQYK4YT.js → chunk-BG7KHGNX.js} +2 -2
  24. package/dist/{chunk-ZI7YHV6I.js → chunk-BK2R2223.js} +10 -8
  25. package/dist/chunk-BXXC6KRR.js +107 -0
  26. package/dist/{chunk-QMWKSYWB.js → chunk-CKJS2AUI.js} +4 -4
  27. package/dist/{chunk-PPQHMSPH.js → chunk-COGU5KQJ.js} +15 -15
  28. package/dist/{chunk-NHA5K226.js → chunk-CQNXALZJ.js} +27 -6
  29. package/dist/{chunk-KZ732ZVW.js → chunk-CSZESDPP.js} +1 -1
  30. package/dist/chunk-CZ5TCJPB.js +98 -0
  31. package/dist/{chunk-LOEJFTF2.js → chunk-D2LFEA5U.js} +9 -2
  32. package/dist/chunk-D3KLF5CD.js +50 -0
  33. package/dist/{chunk-4DAHGU3V.js → chunk-ENJ2M76Y.js} +31 -29
  34. package/dist/{chunk-ZQSSO7LO.js → chunk-EQKF6BAK.js} +3 -3
  35. package/dist/{chunk-PFJLYRO3.js → chunk-F2SAP2FM.js} +40 -47
  36. package/dist/{chunk-ADYQRETD.js → chunk-F6QAJXQV.js} +2 -2
  37. package/dist/chunk-GR2QDWH5.js +25 -0
  38. package/dist/{chunk-LVLPA32Q.js → chunk-GVE5VZYQ.js} +48 -11
  39. package/dist/{chunk-AZG5UJYY.js → chunk-GWZZOJD2.js} +1 -1
  40. package/dist/chunk-GZS6VPIE.js +27 -0
  41. package/dist/chunk-H4B4SC7I.js +71 -0
  42. package/dist/{chunk-YCR6ZYTE.js → chunk-HA6TUJOE.js} +1 -1
  43. package/dist/{chunk-DI4AZZNY.js → chunk-HKPJTI47.js} +2 -2
  44. package/dist/{chunk-O6LCSHHI.js → chunk-HPKC55MA.js} +1 -1
  45. package/dist/{chunk-LQQNFCQJ.js → chunk-I65CQLCG.js} +1 -1
  46. package/dist/{chunk-P5MSLVUW.js → chunk-IDKLWVKY.js} +11 -11
  47. package/dist/chunk-IUM2Q7NF.js +25 -0
  48. package/dist/{chunk-L6BDRYUK.js → chunk-J24IS3KZ.js} +5 -5
  49. package/dist/{chunk-KNSOA43J.js → chunk-J2DAHH4T.js} +2 -2
  50. package/dist/{chunk-7ZVTFLCC.js → chunk-JBDZVOFL.js} +11 -11
  51. package/dist/{chunk-HIJ4CHFF.js → chunk-JC6NFC57.js} +3 -3
  52. package/dist/{chunk-K7O6AHSJ.js → chunk-JTHEUTW7.js} +11 -11
  53. package/dist/{chunk-KXGTLAUW.js → chunk-JWW3ODBN.js} +2 -2
  54. package/dist/{chunk-HIRBC72R.js → chunk-K3ZIYLHT.js} +4 -4
  55. package/dist/{chunk-6GLMMGCX.js → chunk-KDPZA2UE.js} +2 -3
  56. package/dist/{chunk-AXAR5ZW2.js → chunk-KMY2OU4T.js} +553 -434
  57. package/dist/{chunk-DFKOA74L.js → chunk-KQF7VT26.js} +10 -10
  58. package/dist/{chunk-S6MCMD27.js → chunk-KVGA7X76.js} +3 -3
  59. package/dist/{chunk-74AMPWNC.js → chunk-KW7O72AK.js} +2 -2
  60. package/dist/{chunk-UN72ZAJ5.js → chunk-LEQTVRSV.js} +9 -9
  61. package/dist/{chunk-B42AIWPJ.js → chunk-LKPSBM6S.js} +3 -3
  62. package/dist/{chunk-R4L7KZ7R.js → chunk-LKW2HFSZ.js} +9 -9
  63. package/dist/{chunk-3PO4YYOX.js → chunk-LURFD4HD.js} +4240 -3734
  64. package/dist/{chunk-PQXUZYTQ.js → chunk-M6ELTECW.js} +4 -4
  65. package/dist/{chunk-3QXFUP6T.js → chunk-MGVVYYKW.js} +12 -12
  66. package/dist/{chunk-CZJGAOKL.js → chunk-MQBKGRSB.js} +7 -7
  67. package/dist/{chunk-NNEQOC3U.js → chunk-MVG2ZEAO.js} +9 -7
  68. package/dist/{chunk-VWEBZ2JV.js → chunk-MY4XNNTX.js} +39 -41
  69. package/dist/{chunk-RIH3UBK4.js → chunk-N4AJVFRF.js} +11 -11
  70. package/dist/{chunk-TKOFTLGB.js → chunk-OFKKMXWM.js} +31 -36
  71. package/dist/{chunk-3PAS2ERX.js → chunk-OFZE4ANN.js} +8 -8
  72. package/dist/chunk-OLXBUTJR.js +61 -0
  73. package/dist/{chunk-6CFSDLHE.js → chunk-OZGEHOSG.js} +38 -17
  74. package/dist/{chunk-3TSMQZG6.js → chunk-PKGOROPQ.js} +40 -2
  75. package/dist/{chunk-OLWGYBYT.js → chunk-Q6D5QKRG.js} +17 -17
  76. package/dist/{chunk-QE7BJQ6K.js → chunk-QECLJFHI.js} +12 -17
  77. package/dist/{chunk-RJ3APNIP.js → chunk-QJA33VD5.js} +4 -4
  78. package/dist/{chunk-MOAVEPC4.js → chunk-R5XVJ6AN.js} +11 -11
  79. package/dist/{chunk-ZRQMENT4.js → chunk-REZL4OM4.js} +1 -1
  80. package/dist/{chunk-PKWEBMCA.js → chunk-RK5RBREN.js} +251 -201
  81. package/dist/chunk-RP5ZQTHO.js +86 -0
  82. package/dist/{chunk-J2ZB5MDS.js → chunk-RURPX2YV.js} +23 -23
  83. package/dist/chunk-TB5MGZLS.js +53 -0
  84. package/dist/chunk-TC63XRYP.js +27 -0
  85. package/dist/chunk-TJOYHAXJ.js +69 -0
  86. package/dist/{chunk-Q7J3JYJ2.js → chunk-TRXKDCBP.js} +13 -13
  87. package/dist/{chunk-6E5QLMWI.js → chunk-TTK37D7R.js} +22 -23
  88. package/dist/{chunk-XDNWR7SG.js → chunk-UH3QHLR5.js} +2 -2
  89. package/dist/{chunk-SCU62JLX.js → chunk-UNTJJ7GN.js} +7 -7
  90. package/dist/{chunk-O2MHF7QM.js → chunk-UPAFSETJ.js} +58 -63
  91. package/dist/{chunk-PQF6YGYB.js → chunk-UX75PTQW.js} +50 -31
  92. package/dist/{chunk-TWEOJE3D.js → chunk-V353PYMK.js} +1233 -576
  93. package/dist/{chunk-CQY2HEH7.js → chunk-V4TFQY5G.js} +2 -2
  94. package/dist/{chunk-B2OXE4AH.js → chunk-VC3W54G3.js} +446 -293
  95. package/dist/{chunk-JGUDT5KD.js → chunk-VSBCJVPC.js} +5 -5
  96. package/dist/{chunk-5HBQL7DH.js → chunk-WAQQGXVV.js} +3 -3
  97. package/dist/{chunk-7DPXUPRF.js → chunk-WLEVWR7Y.js} +2 -2
  98. package/dist/{chunk-QE5DJ7MX.js → chunk-WPMPVP5I.js} +4 -4
  99. package/dist/{chunk-KNJH6WJQ.js → chunk-WXNLFOC2.js} +7 -7
  100. package/dist/{chunk-XSC3BCN3.js → chunk-Y3ZNOZZS.js} +6 -6
  101. package/dist/{chunk-VGRGW4UL.js → chunk-YL6JQTWC.js} +29 -32
  102. package/dist/{chunk-7CLWC2UH.js → chunk-YVE5Q2UU.js} +86 -217
  103. package/dist/{chunk-LGH2HHZG.js → chunk-YZNARDMM.js} +42 -28
  104. package/dist/{chunk-NGNBJIUO.js → chunk-ZDWNFZJ2.js} +8 -8
  105. package/dist/{chunk-X33QECRJ.js → chunk-ZEUF7BIN.js} +2 -2
  106. package/dist/{chunk-2H5GHZKC.js → chunk-ZIF4WLWR.js} +45 -25
  107. package/dist/{chunk-WLD6BGON.js → chunk-ZSPVF7KI.js} +231 -24
  108. package/dist/{chunk-SDYLT45T.js → chunk-ZX6OKBVO.js} +2 -2
  109. package/dist/index.js +10566 -6819
  110. package/dist/mcp/analyze-cli.js +8 -8
  111. package/dist/mcp/cli.js +39 -41
  112. package/dist/mcp/server.js +1083 -685
  113. package/dist/mcp/worker.js +68 -59
  114. package/dist/probes/installer.js +21 -22
  115. package/docs/ci-bot-pr-checks.md +18 -9
  116. package/docs/ci.md +7 -0
  117. package/docs/configuration.md +24 -10
  118. package/docs/defect-shapes.md +61 -30
  119. package/docs/environment-variables.md +18 -9
  120. package/docs/globalconfig.md +17 -0
  121. package/docs/invariants/dispatch-runners.md +22 -0
  122. package/docs/invariants/lsp-trust-exec.md +33 -3
  123. package/docs/lsp-capability-matrix.md +23 -10
  124. package/docs/lsp-idle-eviction.md +7 -1
  125. package/docs/module-report-read-symbol.md +6 -2
  126. package/docs/pi-lens-merge-policy.md +3 -2
  127. package/docs/pi-lens-orchestration.md +2 -1
  128. package/docs/pi-lens-subagent.md +2 -1
  129. package/docs/release-qa-baseline.md +22 -17
  130. package/docs/servercapabilities.md +1 -1
  131. package/docs/settings.md +10 -2
  132. package/docs/tools.md +1 -1
  133. package/docs/usage.md +1 -0
  134. package/package.json +3 -3
  135. package/dist/chunk-2H7NFZ4Q.js +0 -25
  136. package/dist/chunk-5YJXF2IS.js +0 -56
  137. package/dist/chunk-7WKVCZI4.js +0 -69
  138. package/dist/chunk-BKWFDWYM.js +0 -46
  139. package/dist/chunk-G53LBDNU.js +0 -255
  140. package/dist/chunk-GCSDF5IE.js +0 -27
  141. package/dist/chunk-H5API74E.js +0 -67
  142. package/dist/chunk-HBX55MWO.js +0 -27
  143. package/dist/chunk-JOIKBUQN.js +0 -88
  144. package/dist/chunk-M2YMBT5G.js +0 -73
  145. package/dist/chunk-MJRGPEQ5.js +0 -25
  146. package/dist/chunk-QV3JPCMK.js +0 -17
  147. package/dist/chunk-TFKN5EIR.js +0 -27
  148. package/dist/chunk-UNP6Y4JV.js +0 -38
@@ -1,26 +1,24 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- resolveOpengrepConfig
4
- } from "./chunk-7WKVCZI4.js";
5
2
  import {
6
3
  PYTHON_COMPILE_VERDICT_SERVER_ID,
7
4
  augmentPythonEnvironment,
8
5
  detectPythonEnvironment,
9
- pythonEnvironmentToolCandidates
10
- } from "./chunk-2H5GHZKC.js";
11
- import {
6
+ pythonEnvironmentToolCandidates,
12
7
  scannerReportParentDir
13
- } from "./chunk-QV3JPCMK.js";
8
+ } from "./chunk-ZIF4WLWR.js";
14
9
  import {
15
10
  getUserRuleRoot,
16
11
  load,
17
12
  resolvePackagePath,
18
13
  ruleCorpusFingerprintForCycle
19
- } from "./chunk-ZQSSO7LO.js";
14
+ } from "./chunk-EQKF6BAK.js";
15
+ import {
16
+ resolveOpengrepRulePack
17
+ } from "./chunk-GWZZOJD2.js";
20
18
  import {
21
19
  extensionsForLanguage,
22
20
  isTypeScriptFile
23
- } from "./chunk-DI4AZZNY.js";
21
+ } from "./chunk-HKPJTI47.js";
24
22
  import {
25
23
  ensureTool,
26
24
  findManagedToolBinary,
@@ -30,32 +28,29 @@ import {
30
28
  isZizmorAuditTarget,
31
29
  logSessionStart,
32
30
  resolveZizmorGitHubToken
33
- } from "./chunk-B2OXE4AH.js";
31
+ } from "./chunk-VC3W54G3.js";
34
32
  import {
35
33
  resolveToolCwd
36
- } from "./chunk-LVLPA32Q.js";
34
+ } from "./chunk-GVE5VZYQ.js";
37
35
  import {
38
36
  commandSearchReachesProject,
39
37
  findGlobalBinary,
40
38
  isProjectLocalBinPath
41
- } from "./chunk-LGH2HHZG.js";
39
+ } from "./chunk-YZNARDMM.js";
42
40
  import {
43
41
  hasCargoWorkspaceTable,
44
42
  readCargoWorkspaceExclude,
45
43
  readCargoWorkspaceMembers,
46
44
  readTextFileOrUndefined
47
- } from "./chunk-KNSOA43J.js";
45
+ } from "./chunk-J2DAHH4T.js";
48
46
  import {
49
- classifyFinderFailure,
50
47
  classifyProbeFailure,
51
- createAvailabilityLatch,
52
48
  describeInstallAttempt,
53
- logAvailabilityDecision,
54
- startHostStallSampler
55
- } from "./chunk-6GLMMGCX.js";
49
+ logAvailabilityDecision
50
+ } from "./chunk-KDPZA2UE.js";
56
51
  import {
57
52
  readDirEntriesSafeAsync
58
- } from "./chunk-74AMPWNC.js";
53
+ } from "./chunk-KW7O72AK.js";
59
54
  import {
60
55
  OWNER_TAG_ENV,
61
56
  SpawnFailureError,
@@ -75,6 +70,7 @@ import {
75
70
  isUntrustedProjectPath,
76
71
  mergeWindowsEnvironment,
77
72
  ownerTagForChildren,
73
+ projectSearchJudge,
78
74
  recordProjectCommandRefusal,
79
75
  resolveGitCheckout,
80
76
  resolveLinkedWorktreeOwner,
@@ -83,14 +79,9 @@ import {
83
79
  safeSpawn,
84
80
  safeSpawnAsync,
85
81
  statIsFile,
86
- trustScopedEnvironment
87
- } from "./chunk-3PO4YYOX.js";
88
- import {
89
- DOTNET_CSHARP_ROOT_MARKERS,
90
- DOTNET_FSHARP_ROOT_MARKERS,
91
- KIND_EXTENSIONS,
92
- LEAN_ROOT_MARKERS
93
- } from "./chunk-CQY2HEH7.js";
82
+ trustScopedEnvironment,
83
+ withUnadmittedRootSpawns
84
+ } from "./chunk-LURFD4HD.js";
94
85
  import {
95
86
  boundedKeyLabel,
96
87
  finalizeRecords,
@@ -102,7 +93,13 @@ import {
102
93
  reportPiLensConfigRecords,
103
94
  resolvePiLensConfig,
104
95
  summarizeConfigResolution
105
- } from "./chunk-PQF6YGYB.js";
96
+ } from "./chunk-UX75PTQW.js";
97
+ import {
98
+ DOTNET_CSHARP_ROOT_MARKERS,
99
+ DOTNET_FSHARP_ROOT_MARKERS,
100
+ KIND_EXTENSIONS,
101
+ LEAN_ROOT_MARKERS
102
+ } from "./chunk-V4TFQY5G.js";
106
103
  import {
107
104
  FRESHNESS_CADENCE_MS,
108
105
  LSP_NAMESPACE_KEY,
@@ -113,19 +110,19 @@ import {
113
110
  getDirectoryMarkers,
114
111
  getPiLensGlobalConfigPath,
115
112
  unknownDirMtimeRecords
116
- } from "./chunk-LOEJFTF2.js";
113
+ } from "./chunk-D2LFEA5U.js";
117
114
  import {
118
115
  HOOK_WALL_BUDGET_MS,
119
116
  bounded,
120
117
  getProjectTrustGeneration,
121
118
  getProjectTrustState
122
- } from "./chunk-W26QZ3OM.js";
119
+ } from "./chunk-463WN3VP.js";
123
120
  import {
124
121
  getDegradationLedgerGeneration,
125
122
  incrementDegradationCount,
126
123
  logExtension,
127
124
  recordDegradationOnce
128
- } from "./chunk-NHA5K226.js";
125
+ } from "./chunk-CQNXALZJ.js";
129
126
  import {
130
127
  claimPhaseOncePerSession,
131
128
  currentSessionRecordId,
@@ -136,7 +133,7 @@ import {
136
133
  logLatency,
137
134
  redactSecrets,
138
135
  releasePhaseClaim
139
- } from "./chunk-7CLWC2UH.js";
136
+ } from "./chunk-YVE5Q2UU.js";
140
137
  import {
141
138
  STAGE_TMP_PATTERN
142
139
  } from "./chunk-LJDODBBZ.js";
@@ -163,7 +160,64 @@ import {
163
160
  toPosix,
164
161
  toProjectRelativePath,
165
162
  walkUpDirs
166
- } from "./chunk-WLD6BGON.js";
163
+ } from "./chunk-ZSPVF7KI.js";
164
+
165
+ // dist/clients/opengrep-config.js
166
+ import * as path from "node:path";
167
+ var LOCAL_OPENGREP_CONFIG_NAMES = [
168
+ ".opengrep.yml",
169
+ ".opengrep.yaml",
170
+ "opengrep.yml",
171
+ "opengrep.yaml",
172
+ ".semgrep.yml",
173
+ ".semgrep.yaml",
174
+ "semgrep.yml",
175
+ "semgrep.yaml"
176
+ ];
177
+ function findLocalOpengrepConfig(startDir) {
178
+ return findLocalToolConfig(startDir, LOCAL_OPENGREP_CONFIG_NAMES);
179
+ }
180
+ function isRegistryOrAutoConfig(config) {
181
+ return config === "auto" || config.startsWith("p/") || config.startsWith("r/");
182
+ }
183
+ function normalizeOpengrepConfigArg(config, cwd) {
184
+ if (!config)
185
+ return void 0;
186
+ const trimmed = config.trim();
187
+ if (!trimmed)
188
+ return void 0;
189
+ if (isRegistryOrAutoConfig(trimmed))
190
+ return trimmed;
191
+ return path.isAbsolute(trimmed) ? trimmed : path.resolve(cwd, trimmed);
192
+ }
193
+ function resolveOpengrepConfig(cwd, flags) {
194
+ const localConfig = findLocalOpengrepConfig(cwd);
195
+ const flagConfig = typeof flags?.config === "string" && flags.config.trim() ? flags.config.trim() : void 0;
196
+ if (flags?.enabled || flagConfig) {
197
+ const explicit = normalizeOpengrepConfigArg(flagConfig ?? localConfig, cwd);
198
+ if (explicit) {
199
+ return {
200
+ enabled: true,
201
+ configArg: explicit,
202
+ source: localConfig && !flagConfig ? "local" : "flag"
203
+ };
204
+ }
205
+ const pack = resolveOpengrepRulePack();
206
+ return pack ? { enabled: true, configArg: pack, source: "pack" } : { enabled: true, configArg: "auto", source: "flag" };
207
+ }
208
+ if (localConfig) {
209
+ return {
210
+ enabled: true,
211
+ configArg: localConfig,
212
+ source: "local"
213
+ };
214
+ }
215
+ return {
216
+ enabled: false,
217
+ source: "disabled",
218
+ reason: "no local opengrep config (.opengrep.yml) and --lens-opengrep not set"
219
+ };
220
+ }
167
221
 
168
222
  // dist/clients/analysis-root.js
169
223
  import * as fs from "node:fs";
@@ -280,12 +334,63 @@ function holdsProjectConfig(dir) {
280
334
  });
281
335
  }
282
336
 
337
+ // dist/clients/lsp/server-covers.js
338
+ var BUILTIN_SERVER_RUNNER_COVERS = /* @__PURE__ */ new Map([
339
+ [
340
+ "bash",
341
+ { runnerIds: ["shellcheck"], gateCommands: ["bash-language-server"] }
342
+ ],
343
+ ["shuck", { runnerIds: ["shellcheck"], gateCommands: ["shuck"] }],
344
+ ["toml", { runnerIds: ["taplo"], gateCommands: ["taplo"] }]
345
+ ]);
346
+
347
+ // dist/clients/lsp/server-traits.js
348
+ var ROLE_MEMBERS = {
349
+ language: "language",
350
+ auxiliary: "auxiliary"
351
+ };
352
+ var DEFAULT_LSP_SERVER_ROLE = "language";
353
+ function isTsgoLaunchVariant(variant) {
354
+ return variant === "native-ts7" || variant === "effect-tsgo";
355
+ }
356
+ function isAuxiliary(bearer) {
357
+ const declared = bearer?.role;
358
+ const role = typeof declared === "string" && Object.hasOwn(ROLE_MEMBERS, declared) ? ROLE_MEMBERS[declared] : DEFAULT_LSP_SERVER_ROLE;
359
+ switch (role) {
360
+ case "auxiliary":
361
+ return true;
362
+ case "language":
363
+ return false;
364
+ }
365
+ }
366
+ var DEFAULT_RESEND_RECHECK = "unmeasured";
367
+ var DEFAULT_NOTIFY_INFLIGHT_LIMIT = 8;
368
+ var DEFAULT_REPLY_ORDERING = "unmeasured";
369
+ function serverTraits(declaration) {
370
+ const declaredLimit = declaration.notifyInflightLimit;
371
+ if (typeof declaredLimit === "number" && Number.isFinite(declaredLimit) && declaredLimit > 0) {
372
+ return {
373
+ role: declaration.role,
374
+ notifyInflightLimit: Math.floor(declaredLimit),
375
+ replyOrdering: declaration.replyOrdering ?? DEFAULT_REPLY_ORDERING,
376
+ resendRecheck: declaration.resendRecheck ?? DEFAULT_RESEND_RECHECK
377
+ };
378
+ }
379
+ const envLimit = Number(process.env.PI_LENS_LSP_AUX_NOTIFY_INFLIGHT);
380
+ return {
381
+ role: declaration.role,
382
+ notifyInflightLimit: Number.isFinite(envLimit) && envLimit > 0 ? Math.floor(envLimit) : DEFAULT_NOTIFY_INFLIGHT_LIMIT,
383
+ replyOrdering: declaration.replyOrdering ?? DEFAULT_REPLY_ORDERING,
384
+ resendRecheck: declaration.resendRecheck ?? DEFAULT_RESEND_RECHECK
385
+ };
386
+ }
387
+
283
388
  // dist/clients/lsp/file-server-match.js
284
- import path from "node:path";
389
+ import path2 from "node:path";
285
390
  function fileMatchKeys(filePath) {
286
391
  return {
287
- ext: path.extname(filePath).toLowerCase(),
288
- base: path.basename(filePath).toLowerCase()
392
+ ext: path2.extname(filePath).toLowerCase(),
393
+ base: path2.basename(filePath).toLowerCase()
289
394
  };
290
395
  }
291
396
  function fileMatchReason(server, filePath, ext, base) {
@@ -309,14 +414,14 @@ function registeredServers(config, catalog) {
309
414
  }
310
415
 
311
416
  // dist/clients/lsp/server.js
312
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, statSync as statSync4 } from "node:fs";
417
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readdirSync as readdirSync5, statSync as statSync4 } from "node:fs";
313
418
  import { access, readFile, readdir, realpath, stat } from "node:fs/promises";
314
419
  import os6 from "node:os";
315
- import path8 from "node:path";
420
+ import path9 from "node:path";
316
421
 
317
422
  // dist/clients/shell-dialect.js
318
423
  import * as fs2 from "node:fs";
319
- import * as path2 from "node:path";
424
+ import * as path3 from "node:path";
320
425
  var SHELLCHECK_SUPPORTED_DIALECTS = [
321
426
  "sh",
322
427
  "bash",
@@ -369,7 +474,7 @@ function resolveShellFileDialect(filePath) {
369
474
  }
370
475
  const directive = parseShellDirective(content);
371
476
  const shebang = parseShebang(content);
372
- const parsed = directive ?? shebang ?? (path2.extname(filePath).toLowerCase() === ".zsh" ? "zsh" : null);
477
+ const parsed = directive ?? shebang ?? (path3.extname(filePath).toLowerCase() === ".zsh" ? "zsh" : null);
373
478
  return {
374
479
  shebang,
375
480
  directive,
@@ -380,22 +485,22 @@ function resolveShellFileDialect(filePath) {
380
485
  // dist/clients/sgconfig.js
381
486
  import { createHash } from "node:crypto";
382
487
  import * as fs3 from "node:fs";
383
- import * as path3 from "node:path";
488
+ import * as path4 from "node:path";
384
489
  var SGCONFIG_NAMES = ["sgconfig.yml", "sgconfig.yaml"];
385
490
  function findLocalSgconfig(startDir) {
386
491
  return findLocalToolConfig(startDir, SGCONFIG_NAMES);
387
492
  }
388
493
  function getAstGrepRuleSources(projectRoot = process.cwd()) {
389
- const root = path3.resolve(projectRoot || process.cwd());
494
+ const root = path4.resolve(projectRoot || process.cwd());
390
495
  const packageRoot = resolvePackagePath(import.meta.url);
391
496
  const candidates = [];
392
497
  if (realpathOrResolve(root) !== realpathOrResolve(packageRoot)) {
393
498
  candidates.push({
394
- dir: path3.join(root, "rules", "ast-grep-rules", "rules"),
499
+ dir: path4.join(root, "rules", "ast-grep-rules", "rules"),
395
500
  origin: "project",
396
501
  tier: "primary"
397
502
  }, {
398
- dir: path3.join(root, "rules", "ast-grep-rules", "coderabbit", "rules"),
503
+ dir: path4.join(root, "rules", "ast-grep-rules", "coderabbit", "rules"),
399
504
  origin: "project",
400
505
  tier: "secondary"
401
506
  });
@@ -403,21 +508,21 @@ function getAstGrepRuleSources(projectRoot = process.cwd()) {
403
508
  const userRoot = getUserRuleRoot();
404
509
  if (realpathOrResolve(userRoot) !== realpathOrResolve(root)) {
405
510
  candidates.push({
406
- dir: path3.join(userRoot, "ast-grep-rules", "rules"),
511
+ dir: path4.join(userRoot, "ast-grep-rules", "rules"),
407
512
  origin: "user",
408
513
  tier: "primary"
409
514
  }, {
410
- dir: path3.join(userRoot, "ast-grep-rules", "coderabbit", "rules"),
515
+ dir: path4.join(userRoot, "ast-grep-rules", "coderabbit", "rules"),
411
516
  origin: "user",
412
517
  tier: "secondary"
413
518
  });
414
519
  }
415
520
  candidates.push({
416
- dir: path3.join(packageRoot, "rules", "ast-grep-rules", "rules"),
521
+ dir: path4.join(packageRoot, "rules", "ast-grep-rules", "rules"),
417
522
  origin: "bundled",
418
523
  tier: "primary"
419
524
  }, {
420
- dir: path3.join(packageRoot, "rules", "ast-grep-rules", "coderabbit", "rules"),
525
+ dir: path4.join(packageRoot, "rules", "ast-grep-rules", "coderabbit", "rules"),
421
526
  origin: "bundled",
422
527
  tier: "secondary"
423
528
  });
@@ -441,7 +546,7 @@ function findYamlFiles(dir) {
441
546
  return files;
442
547
  }
443
548
  for (const entry of entries) {
444
- const full = path3.join(dir, entry.name);
549
+ const full = path4.join(dir, entry.name);
445
550
  if (entry.isDirectory()) {
446
551
  files.push(...findYamlFiles(full));
447
552
  } else if (entry.isFile() && /\.ya?ml$/i.test(entry.name)) {
@@ -483,7 +588,7 @@ function snapshotRuleSource(source) {
483
588
  const hash = createHash("sha256");
484
589
  const files = [];
485
590
  for (const file of findYamlFiles(source.dir)) {
486
- const relativePath = path3.relative(source.dir, file);
591
+ const relativePath = path4.relative(source.dir, file);
487
592
  hash.update(relativePath);
488
593
  hash.update("\0");
489
594
  let content;
@@ -526,7 +631,7 @@ function sourceFingerprint(sources) {
526
631
  return hash.digest("hex");
527
632
  }
528
633
  function getAstGrepRuleFingerprint(projectRoot = process.cwd(), options = {}) {
529
- const root = path3.resolve(projectRoot || process.cwd());
634
+ const root = path4.resolve(projectRoot || process.cwd());
530
635
  return ruleCorpusFingerprintForCycle("ast-grep", root, (fingerprintRoot) => sourceFingerprint(getAstGrepRuleSources(fingerprintRoot).map(snapshotRuleSource)), options.force);
531
636
  }
532
637
  function materializeMergedRuleDir(sources, mergedDir) {
@@ -546,7 +651,7 @@ function materializeMergedRuleDir(sources, mergedDir) {
546
651
  });
547
652
  if (survivingDocuments.length === 0)
548
653
  continue;
549
- const destination = path3.join(mergedDir, `source${sourceIndex}-${String(fileIndex).padStart(5, "0")}.yml`);
654
+ const destination = path4.join(mergedDir, `source${sourceIndex}-${String(fileIndex).padStart(5, "0")}.yml`);
550
655
  if (survivingDocuments.length === file.documents.length) {
551
656
  fs3.copyFileSync(file.file, destination);
552
657
  } else {
@@ -563,7 +668,7 @@ function rootArtifactKey(root) {
563
668
  return createHash("sha256").update(root).digest("hex").slice(0, 12);
564
669
  }
565
670
  function resolveBaselineSgconfig(projectRoot = process.cwd()) {
566
- const root = realpathOrResolve(path3.resolve(projectRoot || process.cwd()));
671
+ const root = realpathOrResolve(path4.resolve(projectRoot || process.cwd()));
567
672
  const fingerprint = getAstGrepRuleFingerprint(root, { force: true });
568
673
  const cached = cachedBaselines.get(root);
569
674
  if (cached?.fingerprint === fingerprint && fs3.existsSync(cached.path) && fs3.existsSync(cached.mergedDir)) {
@@ -572,11 +677,11 @@ function resolveBaselineSgconfig(projectRoot = process.cwd()) {
572
677
  const sources = getAstGrepRuleSources(root).map(snapshotRuleSource);
573
678
  if (sources.length === 0)
574
679
  return void 0;
575
- const dir = path3.join(scannerReportParentDir(), "pi-lens-ast-grep");
680
+ const dir = path4.join(scannerReportParentDir(), "pi-lens-ast-grep");
576
681
  fs3.mkdirSync(dir, { recursive: true });
577
682
  const artifactKey = rootArtifactKey(root);
578
- const file = path3.join(dir, `baseline-${process.pid}-${artifactKey}.sgconfig.yml`);
579
- const mergedDir = path3.join(dir, `baseline-${process.pid}-${artifactKey}.rules`);
683
+ const file = path4.join(dir, `baseline-${process.pid}-${artifactKey}.sgconfig.yml`);
684
+ const mergedDir = path4.join(dir, `baseline-${process.pid}-${artifactKey}.rules`);
580
685
  const protectedArtifacts = /* @__PURE__ */ new Set([file, mergedDir]);
581
686
  for (const baseline of cachedBaselines.values()) {
582
687
  protectedArtifacts.add(baseline.path);
@@ -584,7 +689,7 @@ function resolveBaselineSgconfig(projectRoot = process.cwd()) {
584
689
  }
585
690
  cleanupStaleBaselines(dir, protectedArtifacts);
586
691
  materializeMergedRuleDir(sources, mergedDir);
587
- const ruleDirForYaml = mergedDir.split(path3.sep).join("/");
692
+ const ruleDirForYaml = mergedDir.split(path4.sep).join("/");
588
693
  fs3.writeFileSync(file, `ruleDirs:
589
694
  - ${JSON.stringify(ruleDirForYaml)}
590
695
  `);
@@ -606,7 +711,7 @@ function enforceBaselineEntryCap(dir, keep) {
606
711
  const isMergedDir = /^baseline-\d+(?:-[a-f0-9]+)?\.rules$/.test(name);
607
712
  if (!isConfig && !isMergedDir)
608
713
  continue;
609
- const full = path3.join(dir, name);
714
+ const full = path4.join(dir, name);
610
715
  if (keep.has(full))
611
716
  continue;
612
717
  try {
@@ -654,7 +759,7 @@ function cleanupStaleBaselines(dir, keep) {
654
759
  const isMergedDir = /^baseline-\d+(?:-[a-f0-9]+)?\.rules$/.test(name);
655
760
  if (!isConfig && !isMergedDir)
656
761
  continue;
657
- const full = path3.join(dir, name);
762
+ const full = path4.join(dir, name);
658
763
  if (keep.has(full))
659
764
  continue;
660
765
  try {
@@ -679,50 +784,9 @@ function findLocalTyposConfig(startDir) {
679
784
  return findLocalToolConfig(startDir, LOCAL_TYPOS_CONFIG_NAMES);
680
785
  }
681
786
 
682
- // dist/clients/lsp/server-traits.js
683
- var ROLE_MEMBERS = {
684
- language: "language",
685
- auxiliary: "auxiliary"
686
- };
687
- var DEFAULT_LSP_SERVER_ROLE = "language";
688
- function isTsgoLaunchVariant(variant) {
689
- return variant === "native-ts7" || variant === "effect-tsgo";
690
- }
691
- function isAuxiliary(bearer) {
692
- const declared = bearer?.role;
693
- const role = typeof declared === "string" && Object.hasOwn(ROLE_MEMBERS, declared) ? ROLE_MEMBERS[declared] : DEFAULT_LSP_SERVER_ROLE;
694
- switch (role) {
695
- case "auxiliary":
696
- return true;
697
- case "language":
698
- return false;
699
- }
700
- }
701
- var DEFAULT_RESEND_RECHECK = "unmeasured";
702
- var DEFAULT_NOTIFY_INFLIGHT_LIMIT = 8;
703
- var DEFAULT_REPLY_ORDERING = "unmeasured";
704
- function serverTraits(declaration) {
705
- const declaredLimit = declaration.notifyInflightLimit;
706
- if (typeof declaredLimit === "number" && Number.isFinite(declaredLimit) && declaredLimit > 0) {
707
- return {
708
- role: declaration.role,
709
- notifyInflightLimit: Math.floor(declaredLimit),
710
- replyOrdering: declaration.replyOrdering ?? DEFAULT_REPLY_ORDERING,
711
- resendRecheck: declaration.resendRecheck ?? DEFAULT_RESEND_RECHECK
712
- };
713
- }
714
- const envLimit = Number(process.env.PI_LENS_LSP_AUX_NOTIFY_INFLIGHT);
715
- return {
716
- role: declaration.role,
717
- notifyInflightLimit: Number.isFinite(envLimit) && envLimit > 0 ? Math.floor(envLimit) : DEFAULT_NOTIFY_INFLIGHT_LIMIT,
718
- replyOrdering: declaration.replyOrdering ?? DEFAULT_REPLY_ORDERING,
719
- resendRecheck: declaration.resendRecheck ?? DEFAULT_RESEND_RECHECK
720
- };
721
- }
722
-
723
787
  // dist/clients/lsp/config.js
724
788
  import * as os3 from "node:os";
725
- import path5 from "node:path";
789
+ import path6 from "node:path";
726
790
 
727
791
  // dist/clients/dispatch/known-runner-ids.js
728
792
  var knownRunnerIds = /* @__PURE__ */ new Set();
@@ -741,7 +805,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
741
805
  import { spawn as nodeSpawn } from "node:child_process";
742
806
  import fs5 from "node:fs";
743
807
  import os2 from "node:os";
744
- import path4 from "node:path";
808
+ import path5 from "node:path";
745
809
 
746
810
  // dist/clients/lsp/ruby-drive-dirs.js
747
811
  import * as fs4 from "node:fs";
@@ -785,15 +849,99 @@ async function getRubyVersionDirNamesAsync(driveRoot) {
785
849
  // dist/clients/lsp/launch.js
786
850
  var isWindows = process.platform === "win32";
787
851
  var OWNER_TAG_READ_MS = 5e3;
788
- function computeNeedsShell(resolvedCommand) {
789
- return isWindows && (resolvedCommand.includes(" ") || /\.(cmd|bat)$/i.test(resolvedCommand) || !/\.(exe|cmd|bat)$/i.test(resolvedCommand));
852
+ function planServerLaunch(command, args, cwd, env) {
853
+ if (!isWindows)
854
+ return { command, args, shell: false, script: false };
855
+ const file = resolveWindowsCommandForEnvironment(command, cwd, env)?.resolvedPath ?? command;
856
+ if (/\.(exe|com)$/i.test(file)) {
857
+ return { command: file, args, shell: false, script: false };
858
+ }
859
+ const shim = /\.(cmd|bat)$/i.test(file) ? resolveNpmCmdShim(file, cwd, env) : void 0;
860
+ if (shim) {
861
+ return {
862
+ command: shim.program,
863
+ args: [shim.script, ...args],
864
+ shell: false,
865
+ script: true
866
+ };
867
+ }
868
+ return { command: file, args, shell: true, script: true };
869
+ }
870
+ var NPM_CMD_SHIM_HEAD = [
871
+ "@ECHO off",
872
+ "GOTO start",
873
+ ":find_dp0",
874
+ "SET dp0=%~dp0",
875
+ "EXIT /b",
876
+ ":start",
877
+ "SETLOCAL",
878
+ "CALL :find_dp0",
879
+ 'IF EXIST "%dp0%\\node.exe" (',
880
+ 'SET "_prog=%dp0%\\node.exe"',
881
+ ") ELSE (",
882
+ 'SET "_prog=node"'
883
+ ];
884
+ var NPM_CMD_SHIM_TEMPLATES = [
885
+ {
886
+ tail: ["SET PATHEXT=%PATHEXT:;.JS;=;%", ")"],
887
+ run: /^endLocal & goto #_undefined_# 2>NUL \|\| title %COMSPEC% & "%_prog%"\s+"%dp0%\\([^"%]+)"\s+%\*$/
888
+ },
889
+ {
890
+ tail: [")"],
891
+ run: /^set PATHEXT=%PATHEXT:;\.JS;=;% & "%_prog%"\s+"%dp0%\\([^"%]+)"\s+%\*$/
892
+ }
893
+ ];
894
+ function parseNpmCmdShim(content) {
895
+ const lines = content.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
896
+ for (const template of NPM_CMD_SHIM_TEMPLATES) {
897
+ const head = [...NPM_CMD_SHIM_HEAD, ...template.tail];
898
+ if (lines.length !== head.length + 1)
899
+ continue;
900
+ if (!head.every((line, index) => lines[index] === line))
901
+ continue;
902
+ const target = template.run.exec(lines[head.length] ?? "")?.[1];
903
+ if (target !== void 0)
904
+ return target;
905
+ }
906
+ return void 0;
907
+ }
908
+ function resolveNpmCmdShim(shimFile, cwd, env) {
909
+ const recordUncontained = (why) => {
910
+ recordDegradationOnce({
911
+ kind: "lsp-server-uncontained",
912
+ subject: shimFile,
913
+ reason: `${path5.basename(shimFile)} runs behind cmd.exe, so its server outlives a pi that is killed: ${why}`
914
+ });
915
+ return void 0;
916
+ };
917
+ let content;
918
+ try {
919
+ content = fs5.readFileSync(shimFile, "utf-8");
920
+ } catch (cause) {
921
+ recordUncontained(`the shim could not be read (${String(cause)})`);
922
+ return void 0;
923
+ }
924
+ const target = parseNpmCmdShim(content);
925
+ if (target === void 0)
926
+ return recordUncontained("not an npm cmd-shim template");
927
+ const dir = path5.dirname(shimFile);
928
+ const script = path5.resolve(dir, target.replace(/[/\\]/g, path5.sep));
929
+ if (!statIsFile(script))
930
+ return recordUncontained(`its script is not a file: ${script}`);
931
+ const besideShim = path5.join(dir, "node.exe");
932
+ const program = statIsFile(besideShim) ? besideShim : resolveWindowsCommandForEnvironment("node", cwd, env)?.resolvedPath;
933
+ if (program === void 0)
934
+ return recordUncontained("no node.exe beside it or on the child's PATH");
935
+ if (!/\.exe$/i.test(program))
936
+ return recordUncontained(`node is not an .exe: ${program}`);
937
+ return { program, script };
790
938
  }
791
939
  var DEFAULT_STARTUP_FAILURE_WINDOW_MS = 50;
792
940
  var WINDOWS_NAV_STARTUP_FAILURE_WINDOW_MS = 500;
793
941
  var SESSIONSTART_LOG_DIR = getGlobalPiLensLogDir();
794
- var SESSIONSTART_LOG = path4.join(SESSIONSTART_LOG_DIR, "sessionstart.log");
795
- var PI_LENS_BIN_DIR = path4.join(getGlobalPiLensDir(), "bin");
796
- var PI_LENS_TOOLS_BIN_DIR = path4.join(getGlobalPiLensDir(), "tools", "node_modules", ".bin");
942
+ var SESSIONSTART_LOG = path5.join(SESSIONSTART_LOG_DIR, "sessionstart.log");
943
+ var PI_LENS_BIN_DIR = path5.join(getGlobalPiLensDir(), "bin");
944
+ var PI_LENS_TOOLS_BIN_DIR = path5.join(getGlobalPiLensDir(), "tools", "node_modules", ".bin");
797
945
  function logSessionStart2(msg) {
798
946
  if (isTestMode()) {
799
947
  return;
@@ -822,8 +970,8 @@ function splitPathEntries(value, delimiter) {
822
970
  }
823
971
  function normalizePathEntry(entry, platform) {
824
972
  if (platform !== "win32")
825
- return path4.posix.normalize(entry);
826
- return path4.win32.normalize(entry).toLowerCase();
973
+ return path5.posix.normalize(entry);
974
+ return path5.win32.normalize(entry).toLowerCase();
827
975
  }
828
976
  function combinePathValuesForPlatform(values, platform = process.platform) {
829
977
  const unique = [];
@@ -866,27 +1014,27 @@ function getLiveWindowsPath() {
866
1014
  }
867
1015
  async function buildAugmentedPath(basePath) {
868
1016
  const candidates = [];
869
- const nodeDir = path4.dirname(process.execPath);
1017
+ const nodeDir = path5.dirname(process.execPath);
870
1018
  if (nodeDir) {
871
1019
  candidates.push(nodeDir);
872
1020
  }
873
1021
  if (isWindows) {
874
1022
  const home = os2.homedir();
875
- const driveRoot = path4.parse(home).root;
876
- candidates.push(path4.join(home, ".cargo", "bin"));
877
- candidates.push(path4.join(home, "go", "bin"));
878
- candidates.push(path4.join(home, ".dotnet", "tools"));
1023
+ const driveRoot = path5.parse(home).root;
1024
+ candidates.push(path5.join(home, ".cargo", "bin"));
1025
+ candidates.push(path5.join(home, "go", "bin"));
1026
+ candidates.push(path5.join(home, ".dotnet", "tools"));
879
1027
  candidates.push(PI_LENS_BIN_DIR);
880
1028
  candidates.push(PI_LENS_TOOLS_BIN_DIR);
881
- candidates.push(path4.join(driveRoot, "Program Files", "Go", "bin"));
882
- candidates.push(path4.join(driveRoot, "Go", "bin"));
1029
+ candidates.push(path5.join(driveRoot, "Program Files", "Go", "bin"));
1030
+ candidates.push(path5.join(driveRoot, "Go", "bin"));
883
1031
  for (const entry of await getRubyVersionDirNamesAsync(driveRoot)) {
884
- candidates.push(path4.join(driveRoot, entry, "bin"));
1032
+ candidates.push(path5.join(driveRoot, entry, "bin"));
885
1033
  }
886
1034
  }
887
1035
  const effectiveBase = isWindows ? combinePathValuesForPlatform([basePath, getLiveWindowsPath()]) : basePath;
888
1036
  const existing = /* @__PURE__ */ new Set();
889
- for (const entry of splitPathEntries(effectiveBase, path4.delimiter)) {
1037
+ for (const entry of splitPathEntries(effectiveBase, path5.delimiter)) {
890
1038
  if (!entry)
891
1039
  continue;
892
1040
  existing.add(normalizePathEntry(entry, process.platform));
@@ -904,18 +1052,18 @@ async function buildAugmentedPath(basePath) {
904
1052
  if (toAppend.length === 0)
905
1053
  return basePath ?? "";
906
1054
  if (!basePath)
907
- return toAppend.join(path4.delimiter);
908
- return `${basePath}${path4.delimiter}${toAppend.join(path4.delimiter)}`;
1055
+ return toAppend.join(path5.delimiter);
1056
+ return `${basePath}${path5.delimiter}${toAppend.join(path5.delimiter)}`;
909
1057
  }
910
1058
  function isCmdShimValid(cmdPath, cwd) {
911
- const shimFile = cwd === void 0 ? cmdPath : path4.resolve(cwd, cmdPath);
1059
+ const shimFile = cwd === void 0 ? cmdPath : path5.resolve(cwd, cmdPath);
912
1060
  try {
913
1061
  const content = fs5.readFileSync(shimFile, "utf-8");
914
1062
  const match = content.match(/"%~dp0[/\\]\.\.[/\\]((?:[\w./@-]|\\)+\.(?:mjs|cjs|js))"/i);
915
1063
  if (!match)
916
1064
  return true;
917
- const relPath = match[1].replace(/[/\\]/g, path4.sep);
918
- const target = path4.resolve(path4.dirname(shimFile), "..", relPath);
1065
+ const relPath = match[1].replace(/[/\\]/g, path5.sep);
1066
+ const target = path5.resolve(path5.dirname(shimFile), "..", relPath);
919
1067
  return fs5.existsSync(target);
920
1068
  } catch {
921
1069
  return statIsFile(shimFile);
@@ -942,19 +1090,18 @@ function isMissingWindowsStartupCommand(spawnCommand, presence, cwd) {
942
1090
  function bypassPs1OnWindows(ps1Path, args) {
943
1091
  const cmdPath = `${ps1Path.slice(0, -4)}.cmd`;
944
1092
  if (fs5.existsSync(cmdPath)) {
945
- return { command: cmdPath, args, needsShell: true };
1093
+ return { command: cmdPath, args };
946
1094
  }
947
1095
  try {
948
1096
  const content = fs5.readFileSync(ps1Path, "utf-8");
949
1097
  const match = content.match(/"\$basedir[/\\]\.\.[/\\]((?:[\w./@-]|\\)+\.(?:mjs|cjs|js))"/i);
950
1098
  if (match) {
951
- const relPath = match[1].replace(/[/\\]/g, path4.sep);
952
- const jsPath = path4.resolve(path4.dirname(ps1Path), "..", relPath);
1099
+ const relPath = match[1].replace(/[/\\]/g, path5.sep);
1100
+ const jsPath = path5.resolve(path5.dirname(ps1Path), "..", relPath);
953
1101
  if (fs5.existsSync(jsPath)) {
954
1102
  return {
955
1103
  command: process.execPath,
956
- args: [jsPath, ...args],
957
- needsShell: false
1104
+ args: [jsPath, ...args]
958
1105
  };
959
1106
  }
960
1107
  }
@@ -972,10 +1119,13 @@ var lspProjectCodePermission = new AsyncLocalStorage();
972
1119
  function withLspProjectCodePermission(allowed, spawn) {
973
1120
  return lspProjectCodePermission.run(allowed, spawn);
974
1121
  }
1122
+ function isLspProjectCodeAdmitted(projectCodeAllowed = lspProjectCodePermission.getStore() ?? false) {
1123
+ return projectCodeAllowed && getProjectTrustState() === "trusted";
1124
+ }
975
1125
  var unknownProjectLocalNoticeGeneration = -1;
976
1126
  function recordUntrustedLspExecution(request, trust) {
977
1127
  const generation = getDegradationLedgerGeneration();
978
- const subject = request.kind === "project-code-server" ? `project-code-server:g${generation}:${request.serverId}:${request.root}` : `project-local-binary:g${generation}:${path4.basename(request.command)}`;
1128
+ const subject = request.kind === "project-code-server" ? `project-code-server:g${generation}:${request.serverId}:${request.root}` : `project-local-binary:g${generation}:${path5.basename(request.command)}`;
979
1129
  const metadata = request.kind === "project-code-server" ? {
980
1130
  field: request.kind,
981
1131
  serverId: request.serverId,
@@ -1012,7 +1162,7 @@ function refuseUntrustedLspExecution(request, trust = getProjectTrustState()) {
1012
1162
  }
1013
1163
  function admitProjectSuppliedTsserver(tsserverPath, cwd, projectSupplied, projectCodeAllowed = lspProjectCodePermission.getStore() ?? false) {
1014
1164
  const trust = getProjectTrustState();
1015
- if (tsserverPath && (!projectSupplied || projectCodeAllowed && trust === "trusted"))
1165
+ if (tsserverPath && (!projectSupplied || isLspProjectCodeAdmitted(projectCodeAllowed)))
1016
1166
  return tsserverPath;
1017
1167
  if (!tsserverPath) {
1018
1168
  recordUnresolvedTypeScriptCompiler(cwd, trust);
@@ -1054,19 +1204,24 @@ function sessionRepositoryHoldsCompiler(cwd) {
1054
1204
  function isProjectLocalLspBinary(resolvedCommand, cwd) {
1055
1205
  return isProjectLocalBinPath(resolvedCommand, cwd);
1056
1206
  }
1057
- function refuseProjectLookup(command, spawnCommand, cwd, env) {
1207
+ function refuseProjectLookup(command, spawnCommand, cwd, env, reachesRoot) {
1058
1208
  const unresolved = spawnCommand === command;
1059
1209
  if (unresolved && !isWindows)
1060
1210
  return;
1061
1211
  const owned = unresolved ? resolveWindowsCommandForEnvironment(command, cwd, mergeWindowsEnvironment(env, { PATH: cwd }))?.resolvedPath : spawnCommand;
1062
- if (owned === void 0 || !isUntrustedProjectPath(owned))
1212
+ if (owned === void 0)
1213
+ return;
1214
+ const inRoot = reachesRoot?.(path5.dirname(realpathOrResolve(owned))) === true;
1215
+ if (!inRoot && !isUntrustedProjectPath(owned))
1063
1216
  return;
1064
1217
  recordProjectCommandRefusal(owned);
1065
1218
  throw new SpawnFailureError("trust-refused", `LSP lookup refused: ${command} resolved inside the project and project trust is ${getProjectTrustState()}`, new Error(`project trust is ${getProjectTrustState()}`));
1066
1219
  }
1067
- function trySpawn(command, args, cwd, env, needsShell) {
1220
+ function trySpawn(spawnCommand, spawnArgs, cwd, env) {
1221
+ const plan = planServerLaunch(spawnCommand, spawnArgs, cwd, env);
1222
+ const { command, args } = plan;
1068
1223
  let proc;
1069
- if (needsShell) {
1224
+ if (plan.shell) {
1070
1225
  const escapeCmdArg = (s) => {
1071
1226
  const escaped = s.replace(/([&|<>^()!])/g, "^$1");
1072
1227
  return /[\s"]/.test(escaped) ? `"${escaped.replace(/"/g, '""')}"` : escaped;
@@ -1092,8 +1247,8 @@ function trySpawn(command, args, cwd, env, needsShell) {
1092
1247
  if (!proc.stdin || !proc.stdout || !proc.stderr) {
1093
1248
  throw new Error(`Failed to spawn LSP server: ${command}`);
1094
1249
  }
1095
- holdOwnChildPid(proc.pid, "lsp-spawn");
1096
- return proc;
1250
+ holdOwnChildPid(proc, "lsp-spawn");
1251
+ return { proc, plan };
1097
1252
  }
1098
1253
  function unrefLspProcessHandles(proc) {
1099
1254
  try {
@@ -1146,27 +1301,26 @@ async function launchLSP(command, args = [], options = {}) {
1146
1301
  const mergedEnv = { ...process.env, ...options.env };
1147
1302
  const augmentedPath = await buildAugmentedPath(resolvePathValue(mergedEnv));
1148
1303
  const ownerTag = await ownerTagForChildren({ timeoutMs: OWNER_TAG_READ_MS });
1304
+ const reachesRoot = isLspProjectCodeAdmitted() ? void 0 : projectSearchJudge(cwd);
1149
1305
  const env = trustScopedEnvironment({
1150
1306
  ...mergedEnv,
1151
1307
  PATH: augmentedPath,
1152
1308
  ...isWindows ? { Path: augmentedPath } : {}
1153
- }, cwd);
1309
+ }, cwd, reachesRoot);
1154
1310
  if (ownerTag === void 0)
1155
1311
  delete env[OWNER_TAG_ENV];
1156
1312
  else
1157
1313
  env[OWNER_TAG_ENV] = ownerTag;
1158
- const isBareCommand = !isFullyQualified(command) && !command.includes(path4.sep) && !command.includes("/");
1159
- const isRelativePath = !isFullyQualified(command) && (command.includes(path4.sep) || command.includes("/"));
1160
- const explicitCommand = isRelativePath ? path4.resolve(cwd, command) : command;
1314
+ const isBareCommand = !isFullyQualified(command) && !command.includes(path5.sep) && !command.includes("/");
1315
+ const isRelativePath = !isFullyQualified(command) && (command.includes(path5.sep) || command.includes("/"));
1316
+ const explicitCommand = isRelativePath ? path5.resolve(cwd, command) : command;
1161
1317
  const scannedCommandPath = isBareCommand ? findBinaryOnPath(command, env, cwd) : void 0;
1162
1318
  const resolvedCommand = scannedCommandPath ?? explicitCommand;
1163
- let needsShell = computeNeedsShell(resolvedCommand);
1164
1319
  let spawnCommand = resolvedCommand;
1165
1320
  if (isBareCommand) {
1166
1321
  const globalBinPath = await findGlobalBinary(command);
1167
1322
  if (globalBinPath) {
1168
1323
  spawnCommand = globalBinPath;
1169
- needsShell = computeNeedsShell(spawnCommand);
1170
1324
  }
1171
1325
  }
1172
1326
  const commandPresence = isWindows ? windowsCommandPresence({
@@ -1177,7 +1331,7 @@ async function launchLSP(command, args = [], options = {}) {
1177
1331
  cwd,
1178
1332
  env
1179
1333
  }) : "absent";
1180
- if (isProjectLocalLspBinary(spawnCommand, cwd)) {
1334
+ if ((isBareCommand || fs5.existsSync(spawnCommand) || commandPresence === "present") && isProjectLocalLspBinary(spawnCommand, cwd)) {
1181
1335
  refuseUntrustedLspExecution({
1182
1336
  kind: "project-local-binary",
1183
1337
  command,
@@ -1186,7 +1340,7 @@ async function launchLSP(command, args = [], options = {}) {
1186
1340
  });
1187
1341
  }
1188
1342
  if (isBareCommand)
1189
- refuseProjectLookup(command, spawnCommand, cwd, env);
1343
+ refuseProjectLookup(command, spawnCommand, cwd, env, reachesRoot);
1190
1344
  if (isWindows && /\.(cmd|bat)$/i.test(spawnCommand) && !isCmdShimValid(spawnCommand, cwd)) {
1191
1345
  logSessionStart2(`lsp cmd-shim-invalid: ${spawnCommand} target missing \u2014 skipping candidate`);
1192
1346
  const cause = Object.assign(new Error(`LSP .cmd shim target not found: ${spawnCommand}`), { code: "ENOENT" });
@@ -1195,23 +1349,21 @@ async function launchLSP(command, args = [], options = {}) {
1195
1349
  if (isWindows && /\.ps1$/i.test(spawnCommand)) {
1196
1350
  const bypass = bypassPs1OnWindows(spawnCommand, args);
1197
1351
  if (bypass) {
1198
- logSessionStart2(`lsp ps1-bypass: ${spawnCommand} \u2192 ${bypass.command} shell=${bypass.needsShell}`);
1352
+ logSessionStart2(`lsp ps1-bypass: ${spawnCommand} \u2192 ${bypass.command}`);
1199
1353
  spawnCommand = bypass.command;
1200
1354
  args = bypass.args;
1201
- needsShell = bypass.needsShell;
1202
1355
  } else {
1203
1356
  logSessionStart2(`lsp ps1-bypass: no .cmd or JS entry found for ${spawnCommand}, spawn may hang`);
1204
1357
  }
1205
1358
  }
1206
- let proc;
1359
+ let launched;
1207
1360
  try {
1208
- proc = trySpawn(spawnCommand, args, cwd, env, needsShell);
1361
+ launched = trySpawn(spawnCommand, args, cwd, env);
1209
1362
  } catch (err) {
1210
1363
  if (isBareCommand) {
1211
1364
  const globalBinPath = await findGlobalBinary(command);
1212
1365
  if (globalBinPath && globalBinPath !== spawnCommand) {
1213
- const needsShellGlobal = computeNeedsShell(globalBinPath);
1214
- proc = trySpawn(globalBinPath, args, cwd, env, needsShellGlobal);
1366
+ launched = trySpawn(globalBinPath, args, cwd, env);
1215
1367
  } else {
1216
1368
  throw await classifySpawnFailure(err, { command, cwd });
1217
1369
  }
@@ -1219,6 +1371,7 @@ async function launchLSP(command, args = [], options = {}) {
1219
1371
  throw await classifySpawnFailure(err, { command, cwd });
1220
1372
  }
1221
1373
  }
1374
+ const { proc, plan } = launched;
1222
1375
  if (!proc.stdin || !proc.stdout || !proc.stderr) {
1223
1376
  throw new Error(`Failed to spawn LSP server: ${command}`);
1224
1377
  }
@@ -1230,7 +1383,7 @@ async function launchLSP(command, args = [], options = {}) {
1230
1383
  }
1231
1384
  throw failure;
1232
1385
  }
1233
- logSessionStart2(`lsp launch: command=${command} resolved=${spawnCommand} args=${JSON.stringify(args)} cwd=${cwd} shell=${needsShell ? "true" : "false"} pid=${proc.pid ?? 0}`);
1386
+ logSessionStart2(`lsp launch: command=${command} resolved=${plan.command} args=${JSON.stringify(plan.args)} cwd=${cwd} shell=${plan.shell ? "true" : "false"} pid=${proc.pid ?? 0}`);
1234
1387
  const formatStartupStderr = (stderr) => {
1235
1388
  const normalized = compactLogValue(stderr);
1236
1389
  if (!normalized)
@@ -1245,7 +1398,7 @@ async function launchLSP(command, args = [], options = {}) {
1245
1398
  };
1246
1399
  proc.stderr?.on("data", onStartupStderr);
1247
1400
  try {
1248
- await new Promise((resolve4, reject) => {
1401
+ await new Promise((resolve5, reject) => {
1249
1402
  let settled = false;
1250
1403
  proc.on("error", (err) => {
1251
1404
  if (!settled) {
@@ -1274,7 +1427,7 @@ async function launchLSP(command, args = [], options = {}) {
1274
1427
  if (options?.startupFailureWindowMs) {
1275
1428
  return options.startupFailureWindowMs;
1276
1429
  }
1277
- if (isWindows && needsShell) {
1430
+ if (plan.script) {
1278
1431
  return WINDOWS_NAV_STARTUP_FAILURE_WINDOW_MS;
1279
1432
  }
1280
1433
  return DEFAULT_STARTUP_FAILURE_WINDOW_MS;
@@ -1282,7 +1435,7 @@ async function launchLSP(command, args = [], options = {}) {
1282
1435
  setTimeout(() => {
1283
1436
  if (!settled) {
1284
1437
  settled = true;
1285
- resolve4();
1438
+ resolve5();
1286
1439
  }
1287
1440
  }, startupFailureWindowMs);
1288
1441
  });
@@ -1290,8 +1443,8 @@ async function launchLSP(command, args = [], options = {}) {
1290
1443
  proc.stderr?.off("data", onStartupStderr);
1291
1444
  }
1292
1445
  _attachErrorHandler(proc, command, {
1293
- command: spawnCommand,
1294
- args,
1446
+ command: plan.command,
1447
+ args: plan.args,
1295
1448
  cwd,
1296
1449
  pid: proc.pid ?? 0
1297
1450
  });
@@ -1302,8 +1455,8 @@ async function launchLSP(command, args = [], options = {}) {
1302
1455
  stdout: proc.stdout,
1303
1456
  stderr: proc.stderr,
1304
1457
  pid: proc.pid ?? 0,
1305
- command: spawnCommand,
1306
- args
1458
+ command: plan.command,
1459
+ args: plan.args
1307
1460
  };
1308
1461
  }
1309
1462
  async function launchViaNode(scriptPath, args = [], options = {}) {
@@ -1316,7 +1469,7 @@ function asRecord(value) {
1316
1469
  }
1317
1470
  var CONFIG_RESOLVED_PHASE = "config_resolved";
1318
1471
  function configResolutionKey(cwd) {
1319
- return normalizeFilePath(path5.resolve(normalizeFilePath(cwd)));
1472
+ return normalizeFilePath(path6.resolve(normalizeFilePath(cwd)));
1320
1473
  }
1321
1474
  function publishConfigResolutionPending(cwd) {
1322
1475
  logSessionStart(`session_start config_resolution_pending session=${currentSessionRecordId()} root=${configResolutionKey(cwd)}`);
@@ -1593,7 +1746,7 @@ var EMPTY_CONFIG = {
1593
1746
  };
1594
1747
  var configInFlight = /* @__PURE__ */ new Map();
1595
1748
  function normalizeWorkspacePath(cwd) {
1596
- return path5.resolve(cwd);
1749
+ return path6.resolve(cwd);
1597
1750
  }
1598
1751
  var unknownTrustNoticeGeneration = -1;
1599
1752
  var serversForFileOverride;
@@ -1784,7 +1937,7 @@ var OVERRIDE_COPY_TRAITS = {
1784
1937
  },
1785
1938
  idleEviction: {
1786
1939
  keep: false,
1787
- why: "Reset to unmeasured (never evicted): 'transparent' needs per-server evidence."
1940
+ why: "Reset to unmeasured: 'transparent' needs per-server evidence, and a 'resident' opt-out names the catalog binary, not the override."
1788
1941
  },
1789
1942
  replyOrdering: {
1790
1943
  keep: false,
@@ -2552,14 +2705,14 @@ function classifyCascadeWaitTier(lspService, filePath, snapshots) {
2552
2705
  // dist/clients/lsp/lombok.js
2553
2706
  import * as fs6 from "node:fs";
2554
2707
  import * as os4 from "node:os";
2555
- import * as path6 from "node:path";
2708
+ import * as path7 from "node:path";
2556
2709
  var LOMBOK_ENV_KEYS = ["PI_LENS_LOMBOK_JAR", "LOMBOK_JAR"];
2557
2710
  var LOMBOK_PROJECT_FILES = [
2558
2711
  "lombok.config",
2559
2712
  "pom.xml",
2560
2713
  "build.gradle",
2561
2714
  "build.gradle.kts",
2562
- path6.join("gradle", "libs.versions.toml")
2715
+ path7.join("gradle", "libs.versions.toml")
2563
2716
  ];
2564
2717
  function fileExists(filePath) {
2565
2718
  if (!filePath)
@@ -2584,13 +2737,13 @@ function containsLombokDependency(text) {
2584
2737
  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);
2585
2738
  }
2586
2739
  function hasLombokProject(root) {
2587
- const lombokConfig = path6.join(root, "lombok.config");
2740
+ const lombokConfig = path7.join(root, "lombok.config");
2588
2741
  if (fileExists(lombokConfig))
2589
2742
  return true;
2590
2743
  for (const name of LOMBOK_PROJECT_FILES) {
2591
2744
  if (name === "lombok.config")
2592
2745
  continue;
2593
- const text = readTextIfSmall(path6.join(root, name));
2746
+ const text = readTextIfSmall(path7.join(root, name));
2594
2747
  if (text && containsLombokDependency(text))
2595
2748
  return true;
2596
2749
  }
@@ -2600,16 +2753,16 @@ function envJarCandidate(env) {
2600
2753
  for (const key of LOMBOK_ENV_KEYS) {
2601
2754
  const value = env[key]?.trim();
2602
2755
  if (fileExists(value))
2603
- return path6.resolve(value);
2756
+ return path7.resolve(value);
2604
2757
  }
2605
2758
  return void 0;
2606
2759
  }
2607
2760
  function localJarCandidates(root) {
2608
2761
  return [
2609
- path6.join(root, "lombok.jar"),
2610
- path6.join(root, ".lombok", "lombok.jar"),
2611
- path6.join(root, "lib", "lombok.jar"),
2612
- path6.join(root, "libs", "lombok.jar")
2762
+ path7.join(root, "lombok.jar"),
2763
+ path7.join(root, ".lombok", "lombok.jar"),
2764
+ path7.join(root, "lib", "lombok.jar"),
2765
+ path7.join(root, "libs", "lombok.jar")
2613
2766
  ];
2614
2767
  }
2615
2768
  function newestExistingJar(candidates) {
@@ -2628,17 +2781,17 @@ function newestExistingJar(candidates) {
2628
2781
  return best?.filePath;
2629
2782
  }
2630
2783
  function mavenLocalLombokJar(home = os4.homedir()) {
2631
- const base = path6.join(home, ".m2", "repository", "org", "projectlombok", "lombok");
2784
+ const base = path7.join(home, ".m2", "repository", "org", "projectlombok", "lombok");
2632
2785
  let versions = [];
2633
2786
  try {
2634
2787
  versions = fs6.readdirSync(base);
2635
2788
  } catch {
2636
2789
  return void 0;
2637
2790
  }
2638
- return newestExistingJar(versions.map((version) => path6.join(base, version, `lombok-${version}.jar`)));
2791
+ return newestExistingJar(versions.map((version) => path7.join(base, version, `lombok-${version}.jar`)));
2639
2792
  }
2640
2793
  function gradleCacheLombokJar(home = os4.homedir()) {
2641
- const base = path6.join(home, ".gradle", "caches", "modules-2", "files-2.1", "org.projectlombok", "lombok");
2794
+ const base = path7.join(home, ".gradle", "caches", "modules-2", "files-2.1", "org.projectlombok", "lombok");
2642
2795
  const candidates = [];
2643
2796
  let versions = [];
2644
2797
  try {
@@ -2647,7 +2800,7 @@ function gradleCacheLombokJar(home = os4.homedir()) {
2647
2800
  return void 0;
2648
2801
  }
2649
2802
  for (const version of versions) {
2650
- const versionDir = path6.join(base, version);
2803
+ const versionDir = path7.join(base, version);
2651
2804
  let hashes = [];
2652
2805
  try {
2653
2806
  hashes = fs6.readdirSync(versionDir);
@@ -2655,7 +2808,7 @@ function gradleCacheLombokJar(home = os4.homedir()) {
2655
2808
  continue;
2656
2809
  }
2657
2810
  for (const hash of hashes) {
2658
- candidates.push(path6.join(versionDir, hash, `lombok-${version}.jar`));
2811
+ candidates.push(path7.join(versionDir, hash, `lombok-${version}.jar`));
2659
2812
  }
2660
2813
  }
2661
2814
  return newestExistingJar(candidates);
@@ -2688,15 +2841,14 @@ function createLombokJdtlsArgs(root, baseEnv = process.env) {
2688
2841
  // dist/clients/lsp/jvm-runtime.js
2689
2842
  import { existsSync as existsSync2, readdirSync as readdirSync4 } from "node:fs";
2690
2843
  import os5 from "node:os";
2691
- import path7 from "node:path";
2844
+ import path8 from "node:path";
2692
2845
  var JAVA_EXE = process.platform === "win32" ? "java.exe" : "java";
2693
- var JAVA_PROBE_TIMEOUT_MS = 5e3;
2694
2846
  var MIN_JAVA_MAJOR = 17;
2695
2847
  function jdkHomeFrom(dir) {
2696
- if (existsSync2(path7.join(dir, "bin", JAVA_EXE)))
2848
+ if (existsSync2(path8.join(dir, "bin", JAVA_EXE)))
2697
2849
  return dir;
2698
- const macHome = path7.join(dir, "Contents", "Home");
2699
- if (existsSync2(path7.join(macHome, "bin", JAVA_EXE)))
2850
+ const macHome = path8.join(dir, "Contents", "Home");
2851
+ if (existsSync2(path8.join(macHome, "bin", JAVA_EXE)))
2700
2852
  return macHome;
2701
2853
  return void 0;
2702
2854
  }
@@ -2709,7 +2861,7 @@ function parseMajorVersion(name) {
2709
2861
  }
2710
2862
  function childDirs(base) {
2711
2863
  try {
2712
- return readdirSync4(base, { withFileTypes: true }).filter((e) => e.isDirectory() || e.isSymbolicLink()).map((e) => path7.join(base, e.name));
2864
+ return readdirSync4(base, { withFileTypes: true }).filter((e) => e.isDirectory() || e.isSymbolicLink()).map((e) => path8.join(base, e.name));
2713
2865
  } catch {
2714
2866
  return [];
2715
2867
  }
@@ -2717,26 +2869,26 @@ function childDirs(base) {
2717
2869
  function candidateRoots() {
2718
2870
  const home = os5.homedir();
2719
2871
  const roots = [];
2720
- roots.push(path7.join(home, ".jdks"));
2721
- roots.push(path7.join(getGlobalPiLensDir(), "tools"));
2872
+ roots.push(path8.join(home, ".jdks"));
2873
+ roots.push(path8.join(getGlobalPiLensDir(), "tools"));
2722
2874
  if (process.platform === "win32") {
2723
2875
  const progFiles = [
2724
2876
  process.env.ProgramFiles,
2725
2877
  process.env["ProgramFiles(x86)"],
2726
2878
  process.env.ProgramW6432,
2727
- path7.join(process.env.LOCALAPPDATA ?? path7.join(home, "AppData", "Local"), "Programs")
2879
+ path8.join(process.env.LOCALAPPDATA ?? path8.join(home, "AppData", "Local"), "Programs")
2728
2880
  ].filter((p) => Boolean(p));
2729
2881
  for (const base of progFiles) {
2730
- roots.push(path7.join(base, "Eclipse Adoptium"));
2731
- roots.push(path7.join(base, "Java"));
2732
- roots.push(path7.join(base, "Microsoft"));
2733
- roots.push(path7.join(base, "Zulu"));
2734
- roots.push(path7.join(base, "Amazon Corretto"));
2735
- roots.push(path7.join(base, "BellSoft"));
2882
+ roots.push(path8.join(base, "Eclipse Adoptium"));
2883
+ roots.push(path8.join(base, "Java"));
2884
+ roots.push(path8.join(base, "Microsoft"));
2885
+ roots.push(path8.join(base, "Zulu"));
2886
+ roots.push(path8.join(base, "Amazon Corretto"));
2887
+ roots.push(path8.join(base, "BellSoft"));
2736
2888
  }
2737
2889
  } else if (process.platform === "darwin") {
2738
2890
  roots.push("/Library/Java/JavaVirtualMachines");
2739
- roots.push(path7.join(home, "Library", "Java", "JavaVirtualMachines"));
2891
+ roots.push(path8.join(home, "Library", "Java", "JavaVirtualMachines"));
2740
2892
  roots.push("/opt/homebrew/opt");
2741
2893
  roots.push("/usr/local/opt");
2742
2894
  } else {
@@ -2760,7 +2912,7 @@ function discoverJdkHome(roots = candidateRoots(), javaHome = process.env.JAVA_H
2760
2912
  continue;
2761
2913
  found.push({
2762
2914
  home: resolved,
2763
- major: parseMajorVersion(path7.basename(dir))
2915
+ major: parseMajorVersion(path8.basename(dir))
2764
2916
  });
2765
2917
  }
2766
2918
  }
@@ -2771,103 +2923,25 @@ function discoverJdkHome(roots = candidateRoots(), javaHome = process.env.JAVA_H
2771
2923
  return usable[0].home;
2772
2924
  }
2773
2925
  var _cachedEnv;
2774
- var javaAvailabilityLatch = createAvailabilityLatch();
2775
- var inFlightJavaProbe = null;
2776
- function probeJavaOnPath() {
2777
- const trustGeneration = getProjectTrustGeneration();
2778
- const memo = javaAvailabilityLatch.read();
2779
- if (memo !== null) {
2780
- if (javaAvailabilityLatch.getOutcome() === "transient") {
2781
- logAvailabilityDecision({
2782
- tool: "java",
2783
- verdict: "unavailable",
2784
- outcome: "transient",
2785
- cause: javaAvailabilityLatch.getCause() ?? "probe-timeout",
2786
- elapsedMs: 0,
2787
- latched: false,
2788
- retryAfterMs: Math.max(0, javaAvailabilityLatch.getRetryAtMs() - Date.now()),
2789
- budgetMs: JAVA_PROBE_TIMEOUT_MS,
2790
- // No probe ran here: the latch's own remembered cause is replayed
2791
- // as-is, so the call site is the one asserting it (#2209).
2792
- classifiedBy: "caller"
2793
- });
2794
- return Promise.resolve(void 0);
2795
- }
2796
- return Promise.resolve(memo);
2797
- }
2798
- if (inFlightJavaProbe?.trustGeneration === trustGeneration)
2799
- return inFlightJavaProbe.promise;
2800
- const promise = runJavaProbe().finally(() => {
2801
- if (inFlightJavaProbe?.promise === promise)
2802
- inFlightJavaProbe = null;
2803
- });
2804
- inFlightJavaProbe = { trustGeneration, promise };
2805
- return promise;
2806
- }
2807
- async function runJavaProbe() {
2808
- const finder = process.platform === "win32" ? "where" : "which";
2809
- const startedAt = Date.now();
2810
- const sampler = startHostStallSampler();
2811
- let result;
2812
- let hostStallMs;
2813
- try {
2814
- result = await safeSpawnAsync(finder, ["java"], {
2815
- timeout: JAVA_PROBE_TIMEOUT_MS
2816
- });
2817
- } finally {
2818
- hostStallMs = sampler.stop();
2819
- }
2820
- const elapsedMs = Date.now() - startedAt;
2821
- if (result.status === 0 && !result.error) {
2822
- javaAvailabilityLatch.noteAvailable();
2823
- logAvailabilityDecision({
2824
- tool: "java",
2825
- verdict: "available",
2826
- outcome: "success",
2827
- cause: "ok",
2828
- elapsedMs,
2829
- latched: true,
2830
- hostStallMs,
2831
- budgetMs: JAVA_PROBE_TIMEOUT_MS,
2832
- classifiedBy: "probe"
2833
- });
2834
- return true;
2835
- }
2836
- const { outcome, cause, forced } = classifyFinderFailure(result, {
2837
- hostStallMs
2838
- });
2839
- const retryAfterMs = javaAvailabilityLatch.noteUnavailable(outcome, cause);
2840
- logAvailabilityDecision({
2841
- tool: "java",
2842
- verdict: "unavailable",
2843
- outcome,
2844
- cause,
2845
- elapsedMs,
2846
- latched: outcome !== "transient",
2847
- hostStallMs,
2848
- ...retryAfterMs > 0 && { retryAfterMs },
2849
- budgetMs: JAVA_PROBE_TIMEOUT_MS,
2850
- classifiedBy: forced ? "caller" : "probe"
2851
- });
2852
- return outcome === "transient" ? void 0 : false;
2853
- }
2926
+ var probeModule;
2854
2927
  async function resolveJavaRuntimeEnv() {
2855
2928
  if (_cachedEnv?.trustGeneration === getProjectTrustGeneration())
2856
2929
  return _cachedEnv.value;
2930
+ const { toolOnPath } = probeModule ??= await import("./chunk-BXXC6KRR.js");
2857
2931
  const trustGeneration = getProjectTrustGeneration();
2858
- const javaOnPath = await probeJavaOnPath();
2932
+ const javaOnPath = await toolOnPath("java");
2859
2933
  if (javaOnPath === true) {
2860
2934
  _cachedEnv = { value: void 0, trustGeneration };
2861
2935
  return void 0;
2862
2936
  }
2863
2937
  const home = discoverJdkHome();
2864
2938
  if (home) {
2865
- const binDir = path7.join(home, "bin");
2939
+ const binDir = path8.join(home, "bin");
2866
2940
  const currentPath = process.env.PATH ?? process.env.Path ?? "";
2867
2941
  _cachedEnv = {
2868
2942
  value: {
2869
2943
  JAVA_HOME: home,
2870
- PATH: binDir + path7.delimiter + currentPath
2944
+ PATH: binDir + path8.delimiter + currentPath
2871
2945
  },
2872
2946
  trustGeneration
2873
2947
  };
@@ -2879,17 +2953,8 @@ async function resolveJavaRuntimeEnv() {
2879
2953
  return void 0;
2880
2954
  }
2881
2955
 
2882
- // dist/clients/lsp/server-covers.js
2883
- var BUILTIN_SERVER_RUNNER_COVERS = /* @__PURE__ */ new Map([
2884
- [
2885
- "bash",
2886
- { runnerIds: ["shellcheck"], gateCommands: ["bash-language-server"] }
2887
- ],
2888
- ["shuck", { runnerIds: ["shellcheck"], gateCommands: ["shuck"] }],
2889
- ["toml", { runnerIds: ["taplo"], gateCommands: ["taplo"] }]
2890
- ]);
2891
-
2892
2956
  // dist/clients/lsp/server.js
2957
+ var LSP_ROOT_DECLINED = /* @__PURE__ */ Symbol("pi-lens.lsp-root-declined");
2893
2958
  function withRootMarkers(root, markers) {
2894
2959
  root.rootMarkers = markers;
2895
2960
  return root;
@@ -2920,13 +2985,16 @@ async function resolveLspServerCwd(server, filePath, sessionCwd, onRootFailure,
2920
2985
  let serverRoot;
2921
2986
  let rootFailed = false;
2922
2987
  try {
2923
- serverRoot = await server.root(filePath);
2988
+ const verdict = await server.root(filePath);
2989
+ if (verdict === LSP_ROOT_DECLINED)
2990
+ return void 0;
2991
+ serverRoot = verdict;
2924
2992
  } catch (error) {
2925
2993
  const reason = error instanceof Error ? error.message : String(error);
2926
2994
  rootFailed = true;
2927
2995
  onRootFailure?.(reason);
2928
2996
  }
2929
- const isFileDirFallback = serverRoot !== void 0 && rootMarkers?.length && path8.resolve(serverRoot) === path8.resolve(path8.dirname(filePath));
2997
+ const isFileDirFallback = serverRoot !== void 0 && rootMarkers?.length && path9.resolve(serverRoot) === path9.resolve(path9.dirname(filePath));
2930
2998
  if (!serverRoot || isFileDirFallback) {
2931
2999
  const probedMarker = onRootFallback && !rootFailed && rootMarkers?.length ? resolveToolCwd("lsp", server.id, filePath, {
2932
3000
  cwd: sessionCwd,
@@ -2935,7 +3003,7 @@ async function resolveLspServerCwd(server, filePath, sessionCwd, onRootFailure,
2935
3003
  }).marker : void 0;
2936
3004
  const refusedMarker = probedMarker !== void 0 && rootMarkers?.includes(probedMarker) ? probedMarker : void 0;
2937
3005
  const fallbackCwd = rootMarkers?.length ? resolveToolCwd("lsp", server.id, filePath, {
2938
- cwd: path8.dirname(path8.resolve(filePath)),
3006
+ cwd: path9.dirname(path9.resolve(filePath)),
2939
3007
  rootMarkers
2940
3008
  }) : void 0;
2941
3009
  if (!serverRoot) {
@@ -3018,17 +3086,17 @@ var PYTHON_EXTENSIONS = new Set(extensionsForLanguage("python"));
3018
3086
  var loggedRootCeilingClamps = /* @__PURE__ */ new Set();
3019
3087
  var posixCaseInsensitiveByPath = /* @__PURE__ */ new Map();
3020
3088
  function posixFilesystemIsCaseInsensitive(root) {
3021
- const resolved = path8.resolve(root);
3089
+ const resolved = path9.resolve(root);
3022
3090
  const cached = posixCaseInsensitiveByPath.get(resolved);
3023
3091
  if (cached !== void 0)
3024
3092
  return cached;
3025
3093
  if (!existsSync3(resolved)) {
3026
3094
  return false;
3027
3095
  }
3028
- const name = path8.basename(resolved);
3096
+ const name = path9.basename(resolved);
3029
3097
  const alternate = name.toLowerCase() === name ? name.toUpperCase() : name.toLowerCase();
3030
3098
  let insensitive = false;
3031
- const alternatePath = path8.join(path8.dirname(resolved), alternate);
3099
+ const alternatePath = path9.join(path9.dirname(resolved), alternate);
3032
3100
  if (alternate !== name && existsSync3(alternatePath)) {
3033
3101
  try {
3034
3102
  const actual = statSync4(resolved);
@@ -3046,7 +3114,7 @@ function resetLSPCaseSensitivityState() {
3046
3114
  }
3047
3115
  function isSameOrWithin(ancestor, candidate, deps = {}) {
3048
3116
  const windowsShaped = isWindowsPath(ancestor) || isWindowsPath(candidate);
3049
- const pathApi = windowsShaped ? path8.win32 : path8;
3117
+ const pathApi = windowsShaped ? path9.win32 : path9;
3050
3118
  const resolvedAncestor = pathApi.resolve(ancestor);
3051
3119
  const resolvedCandidate = pathApi.resolve(candidate);
3052
3120
  let caseInsensitive = false;
@@ -3070,7 +3138,7 @@ function isSameOrWithin(ancestor, candidate, deps = {}) {
3070
3138
  }
3071
3139
  function enforceLspRootCeiling(root, sessionCwd, filePath) {
3072
3140
  const windowsShaped = isWindowsPath(root) || isWindowsPath(sessionCwd);
3073
- const pathApi = windowsShaped ? path8.win32 : path8;
3141
+ const pathApi = windowsShaped ? path9.win32 : path9;
3074
3142
  const resolvedRoot = pathApi.resolve(root);
3075
3143
  const resolvedCwd = pathApi.resolve(sessionCwd);
3076
3144
  if (filePath && !isSameOrWithin(resolvedCwd, pathApi.resolve(filePath))) {
@@ -3097,8 +3165,8 @@ async function hasProjectBoundaryMarker(dir, server) {
3097
3165
  return false;
3098
3166
  }
3099
3167
  function pathSegments(dir) {
3100
- const parsed = path8.parse(path8.resolve(dir));
3101
- return path8.relative(parsed.root, path8.resolve(dir)).split(path8.sep).filter(Boolean).map((segment) => segment.toLowerCase());
3168
+ const parsed = path9.parse(path9.resolve(dir));
3169
+ return path9.relative(parsed.root, path9.resolve(dir)).split(path9.sep).filter(Boolean).map((segment) => segment.toLowerCase());
3102
3170
  }
3103
3171
  function hasFixtureConvention(dir) {
3104
3172
  const segments = pathSegments(dir);
@@ -3129,7 +3197,7 @@ async function findGitBoundary(dir, memo) {
3129
3197
  return found;
3130
3198
  }
3131
3199
  async function isExcludedLspRoot(dir, gitBoundaries) {
3132
- const candidate = path8.resolve(dir);
3200
+ const candidate = path9.resolve(dir);
3133
3201
  if (hasFixtureConvention(candidate) || hasAtomicStageSegment(candidate))
3134
3202
  return true;
3135
3203
  const gitRoot = await findGitBoundary(candidate, gitBoundaries);
@@ -3140,8 +3208,8 @@ async function isExcludedLspRoot(dir, gitBoundaries) {
3140
3208
  return isPathIgnoredByProject(candidate, gitRoot, true);
3141
3209
  }
3142
3210
  async function nearestNonExcludedFallbackRoot(candidate, stopDir) {
3143
- const startDir = path8.resolve(candidate);
3144
- const fsRoot = path8.parse(startDir).root;
3211
+ const startDir = path9.resolve(candidate);
3212
+ const fsRoot = path9.parse(startDir).root;
3145
3213
  let nearestAllowed;
3146
3214
  const gitBoundaries = /* @__PURE__ */ new Map();
3147
3215
  for (const current of walkUpDirs(startDir, { spelling: true })) {
@@ -3193,7 +3261,7 @@ async function installEvidenceForLaunch(toolId, installed, attempt) {
3193
3261
  const confirmedManagedPath = await findManagedToolBinary(toolId);
3194
3262
  return {
3195
3263
  ...evidence,
3196
- binary: path8.basename(installed),
3264
+ binary: path9.basename(installed),
3197
3265
  ...confirmedManagedPath !== void 0 && pathsEqual(confirmedManagedPath, installed) && {
3198
3266
  source: "managed-dir"
3199
3267
  }
@@ -3246,7 +3314,30 @@ function markDirectLspCommandUnavailable(command) {
3246
3314
  directLspCommandUnavailableUntil.set(command, Date.now() + DIRECT_LSP_NEGATIVE_TTL_MS);
3247
3315
  directLspCommandSkipLoggedUntil.delete(command);
3248
3316
  }
3249
- var PI_LENS_BIN_DIR2 = path8.join(getGlobalPiLensDir(), "bin");
3317
+ var PI_LENS_BIN_DIR2 = path9.join(getGlobalPiLensDir(), "bin");
3318
+ function bareLookupReachesUnadmittedRoot(cwd, refusals) {
3319
+ return !isLspProjectCodeAdmitted() && (refusals?.bareRefused === true || commandSearchReachesProject(cwd));
3320
+ }
3321
+ async function lookupManagedTool(toolId, cwd, refusals, ...ensureOptions) {
3322
+ const storeOnly = bareLookupReachesUnadmittedRoot(cwd, refusals);
3323
+ if (storeOnly) {
3324
+ const trigger = refusals?.bareRefused === true ? "a bare candidate resolved into the project and was refused" : "a PATH entry reaches a project not admitted for project code";
3325
+ recordDegradationOnce({
3326
+ kind: "lsp-registry-decision",
3327
+ subject: `store-only-repair:${toolId}`,
3328
+ reason: `LSP repair read only the pi-lens tool store: ${trigger}, so nothing was probed on PATH or installed`,
3329
+ metadata: { field: "store-only-repair", tool: toolId }
3330
+ });
3331
+ }
3332
+ logSessionStart(`lsp launch ensure-tool start tool=${toolId} cwd=${cwd} storeOnly=${storeOnly}`);
3333
+ return {
3334
+ found: await (storeOnly ? getToolPath(toolId, { storeOnly: true }) : spawnsJudgedAgainstRoot(cwd, () => ensureTool(toolId, ...ensureOptions))),
3335
+ storeOnly
3336
+ };
3337
+ }
3338
+ function spawnsJudgedAgainstRoot(cwd, lookup) {
3339
+ return isLspProjectCodeAdmitted() ? lookup() : withUnadmittedRootSpawns(cwd, lookup);
3340
+ }
3250
3341
  async function resolveAndLaunch(spec, allowInstall) {
3251
3342
  const generation = lspLaunchAvailabilityGeneration.capture();
3252
3343
  const toolLabel = spec.managedToolId ?? spec.candidates[spec.candidates.length - 1] ?? "unknown";
@@ -3311,7 +3402,7 @@ async function resolveAndLaunch(spec, allowInstall) {
3311
3402
  producer: "lsp-launch",
3312
3403
  classifiedBy: "probe",
3313
3404
  evidence: {
3314
- binary: path8.basename(managedCandidate),
3405
+ binary: path9.basename(managedCandidate),
3315
3406
  source: "managed-dir",
3316
3407
  correctsLatchedRow: false
3317
3408
  }
@@ -3342,6 +3433,14 @@ async function resolveAndLaunch(spec, allowInstall) {
3342
3433
  logSessionStart(`lsp launch candidate failed tool=${toolLabel} idx=${failure.index} command=${failure.command} error=${failure.message}`);
3343
3434
  trackRuntimeFailure(failure.err);
3344
3435
  }
3436
+ const refusals = spec.refusals ?? { refused: false, bareRefused: false };
3437
+ for (const failure of candidateFailures) {
3438
+ if (!hasSpawnFailureKind(failure.err, "trust-refused"))
3439
+ continue;
3440
+ refusals.refused = true;
3441
+ if (isSimpleCommand(failure.command))
3442
+ refusals.bareRefused = true;
3443
+ }
3345
3444
  const hasOnlyRepairableCandidateFailures = candidateFailures.every((failure) => hasSpawnFailureKind(failure.err, "tool-not-found") || hasSpawnFailureKind(failure.err, "trust-refused"));
3346
3445
  if (!hasOnlyRepairableCandidateFailures) {
3347
3446
  if (lastRuntimeFailure)
@@ -3361,13 +3460,8 @@ async function resolveAndLaunch(spec, allowInstall) {
3361
3460
  globalInstallDisabled: isLspInstallDisabled()
3362
3461
  }
3363
3462
  });
3364
- if (lastRuntimeFailure)
3365
- throw lastRuntimeFailure;
3366
3463
  return void 0;
3367
3464
  }
3368
- const isRefusal = (failure) => hasSpawnFailureKind(failure.err, "trust-refused");
3369
- const trustRefused = candidateFailures.some(isRefusal);
3370
- const storeOnly = trustRefused && (candidateFailures.some((failure) => isRefusal(failure) && isSimpleCommand(failure.command)) || commandSearchReachesProject(spec.cwd));
3371
3465
  if (spec.managedToolId) {
3372
3466
  const failedCandidate = candidateFailures.at(-1);
3373
3467
  const classifiedFailure = classifyProbeFailure({
@@ -3387,17 +3481,8 @@ async function resolveAndLaunch(spec, allowInstall) {
3387
3481
  producer: "lsp-launch",
3388
3482
  evidence: classifiedFailure.evidence
3389
3483
  });
3390
- if (storeOnly) {
3391
- recordDegradationOnce({
3392
- kind: "lsp-registry-decision",
3393
- subject: `store-only-repair:${spec.managedToolId}`,
3394
- 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",
3395
- metadata: { field: "store-only-repair", tool: spec.managedToolId }
3396
- });
3397
- }
3398
- logSessionStart(`lsp launch ensure-tool start tool=${spec.managedToolId} cwd=${spec.cwd} storeOnly=${storeOnly}`);
3399
3484
  const installStartedAt = Date.now();
3400
- const installed = await (storeOnly ? getToolPath(spec.managedToolId, { storeOnly: true }) : ensureTool(spec.managedToolId));
3485
+ const { found: installed, storeOnly } = await lookupManagedTool(spec.managedToolId, spec.cwd, refusals);
3401
3486
  const installAttempt = storeOnly ? void 0 : captureInstallAttempt(spec.managedToolId);
3402
3487
  if (staleLaunch(generation, `${toolLabel}:ensureTool`)) {
3403
3488
  return void 0;
@@ -3528,13 +3613,13 @@ async function resolveAndLaunch(spec, allowInstall) {
3528
3613
  }
3529
3614
  }
3530
3615
  }
3531
- const runtimeInstall = trustRefused ? void 0 : spec.runtimeInstall;
3532
- const runtimeAvailable = runtimeInstall ? await isOnPath(runtimeInstall.runtimeCommand) : false;
3616
+ const runtimeInstall = refusals.refused || bareLookupReachesUnadmittedRoot(spec.cwd, refusals) ? void 0 : spec.runtimeInstall;
3617
+ const runtimeAvailable = runtimeInstall ? await isCommandAvailableAsync(runtimeInstall.runtimeCommand) : false;
3533
3618
  if (staleLaunch(generation, `${toolLabel}:runtimeAvailability`)) {
3534
3619
  return void 0;
3535
3620
  }
3536
3621
  if (runtimeInstall && runtimeAvailable) {
3537
- const ok = await runtimeInstall.install();
3622
+ const ok = await spawnsJudgedAgainstRoot(spec.cwd, () => runtimeInstall.install());
3538
3623
  if (staleLaunch(generation, `${toolLabel}:runtimeInstall`)) {
3539
3624
  return void 0;
3540
3625
  }
@@ -3567,7 +3652,7 @@ async function resolveAndLaunch(spec, allowInstall) {
3567
3652
  async function resolveAndLaunchBundle(spec, allowInstall) {
3568
3653
  let runtime;
3569
3654
  for (const candidate of spec.runtimeCandidates) {
3570
- if (await isOnPath(candidate)) {
3655
+ if (await isCommandAvailableAsync(candidate)) {
3571
3656
  runtime = candidate;
3572
3657
  break;
3573
3658
  }
@@ -3617,7 +3702,7 @@ async function resolveAndLaunchTreeBinary(spec, allowInstall) {
3617
3702
  return void 0;
3618
3703
  }
3619
3704
  const suffix = process.platform === "win32" ? ".exe" : "";
3620
- const binPath = path8.join(bundleDir, ...spec.binRelPath.split("/")) + suffix;
3705
+ const binPath = path9.join(bundleDir, ...spec.binRelPath.split("/")) + suffix;
3621
3706
  try {
3622
3707
  const proc = await launchLSP(binPath, spec.args, {
3623
3708
  cwd: spec.cwd,
@@ -3632,7 +3717,7 @@ async function resolveAndLaunchTreeBinary(spec, allowInstall) {
3632
3717
  }
3633
3718
  }
3634
3719
  function nodeBinLocalCandidates(root, baseName) {
3635
- const localBase = path8.join(root, "node_modules", ".bin", baseName);
3720
+ const localBase = path9.join(root, "node_modules", ".bin", baseName);
3636
3721
  if (process.platform === "win32") {
3637
3722
  return [`${localBase}.cmd`, `${localBase}.exe`];
3638
3723
  }
@@ -3642,7 +3727,7 @@ function nodeBinCandidates(root, baseName) {
3642
3727
  return [...nodeBinLocalCandidates(root, baseName), baseName];
3643
3728
  }
3644
3729
  function piAgentExtensionsRootKey(file) {
3645
- const dirKey = normalizeEphemeralMapKey(path8.dirname(path8.resolve(file)));
3730
+ const dirKey = normalizeEphemeralMapKey(path9.dirname(path9.resolve(file)));
3646
3731
  const marker = "/.pi/agent/extensions";
3647
3732
  const index = dirKey.indexOf(marker);
3648
3733
  if (index === -1)
@@ -3655,7 +3740,7 @@ function IgnoreHomeRoot(primary) {
3655
3740
  const root = await primary(file);
3656
3741
  if (!root)
3657
3742
  return void 0;
3658
- return normalizeEphemeralMapKey(path8.resolve(root)) === homeKey ? void 0 : root;
3743
+ return normalizeEphemeralMapKey(path9.resolve(root)) === homeKey ? void 0 : root;
3659
3744
  }, primary.rootMarkers ?? []);
3660
3745
  }
3661
3746
  function rubyBinCandidates(baseName) {
@@ -3663,13 +3748,13 @@ function rubyBinCandidates(baseName) {
3663
3748
  const home = os6.homedir();
3664
3749
  const isWin = process.platform === "win32";
3665
3750
  const ext = isWin ? ".bat" : "";
3666
- candidates.push(path8.join(home, ".local", "share", "mise", "installs", "ruby", "bin", `${baseName}${ext}`));
3667
- candidates.push(path8.join(home, ".asdf", "installs", "ruby", "bin", `${baseName}${ext}`));
3751
+ candidates.push(path9.join(home, ".local", "share", "mise", "installs", "ruby", "bin", `${baseName}${ext}`));
3752
+ candidates.push(path9.join(home, ".asdf", "installs", "ruby", "bin", `${baseName}${ext}`));
3668
3753
  if (isWin) {
3669
- const driveRoot = path8.parse(home).root;
3754
+ const driveRoot = path9.parse(home).root;
3670
3755
  for (const entry of getRubyVersionDirNamesSync(driveRoot)) {
3671
- candidates.push(path8.join(driveRoot, entry, "bin", `${baseName}.bat`));
3672
- candidates.push(path8.join(driveRoot, entry, "bin", baseName));
3756
+ candidates.push(path9.join(driveRoot, entry, "bin", `${baseName}.bat`));
3757
+ candidates.push(path9.join(driveRoot, entry, "bin", baseName));
3673
3758
  }
3674
3759
  }
3675
3760
  return candidates;
@@ -3690,6 +3775,9 @@ function createInteractiveServer(spec) {
3690
3775
  fallbackFor: spec.fallbackFor,
3691
3776
  requiresProjectRoot: spec.requiresProjectRoot,
3692
3777
  executesProjectCode: spec.executesProjectCode,
3778
+ ...spec.resendRecheck !== void 0 && {
3779
+ resendRecheck: spec.resendRecheck
3780
+ },
3693
3781
  availabilityKey: typeof spec.command === "string" && isSimpleCommand(spec.command) ? spec.command : void 0,
3694
3782
  async spawn(root) {
3695
3783
  const command = typeof spec.command === "function" ? spec.command(root) : spec.command;
@@ -3717,8 +3805,8 @@ function createInteractiveServer(spec) {
3717
3805
  function PriorityRoot(markerGroups, excludePatterns, stopDir) {
3718
3806
  const resolvers = markerGroups.map((markers) => NearestRoot(markers, excludePatterns, stopDir));
3719
3807
  return withRootMarkers(async (file) => {
3720
- for (const resolve4 of resolvers) {
3721
- const root = await resolve4(file);
3808
+ for (const resolve5 of resolvers) {
3809
+ const root = await resolve5(file);
3722
3810
  if (root)
3723
3811
  return root;
3724
3812
  }
@@ -3726,7 +3814,7 @@ function PriorityRoot(markerGroups, excludePatterns, stopDir) {
3726
3814
  }, markerGroups.flat());
3727
3815
  }
3728
3816
  var FileDirRoot = async (file) => {
3729
- const candidate = path8.resolve(path8.dirname(file));
3817
+ const candidate = path9.resolve(path9.dirname(file));
3730
3818
  return nearestNonExcludedFallbackRoot(candidate, piAgentExtensionsRootKey(file));
3731
3819
  };
3732
3820
  function declinesLooseFileRoot(server, root) {
@@ -3752,7 +3840,7 @@ async function declinesProjectlessRoot(server, root) {
3752
3840
  if (visited + queue.length + 1 >= PROJECT_FILE_SEARCH_MAX_DIRS)
3753
3841
  break;
3754
3842
  if (entry.isDirectory() && !isExcludedDirName(entry.name)) {
3755
- queue.push(path8.join(dir, entry.name));
3843
+ queue.push(path9.join(dir, entry.name));
3756
3844
  }
3757
3845
  }
3758
3846
  }
@@ -3777,16 +3865,16 @@ function markerProbeDir(dir, pattern) {
3777
3865
  const normalized = toPosix(pattern);
3778
3866
  const slash = normalized.lastIndexOf("/");
3779
3867
  const parentPattern = slash >= 0 ? normalized.slice(0, slash) : "";
3780
- return parentPattern ? path8.join(dir, ...parentPattern.split("/").filter(Boolean)) : dir;
3868
+ return parentPattern ? path9.join(dir, ...parentPattern.split("/").filter(Boolean)) : dir;
3781
3869
  }
3782
3870
  async function markerExists(dir, pattern) {
3783
3871
  if (!pattern.includes("*")) {
3784
3872
  try {
3785
- await stat(path8.join(dir, pattern));
3873
+ await stat(path9.join(dir, pattern));
3786
3874
  return true;
3787
3875
  } catch (err) {
3788
3876
  if (isPermissionFsError(err)) {
3789
- logSessionStart(`lsp root marker skipped: permission error stat ${path8.join(dir, pattern)}`);
3877
+ logSessionStart(`lsp root marker skipped: permission error stat ${path9.join(dir, pattern)}`);
3790
3878
  }
3791
3879
  return false;
3792
3880
  }
@@ -3823,7 +3911,7 @@ function NearestRoot(includePatterns, excludePatterns, stopDir) {
3823
3911
  }
3824
3912
  return withRootMarkers(async (file) => {
3825
3913
  const identity = realpathOrResolve(file);
3826
- const startDir = path8.dirname(identity);
3914
+ const startDir = path9.dirname(identity);
3827
3915
  const dirKey = normalizeEphemeralMapKey(startDir);
3828
3916
  const cached = cache.get(dirKey);
3829
3917
  if (cached !== void 0 && Date.now() - cached.walkedAt < FRESHNESS_CADENCE_MS && await bounded(dirMtimesStillFreshAsync(cached.probedDirs), rootMtimeBound("lsp-root-memo-freshness")) === true)
@@ -3834,7 +3922,7 @@ function NearestRoot(includePatterns, excludePatterns, stopDir) {
3834
3922
  const probedDirs = [];
3835
3923
  const walkedAt = Date.now();
3836
3924
  const promise = (async () => {
3837
- const fsRoot = path8.parse(startDir).root;
3925
+ const fsRoot = path9.parse(startDir).root;
3838
3926
  const stop = stopDir ? realpathOrResolve(stopDir) : fsRoot;
3839
3927
  for (const currentDir of walkUpDirs(startDir)) {
3840
3928
  if (stop !== fsRoot && relativeInside(stop, currentDir) === void 0) {
@@ -3880,9 +3968,6 @@ function NearestRoot(includePatterns, excludePatterns, stopDir) {
3880
3968
  }, includePatterns);
3881
3969
  }
3882
3970
  var createRootDetector = NearestRoot;
3883
- function isOnPath(command) {
3884
- return isCommandAvailableAsync(command);
3885
- }
3886
3971
  async function tryGoInstallGopls() {
3887
3972
  const isWindows2 = process.platform === "win32";
3888
3973
  const result = await safeSpawnAsync(isWindows2 ? "go.exe" : "go", ["install", "golang.org/x/tools/gopls@latest"], { timeout: 18e4, ignoreAmbientSignal: true });
@@ -3911,7 +3996,7 @@ async function findAncestorFileAmong(startDir, candidateSegmentLists) {
3911
3996
  if (isAtOrAboveHomeDir(realpathOrResolve(currentDir), home))
3912
3997
  break;
3913
3998
  for (const segments of candidateSegmentLists) {
3914
- const candidate = path8.join(currentDir, ...segments);
3999
+ const candidate = path9.join(currentDir, ...segments);
3915
4000
  try {
3916
4001
  await fs7.access(candidate);
3917
4002
  return candidate;
@@ -3930,21 +4015,21 @@ function resetClassicTsRepairGuard() {
3930
4015
  classicTsRepairState().attempted = false;
3931
4016
  }
3932
4017
  function typescriptDirsForTsc(tscPath) {
3933
- const binDir = path8.dirname(tscPath);
4018
+ const binDir = path9.dirname(tscPath);
3934
4019
  return [
3935
- path8.join(binDir, "..", "typescript"),
3936
- path8.join(binDir, "..", "..", "typescript"),
4020
+ path9.join(binDir, "..", "typescript"),
4021
+ path9.join(binDir, "..", "..", "typescript"),
3937
4022
  // Windows npm-global: `<prefix>/tsc.cmd` beside `<prefix>/node_modules`.
3938
- path8.join(binDir, "node_modules", "typescript")
4023
+ path9.join(binDir, "node_modules", "typescript")
3939
4024
  ];
3940
4025
  }
3941
4026
  async function typescriptVersionForTsc(tscPath) {
3942
- if (!path8.isAbsolute(tscPath))
4027
+ if (!path9.isAbsolute(tscPath))
3943
4028
  return void 0;
3944
4029
  for (const dir of typescriptDirsForTsc(tscPath)) {
3945
4030
  let manifest;
3946
4031
  try {
3947
- manifest = await readFile(path8.join(dir, "package.json"), "utf8");
4032
+ manifest = await readFile(path9.join(dir, "package.json"), "utf8");
3948
4033
  } catch {
3949
4034
  continue;
3950
4035
  }
@@ -3974,20 +4059,20 @@ async function hasTypescriptPackageDir(tscPath) {
3974
4059
  return false;
3975
4060
  }
3976
4061
  async function absoluteCommandPath(command) {
3977
- if (!command || path8.isAbsolute(command))
4062
+ if (!command || path9.isAbsolute(command))
3978
4063
  return command;
3979
4064
  const found = await findCommandAsync(command);
3980
4065
  return found ? realpath(found).catch(() => void 0) : void 0;
3981
4066
  }
3982
4067
  async function findTsserverPath(root, allowInstall, options) {
3983
4068
  const fs7 = await import("node:fs/promises");
3984
- const projectRoots = await Promise.all([root, options?.sessionRoot ?? process.cwd(), process.cwd()].map((dir) => fs7.realpath(dir).catch(() => path8.resolve(dir))));
4069
+ const projectRoots = await Promise.all([root, options?.sessionRoot ?? process.cwd(), process.cwd()].map((dir) => fs7.realpath(dir).catch(() => path9.resolve(dir))));
3985
4070
  const admitCandidate = async (candidate, projectSupplied) => {
3986
4071
  try {
3987
4072
  const real = await fs7.realpath(candidate);
3988
- if (path8.basename(real) !== "tsserver.js" || !(await fs7.stat(real)).isFile())
4073
+ if (path9.basename(real) !== "tsserver.js" || !(await fs7.stat(real)).isFile())
3989
4074
  return void 0;
3990
- const manifest = JSON.parse(await fs7.readFile(path8.join(path8.dirname(real), "..", "package.json"), "utf8"));
4075
+ const manifest = JSON.parse(await fs7.readFile(path9.join(path9.dirname(real), "..", "package.json"), "utf8"));
3991
4076
  if (typeof manifest?.version !== "string" || !manifest.version)
3992
4077
  return void 0;
3993
4078
  return admitProjectSuppliedTsserver(real, options?.sessionRoot ?? process.cwd(), projectSupplied || projectRoots.some((dir) => isUnderDir(real, dir)), options?.projectCodeAllowed);
@@ -4001,7 +4086,7 @@ async function findTsserverPath(root, allowInstall, options) {
4001
4086
  if (admittedAncestor)
4002
4087
  return admittedAncestor;
4003
4088
  }
4004
- const cwdCandidate = path8.join(process.cwd(), "node_modules", "typescript", "lib", "tsserver.js");
4089
+ const cwdCandidate = path9.join(process.cwd(), "node_modules", "typescript", "lib", "tsserver.js");
4005
4090
  try {
4006
4091
  await fs7.access(cwdCandidate);
4007
4092
  const admittedCwd = await admitCandidate(cwdCandidate, false);
@@ -4013,7 +4098,7 @@ async function findTsserverPath(root, allowInstall, options) {
4013
4098
  if (!tscPath)
4014
4099
  return void 0;
4015
4100
  for (const dir of typescriptDirsForTsc(tscPath)) {
4016
- const candidate = path8.join(dir, "lib", "tsserver.js");
4101
+ const candidate = path9.join(dir, "lib", "tsserver.js");
4017
4102
  try {
4018
4103
  const admitted = await admitCandidate(candidate, false);
4019
4104
  if (admitted)
@@ -4024,7 +4109,9 @@ async function findTsserverPath(root, allowInstall, options) {
4024
4109
  return void 0;
4025
4110
  };
4026
4111
  const installAllowed = canInstall(allowInstall);
4027
- const discoveredTsc = await absoluteCommandPath(await ensureTool("typescript", { allowInstall: installAllowed }));
4112
+ const discoveredTsc = await absoluteCommandPath((await lookupManagedTool("typescript", root, void 0, {
4113
+ allowInstall: installAllowed
4114
+ })).found);
4028
4115
  const discoveredTsserver = await tsserverForTsc(discoveredTsc);
4029
4116
  if (discoveredTsserver || !discoveredTsc || !installAllowed || classicTsRepairState().attempted) {
4030
4117
  return discoveredTsserver;
@@ -4035,10 +4122,10 @@ async function findTsserverPath(root, allowInstall, options) {
4035
4122
  return void 0;
4036
4123
  classicTsRepairState().attempted = true;
4037
4124
  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`);
4038
- const repairedTsc = await absoluteCommandPath(await ensureTool("typescript", {
4125
+ const repairedTsc = await absoluteCommandPath((await lookupManagedTool("typescript", root, void 0, {
4039
4126
  allowInstall: true,
4040
4127
  forceReinstall: true
4041
- }));
4128
+ })).found);
4042
4129
  return tsserverForTsc(repairedTsc);
4043
4130
  }
4044
4131
  function typeScriptMajor(version) {
@@ -4046,10 +4133,10 @@ function typeScriptMajor(version) {
4046
4133
  return /^\d+$/.test(majorText) ? Number(majorText) : Number.NaN;
4047
4134
  }
4048
4135
  async function findTypeScriptNativeAlias(nodeModulesDir) {
4049
- const aliasDir = path8.join(nodeModulesDir, "@typescript", "native");
4136
+ const aliasDir = path9.join(nodeModulesDir, "@typescript", "native");
4050
4137
  let manifest;
4051
4138
  try {
4052
- manifest = JSON.parse(await readFile(path8.join(aliasDir, "package.json"), "utf8"));
4139
+ manifest = JSON.parse(await readFile(path9.join(aliasDir, "package.json"), "utf8"));
4053
4140
  } catch {
4054
4141
  return void 0;
4055
4142
  }
@@ -4064,7 +4151,7 @@ async function findTypeScriptNativeAlias(nodeModulesDir) {
4064
4151
  const tsc = typeof bin === "object" && bin !== null ? bin.tsc : void 0;
4065
4152
  if (typeof tsc !== "string" || !tsc)
4066
4153
  return void 0;
4067
- const command = path8.resolve(aliasDir, tsc);
4154
+ const command = path9.resolve(aliasDir, tsc);
4068
4155
  try {
4069
4156
  if (!(await stat(command)).isFile())
4070
4157
  return void 0;
@@ -4078,9 +4165,9 @@ async function findNativeTypeScriptLsp(root) {
4078
4165
  for (const currentDir of walkUpDirs(root, { spelling: true })) {
4079
4166
  if (isAtOrAboveHomeDir(realpathOrResolve(currentDir), home))
4080
4167
  break;
4081
- const nodeModulesDir = path8.join(currentDir, "node_modules");
4082
- const typescriptDir = path8.join(nodeModulesDir, "typescript");
4083
- const packageJsonPath = path8.join(typescriptDir, "package.json");
4168
+ const nodeModulesDir = path9.join(currentDir, "node_modules");
4169
+ const typescriptDir = path9.join(nodeModulesDir, "typescript");
4170
+ const packageJsonPath = path9.join(typescriptDir, "package.json");
4084
4171
  let packageJsonText;
4085
4172
  try {
4086
4173
  packageJsonText = await readFile(packageJsonPath, "utf8");
@@ -4113,7 +4200,7 @@ async function findNativeTypeScriptLsp(root) {
4113
4200
  const alias = await findTypeScriptNativeAlias(nodeModulesDir);
4114
4201
  return alias && { ...alias, entry: "node-script", nodeModulesDir };
4115
4202
  }
4116
- const localTsc = path8.join(nodeModulesDir, ".bin", "tsc");
4203
+ const localTsc = path9.join(nodeModulesDir, ".bin", "tsc");
4117
4204
  const candidates = process.platform === "win32" ? [`${localTsc}.cmd`, `${localTsc}.exe`, localTsc] : [localTsc];
4118
4205
  for (const command of candidates) {
4119
4206
  try {
@@ -4187,14 +4274,14 @@ function recordEffectTsgoFallback(root, reason, failure) {
4187
4274
  async function findEffectTsgoLsp(nodeModulesDir) {
4188
4275
  let release;
4189
4276
  try {
4190
- const manifest = JSON.parse(await readFile(path8.join(nodeModulesDir, "@effect", "tsgo", "package.json"), "utf8"));
4277
+ const manifest = JSON.parse(await readFile(path9.join(nodeModulesDir, "@effect", "tsgo", "package.json"), "utf8"));
4191
4278
  release = typeof manifest === "object" && manifest !== null && "version" in manifest ? manifest.version : void 0;
4192
4279
  } catch {
4193
4280
  return void 0;
4194
4281
  }
4195
4282
  if (typeof release !== "string" || !release)
4196
4283
  return void 0;
4197
- const localBin = path8.join(nodeModulesDir, ".bin", "effect-tsgo");
4284
+ const localBin = path9.join(nodeModulesDir, ".bin", "effect-tsgo");
4198
4285
  const candidates = process.platform === "win32" ? [`${localBin}.cmd`, `${localBin}.exe`, localBin] : [localBin];
4199
4286
  for (const command of candidates) {
4200
4287
  try {
@@ -4208,32 +4295,52 @@ async function findEffectTsgoLsp(nodeModulesDir) {
4208
4295
  function dotnetToolCandidates(tool) {
4209
4296
  const home = os6.homedir();
4210
4297
  return [
4211
- path8.join(PI_LENS_BIN_DIR2, `${tool}.exe`),
4212
- path8.join(PI_LENS_BIN_DIR2, tool),
4213
- path8.join(home, ".dotnet", "tools", `${tool}.exe`),
4214
- path8.join(home, ".dotnet", "tools", tool),
4298
+ path9.join(PI_LENS_BIN_DIR2, `${tool}.exe`),
4299
+ path9.join(PI_LENS_BIN_DIR2, tool),
4300
+ path9.join(home, ".dotnet", "tools", `${tool}.exe`),
4301
+ path9.join(home, ".dotnet", "tools", tool),
4215
4302
  tool
4216
4303
  ].filter(Boolean);
4217
4304
  }
4218
4305
  function binExeVariants(dir, tool) {
4219
- const variants = process.platform === "win32" ? [path8.join(dir, `${tool}.exe`), path8.join(dir, tool)] : [path8.join(dir, tool)];
4306
+ const win32 = process.platform === "win32";
4307
+ const bare = path9.join(dir, tool);
4308
+ const variants = win32 ? [path9.join(dir, `${tool}.exe`), bare] : [bare];
4220
4309
  const admitted = [];
4221
4310
  for (const candidate of variants) {
4222
4311
  if (existsSync3(candidate) && isUntrustedProjectPath(candidate)) {
4223
4312
  recordProjectCommandRefusal(candidate);
4224
4313
  continue;
4225
4314
  }
4315
+ if (win32 && candidate === bare && isUntrustedProjectPath(bare)) {
4316
+ const sibling = pathextSibling(dir, tool);
4317
+ if (sibling)
4318
+ recordProjectCommandRefusal(sibling);
4319
+ continue;
4320
+ }
4226
4321
  admitted.push(candidate);
4227
4322
  }
4228
4323
  return admitted;
4229
4324
  }
4325
+ function pathextSibling(dir, tool) {
4326
+ const wanted = tool.toLowerCase();
4327
+ try {
4328
+ const name = readdirSync5(dir).find((entry) => {
4329
+ const lower = entry.toLowerCase();
4330
+ return lower === wanted || lower.startsWith(`${wanted}.`);
4331
+ });
4332
+ return name === void 0 ? void 0 : path9.join(dir, name);
4333
+ } catch {
4334
+ return void 0;
4335
+ }
4336
+ }
4230
4337
  function goBinCandidates(tool) {
4231
- const gopath = process.env.GOPATH?.split(path8.delimiter)[0] || path8.join(os6.homedir(), "go");
4232
- return [tool, ...binExeVariants(path8.join(gopath, "bin"), tool)];
4338
+ const gopath = process.env.GOPATH?.split(path9.delimiter)[0] || path9.join(os6.homedir(), "go");
4339
+ return [tool, ...binExeVariants(path9.join(gopath, "bin"), tool)];
4233
4340
  }
4234
4341
  function cargoBinCandidates(tool) {
4235
- const cargoHome = process.env.CARGO_HOME || path8.join(os6.homedir(), ".cargo");
4236
- return [tool, ...binExeVariants(path8.join(cargoHome, "bin"), tool)];
4342
+ const cargoHome = process.env.CARGO_HOME || path9.join(os6.homedir(), ".cargo");
4343
+ return [tool, ...binExeVariants(path9.join(cargoHome, "bin"), tool)];
4237
4344
  }
4238
4345
  async function tryGemInstall(gem) {
4239
4346
  const { join: join4 } = await import("node:path");
@@ -4255,7 +4362,7 @@ function DenoExcludeRoot(primary) {
4255
4362
  return async (file) => {
4256
4363
  const denoRoot = await denoDetector(file);
4257
4364
  if (denoRoot)
4258
- return void 0;
4365
+ return LSP_ROOT_DECLINED;
4259
4366
  return primary(file);
4260
4367
  };
4261
4368
  }
@@ -4291,31 +4398,31 @@ async function findExtensionBoundedRoot(file, extensionRootKey) {
4291
4398
  const identity = realpathOrResolve(file);
4292
4399
  const insideBoundary = isUnderDir(identity, extensionRootKey);
4293
4400
  const boundaryKey = insideBoundary ? normalizeEphemeralMapKey(realpathOrResolve(extensionRootKey)) : extensionRootKey;
4294
- const start = path8.dirname(insideBoundary ? identity : path8.resolve(file));
4401
+ const start = path9.dirname(insideBoundary ? identity : path9.resolve(file));
4295
4402
  const configMarkers = tsConfigMarkersForFile(file);
4296
4403
  for (const currentDir of walkUpDirs(start, { spelling: true })) {
4297
4404
  for (const pattern of configMarkers) {
4298
4405
  try {
4299
- await stat(path8.join(currentDir, pattern));
4406
+ await stat(path9.join(currentDir, pattern));
4300
4407
  return currentDir;
4301
4408
  } catch {
4302
4409
  }
4303
4410
  }
4304
4411
  for (const pattern of TS_TOOLING_MARKERS) {
4305
4412
  try {
4306
- await stat(path8.join(currentDir, pattern));
4413
+ await stat(path9.join(currentDir, pattern));
4307
4414
  return currentDir;
4308
4415
  } catch {
4309
4416
  }
4310
4417
  }
4311
- const currentKey = normalizeEphemeralMapKey(path8.resolve(currentDir));
4418
+ const currentKey = normalizeEphemeralMapKey(path9.resolve(currentDir));
4312
4419
  if (currentKey === boundaryKey)
4313
4420
  return void 0;
4314
4421
  }
4315
4422
  return void 0;
4316
4423
  }
4317
4424
  async function classifyAgentLevelMarker(extensionRootKey, file) {
4318
- const agentDir = path8.dirname(extensionRootKey);
4425
+ const agentDir = path9.dirname(extensionRootKey);
4319
4426
  if (!agentDir || agentDir === extensionRootKey)
4320
4427
  return void 0;
4321
4428
  const configMarkers = tsConfigMarkersForFile(file);
@@ -4325,7 +4432,7 @@ async function classifyAgentLevelMarker(extensionRootKey, file) {
4325
4432
  ...TS_TOOLING_MARKERS
4326
4433
  ]) {
4327
4434
  try {
4328
- await stat(path8.join(agentDir, pattern));
4435
+ await stat(path9.join(agentDir, pattern));
4329
4436
  return configMarkers.includes(pattern) ? "config" : "other";
4330
4437
  } catch {
4331
4438
  }
@@ -4335,12 +4442,12 @@ async function classifyAgentLevelMarker(extensionRootKey, file) {
4335
4442
  var TypeScriptRoot = withRootMarkers(DenoExcludeRoot(async (file) => {
4336
4443
  const extensionRootKey = piAgentExtensionsRootKey(file) ?? piAgentExtensionsRootKey(realpathOrResolve(file));
4337
4444
  if (extensionRootKey) {
4338
- const bounded2 = await findExtensionBoundedRoot(file, extensionRootKey);
4339
- if (bounded2)
4340
- return bounded2;
4445
+ const extensionRoot = await findExtensionBoundedRoot(file, extensionRootKey);
4446
+ if (extensionRoot)
4447
+ return extensionRoot;
4341
4448
  const agentMarker = await classifyAgentLevelMarker(extensionRootKey, file);
4342
4449
  if (agentMarker === "config") {
4343
- return realpathOrResolve(path8.dirname(extensionRootKey));
4450
+ return realpathOrResolve(path9.dirname(extensionRootKey));
4344
4451
  }
4345
4452
  if (agentMarker === "other") {
4346
4453
  return FileDirRoot(file);
@@ -4359,9 +4466,7 @@ async function launchClassicTypeScript(root, options) {
4359
4466
  ["node_modules", ".bin", "typescript-language-server"]
4360
4467
  ]);
4361
4468
  if (!lspPath) {
4362
- lspPath = await ensureTool("typescript-language-server", {
4363
- allowInstall: canInstall(options?.allowInstall)
4364
- });
4469
+ ({ found: lspPath } = await lookupManagedTool("typescript-language-server", root, void 0, { allowInstall: canInstall(options?.allowInstall) }));
4365
4470
  if (lspPath)
4366
4471
  source = "managed";
4367
4472
  if (!lspPath) {
@@ -4488,6 +4593,7 @@ var PythonServer = {
4488
4593
  const toolEnvironment = await getToolEnvironment();
4489
4594
  const env = augmentPythonEnvironment(toolEnvironment, pythonEnvironment);
4490
4595
  let source = "direct";
4596
+ const refusals = { refused: false, bareRefused: false };
4491
4597
  const projectPyright = await resolveAndLaunch({
4492
4598
  candidates: [
4493
4599
  ...pythonEnvironmentToolCandidates(pythonEnvironment, "pyright-langserver"),
@@ -4497,7 +4603,8 @@ var PythonServer = {
4497
4603
  ],
4498
4604
  args: ["--stdio"],
4499
4605
  cwd: root,
4500
- env
4606
+ env,
4607
+ refusals
4501
4608
  }, false);
4502
4609
  if (projectPyright) {
4503
4610
  return {
@@ -4510,7 +4617,8 @@ var PythonServer = {
4510
4617
  candidates: pythonEnvironmentToolCandidates(pythonEnvironment, "ty"),
4511
4618
  args: ["server"],
4512
4619
  cwd: root,
4513
- env
4620
+ env,
4621
+ refusals
4514
4622
  }, false);
4515
4623
  if (projectTy) {
4516
4624
  return { process: projectTy.process, source: projectTy.source };
@@ -4519,7 +4627,8 @@ var PythonServer = {
4519
4627
  candidates: ["pyright-langserver", "basedpyright-langserver"],
4520
4628
  args: ["--stdio"],
4521
4629
  cwd: root,
4522
- env
4630
+ env,
4631
+ refusals
4523
4632
  }, false);
4524
4633
  if (pathPyright) {
4525
4634
  return {
@@ -4532,24 +4641,23 @@ var PythonServer = {
4532
4641
  candidates: ["ty"],
4533
4642
  args: ["server"],
4534
4643
  cwd: root,
4535
- env
4644
+ env,
4645
+ refusals
4536
4646
  }, false);
4537
4647
  if (pathTy) {
4538
4648
  return { process: pathTy.process, source: pathTy.source };
4539
4649
  }
4540
- const pyrightPath = await ensureTool("pyright", {
4541
- allowInstall: canInstall(options?.allowInstall)
4542
- });
4650
+ const { found: pyrightPath } = await lookupManagedTool("pyright", root, refusals, { allowInstall: canInstall(options?.allowInstall) });
4543
4651
  if (!pyrightPath)
4544
4652
  return void 0;
4545
4653
  source = "managed";
4546
- const binDir = path8.dirname(pyrightPath);
4654
+ const binDir = path9.dirname(pyrightPath);
4547
4655
  const isWindows2 = process.platform === "win32";
4548
4656
  const managedCandidates = isWindows2 ? [
4549
- path8.join(binDir, "pyright-langserver.cmd"),
4550
- path8.join(binDir, "pyright-langserver"),
4657
+ path9.join(binDir, "pyright-langserver.cmd"),
4658
+ path9.join(binDir, "pyright-langserver"),
4551
4659
  "pyright-langserver"
4552
- ] : [path8.join(binDir, "pyright-langserver"), "pyright-langserver"];
4660
+ ] : [path9.join(binDir, "pyright-langserver"), "pyright-langserver"];
4553
4661
  const resolved = await resolveAndLaunch({ candidates: managedCandidates, args: ["--stdio"], cwd: root, env }, false);
4554
4662
  if (!resolved)
4555
4663
  return void 0;
@@ -4583,13 +4691,15 @@ var PythonJediServer = {
4583
4691
  const toolEnvironment = await getToolEnvironment();
4584
4692
  const env = augmentPythonEnvironment(toolEnvironment, pythonEnvironment);
4585
4693
  const initialization = pythonEnvironment ? { workspace: { environmentPath: pythonEnvironment.pythonPath } } : {};
4694
+ const refusals = { refused: false, bareRefused: false };
4586
4695
  if (pythonEnvironment) {
4587
4696
  try {
4588
4697
  const projectLaunched = await resolveAndLaunch({
4589
4698
  candidates: pythonEnvironmentToolCandidates(pythonEnvironment, "jedi-language-server"),
4590
4699
  args: [],
4591
4700
  cwd: root,
4592
- env
4701
+ env,
4702
+ refusals
4593
4703
  }, options?.allowInstall);
4594
4704
  if (projectLaunched)
4595
4705
  return { ...projectLaunched, initialization };
@@ -4607,7 +4717,8 @@ var PythonJediServer = {
4607
4717
  args: [],
4608
4718
  cwd: root,
4609
4719
  env: toolEnvironment,
4610
- managedToolId: "jedi-language-server"
4720
+ managedToolId: "jedi-language-server",
4721
+ refusals
4611
4722
  }, options?.allowInstall);
4612
4723
  if (!launched)
4613
4724
  return void 0;
@@ -4654,7 +4765,7 @@ function cargoWorkspaceDeclaresMember(workspaceContent, parentDir, childDir) {
4654
4765
  return readCargoWorkspaceMembers(workspaceContent).some(matches);
4655
4766
  }
4656
4767
  function sessionHoistCeiling(sessionCwd, file) {
4657
- return isSameOrWithin(path8.resolve(sessionCwd), path8.resolve(file)) ? path8.resolve(sessionCwd) : void 0;
4768
+ return isSameOrWithin(path9.resolve(sessionCwd), path9.resolve(file)) ? path9.resolve(sessionCwd) : void 0;
4658
4769
  }
4659
4770
  function RustWorkspaceRoot() {
4660
4771
  const crateRoot = createRootDetector(["Cargo.toml", "Cargo.lock"]);
@@ -4664,14 +4775,14 @@ function RustWorkspaceRoot() {
4664
4775
  return void 0;
4665
4776
  const sessionCwd = process.cwd();
4666
4777
  const stop = sessionHoistCeiling(sessionCwd, file);
4667
- const fsRoot = path8.parse(root).root;
4778
+ const fsRoot = path9.parse(root).root;
4668
4779
  for (const current of walkUpDirs(root, { spelling: true })) {
4669
4780
  if (stop !== void 0 && current === stop)
4670
4781
  break;
4671
- const parent = path8.dirname(current);
4782
+ const parent = path9.dirname(current);
4672
4783
  if (parent === current || parent === fsRoot)
4673
4784
  break;
4674
- const parentCargoPath = path8.join(parent, "Cargo.toml");
4785
+ const parentCargoPath = path9.join(parent, "Cargo.toml");
4675
4786
  const parentCargoContent = await readTextFileOrUndefined(parentCargoPath);
4676
4787
  if (parentCargoContent !== void 0 && hasCargoWorkspaceTable(parentCargoContent)) {
4677
4788
  if (cargoWorkspaceDeclaresMember(parentCargoContent, parent, root)) {
@@ -4698,9 +4809,9 @@ async function declaresMavenModule(parentDir, parentPomPath, childDir) {
4698
4809
  const modulesBlock = content.match(/<modules>([\s\S]*?)<\/modules>/);
4699
4810
  if (!modulesBlock)
4700
4811
  return false;
4701
- const resolvedChild = path8.resolve(childDir);
4812
+ const resolvedChild = path9.resolve(childDir);
4702
4813
  for (const match of modulesBlock[1].matchAll(/<module>\s*([^<]+?)\s*<\/module>/g)) {
4703
- if (pathsEqual(path8.resolve(parentDir, match[1]), resolvedChild))
4814
+ if (pathsEqual(path9.resolve(parentDir, match[1]), resolvedChild))
4704
4815
  return true;
4705
4816
  }
4706
4817
  return false;
@@ -4723,16 +4834,16 @@ function JavaWorkspaceRoot() {
4723
4834
  const sessionCwd = process.cwd();
4724
4835
  const stop = sessionHoistCeiling(sessionCwd, file);
4725
4836
  let lastHop = root;
4726
- const fsRoot = path8.parse(root).root;
4837
+ const fsRoot = path9.parse(root).root;
4727
4838
  for (const current of walkUpDirs(root, { spelling: true })) {
4728
4839
  if (stop !== void 0 && current === stop)
4729
4840
  break;
4730
- const parent = path8.dirname(current);
4841
+ const parent = path9.dirname(current);
4731
4842
  if (parent === current || parent === fsRoot)
4732
4843
  break;
4733
4844
  if (!await markerExists(parent, "pom.xml"))
4734
4845
  continue;
4735
- const parentPom = path8.join(parent, "pom.xml");
4846
+ const parentPom = path9.join(parent, "pom.xml");
4736
4847
  if (!await declaresMavenModule(parent, parentPom, lastHop))
4737
4848
  break;
4738
4849
  lastHop = parent;
@@ -4742,7 +4853,7 @@ function JavaWorkspaceRoot() {
4742
4853
  }
4743
4854
  var RustServer = {
4744
4855
  id: "rust",
4745
- idleEviction: "unmeasured",
4856
+ idleEviction: "resident",
4746
4857
  role: "language",
4747
4858
  // Measured (#3750): rust-analyzer answers an empty result for a detached file.
4748
4859
  requiresProjectRoot: true,
@@ -4835,17 +4946,17 @@ var PHPServer = {
4835
4946
  return {
4836
4947
  ...result,
4837
4948
  initialization: {
4838
- storagePath: path8.join(getGlobalPiLensDir(), "intelephense")
4949
+ storagePath: path9.join(getGlobalPiLensDir(), "intelephense")
4839
4950
  }
4840
4951
  };
4841
4952
  }
4842
4953
  };
4843
4954
  function buildPsesArgs(bundleDir) {
4844
- const script = path8.join(bundleDir, "PowerShellEditorServices", "Start-EditorServices.ps1");
4845
- const sessionDir = path8.join(getGlobalPiLensDir(), "pses", `${process.pid}-${Date.now()}`);
4955
+ const script = path9.join(bundleDir, "PowerShellEditorServices", "Start-EditorServices.ps1");
4956
+ const sessionDir = path9.join(getGlobalPiLensDir(), "pses", `${process.pid}-${Date.now()}`);
4846
4957
  mkdirSync2(sessionDir, { recursive: true });
4847
- const logPath = path8.join(sessionDir, "pses.log");
4848
- const sessionDetailsPath = path8.join(sessionDir, "session.json");
4958
+ const logPath = path9.join(sessionDir, "pses.log");
4959
+ const sessionDetailsPath = path9.join(sessionDir, "session.json");
4849
4960
  return [
4850
4961
  "-NoLogo",
4851
4962
  "-NoProfile",
@@ -4876,7 +4987,7 @@ function buildPsesArgs(bundleDir) {
4876
4987
  }
4877
4988
  var PowerShellServer = {
4878
4989
  id: "powershell",
4879
- idleEviction: "unmeasured",
4990
+ idleEviction: "resident",
4880
4991
  role: "language",
4881
4992
  name: "PowerShell Editor Services",
4882
4993
  executesProjectCode: true,
@@ -4969,11 +5080,17 @@ var JavaServer = createInteractiveServer({
4969
5080
  language: "java",
4970
5081
  command: () => process.env.JDTLS_PATH || "jdtls",
4971
5082
  args: (root) => createLombokJdtlsArgs(root),
4972
- runtime: "java"
5083
+ runtime: "java",
5084
+ // #5675: jdtls 1.63.0 (Temurin 25.0.5+8) answers a didChange that carries
5085
+ // the bytes it already holds: the cascade's re-send of an importer at
5086
+ // 19.331 was published for the new version at 19.847 (+516 ms, docVersion 1)
5087
+ // and republished the other importer at 19.855, 3/3 on the real smoke row
5088
+ // (see LspResendRecheck; transcripts in the PR body).
5089
+ resendRecheck: "rechecks"
4973
5090
  });
4974
5091
  var KotlinServer = {
4975
5092
  id: "kotlin",
4976
- idleEviction: "unmeasured",
5093
+ idleEviction: "resident",
4977
5094
  role: "language",
4978
5095
  name: "Kotlin Language Server",
4979
5096
  executesProjectCode: true,
@@ -5018,7 +5135,7 @@ var GroovyServer = {
5018
5135
  if (viaLauncher)
5019
5136
  return viaLauncher;
5020
5137
  const jar = process.env[GROOVY_LANGUAGE_SERVER_JAR_ENV];
5021
- const resolvedJar = jar ? path8.resolve(jar) : void 0;
5138
+ const resolvedJar = jar ? path9.resolve(jar) : void 0;
5022
5139
  const jarIsFile = resolvedJar ? statSync4(resolvedJar, { throwIfNoEntry: false })?.isFile() ?? false : false;
5023
5140
  if (resolvedJar && jarIsFile) {
5024
5141
  try {
@@ -5156,7 +5273,7 @@ var ElixirServer = createInteractiveServer({
5156
5273
  });
5157
5274
  var ElixirExpertServer = {
5158
5275
  id: "expert",
5159
- idleEviction: "unmeasured",
5276
+ idleEviction: "resident",
5160
5277
  role: "language",
5161
5278
  name: "Expert",
5162
5279
  executesProjectCode: true,
@@ -5558,8 +5675,8 @@ var VueServer = {
5558
5675
  initializeTimeoutMs: 3e4,
5559
5676
  async spawn(root, options) {
5560
5677
  const tsserverPath = await findTsserverPath(root, options?.allowInstall, options);
5561
- const hasPackageJson = existsSync3(path8.join(root, "package.json"));
5562
- const hasNodeModules = existsSync3(path8.join(root, "node_modules"));
5678
+ const hasPackageJson = existsSync3(path9.join(root, "package.json"));
5679
+ const hasNodeModules = existsSync3(path9.join(root, "node_modules"));
5563
5680
  if (hasPackageJson && !hasNodeModules) {
5564
5681
  logSessionStart(`lsp vue: node_modules missing in ${root} \u2014 Vue navigation may be limited. Run: npm install (or pnpm/yarn install) in this project.`);
5565
5682
  }
@@ -5574,14 +5691,14 @@ var VueServer = {
5574
5691
  return {
5575
5692
  process: proc.process,
5576
5693
  source: proc.source,
5577
- initialization: tsserverPath ? { typescript: { tsdk: path8.dirname(tsserverPath) } } : void 0
5694
+ initialization: tsserverPath ? { typescript: { tsdk: path9.dirname(tsserverPath) } } : void 0
5578
5695
  };
5579
5696
  }
5580
5697
  };
5581
5698
  var SvelteServer = {
5582
5699
  id: "svelte",
5583
5700
  executesProjectCode: true,
5584
- idleEviction: "unmeasured",
5701
+ idleEviction: "resident",
5585
5702
  role: "language",
5586
5703
  name: "Svelte Language Server",
5587
5704
  extensions: [".svelte"],
@@ -5616,7 +5733,7 @@ var SvelteServer = {
5616
5733
  return {
5617
5734
  process: proc.process,
5618
5735
  source: proc.source,
5619
- initialization: tsserverPath ? { typescript: { tsdk: path8.dirname(tsserverPath) } } : void 0
5736
+ initialization: tsserverPath ? { typescript: { tsdk: path9.dirname(tsserverPath) } } : void 0
5620
5737
  };
5621
5738
  }
5622
5739
  };
@@ -5941,7 +6058,7 @@ function getServerById(id) {
5941
6058
  }
5942
6059
 
5943
6060
  // dist/clients/lsp/session-roots.js
5944
- import path9 from "node:path";
6061
+ import path10 from "node:path";
5945
6062
  var SESSION_ROOT_CAP = 128;
5946
6063
  var sessionRoots = new BoundedFifoMap(SESSION_ROOT_CAP);
5947
6064
  function noteEvictedRoots(evicted) {
@@ -5956,16 +6073,16 @@ function noteEvictedRoots(evicted) {
5956
6073
  return roots;
5957
6074
  }
5958
6075
  function registerSessionRoot(cwd) {
5959
- const root = path9.resolve(cwd);
6076
+ const root = path10.resolve(cwd);
5960
6077
  if (sessionRoots.has(root))
5961
6078
  return [];
5962
6079
  return noteEvictedRoots(sessionRoots.set(root, void 0));
5963
6080
  }
5964
6081
  function setSessionRootConfig(cwd, config) {
5965
- return noteEvictedRoots(sessionRoots.set(path9.resolve(cwd), config));
6082
+ return noteEvictedRoots(sessionRoots.set(path10.resolve(cwd), config));
5966
6083
  }
5967
6084
  function sessionRootConfigForFile(filePath) {
5968
- const resolvedFilePath = path9.resolve(filePath);
6085
+ const resolvedFilePath = path10.resolve(filePath);
5969
6086
  let bestMatch;
5970
6087
  for (const [root, config] of sessionRoots) {
5971
6088
  if (config === void 0)
@@ -5992,16 +6109,16 @@ function disabledPrimaries(filePath) {
5992
6109
  };
5993
6110
  }
5994
6111
  function isSessionRootRegistered(cwd) {
5995
- return sessionRoots.has(path9.resolve(cwd));
6112
+ return sessionRoots.has(path10.resolve(cwd));
5996
6113
  }
5997
6114
  function shouldInitializeSessionRoot(cwd, readyRoots) {
5998
- const normalized = path9.resolve(cwd);
6115
+ const normalized = path10.resolve(cwd);
5999
6116
  return !readyRoots.has(normalized) || !isSessionRootRegistered(normalized);
6000
6117
  }
6001
6118
  function isOutsideAllSessionRoots(filePath) {
6002
6119
  if (sessionRoots.size === 0)
6003
6120
  return false;
6004
- const resolved = path9.resolve(filePath);
6121
+ const resolved = path10.resolve(filePath);
6005
6122
  for (const root of sessionRoots.keys()) {
6006
6123
  if (isSameOrWithin(root, resolved))
6007
6124
  return false;
@@ -6013,6 +6130,8 @@ function getSessionRootsForTelemetry(limit = 4) {
6013
6130
  }
6014
6131
 
6015
6132
  export {
6133
+ findLocalOpengrepConfig,
6134
+ resolveOpengrepConfig,
6016
6135
  findLocalTyposConfig,
6017
6136
  getAstGrepRuleSources,
6018
6137
  getAstGrepRuleFingerprint,