oh-my-opencode 5.1.82 → 5.1.84

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 (150) hide show
  1. package/dist/cli/cli-program.d.ts +3 -0
  2. package/dist/cli/index.js +202 -193
  3. package/dist/cli-node/index.js +202 -193
  4. package/dist/index.js +28 -22
  5. package/dist/skills/browser/SKILL.md +97 -91
  6. package/dist/skills/browser/references/commands.md +88 -26
  7. package/dist/skills/browser/references/desktop.md +21 -0
  8. package/dist/skills/browser/references/install.md +18 -0
  9. package/dist/skills/browser/references/owned-engine/README.md +5 -2
  10. package/dist/skills/browser/references/owned-engine/frames-and-humans.md +7 -2
  11. package/dist/skills/browser/references/owned-engine/network.md +4 -3
  12. package/dist/skills/browser/references/recipes/1password.md +4 -2
  13. package/dist/skills/browser/runtime/omowright/index.js +7 -7
  14. package/dist/skills/browser/runtime/omowright/manifest.json +4 -4
  15. package/dist/skills/debugging/references/tools/browser-qa.md +1 -1
  16. package/dist/skills/programming/SKILL.md +51 -320
  17. package/dist/skills/programming/references/go/README.md +1 -0
  18. package/dist/skills/programming/references/python/README.md +21 -3
  19. package/dist/skills/programming/references/python/error-handling.md +14 -0
  20. package/dist/skills/programming/references/rust/README.md +5 -1
  21. package/dist/skills/programming/references/typescript/README.md +9 -3
  22. package/dist/skills/programming/references/typescript/error-handling.md +18 -0
  23. package/dist/skills/ultimate-browsing/SKILL.md +1 -1
  24. package/dist/skills/visual-qa/references/browser-setup.md +5 -5
  25. package/dist/tui.js +16 -16
  26. package/package.json +14 -14
  27. package/packages/lsp-core/src/lsp/client-key.ts +14 -0
  28. package/packages/lsp-core/src/lsp/client-startup.ts +139 -0
  29. package/packages/lsp-core/src/lsp/client-wrapper.ts +4 -4
  30. package/packages/lsp-core/src/lsp/config-loader.ts +15 -0
  31. package/packages/lsp-core/src/lsp/directory-diagnostics-group-scan.test.ts +388 -0
  32. package/packages/lsp-core/src/lsp/directory-diagnostics-mixed-typescript.test.ts +124 -0
  33. package/packages/lsp-core/src/lsp/directory-diagnostics.test.ts +4 -4
  34. package/packages/lsp-core/src/lsp/directory-diagnostics.ts +38 -41
  35. package/packages/lsp-core/src/lsp/directory-group-scan.ts +124 -0
  36. package/packages/lsp-core/src/lsp/directory-server-groups.ts +84 -0
  37. package/packages/lsp-core/src/lsp/manager-acquisition.test.ts +115 -0
  38. package/packages/lsp-core/src/lsp/manager-lifecycle.test.ts +9 -9
  39. package/packages/lsp-core/src/lsp/manager-max-clients.test.ts +41 -16
  40. package/packages/lsp-core/src/lsp/manager-reaping.test.ts +119 -0
  41. package/packages/lsp-core/src/lsp/manager-test-support.ts +108 -0
  42. package/packages/lsp-core/src/lsp/manager.ts +80 -249
  43. package/packages/lsp-core/src/lsp/native-typescript.ts +88 -0
  44. package/packages/lsp-core/src/lsp/server-installation.ts +15 -7
  45. package/packages/lsp-core/src/lsp/server-resolution-typescript-native.test.ts +327 -0
  46. package/packages/lsp-core/src/lsp/server-resolution.ts +28 -2
  47. package/packages/lsp-core/src/lsp/timer-provider.ts +17 -0
  48. package/packages/lsp-core/src/lsp/typescript-project-test-support.ts +52 -0
  49. package/packages/lsp-daemon/dist/cli.js +486 -310
  50. package/packages/lsp-daemon/dist/client.js +472 -296
  51. package/packages/lsp-daemon/dist/index.js +476 -300
  52. package/packages/lsp-tools-mcp/dist/cli.js +467 -291
  53. package/packages/lsp-tools-mcp/dist/lsp/manager.js +160 -193
  54. package/packages/lsp-tools-mcp/dist/mcp.js +467 -291
  55. package/packages/lsp-tools-mcp/dist/tools.js +467 -291
  56. package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
  57. package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +2 -2
  58. package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
  59. package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
  60. package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
  61. package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
  62. package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
  63. package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
  64. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
  65. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
  66. package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +3 -3
  67. package/packages/omo-codex/plugin/components/lsp/dist/cli.js +478 -313
  68. package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
  69. package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
  70. package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
  71. package/packages/omo-codex/plugin/components/rules/package.json +1 -1
  72. package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
  73. package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
  74. package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +8711 -172
  75. package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +8660 -121
  76. package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
  77. package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
  78. package/packages/omo-codex/plugin/components/telemetry/src/posthog.ts +5 -0
  79. package/packages/omo-codex/plugin/components/telemetry/tsconfig.json +2 -2
  80. package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
  81. package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
  82. package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
  83. package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
  84. package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
  85. package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
  86. package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
  87. package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
  88. package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
  89. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
  90. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
  91. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
  92. package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
  93. package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
  94. package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
  95. package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
  96. package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
  97. package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
  98. package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
  99. package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
  100. package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
  101. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
  102. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
  103. package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
  104. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
  105. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
  106. package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
  107. package/packages/omo-codex/plugin/package-lock.json +12 -12
  108. package/packages/omo-codex/plugin/package.json +1 -1
  109. package/packages/omo-codex/plugin/shared/src/config-loader.ts +15 -1
  110. package/packages/omo-codex/plugin/skills/browser/SKILL.md +97 -91
  111. package/packages/omo-codex/plugin/skills/browser/references/commands.md +88 -26
  112. package/packages/omo-codex/plugin/skills/browser/references/desktop.md +21 -0
  113. package/packages/omo-codex/plugin/skills/browser/references/install.md +18 -0
  114. package/packages/omo-codex/plugin/skills/browser/references/owned-engine/README.md +5 -2
  115. package/packages/omo-codex/plugin/skills/browser/references/owned-engine/frames-and-humans.md +7 -2
  116. package/packages/omo-codex/plugin/skills/browser/references/owned-engine/network.md +4 -3
  117. package/packages/omo-codex/plugin/skills/browser/references/recipes/1password.md +4 -2
  118. package/packages/omo-codex/plugin/skills/browser/runtime/omowright/index.js +7 -7
  119. package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +4 -4
  120. package/packages/omo-codex/plugin/skills/debugging/references/tools/browser-qa.md +1 -1
  121. package/packages/omo-codex/plugin/skills/programming/SKILL.md +51 -320
  122. package/packages/omo-codex/plugin/skills/programming/references/go/README.md +1 -0
  123. package/packages/omo-codex/plugin/skills/programming/references/python/README.md +21 -3
  124. package/packages/omo-codex/plugin/skills/programming/references/python/error-handling.md +14 -0
  125. package/packages/omo-codex/plugin/skills/programming/references/rust/README.md +5 -1
  126. package/packages/omo-codex/plugin/skills/programming/references/typescript/README.md +9 -3
  127. package/packages/omo-codex/plugin/skills/programming/references/typescript/error-handling.md +18 -0
  128. package/packages/omo-codex/plugin/skills/ultimate-browsing/SKILL.md +1 -1
  129. package/packages/omo-codex/plugin/skills/visual-qa/references/browser-setup.md +5 -5
  130. package/packages/omo-codex/scripts/install-dist/install-local.mjs +21189 -20653
  131. package/packages/shared-skills/skills/browser/SKILL.md +97 -91
  132. package/packages/shared-skills/skills/browser/references/commands.md +88 -26
  133. package/packages/shared-skills/skills/browser/references/desktop.md +21 -0
  134. package/packages/shared-skills/skills/browser/references/install.md +18 -0
  135. package/packages/shared-skills/skills/browser/references/owned-engine/README.md +5 -2
  136. package/packages/shared-skills/skills/browser/references/owned-engine/frames-and-humans.md +7 -2
  137. package/packages/shared-skills/skills/browser/references/owned-engine/network.md +4 -3
  138. package/packages/shared-skills/skills/browser/references/recipes/1password.md +4 -2
  139. package/packages/shared-skills/skills/browser/runtime/omowright/index.js +7 -7
  140. package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +4 -4
  141. package/packages/shared-skills/skills/debugging/references/tools/browser-qa.md +1 -1
  142. package/packages/shared-skills/skills/programming/SKILL.md +51 -320
  143. package/packages/shared-skills/skills/programming/references/go/README.md +1 -0
  144. package/packages/shared-skills/skills/programming/references/python/README.md +21 -3
  145. package/packages/shared-skills/skills/programming/references/python/error-handling.md +14 -0
  146. package/packages/shared-skills/skills/programming/references/rust/README.md +5 -1
  147. package/packages/shared-skills/skills/programming/references/typescript/README.md +9 -3
  148. package/packages/shared-skills/skills/programming/references/typescript/error-handling.md +18 -0
  149. package/packages/shared-skills/skills/ultimate-browsing/SKILL.md +1 -1
  150. package/packages/shared-skills/skills/visual-qa/references/browser-setup.md +5 -5
