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
package/dist/cli/index.js CHANGED
@@ -2132,7 +2132,7 @@ var package_default;
2132
2132
  var init_package = __esm(() => {
2133
2133
  package_default = {
2134
2134
  name: "oh-my-opencode",
2135
- version: "5.1.82",
2135
+ version: "5.1.83",
2136
2136
  description: "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
2137
2137
  main: "./dist/index.js",
2138
2138
  types: "dist/index.d.ts",
@@ -2406,18 +2406,18 @@ var init_package = __esm(() => {
2406
2406
  typescript: "^7.0.2"
2407
2407
  },
2408
2408
  optionalDependencies: {
2409
- "oh-my-opencode-darwin-arm64": "5.1.82",
2410
- "oh-my-opencode-darwin-x64": "5.1.82",
2411
- "oh-my-opencode-darwin-x64-baseline": "5.1.82",
2412
- "oh-my-opencode-linux-arm64": "5.1.82",
2413
- "oh-my-opencode-linux-arm64-musl": "5.1.82",
2414
- "oh-my-opencode-linux-x64": "5.1.82",
2415
- "oh-my-opencode-linux-x64-baseline": "5.1.82",
2416
- "oh-my-opencode-linux-x64-musl": "5.1.82",
2417
- "oh-my-opencode-linux-x64-musl-baseline": "5.1.82",
2418
- "oh-my-opencode-windows-arm64": "5.1.82",
2419
- "oh-my-opencode-windows-x64": "5.1.82",
2420
- "oh-my-opencode-windows-x64-baseline": "5.1.82"
2409
+ "oh-my-opencode-darwin-arm64": "5.1.83",
2410
+ "oh-my-opencode-darwin-x64": "5.1.83",
2411
+ "oh-my-opencode-darwin-x64-baseline": "5.1.83",
2412
+ "oh-my-opencode-linux-arm64": "5.1.83",
2413
+ "oh-my-opencode-linux-arm64-musl": "5.1.83",
2414
+ "oh-my-opencode-linux-x64": "5.1.83",
2415
+ "oh-my-opencode-linux-x64-baseline": "5.1.83",
2416
+ "oh-my-opencode-linux-x64-musl": "5.1.83",
2417
+ "oh-my-opencode-linux-x64-musl-baseline": "5.1.83",
2418
+ "oh-my-opencode-windows-arm64": "5.1.83",
2419
+ "oh-my-opencode-windows-x64": "5.1.83",
2420
+ "oh-my-opencode-windows-x64-baseline": "5.1.83"
2421
2421
  },
2422
2422
  overrides: {
2423
2423
  hono: "^4.13.8",
@@ -92950,7 +92950,7 @@ var package_default2;
92950
92950
  var init_package2 = __esm(() => {
92951
92951
  package_default2 = {
92952
92952
  name: "@oh-my-opencode/omo-codex",
92953
- version: "5.1.82",
92953
+ version: "5.1.83",
92954
92954
  type: "module",
92955
92955
  private: true,
92956
92956
  description: "Codex harness adapter for oh-my-openagent. Vendored Codex plugin namespace (omo) + TypeScript installer + telemetry.",
@@ -132567,7 +132567,7 @@ init_timers();
132567
132567
  // packages/omo-native/package.json
132568
132568
  var package_default4 = {
132569
132569
  name: "omo-ai",
132570
- version: "5.1.82",
132570
+ version: "5.1.83",
132571
132571
  type: "module",
132572
132572
  description: "OmO Native - the standalone omo command with the OMO extension built in: bun add -g omo-ai",
132573
132573
  bin: {
@@ -2133,7 +2133,7 @@ var package_default;
2133
2133
  var init_package = __esm(() => {
2134
2134
  package_default = {
2135
2135
  name: "oh-my-opencode",
2136
- version: "5.1.82",
2136
+ version: "5.1.83",
2137
2137
  description: "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
2138
2138
  main: "./dist/index.js",
2139
2139
  types: "dist/index.d.ts",
@@ -2407,18 +2407,18 @@ var init_package = __esm(() => {
2407
2407
  typescript: "^7.0.2"
2408
2408
  },
2409
2409
  optionalDependencies: {
2410
- "oh-my-opencode-darwin-arm64": "5.1.82",
2411
- "oh-my-opencode-darwin-x64": "5.1.82",
2412
- "oh-my-opencode-darwin-x64-baseline": "5.1.82",
2413
- "oh-my-opencode-linux-arm64": "5.1.82",
2414
- "oh-my-opencode-linux-arm64-musl": "5.1.82",
2415
- "oh-my-opencode-linux-x64": "5.1.82",
2416
- "oh-my-opencode-linux-x64-baseline": "5.1.82",
2417
- "oh-my-opencode-linux-x64-musl": "5.1.82",
2418
- "oh-my-opencode-linux-x64-musl-baseline": "5.1.82",
2419
- "oh-my-opencode-windows-arm64": "5.1.82",
2420
- "oh-my-opencode-windows-x64": "5.1.82",
2421
- "oh-my-opencode-windows-x64-baseline": "5.1.82"
2410
+ "oh-my-opencode-darwin-arm64": "5.1.83",
2411
+ "oh-my-opencode-darwin-x64": "5.1.83",
2412
+ "oh-my-opencode-darwin-x64-baseline": "5.1.83",
2413
+ "oh-my-opencode-linux-arm64": "5.1.83",
2414
+ "oh-my-opencode-linux-arm64-musl": "5.1.83",
2415
+ "oh-my-opencode-linux-x64": "5.1.83",
2416
+ "oh-my-opencode-linux-x64-baseline": "5.1.83",
2417
+ "oh-my-opencode-linux-x64-musl": "5.1.83",
2418
+ "oh-my-opencode-linux-x64-musl-baseline": "5.1.83",
2419
+ "oh-my-opencode-windows-arm64": "5.1.83",
2420
+ "oh-my-opencode-windows-x64": "5.1.83",
2421
+ "oh-my-opencode-windows-x64-baseline": "5.1.83"
2422
2422
  },
2423
2423
  overrides: {
2424
2424
  hono: "^4.13.8",
@@ -93029,7 +93029,7 @@ var package_default2;
93029
93029
  var init_package2 = __esm(() => {
93030
93030
  package_default2 = {
93031
93031
  name: "@oh-my-opencode/omo-codex",
93032
- version: "5.1.82",
93032
+ version: "5.1.83",
93033
93033
  type: "module",
93034
93034
  private: true,
93035
93035
  description: "Codex harness adapter for oh-my-openagent. Vendored Codex plugin namespace (omo) + TypeScript installer + telemetry.",
@@ -132646,7 +132646,7 @@ init_timers();
132646
132646
  // packages/omo-native/package.json
132647
132647
  var package_default4 = {
132648
132648
  name: "omo-ai",
132649
- version: "5.1.82",
132649
+ version: "5.1.83",
132650
132650
  type: "module",
132651
132651
  description: "OmO Native - the standalone omo command with the OMO extension built in: bun add -g omo-ai",
132652
132652
  bin: {
package/dist/index.js CHANGED
@@ -98105,7 +98105,7 @@ init_src();
98105
98105
  // package.json
98106
98106
  var package_default = {
98107
98107
  name: "oh-my-opencode",
98108
- version: "5.1.82",
98108
+ version: "5.1.83",
98109
98109
  description: "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
98110
98110
  main: "./dist/index.js",
98111
98111
  types: "dist/index.d.ts",
@@ -98379,18 +98379,18 @@ var package_default = {
98379
98379
  typescript: "^7.0.2"
98380
98380
  },
98381
98381
  optionalDependencies: {
98382
- "oh-my-opencode-darwin-arm64": "5.1.82",
98383
- "oh-my-opencode-darwin-x64": "5.1.82",
98384
- "oh-my-opencode-darwin-x64-baseline": "5.1.82",
98385
- "oh-my-opencode-linux-arm64": "5.1.82",
98386
- "oh-my-opencode-linux-arm64-musl": "5.1.82",
98387
- "oh-my-opencode-linux-x64": "5.1.82",
98388
- "oh-my-opencode-linux-x64-baseline": "5.1.82",
98389
- "oh-my-opencode-linux-x64-musl": "5.1.82",
98390
- "oh-my-opencode-linux-x64-musl-baseline": "5.1.82",
98391
- "oh-my-opencode-windows-arm64": "5.1.82",
98392
- "oh-my-opencode-windows-x64": "5.1.82",
98393
- "oh-my-opencode-windows-x64-baseline": "5.1.82"
98382
+ "oh-my-opencode-darwin-arm64": "5.1.83",
98383
+ "oh-my-opencode-darwin-x64": "5.1.83",
98384
+ "oh-my-opencode-darwin-x64-baseline": "5.1.83",
98385
+ "oh-my-opencode-linux-arm64": "5.1.83",
98386
+ "oh-my-opencode-linux-arm64-musl": "5.1.83",
98387
+ "oh-my-opencode-linux-x64": "5.1.83",
98388
+ "oh-my-opencode-linux-x64-baseline": "5.1.83",
98389
+ "oh-my-opencode-linux-x64-musl": "5.1.83",
98390
+ "oh-my-opencode-linux-x64-musl-baseline": "5.1.83",
98391
+ "oh-my-opencode-windows-arm64": "5.1.83",
98392
+ "oh-my-opencode-windows-x64": "5.1.83",
98393
+ "oh-my-opencode-windows-x64-baseline": "5.1.83"
98394
98394
  },
98395
98395
  overrides: {
98396
98396
  hono: "^4.13.8",
@@ -6,5 +6,5 @@
6
6
  "page-bundle.js": "c517fa11a62a1b83dc79f72b288159a420831426418b1d4d9d492fc6c414f78c",
7
7
  "LICENSE": "b083425948376611de9b92b0aeb7377e604505756ea427e541a34d9b030d4dc1"
8
8
  },
9
- "stagedAtUtc": "2026-11-23T23:04:51.576Z"
9
+ "stagedAtUtc": "2026-11-24T02:35:28.231Z"
10
10
  }
package/dist/tui.js CHANGED
@@ -75883,7 +75883,7 @@ init_shared();
75883
75883
  // package.json
75884
75884
  var package_default = {
75885
75885
  name: "oh-my-opencode",
75886
- version: "5.1.82",
75886
+ version: "5.1.83",
75887
75887
  description: "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
75888
75888
  main: "./dist/index.js",
75889
75889
  types: "dist/index.d.ts",
@@ -76157,18 +76157,18 @@ var package_default = {
76157
76157
  typescript: "^7.0.2"
76158
76158
  },
76159
76159
  optionalDependencies: {
76160
- "oh-my-opencode-darwin-arm64": "5.1.82",
76161
- "oh-my-opencode-darwin-x64": "5.1.82",
76162
- "oh-my-opencode-darwin-x64-baseline": "5.1.82",
76163
- "oh-my-opencode-linux-arm64": "5.1.82",
76164
- "oh-my-opencode-linux-arm64-musl": "5.1.82",
76165
- "oh-my-opencode-linux-x64": "5.1.82",
76166
- "oh-my-opencode-linux-x64-baseline": "5.1.82",
76167
- "oh-my-opencode-linux-x64-musl": "5.1.82",
76168
- "oh-my-opencode-linux-x64-musl-baseline": "5.1.82",
76169
- "oh-my-opencode-windows-arm64": "5.1.82",
76170
- "oh-my-opencode-windows-x64": "5.1.82",
76171
- "oh-my-opencode-windows-x64-baseline": "5.1.82"
76160
+ "oh-my-opencode-darwin-arm64": "5.1.83",
76161
+ "oh-my-opencode-darwin-x64": "5.1.83",
76162
+ "oh-my-opencode-darwin-x64-baseline": "5.1.83",
76163
+ "oh-my-opencode-linux-arm64": "5.1.83",
76164
+ "oh-my-opencode-linux-arm64-musl": "5.1.83",
76165
+ "oh-my-opencode-linux-x64": "5.1.83",
76166
+ "oh-my-opencode-linux-x64-baseline": "5.1.83",
76167
+ "oh-my-opencode-linux-x64-musl": "5.1.83",
76168
+ "oh-my-opencode-linux-x64-musl-baseline": "5.1.83",
76169
+ "oh-my-opencode-windows-arm64": "5.1.83",
76170
+ "oh-my-opencode-windows-x64": "5.1.83",
76171
+ "oh-my-opencode-windows-x64-baseline": "5.1.83"
76172
76172
  },
76173
76173
  overrides: {
76174
76174
  hono: "^4.13.8",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-opencode",
3
- "version": "5.1.82",
3
+ "version": "5.1.83",
4
4
  "description": "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
5
5
  "main": "./dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -274,18 +274,18 @@
274
274
  "typescript": "^7.0.2"
275
275
  },
276
276
  "optionalDependencies": {
277
- "oh-my-opencode-darwin-arm64": "5.1.82",
278
- "oh-my-opencode-darwin-x64": "5.1.82",
279
- "oh-my-opencode-darwin-x64-baseline": "5.1.82",
280
- "oh-my-opencode-linux-arm64": "5.1.82",
281
- "oh-my-opencode-linux-arm64-musl": "5.1.82",
282
- "oh-my-opencode-linux-x64": "5.1.82",
283
- "oh-my-opencode-linux-x64-baseline": "5.1.82",
284
- "oh-my-opencode-linux-x64-musl": "5.1.82",
285
- "oh-my-opencode-linux-x64-musl-baseline": "5.1.82",
286
- "oh-my-opencode-windows-arm64": "5.1.82",
287
- "oh-my-opencode-windows-x64": "5.1.82",
288
- "oh-my-opencode-windows-x64-baseline": "5.1.82"
277
+ "oh-my-opencode-darwin-arm64": "5.1.83",
278
+ "oh-my-opencode-darwin-x64": "5.1.83",
279
+ "oh-my-opencode-darwin-x64-baseline": "5.1.83",
280
+ "oh-my-opencode-linux-arm64": "5.1.83",
281
+ "oh-my-opencode-linux-arm64-musl": "5.1.83",
282
+ "oh-my-opencode-linux-x64": "5.1.83",
283
+ "oh-my-opencode-linux-x64-baseline": "5.1.83",
284
+ "oh-my-opencode-linux-x64-musl": "5.1.83",
285
+ "oh-my-opencode-linux-x64-musl-baseline": "5.1.83",
286
+ "oh-my-opencode-windows-arm64": "5.1.83",
287
+ "oh-my-opencode-windows-x64": "5.1.83",
288
+ "oh-my-opencode-windows-x64-baseline": "5.1.83"
289
289
  },
290
290
  "overrides": {
291
291
  "hono": "^4.13.8",
@@ -0,0 +1,14 @@
1
+ import type { ResolvedServer } from "./types.js"
2
+
3
+ /** What tells two resident clients apart: the server id and the exact command it was resolved to. */
4
+ export type ClientIdentity = Pick<ResolvedServer, "id" | "command">
5
+
6
+ /**
7
+ * The resident client key. The resolved command is part of it because one server id can resolve to
8
+ * different binaries under one workspace root: in a monorepo, a TypeScript 7 package is served by its
9
+ * own `tsc --lsp` while a TypeScript 5 sibling is served by typescript-language-server. The same root
10
+ * and command still share one client.
11
+ */
12
+ export function lspClientKey(root: string, server: ClientIdentity): string {
13
+ return JSON.stringify([root, server.id, server.command])
14
+ }
@@ -0,0 +1,139 @@
1
+ import type { LspClient } from "./client.js"
2
+
3
+ /**
4
+ * Lifecycle of a starting client, owned by the LspManager.
5
+ *
6
+ * The manager owns every startup and every shutdown; a caller only waits. A startup begun by getClient
7
+ * is held by its waiters, counted in `pendingWaiters` from the moment they join until each one either
8
+ * becomes a reference or leaves. A waiter whose signal aborts (a caller cancellation or a directory
9
+ * scan's start deadline) detaches: it stops counting and rejects at once, and never awaits a shutdown.
10
+ * When the last waiter of a waiter-held startup leaves while it holds no reference, the manager drops
11
+ * the startup from its pool (so `clientCount()` no longer counts it) and stops it as a tracked
12
+ * tombstone, which the next getClient for that key and `stopAll()` await, so no process outlives the
13
+ * manager. A start that fails is dropped and stopped the same way, once. A warmup startup has no waiter
14
+ * to lose and runs to its end.
15
+ *
16
+ * States of one key: ABSENT; STARTING (N counted waiters); RESIDENT (R references, plus the counted
17
+ * waiters of a start that just finished); STOPPING (not pooled, stop tracked in `pendingStops`).
18
+ * - getClient resident hit: R+1 synchronously, no await.
19
+ * - getClient cold start or joining a start: counted (N+1) synchronously, then awaits the start. When it
20
+ * resumes it stops counting and takes its reference (R+1) in one synchronous step, after checking it
21
+ * still holds the pooled instance for its key and that the client is alive. A client that is no longer
22
+ * pooled (stopped by the init-timeout reaper, invalidateClient or stopAll while it waited) is never
23
+ * handed out: the caller acquires again through the normal path, which awaits that stop and starts a
24
+ * fresh client, or rejects once the manager is disposed.
25
+ * - Waiter abort or deadline: N-1, rejects; the last waiter leaving stops the startup as above.
26
+ * - releaseClient: R-1 on the instance the caller held; a stale instance gives back nothing.
27
+ * - Eviction at the resident cap and the idle reaper take only a RESIDENT client with R = 0 and N = 0.
28
+ * - The init-timeout reaper stops a startup older than the init timeout whatever its waiters, and
29
+ * stopAll stops everything; neither hands the stopped client to a caller.
30
+ */
31
+ export interface ManagedClient {
32
+ readonly key: string
33
+ readonly root: string
34
+ readonly serverId: string
35
+ readonly client: LspClient
36
+ /** False for a warmup startup, which no waiter holds. */
37
+ readonly heldByWaiters: boolean
38
+ refCount: number
39
+ pendingWaiters: number
40
+ lastUsedAt: number
41
+ initPromise: Promise<void> | null
42
+ isInitializing: boolean
43
+ initializingSince: number | null
44
+ }
45
+
46
+ export interface StartupRequest {
47
+ readonly key: string
48
+ readonly root: string
49
+ readonly serverId: string
50
+ readonly client: LspClient
51
+ readonly heldByWaiters: boolean
52
+ }
53
+
54
+ export class ClientStartups {
55
+ constructor(
56
+ private readonly now: () => number,
57
+ private readonly discard: (managed: ManagedClient) => void,
58
+ ) {}
59
+
60
+ begin(request: StartupRequest): ManagedClient {
61
+ const { client } = request
62
+ const startedAt = this.now()
63
+ const initPromise = (async () => {
64
+ await client.start()
65
+ await client.initialize()
66
+ })()
67
+ const managed: ManagedClient = {
68
+ ...request,
69
+ refCount: 0,
70
+ pendingWaiters: 0,
71
+ lastUsedAt: startedAt,
72
+ initPromise,
73
+ isInitializing: true,
74
+ initializingSince: startedAt,
75
+ }
76
+ // Registered before any waiter, so the pool reflects the outcome by the time a waiter resumes.
77
+ initPromise.then(
78
+ () => {
79
+ managed.isInitializing = false
80
+ managed.initializingSince = null
81
+ managed.initPromise = null
82
+ managed.lastUsedAt = this.now()
83
+ },
84
+ () => this.discard(managed),
85
+ )
86
+ return managed
87
+ }
88
+
89
+ /**
90
+ * Waits for the start as one counted waiter. A rejection has already detached the waiter; a
91
+ * resolution leaves it counted, and the caller must turn it into a reference or `detach` it before
92
+ * its next await.
93
+ */
94
+ async wait(managed: ManagedClient, initPromise: Promise<void>, signal: AbortSignal | undefined): Promise<void> {
95
+ managed.pendingWaiters++
96
+ try {
97
+ await awaitWithSignal(initPromise, signal)
98
+ } catch (error) {
99
+ this.detach(managed)
100
+ throw error
101
+ }
102
+ }
103
+
104
+ detach(managed: ManagedClient): void {
105
+ managed.pendingWaiters--
106
+ if (managed.pendingWaiters === 0 && managed.refCount === 0 && managed.heldByWaiters) this.discard(managed)
107
+ }
108
+ }
109
+
110
+ export function awaitWithSignal<T>(promise: Promise<T>, signal: AbortSignal | undefined): Promise<T> {
111
+ if (!signal) return promise
112
+ return new Promise<T>((resolve, reject) => {
113
+ let settled = false
114
+ const onAbort = () => {
115
+ if (settled) return
116
+ settled = true
117
+ reject(new DOMException("Aborted", "AbortError"))
118
+ }
119
+ if (signal.aborted) {
120
+ onAbort()
121
+ return
122
+ }
123
+ signal.addEventListener("abort", onAbort, { once: true })
124
+ promise.then(
125
+ (value) => {
126
+ if (settled) return
127
+ settled = true
128
+ signal.removeEventListener("abort", onAbort)
129
+ resolve(value)
130
+ },
131
+ (err) => {
132
+ if (settled) return
133
+ settled = true
134
+ signal.removeEventListener("abort", onAbort)
135
+ reject(err)
136
+ },
137
+ )
138
+ })
139
+ }
@@ -255,7 +255,7 @@ export async function withLspClient<T>(
255
255
  }
256
256
 
257
257
  const ext = effectiveExtension(absPath)
258
- const result = findServerForExtension(ext)
258
+ const result = findServerForExtension(ext, absPath)
259
259
  if (result.status !== "found") {
260
260
  throw new LspServerLookupError(formatServerLookupError(result), result)
261
261
  }
@@ -271,18 +271,18 @@ export async function withLspClient<T>(
271
271
  return await fn(client, root, absPath)
272
272
  } catch (err) {
273
273
  if (allowRetry && READ_ONLY_TOOLS.has(toolName) && isLspDeadConnectionError(err)) {
274
- manager.invalidateClient(root, server.id, client)
274
+ manager.invalidateClient(root, server, client)
275
275
  return acquireAndCall(false)
276
276
  }
277
277
 
278
278
  if (err instanceof LspRequestTimeoutError) {
279
- if (manager.isServerInitializing(root, server.id)) {
279
+ if (manager.isServerInitializing(root, server)) {
280
280
  throw new LspServerInitializingError(err)
281
281
  }
282
282
  }
283
283
  throw err
284
284
  } finally {
285
- manager.releaseClient(root, server.id)
285
+ manager.releaseClient(root, server, client)
286
286
  }
287
287
  }
288
288
 
@@ -21,6 +21,13 @@ type ConfigSource = "project" | "user"
21
21
 
22
22
  export interface ServerWithSource extends ResolvedServer {
23
23
  source: "project" | "user" | "builtin"
24
+ /**
25
+ * True when no config file named `command`, so it is the builtin default. A configured command
26
+ * stays false even when it is textually equal to the default.
27
+ */
28
+ inheritsBuiltinCommand: boolean
29
+ /** The `initialization` a config file supplied, without the builtin option set merged in. */
30
+ configuredInitialization?: Record<string, unknown>
24
31
  }
25
32
 
26
33
  export function getConfigPaths(): { project: string; user: string } {
@@ -106,6 +113,7 @@ export function getMergedServers(): ServerWithSource[] {
106
113
  extensions: config.extensions,
107
114
  priority: -100,
108
115
  source: "builtin",
116
+ inheritsBuiltinCommand: true,
109
117
  ...(config.initialization === undefined ? {} : { initialization: config.initialization }),
110
118
  })
111
119
  }
@@ -133,7 +141,9 @@ function createServerFromEntry(id: string, entry: LspEntry, source: ConfigSource
133
141
  extensions: entry.extensions ?? builtin.extensions,
134
142
  priority: entry.priority ?? 0,
135
143
  source,
144
+ inheritsBuiltinCommand: true,
136
145
  })
146
+ if (entry.initialization !== undefined) server.configuredInitialization = entry.initialization
137
147
  const initialization = mergeInitialization(builtin.initialization, entry.initialization)
138
148
  if (initialization !== undefined) {
139
149
  server.initialization = initialization
@@ -148,6 +158,7 @@ function createServerFromEntry(id: string, entry: LspEntry, source: ConfigSource
148
158
  extensions: entry.extensions,
149
159
  priority: entry.priority ?? 0,
150
160
  source,
161
+ inheritsBuiltinCommand: false,
151
162
  })
152
163
  applyOptionalServerFields(server, entry)
153
164
  return server
@@ -160,6 +171,7 @@ function createServerFromEntry(id: string, entry: LspEntry, source: ConfigSource
160
171
  extensions: entry.extensions ?? builtin.extensions,
161
172
  priority: entry.priority ?? 0,
162
173
  source,
174
+ inheritsBuiltinCommand: entry.command === undefined,
163
175
  })
164
176
  applyOptionalServerFields(server, entry)
165
177
  const builtinInitialization = entry.command === undefined ? builtin.initialization : undefined
@@ -185,6 +197,7 @@ function createServer(input: {
185
197
  readonly extensions: string[]
186
198
  readonly priority: number
187
199
  readonly source: ConfigSource
200
+ readonly inheritsBuiltinCommand: boolean
188
201
  readonly env?: Record<string, string>
189
202
  readonly initialization?: Record<string, unknown>
190
203
  }): ServerWithSource {
@@ -194,6 +207,7 @@ function createServer(input: {
194
207
  extensions: input.extensions,
195
208
  priority: input.priority,
196
209
  source: input.source,
210
+ inheritsBuiltinCommand: input.inheritsBuiltinCommand,
197
211
  }
198
212
  if (input.env !== undefined) {
199
213
  server.env = input.env
@@ -210,6 +224,7 @@ function applyOptionalServerFields(server: ServerWithSource, entry: LspEntry): v
210
224
  }
211
225
  if (entry.initialization !== undefined) {
212
226
  server.initialization = entry.initialization
227
+ server.configuredInitialization = entry.initialization
213
228
  }
214
229
  }
215
230