oh-my-opencode 5.1.82 → 5.1.83

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 (86) hide show
  1. package/dist/cli/index.js +15 -15
  2. package/dist/cli-node/index.js +15 -15
  3. package/dist/index.js +13 -13
  4. package/dist/skills/browser/runtime/omowright/manifest.json +1 -1
  5. package/dist/tui.js +13 -13
  6. package/package.json +13 -13
  7. package/packages/lsp-core/src/lsp/client-key.ts +14 -0
  8. package/packages/lsp-core/src/lsp/client-startup.ts +139 -0
  9. package/packages/lsp-core/src/lsp/client-wrapper.ts +4 -4
  10. package/packages/lsp-core/src/lsp/config-loader.ts +15 -0
  11. package/packages/lsp-core/src/lsp/directory-diagnostics-group-scan.test.ts +388 -0
  12. package/packages/lsp-core/src/lsp/directory-diagnostics-mixed-typescript.test.ts +124 -0
  13. package/packages/lsp-core/src/lsp/directory-diagnostics.test.ts +4 -4
  14. package/packages/lsp-core/src/lsp/directory-diagnostics.ts +38 -41
  15. package/packages/lsp-core/src/lsp/directory-group-scan.ts +124 -0
  16. package/packages/lsp-core/src/lsp/directory-server-groups.ts +84 -0
  17. package/packages/lsp-core/src/lsp/manager-acquisition.test.ts +115 -0
  18. package/packages/lsp-core/src/lsp/manager-lifecycle.test.ts +9 -9
  19. package/packages/lsp-core/src/lsp/manager-max-clients.test.ts +41 -16
  20. package/packages/lsp-core/src/lsp/manager-reaping.test.ts +119 -0
  21. package/packages/lsp-core/src/lsp/manager-test-support.ts +108 -0
  22. package/packages/lsp-core/src/lsp/manager.ts +80 -249
  23. package/packages/lsp-core/src/lsp/native-typescript.ts +88 -0
  24. package/packages/lsp-core/src/lsp/server-installation.ts +15 -7
  25. package/packages/lsp-core/src/lsp/server-resolution-typescript-native.test.ts +327 -0
  26. package/packages/lsp-core/src/lsp/server-resolution.ts +28 -2
  27. package/packages/lsp-core/src/lsp/timer-provider.ts +17 -0
  28. package/packages/lsp-core/src/lsp/typescript-project-test-support.ts +52 -0
  29. package/packages/lsp-daemon/dist/cli.js +486 -310
  30. package/packages/lsp-daemon/dist/client.js +472 -296
  31. package/packages/lsp-daemon/dist/index.js +476 -300
  32. package/packages/lsp-tools-mcp/dist/cli.js +467 -291
  33. package/packages/lsp-tools-mcp/dist/lsp/manager.js +160 -193
  34. package/packages/lsp-tools-mcp/dist/mcp.js +467 -291
  35. package/packages/lsp-tools-mcp/dist/tools.js +467 -291
  36. package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
  37. package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
  38. package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
  39. package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
  40. package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
  41. package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
  42. package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
  43. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
  44. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
  45. package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +3 -3
  46. package/packages/omo-codex/plugin/components/lsp/dist/cli.js +478 -313
  47. package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
  48. package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
  49. package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
  50. package/packages/omo-codex/plugin/components/rules/package.json +1 -1
  51. package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
  52. package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
  53. package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
  54. package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
  55. package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
  56. package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
  57. package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
  58. package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
  59. package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
  60. package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
  61. package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
  62. package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
  63. package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
  64. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
  65. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
  66. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
  67. package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
  68. package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
  69. package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
  70. package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
  71. package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
  72. package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
  73. package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
  74. package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
  75. package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
  76. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
  77. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
  78. package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
  79. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
  80. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
  81. package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
  82. package/packages/omo-codex/plugin/package-lock.json +12 -12
  83. package/packages/omo-codex/plugin/package.json +1 -1
  84. package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +1 -1
  85. package/packages/omo-codex/scripts/install-dist/install-local.mjs +2 -2
  86. package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +1 -1
@@ -445,8 +445,8 @@ function parseEndpoint(value) {
445
445
  }
446
446
 
447
447
  // src/proxy.ts
448
- import { existsSync as existsSync15, realpathSync as realpathSync7 } from "node:fs";
449
- import { basename as basename4, delimiter as delimiter4, dirname as dirname14, isAbsolute as isAbsolute6 } from "node:path";
448
+ import { existsSync as existsSync16, realpathSync as realpathSync8 } from "node:fs";
449
+ import { basename as basename4, delimiter as delimiter4, dirname as dirname16, isAbsolute as isAbsolute6 } from "node:path";
450
450
  // ../mcp-stdio-core/src/responses.ts
451
451
  function successResponse(id, result) {
452
452
  return { jsonrpc: "2.0", id, result };
@@ -756,8 +756,8 @@ function createIdleTimer(idleTimeoutMs, log, onTimeout) {
756
756
  };
757
757
  }
758
758
  // ../lsp-core/src/lsp/client-wrapper.ts
759
- import { existsSync as existsSync11, realpathSync as realpathSync6, statSync as statSync4 } from "node:fs";
760
- import { basename as basename3, dirname as dirname11, join as join5, resolve as resolve8 } from "node:path";
759
+ import { existsSync as existsSync12, realpathSync as realpathSync7, statSync as statSync5 } from "node:fs";
760
+ import { basename as basename3, dirname as dirname12, join as join6, resolve as resolve9 } from "node:path";
761
761
 
762
762
  // ../lsp-core/src/request-context.ts
763
763
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -1037,6 +1037,24 @@ var realTimerProvider = {
1037
1037
  setTimeout: (callback, delayMs) => setTimeout(callback, delayMs),
1038
1038
  clearTimeout: (handle) => clearTimeout(handle)
1039
1039
  };
1040
+ function repeatEvery(timers, intervalMs, tick) {
1041
+ let handle = null;
1042
+ const arm = () => {
1043
+ handle = timers.setTimeout(() => {
1044
+ tick();
1045
+ if (handle !== null)
1046
+ arm();
1047
+ }, intervalMs);
1048
+ if (typeof handle.unref === "function")
1049
+ handle.unref();
1050
+ };
1051
+ arm();
1052
+ return () => {
1053
+ if (handle !== null)
1054
+ timers.clearTimeout(handle);
1055
+ handle = null;
1056
+ };
1057
+ }
1040
1058
 
1041
1059
  // ../lsp-core/src/lsp/constants.ts
1042
1060
  var DEFAULT_MAX_REFERENCES = 200;
@@ -3699,30 +3717,54 @@ function abortError2(signal) {
3699
3717
  return error;
3700
3718
  }
3701
3719
 