@@ -8,12 +8,12 @@ import { argv, execPath as execPath2, stderr } from "node:process";
8
8
  import { stdin as processStdin } from "node:process";
9
9
 
10
10
  // src/codex-hook.ts
11
- import { readFileSync as readFileSync10, realpathSync as realpathSync8 } from "node:fs";
11
+ import { readFileSync as readFileSync10, realpathSync as realpathSync9 } from "node:fs";
12
12
  import { homedir as homedir4 } from "node:os";
13
- import { join as join12, resolve as resolve13 } from "node:path";
13
+ import { join as join13, resolve as resolve14 } from "node:path";
14
14
 
15
15
  // ../../../../lsp-daemon/dist/client.js
16
- import { statSync as statSync6 } from "node:fs";
16
+ import { statSync as statSync7 } from "node:fs";
17
17
  import { isAbsolute as isAbsolute6 } from "node:path";
18
18
  import { connect } from "node:net";
19
19
  import { setTimeout as delay } from "node:timers/promises";
@@ -45,8 +45,8 @@ import * as path from "node:path";
45
45
  import { fileURLToPath } from "node:url";
46
46
  import { statSync as statSync2 } from "node:fs";
47
47
  import { isAbsolute as isAbsolute2 } from "node:path";
48
- import { existsSync as existsSync11, realpathSync as realpathSync6, statSync as statSync4 } from "node:fs";
49
- import { basename as basename3, dirname as dirname10, join as join5, resolve as resolve8 } from "node:path";
48
+ import { existsSync as existsSync12, realpathSync as realpathSync7, statSync as statSync5 } from "node:fs";
49
+ import { basename as basename3, dirname as dirname11, join as join6, resolve as resolve9 } from "node:path";
50
50
  import { basename as basename2, extname } from "node:path";
51
51
  import { resolve as resolve6 } from "node:path";
52
52
  import { pathToFileURL as pathToFileURL3 } from "node:url";