3702
- // ../lsp-core/src/lsp/process-signal-cleanup.ts
3703
- function installProcessSignalCleanup(cleanup) {
3704
- const signals = process.platform === "win32" ? ["SIGINT", "SIGTERM", "SIGBREAK"] : ["SIGINT", "SIGTERM"];
3705
- const handler = () => {
3706
- cleanup().catch((error) => {
3707
- reportBestEffortCleanupError("signal cleanup", error);
3708
- });
3709
- };
3710
- for (const signal of signals) {
3711
- process.on(signal, handler);
3712
- }
3713
- return () => {
3714
- for (const signal of signals) {
3715
- process.removeListener(signal, handler);
3716
- }
3717
- };
3720
+ // ../lsp-core/src/lsp/client-key.ts
3721
+ function lspClientKey(root, server) {
3722
+ return JSON.stringify([root, server.id, server.command]);
3718
3723
  }
3719
3724
 
3720
- // ../lsp-core/src/lsp/manager.ts
3721
- async function stopClientBestEffort(client) {
3722
- try {
3723
- await client.stop();
3724
- } catch (error) {
3725
- reportBestEffortCleanupError("client stop", error);
3725
+ // ../lsp-core/src/lsp/client-startup.ts
3726
+ class ClientStartups {
3727
+ constructor(now, discard) {
3728
+ this.now = now;
3729
+ this.discard = discard;
3730
+ }
3731
+ begin(request) {
3732
+ const { client } = request;
3733
+ const startedAt = this.now();
3734
+ const initPromise = (async () => {
3735
+ await client.start();
3736
+ await client.initialize();
3737
+ })();
3738
+ const managed = {
3739
+ ...request,
3740
+ refCount: 0,
3741
+ pendingWaiters: 0,
3742
+ lastUsedAt: startedAt,
3743
+ initPromise,
3744
+ isInitializing: true,
3745
+ initializingSince: startedAt
3746
+ };
3747
+ initPromise.then(() => {
3748
+ managed.isInitializing = false;
3749
+ managed.initializingSince = null;
3750
+ managed.initPromise = null;
3751
+ managed.lastUsedAt = this.now();
3752
+ }, () => this.discard(managed));
3753
+ return managed;
3754
+ }
3755
+ async wait(managed, initPromise, signal) {
3756
+ managed.pendingWaiters++;
3757
+ try {
3758
+ await awaitWithSignal(initPromise, signal);
3759
+ } catch (error) {
3760
+ this.detach(managed);
3761
+ throw error;
3762
+ }
3763
+ }
3764
+ detach(managed) {
3765
+ managed.pendingWaiters--;
3766
+ if (managed.pendingWaiters === 0 && managed.refCount === 0 && managed.heldByWaiters)
3767
+ this.discard(managed);
3726
3768
  }
3727
3769
  }
3728
3770
  function awaitWithSignal(promise, signal) {
@@ -3757,36 +3799,50 @@ function awaitWithSignal(promise, signal) {
3757
3799
  });
3758
3800
  }
3759
3801
 
3802
+ // ../lsp-core/src/lsp/process-signal-cleanup.ts
3803
+ function installProcessSignalCleanup(cleanup) {
3804
+ const signals = process.platform === "win32" ? ["SIGINT", "SIGTERM", "SIGBREAK"] : ["SIGINT", "SIGTERM"];
3805
+ const handler = () => {
3806
+ cleanup().catch((error) => {
3807
+ reportBestEffortCleanupError("signal cleanup", error);
3808
+ });
3809
+ };
3810
+ for (const signal of signals) {
3811
+ process.on(signal, handler);
3812
+ }
3813
+ return () => {
3814
+ for (const signal of signals) {
3815
+ process.removeListener(signal, handler);
3816
+ }
3817
+ };
3818
+ }
3819
+
3820
+ // ../lsp-core/src/lsp/manager.ts
3821
+ async function stopClientBestEffort(client) {
3822
+ try {
3823
+ await client.stop();
3824
+ } catch (error) {
3825
+ reportBestEffortCleanupError("client stop", error);
3826
+ }
3827
+ }
3828
+
3760
3829
  class LspManager {
3761
3830
  constructor(options = {}) {
3762
3831
  this.clients = new Map;
3763
3832
  this.pendingStops = new Map;
3764
3833
  this.respawnBudgets = new Map;
3765
- this.reaperHandle = null;
3766
3834
  this.signalDisposer = null;
3767
3835
  this.disposed = false;
3768
3836
  this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS;
3769
3837
  this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS;
3770
3838
  this.maxResidentClients = options.maxResidentClients ?? MAX_RESIDENT_CLIENTS;
3771
- this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
3772
3839
  this.clientFactory = options.clientFactory ?? ((root, server) => new LspClient(root, server));
3773
3840
  this.now = options.now ?? (() => Date.now());
3774
- this.startReaper();
3841
+ this.startups = new ClientStartups(this.now, (managed) => this.discard(managed));
3842
+ const reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
3843
+ this.stopReaper = repeatEvery(options.timers ?? realTimerProvider, reaperIntervalMs, () => this.reapStale());
3775
3844
  this.signalDisposer = installProcessSignalCleanup(() => this.stopAll());
3776
3845
  }
3777
- startReaper() {
3778
- if (this.reaperHandle)
3779
- return;
3780
- this.reaperHandle = setInterval(() => {
3781
- this.reapStale();
3782
- }, this.reaperIntervalMs);
3783
- if (typeof this.reaperHandle.unref === "function") {
3784
- this.reaperHandle.unref();
3785
- }
3786
- }
3787
- getKey(root, serverId) {
3788
- return `${root}::${serverId}`;
3789
- }
3790
3846
  tombstoneStop(key, client) {
3791
3847
  const stop = stopClientBestEffort(client);
3792
3848
  this.pendingStops.set(key, stop);
@@ -3822,18 +3878,15 @@ class LspManager {
3822
3878
  budget.deadGenerations = 0;
3823
3879
  budget.exhaustedAt = null;
3824
3880
  }
3881
+ startupExpired(managed, t) {
3882
+ return managed.isInitializing && managed.initializingSince !== null && t - managed.initializingSince > this.initTimeoutMs;
3883
+ }
3825
3884
  reapStale() {
3826
3885
  const t = this.now();
3827
- for (const [key, managed] of this.clients) {
3828
- if (managed.isInitializing && managed.initializingSince !== null && t - managed.initializingSince > this.initTimeoutMs) {
3829
- this.clients.delete(key);
3830
- this.tombstoneStop(key, managed.client);
3831
- continue;
3832
- }
3833
- if (!managed.isInitializing && managed.refCount === 0 && managed.pendingWaiters === 0 && t - managed.lastUsedAt > this.idleTimeoutMs) {
3834
- this.clients.delete(key);
3835
- this.tombstoneStop(key, managed.client);
3836
- }
3886
+ for (const managed of [...this.clients.values()]) {
3887
+ const idle = !managed.isInitializing && managed.refCount === 0 && managed.pendingWaiters === 0 && t - managed.lastUsedAt > this.idleTimeoutMs;
3888
+ if (idle || this.startupExpired(managed, t))
3889
+ this.discard(managed);
3837
3890
  }
3838
3891
  }
3839
3892
  evictForAdmission() {
@@ -3841,152 +3894,96 @@ class LspManager {
3841
3894
  const victim = this.leastRecentlyUsedIdleClient();
3842
3895
  if (!victim)
3843
3896
  return;
3844
- this.clients.delete(victim.key);
3845
- this.tombstoneStop(victim.key, victim.managed.client);
3897
+ this.discard(victim);
3846
3898
  }
3847
3899
  }
3848
3900
  leastRecentlyUsedIdleClient() {
3849
3901
  let candidate = null;
3850
- for (const [key, managed] of this.clients) {
3902
+ for (const managed of this.clients.values()) {
3851
3903
  if (managed.refCount > 0 || managed.pendingWaiters > 0 || managed.isInitializing)
3852
3904
  continue;
3853
- if (candidate === null || managed.lastUsedAt < candidate.managed.lastUsedAt) {
3854
- candidate = { key, managed };
3855
- }
3905
+ if (candidate === null || managed.lastUsedAt < candidate.lastUsedAt)
3906
+ candidate = managed;
3856
3907
  }
3857
3908
  return candidate;
3858
3909
  }
3859
- async tryDeleteIfOrphaned(key, managed) {
3860
- if (managed.refCount === 0 && managed.pendingWaiters === 0 && !managed.isInitializing && this.clients.get(key) === managed) {
3861
- this.clients.delete(key);
3862
- await this.tombstoneStop(key, managed.client);
3863
- }
3910
+ discard(managed) {
3911
+ if (this.clients.get(managed.key) !== managed)
3912
+ return;
3913
+ this.clients.delete(managed.key);
3914
+ this.tombstoneStop(managed.key, managed.client);
3864
3915
  }
3865
3916
  async getClient(root, server, signal) {
3866
- if (this.disposed) {
3867
- throw new Error("LspManager has been disposed");
3868
- }
3869
- signal?.throwIfAborted();
3870
- const key = this.getKey(root, server.id);
3917
+ const key = lspClientKey(root, server);
3871
3918
  for (;; ) {
3872
- const pendingStop = this.pendingStops.get(key);
3873
- if (pendingStop === undefined)
3874
- break;
3875
- await awaitWithSignal(pendingStop, signal);
3919
+ if (this.disposed) {
3920
+ throw new Error("LspManager has been disposed");
3921
+ }
3876
3922
  signal?.throwIfAborted();
3877
- }
3878
- if (this.disposed) {
3879
- throw new Error("LspManager has been disposed");
3880
- }
3881
- let managed = this.clients.get(key);
3882
- if (managed) {
3883
- const t = this.now();
3884
- if (managed.isInitializing && managed.initializingSince !== null && t - managed.initializingSince > this.initTimeoutMs) {
3885
- this.clients.delete(key);
3886
- await this.tombstoneStop(key, managed.client);
3887
- managed = undefined;
3923
+ const pendingStop = this.pendingStops.get(key);
3924
+ if (pendingStop !== undefined) {
3925
+ await awaitWithSignal(pendingStop, signal);
3926
+ continue;
3888
3927
  }
3889
- }
3890
- if (managed) {
3891
- if (managed.initPromise) {
3892
- managed.pendingWaiters++;
3893
- try {
3894
- await awaitWithSignal(managed.initPromise, signal);
3895
- } catch (err) {
3896
- managed.pendingWaiters--;
3897
- await this.tryDeleteIfOrphaned(key, managed);
3898
- throw err;
3928
+ let managed = this.clients.get(key);
3929
+ if (managed !== undefined && this.startupExpired(managed, this.now())) {
3930
+ this.discard(managed);
3931
+ continue;
3932
+ }
3933
+ if (managed === undefined) {
3934
+ this.evictForAdmission();
3935
+ this.ensureRespawnAllowed(key, root, server.id);
3936
+ managed = this.startClient(key, root, server, true);
3937
+ }
3938
+ const { initPromise } = managed;
3939
+ if (initPromise !== null) {
3940
+ await this.startups.wait(managed, initPromise, signal);
3941
+ if (signal?.aborted) {
3942
+ this.startups.detach(managed);
3943
+ signal.throwIfAborted();
3899
3944
  }
3900
3945
  managed.pendingWaiters--;
3901
3946
  }
3902
- if (signal?.aborted) {
3903
- await this.tryDeleteIfOrphaned(key, managed);
3904
- signal.throwIfAborted();
3905
- }
3947
+ if (this.clients.get(key) !== managed)
3948
+ continue;
3906
3949
  if (!managed.client.isAlive()) {
3907
3950
  this.recordDeadGeneration(key);
3908
- if (this.clients.get(key) === managed) {
3909
- this.clients.delete(key);
3910
- }
3911
- await this.tombstoneStop(key, managed.client);
3912
- return this.getClient(root, server, signal);
3951
+ this.discard(managed);
3952
+ continue;
3913
3953
  }
3914
3954
  this.markHealthyGeneration(key);
3915
3955
  managed.refCount++;
3916
3956
  managed.lastUsedAt = this.now();
3917
3957
  return managed.client;
3918
3958
  }
3919
- this.evictForAdmission();
3920
- this.ensureRespawnAllowed(key, root, server.id);
3959
+ }
3960
+ startClient(key, root, server, heldByWaiters) {
3921
3961
  const client = this.clientFactory(root, server);
3922
- const initStartedAt = this.now();
3923
- const initPromise = (async () => {
3924
- await client.start();
3925
- await client.initialize();
3926
- })();
3927
- const newManaged = {
3928
- client,
3929
- refCount: 0,
3930
- pendingWaiters: 1,
3931
- lastUsedAt: initStartedAt,
3932
- initPromise,
3933
- isInitializing: true,
3934
- initializingSince: initStartedAt
3935
- };
3936
- this.clients.set(key, newManaged);
3937
- try {
3938
- await awaitWithSignal(initPromise, signal);
3939
- } catch (err) {
3940
- newManaged.pendingWaiters--;
3941
- if (this.clients.get(key) === newManaged) {
3942
- this.clients.delete(key);
3943
- }
3944
- await this.tombstoneStop(key, client);
3945
- throw err;
3946
- }
3947
- newManaged.pendingWaiters--;
3948
- newManaged.isInitializing = false;
3949
- newManaged.initializingSince = null;
3950
- newManaged.initPromise = null;
3951
- if (signal?.aborted) {
3952
- await this.tryDeleteIfOrphaned(key, newManaged);
3953
- signal.throwIfAborted();
3954
- }
3955
- if (!client.isAlive()) {
3956
- this.recordDeadGeneration(key);
3957
- if (this.clients.get(key) === newManaged) {
3958
- this.clients.delete(key);
3959
- }
3960
- await this.tombstoneStop(key, client);
3961
- return this.getClient(root, server, signal);
3962
- }
3963
- this.markHealthyGeneration(key);
3964
- newManaged.refCount++;
3965
- newManaged.lastUsedAt = this.now();
3966
- return client;
3962
+ const managed = this.startups.begin({ key, root, serverId: server.id, client, heldByWaiters });
3963
+ this.clients.set(key, managed);
3964
+ return managed;
3967
3965
  }
3968
- releaseClient(root, serverId) {
3969
- const key = this.getKey(root, serverId);
3970
- const managed = this.clients.get(key);
3966
+ releaseClient(root, server, client) {
3967
+ const managed = this.clients.get(lspClientKey(root, server));
3968
+ if (client !== undefined && managed?.client !== client)
3969
+ return;
3971
3970
  if (managed && managed.refCount > 0) {
3972
3971
  managed.refCount--;
3973
3972
  managed.lastUsedAt = this.now();
3974
3973
  }
3975
3974
  }
3976
- invalidateClient(root, serverId, client) {
3977
- const key = this.getKey(root, serverId);
3978
- const managed = this.clients.get(key);
3975
+ invalidateClient(root, server, client) {
3976
+ const managed = this.clients.get(lspClientKey(root, server));
3979
3977
  if (!managed)
3980
3978
  return;
3981
3979
  if (client && managed.client !== client)
3982
3980
  return;
3983
- this.clients.delete(key);
3984
- this.tombstoneStop(key, managed.client);
3981
+ this.discard(managed);
3985
3982
  }
3986
3983
  warmupClient(root, server) {
3987
3984
  if (this.disposed)
3988
3985
  return;
3989
- const key = this.getKey(root, server.id);
3986
+ const key = lspClientKey(root, server);
3990
3987
  if (this.clients.has(key) || this.pendingStops.has(key))
3991
3988
  return;
3992
3989
  this.evictForAdmission();
@@ -3995,45 +3992,18 @@ class LspManager {
3995
3992
  } catch {
3996
3993
  return;
3997
3994
  }
3998
- const client = this.clientFactory(root, server);
3999
- const initStartedAt = this.now();
4000
- const initPromise = (async () => {
4001
- await client.start();
4002
- await client.initialize();
4003
- })();
4004
- const managed = {
4005
- client,
4006
- refCount: 0,
4007
- pendingWaiters: 0,
4008
- lastUsedAt: initStartedAt,
4009
- initPromise,
4010
- isInitializing: true,
4011
- initializingSince: initStartedAt
4012
- };
4013
- this.clients.set(key, managed);
4014
- initPromise.then(() => {
4015
- managed.isInitializing = false;
4016
- managed.initializingSince = null;
4017
- managed.initPromise = null;
4018
- managed.lastUsedAt = this.now();
4019
- }, () => {
4020
- if (this.clients.get(key) === managed) {
4021
- this.clients.delete(key);
4022
- }
4023
- this.tombstoneStop(key, client);
4024
- });
3995
+ this.startClient(key, root, server, false);
4025
3996
  }
4026
- isServerInitializing(root, serverId) {
4027
- const managed = this.clients.get(this.getKey(root, serverId));
3997
+ isServerInitializing(root, server) {
3998
+ const managed = this.clients.get(lspClientKey(root, server));
4028
3999
  return managed?.isInitializing ?? false;
4029
4000
  }
4030
4001
  getSnapshot() {
4031
4002
  const snapshots = [];
4032
- for (const [key, managed] of this.clients) {
4033
- const [root, serverId] = key.split("::");
4003
+ for (const managed of this.clients.values()) {
4034
4004
  snapshots.push({
4035
- root,
4036
- serverId,
4005
+ root: managed.root,
4006
+ serverId: managed.serverId,
4037
4007
  refCount: managed.refCount,
4038
4008
  pendingWaiters: managed.pendingWaiters,
4039
4009
  lastUsedAt: managed.lastUsedAt,
@@ -4044,18 +4014,15 @@ class LspManager {
4044
4014
  }
4045
4015
  return snapshots;
4046
4016
  }
4047
- hasClient(root, serverId) {
4048
- return this.clients.has(this.getKey(root, serverId));
4017
+ hasClient(root, server) {
4018
+ return this.clients.has(lspClientKey(root, server));
4049
4019
  }
4050
4020
  clientCount() {
4051
4021
  return this.clients.size;
4052
4022
  }
4053
4023
  async stopAll() {
4054
4024
  this.disposed = true;
4055
- if (this.reaperHandle) {
4056
- clearInterval(this.reaperHandle);
4057
- this.reaperHandle = null;
4058
- }
4025
+ this.stopReaper();
4059
4026
  if (this.signalDisposer) {
4060
4027
  this.signalDisposer();
4061
4028
  this.signalDisposer = null;
@@ -4424,6 +4391,7 @@ function getMergedServers() {
4424
4391
  extensions: config.extensions,
4425
4392
  priority: -100,
4426
4393
  source: "builtin",
4394
+ inheritsBuiltinCommand: true,
4427
4395
  ...config.initialization === undefined ? {} : { initialization: config.initialization }
4428
4396
  });
4429
4397
  }
@@ -4449,8 +4417,11 @@ function createServerFromEntry(id, entry, source) {
4449
4417
  command: builtin.command,
4450
4418
  extensions: entry.extensions ?? builtin.extensions,
4451
4419
  priority: entry.priority ?? 0,
4452
- source
4420
+ source,
4421
+ inheritsBuiltinCommand: true
4453
4422
  });
4423
+ if (entry.initialization !== undefined)
4424
+ server.configuredInitialization = entry.initialization;
4454
4425
  const initialization = mergeInitialization(builtin.initialization, entry.initialization);
4455
4426
  if (initialization !== undefined) {
4456
4427
  server.initialization = initialization;
@@ -4463,7 +4434,8 @@ function createServerFromEntry(id, entry, source) {
4463
4434
  command: entry.command,
4464
4435
  extensions: entry.extensions,
4465
4436
  priority: entry.priority ?? 0,
4466
- source
4437
+ source,
4438
+ inheritsBuiltinCommand: false
4467
4439
  });
4468
4440
  applyOptionalServerFields(server, entry);
4469
4441
  return server;
@@ -4475,7 +4447,8 @@ function createServerFromEntry(id, entry, source) {
4475
4447
  command: entry.command ?? builtin.command,
4476
4448
  extensions: entry.extensions ?? builtin.extensions,
4477
4449
  priority: entry.priority ?? 0,
4478
- source
4450
+ source,
4451
+ inheritsBuiltinCommand: entry.command === undefined
4479
4452
  });
4480
4453
  applyOptionalServerFields(server, entry);
4481
4454
  const builtinInitialization = entry.command === undefined ? builtin.initialization : undefined;
@@ -4498,7 +4471,8 @@ function createServer(input) {
4498
4471
  command: input.command,
4499
4472
  extensions: input.extensions,
4500
4473
  priority: input.priority,
4501
- source: input.source
4474
+ source: input.source,
4475
+ inheritsBuiltinCommand: input.inheritsBuiltinCommand
4502
4476
  };
4503
4477
  if (input.env !== undefined) {
4504
4478
  server.env = input.env;
@@ -4514,6 +4488,7 @@ function applyOptionalServerFields(server, entry) {
4514
4488
  }
4515
4489
  if (entry.initialization !== undefined) {
4516
4490
  server.initialization = entry.initialization;
4491
+ server.configuredInitialization = entry.initialization;
4517
4492
  }
4518
4493
  }
4519
4494
  function isConfigJson(value) {
@@ -4605,14 +4580,24 @@ function readHead(path) {
4605
4580
  }
4606
4581
  }
4607
4582
 
4583
+ // ../lsp-core/src/lsp/native-typescript.ts
4584
+ import { existsSync as existsSync11, realpathSync as realpathSync6, statSync as statSync4 } from "node:fs";
4585
+ import { dirname as dirname11, join as join5, resolve as resolve8 } from "node:path";
4586
+
4608
4587
  // ../lsp-core/src/lsp/server-installation.ts
4609
4588
  import { existsSync as existsSync10 } from "node:fs";
4610
4589
  import { delimiter as delimiter3, dirname as dirname10, isAbsolute as isAbsolute3, join as join4, resolve as resolve7 } from "node:path";
4590
+ var NODE_PROJECT_MARKERS = [
4591
+ "package.json",
4592
+ "bun.lock",
4593
+ "bun.lockb",
4594
+ "package-lock.json",
4595
+ "yarn.lock",
4596
+ "pnpm-lock.yaml"
4597
+ ];
4598
+ var NODE_LOCAL_BIN_DIR = join4("node_modules", ".bin");
4611
4599
  var LOCAL_BIN_RULES = [
4612
- {
4613
- markers: ["package.json", "bun.lock", "bun.lockb", "package-lock.json", "yarn.lock", "pnpm-lock.yaml"],
4614
- binDirs: [join4("node_modules", ".bin")]
4615
- },
4600
+ { markers: NODE_PROJECT_MARKERS, binDirs: [NODE_LOCAL_BIN_DIR] },
4616
4601
  {
4617
4602
  markers: [
4618
4603
  "pyproject.toml",
@@ -4740,6 +4725,57 @@ function isServerInstalled(command, workingDirectory, options = {}) {
4740
4725
  return resolveServerBinary(command, workingDirectory, options) !== null;
4741
4726
  }
4742
4727
 
4728
+ // ../lsp-core/src/lsp/native-typescript.ts
4729
+ function nativeTypescriptSearchDirectory(targetPath, workingDirectory) {
4730
+ try {
4731
+ const session = realpathSync6(workingDirectory);
4732
+ if (targetPath === undefined)
4733
+ return session;
4734
+ const target = canonicalizeExistingOrNearestAncestor(resolve8(workingDirectory, targetPath));
4735
+ if (!isPathInside(session, target))
4736
+ return session;
4737
+ return statSync4(target, { throwIfNoEntry: false })?.isDirectory() === true ? target : dirname11(target);
4738
+ } catch {
4739
+ return workingDirectory;
4740
+ }
4741
+ }
4742
+ function nativeTypescriptCommand(server, searchDirectory) {
4743
+ if (server.id !== "typescript" || !server.inheritsBuiltinCommand)
4744
+ return null;
4745
+ const found = findProjectTsc(searchDirectory);
4746
+ if (found === null)
4747
+ return null;
4748
+ const speaksLsp = !existsSync11(join5(found.packageDir, "lib", "tsserver.js"));
4749
+ return speaksLsp ? [found.tsc, "--lsp", "--stdio"] : null;
4750
+ }
4751
+ function findProjectTsc(searchDirectory) {
4752
+ const suffixes = executableSuffixes(process.platform, undefined);
4753
+ let current = searchDirectory;
4754
+ for (;; ) {
4755
+ if (NODE_PROJECT_MARKERS.some((marker) => probe(join5(current, marker)))) {
4756
+ const binDir = join5(current, NODE_LOCAL_BIN_DIR);
4757
+ const tsc = probeWithSuffixes(binDir, "tsc", suffixes);
4758
+ const packageDir = join5(binDir, "..", "typescript");
4759
+ if (tsc !== null && isRealDirectory(binDir) && existsSync11(join5(packageDir, "package.json"))) {
4760
+ return { tsc, packageDir };
4761
+ }
4762
+ }
4763
+ if (probe(join5(current, ".git")))
4764
+ return null;
4765
+ const parent = dirname11(current);
4766
+ if (parent === current)
4767
+ return null;
4768
+ current = parent;
4769
+ }
4770
+ }
4771
+ function isRealDirectory(directory) {
4772
+ try {
4773
+ return realpathSync6(directory) === directory;
4774
+ } catch {
4775
+ return false;
4776
+ }
4777
+ }
4778
+
4743
4779
  // ../lsp-core/src/lsp/server-resolution.ts
4744
4780
  function withResolvedCommand(command, binaryPath) {
4745
4781
  return [binaryPath, ...command.slice(1)];
@@ -4748,12 +4784,27 @@ function usesBuiltinCommand(id, command) {
4748
4784
  const builtin = BUILTIN_SERVERS[id]?.command;
4749
4785
  return builtin !== undefined && builtin.length === command.length && builtin.every((part, index) => part === command[index]);
4750
4786
  }
4751
- function findServerForExtension(ext) {
4787
+ function findServerForExtension(ext, targetPath) {
4752
4788
  const servers = getMergedServers();
4753
4789
  const workingDirectory = contextCwd();
4790
+ const searchDirectory = nativeTypescriptSearchDirectory(targetPath, workingDirectory);
4754
4791
  for (const server of servers) {
4755
4792
  if (!server.extensions.includes(ext))
4756
4793
  continue;
4794
+ const nativeTypescript = nativeTypescriptCommand(server, searchDirectory);
4795
+ if (nativeTypescript !== null) {
4796
+ return {
4797
+ status: "found",
4798
+ server: {
4799
+ id: server.id,
4800
+ command: withHostJsRuntime(server.id, nativeTypescript),
4801
+ extensions: server.extensions,
4802
+ priority: server.priority,
4803
+ ...server.env === undefined ? {} : { env: server.env },
4804
+ ...server.configuredInitialization === undefined ? {} : { initialization: server.configuredInitialization }
4805
+ }
4806
+ };
4807
+ }
4757
4808
  const binaryPath = resolveServerBinary(server.command, workingDirectory);
4758
4809
  if (binaryPath !== null) {
4759
4810
  const resolvedServer = {
@@ -4806,6 +4857,7 @@ function getAllServers() {
4806
4857
  const servers = getMergedServers();
4807
4858
  const disabled = getDisabledServerIds();
4808
4859
  const workingDirectory = contextCwd();
4860
+ const nativeSearchDirectory = nativeTypescriptSearchDirectory(undefined, workingDirectory);
4809
4861
  const result = [];
4810
4862
  const seen = new Set;
4811
4863
  for (const server of servers) {
@@ -4813,7 +4865,7 @@ function getAllServers() {
4813
4865
  continue;
4814
4866
  result.push({
4815
4867
  id: server.id,
4816
- installed: isServerInstalled(server.command, workingDirectory),
4868
+ installed: isServerInstalled(server.command, workingDirectory) || nativeTypescriptCommand(server, nativeSearchDirectory) !== null,
4817
4869
  extensions: server.extensions,
4818
4870
  disabled: false,
4819
4871
  source: server.source,
@@ -4840,7 +4892,7 @@ function getAllServers() {
4840
4892
  // ../lsp-core/src/lsp/client-wrapper.ts
4841
4893
  function isDirectoryPath(filePath) {
4842
4894
  try {
4843
- return statSync4(filePath).isDirectory();
4895
+ return statSync5(filePath).isDirectory();
4844
4896
  } catch {
4845
4897
  return false;
4846
4898
  }
@@ -4850,7 +4902,7 @@ function findWorkspaceRoot(filePath) {
4850
4902
  const abs = resolveReadablePathInsideContext(filePath);
4851
4903
  let dir = abs;
4852
4904
  if (!isDirectoryPath(dir)) {
4853
- dir = dirname11(dir);
4905
+ dir = dirname12(dir);
4854
4906
  }
4855
4907
  if (!isPathInside(cwd, abs))
4856
4908
  return findWorkspaceRootOutsideContext(dir);
@@ -4859,7 +4911,7 @@ function findWorkspaceRoot(filePath) {
4859
4911
  while (isPathInside(cwd, dir)) {
4860
4912
  const canonicalDir = existingDirectoryInsideContext(dir, cwd);
4861
4913
  if (canonicalDir !== undefined) {
4862
- if (existsSync11(join5(dir, GIT_WORKSPACE_MARKER))) {
4914
+ if (existsSync12(join6(dir, GIT_WORKSPACE_MARKER))) {
4863
4915
  return canonicalDir;
4864
4916
  }
4865
4917
  if (nearestPackageRoot === undefined && hasProjectWorkspaceMarker(dir)) {
@@ -4868,16 +4920,16 @@ function findWorkspaceRoot(filePath) {
4868
4920
  }
4869
4921
  if (dir === cwd)
4870
4922
  break;
4871
- dir = dirname11(dir);
4923
+ dir = dirname12(dir);
4872
4924
  }
4873
4925
  return nearestPackageRoot ?? fallbackRoot;
4874
4926
  }
4875
4927
  function hasProjectWorkspaceMarker(directory) {
4876
- return PROJECT_WORKSPACE_MARKERS.some((marker) => existsSync11(join5(directory, marker)));
4928
+ return PROJECT_WORKSPACE_MARKERS.some((marker) => existsSync12(join6(directory, marker)));
4877
4929
  }
4878
4930
  function resolveReadablePathInsideContext(filePath) {
4879
4931
  const cwd = contextCwd();
4880
- const abs = resolve8(cwd, filePath);
4932
+ const abs = resolve9(cwd, filePath);
4881
4933
  if (isPathInside(cwd, abs))
4882
4934
  return abs;
4883
4935
  const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
@@ -4898,12 +4950,12 @@ function rebaseThroughCanonicalAncestor(path, cwd) {
4898
4950
  let current = path;
4899
4951
  const suffix = [];
4900
4952
  while (true) {
4901
- if (existsSync11(current)) {
4902
- const canonical = realpathSync6(current);
4953
+ if (existsSync12(current)) {
4954
+ const canonical = realpathSync7(current);
4903
4955
  if (isPathInside(cwd, canonical))
4904
- return suffix.length === 0 ? canonical : join5(canonical, ...suffix);
4956
+ return suffix.length === 0 ? canonical : join6(canonical, ...suffix);
4905
4957
  }
4906
- const parent = dirname11(current);
4958
+ const parent = dirname12(current);
4907
4959
  if (parent === current)
4908
4960
  return;
4909
4961
  suffix.unshift(basename3(current));
@@ -4911,10 +4963,10 @@ function rebaseThroughCanonicalAncestor(path, cwd) {
4911
4963
  }
4912
4964
  }
4913
4965
  function existingDirectoryInsideContext(directory, cwd) {
4914
- if (!existsSync11(directory))
4966
+ if (!existsSync12(directory))
4915
4967
  return;
4916
- const canonical = realpathSync6(directory);
4917
- if (!statSync4(canonical).isDirectory())
4968
+ const canonical = realpathSync7(directory);
4969
+ if (!statSync5(canonical).isDirectory())
4918
4970
  return;
4919
4971
  return isPathInside(cwd, canonical) ? canonical : undefined;
4920
4972
  }
@@ -4926,7 +4978,7 @@ function nearestExistingDirectoryInsideContext(directory, cwd) {
4926
4978
  return canonical;
4927
4979
  if (current === cwd)
4928
4980
  return;
4929
- current = dirname11(current);
4981
+ current = dirname12(current);
4930
4982
  }
4931
4983
  return;
4932
4984
  }
@@ -5026,7 +5078,7 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
5026
5078
  throw new LspInvalidPathError("Directory paths are not supported by this LSP tool. " + "Use lsp.diagnostics with a directory path for directory diagnostics.");
5027
5079
  }
5028
5080
  const ext = effectiveExtension(absPath);
5029
- const result = findServerForExtension(ext);
5081
+ const result = findServerForExtension(ext, absPath);
5030
5082
  if (result.status !== "found") {
5031
5083
  throw new LspServerLookupError(formatServerLookupError(result), result);
5032
5084
  }
@@ -5039,25 +5091,153 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
5039
5091
  return await fn(client, root, absPath);
5040
5092
  } catch (err) {
5041
5093
  if (allowRetry && READ_ONLY_TOOLS.has(toolName) && isLspDeadConnectionError(err)) {
5042
- manager.invalidateClient(root, server.id, client);
5094
+ manager.invalidateClient(root, server, client);
5043
5095
  return acquireAndCall(false);
5044
5096
  }
5045
5097
  if (err instanceof LspRequestTimeoutError) {
5046
- if (manager.isServerInitializing(root, server.id)) {
5098
+ if (manager.isServerInitializing(root, server)) {
5047
5099
  throw new LspServerInitializingError(err);
5048
5100
  }
5049
5101
  }
5050
5102
  throw err;
5051
5103
  } finally {
5052
- manager.releaseClient(root, server.id);
5104
+ manager.releaseClient(root, server, client);
5053
5105
  }
5054
5106
  };
5055
5107
  return acquireAndCall(true);
5056
5108
  }
5057
5109
 
5058
5110
  // ../lsp-core/src/lsp/directory-diagnostics.ts
5059
- import { existsSync as existsSync12, lstatSync as lstatSync6, readdirSync as readdirSync3 } from "node:fs";
5060
- import { join as join6, resolve as resolve9 } from "node:path";
5111
+ import { existsSync as existsSync13, lstatSync as lstatSync6, readdirSync as readdirSync3 } from "node:fs";
5112
+ import { join as join7, resolve as resolve10 } from "node:path";
5113
+
5114
+ // ../lsp-core/src/lsp/directory-group-scan.ts
5115
+ async function scanServedGroups(options) {
5116
+ const { groups, signal } = options;
5117
+ const limit = Math.max(1, options.maxConcurrency);
5118
+ const fileSlots = createSlots(limit);
5119
+ let nextGroup = 0;
5120
+ let startedGroups = 0;
5121
+ let firstError;
5122
+ const runners = Array.from({ length: Math.min(limit, groups.length) }, async () => {
5123
+ for (;; ) {
5124
+ if (signal?.aborted)
5125
+ return;
5126
+ const group = groups[nextGroup];
5127
+ nextGroup += 1;
5128
+ if (group === undefined)
5129
+ return;
5130
+ let client;
5131
+ try {
5132
+ client = await acquireWithinInitTimeout(options, group);
5133
+ } catch (error) {
5134
+ if (signal?.aborted)
5135
+ return;
5136
+ firstError ??= error;
5137
+ options.onGroupUnavailable(group, error instanceof Error ? error.message : String(error));
5138
+ continue;
5139
+ }
5140
+ startedGroups += 1;
5141
+ try {
5142
+ await Promise.all(group.files.map(async (file) => {
5143
+ const release = await fileSlots.acquire();
5144
+ try {
5145
+ if (!signal?.aborted)
5146
+ await options.checkFile(client, file);
5147
+ } finally {
5148
+ release();
5149
+ }
5150
+ }));
5151
+ } finally {
5152
+ options.manager.releaseClient(group.root, group.server, client);
5153
+ }
5154
+ }
5155
+ });
5156
+ await Promise.all(runners);
5157
+ signal?.throwIfAborted();
5158
+ if (startedGroups === 0 && firstError !== undefined)
5159
+ throw firstError;
5160
+ }
5161
+ async function acquireWithinInitTimeout(options, group) {
5162
+ const { signal } = options;
5163
+ const timers = options.timers ?? realTimerProvider;
5164
+ const controller = new AbortController;
5165
+ const forwardAbort = () => controller.abort(signal?.reason);
5166
+ signal?.addEventListener("abort", forwardAbort, { once: true });
5167
+ if (signal?.aborted)
5168
+ forwardAbort();
5169
+ let timedOut = false;
5170
+ const timer = timers.setTimeout(() => {
5171
+ timedOut = true;
5172
+ controller.abort();
5173
+ }, INIT_TIMEOUT_MS);
5174
+ try {
5175
+ return await options.manager.getClient(group.root, group.server, controller.signal);
5176
+ } catch (error) {
5177
+ if (timedOut && signal?.aborted !== true) {
5178
+ throw new Error(`${group.server.id} did not start within ${INIT_TIMEOUT_MS}ms`);
5179
+ }
5180
+ throw error;
5181
+ } finally {
5182
+ timers.clearTimeout(timer);
5183
+ signal?.removeEventListener("abort", forwardAbort);
5184
+ }
5185
+ }
5186
+ function createSlots(limit) {
5187
+ let free = limit;
5188
+ const waiting = [];
5189
+ const release = () => {
5190
+ const next = waiting.shift();
5191
+ if (next === undefined)
5192
+ free += 1;
5193
+ else
5194
+ next();
5195
+ };
5196
+ return {
5197
+ acquire() {
5198
+ if (free > 0) {
5199
+ free -= 1;
5200
+ return Promise.resolve(release);
5201
+ }
5202
+ return new Promise((resolve) => waiting.push(() => resolve(release)));
5203
+ }
5204
+ };
5205
+ }
5206
+
5207
+ // ../lsp-core/src/lsp/directory-server-groups.ts
5208
+ import { dirname as dirname13 } from "node:path";
5209
+ function groupFilesByClient(files, extension, fixed = {}) {
5210
+ const byDirectory = new Map;
5211
+ const served = new Map;
5212
+ const unserved = new Map;
5213
+ for (const file of files) {
5214
+ const directory = dirname13(file);
5215
+ let resolution = byDirectory.get(directory);
5216
+ if (resolution === undefined) {
5217
+ resolution = resolveDirectory(directory, extension, fixed);
5218
+ byDirectory.set(directory, resolution);
5219
+ }
5220
+ if (resolution.kind === "served") {
5221
+ const group = served.get(resolution.key) ?? { root: resolution.root, server: resolution.server, files: [] };
5222
+ group.files.push(file);
5223
+ served.set(resolution.key, group);
5224
+ } else {
5225
+ const group = unserved.get(resolution.key) ?? { lookup: resolution.lookup, files: [] };
5226
+ group.files.push(file);
5227
+ unserved.set(resolution.key, group);
5228
+ }
5229
+ }
5230
+ return { served: [...served.values()], unserved: [...unserved.values()] };
5231
+ }
5232
+ function resolveDirectory(directory, extension, fixed) {
5233
+ const lookup = fixed.server === undefined ? findServerForExtension(extension, directory) : { status: "found", server: fixed.server };
5234
+ if (lookup.status !== "found") {
5235
+ const serverId = lookup.status === "not_installed" ? lookup.server.id : "";
5236
+ return { kind: "unserved", key: JSON.stringify([lookup.status, serverId]), lookup };
5237
+ }
5238
+ const root = fixed.workspaceRoot ?? findWorkspaceRoot(directory);
5239
+ return { kind: "served", key: lspClientKey(root, lookup.server), root, server: lookup.server };
5240
+ }
5061
5241
 
5062
5242
  // ../lsp-core/src/lsp/formatters.ts
5063
5243
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -5187,7 +5367,7 @@ function collectFilesWithExtension(dir, extension, maxFiles) {
5187
5367
  for (const entry of entries) {
5188
5368
  if (files.length >= maxFiles)
5189
5369
  return;
5190
- const fullPath = join6(currentDir, entry);
5370
+ const fullPath = join7(currentDir, entry);
5191
5371
  let stat;
5192
5372
  try {
5193
5373
  stat = lstatSync6(fullPath);
@@ -5212,15 +5392,10 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
5212
5392
  if (!extension.startsWith(".")) {
5213
5393
  throw new LspInvalidPathError(`Extension must start with a dot (e.g., ".ts", not "${extension}"). Use ".${extension}" instead.`);
5214
5394
  }
5215
- const absDir = resolve9(options.workspaceRoot ?? contextCwd(), directory);
5216
- if (!existsSync12(absDir)) {
5395
+ const absDir = resolve10(options.workspaceRoot ?? contextCwd(), directory);
5396
+ if (!existsSync13(absDir)) {
5217
5397
  throw new LspInvalidPathError(`Directory does not exist: ${absDir}`);
5218
5398
  }
5219
- const serverResult = options.server === undefined ? findServerForExtension(extension) : { status: "found", server: options.server };
5220
- if (serverResult.status !== "found") {
5221
- throw new LspServerLookupError(formatServerLookupError(serverResult));
5222
- }
5223
- const server = serverResult.server;
5224
5399
  const allFiles = (options.listFiles ?? collectFilesWithExtension)(absDir, extension, maxFiles + 1);
5225
5400
  const wasCapped = allFiles.length > maxFiles;
5226
5401
  const filesToProcess = allFiles.slice(0, maxFiles);
@@ -5234,42 +5409,43 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
5234
5409
  `);
5235
5410
  return { output, totalDiagnostics: 0, fileFailures: [] };
5236
5411
  }
5237
- const root = options.workspaceRoot ?? findWorkspaceRoot(absDir);
5412
+ const groups = groupFilesByClient(filesToProcess, extension, {
5413
+ ...options.server === undefined ? {} : { server: options.server },
5414
+ ...options.workspaceRoot === undefined ? {} : { workspaceRoot: options.workspaceRoot }
5415
+ });
5416
+ const firstUnserved = groups.unserved[0];
5417
+ if (groups.served.length === 0 && firstUnserved !== undefined) {
5418
+ throw new LspServerLookupError(formatServerLookupError(firstUnserved.lookup));
5419
+ }
5238
5420
  const manager = options.manager ?? getLspManager();
5239
5421
  const allDiagnostics = [];
5240
5422
  const fileErrors = [];
5241
5423
  const maxConcurrency = Math.max(1, options.maxConcurrency ?? DIRECTORY_DIAGNOSTICS_MAX_CONCURRENCY);
5424
+ for (const group of groups.unserved) {
5425
+ const error = formatServerLookupError(group.lookup).split(`
5426
+ `)[0] ?? "No LSP server";
5427
+ fileErrors.push(...group.files.map((file) => ({ file, error })));
5428
+ }
5242
5429
  options.signal?.throwIfAborted();
5243
- const client = await manager.getClient(root, server, options.signal);
5244
- try {
5245
- let nextIndex = 0;
5246
- const workers = Array.from({ length: Math.min(maxConcurrency, filesToProcess.length) }, async () => {
5247
- for (;; ) {
5248
- if (options.signal?.aborted)
5249
- return;
5250
- const file = filesToProcess[nextIndex];
5251
- nextIndex += 1;
5252
- if (file === undefined)
5253
- return;
5254
- try {
5255
- const result = await client.diagnostics(file, options.signal);
5256
- const filtered = filterDiagnosticsBySeverity(result.items, severity);
5257
- allDiagnostics.push(...filtered.map((diagnostic) => ({
5258
- filePath: file,
5259
- diagnostic
5260
- })));
5261
- } catch (e) {
5262
- fileErrors.push({
5263
- file,
5264
- error: e instanceof Error ? e.message : String(e)
5265
- });
5266
- }
5430
+ await scanServedGroups({
5431
+ manager,
5432
+ groups: groups.served,
5433
+ maxConcurrency,
5434
+ ...options.signal === undefined ? {} : { signal: options.signal },
5435
+ ...options.timers === undefined ? {} : { timers: options.timers },
5436
+ onGroupUnavailable: (group, error) => {
5437
+ fileErrors.push(...group.files.map((file) => ({ file, error })));
5438
+ },
5439
+ checkFile: async (client, file) => {
5440
+ try {
5441
+ const result = await client.diagnostics(file, options.signal);
5442
+ const filtered = filterDiagnosticsBySeverity(result.items, severity);
5443
+ allDiagnostics.push(...filtered.map((diagnostic) => ({ filePath: file, diagnostic })));
5444
+ } catch (e) {
5445
+ fileErrors.push({ file, error: e instanceof Error ? e.message : String(e) });
5267
5446
  }
5268
- });
5269
- await Promise.all(workers);
5270
- } finally {
5271
- manager.releaseClient(root, server.id);
5272
- }
5447
+ }
5448
+ });
5273
5449
  const displayDiagnostics = allDiagnostics.slice(0, DEFAULT_MAX_DIAGNOSTICS);
5274
5450
  const wasDiagCapped = allDiagnostics.length > DEFAULT_MAX_DIAGNOSTICS;
5275
5451
  const lines = [
@@ -5300,7 +5476,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
5300
5476
 
5301
5477
  // ../lsp-core/src/lsp/infer-extension.ts
5302
5478
  import { lstatSync as lstatSync7, readdirSync as readdirSync4 } from "node:fs";
5303
- import { join as join7 } from "node:path";
5479
+ import { join as join8 } from "node:path";
5304
5480
  var SKIP_DIRECTORIES2 = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]);
5305
5481
  var MAX_SCAN_ENTRIES = 500;
5306
5482
  function inferExtensionFromDirectory(directory) {
@@ -5318,7 +5494,7 @@ function inferExtensionFromDirectory(directory) {
5318
5494
  for (const entry of entries) {
5319
5495
  if (scanned >= MAX_SCAN_ENTRIES)
5320
5496
  return;
5321
- const fullPath = join7(dir, entry);
5497
+ const fullPath = join8(dir, entry);
5322
5498
  let stat;
5323
5499
  try {
5324
5500
  stat = lstatSync7(fullPath);
@@ -5437,7 +5613,7 @@ function missingDependencyAvailability(error) {
5437
5613
  }
5438
5614
 
5439
5615
  // ../lsp-core/src/lsp/bun-command-output.ts
5440
- import { resolve as resolve10 } from "node:path";
5616
+ import { resolve as resolve11 } from "node:path";
5441
5617
  var TSC_LINE = /^(.+?)\((\d+),(\d+)\): (error|warning|message) (TS\d+): (.*)$/;
5442
5618
  var TSC_SEVERITY = { error: 1, warning: 2, message: 3 };
5443
5619
  function parseBunCheckOutput(stdout, cwd) {
@@ -5448,7 +5624,7 @@ function parseBunCheckOutput(stdout, cwd) {
5448
5624
  const [, path, lineNumber, column, severity, code, message] = match;
5449
5625
  const start = { line: Number(lineNumber) - 1, character: Number(column) - 1 };
5450
5626
  results.push({
5451
- file: resolve10(cwd, path ?? ""),
5627
+ file: resolve11(cwd, path ?? ""),
5452
5628
  diagnostic: {
5453
5629
  range: { start, end: start },
5454
5630
  severity: TSC_SEVERITY[severity ?? "error"] ?? 1,
@@ -5507,9 +5683,9 @@ function parseBunLintJson(stdout) {
5507
5683
 
5508
5684
  // ../lsp-core/src/lsp/bun-project-checks.ts
5509
5685
  import { spawn as spawn2 } from "node:child_process";
5510
- import { existsSync as existsSync13, mkdtempSync, readFileSync as readFileSync8, rmSync as rmSync2, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
5686
+ import { existsSync as existsSync14, mkdtempSync, readFileSync as readFileSync8, rmSync as rmSync2, statSync as statSync6, writeFileSync as writeFileSync3 } from "node:fs";
5511
5687
  import { homedir as homedir2, tmpdir } from "node:os";
5512
- import { dirname as dirname12, join as join8, resolve as resolve11 } from "node:path";
5688
+ import { dirname as dirname14, join as join9, resolve as resolve12 } from "node:path";
5513
5689
  var BUN_LOCKFILES = ["bun.lock", "bun.lockb", "bunfig.toml"];
5514
5690
  var RUNNABLE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".cts", ".cjs", ".js", ".mjs", ".mts"];
5515
5691
  var BIN_SUFFIXES = process.platform === "win32" ? [".exe", ".bunx", ".cmd", ""] : [""];
@@ -5518,18 +5694,18 @@ var UNFORMATTED_PROBE = `const a=1
5518
5694
  `;
5519
5695
  var probeCache = new Map;
5520
5696
  function findBunProjectRoot(start, home = homedir2()) {
5521
- const stopAt = resolve11(home);
5522
- let dir = resolve11(start);
5697
+ const stopAt = resolve12(home);
5698
+ let dir = resolve12(start);
5523
5699
  for (;; ) {
5524
5700
  if (dir === stopAt)
5525
5701
  return;
5526
- if (BUN_LOCKFILES.some((name) => existsSync13(join8(dir, name))))
5702
+ if (BUN_LOCKFILES.some((name) => existsSync14(join9(dir, name))))
5527
5703
  return dir;
5528
- if (packageManagerIsBun(join8(dir, "package.json")))
5704
+ if (packageManagerIsBun(join9(dir, "package.json")))
5529
5705
  return dir;
5530
- if (existsSync13(join8(dir, ".git")))
5706
+ if (existsSync14(join9(dir, ".git")))
5531
5707
  return;
5532
- const parent = dirname12(dir);
5708
+ const parent = dirname14(dir);
5533
5709
  if (parent === dir)
5534
5710
  return;
5535
5711
  dir = parent;
@@ -5541,7 +5717,7 @@ function packageManagerIsBun(packageJsonPath) {
5541
5717
  return typeof packageManager === "string" && packageManager.startsWith("bun@");
5542
5718
  }
5543
5719
  function readJsonObject(path) {
5544
- if (!existsSync13(path))
5720
+ if (!existsSync14(path))
5545
5721
  return;
5546
5722
  try {
5547
5723
  const parsed = JSON.parse(readFileSync8(path, "utf8"));
@@ -5552,14 +5728,14 @@ function readJsonObject(path) {
5552
5728
  }
5553
5729
  function isFile(path) {
5554
5730
  try {
5555
- return statSync5(path).isFile();
5731
+ return statSync6(path).isFile();
5556
5732
  } catch {
5557
5733
  return false;
5558
5734
  }
5559
5735
  }
5560
5736
  function isDirectory(path) {
5561
5737
  try {
5562
- return statSync5(path).isDirectory();
5738
+ return statSync6(path).isDirectory();
5563
5739
  } catch {
5564
5740
  return false;
5565
5741
  }
@@ -5567,35 +5743,35 @@ function isDirectory(path) {
5567
5743
  function projectShadowsBunCommand(command, cwd) {
5568
5744
  const packageJsonDir = nearestPackageJsonDir(cwd);
5569
5745
  if (packageJsonDir !== undefined) {
5570
- const scripts = readJsonObject(join8(packageJsonDir, "package.json"))?.["scripts"];
5746
+ const scripts = readJsonObject(join9(packageJsonDir, "package.json"))?.["scripts"];
5571
5747
  if (scripts !== null && typeof scripts === "object" && typeof scripts[command] === "string") {
5572
5748
  return true;
5573
5749
  }
5574
5750
  }
5575
5751
  if (command === "check")
5576
5752
  return false;
5577
- const base = join8(cwd, command);
5753
+ const base = join9(cwd, command);
5578
5754
  if (isFile(base) || RUNNABLE_EXTENSIONS.some((extension) => isFile(`${base}${extension}`)))
5579
5755
  return true;
5580
- if (isDirectory(base) && (isFile(join8(base, "package.json")) || RUNNABLE_EXTENSIONS.some((extension) => isFile(join8(base, `index${extension}`))))) {
5756
+ if (isDirectory(base) && (isFile(join9(base, "package.json")) || RUNNABLE_EXTENSIONS.some((extension) => isFile(join9(base, `index${extension}`))))) {
5581
5757
  return true;
5582
5758
  }
5583
- let dir = resolve11(cwd);
5759
+ let dir = resolve12(cwd);
5584
5760
  for (;; ) {
5585
- if (BIN_SUFFIXES.some((suffix) => existsSync13(join8(dir, "node_modules", ".bin", `${command}${suffix}`))))
5761
+ if (BIN_SUFFIXES.some((suffix) => existsSync14(join9(dir, "node_modules", ".bin", `${command}${suffix}`))))
5586
5762
  return true;
5587
- const parent = dirname12(dir);
5763
+ const parent = dirname14(dir);
5588
5764
  if (parent === dir)
5589
5765
  return false;
5590
5766
  dir = parent;
5591
5767
  }
5592
5768
  }
5593
5769
  function nearestPackageJsonDir(start) {
5594
- let dir = resolve11(start);
5770
+ let dir = resolve12(start);
5595
5771
  for (;; ) {
5596
- if (existsSync13(join8(dir, "package.json")))
5772
+ if (existsSync14(join9(dir, "package.json")))
5597
5773
  return dir;
5598
- const parent = dirname12(dir);
5774
+ const parent = dirname14(dir);
5599
5775
  if (parent === dir)
5600
5776
  return;
5601
5777
  dir = parent;
@@ -5603,7 +5779,7 @@ function nearestPackageJsonDir(start) {
5603
5779
  }
5604
5780
  function binaryIdentity(bunPath) {
5605
5781
  try {
5606
- const stats = statSync5(bunPath);
5782
+ const stats = statSync6(bunPath);
5607
5783
  return `${stats.mtimeMs}:${stats.size}`;
5608
5784
  } catch {
5609
5785
  return "missing";
@@ -5623,7 +5799,7 @@ function bunHasCommand(bunPath, command, timeoutMs = PROBE_TIMEOUT_MS) {
5623
5799
  return probe;
5624
5800
  }
5625
5801
  async function probeOnce(bunPath, command, timeoutMs) {
5626
- const emptyDir = mkdtempSync(join8(tmpdir(), "omo-bun-probe-"));
5802
+ const emptyDir = mkdtempSync(join9(tmpdir(), "omo-bun-probe-"));
5627
5803
  const timeout = AbortSignal.timeout(timeoutMs);
5628
5804
  try {
5629
5805
  const help = await runBunCommand(bunPath, [command, "--help"], emptyDir, timeout);
@@ -5633,7 +5809,7 @@ async function probeOnce(bunPath, command, timeoutMs) {
5633
5809
  return false;
5634
5810
  if (command !== "format")
5635
5811
  return true;
5636
- const probeFile = join8(emptyDir, "probe.ts");
5812
+ const probeFile = join9(emptyDir, "probe.ts");
5637
5813
  writeFileSync3(probeFile, UNFORMATTED_PROBE);
5638
5814
  const write = await runBunCommand(bunPath, ["format", "--write", "probe.ts"], emptyDir, timeout);
5639
5815
  if (write.exitCode === null)
@@ -6435,7 +6611,7 @@ function requestedProtocolVersion(params) {
6435
6611
  // src/daemon-client.ts
6436
6612
  import { connect } from "node:net";
6437
6613
  import { homedir as homedir4 } from "node:os";
6438
- import { join as join9 } from "node:path";
6614
+ import { join as join10 } from "node:path";
6439
6615
  import { setTimeout as delay } from "node:timers/promises";
6440
6616
 
6441
6617
  // src/daemon-request-error.ts
@@ -6513,9 +6689,9 @@ function errorText(error) {
6513
6689
 
6514
6690
  // src/ensure-daemon.ts
6515
6691
  import { spawn as spawn3 } from "node:child_process";
6516
- import { closeSync as closeSync4, existsSync as existsSync14, mkdirSync as mkdirSync4, openSync as openSync4, writeSync as writeSync3 } from "node:fs";
6692
+ import { closeSync as closeSync4, existsSync as existsSync15, mkdirSync as mkdirSync4, openSync as openSync4, writeSync as writeSync3 } from "node:fs";
6517
6693
  import { Socket } from "node:net";
6518
- import { dirname as dirname13, isAbsolute as isAbsolute5 } from "node:path";
6694
+ import { dirname as dirname15, isAbsolute as isAbsolute5 } from "node:path";
6519
6695
  import { argv0, execPath } from "node:process";
6520
6696
 
6521
6697
  // src/paths.ts
@@ -6526,7 +6702,7 @@ import * as path from "node:path";
6526
6702
  import { fileURLToPath as fileURLToPath3 } from "node:url";
6527
6703
 
6528
6704
  // src/runtime-contract.ts
6529
- import { statSync as statSync6 } from "node:fs";
6705
+ import { statSync as statSync7 } from "node:fs";
6530
6706
  import { isAbsolute as isAbsolute4 } from "node:path";
6531
6707
  var OMO_LSP_DAEMON_DIR = "OMO_LSP_DAEMON_DIR";
6532
6708
  var OMO_LSP_DAEMON_CLI = "OMO_LSP_DAEMON_CLI";
@@ -6574,7 +6750,7 @@ function resolveDaemonRuntime(env, defaults) {
6574
6750
  }
6575
6751
  let cliStats;
6576
6752
  try {
6577
- cliStats = statSync6(cliOverride);
6753
+ cliStats = statSync7(cliOverride);
6578
6754
  } catch (error) {
6579
6755
  if (!(error instanceof Error))
6580
6756
  throw error;
@@ -6796,7 +6972,7 @@ function pingDaemon(paths, token, timeoutMs = PROBE_TIMEOUT_MS2, signal) {
6796
6972
  });
6797
6973
  }
6798
6974
  function spawnDaemonProcess(paths, deps = {}) {
6799
- mkdirSync4(dirname13(paths.log), { recursive: true });
6975
+ mkdirSync4(dirname15(paths.log), { recursive: true });
6800
6976
  const logFd = openSync4(paths.log, "a");
6801
6977
  try {
6802
6978
  const spawnDaemonChild = deps.spawn ?? spawn3;
@@ -6819,7 +6995,7 @@ function spawnDaemonProcess(paths, deps = {}) {
6819
6995
  throw error;
6820
6996
  }
6821
6997
  }
6822
- function resolveDaemonNodeExecutable(cachedExecPath = execPath, originalArgv0 = argv0, pathExists = existsSync14) {
6998
+ function resolveDaemonNodeExecutable(cachedExecPath = execPath, originalArgv0 = argv0, pathExists = existsSync15) {
6823
6999
  if (pathExists(cachedExecPath))
6824
7000
  return cachedExecPath;
6825
7001
  if (isAbsolute5(originalArgv0) && pathExists(originalArgv0))
@@ -7060,9 +7236,9 @@ function currentRequestContext(env = process.env) {
7060
7236
  const home = env["HOME"] ?? homedir4();
7061
7237
  return parseLspRequestContext({
7062
7238
  cwd,
7063
- projectConfigPaths: [join9(cwd, ".codex", "lsp-client.json")],
7064
- userConfigPath: join9(home, ".codex", "lsp-client.json"),
7065
- installDecisionsPath: join9(home, ".codex", "lsp-install-decisions.json"),
7239
+ projectConfigPaths: [join10(cwd, ".codex", "lsp-client.json")],
7240
+ userConfigPath: join10(home, ".codex", "lsp-client.json"),
7241
+ installDecisionsPath: join10(home, ".codex", "lsp-install-decisions.json"),
7066
7242
  capabilities: { installDecisionTool: true }
7067
7243
  });
7068
7244
  }
@@ -7317,18 +7493,18 @@ function canonicalizePathList(value) {
7317
7493
  return value.split(delimiter4).map((entry) => canonicalizePath(entry) ?? entry).join(delimiter4);
7318
7494
  }
7319
7495
  function canonicalizePath(value) {
7320
- if (value === undefined || !isAbsolute6(value) || !existsSync15(value))
7496
+ if (value === undefined || !isAbsolute6(value) || !existsSync16(value))
7321
7497
  return value;
7322
- return realpathSync7(value);
7498
+ return realpathSync8(value);
7323
7499
  }
7324
7500
  function projectRootFromOpenCodeConfigPath(path) {
7325
7501
  if (basename4(path) !== "lsp.json" && basename4(path) !== "lsp-client.json")
7326
7502
  return;
7327
- const configDir = dirname14(path);
7503
+ const configDir = dirname16(path);
7328
7504
  const configDirName = basename4(configDir);
7329
7505
  if (configDirName !== ".opencode" && configDirName !== ".omo")
7330
7506
  return;
7331
- return dirname14(configDir);
7507
+ return dirname16(configDir);
7332
7508
  }
7333
7509
 
7334
7510
  // src/daemon-server.ts
@@ -7338,7 +7514,7 @@ import { createServer as createServer2 } from "node:net";
7338
7514
  // src/version-reap.ts
7339
7515
  import { execFile } from "node:child_process";
7340
7516
  import { readdir, readFile, rm } from "node:fs/promises";
7341
- import { basename as basename5, dirname as dirname15, join as join10 } from "node:path";
7517
+ import { basename as basename5, dirname as dirname17, join as join11 } from "node:path";
7342
7518
  var TERM_GRACE_MS = 5000;
7343
7519
  var KILL_GRACE_MS = 1000;
7344
7520
  var VERSION_ENTRY_PATTERN = /^v([A-Za-z0-9][A-Za-z0-9._+-]{0,127})$/;
@@ -7359,7 +7535,7 @@ async function attestDaemonCliProcess(pid, platform, deps = {}) {
7359
7535
  return isNodeCliDaemonCommand(command.trim());
7360
7536
  }
7361
7537
  async function reapStaleDaemonVersions(ownPaths, deps = {}) {
7362
- const baseDir = dirname15(ownPaths.dir);
7538
+ const baseDir = dirname17(ownPaths.dir);
7363
7539
  const platform = deps.platform ?? process.platform;
7364
7540
  const isAlive = deps.isAlive ?? isProcessAlive;
7365
7541
  const attest = deps.attest ?? ((pid) => attestDaemonCliProcess(pid, platform));
@@ -7378,7 +7554,7 @@ async function reapStaleDaemonVersions(ownPaths, deps = {}) {
7378
7554
  const version = parseVersionEntry(entry.name);
7379
7555
  if (version === null || !entry.isDirectory())
7380
7556
  continue;
7381
- const versionDir = join10(baseDir, entry.name);
7557
+ const versionDir = join11(baseDir, entry.name);
7382
7558
  const siblingPaths = daemonPaths({ [OMO_LSP_DAEMON_DIR]: baseDir }, { cliPath: ownPaths.cliPath, version });
7383
7559
  results.push(await reapOneVersion({
7384
7560
  version,
@@ -7402,7 +7578,7 @@ async function reapOneVersion(context) {
7402
7578
  const { version, versionDir } = context;
7403
7579
  const owner = context.readOwner(context.siblingPaths);
7404
7580
  if (!owner) {
7405
- const lockPid = readLockPid(join10(versionDir, "daemon.lock"));
7581
+ const lockPid = readLockPid(join11(versionDir, "daemon.lock"));
7406
7582
  if (lockPid !== null && context.isAlive(lockPid)) {
7407
7583
  context.log(`reap: sparing v${version}: owner metadata missing but daemon.lock is held by live pid ${lockPid}`);
7408
7584
  return { version, status: "spared", reason: `owner metadata missing but lock held by live pid ${lockPid}` };