@@ -71,18 +71,21 @@ import { existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as rea
71
71
  import { dirname as dirname8 } from "node:path";
72
72
  import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
73
73
  import { closeSync as closeSync3, openSync as openSync3, readSync, realpathSync as realpathSync5 } from "node:fs";
74
+ import { existsSync as existsSync11, realpathSync as realpathSync6, statSync as statSync4 } from "node:fs";
75
+ import { dirname as dirname10, join as join5, resolve as resolve8 } from "node:path";
74
76
  import { existsSync as existsSync10 } from "node:fs";
75
77
  import { delimiter as delimiter3, dirname as dirname9, isAbsolute as isAbsolute5, join as join4, resolve as resolve7 } from "node:path";
76
- import { existsSync as existsSync12, lstatSync as lstatSync5, readdirSync as readdirSync3 } from "node:fs";
77
- import { join as join6, resolve as resolve9 } from "node:path";
78
+ import { existsSync as existsSync13, lstatSync as lstatSync5, readdirSync as readdirSync3 } from "node:fs";
79
+ import { join as join7, resolve as resolve10 } from "node:path";
80
+ import { dirname as dirname12 } from "node:path";
78
81
  import { fileURLToPath as fileURLToPath3 } from "node:url";
79
82
  import { lstatSync as lstatSync6, readdirSync as readdirSync4 } from "node:fs";
80
- import { join as join7 } from "node:path";
81
- import { resolve as resolve10 } from "node:path";
83
+ import { join as join8 } from "node:path";
84
+ import { resolve as resolve11 } from "node:path";
82
85
  import { spawn as spawn3 } from "node:child_process";
83
- import { existsSync as existsSync13, mkdtempSync, readFileSync as readFileSync6, rmSync as rmSync2, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
86
+ import { existsSync as existsSync14, mkdtempSync, readFileSync as readFileSync6, rmSync as rmSync2, statSync as statSync6, writeFileSync as writeFileSync3 } from "node:fs";
84
87
  import { homedir as homedir3, tmpdir as tmpdir2 } from "node:os";
85
- import { dirname as dirname11, join as join8, resolve as resolve11 } from "node:path";
88
+ import { dirname as dirname13, join as join9, resolve as resolve12 } from "node:path";
86
89
  import { readFileSync as readFileSync7, renameSync as renameSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync4 } from "node:fs";
87
90
 
88
91
  class LspRequestContextParseError extends Error {
@@ -794,6 +797,24 @@ var realTimerProvider = {
794
797
  setTimeout: (callback, delayMs) => setTimeout(callback, delayMs),
795
798
  clearTimeout: (handle) => clearTimeout(handle)
796
799
  };
800
+ function repeatEvery(timers, intervalMs, tick) {
801
+ let handle = null;
802
+ const arm = () => {
803
+ handle = timers.setTimeout(() => {
804
+ tick();
805
+ if (handle !== null)
806
+ arm();
807
+ }, intervalMs);
808
+ if (typeof handle.unref === "function")
809
+ handle.unref();
810
+ };
811
+ arm();
812
+ return () => {
813
+ if (handle !== null)
814
+ timers.clearTimeout(handle);
815
+ handle = null;
816
+ };
817
+ }
797
818
  var DEFAULT_MAX_REFERENCES = 200;
798
819
  var DEFAULT_MAX_SYMBOLS = 200;
799
820
  var DEFAULT_MAX_DIAGNOSTICS = 200;
@@ -3395,27 +3416,52 @@ function abortError3(signal) {
3395
3416
  error.name = "AbortError";
3396
3417
  return error;
3397
3418
  }
3398
- function installProcessSignalCleanup(cleanup) {
3399
- const signals = process.platform === "win32" ? ["SIGINT", "SIGTERM", "SIGBREAK"] : ["SIGINT", "SIGTERM"];
3400
- const handler = () => {
3401
- cleanup().catch((error) => {
3402
- reportBestEffortCleanupError("signal cleanup", error);
3403
- });
3404
- };
3405
- for (const signal of signals) {
3406
- process.on(signal, handler);
3419
+ function lspClientKey(root, server) {
3420
+ return JSON.stringify([root, server.id, server.command]);
3421
+ }
3422
+
3423
+ class ClientStartups {
3424
+ constructor(now, discard) {
3425
+ this.now = now;
3426
+ this.discard = discard;
3427
+ }
3428
+ begin(request) {
3429
+ const { client } = request;
3430
+ const startedAt = this.now();
3431
+ const initPromise = (async () => {
3432
+ await client.start();
3433
+ await client.initialize();
3434
+ })();
3435
+ const managed = {
3436
+ ...request,
3437
+ refCount: 0,
3438
+ pendingWaiters: 0,
3439
+ lastUsedAt: startedAt,
3440
+ initPromise,
3441
+ isInitializing: true,
3442
+ initializingSince: startedAt
3443
+ };
3444
+ initPromise.then(() => {
3445
+ managed.isInitializing = false;
3446
+ managed.initializingSince = null;
3447
+ managed.initPromise = null;
3448
+ managed.lastUsedAt = this.now();
3449
+ }, () => this.discard(managed));
3450
+ return managed;
3407
3451
  }
3408
- return () => {
3409
- for (const signal of signals) {
3410
- process.removeListener(signal, handler);
3452
+ async wait(managed, initPromise, signal) {
3453
+ managed.pendingWaiters++;
3454
+ try {
3455
+ await awaitWithSignal2(initPromise, signal);
3456
+ } catch (error) {
3457
+ this.detach(managed);
3458
+ throw error;
3411
3459
  }
3412
- };
3413
- }
3414
- async function stopClientBestEffort(client) {
3415
- try {
3416
- await client.stop();
3417
- } catch (error) {
3418
- reportBestEffortCleanupError("client stop", error);
3460
+ }
3461
+ detach(managed) {
3462
+ managed.pendingWaiters--;
3463
+ if (managed.pendingWaiters === 0 && managed.refCount === 0 && managed.heldByWaiters)
3464
+ this.discard(managed);
3419
3465
  }
3420
3466
  }
3421
3467
  function awaitWithSignal2(promise, signal) {
@@ -3449,37 +3495,47 @@ function awaitWithSignal2(promise, signal) {
3449
3495
  });
3450
3496
  });
3451
3497
  }
3498
+ function installProcessSignalCleanup(cleanup) {
3499
+ const signals = process.platform === "win32" ? ["SIGINT", "SIGTERM", "SIGBREAK"] : ["SIGINT", "SIGTERM"];
3500
+ const handler = () => {
3501
+ cleanup().catch((error) => {
3502
+ reportBestEffortCleanupError("signal cleanup", error);
3503
+ });
3504
+ };
3505
+ for (const signal of signals) {
3506
+ process.on(signal, handler);
3507
+ }
3508
+ return () => {
3509
+ for (const signal of signals) {
3510
+ process.removeListener(signal, handler);
3511
+ }
3512
+ };
3513
+ }
3514
+ async function stopClientBestEffort(client) {
3515
+ try {
3516
+ await client.stop();
3517
+ } catch (error) {
3518
+ reportBestEffortCleanupError("client stop", error);
3519
+ }
3520
+ }
3452
3521
 
3453
3522
  class LspManager {
3454
3523
  constructor(options = {}) {
3455
3524
  this.clients = new Map;
3456
3525
  this.pendingStops = new Map;
3457
3526
  this.respawnBudgets = new Map;
3458
- this.reaperHandle = null;
3459
3527
  this.signalDisposer = null;
3460
3528
  this.disposed = false;
3461
3529
  this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS;
3462
3530
  this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS;
3463
3531
  this.maxResidentClients = options.maxResidentClients ?? MAX_RESIDENT_CLIENTS;
3464
- this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
3465
3532
  this.clientFactory = options.clientFactory ?? ((root, server) => new LspClient(root, server));
3466
3533
  this.now = options.now ?? (() => Date.now());
3467
- this.startReaper();
3534
+ this.startups = new ClientStartups(this.now, (managed) => this.discard(managed));
3535
+ const reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
3536
+ this.stopReaper = repeatEvery(options.timers ?? realTimerProvider, reaperIntervalMs, () => this.reapStale());
3468
3537
  this.signalDisposer = installProcessSignalCleanup(() => this.stopAll());
3469
3538
  }
3470
- startReaper() {
3471
- if (this.reaperHandle)
3472
- return;
3473
- this.reaperHandle = setInterval(() => {
3474
- this.reapStale();
3475
- }, this.reaperIntervalMs);
3476
- if (typeof this.reaperHandle.unref === "function") {
3477
- this.reaperHandle.unref();
3478
- }
3479
- }
3480
- getKey(root, serverId) {
3481
- return `${root}::${serverId}`;
3482
- }
3483
3539
  tombstoneStop(key, client) {
3484
3540
  const stop = stopClientBestEffort(client);
3485
3541
  this.pendingStops.set(key, stop);
@@ -3515,18 +3571,15 @@ class LspManager {
3515
3571
  budget.deadGenerations = 0;
3516
3572
  budget.exhaustedAt = null;
3517
3573
  }
3574
+ startupExpired(managed, t) {
3575
+ return managed.isInitializing && managed.initializingSince !== null && t - managed.initializingSince > this.initTimeoutMs;
3576
+ }
3518
3577
  reapStale() {
3519
3578
  const t = this.now();
3520
- for (const [key, managed] of this.clients) {
3521
- if (managed.isInitializing && managed.initializingSince !== null && t - managed.initializingSince > this.initTimeoutMs) {
3522
- this.clients.delete(key);
3523
- this.tombstoneStop(key, managed.client);
3524
- continue;
3525
- }
3526
- if (!managed.isInitializing && managed.refCount === 0 && managed.pendingWaiters === 0 && t - managed.lastUsedAt > this.idleTimeoutMs) {
3527
- this.clients.delete(key);
3528
- this.tombstoneStop(key, managed.client);
3529
- }
3579
+ for (const managed of [...this.clients.values()]) {
3580
+ const idle = !managed.isInitializing && managed.refCount === 0 && managed.pendingWaiters === 0 && t - managed.lastUsedAt > this.idleTimeoutMs;
3581
+ if (idle || this.startupExpired(managed, t))
3582
+ this.discard(managed);
3530
3583
  }
3531
3584
  }
3532
3585
  evictForAdmission() {
@@ -3534,152 +3587,96 @@ class LspManager {
3534
3587
  const victim = this.leastRecentlyUsedIdleClient();
3535
3588
  if (!victim)
3536
3589
  return;
3537
- this.clients.delete(victim.key);
3538
- this.tombstoneStop(victim.key, victim.managed.client);
3590
+ this.discard(victim);
3539
3591
  }
3540
3592
  }
3541
3593
  leastRecentlyUsedIdleClient() {
3542
3594
  let candidate = null;
3543
- for (const [key, managed] of this.clients) {
3595
+ for (const managed of this.clients.values()) {
3544
3596
  if (managed.refCount > 0 || managed.pendingWaiters > 0 || managed.isInitializing)
3545
3597
  continue;
3546
- if (candidate === null || managed.lastUsedAt < candidate.managed.lastUsedAt) {
3547
- candidate = { key, managed };
3548
- }
3598
+ if (candidate === null || managed.lastUsedAt < candidate.lastUsedAt)
3599
+ candidate = managed;
3549
3600
  }
3550
3601
  return candidate;
3551
3602
  }
3552
- async tryDeleteIfOrphaned(key, managed) {
3553
- if (managed.refCount === 0 && managed.pendingWaiters === 0 && !managed.isInitializing && this.clients.get(key) === managed) {
3554
- this.clients.delete(key);
3555
- await this.tombstoneStop(key, managed.client);
3556
- }
3603
+ discard(managed) {
3604
+ if (this.clients.get(managed.key) !== managed)
3605
+ return;
3606
+ this.clients.delete(managed.key);
3607
+ this.tombstoneStop(managed.key, managed.client);
3557
3608
  }
3558
3609
  async getClient(root, server, signal) {
3559
- if (this.disposed) {
3560
- throw new Error("LspManager has been disposed");
3561
- }
3562
- signal?.throwIfAborted();
3563
- const key = this.getKey(root, server.id);
3610
+ const key = lspClientKey(root, server);
3564
3611
  for (;; ) {
3565
- const pendingStop = this.pendingStops.get(key);
3566
- if (pendingStop === undefined)
3567
- break;
3568
- await awaitWithSignal2(pendingStop, signal);
3612
+ if (this.disposed) {
3613
+ throw new Error("LspManager has been disposed");
3614
+ }
3569
3615
  signal?.throwIfAborted();
3570
- }
3571
- if (this.disposed) {
3572
- throw new Error("LspManager has been disposed");
3573
- }
3574
- let managed = this.clients.get(key);
3575
- if (managed) {
3576
- const t = this.now();
3577
- if (managed.isInitializing && managed.initializingSince !== null && t - managed.initializingSince > this.initTimeoutMs) {
3578
- this.clients.delete(key);
3579
- await this.tombstoneStop(key, managed.client);
3580
- managed = undefined;
3616
+ const pendingStop = this.pendingStops.get(key);
3617
+ if (pendingStop !== undefined) {
3618
+ await awaitWithSignal2(pendingStop, signal);
3619
+ continue;
3581
3620
  }
3582
- }
3583
- if (managed) {
3584
- if (managed.initPromise) {
3585
- managed.pendingWaiters++;
3586
- try {
3587
- await awaitWithSignal2(managed.initPromise, signal);
3588
- } catch (err) {
3589
- managed.pendingWaiters--;
3590
- await this.tryDeleteIfOrphaned(key, managed);
3591
- throw err;
3621
+ let managed = this.clients.get(key);
3622
+ if (managed !== undefined && this.startupExpired(managed, this.now())) {
3623
+ this.discard(managed);
3624
+ continue;
3625
+ }
3626
+ if (managed === undefined) {
3627
+ this.evictForAdmission();
3628
+ this.ensureRespawnAllowed(key, root, server.id);
3629
+ managed = this.startClient(key, root, server, true);
3630
+ }
3631
+ const { initPromise } = managed;
3632
+ if (initPromise !== null) {
3633
+ await this.startups.wait(managed, initPromise, signal);
3634
+ if (signal?.aborted) {
3635
+ this.startups.detach(managed);
3636
+ signal.throwIfAborted();
3592
3637
  }
3593
3638
  managed.pendingWaiters--;
3594
3639
  }
3595
- if (signal?.aborted) {
3596
- await this.tryDeleteIfOrphaned(key, managed);
3597
- signal.throwIfAborted();
3598
- }
3640
+ if (this.clients.get(key) !== managed)
3641
+ continue;
3599
3642
  if (!managed.client.isAlive()) {
3600
3643
  this.recordDeadGeneration(key);
3601
- if (this.clients.get(key) === managed) {
3602
- this.clients.delete(key);
3603
- }
3604
- await this.tombstoneStop(key, managed.client);
3605
- return this.getClient(root, server, signal);
3644
+ this.discard(managed);
3645
+ continue;
3606
3646
  }
3607
3647
  this.markHealthyGeneration(key);
3608
3648
  managed.refCount++;
3609
3649
  managed.lastUsedAt = this.now();
3610
3650
  return managed.client;
3611
3651
  }
3612
- this.evictForAdmission();
3613
- this.ensureRespawnAllowed(key, root, server.id);
3652
+ }
3653
+ startClient(key, root, server, heldByWaiters) {
3614
3654
  const client = this.clientFactory(root, server);
3615
- const initStartedAt = this.now();
3616
- const initPromise = (async () => {
3617
- await client.start();
3618
- await client.initialize();
3619
- })();
3620
- const newManaged = {
3621
- client,
3622
- refCount: 0,
3623
- pendingWaiters: 1,
3624
- lastUsedAt: initStartedAt,
3625
- initPromise,
3626
- isInitializing: true,
3627
- initializingSince: initStartedAt
3628
- };
3629
- this.clients.set(key, newManaged);
3630
- try {
3631
- await awaitWithSignal2(initPromise, signal);
3632
- } catch (err) {
3633
- newManaged.pendingWaiters--;
3634
- if (this.clients.get(key) === newManaged) {
3635
- this.clients.delete(key);
3636
- }
3637
- await this.tombstoneStop(key, client);
3638
- throw err;
3639
- }
3640
- newManaged.pendingWaiters--;
3641
- newManaged.isInitializing = false;
3642
- newManaged.initializingSince = null;
3643
- newManaged.initPromise = null;
3644
- if (signal?.aborted) {
3645
- await this.tryDeleteIfOrphaned(key, newManaged);
3646
- signal.throwIfAborted();
3647
- }
3648
- if (!client.isAlive()) {
3649
- this.recordDeadGeneration(key);
3650
- if (this.clients.get(key) === newManaged) {
3651
- this.clients.delete(key);
3652
- }
3653
- await this.tombstoneStop(key, client);
3654
- return this.getClient(root, server, signal);
3655
- }
3656
- this.markHealthyGeneration(key);
3657
- newManaged.refCount++;
3658
- newManaged.lastUsedAt = this.now();
3659
- return client;
3655
+ const managed = this.startups.begin({ key, root, serverId: server.id, client, heldByWaiters });
3656
+ this.clients.set(key, managed);
3657
+ return managed;
3660
3658
  }
3661
- releaseClient(root, serverId) {
3662
- const key = this.getKey(root, serverId);
3663
- const managed = this.clients.get(key);
3659
+ releaseClient(root, server, client) {
3660
+ const managed = this.clients.get(lspClientKey(root, server));
3661
+ if (client !== undefined && managed?.client !== client)
3662
+ return;
3664
3663
  if (managed && managed.refCount > 0) {
3665
3664
  managed.refCount--;
3666
3665
  managed.lastUsedAt = this.now();
3667
3666
  }
3668
3667
  }
3669
- invalidateClient(root, serverId, client) {
3670
- const key = this.getKey(root, serverId);
3671
- const managed = this.clients.get(key);
3668
+ invalidateClient(root, server, client) {
3669
+ const managed = this.clients.get(lspClientKey(root, server));
3672
3670
  if (!managed)
3673
3671
  return;
3674
3672
  if (client && managed.client !== client)
3675
3673
  return;
3676
- this.clients.delete(key);
3677
- this.tombstoneStop(key, managed.client);
3674
+ this.discard(managed);
3678
3675
  }
3679
3676
  warmupClient(root, server) {
3680
3677
  if (this.disposed)
3681
3678
  return;
3682
- const key = this.getKey(root, server.id);
3679
+ const key = lspClientKey(root, server);
3683
3680
  if (this.clients.has(key) || this.pendingStops.has(key))
3684
3681
  return;
3685
3682
  this.evictForAdmission();
@@ -3688,45 +3685,18 @@ class LspManager {
3688
3685
  } catch {
3689
3686
  return;
3690
3687
  }
3691
- const client = this.clientFactory(root, server);
3692
- const initStartedAt = this.now();
3693
- const initPromise = (async () => {
3694
- await client.start();
3695
- await client.initialize();
3696
- })();
3697
- const managed = {
3698
- client,
3699
- refCount: 0,
3700
- pendingWaiters: 0,
3701
- lastUsedAt: initStartedAt,
3702
- initPromise,
3703
- isInitializing: true,
3704
- initializingSince: initStartedAt
3705
- };
3706
- this.clients.set(key, managed);
3707
- initPromise.then(() => {
3708
- managed.isInitializing = false;
3709
- managed.initializingSince = null;
3710
- managed.initPromise = null;
3711
- managed.lastUsedAt = this.now();
3712
- }, () => {
3713
- if (this.clients.get(key) === managed) {
3714
- this.clients.delete(key);
3715
- }
3716
- this.tombstoneStop(key, client);
3717
- });
3688
+ this.startClient(key, root, server, false);
3718
3689
  }
3719
- isServerInitializing(root, serverId) {
3720
- const managed = this.clients.get(this.getKey(root, serverId));
3690
+ isServerInitializing(root, server) {
3691
+ const managed = this.clients.get(lspClientKey(root, server));
3721
3692
  return managed?.isInitializing ?? false;
3722
3693
  }
3723
3694
  getSnapshot() {
3724
3695
  const snapshots = [];
3725
- for (const [key, managed] of this.clients) {
3726
- const [root, serverId] = key.split("::");
3696
+ for (const managed of this.clients.values()) {
3727
3697
  snapshots.push({
3728
- root,
3729
- serverId,
3698
+ root: managed.root,
3699
+ serverId: managed.serverId,
3730
3700
  refCount: managed.refCount,
3731
3701
  pendingWaiters: managed.pendingWaiters,
3732
3702
  lastUsedAt: managed.lastUsedAt,
@@ -3737,18 +3707,15 @@ class LspManager {
3737
3707
  }
3738
3708
  return snapshots;
3739
3709
  }
3740
- hasClient(root, serverId) {
3741
- return this.clients.has(this.getKey(root, serverId));
3710
+ hasClient(root, server) {
3711
+ return this.clients.has(lspClientKey(root, server));
3742
3712
  }
3743
3713
  clientCount() {
3744
3714
  return this.clients.size;
3745
3715
  }
3746
3716
  async stopAll() {
3747
3717
  this.disposed = true;
3748
- if (this.reaperHandle) {
3749
- clearInterval(this.reaperHandle);
3750
- this.reaperHandle = null;
3751
- }
3718
+ this.stopReaper();
3752
3719
  if (this.signalDisposer) {
3753
3720
  this.signalDisposer();
3754
3721
  this.signalDisposer = null;
@@ -4093,6 +4060,7 @@ function getMergedServers() {
4093
4060
  extensions: config.extensions,
4094
4061
  priority: -100,
4095
4062
  source: "builtin",
4063
+ inheritsBuiltinCommand: true,
4096
4064
  ...config.initialization === undefined ? {} : { initialization: config.initialization }
4097
4065
  });
4098
4066
  }
@@ -4118,8 +4086,11 @@ function createServerFromEntry(id, entry, source) {
4118
4086
  command: builtin.command,
4119
4087
  extensions: entry.extensions ?? builtin.extensions,
4120
4088
  priority: entry.priority ?? 0,
4121
- source
4089
+ source,
4090
+ inheritsBuiltinCommand: true
4122
4091
  });
4092
+ if (entry.initialization !== undefined)
4093
+ server.configuredInitialization = entry.initialization;
4123
4094
  const initialization = mergeInitialization(builtin.initialization, entry.initialization);
4124
4095
  if (initialization !== undefined) {
4125
4096
  server.initialization = initialization;
@@ -4132,7 +4103,8 @@ function createServerFromEntry(id, entry, source) {
4132
4103
  command: entry.command,
4133
4104
  extensions: entry.extensions,
4134
4105
  priority: entry.priority ?? 0,
4135
- source
4106
+ source,
4107
+ inheritsBuiltinCommand: false
4136
4108
  });
4137
4109
  applyOptionalServerFields(server, entry);
4138
4110
  return server;
@@ -4144,7 +4116,8 @@ function createServerFromEntry(id, entry, source) {
4144
4116
  command: entry.command ?? builtin.command,
4145
4117
  extensions: entry.extensions ?? builtin.extensions,
4146
4118
  priority: entry.priority ?? 0,
4147
- source
4119
+ source,
4120
+ inheritsBuiltinCommand: entry.command === undefined
4148
4121
  });
4149
4122
  applyOptionalServerFields(server, entry);
4150
4123
  const builtinInitialization = entry.command === undefined ? builtin.initialization : undefined;
@@ -4167,7 +4140,8 @@ function createServer(input) {
4167
4140
  command: input.command,
4168
4141
  extensions: input.extensions,
4169
4142
  priority: input.priority,
4170
- source: input.source
4143
+ source: input.source,
4144
+ inheritsBuiltinCommand: input.inheritsBuiltinCommand
4171
4145
  };
4172
4146
  if (input.env !== undefined) {
4173
4147
  server.env = input.env;
@@ -4183,6 +4157,7 @@ function applyOptionalServerFields(server, entry) {
4183
4157
  }
4184
4158
  if (entry.initialization !== undefined) {
4185
4159
  server.initialization = entry.initialization;
4160
+ server.configuredInitialization = entry.initialization;
4186
4161
  }
4187
4162
  }
4188
4163
  function isConfigJson(value) {
@@ -4270,11 +4245,17 @@ function readHead(path) {
4270
4245
  closeSync3(fd);
4271
4246
  }
4272
4247
  }
4248
+ var NODE_PROJECT_MARKERS = [
4249
+ "package.json",
4250
+ "bun.lock",
4251
+ "bun.lockb",
4252
+ "package-lock.json",
4253
+ "yarn.lock",
4254
+ "pnpm-lock.yaml"
4255
+ ];
4256
+ var NODE_LOCAL_BIN_DIR = join4("node_modules", ".bin");
4273
4257
  var LOCAL_BIN_RULES = [
4274
- {
4275
- markers: ["package.json", "bun.lock", "bun.lockb", "package-lock.json", "yarn.lock", "pnpm-lock.yaml"],
4276
- binDirs: [join4("node_modules", ".bin")]
4277
- },
4258
+ { markers: NODE_PROJECT_MARKERS, binDirs: [NODE_LOCAL_BIN_DIR] },
4278
4259
  {
4279
4260
  markers: [
4280
4261
  "pyproject.toml",
@@ -4401,6 +4382,55 @@ function isServerInstalled(command, workingDirectory, options = {}) {
4401
4382
  return false;
4402
4383
  return resolveServerBinary(command, workingDirectory, options) !== null;
4403
4384
  }
4385
+ function nativeTypescriptSearchDirectory(targetPath, workingDirectory) {
4386
+ try {
4387
+ const session = realpathSync6(workingDirectory);
4388
+ if (targetPath === undefined)
4389
+ return session;
4390
+ const target = canonicalizeExistingOrNearestAncestor(resolve8(workingDirectory, targetPath));
4391
+ if (!isPathInside(session, target))
4392
+ return session;
4393
+ return statSync4(target, { throwIfNoEntry: false })?.isDirectory() === true ? target : dirname10(target);
4394
+ } catch {
4395
+ return workingDirectory;
4396
+ }
4397
+ }
4398
+ function nativeTypescriptCommand(server, searchDirectory) {
4399
+ if (server.id !== "typescript" || !server.inheritsBuiltinCommand)
4400
+ return null;
4401
+ const found = findProjectTsc(searchDirectory);
4402
+ if (found === null)
4403
+ return null;
4404
+ const speaksLsp = !existsSync11(join5(found.packageDir, "lib", "tsserver.js"));
4405
+ return speaksLsp ? [found.tsc, "--lsp", "--stdio"] : null;
4406
+ }
4407
+ function findProjectTsc(searchDirectory) {
4408
+ const suffixes = executableSuffixes(process.platform, undefined);
4409
+ let current = searchDirectory;
4410
+ for (;; ) {
4411
+ if (NODE_PROJECT_MARKERS.some((marker) => probe(join5(current, marker)))) {
4412
+ const binDir = join5(current, NODE_LOCAL_BIN_DIR);
4413
+ const tsc = probeWithSuffixes(binDir, "tsc", suffixes);
4414
+ const packageDir = join5(binDir, "..", "typescript");
4415
+ if (tsc !== null && isRealDirectory(binDir) && existsSync11(join5(packageDir, "package.json"))) {
4416
+ return { tsc, packageDir };
4417
+ }
4418
+ }
4419
+ if (probe(join5(current, ".git")))
4420
+ return null;
4421
+ const parent = dirname10(current);
4422
+ if (parent === current)
4423
+ return null;
4424
+ current = parent;
4425
+ }
4426
+ }
4427
+ function isRealDirectory(directory) {
4428
+ try {
4429
+ return realpathSync6(directory) === directory;
4430
+ } catch {
4431
+ return false;
4432
+ }
4433
+ }
4404
4434
  function withResolvedCommand(command, binaryPath) {
4405
4435
  return [binaryPath, ...command.slice(1)];
4406
4436
  }
@@ -4408,12 +4438,27 @@ function usesBuiltinCommand(id, command) {
4408
4438
  const builtin = BUILTIN_SERVERS[id]?.command;
4409
4439
  return builtin !== undefined && builtin.length === command.length && builtin.every((part, index) => part === command[index]);
4410
4440
  }
4411
- function findServerForExtension(ext) {
4441
+ function findServerForExtension(ext, targetPath) {
4412
4442
  const servers = getMergedServers();
4413
4443
  const workingDirectory = contextCwd();
4444
+ const searchDirectory = nativeTypescriptSearchDirectory(targetPath, workingDirectory);
4414
4445
  for (const server of servers) {
4415
4446
  if (!server.extensions.includes(ext))
4416
4447
  continue;
4448
+ const nativeTypescript = nativeTypescriptCommand(server, searchDirectory);
4449
+ if (nativeTypescript !== null) {
4450
+ return {
4451
+ status: "found",
4452
+ server: {
4453
+ id: server.id,
4454
+ command: withHostJsRuntime(server.id, nativeTypescript),
4455
+ extensions: server.extensions,
4456
+ priority: server.priority,
4457
+ ...server.env === undefined ? {} : { env: server.env },
4458
+ ...server.configuredInitialization === undefined ? {} : { initialization: server.configuredInitialization }
4459
+ }
4460
+ };
4461
+ }
4417
4462
  const binaryPath = resolveServerBinary(server.command, workingDirectory);
4418
4463
  if (binaryPath !== null) {
4419
4464
  const resolvedServer = {
@@ -4466,6 +4511,7 @@ function getAllServers() {
4466
4511
  const servers = getMergedServers();
4467
4512
  const disabled = getDisabledServerIds();
4468
4513
  const workingDirectory = contextCwd();
4514
+ const nativeSearchDirectory = nativeTypescriptSearchDirectory(undefined, workingDirectory);
4469
4515
  const result = [];
4470
4516
  const seen = new Set;
4471
4517
  for (const server of servers) {
@@ -4473,7 +4519,7 @@ function getAllServers() {
4473
4519
  continue;
4474
4520
  result.push({
4475
4521
  id: server.id,
4476
- installed: isServerInstalled(server.command, workingDirectory),
4522
+ installed: isServerInstalled(server.command, workingDirectory) || nativeTypescriptCommand(server, nativeSearchDirectory) !== null,
4477
4523
  extensions: server.extensions,
4478
4524
  disabled: false,
4479
4525
  source: server.source,
@@ -4498,7 +4544,7 @@ function getAllServers() {
4498
4544
  }
4499
4545
  function isDirectoryPath(filePath) {
4500
4546
  try {
4501
- return statSync4(filePath).isDirectory();
4547
+ return statSync5(filePath).isDirectory();
4502
4548
  } catch {
4503
4549
  return false;
4504
4550
  }
@@ -4508,7 +4554,7 @@ function findWorkspaceRoot(filePath) {
4508
4554
  const abs = resolveReadablePathInsideContext(filePath);
4509
4555
  let dir = abs;
4510
4556
  if (!isDirectoryPath(dir)) {
4511
- dir = dirname10(dir);
4557
+ dir = dirname11(dir);
4512
4558
  }
4513
4559
  if (!isPathInside(cwd, abs))
4514
4560
  return findWorkspaceRootOutsideContext(dir);
@@ -4517,7 +4563,7 @@ function findWorkspaceRoot(filePath) {
4517
4563
  while (isPathInside(cwd, dir)) {
4518
4564
  const canonicalDir = existingDirectoryInsideContext(dir, cwd);
4519
4565
  if (canonicalDir !== undefined) {
4520
- if (existsSync11(join5(dir, GIT_WORKSPACE_MARKER))) {
4566
+ if (existsSync12(join6(dir, GIT_WORKSPACE_MARKER))) {
4521
4567
  return canonicalDir;
4522
4568
  }
4523
4569
  if (nearestPackageRoot === undefined && hasProjectWorkspaceMarker(dir)) {
@@ -4526,16 +4572,16 @@ function findWorkspaceRoot(filePath) {
4526
4572
  }
4527
4573
  if (dir === cwd)
4528
4574
  break;
4529
- dir = dirname10(dir);
4575
+ dir = dirname11(dir);
4530
4576
  }
4531
4577
  return nearestPackageRoot ?? fallbackRoot;
4532
4578
  }
4533
4579
  function hasProjectWorkspaceMarker(directory) {
4534
- return PROJECT_WORKSPACE_MARKERS.some((marker) => existsSync11(join5(directory, marker)));
4580
+ return PROJECT_WORKSPACE_MARKERS.some((marker) => existsSync12(join6(directory, marker)));
4535
4581
  }
4536
4582
  function resolveReadablePathInsideContext(filePath) {
4537
4583
  const cwd = contextCwd();
4538
- const abs = resolve8(cwd, filePath);
4584
+ const abs = resolve9(cwd, filePath);
4539
4585
  if (isPathInside(cwd, abs))
4540
4586
  return abs;
4541
4587
  const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
@@ -4556,12 +4602,12 @@ function rebaseThroughCanonicalAncestor(path, cwd) {
4556
4602
  let current = path;
4557
4603
  const suffix = [];
4558
4604
  while (true) {
4559
- if (existsSync11(current)) {
4560
- const canonical = realpathSync6(current);
4605
+ if (existsSync12(current)) {
4606
+ const canonical = realpathSync7(current);
4561
4607
  if (isPathInside(cwd, canonical))
4562
- return suffix.length === 0 ? canonical : join5(canonical, ...suffix);
4608
+ return suffix.length === 0 ? canonical : join6(canonical, ...suffix);
4563
4609
  }
4564
- const parent = dirname10(current);
4610
+ const parent = dirname11(current);
4565
4611
  if (parent === current)
4566
4612
  return;
4567
4613
  suffix.unshift(basename3(current));
@@ -4569,10 +4615,10 @@ function rebaseThroughCanonicalAncestor(path, cwd) {
4569
4615
  }
4570
4616
  }
4571
4617
  function existingDirectoryInsideContext(directory, cwd) {
4572
- if (!existsSync11(directory))
4618
+ if (!existsSync12(directory))
4573
4619
  return;
4574
- const canonical = realpathSync6(directory);
4575
- if (!statSync4(canonical).isDirectory())
4620
+ const canonical = realpathSync7(directory);
4621
+ if (!statSync5(canonical).isDirectory())
4576
4622
  return;
4577
4623
  return isPathInside(cwd, canonical) ? canonical : undefined;
4578
4624
  }
@@ -4584,7 +4630,7 @@ function nearestExistingDirectoryInsideContext(directory, cwd) {
4584
4630
  return canonical;
4585
4631
  if (current === cwd)
4586
4632
  return;
4587
- current = dirname10(current);
4633
+ current = dirname11(current);
4588
4634
  }
4589
4635
  return;
4590
4636
  }
@@ -4684,7 +4730,7 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
4684
4730
  throw new LspInvalidPathError("Directory paths are not supported by this LSP tool. " + "Use lsp.diagnostics with a directory path for directory diagnostics.");
4685
4731
  }
4686
4732
  const ext = effectiveExtension(absPath);
4687
- const result = findServerForExtension(ext);
4733
+ const result = findServerForExtension(ext, absPath);
4688
4734
  if (result.status !== "found") {
4689
4735
  throw new LspServerLookupError(formatServerLookupError(result), result);
4690
4736
  }
@@ -4697,21 +4743,144 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
4697
4743
  return await fn(client, root, absPath);
4698
4744
  } catch (err) {
4699
4745
  if (allowRetry && READ_ONLY_TOOLS.has(toolName) && isLspDeadConnectionError(err)) {
4700
- manager.invalidateClient(root, server.id, client);
4746
+ manager.invalidateClient(root, server, client);
4701
4747
  return acquireAndCall(false);
4702
4748
  }
4703
4749
  if (err instanceof LspRequestTimeoutError) {
4704
- if (manager.isServerInitializing(root, server.id)) {
4750
+ if (manager.isServerInitializing(root, server)) {
4705
4751
  throw new LspServerInitializingError(err);
4706
4752
  }
4707
4753
  }
4708
4754
  throw err;
4709
4755
  } finally {
4710
- manager.releaseClient(root, server.id);
4756
+ manager.releaseClient(root, server, client);
4711
4757
  }
4712
4758
  };
4713
4759
  return acquireAndCall(true);
4714
4760
  }
4761
+ async function scanServedGroups(options) {
4762
+ const { groups, signal } = options;
4763
+ const limit = Math.max(1, options.maxConcurrency);
4764
+ const fileSlots = createSlots(limit);
4765
+ let nextGroup = 0;
4766
+ let startedGroups = 0;
4767
+ let firstError;
4768
+ const runners = Array.from({ length: Math.min(limit, groups.length) }, async () => {
4769
+ for (;; ) {
4770
+ if (signal?.aborted)
4771
+ return;
4772
+ const group = groups[nextGroup];
4773
+ nextGroup += 1;
4774
+ if (group === undefined)
4775
+ return;
4776
+ let client;
4777
+ try {
4778
+ client = await acquireWithinInitTimeout(options, group);
4779
+ } catch (error) {
4780
+ if (signal?.aborted)
4781
+ return;
4782
+ firstError ??= error;
4783
+ options.onGroupUnavailable(group, error instanceof Error ? error.message : String(error));
4784
+ continue;
4785
+ }
4786
+ startedGroups += 1;
4787
+ try {
4788
+ await Promise.all(group.files.map(async (file) => {
4789
+ const release = await fileSlots.acquire();
4790
+ try {
4791
+ if (!signal?.aborted)
4792
+ await options.checkFile(client, file);
4793
+ } finally {
4794
+ release();
4795
+ }
4796
+ }));
4797
+ } finally {
4798
+ options.manager.releaseClient(group.root, group.server, client);
4799
+ }
4800
+ }
4801
+ });
4802
+ await Promise.all(runners);
4803
+ signal?.throwIfAborted();
4804
+ if (startedGroups === 0 && firstError !== undefined)
4805
+ throw firstError;
4806
+ }
4807
+ async function acquireWithinInitTimeout(options, group) {
4808
+ const { signal } = options;
4809
+ const timers = options.timers ?? realTimerProvider;
4810
+ const controller = new AbortController;
4811
+ const forwardAbort = () => controller.abort(signal?.reason);
4812
+ signal?.addEventListener("abort", forwardAbort, { once: true });
4813
+ if (signal?.aborted)
4814
+ forwardAbort();
4815
+ let timedOut = false;
4816
+ const timer = timers.setTimeout(() => {
4817
+ timedOut = true;
4818
+ controller.abort();
4819
+ }, INIT_TIMEOUT_MS);
4820
+ try {
4821
+ return await options.manager.getClient(group.root, group.server, controller.signal);
4822
+ } catch (error) {
4823
+ if (timedOut && signal?.aborted !== true) {
4824
+ throw new Error(`${group.server.id} did not start within ${INIT_TIMEOUT_MS}ms`);
4825
+ }
4826
+ throw error;
4827
+ } finally {
4828
+ timers.clearTimeout(timer);
4829
+ signal?.removeEventListener("abort", forwardAbort);
4830
+ }
4831
+ }
4832
+ function createSlots(limit) {
4833
+ let free = limit;
4834
+ const waiting = [];
4835
+ const release = () => {
4836
+ const next = waiting.shift();
4837
+ if (next === undefined)
4838
+ free += 1;
4839
+ else
4840
+ next();
4841
+ };
4842
+ return {
4843
+ acquire() {
4844
+ if (free > 0) {
4845
+ free -= 1;
4846
+ return Promise.resolve(release);
4847
+ }
4848
+ return new Promise((resolve) => waiting.push(() => resolve(release)));
4849
+ }
4850
+ };
4851
+ }
4852
+ function groupFilesByClient(files, extension, fixed = {}) {
4853
+ const byDirectory = new Map;
4854
+ const served = new Map;
4855
+ const unserved = new Map;
4856
+ for (const file of files) {
4857
+ const directory = dirname12(file);
4858
+ let resolution = byDirectory.get(directory);
4859
+ if (resolution === undefined) {
4860
+ resolution = resolveDirectory(directory, extension, fixed);
4861
+ byDirectory.set(directory, resolution);
4862
+ }
4863
+ if (resolution.kind === "served") {
4864
+ const group = served.get(resolution.key) ?? { root: resolution.root, server: resolution.server, files: [] };
4865
+ group.files.push(file);
4866
+ served.set(resolution.key, group);
4867
+ } else {
4868
+ const group = unserved.get(resolution.key) ?? { lookup: resolution.lookup, files: [] };
4869
+ group.files.push(file);
4870
+ unserved.set(resolution.key, group);
4871
+ }
4872
+ }
4873
+ return { served: [...served.values()], unserved: [...unserved.values()] };
4874
+ }
4875
+ function resolveDirectory(directory, extension, fixed) {
4876
+ const lookup = fixed.server === undefined ? findServerForExtension(extension, directory) : { status: "found", server: fixed.server };
4877
+ if (lookup.status !== "found") {
4878
+ const serverId = lookup.status === "not_installed" ? lookup.server.id : "";
4879
+ return { kind: "unserved", key: JSON.stringify([lookup.status, serverId]), lookup };
4880
+ }
4881
+ const root = fixed.workspaceRoot ?? findWorkspaceRoot(directory);
4882
+ return { kind: "served", key: lspClientKey(root, lookup.server), root, server: lookup.server };
4883
+ }
4715
4884
  var DIAGNOSTIC_SEVERITY_FILTERS = {
4716
4885
  error: 1,
4717
4886
  warning: 2,
@@ -4836,7 +5005,7 @@ function collectFilesWithExtension(dir, extension, maxFiles) {
4836
5005
  for (const entry of entries) {
4837
5006
  if (files.length >= maxFiles)
4838
5007
  return;
4839
- const fullPath = join6(currentDir, entry);
5008
+ const fullPath = join7(currentDir, entry);
4840
5009
  let stat;
4841
5010
  try {
4842
5011
  stat = lstatSync5(fullPath);
@@ -4861,15 +5030,10 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
4861
5030
  if (!extension.startsWith(".")) {
4862
5031
  throw new LspInvalidPathError(`Extension must start with a dot (e.g., ".ts", not "${extension}"). Use ".${extension}" instead.`);
4863
5032
  }
4864
- const absDir = resolve9(options.workspaceRoot ?? contextCwd(), directory);
4865
- if (!existsSync12(absDir)) {
5033
+ const absDir = resolve10(options.workspaceRoot ?? contextCwd(), directory);
5034
+ if (!existsSync13(absDir)) {
4866
5035
  throw new LspInvalidPathError(`Directory does not exist: ${absDir}`);
4867
5036
  }
4868
- const serverResult = options.server === undefined ? findServerForExtension(extension) : { status: "found", server: options.server };
4869
- if (serverResult.status !== "found") {
4870
- throw new LspServerLookupError(formatServerLookupError(serverResult));
4871
- }
4872
- const server = serverResult.server;
4873
5037
  const allFiles = (options.listFiles ?? collectFilesWithExtension)(absDir, extension, maxFiles + 1);
4874
5038
  const wasCapped = allFiles.length > maxFiles;
4875
5039
  const filesToProcess = allFiles.slice(0, maxFiles);
@@ -4883,42 +5047,43 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
4883
5047
  `);
4884
5048
  return { output, totalDiagnostics: 0, fileFailures: [] };
4885
5049
  }
4886
- const root = options.workspaceRoot ?? findWorkspaceRoot(absDir);
5050
+ const groups = groupFilesByClient(filesToProcess, extension, {
5051
+ ...options.server === undefined ? {} : { server: options.server },
5052
+ ...options.workspaceRoot === undefined ? {} : { workspaceRoot: options.workspaceRoot }
5053
+ });
5054
+ const firstUnserved = groups.unserved[0];
5055
+ if (groups.served.length === 0 && firstUnserved !== undefined) {
5056
+ throw new LspServerLookupError(formatServerLookupError(firstUnserved.lookup));
5057
+ }
4887
5058
  const manager = options.manager ?? getLspManager();
4888
5059
  const allDiagnostics = [];
4889
5060
  const fileErrors = [];
4890
5061
  const maxConcurrency = Math.max(1, options.maxConcurrency ?? DIRECTORY_DIAGNOSTICS_MAX_CONCURRENCY);
5062
+ for (const group of groups.unserved) {
5063
+ const error = formatServerLookupError(group.lookup).split(`
5064
+ `)[0] ?? "No LSP server";
5065
+ fileErrors.push(...group.files.map((file) => ({ file, error })));
5066
+ }
4891
5067
  options.signal?.throwIfAborted();
4892
- const client = await manager.getClient(root, server, options.signal);
4893
- try {
4894
- let nextIndex = 0;
4895
- const workers = Array.from({ length: Math.min(maxConcurrency, filesToProcess.length) }, async () => {
4896
- for (;; ) {
4897
- if (options.signal?.aborted)
4898
- return;
4899
- const file = filesToProcess[nextIndex];
4900
- nextIndex += 1;
4901
- if (file === undefined)
4902
- return;
4903
- try {
4904
- const result = await client.diagnostics(file, options.signal);
4905
- const filtered = filterDiagnosticsBySeverity(result.items, severity);
4906
- allDiagnostics.push(...filtered.map((diagnostic) => ({
4907
- filePath: file,
4908
- diagnostic
4909
- })));
4910
- } catch (e) {
4911
- fileErrors.push({
4912
- file,
4913
- error: e instanceof Error ? e.message : String(e)
4914
- });
4915
- }
5068
+ await scanServedGroups({
5069
+ manager,
5070
+ groups: groups.served,
5071
+ maxConcurrency,
5072
+ ...options.signal === undefined ? {} : { signal: options.signal },
5073
+ ...options.timers === undefined ? {} : { timers: options.timers },
5074
+ onGroupUnavailable: (group, error) => {
5075
+ fileErrors.push(...group.files.map((file) => ({ file, error })));
5076
+ },
5077
+ checkFile: async (client, file) => {
5078
+ try {
5079
+ const result = await client.diagnostics(file, options.signal);
5080
+ const filtered = filterDiagnosticsBySeverity(result.items, severity);
5081
+ allDiagnostics.push(...filtered.map((diagnostic) => ({ filePath: file, diagnostic })));
5082
+ } catch (e) {
5083
+ fileErrors.push({ file, error: e instanceof Error ? e.message : String(e) });
4916
5084
  }
4917
- });
4918
- await Promise.all(workers);
4919
- } finally {
4920
- manager.releaseClient(root, server.id);
4921
- }
5085
+ }
5086
+ });
4922
5087
  const displayDiagnostics = allDiagnostics.slice(0, DEFAULT_MAX_DIAGNOSTICS);
4923
5088
  const wasDiagCapped = allDiagnostics.length > DEFAULT_MAX_DIAGNOSTICS;
4924
5089
  const lines = [
@@ -4963,7 +5128,7 @@ function inferExtensionFromDirectory(directory) {
4963
5128
  for (const entry of entries) {
4964
5129
  if (scanned >= MAX_SCAN_ENTRIES)
4965
5130
  return;
4966
- const fullPath = join7(dir, entry);
5131
+ const fullPath = join8(dir, entry);
4967
5132
  let stat;
4968
5133
  try {
4969
5134
  stat = lstatSync6(fullPath);
@@ -5087,7 +5252,7 @@ function parseBunCheckOutput(stdout, cwd) {
5087
5252
  const [, path, lineNumber, column, severity, code, message] = match;
5088
5253
  const start = { line: Number(lineNumber) - 1, character: Number(column) - 1 };
5089
5254
  results.push({
5090
- file: resolve10(cwd, path ?? ""),
5255
+ file: resolve11(cwd, path ?? ""),
5091
5256
  diagnostic: {
5092
5257
  range: { start, end: start },
5093
5258
  severity: TSC_SEVERITY[severity ?? "error"] ?? 1,
@@ -5151,18 +5316,18 @@ var UNFORMATTED_PROBE = `const a=1
5151
5316
  `;
5152
5317
  var probeCache = new Map;
5153
5318
  function findBunProjectRoot(start, home = homedir3()) {
5154
- const stopAt = resolve11(home);
5155
- let dir = resolve11(start);
5319
+ const stopAt = resolve12(home);
5320
+ let dir = resolve12(start);
5156
5321
  for (;; ) {
5157
5322
  if (dir === stopAt)
5158
5323
  return;
5159
- if (BUN_LOCKFILES.some((name) => existsSync13(join8(dir, name))))
5324
+ if (BUN_LOCKFILES.some((name) => existsSync14(join9(dir, name))))
5160
5325
  return dir;
5161
- if (packageManagerIsBun(join8(dir, "package.json")))
5326
+ if (packageManagerIsBun(join9(dir, "package.json")))
5162
5327
  return dir;
5163
- if (existsSync13(join8(dir, ".git")))
5328
+ if (existsSync14(join9(dir, ".git")))
5164
5329
  return;
5165
- const parent = dirname11(dir);
5330
+ const parent = dirname13(dir);
5166
5331
  if (parent === dir)
5167
5332
  return;
5168
5333
  dir = parent;
@@ -5174,7 +5339,7 @@ function packageManagerIsBun(packageJsonPath) {
5174
5339
  return typeof packageManager === "string" && packageManager.startsWith("bun@");
5175
5340
  }
5176
5341
  function readJsonObject(path) {
5177
- if (!existsSync13(path))
5342
+ if (!existsSync14(path))
5178
5343
  return;
5179
5344
  try {
5180
5345
  const parsed = JSON.parse(readFileSync6(path, "utf8"));
@@ -5185,14 +5350,14 @@ function readJsonObject(path) {
5185
5350
  }
5186
5351
  function isFile(path) {
5187
5352
  try {
5188
- return statSync5(path).isFile();
5353
+ return statSync6(path).isFile();
5189
5354
  } catch {
5190
5355
  return false;
5191
5356
  }
5192
5357
  }
5193
5358
  function isDirectory(path) {
5194
5359
  try {
5195
- return statSync5(path).isDirectory();
5360
+ return statSync6(path).isDirectory();
5196
5361
  } catch {
5197
5362
  return false;
5198
5363
  }
@@ -5200,35 +5365,35 @@ function isDirectory(path) {
5200
5365
  function projectShadowsBunCommand(command, cwd) {
5201
5366
  const packageJsonDir = nearestPackageJsonDir(cwd);
5202
5367
  if (packageJsonDir !== undefined) {
5203
- const scripts = readJsonObject(join8(packageJsonDir, "package.json"))?.["scripts"];
5368
+ const scripts = readJsonObject(join9(packageJsonDir, "package.json"))?.["scripts"];
5204
5369
  if (scripts !== null && typeof scripts === "object" && typeof scripts[command] === "string") {
5205
5370
  return true;
5206
5371
  }
5207
5372
  }
5208
5373
  if (command === "check")
5209
5374
  return false;
5210
- const base = join8(cwd, command);
5375
+ const base = join9(cwd, command);
5211
5376
  if (isFile(base) || RUNNABLE_EXTENSIONS.some((extension) => isFile(`${base}${extension}`)))
5212
5377
  return true;
5213
- if (isDirectory(base) && (isFile(join8(base, "package.json")) || RUNNABLE_EXTENSIONS.some((extension) => isFile(join8(base, `index${extension}`))))) {
5378
+ if (isDirectory(base) && (isFile(join9(base, "package.json")) || RUNNABLE_EXTENSIONS.some((extension) => isFile(join9(base, `index${extension}`))))) {
5214
5379
  return true;
5215
5380
  }
5216
- let dir = resolve11(cwd);
5381
+ let dir = resolve12(cwd);
5217
5382
  for (;; ) {
5218
- if (BIN_SUFFIXES.some((suffix) => existsSync13(join8(dir, "node_modules", ".bin", `${command}${suffix}`))))
5383
+ if (BIN_SUFFIXES.some((suffix) => existsSync14(join9(dir, "node_modules", ".bin", `${command}${suffix}`))))
5219
5384
  return true;
5220
- const parent = dirname11(dir);
5385
+ const parent = dirname13(dir);
5221
5386
  if (parent === dir)
5222
5387
  return false;
5223
5388
  dir = parent;
5224
5389
  }
5225
5390
  }
5226
5391
  function nearestPackageJsonDir(start) {
5227
- let dir = resolve11(start);
5392
+ let dir = resolve12(start);
5228
5393
  for (;; ) {
5229
- if (existsSync13(join8(dir, "package.json")))
5394
+ if (existsSync14(join9(dir, "package.json")))
5230
5395
  return dir;
5231
- const parent = dirname11(dir);
5396
+ const parent = dirname13(dir);
5232
5397
  if (parent === dir)
5233
5398
  return;
5234
5399
  dir = parent;
@@ -5236,7 +5401,7 @@ function nearestPackageJsonDir(start) {
5236
5401
  }
5237
5402
  function binaryIdentity(bunPath) {
5238
5403
  try {
5239
- const stats = statSync5(bunPath);
5404
+ const stats = statSync6(bunPath);
5240
5405
  return `${stats.mtimeMs}:${stats.size}`;
5241
5406
  } catch {
5242
5407
  return "missing";
@@ -5256,7 +5421,7 @@ function bunHasCommand(bunPath, command, timeoutMs = PROBE_TIMEOUT_MS2) {
5256
5421
  return probe;
5257
5422
  }
5258
5423
  async function probeOnce(bunPath, command, timeoutMs) {
5259
- const emptyDir = mkdtempSync(join8(tmpdir2(), "omo-bun-probe-"));
5424
+ const emptyDir = mkdtempSync(join9(tmpdir2(), "omo-bun-probe-"));
5260
5425
  const timeout = AbortSignal.timeout(timeoutMs);
5261
5426
  try {
5262
5427
  const help = await runBunCommand(bunPath, [command, "--help"], emptyDir, timeout);
@@ -5266,7 +5431,7 @@ async function probeOnce(bunPath, command, timeoutMs) {
5266
5431
  return false;
5267
5432
  if (command !== "format")
5268
5433
  return true;
5269
- const probeFile = join8(emptyDir, "probe.ts");
5434
+ const probeFile = join9(emptyDir, "probe.ts");
5270
5435
  writeFileSync3(probeFile, UNFORMATTED_PROBE);
5271
5436
  const write = await runBunCommand(bunPath, ["format", "--write", "probe.ts"], emptyDir, timeout);
5272
5437
  if (write.exitCode === null)
@@ -6172,7 +6337,7 @@ function resolveDaemonRuntime2(env, defaults) {
6172
6337
  if (!isAbsolute6(cliOverride)) {
6173
6338
  throw new InvalidRuntimeOverrideError2("cli_must_be_absolute", `${OMO_LSP_DAEMON_CLI2} must be an absolute path to an existing regular file`);
6174
6339
  }
6175
- const stat = statSync6(cliOverride, { throwIfNoEntry: false });
6340
+ const stat = statSync7(cliOverride, { throwIfNoEntry: false });
6176
6341
  if (!stat) {
6177
6342
  throw new InvalidRuntimeOverrideError2("cli_not_found", `${OMO_LSP_DAEMON_CLI2} points to a missing file`);
6178
6343
  }
@@ -6199,8 +6364,8 @@ var WORKSPACE_MARKERS2 = [GIT_WORKSPACE_MARKER2, ...PROJECT_WORKSPACE_MARKERS2];
6199
6364
 
6200
6365
  // ../../../../lsp-core/src/request-context.ts
6201
6366
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
6202
- import { existsSync as existsSync14, realpathSync as realpathSync7, statSync as statSync7 } from "node:fs";
6203
- import { basename as basename4, delimiter as delimiter4, dirname as dirname2, isAbsolute as isAbsolute7, join as join9, relative as relative5, resolve as resolve12 } from "node:path";
6367
+ import { existsSync as existsSync15, realpathSync as realpathSync8, statSync as statSync8 } from "node:fs";
6368
+ import { basename as basename4, delimiter as delimiter4, dirname as dirname2, isAbsolute as isAbsolute7, join as join10, relative as relative5, resolve as resolve13 } from "node:path";
6204
6369
 
6205
6370
  class LspRequestContextParseError2 extends Error {
6206
6371
  constructor(code, message) {
@@ -6241,19 +6406,19 @@ function parseLspRequestContext2(value) {
6241
6406
  };
6242
6407
  }
6243
6408
  function canonicalCwd2(cwd) {
6244
- const resolved = resolve12(cwd);
6245
- if (!existsSync14(resolved) || !statSync7(resolved).isDirectory()) {
6409
+ const resolved = resolve13(cwd);
6410
+ if (!existsSync15(resolved) || !statSync8(resolved).isDirectory()) {
6246
6411
  throw new LspRequestContextParseError2("invalid_cwd", `LSP request cwd must be an existing directory: ${cwd}`);
6247
6412
  }
6248
- return realpathSync7(resolved);
6413
+ return realpathSync8(resolved);
6249
6414
  }
6250
6415
  function canonicalizeExistingOrNearestAncestor2(path) {
6251
- let current = resolve12(path);
6416
+ let current = resolve13(path);
6252
6417
  const suffix = [];
6253
6418
  while (true) {
6254
6419
  try {
6255
- const existing = realpathSync7(current);
6256
- return suffix.length === 0 ? existing : join9(existing, ...suffix);
6420
+ const existing = realpathSync8(current);
6421
+ return suffix.length === 0 ? existing : join10(existing, ...suffix);
6257
6422
  } catch (error) {
6258
6423
  if (!isMissingPathError2(error))
6259
6424
  throw error;
@@ -6296,7 +6461,7 @@ function requireAbsolutePath2(path, field) {
6296
6461
  }
6297
6462
  }
6298
6463
  function isPathInside2(parent, child) {
6299
- const childPath = resolve12(child);
6464
+ const childPath = resolve13(child);
6300
6465
  const relativePath = relative5(parent, childPath);
6301
6466
  return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute7(relativePath);
6302
6467
  }
@@ -6449,9 +6614,9 @@ function extensionKey(filePath) {
6449
6614
  return extension.length === 0 ? undefined : extension;
6450
6615
  }
6451
6616
  // src/daemon-cli-path.ts
6452
- import { existsSync as existsSync15, readFileSync as readFileSync8 } from "node:fs";
6617
+ import { existsSync as existsSync16, readFileSync as readFileSync8 } from "node:fs";
6453
6618
  import { createRequire as createRequire2 } from "node:module";
6454
- import { dirname as dirname12, join as join10 } from "node:path";
6619
+ import { dirname as dirname14, join as join11 } from "node:path";
6455
6620
  import { fileURLToPath as fileURLToPath4 } from "node:url";
6456
6621
  var requireFromHere2 = createRequire2(import.meta.url);
6457
6622
  var PACKAGE_LSP_DAEMON_CLI = "@code-yeongyu/lsp-daemon/cli";
@@ -6473,7 +6638,7 @@ function resolveLspDaemonCli() {
6473
6638
  if (packageCli !== null)
6474
6639
  return resolveConfiguredLspDaemonCli(packageCli);
6475
6640
  const bundledCli = fileURLToPath4(new URL("../../lsp-daemon/dist/cli.js", import.meta.url));
6476
- if (existsSync15(bundledCli))
6641
+ if (existsSync16(bundledCli))
6477
6642
  return resolveConfiguredLspDaemonCli(bundledCli);
6478
6643
  return resolveConfiguredLspDaemonCli(bundledCli);
6479
6644
  }
@@ -6498,7 +6663,7 @@ function resolveConfiguredLspDaemonCli(cliPath) {
6498
6663
  }
6499
6664
  function readDaemonPackageVersion(cliPath) {
6500
6665
  try {
6501
- const parsed = JSON.parse(readFileSync8(join10(dirname12(cliPath), "package.json"), "utf8"));
6666
+ const parsed = JSON.parse(readFileSync8(join11(dirname14(cliPath), "package.json"), "utf8"));
6502
6667
  if (isRecord8(parsed) && typeof parsed["version"] === "string" && parsed["version"].length > 0) {
6503
6668
  return parsed["version"];
6504
6669
  }
@@ -6515,7 +6680,7 @@ function isRecord8(value) {
6515
6680
  // src/lsp-session-state.ts
6516
6681
  import { mkdirSync as mkdirSync4, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "node:fs";
6517
6682
  import { homedir } from "node:os";
6518
- import { dirname as dirname13, join as join11 } from "node:path";
6683
+ import { dirname as dirname15, join as join12 } from "node:path";
6519
6684
  function sessionIdFrom(input) {
6520
6685
  return typeof input.session_id === "string" && input.session_id.length > 0 ? input.session_id : undefined;
6521
6686
  }
@@ -6541,8 +6706,8 @@ function isLspDaemonUnreachableDiagnostics(diagnostics) {
6541
6706
  return diagnostics.includes("LSP daemon unreachable");
6542
6707
  }
6543
6708
  function sessionStatePath(sessionId) {
6544
- const root = process.env["PLUGIN_DATA"] ?? join11(homedir(), ".codex", "codex-lsp");
6545
- return join11(root, "sessions", `${safePathSegment(sessionId)}.json`);
6709
+ const root = process.env["PLUGIN_DATA"] ?? join12(homedir(), ".codex", "codex-lsp");
6710
+ return join12(root, "sessions", `${safePathSegment(sessionId)}.json`);
6546
6711
  }
6547
6712
  function readSessionState(path) {
6548
6713
  try {
@@ -6557,7 +6722,7 @@ function readSessionState(path) {
6557
6722
  }
6558
6723
  }
6559
6724
  function writeSessionState(path, state) {
6560
- mkdirSync4(dirname13(path), { recursive: true });
6725
+ mkdirSync4(dirname15(path), { recursive: true });
6561
6726
  writeFileSync5(path, `${JSON.stringify(state)}
6562
6727
  `);
6563
6728
  }
@@ -6712,13 +6877,13 @@ function notInstalledOutcome(availability, text) {
6712
6877
  return decision === "declined" || decision === "allowed" ? { ...base, decision } : base;
6713
6878
  }
6714
6879
  function codexLspRequestContext(env = process.env, cwd = process.cwd()) {
6715
- const canonicalCwd = realpathSync8(resolve13(cwd));
6716
- const codexHome = resolve13(env["CODEX_HOME"]?.trim() || join12(homedir4(), ".codex"));
6880
+ const canonicalCwd = realpathSync9(resolve14(cwd));
6881
+ const codexHome = resolve14(env["CODEX_HOME"]?.trim() || join13(homedir4(), ".codex"));
6717
6882
  return parseLspRequestContext2({
6718
6883
  cwd: canonicalCwd,
6719
- projectConfigPaths: [join12(canonicalCwd, ".codex", "lsp-client.json")],
6720
- userConfigPath: join12(codexHome, "lsp-client.json"),
6721
- installDecisionsPath: join12(codexHome, "lsp-install-decisions.json"),
6884
+ projectConfigPaths: [join13(canonicalCwd, ".codex", "lsp-client.json")],
6885
+ userConfigPath: join13(codexHome, "lsp-client.json"),
6886
+ installDecisionsPath: join13(codexHome, "lsp-install-decisions.json"),
6722
6887
  capabilities: { installDecisionTool: true }
6723
6888
  });
6724
6889
  }