oh-my-opencode 5.1.82 → 5.1.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli-program.d.ts +3 -0
- package/dist/cli/index.js +202 -193
- package/dist/cli-node/index.js +202 -193
- package/dist/index.js +28 -22
- package/dist/skills/browser/SKILL.md +97 -91
- package/dist/skills/browser/references/commands.md +88 -26
- package/dist/skills/browser/references/desktop.md +21 -0
- package/dist/skills/browser/references/install.md +18 -0
- package/dist/skills/browser/references/owned-engine/README.md +5 -2
- package/dist/skills/browser/references/owned-engine/frames-and-humans.md +7 -2
- package/dist/skills/browser/references/owned-engine/network.md +4 -3
- package/dist/skills/browser/references/recipes/1password.md +4 -2
- package/dist/skills/browser/runtime/omowright/index.js +7 -7
- package/dist/skills/browser/runtime/omowright/manifest.json +4 -4
- package/dist/skills/debugging/references/tools/browser-qa.md +1 -1
- package/dist/skills/programming/SKILL.md +51 -320
- package/dist/skills/programming/references/go/README.md +1 -0
- package/dist/skills/programming/references/python/README.md +21 -3
- package/dist/skills/programming/references/python/error-handling.md +14 -0
- package/dist/skills/programming/references/rust/README.md +5 -1
- package/dist/skills/programming/references/typescript/README.md +9 -3
- package/dist/skills/programming/references/typescript/error-handling.md +18 -0
- package/dist/skills/ultimate-browsing/SKILL.md +1 -1
- package/dist/skills/visual-qa/references/browser-setup.md +5 -5
- package/dist/tui.js +16 -16
- package/package.json +14 -14
- package/packages/lsp-core/src/lsp/client-key.ts +14 -0
- package/packages/lsp-core/src/lsp/client-startup.ts +139 -0
- package/packages/lsp-core/src/lsp/client-wrapper.ts +4 -4
- package/packages/lsp-core/src/lsp/config-loader.ts +15 -0
- package/packages/lsp-core/src/lsp/directory-diagnostics-group-scan.test.ts +388 -0
- package/packages/lsp-core/src/lsp/directory-diagnostics-mixed-typescript.test.ts +124 -0
- package/packages/lsp-core/src/lsp/directory-diagnostics.test.ts +4 -4
- package/packages/lsp-core/src/lsp/directory-diagnostics.ts +38 -41
- package/packages/lsp-core/src/lsp/directory-group-scan.ts +124 -0
- package/packages/lsp-core/src/lsp/directory-server-groups.ts +84 -0
- package/packages/lsp-core/src/lsp/manager-acquisition.test.ts +115 -0
- package/packages/lsp-core/src/lsp/manager-lifecycle.test.ts +9 -9
- package/packages/lsp-core/src/lsp/manager-max-clients.test.ts +41 -16
- package/packages/lsp-core/src/lsp/manager-reaping.test.ts +119 -0
- package/packages/lsp-core/src/lsp/manager-test-support.ts +108 -0
- package/packages/lsp-core/src/lsp/manager.ts +80 -249
- package/packages/lsp-core/src/lsp/native-typescript.ts +88 -0
- package/packages/lsp-core/src/lsp/server-installation.ts +15 -7
- package/packages/lsp-core/src/lsp/server-resolution-typescript-native.test.ts +327 -0
- package/packages/lsp-core/src/lsp/server-resolution.ts +28 -2
- package/packages/lsp-core/src/lsp/timer-provider.ts +17 -0
- package/packages/lsp-core/src/lsp/typescript-project-test-support.ts +52 -0
- package/packages/lsp-daemon/dist/cli.js +486 -310
- package/packages/lsp-daemon/dist/client.js +472 -296
- package/packages/lsp-daemon/dist/index.js +476 -300
- package/packages/lsp-tools-mcp/dist/cli.js +467 -291
- package/packages/lsp-tools-mcp/dist/lsp/manager.js +160 -193
- package/packages/lsp-tools-mcp/dist/mcp.js +467 -291
- package/packages/lsp-tools-mcp/dist/tools.js +467 -291
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +2 -2
- package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
- package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +3 -3
- package/packages/omo-codex/plugin/components/lsp/dist/cli.js +478 -313
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +8711 -172
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +8660 -121
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/src/posthog.ts +5 -0
- package/packages/omo-codex/plugin/components/telemetry/tsconfig.json +2 -2
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/package-lock.json +12 -12
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/shared/src/config-loader.ts +15 -1
- package/packages/omo-codex/plugin/skills/browser/SKILL.md +97 -91
- package/packages/omo-codex/plugin/skills/browser/references/commands.md +88 -26
- package/packages/omo-codex/plugin/skills/browser/references/desktop.md +21 -0
- package/packages/omo-codex/plugin/skills/browser/references/install.md +18 -0
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/README.md +5 -2
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/frames-and-humans.md +7 -2
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/network.md +4 -3
- package/packages/omo-codex/plugin/skills/browser/references/recipes/1password.md +4 -2
- package/packages/omo-codex/plugin/skills/browser/runtime/omowright/index.js +7 -7
- package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +4 -4
- package/packages/omo-codex/plugin/skills/debugging/references/tools/browser-qa.md +1 -1
- package/packages/omo-codex/plugin/skills/programming/SKILL.md +51 -320
- package/packages/omo-codex/plugin/skills/programming/references/go/README.md +1 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/README.md +21 -3
- package/packages/omo-codex/plugin/skills/programming/references/python/error-handling.md +14 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/README.md +5 -1
- package/packages/omo-codex/plugin/skills/programming/references/typescript/README.md +9 -3
- package/packages/omo-codex/plugin/skills/programming/references/typescript/error-handling.md +18 -0
- package/packages/omo-codex/plugin/skills/ultimate-browsing/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/visual-qa/references/browser-setup.md +5 -5
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +21189 -20653
- package/packages/shared-skills/skills/browser/SKILL.md +97 -91
- package/packages/shared-skills/skills/browser/references/commands.md +88 -26
- package/packages/shared-skills/skills/browser/references/desktop.md +21 -0
- package/packages/shared-skills/skills/browser/references/install.md +18 -0
- package/packages/shared-skills/skills/browser/references/owned-engine/README.md +5 -2
- package/packages/shared-skills/skills/browser/references/owned-engine/frames-and-humans.md +7 -2
- package/packages/shared-skills/skills/browser/references/owned-engine/network.md +4 -3
- package/packages/shared-skills/skills/browser/references/recipes/1password.md +4 -2
- package/packages/shared-skills/skills/browser/runtime/omowright/index.js +7 -7
- package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +4 -4
- package/packages/shared-skills/skills/debugging/references/tools/browser-qa.md +1 -1
- package/packages/shared-skills/skills/programming/SKILL.md +51 -320
- package/packages/shared-skills/skills/programming/references/go/README.md +1 -0
- package/packages/shared-skills/skills/programming/references/python/README.md +21 -3
- package/packages/shared-skills/skills/programming/references/python/error-handling.md +14 -0
- package/packages/shared-skills/skills/programming/references/rust/README.md +5 -1
- package/packages/shared-skills/skills/programming/references/typescript/README.md +9 -3
- package/packages/shared-skills/skills/programming/references/typescript/error-handling.md +18 -0
- package/packages/shared-skills/skills/ultimate-browsing/SKILL.md +1 -1
- package/packages/shared-skills/skills/visual-qa/references/browser-setup.md +5 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// src/client.ts
|
|
2
|
-
import { statSync as
|
|
2
|
+
import { statSync as statSync7 } from "node:fs";
|
|
3
3
|
import { isAbsolute as isAbsolute6 } from "node:path";
|
|
4
4
|
|
|
5
5
|
// src/daemon-client.ts
|
|
6
6
|
import { connect } from "node:net";
|
|
7
7
|
import { homedir as homedir4 } from "node:os";
|
|
8
|
-
import { join as
|
|
8
|
+
import { join as join10 } from "node:path";
|
|
9
9
|
import { setTimeout as delay } from "node:timers/promises";
|
|
10
10
|
|
|
11
11
|
// ../lsp-core/src/request-context.ts
|
|
@@ -1160,8 +1160,8 @@ function createIdleTimer(idleTimeoutMs, log, onTimeout) {
|
|
|
1160
1160
|
};
|
|
1161
1161
|
}
|
|
1162
1162
|
// ../lsp-core/src/lsp/client-wrapper.ts
|
|
1163
|
-
import { existsSync as
|
|
1164
|
-
import { basename as basename3, dirname as
|
|
1163
|
+
import { existsSync as existsSync12, realpathSync as realpathSync7, statSync as statSync5 } from "node:fs";
|
|
1164
|
+
import { basename as basename3, dirname as dirname11, join as join6, resolve as resolve9 } from "node:path";
|
|
1165
1165
|
|
|
1166
1166
|
// ../lsp-core/src/lsp/effective-extension.ts
|
|
1167
1167
|
import { basename as basename2, extname } from "node:path";
|
|
@@ -1273,6 +1273,24 @@ var realTimerProvider = {
|
|
|
1273
1273
|
setTimeout: (callback, delayMs) => setTimeout(callback, delayMs),
|
|
1274
1274
|
clearTimeout: (handle) => clearTimeout(handle)
|
|
1275
1275
|
};
|
|
1276
|
+
function repeatEvery(timers, intervalMs, tick) {
|
|
1277
|
+
let handle = null;
|
|
1278
|
+
const arm = () => {
|
|
1279
|
+
handle = timers.setTimeout(() => {
|
|
1280
|
+
tick();
|
|
1281
|
+
if (handle !== null)
|
|
1282
|
+
arm();
|
|
1283
|
+
}, intervalMs);
|
|
1284
|
+
if (typeof handle.unref === "function")
|
|
1285
|
+
handle.unref();
|
|
1286
|
+
};
|
|
1287
|
+
arm();
|
|
1288
|
+
return () => {
|
|
1289
|
+
if (handle !== null)
|
|
1290
|
+
timers.clearTimeout(handle);
|
|
1291
|
+
handle = null;
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1276
1294
|
|
|
1277
1295
|
// ../lsp-core/src/lsp/constants.ts
|
|
1278
1296
|
var DEFAULT_MAX_REFERENCES = 200;
|
|
@@ -3935,30 +3953,54 @@ function abortError3(signal) {
|
|
|
3935
3953
|
return error;
|
|
3936
3954
|
}
|
|
3937
3955
|
|
|
3938
|
-
// ../lsp-core/src/lsp/
|
|
3939
|
-
function
|
|
3940
|
-
|
|
3941
|
-
const handler = () => {
|
|
3942
|
-
cleanup().catch((error) => {
|
|
3943
|
-
reportBestEffortCleanupError("signal cleanup", error);
|
|
3944
|
-
});
|
|
3945
|
-
};
|
|
3946
|
-
for (const signal of signals) {
|
|
3947
|
-
process.on(signal, handler);
|
|
3948
|
-
}
|
|
3949
|
-
return () => {
|
|
3950
|
-
for (const signal of signals) {
|
|
3951
|
-
process.removeListener(signal, handler);
|
|
3952
|
-
}
|
|
3953
|
-
};
|
|
3956
|
+
// ../lsp-core/src/lsp/client-key.ts
|
|
3957
|
+
function lspClientKey(root, server) {
|
|
3958
|
+
return JSON.stringify([root, server.id, server.command]);
|
|
3954
3959
|
}
|
|
3955
3960
|
|
|
3956
|
-
// ../lsp-core/src/lsp/
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3961
|
+
// ../lsp-core/src/lsp/client-startup.ts
|
|
3962
|
+
class ClientStartups {
|
|
3963
|
+
constructor(now, discard) {
|
|
3964
|
+
this.now = now;
|
|
3965
|
+
this.discard = discard;
|
|
3966
|
+
}
|
|
3967
|
+
begin(request) {
|
|
3968
|
+
const { client } = request;
|
|
3969
|
+
const startedAt = this.now();
|
|
3970
|
+
const initPromise = (async () => {
|
|
3971
|
+
await client.start();
|
|
3972
|
+
await client.initialize();
|
|
3973
|
+
})();
|
|
3974
|
+
const managed = {
|
|
3975
|
+
...request,
|
|
3976
|
+
refCount: 0,
|
|
3977
|
+
pendingWaiters: 0,
|
|
3978
|
+
lastUsedAt: startedAt,
|
|
3979
|
+
initPromise,
|
|
3980
|
+
isInitializing: true,
|
|
3981
|
+
initializingSince: startedAt
|
|
3982
|
+
};
|
|
3983
|
+
initPromise.then(() => {
|
|
3984
|
+
managed.isInitializing = false;
|
|
3985
|
+
managed.initializingSince = null;
|
|
3986
|
+
managed.initPromise = null;
|
|
3987
|
+
managed.lastUsedAt = this.now();
|
|
3988
|
+
}, () => this.discard(managed));
|
|
3989
|
+
return managed;
|
|
3990
|
+
}
|
|
3991
|
+
async wait(managed, initPromise, signal) {
|
|
3992
|
+
managed.pendingWaiters++;
|
|
3993
|
+
try {
|
|
3994
|
+
await awaitWithSignal2(initPromise, signal);
|
|
3995
|
+
} catch (error) {
|
|
3996
|
+
this.detach(managed);
|
|
3997
|
+
throw error;
|
|
3998
|
+
}
|
|
3999
|
+
}
|
|
4000
|
+
detach(managed) {
|
|
4001
|
+
managed.pendingWaiters--;
|
|
4002
|
+
if (managed.pendingWaiters === 0 && managed.refCount === 0 && managed.heldByWaiters)
|
|
4003
|
+
this.discard(managed);
|
|
3962
4004
|
}
|
|
3963
4005
|
}
|
|
3964
4006
|
function awaitWithSignal2(promise, signal) {
|
|
@@ -3993,36 +4035,50 @@ function awaitWithSignal2(promise, signal) {
|
|
|
3993
4035
|
});
|
|
3994
4036
|
}
|
|
3995
4037
|
|
|
4038
|
+
// ../lsp-core/src/lsp/process-signal-cleanup.ts
|
|
4039
|
+
function installProcessSignalCleanup(cleanup) {
|
|
4040
|
+
const signals = process.platform === "win32" ? ["SIGINT", "SIGTERM", "SIGBREAK"] : ["SIGINT", "SIGTERM"];
|
|
4041
|
+
const handler = () => {
|
|
4042
|
+
cleanup().catch((error) => {
|
|
4043
|
+
reportBestEffortCleanupError("signal cleanup", error);
|
|
4044
|
+
});
|
|
4045
|
+
};
|
|
4046
|
+
for (const signal of signals) {
|
|
4047
|
+
process.on(signal, handler);
|
|
4048
|
+
}
|
|
4049
|
+
return () => {
|
|
4050
|
+
for (const signal of signals) {
|
|
4051
|
+
process.removeListener(signal, handler);
|
|
4052
|
+
}
|
|
4053
|
+
};
|
|
4054
|
+
}
|
|
4055
|
+
|
|
4056
|
+
// ../lsp-core/src/lsp/manager.ts
|
|
4057
|
+
async function stopClientBestEffort(client) {
|
|
4058
|
+
try {
|
|
4059
|
+
await client.stop();
|
|
4060
|
+
} catch (error) {
|
|
4061
|
+
reportBestEffortCleanupError("client stop", error);
|
|
4062
|
+
}
|
|
4063
|
+
}
|
|
4064
|
+
|
|
3996
4065
|
class LspManager {
|
|
3997
4066
|
constructor(options = {}) {
|
|
3998
4067
|
this.clients = new Map;
|
|
3999
4068
|
this.pendingStops = new Map;
|
|
4000
4069
|
this.respawnBudgets = new Map;
|
|
4001
|
-
this.reaperHandle = null;
|
|
4002
4070
|
this.signalDisposer = null;
|
|
4003
4071
|
this.disposed = false;
|
|
4004
4072
|
this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS;
|
|
4005
4073
|
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
4006
4074
|
this.maxResidentClients = options.maxResidentClients ?? MAX_RESIDENT_CLIENTS;
|
|
4007
|
-
this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
|
|
4008
4075
|
this.clientFactory = options.clientFactory ?? ((root, server) => new LspClient(root, server));
|
|
4009
4076
|
this.now = options.now ?? (() => Date.now());
|
|
4010
|
-
this.
|
|
4077
|
+
this.startups = new ClientStartups(this.now, (managed) => this.discard(managed));
|
|
4078
|
+
const reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
|
|
4079
|
+
this.stopReaper = repeatEvery(options.timers ?? realTimerProvider, reaperIntervalMs, () => this.reapStale());
|
|
4011
4080
|
this.signalDisposer = installProcessSignalCleanup(() => this.stopAll());
|
|
4012
4081
|
}
|
|
4013
|
-
startReaper() {
|
|
4014
|
-
if (this.reaperHandle)
|
|
4015
|
-
return;
|
|
4016
|
-
this.reaperHandle = setInterval(() => {
|
|
4017
|
-
this.reapStale();
|
|
4018
|
-
}, this.reaperIntervalMs);
|
|
4019
|
-
if (typeof this.reaperHandle.unref === "function") {
|
|
4020
|
-
this.reaperHandle.unref();
|
|
4021
|
-
}
|
|
4022
|
-
}
|
|
4023
|
-
getKey(root, serverId) {
|
|
4024
|
-
return `${root}::${serverId}`;
|
|
4025
|
-
}
|
|
4026
4082
|
tombstoneStop(key, client) {
|
|
4027
4083
|
const stop = stopClientBestEffort(client);
|
|
4028
4084
|
this.pendingStops.set(key, stop);
|
|
@@ -4058,18 +4114,15 @@ class LspManager {
|
|
|
4058
4114
|
budget.deadGenerations = 0;
|
|
4059
4115
|
budget.exhaustedAt = null;
|
|
4060
4116
|
}
|
|
4117
|
+
startupExpired(managed, t) {
|
|
4118
|
+
return managed.isInitializing && managed.initializingSince !== null && t - managed.initializingSince > this.initTimeoutMs;
|
|
4119
|
+
}
|
|
4061
4120
|
reapStale() {
|
|
4062
4121
|
const t = this.now();
|
|
4063
|
-
for (const
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
this.
|
|
4067
|
-
continue;
|
|
4068
|
-
}
|
|
4069
|
-
if (!managed.isInitializing && managed.refCount === 0 && managed.pendingWaiters === 0 && t - managed.lastUsedAt > this.idleTimeoutMs) {
|
|
4070
|
-
this.clients.delete(key);
|
|
4071
|
-
this.tombstoneStop(key, managed.client);
|
|
4072
|
-
}
|
|
4122
|
+
for (const managed of [...this.clients.values()]) {
|
|
4123
|
+
const idle = !managed.isInitializing && managed.refCount === 0 && managed.pendingWaiters === 0 && t - managed.lastUsedAt > this.idleTimeoutMs;
|
|
4124
|
+
if (idle || this.startupExpired(managed, t))
|
|
4125
|
+
this.discard(managed);
|
|
4073
4126
|
}
|
|
4074
4127
|
}
|
|
4075
4128
|
evictForAdmission() {
|
|
@@ -4077,152 +4130,96 @@ class LspManager {
|
|
|
4077
4130
|
const victim = this.leastRecentlyUsedIdleClient();
|
|
4078
4131
|
if (!victim)
|
|
4079
4132
|
return;
|
|
4080
|
-
this.
|
|
4081
|
-
this.tombstoneStop(victim.key, victim.managed.client);
|
|
4133
|
+
this.discard(victim);
|
|
4082
4134
|
}
|
|
4083
4135
|
}
|
|
4084
4136
|
leastRecentlyUsedIdleClient() {
|
|
4085
4137
|
let candidate = null;
|
|
4086
|
-
for (const
|
|
4138
|
+
for (const managed of this.clients.values()) {
|
|
4087
4139
|
if (managed.refCount > 0 || managed.pendingWaiters > 0 || managed.isInitializing)
|
|
4088
4140
|
continue;
|
|
4089
|
-
if (candidate === null || managed.lastUsedAt < candidate.
|
|
4090
|
-
candidate =
|
|
4091
|
-
}
|
|
4141
|
+
if (candidate === null || managed.lastUsedAt < candidate.lastUsedAt)
|
|
4142
|
+
candidate = managed;
|
|
4092
4143
|
}
|
|
4093
4144
|
return candidate;
|
|
4094
4145
|
}
|
|
4095
|
-
|
|
4096
|
-
if (
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4146
|
+
discard(managed) {
|
|
4147
|
+
if (this.clients.get(managed.key) !== managed)
|
|
4148
|
+
return;
|
|
4149
|
+
this.clients.delete(managed.key);
|
|
4150
|
+
this.tombstoneStop(managed.key, managed.client);
|
|
4100
4151
|
}
|
|
4101
4152
|
async getClient(root, server, signal) {
|
|
4102
|
-
|
|
4103
|
-
throw new Error("LspManager has been disposed");
|
|
4104
|
-
}
|
|
4105
|
-
signal?.throwIfAborted();
|
|
4106
|
-
const key = this.getKey(root, server.id);
|
|
4153
|
+
const key = lspClientKey(root, server);
|
|
4107
4154
|
for (;; ) {
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
await awaitWithSignal2(pendingStop, signal);
|
|
4155
|
+
if (this.disposed) {
|
|
4156
|
+
throw new Error("LspManager has been disposed");
|
|
4157
|
+
}
|
|
4112
4158
|
signal?.throwIfAborted();
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
let managed = this.clients.get(key);
|
|
4118
|
-
if (managed) {
|
|
4119
|
-
const t = this.now();
|
|
4120
|
-
if (managed.isInitializing && managed.initializingSince !== null && t - managed.initializingSince > this.initTimeoutMs) {
|
|
4121
|
-
this.clients.delete(key);
|
|
4122
|
-
await this.tombstoneStop(key, managed.client);
|
|
4123
|
-
managed = undefined;
|
|
4159
|
+
const pendingStop = this.pendingStops.get(key);
|
|
4160
|
+
if (pendingStop !== undefined) {
|
|
4161
|
+
await awaitWithSignal2(pendingStop, signal);
|
|
4162
|
+
continue;
|
|
4124
4163
|
}
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4164
|
+
let managed = this.clients.get(key);
|
|
4165
|
+
if (managed !== undefined && this.startupExpired(managed, this.now())) {
|
|
4166
|
+
this.discard(managed);
|
|
4167
|
+
continue;
|
|
4168
|
+
}
|
|
4169
|
+
if (managed === undefined) {
|
|
4170
|
+
this.evictForAdmission();
|
|
4171
|
+
this.ensureRespawnAllowed(key, root, server.id);
|
|
4172
|
+
managed = this.startClient(key, root, server, true);
|
|
4173
|
+
}
|
|
4174
|
+
const { initPromise } = managed;
|
|
4175
|
+
if (initPromise !== null) {
|
|
4176
|
+
await this.startups.wait(managed, initPromise, signal);
|
|
4177
|
+
if (signal?.aborted) {
|
|
4178
|
+
this.startups.detach(managed);
|
|
4179
|
+
signal.throwIfAborted();
|
|
4135
4180
|
}
|
|
4136
4181
|
managed.pendingWaiters--;
|
|
4137
4182
|
}
|
|
4138
|
-
if (
|
|
4139
|
-
|
|
4140
|
-
signal.throwIfAborted();
|
|
4141
|
-
}
|
|
4183
|
+
if (this.clients.get(key) !== managed)
|
|
4184
|
+
continue;
|
|
4142
4185
|
if (!managed.client.isAlive()) {
|
|
4143
4186
|
this.recordDeadGeneration(key);
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
}
|
|
4147
|
-
await this.tombstoneStop(key, managed.client);
|
|
4148
|
-
return this.getClient(root, server, signal);
|
|
4187
|
+
this.discard(managed);
|
|
4188
|
+
continue;
|
|
4149
4189
|
}
|
|
4150
4190
|
this.markHealthyGeneration(key);
|
|
4151
4191
|
managed.refCount++;
|
|
4152
4192
|
managed.lastUsedAt = this.now();
|
|
4153
4193
|
return managed.client;
|
|
4154
4194
|
}
|
|
4155
|
-
|
|
4156
|
-
|
|
4195
|
+
}
|
|
4196
|
+
startClient(key, root, server, heldByWaiters) {
|
|
4157
4197
|
const client = this.clientFactory(root, server);
|
|
4158
|
-
const
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
await client.initialize();
|
|
4162
|
-
})();
|
|
4163
|
-
const newManaged = {
|
|
4164
|
-
client,
|
|
4165
|
-
refCount: 0,
|
|
4166
|
-
pendingWaiters: 1,
|
|
4167
|
-
lastUsedAt: initStartedAt,
|
|
4168
|
-
initPromise,
|
|
4169
|
-
isInitializing: true,
|
|
4170
|
-
initializingSince: initStartedAt
|
|
4171
|
-
};
|
|
4172
|
-
this.clients.set(key, newManaged);
|
|
4173
|
-
try {
|
|
4174
|
-
await awaitWithSignal2(initPromise, signal);
|
|
4175
|
-
} catch (err) {
|
|
4176
|
-
newManaged.pendingWaiters--;
|
|
4177
|
-
if (this.clients.get(key) === newManaged) {
|
|
4178
|
-
this.clients.delete(key);
|
|
4179
|
-
}
|
|
4180
|
-
await this.tombstoneStop(key, client);
|
|
4181
|
-
throw err;
|
|
4182
|
-
}
|
|
4183
|
-
newManaged.pendingWaiters--;
|
|
4184
|
-
newManaged.isInitializing = false;
|
|
4185
|
-
newManaged.initializingSince = null;
|
|
4186
|
-
newManaged.initPromise = null;
|
|
4187
|
-
if (signal?.aborted) {
|
|
4188
|
-
await this.tryDeleteIfOrphaned(key, newManaged);
|
|
4189
|
-
signal.throwIfAborted();
|
|
4190
|
-
}
|
|
4191
|
-
if (!client.isAlive()) {
|
|
4192
|
-
this.recordDeadGeneration(key);
|
|
4193
|
-
if (this.clients.get(key) === newManaged) {
|
|
4194
|
-
this.clients.delete(key);
|
|
4195
|
-
}
|
|
4196
|
-
await this.tombstoneStop(key, client);
|
|
4197
|
-
return this.getClient(root, server, signal);
|
|
4198
|
-
}
|
|
4199
|
-
this.markHealthyGeneration(key);
|
|
4200
|
-
newManaged.refCount++;
|
|
4201
|
-
newManaged.lastUsedAt = this.now();
|
|
4202
|
-
return client;
|
|
4198
|
+
const managed = this.startups.begin({ key, root, serverId: server.id, client, heldByWaiters });
|
|
4199
|
+
this.clients.set(key, managed);
|
|
4200
|
+
return managed;
|
|
4203
4201
|
}
|
|
4204
|
-
releaseClient(root,
|
|
4205
|
-
const
|
|
4206
|
-
|
|
4202
|
+
releaseClient(root, server, client) {
|
|
4203
|
+
const managed = this.clients.get(lspClientKey(root, server));
|
|
4204
|
+
if (client !== undefined && managed?.client !== client)
|
|
4205
|
+
return;
|
|
4207
4206
|
if (managed && managed.refCount > 0) {
|
|
4208
4207
|
managed.refCount--;
|
|
4209
4208
|
managed.lastUsedAt = this.now();
|
|
4210
4209
|
}
|
|
4211
4210
|
}
|
|
4212
|
-
invalidateClient(root,
|
|
4213
|
-
const
|
|
4214
|
-
const managed = this.clients.get(key);
|
|
4211
|
+
invalidateClient(root, server, client) {
|
|
4212
|
+
const managed = this.clients.get(lspClientKey(root, server));
|
|
4215
4213
|
if (!managed)
|
|
4216
4214
|
return;
|
|
4217
4215
|
if (client && managed.client !== client)
|
|
4218
4216
|
return;
|
|
4219
|
-
this.
|
|
4220
|
-
this.tombstoneStop(key, managed.client);
|
|
4217
|
+
this.discard(managed);
|
|
4221
4218
|
}
|
|
4222
4219
|
warmupClient(root, server) {
|
|
4223
4220
|
if (this.disposed)
|
|
4224
4221
|
return;
|
|
4225
|
-
const key =
|
|
4222
|
+
const key = lspClientKey(root, server);
|
|
4226
4223
|
if (this.clients.has(key) || this.pendingStops.has(key))
|
|
4227
4224
|
return;
|
|
4228
4225
|
this.evictForAdmission();
|
|
@@ -4231,45 +4228,18 @@ class LspManager {
|
|
|
4231
4228
|
} catch {
|
|
4232
4229
|
return;
|
|
4233
4230
|
}
|
|
4234
|
-
|
|
4235
|
-
const initStartedAt = this.now();
|
|
4236
|
-
const initPromise = (async () => {
|
|
4237
|
-
await client.start();
|
|
4238
|
-
await client.initialize();
|
|
4239
|
-
})();
|
|
4240
|
-
const managed = {
|
|
4241
|
-
client,
|
|
4242
|
-
refCount: 0,
|
|
4243
|
-
pendingWaiters: 0,
|
|
4244
|
-
lastUsedAt: initStartedAt,
|
|
4245
|
-
initPromise,
|
|
4246
|
-
isInitializing: true,
|
|
4247
|
-
initializingSince: initStartedAt
|
|
4248
|
-
};
|
|
4249
|
-
this.clients.set(key, managed);
|
|
4250
|
-
initPromise.then(() => {
|
|
4251
|
-
managed.isInitializing = false;
|
|
4252
|
-
managed.initializingSince = null;
|
|
4253
|
-
managed.initPromise = null;
|
|
4254
|
-
managed.lastUsedAt = this.now();
|
|
4255
|
-
}, () => {
|
|
4256
|
-
if (this.clients.get(key) === managed) {
|
|
4257
|
-
this.clients.delete(key);
|
|
4258
|
-
}
|
|
4259
|
-
this.tombstoneStop(key, client);
|
|
4260
|
-
});
|
|
4231
|
+
this.startClient(key, root, server, false);
|
|
4261
4232
|
}
|
|
4262
|
-
isServerInitializing(root,
|
|
4263
|
-
const managed = this.clients.get(
|
|
4233
|
+
isServerInitializing(root, server) {
|
|
4234
|
+
const managed = this.clients.get(lspClientKey(root, server));
|
|
4264
4235
|
return managed?.isInitializing ?? false;
|
|
4265
4236
|
}
|
|
4266
4237
|
getSnapshot() {
|
|
4267
4238
|
const snapshots = [];
|
|
4268
|
-
for (const
|
|
4269
|
-
const [root, serverId] = key.split("::");
|
|
4239
|
+
for (const managed of this.clients.values()) {
|
|
4270
4240
|
snapshots.push({
|
|
4271
|
-
root,
|
|
4272
|
-
serverId,
|
|
4241
|
+
root: managed.root,
|
|
4242
|
+
serverId: managed.serverId,
|
|
4273
4243
|
refCount: managed.refCount,
|
|
4274
4244
|
pendingWaiters: managed.pendingWaiters,
|
|
4275
4245
|
lastUsedAt: managed.lastUsedAt,
|
|
@@ -4280,18 +4250,15 @@ class LspManager {
|
|
|
4280
4250
|
}
|
|
4281
4251
|
return snapshots;
|
|
4282
4252
|
}
|
|
4283
|
-
hasClient(root,
|
|
4284
|
-
return this.clients.has(
|
|
4253
|
+
hasClient(root, server) {
|
|
4254
|
+
return this.clients.has(lspClientKey(root, server));
|
|
4285
4255
|
}
|
|
4286
4256
|
clientCount() {
|
|
4287
4257
|
return this.clients.size;
|
|
4288
4258
|
}
|
|
4289
4259
|
async stopAll() {
|
|
4290
4260
|
this.disposed = true;
|
|
4291
|
-
|
|
4292
|
-
clearInterval(this.reaperHandle);
|
|
4293
|
-
this.reaperHandle = null;
|
|
4294
|
-
}
|
|
4261
|
+
this.stopReaper();
|
|
4295
4262
|
if (this.signalDisposer) {
|
|
4296
4263
|
this.signalDisposer();
|
|
4297
4264
|
this.signalDisposer = null;
|
|
@@ -4660,6 +4627,7 @@ function getMergedServers() {
|
|
|
4660
4627
|
extensions: config.extensions,
|
|
4661
4628
|
priority: -100,
|
|
4662
4629
|
source: "builtin",
|
|
4630
|
+
inheritsBuiltinCommand: true,
|
|
4663
4631
|
...config.initialization === undefined ? {} : { initialization: config.initialization }
|
|
4664
4632
|
});
|
|
4665
4633
|
}
|
|
@@ -4685,8 +4653,11 @@ function createServerFromEntry(id, entry, source) {
|
|
|
4685
4653
|
command: builtin.command,
|
|
4686
4654
|
extensions: entry.extensions ?? builtin.extensions,
|
|
4687
4655
|
priority: entry.priority ?? 0,
|
|
4688
|
-
source
|
|
4656
|
+
source,
|
|
4657
|
+
inheritsBuiltinCommand: true
|
|
4689
4658
|
});
|
|
4659
|
+
if (entry.initialization !== undefined)
|
|
4660
|
+
server.configuredInitialization = entry.initialization;
|
|
4690
4661
|
const initialization = mergeInitialization(builtin.initialization, entry.initialization);
|
|
4691
4662
|
if (initialization !== undefined) {
|
|
4692
4663
|
server.initialization = initialization;
|
|
@@ -4699,7 +4670,8 @@ function createServerFromEntry(id, entry, source) {
|
|
|
4699
4670
|
command: entry.command,
|
|
4700
4671
|
extensions: entry.extensions,
|
|
4701
4672
|
priority: entry.priority ?? 0,
|
|
4702
|
-
source
|
|
4673
|
+
source,
|
|
4674
|
+
inheritsBuiltinCommand: false
|
|
4703
4675
|
});
|
|
4704
4676
|
applyOptionalServerFields(server, entry);
|
|
4705
4677
|
return server;
|
|
@@ -4711,7 +4683,8 @@ function createServerFromEntry(id, entry, source) {
|
|
|
4711
4683
|
command: entry.command ?? builtin.command,
|
|
4712
4684
|
extensions: entry.extensions ?? builtin.extensions,
|
|
4713
4685
|
priority: entry.priority ?? 0,
|
|
4714
|
-
source
|
|
4686
|
+
source,
|
|
4687
|
+
inheritsBuiltinCommand: entry.command === undefined
|
|
4715
4688
|
});
|
|
4716
4689
|
applyOptionalServerFields(server, entry);
|
|
4717
4690
|
const builtinInitialization = entry.command === undefined ? builtin.initialization : undefined;
|
|
@@ -4734,7 +4707,8 @@ function createServer(input) {
|
|
|
4734
4707
|
command: input.command,
|
|
4735
4708
|
extensions: input.extensions,
|
|
4736
4709
|
priority: input.priority,
|
|
4737
|
-
source: input.source
|
|
4710
|
+
source: input.source,
|
|
4711
|
+
inheritsBuiltinCommand: input.inheritsBuiltinCommand
|
|
4738
4712
|
};
|
|
4739
4713
|
if (input.env !== undefined) {
|
|
4740
4714
|
server.env = input.env;
|
|
@@ -4750,6 +4724,7 @@ function applyOptionalServerFields(server, entry) {
|
|
|
4750
4724
|
}
|
|
4751
4725
|
if (entry.initialization !== undefined) {
|
|
4752
4726
|
server.initialization = entry.initialization;
|
|
4727
|
+
server.configuredInitialization = entry.initialization;
|
|
4753
4728
|
}
|
|
4754
4729
|
}
|
|
4755
4730
|
function isConfigJson(value) {
|
|
@@ -4841,14 +4816,24 @@ function readHead(path) {
|
|
|
4841
4816
|
}
|
|
4842
4817
|
}
|
|
4843
4818
|
|
|
4819
|
+
// ../lsp-core/src/lsp/native-typescript.ts
|
|
4820
|
+
import { existsSync as existsSync11, realpathSync as realpathSync6, statSync as statSync4 } from "node:fs";
|
|
4821
|
+
import { dirname as dirname10, join as join5, resolve as resolve8 } from "node:path";
|
|
4822
|
+
|
|
4844
4823
|
// ../lsp-core/src/lsp/server-installation.ts
|
|
4845
4824
|
import { existsSync as existsSync10 } from "node:fs";
|
|
4846
4825
|
import { delimiter as delimiter3, dirname as dirname9, isAbsolute as isAbsolute5, join as join4, resolve as resolve7 } from "node:path";
|
|
4826
|
+
var NODE_PROJECT_MARKERS = [
|
|
4827
|
+
"package.json",
|
|
4828
|
+
"bun.lock",
|
|
4829
|
+
"bun.lockb",
|
|
4830
|
+
"package-lock.json",
|
|
4831
|
+
"yarn.lock",
|
|
4832
|
+
"pnpm-lock.yaml"
|
|
4833
|
+
];
|
|
4834
|
+
var NODE_LOCAL_BIN_DIR = join4("node_modules", ".bin");
|
|
4847
4835
|
var LOCAL_BIN_RULES = [
|
|
4848
|
-
{
|
|
4849
|
-
markers: ["package.json", "bun.lock", "bun.lockb", "package-lock.json", "yarn.lock", "pnpm-lock.yaml"],
|
|
4850
|
-
binDirs: [join4("node_modules", ".bin")]
|
|
4851
|
-
},
|
|
4836
|
+
{ markers: NODE_PROJECT_MARKERS, binDirs: [NODE_LOCAL_BIN_DIR] },
|
|
4852
4837
|
{
|
|
4853
4838
|
markers: [
|
|
4854
4839
|
"pyproject.toml",
|
|
@@ -4976,6 +4961,57 @@ function isServerInstalled(command, workingDirectory, options = {}) {
|
|
|
4976
4961
|
return resolveServerBinary(command, workingDirectory, options) !== null;
|
|
4977
4962
|
}
|
|
4978
4963
|
|
|
4964
|
+
// ../lsp-core/src/lsp/native-typescript.ts
|
|
4965
|
+
function nativeTypescriptSearchDirectory(targetPath, workingDirectory) {
|
|
4966
|
+
try {
|
|
4967
|
+
const session = realpathSync6(workingDirectory);
|
|
4968
|
+
if (targetPath === undefined)
|
|
4969
|
+
return session;
|
|
4970
|
+
const target = canonicalizeExistingOrNearestAncestor(resolve8(workingDirectory, targetPath));
|
|
4971
|
+
if (!isPathInside(session, target))
|
|
4972
|
+
return session;
|
|
4973
|
+
return statSync4(target, { throwIfNoEntry: false })?.isDirectory() === true ? target : dirname10(target);
|
|
4974
|
+
} catch {
|
|
4975
|
+
return workingDirectory;
|
|
4976
|
+
}
|
|
4977
|
+
}
|
|
4978
|
+
function nativeTypescriptCommand(server, searchDirectory) {
|
|
4979
|
+
if (server.id !== "typescript" || !server.inheritsBuiltinCommand)
|
|
4980
|
+
return null;
|
|
4981
|
+
const found = findProjectTsc(searchDirectory);
|
|
4982
|
+
if (found === null)
|
|
4983
|
+
return null;
|
|
4984
|
+
const speaksLsp = !existsSync11(join5(found.packageDir, "lib", "tsserver.js"));
|
|
4985
|
+
return speaksLsp ? [found.tsc, "--lsp", "--stdio"] : null;
|
|
4986
|
+
}
|
|
4987
|
+
function findProjectTsc(searchDirectory) {
|
|
4988
|
+
const suffixes = executableSuffixes(process.platform, undefined);
|
|
4989
|
+
let current = searchDirectory;
|
|
4990
|
+
for (;; ) {
|
|
4991
|
+
if (NODE_PROJECT_MARKERS.some((marker) => probe(join5(current, marker)))) {
|
|
4992
|
+
const binDir = join5(current, NODE_LOCAL_BIN_DIR);
|
|
4993
|
+
const tsc = probeWithSuffixes(binDir, "tsc", suffixes);
|
|
4994
|
+
const packageDir = join5(binDir, "..", "typescript");
|
|
4995
|
+
if (tsc !== null && isRealDirectory(binDir) && existsSync11(join5(packageDir, "package.json"))) {
|
|
4996
|
+
return { tsc, packageDir };
|
|
4997
|
+
}
|
|
4998
|
+
}
|
|
4999
|
+
if (probe(join5(current, ".git")))
|
|
5000
|
+
return null;
|
|
5001
|
+
const parent = dirname10(current);
|
|
5002
|
+
if (parent === current)
|
|
5003
|
+
return null;
|
|
5004
|
+
current = parent;
|
|
5005
|
+
}
|
|
5006
|
+
}
|
|
5007
|
+
function isRealDirectory(directory) {
|
|
5008
|
+
try {
|
|
5009
|
+
return realpathSync6(directory) === directory;
|
|
5010
|
+
} catch {
|
|
5011
|
+
return false;
|
|
5012
|
+
}
|
|
5013
|
+
}
|
|
5014
|
+
|
|
4979
5015
|
// ../lsp-core/src/lsp/server-resolution.ts
|
|
4980
5016
|
function withResolvedCommand(command, binaryPath) {
|
|
4981
5017
|
return [binaryPath, ...command.slice(1)];
|
|
@@ -4984,12 +5020,27 @@ function usesBuiltinCommand(id, command) {
|
|
|
4984
5020
|
const builtin = BUILTIN_SERVERS[id]?.command;
|
|
4985
5021
|
return builtin !== undefined && builtin.length === command.length && builtin.every((part, index) => part === command[index]);
|
|
4986
5022
|
}
|
|
4987
|
-
function findServerForExtension(ext) {
|
|
5023
|
+
function findServerForExtension(ext, targetPath) {
|
|
4988
5024
|
const servers = getMergedServers();
|
|
4989
5025
|
const workingDirectory = contextCwd();
|
|
5026
|
+
const searchDirectory = nativeTypescriptSearchDirectory(targetPath, workingDirectory);
|
|
4990
5027
|
for (const server of servers) {
|
|
4991
5028
|
if (!server.extensions.includes(ext))
|
|
4992
5029
|
continue;
|
|
5030
|
+
const nativeTypescript = nativeTypescriptCommand(server, searchDirectory);
|
|
5031
|
+
if (nativeTypescript !== null) {
|
|
5032
|
+
return {
|
|
5033
|
+
status: "found",
|
|
5034
|
+
server: {
|
|
5035
|
+
id: server.id,
|
|
5036
|
+
command: withHostJsRuntime(server.id, nativeTypescript),
|
|
5037
|
+
extensions: server.extensions,
|
|
5038
|
+
priority: server.priority,
|
|
5039
|
+
...server.env === undefined ? {} : { env: server.env },
|
|
5040
|
+
...server.configuredInitialization === undefined ? {} : { initialization: server.configuredInitialization }
|
|
5041
|
+
}
|
|
5042
|
+
};
|
|
5043
|
+
}
|
|
4993
5044
|
const binaryPath = resolveServerBinary(server.command, workingDirectory);
|
|
4994
5045
|
if (binaryPath !== null) {
|
|
4995
5046
|
const resolvedServer = {
|
|
@@ -5042,6 +5093,7 @@ function getAllServers() {
|
|
|
5042
5093
|
const servers = getMergedServers();
|
|
5043
5094
|
const disabled = getDisabledServerIds();
|
|
5044
5095
|
const workingDirectory = contextCwd();
|
|
5096
|
+
const nativeSearchDirectory = nativeTypescriptSearchDirectory(undefined, workingDirectory);
|
|
5045
5097
|
const result = [];
|
|
5046
5098
|
const seen = new Set;
|
|
5047
5099
|
for (const server of servers) {
|
|
@@ -5049,7 +5101,7 @@ function getAllServers() {
|
|
|
5049
5101
|
continue;
|
|
5050
5102
|
result.push({
|
|
5051
5103
|
id: server.id,
|
|
5052
|
-
installed: isServerInstalled(server.command, workingDirectory),
|
|
5104
|
+
installed: isServerInstalled(server.command, workingDirectory) || nativeTypescriptCommand(server, nativeSearchDirectory) !== null,
|
|
5053
5105
|
extensions: server.extensions,
|
|
5054
5106
|
disabled: false,
|
|
5055
5107
|
source: server.source,
|
|
@@ -5076,7 +5128,7 @@ function getAllServers() {
|
|
|
5076
5128
|
// ../lsp-core/src/lsp/client-wrapper.ts
|
|
5077
5129
|
function isDirectoryPath(filePath) {
|
|
5078
5130
|
try {
|
|
5079
|
-
return
|
|
5131
|
+
return statSync5(filePath).isDirectory();
|
|
5080
5132
|
} catch {
|
|
5081
5133
|
return false;
|
|
5082
5134
|
}
|
|
@@ -5086,7 +5138,7 @@ function findWorkspaceRoot(filePath) {
|
|
|
5086
5138
|
const abs = resolveReadablePathInsideContext(filePath);
|
|
5087
5139
|
let dir = abs;
|
|
5088
5140
|
if (!isDirectoryPath(dir)) {
|
|
5089
|
-
dir =
|
|
5141
|
+
dir = dirname11(dir);
|
|
5090
5142
|
}
|
|
5091
5143
|
if (!isPathInside(cwd, abs))
|
|
5092
5144
|
return findWorkspaceRootOutsideContext(dir);
|
|
@@ -5095,7 +5147,7 @@ function findWorkspaceRoot(filePath) {
|
|
|
5095
5147
|
while (isPathInside(cwd, dir)) {
|
|
5096
5148
|
const canonicalDir = existingDirectoryInsideContext(dir, cwd);
|
|
5097
5149
|
if (canonicalDir !== undefined) {
|
|
5098
|
-
if (
|
|
5150
|
+
if (existsSync12(join6(dir, GIT_WORKSPACE_MARKER))) {
|
|
5099
5151
|
return canonicalDir;
|
|
5100
5152
|
}
|
|
5101
5153
|
if (nearestPackageRoot === undefined && hasProjectWorkspaceMarker(dir)) {
|
|
@@ -5104,16 +5156,16 @@ function findWorkspaceRoot(filePath) {
|
|
|
5104
5156
|
}
|
|
5105
5157
|
if (dir === cwd)
|
|
5106
5158
|
break;
|
|
5107
|
-
dir =
|
|
5159
|
+
dir = dirname11(dir);
|
|
5108
5160
|
}
|
|
5109
5161
|
return nearestPackageRoot ?? fallbackRoot;
|
|
5110
5162
|
}
|
|
5111
5163
|
function hasProjectWorkspaceMarker(directory) {
|
|
5112
|
-
return PROJECT_WORKSPACE_MARKERS.some((marker) =>
|
|
5164
|
+
return PROJECT_WORKSPACE_MARKERS.some((marker) => existsSync12(join6(directory, marker)));
|
|
5113
5165
|
}
|
|
5114
5166
|
function resolveReadablePathInsideContext(filePath) {
|
|
5115
5167
|
const cwd = contextCwd();
|
|
5116
|
-
const abs =
|
|
5168
|
+
const abs = resolve9(cwd, filePath);
|
|
5117
5169
|
if (isPathInside(cwd, abs))
|
|
5118
5170
|
return abs;
|
|
5119
5171
|
const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
|
|
@@ -5134,12 +5186,12 @@ function rebaseThroughCanonicalAncestor(path, cwd) {
|
|
|
5134
5186
|
let current = path;
|
|
5135
5187
|
const suffix = [];
|
|
5136
5188
|
while (true) {
|
|
5137
|
-
if (
|
|
5138
|
-
const canonical =
|
|
5189
|
+
if (existsSync12(current)) {
|
|
5190
|
+
const canonical = realpathSync7(current);
|
|
5139
5191
|
if (isPathInside(cwd, canonical))
|
|
5140
|
-
return suffix.length === 0 ? canonical :
|
|
5192
|
+
return suffix.length === 0 ? canonical : join6(canonical, ...suffix);
|
|
5141
5193
|
}
|
|
5142
|
-
const parent =
|
|
5194
|
+
const parent = dirname11(current);
|
|
5143
5195
|
if (parent === current)
|
|
5144
5196
|
return;
|
|
5145
5197
|
suffix.unshift(basename3(current));
|
|
@@ -5147,10 +5199,10 @@ function rebaseThroughCanonicalAncestor(path, cwd) {
|
|
|
5147
5199
|
}
|
|
5148
5200
|
}
|
|
5149
5201
|
function existingDirectoryInsideContext(directory, cwd) {
|
|
5150
|
-
if (!
|
|
5202
|
+
if (!existsSync12(directory))
|
|
5151
5203
|
return;
|
|
5152
|
-
const canonical =
|
|
5153
|
-
if (!
|
|
5204
|
+
const canonical = realpathSync7(directory);
|
|
5205
|
+
if (!statSync5(canonical).isDirectory())
|
|
5154
5206
|
return;
|
|
5155
5207
|
return isPathInside(cwd, canonical) ? canonical : undefined;
|
|
5156
5208
|
}
|
|
@@ -5162,7 +5214,7 @@ function nearestExistingDirectoryInsideContext(directory, cwd) {
|
|
|
5162
5214
|
return canonical;
|
|
5163
5215
|
if (current === cwd)
|
|
5164
5216
|
return;
|
|
5165
|
-
current =
|
|
5217
|
+
current = dirname11(current);
|
|
5166
5218
|
}
|
|
5167
5219
|
return;
|
|
5168
5220
|
}
|
|
@@ -5262,7 +5314,7 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
|
5262
5314
|
throw new LspInvalidPathError("Directory paths are not supported by this LSP tool. " + "Use lsp.diagnostics with a directory path for directory diagnostics.");
|
|
5263
5315
|
}
|
|
5264
5316
|
const ext = effectiveExtension(absPath);
|
|
5265
|
-
const result = findServerForExtension(ext);
|
|
5317
|
+
const result = findServerForExtension(ext, absPath);
|
|
5266
5318
|
if (result.status !== "found") {
|
|
5267
5319
|
throw new LspServerLookupError(formatServerLookupError(result), result);
|
|
5268
5320
|
}
|
|
@@ -5275,25 +5327,153 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
|
5275
5327
|
return await fn(client, root, absPath);
|
|
5276
5328
|
} catch (err) {
|
|
5277
5329
|
if (allowRetry && READ_ONLY_TOOLS.has(toolName) && isLspDeadConnectionError(err)) {
|
|
5278
|
-
manager.invalidateClient(root, server
|
|
5330
|
+
manager.invalidateClient(root, server, client);
|
|
5279
5331
|
return acquireAndCall(false);
|
|
5280
5332
|
}
|
|
5281
5333
|
if (err instanceof LspRequestTimeoutError) {
|
|
5282
|
-
if (manager.isServerInitializing(root, server
|
|
5334
|
+
if (manager.isServerInitializing(root, server)) {
|
|
5283
5335
|
throw new LspServerInitializingError(err);
|
|
5284
5336
|
}
|
|
5285
5337
|
}
|
|
5286
5338
|
throw err;
|
|
5287
5339
|
} finally {
|
|
5288
|
-
manager.releaseClient(root, server
|
|
5340
|
+
manager.releaseClient(root, server, client);
|
|
5289
5341
|
}
|
|
5290
5342
|
};
|
|
5291
5343
|
return acquireAndCall(true);
|
|
5292
5344
|
}
|
|
5293
5345
|
|
|
5294
5346
|
// ../lsp-core/src/lsp/directory-diagnostics.ts
|
|
5295
|
-
import { existsSync as
|
|
5296
|
-
import { join as
|
|
5347
|
+
import { existsSync as existsSync13, lstatSync as lstatSync5, readdirSync as readdirSync3 } from "node:fs";
|
|
5348
|
+
import { join as join7, resolve as resolve10 } from "node:path";
|
|
5349
|
+
|
|
5350
|
+
// ../lsp-core/src/lsp/directory-group-scan.ts
|
|
5351
|
+
async function scanServedGroups(options) {
|
|
5352
|
+
const { groups, signal } = options;
|
|
5353
|
+
const limit = Math.max(1, options.maxConcurrency);
|
|
5354
|
+
const fileSlots = createSlots(limit);
|
|
5355
|
+
let nextGroup = 0;
|
|
5356
|
+
let startedGroups = 0;
|
|
5357
|
+
let firstError;
|
|
5358
|
+
const runners = Array.from({ length: Math.min(limit, groups.length) }, async () => {
|
|
5359
|
+
for (;; ) {
|
|
5360
|
+
if (signal?.aborted)
|
|
5361
|
+
return;
|
|
5362
|
+
const group = groups[nextGroup];
|
|
5363
|
+
nextGroup += 1;
|
|
5364
|
+
if (group === undefined)
|
|
5365
|
+
return;
|
|
5366
|
+
let client;
|
|
5367
|
+
try {
|
|
5368
|
+
client = await acquireWithinInitTimeout(options, group);
|
|
5369
|
+
} catch (error) {
|
|
5370
|
+
if (signal?.aborted)
|
|
5371
|
+
return;
|
|
5372
|
+
firstError ??= error;
|
|
5373
|
+
options.onGroupUnavailable(group, error instanceof Error ? error.message : String(error));
|
|
5374
|
+
continue;
|
|
5375
|
+
}
|
|
5376
|
+
startedGroups += 1;
|
|
5377
|
+
try {
|
|
5378
|
+
await Promise.all(group.files.map(async (file) => {
|
|
5379
|
+
const release = await fileSlots.acquire();
|
|
5380
|
+
try {
|
|
5381
|
+
if (!signal?.aborted)
|
|
5382
|
+
await options.checkFile(client, file);
|
|
5383
|
+
} finally {
|
|
5384
|
+
release();
|
|
5385
|
+
}
|
|
5386
|
+
}));
|
|
5387
|
+
} finally {
|
|
5388
|
+
options.manager.releaseClient(group.root, group.server, client);
|
|
5389
|
+
}
|
|
5390
|
+
}
|
|
5391
|
+
});
|
|
5392
|
+
await Promise.all(runners);
|
|
5393
|
+
signal?.throwIfAborted();
|
|
5394
|
+
if (startedGroups === 0 && firstError !== undefined)
|
|
5395
|
+
throw firstError;
|
|
5396
|
+
}
|
|
5397
|
+
async function acquireWithinInitTimeout(options, group) {
|
|
5398
|
+
const { signal } = options;
|
|
5399
|
+
const timers = options.timers ?? realTimerProvider;
|
|
5400
|
+
const controller = new AbortController;
|
|
5401
|
+
const forwardAbort = () => controller.abort(signal?.reason);
|
|
5402
|
+
signal?.addEventListener("abort", forwardAbort, { once: true });
|
|
5403
|
+
if (signal?.aborted)
|
|
5404
|
+
forwardAbort();
|
|
5405
|
+
let timedOut = false;
|
|
5406
|
+
const timer = timers.setTimeout(() => {
|
|
5407
|
+
timedOut = true;
|
|
5408
|
+
controller.abort();
|
|
5409
|
+
}, INIT_TIMEOUT_MS);
|
|
5410
|
+
try {
|
|
5411
|
+
return await options.manager.getClient(group.root, group.server, controller.signal);
|
|
5412
|
+
} catch (error) {
|
|
5413
|
+
if (timedOut && signal?.aborted !== true) {
|
|
5414
|
+
throw new Error(`${group.server.id} did not start within ${INIT_TIMEOUT_MS}ms`);
|
|
5415
|
+
}
|
|
5416
|
+
throw error;
|
|
5417
|
+
} finally {
|
|
5418
|
+
timers.clearTimeout(timer);
|
|
5419
|
+
signal?.removeEventListener("abort", forwardAbort);
|
|
5420
|
+
}
|
|
5421
|
+
}
|
|
5422
|
+
function createSlots(limit) {
|
|
5423
|
+
let free = limit;
|
|
5424
|
+
const waiting = [];
|
|
5425
|
+
const release = () => {
|
|
5426
|
+
const next = waiting.shift();
|
|
5427
|
+
if (next === undefined)
|
|
5428
|
+
free += 1;
|
|
5429
|
+
else
|
|
5430
|
+
next();
|
|
5431
|
+
};
|
|
5432
|
+
return {
|
|
5433
|
+
acquire() {
|
|
5434
|
+
if (free > 0) {
|
|
5435
|
+
free -= 1;
|
|
5436
|
+
return Promise.resolve(release);
|
|
5437
|
+
}
|
|
5438
|
+
return new Promise((resolve) => waiting.push(() => resolve(release)));
|
|
5439
|
+
}
|
|
5440
|
+
};
|
|
5441
|
+
}
|
|
5442
|
+
|
|
5443
|
+
// ../lsp-core/src/lsp/directory-server-groups.ts
|
|
5444
|
+
import { dirname as dirname12 } from "node:path";
|
|
5445
|
+
function groupFilesByClient(files, extension, fixed = {}) {
|
|
5446
|
+
const byDirectory = new Map;
|
|
5447
|
+
const served = new Map;
|
|
5448
|
+
const unserved = new Map;
|
|
5449
|
+
for (const file of files) {
|
|
5450
|
+
const directory = dirname12(file);
|
|
5451
|
+
let resolution = byDirectory.get(directory);
|
|
5452
|
+
if (resolution === undefined) {
|
|
5453
|
+
resolution = resolveDirectory(directory, extension, fixed);
|
|
5454
|
+
byDirectory.set(directory, resolution);
|
|
5455
|
+
}
|
|
5456
|
+
if (resolution.kind === "served") {
|
|
5457
|
+
const group = served.get(resolution.key) ?? { root: resolution.root, server: resolution.server, files: [] };
|
|
5458
|
+
group.files.push(file);
|
|
5459
|
+
served.set(resolution.key, group);
|
|
5460
|
+
} else {
|
|
5461
|
+
const group = unserved.get(resolution.key) ?? { lookup: resolution.lookup, files: [] };
|
|
5462
|
+
group.files.push(file);
|
|
5463
|
+
unserved.set(resolution.key, group);
|
|
5464
|
+
}
|
|
5465
|
+
}
|
|
5466
|
+
return { served: [...served.values()], unserved: [...unserved.values()] };
|
|
5467
|
+
}
|
|
5468
|
+
function resolveDirectory(directory, extension, fixed) {
|
|
5469
|
+
const lookup = fixed.server === undefined ? findServerForExtension(extension, directory) : { status: "found", server: fixed.server };
|
|
5470
|
+
if (lookup.status !== "found") {
|
|
5471
|
+
const serverId = lookup.status === "not_installed" ? lookup.server.id : "";
|
|
5472
|
+
return { kind: "unserved", key: JSON.stringify([lookup.status, serverId]), lookup };
|
|
5473
|
+
}
|
|
5474
|
+
const root = fixed.workspaceRoot ?? findWorkspaceRoot(directory);
|
|
5475
|
+
return { kind: "served", key: lspClientKey(root, lookup.server), root, server: lookup.server };
|
|
5476
|
+
}
|
|
5297
5477
|
|
|
5298
5478
|
// ../lsp-core/src/lsp/formatters.ts
|
|
5299
5479
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -5423,7 +5603,7 @@ function collectFilesWithExtension(dir, extension, maxFiles) {
|
|
|
5423
5603
|
for (const entry of entries) {
|
|
5424
5604
|
if (files.length >= maxFiles)
|
|
5425
5605
|
return;
|
|
5426
|
-
const fullPath =
|
|
5606
|
+
const fullPath = join7(currentDir, entry);
|
|
5427
5607
|
let stat;
|
|
5428
5608
|
try {
|
|
5429
5609
|
stat = lstatSync5(fullPath);
|
|
@@ -5448,15 +5628,10 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
5448
5628
|
if (!extension.startsWith(".")) {
|
|
5449
5629
|
throw new LspInvalidPathError(`Extension must start with a dot (e.g., ".ts", not "${extension}"). Use ".${extension}" instead.`);
|
|
5450
5630
|
}
|
|
5451
|
-
const absDir =
|
|
5452
|
-
if (!
|
|
5631
|
+
const absDir = resolve10(options.workspaceRoot ?? contextCwd(), directory);
|
|
5632
|
+
if (!existsSync13(absDir)) {
|
|
5453
5633
|
throw new LspInvalidPathError(`Directory does not exist: ${absDir}`);
|
|
5454
5634
|
}
|
|
5455
|
-
const serverResult = options.server === undefined ? findServerForExtension(extension) : { status: "found", server: options.server };
|
|
5456
|
-
if (serverResult.status !== "found") {
|
|
5457
|
-
throw new LspServerLookupError(formatServerLookupError(serverResult));
|
|
5458
|
-
}
|
|
5459
|
-
const server = serverResult.server;
|
|
5460
5635
|
const allFiles = (options.listFiles ?? collectFilesWithExtension)(absDir, extension, maxFiles + 1);
|
|
5461
5636
|
const wasCapped = allFiles.length > maxFiles;
|
|
5462
5637
|
const filesToProcess = allFiles.slice(0, maxFiles);
|
|
@@ -5470,42 +5645,43 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
5470
5645
|
`);
|
|
5471
5646
|
return { output, totalDiagnostics: 0, fileFailures: [] };
|
|
5472
5647
|
}
|
|
5473
|
-
const
|
|
5648
|
+
const groups = groupFilesByClient(filesToProcess, extension, {
|
|
5649
|
+
...options.server === undefined ? {} : { server: options.server },
|
|
5650
|
+
...options.workspaceRoot === undefined ? {} : { workspaceRoot: options.workspaceRoot }
|
|
5651
|
+
});
|
|
5652
|
+
const firstUnserved = groups.unserved[0];
|
|
5653
|
+
if (groups.served.length === 0 && firstUnserved !== undefined) {
|
|
5654
|
+
throw new LspServerLookupError(formatServerLookupError(firstUnserved.lookup));
|
|
5655
|
+
}
|
|
5474
5656
|
const manager = options.manager ?? getLspManager();
|
|
5475
5657
|
const allDiagnostics = [];
|
|
5476
5658
|
const fileErrors = [];
|
|
5477
5659
|
const maxConcurrency = Math.max(1, options.maxConcurrency ?? DIRECTORY_DIAGNOSTICS_MAX_CONCURRENCY);
|
|
5660
|
+
for (const group of groups.unserved) {
|
|
5661
|
+
const error = formatServerLookupError(group.lookup).split(`
|
|
5662
|
+
`)[0] ?? "No LSP server";
|
|
5663
|
+
fileErrors.push(...group.files.map((file) => ({ file, error })));
|
|
5664
|
+
}
|
|
5478
5665
|
options.signal?.throwIfAborted();
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
diagnostic
|
|
5496
|
-
})));
|
|
5497
|
-
} catch (e) {
|
|
5498
|
-
fileErrors.push({
|
|
5499
|
-
file,
|
|
5500
|
-
error: e instanceof Error ? e.message : String(e)
|
|
5501
|
-
});
|
|
5502
|
-
}
|
|
5666
|
+
await scanServedGroups({
|
|
5667
|
+
manager,
|
|
5668
|
+
groups: groups.served,
|
|
5669
|
+
maxConcurrency,
|
|
5670
|
+
...options.signal === undefined ? {} : { signal: options.signal },
|
|
5671
|
+
...options.timers === undefined ? {} : { timers: options.timers },
|
|
5672
|
+
onGroupUnavailable: (group, error) => {
|
|
5673
|
+
fileErrors.push(...group.files.map((file) => ({ file, error })));
|
|
5674
|
+
},
|
|
5675
|
+
checkFile: async (client, file) => {
|
|
5676
|
+
try {
|
|
5677
|
+
const result = await client.diagnostics(file, options.signal);
|
|
5678
|
+
const filtered = filterDiagnosticsBySeverity(result.items, severity);
|
|
5679
|
+
allDiagnostics.push(...filtered.map((diagnostic) => ({ filePath: file, diagnostic })));
|
|
5680
|
+
} catch (e) {
|
|
5681
|
+
fileErrors.push({ file, error: e instanceof Error ? e.message : String(e) });
|
|
5503
5682
|
}
|
|
5504
|
-
}
|
|
5505
|
-
|
|
5506
|
-
} finally {
|
|
5507
|
-
manager.releaseClient(root, server.id);
|
|
5508
|
-
}
|
|
5683
|
+
}
|
|
5684
|
+
});
|
|
5509
5685
|
const displayDiagnostics = allDiagnostics.slice(0, DEFAULT_MAX_DIAGNOSTICS);
|
|
5510
5686
|
const wasDiagCapped = allDiagnostics.length > DEFAULT_MAX_DIAGNOSTICS;
|
|
5511
5687
|
const lines = [
|
|
@@ -5536,7 +5712,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
5536
5712
|
|
|
5537
5713
|
// ../lsp-core/src/lsp/infer-extension.ts
|
|
5538
5714
|
import { lstatSync as lstatSync6, readdirSync as readdirSync4 } from "node:fs";
|
|
5539
|
-
import { join as
|
|
5715
|
+
import { join as join8 } from "node:path";
|
|
5540
5716
|
var SKIP_DIRECTORIES2 = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]);
|
|
5541
5717
|
var MAX_SCAN_ENTRIES = 500;
|
|
5542
5718
|
function inferExtensionFromDirectory(directory) {
|
|
@@ -5554,7 +5730,7 @@ function inferExtensionFromDirectory(directory) {
|
|
|
5554
5730
|
for (const entry of entries) {
|
|
5555
5731
|
if (scanned >= MAX_SCAN_ENTRIES)
|
|
5556
5732
|
return;
|
|
5557
|
-
const fullPath =
|
|
5733
|
+
const fullPath = join8(dir, entry);
|
|
5558
5734
|
let stat;
|
|
5559
5735
|
try {
|
|
5560
5736
|
stat = lstatSync6(fullPath);
|
|
@@ -5673,7 +5849,7 @@ function missingDependencyAvailability(error) {
|
|
|
5673
5849
|
}
|
|
5674
5850
|
|
|
5675
5851
|
// ../lsp-core/src/lsp/bun-command-output.ts
|
|
5676
|
-
import { resolve as
|
|
5852
|
+
import { resolve as resolve11 } from "node:path";
|
|
5677
5853
|
var TSC_LINE = /^(.+?)\((\d+),(\d+)\): (error|warning|message) (TS\d+): (.*)$/;
|
|
5678
5854
|
var TSC_SEVERITY = { error: 1, warning: 2, message: 3 };
|
|
5679
5855
|
function parseBunCheckOutput(stdout, cwd) {
|
|
@@ -5684,7 +5860,7 @@ function parseBunCheckOutput(stdout, cwd) {
|
|
|
5684
5860
|
const [, path, lineNumber, column, severity, code, message] = match;
|
|
5685
5861
|
const start = { line: Number(lineNumber) - 1, character: Number(column) - 1 };
|
|
5686
5862
|
results.push({
|
|
5687
|
-
file:
|
|
5863
|
+
file: resolve11(cwd, path ?? ""),
|
|
5688
5864
|
diagnostic: {
|
|
5689
5865
|
range: { start, end: start },
|
|
5690
5866
|
severity: TSC_SEVERITY[severity ?? "error"] ?? 1,
|
|
@@ -5743,9 +5919,9 @@ function parseBunLintJson(stdout) {
|
|
|
5743
5919
|
|
|
5744
5920
|
// ../lsp-core/src/lsp/bun-project-checks.ts
|
|
5745
5921
|
import { spawn as spawn3 } from "node:child_process";
|
|
5746
|
-
import { existsSync as
|
|
5922
|
+
import { existsSync as existsSync14, mkdtempSync, readFileSync as readFileSync6, rmSync as rmSync2, statSync as statSync6, writeFileSync as writeFileSync3 } from "node:fs";
|
|
5747
5923
|
import { homedir as homedir3, tmpdir as tmpdir2 } from "node:os";
|
|
5748
|
-
import { dirname as
|
|
5924
|
+
import { dirname as dirname13, join as join9, resolve as resolve12 } from "node:path";
|
|
5749
5925
|
var BUN_LOCKFILES = ["bun.lock", "bun.lockb", "bunfig.toml"];
|
|
5750
5926
|
var RUNNABLE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".cts", ".cjs", ".js", ".mjs", ".mts"];
|
|
5751
5927
|
var BIN_SUFFIXES = process.platform === "win32" ? [".exe", ".bunx", ".cmd", ""] : [""];
|
|
@@ -5754,18 +5930,18 @@ var UNFORMATTED_PROBE = `const a=1
|
|
|
5754
5930
|
`;
|
|
5755
5931
|
var probeCache = new Map;
|
|
5756
5932
|
function findBunProjectRoot(start, home = homedir3()) {
|
|
5757
|
-
const stopAt =
|
|
5758
|
-
let dir =
|
|
5933
|
+
const stopAt = resolve12(home);
|
|
5934
|
+
let dir = resolve12(start);
|
|
5759
5935
|
for (;; ) {
|
|
5760
5936
|
if (dir === stopAt)
|
|
5761
5937
|
return;
|
|
5762
|
-
if (BUN_LOCKFILES.some((name) =>
|
|
5938
|
+
if (BUN_LOCKFILES.some((name) => existsSync14(join9(dir, name))))
|
|
5763
5939
|
return dir;
|
|
5764
|
-
if (packageManagerIsBun(
|
|
5940
|
+
if (packageManagerIsBun(join9(dir, "package.json")))
|
|
5765
5941
|
return dir;
|
|
5766
|
-
if (
|
|
5942
|
+
if (existsSync14(join9(dir, ".git")))
|
|
5767
5943
|
return;
|
|
5768
|
-
const parent =
|
|
5944
|
+
const parent = dirname13(dir);
|
|
5769
5945
|
if (parent === dir)
|
|
5770
5946
|
return;
|
|
5771
5947
|
dir = parent;
|
|
@@ -5777,7 +5953,7 @@ function packageManagerIsBun(packageJsonPath) {
|
|
|
5777
5953
|
return typeof packageManager === "string" && packageManager.startsWith("bun@");
|
|
5778
5954
|
}
|
|
5779
5955
|
function readJsonObject(path) {
|
|
5780
|
-
if (!
|
|
5956
|
+
if (!existsSync14(path))
|
|
5781
5957
|
return;
|
|
5782
5958
|
try {
|
|
5783
5959
|
const parsed = JSON.parse(readFileSync6(path, "utf8"));
|
|
@@ -5788,14 +5964,14 @@ function readJsonObject(path) {
|
|
|
5788
5964
|
}
|
|
5789
5965
|
function isFile(path) {
|
|
5790
5966
|
try {
|
|
5791
|
-
return
|
|
5967
|
+
return statSync6(path).isFile();
|
|
5792
5968
|
} catch {
|
|
5793
5969
|
return false;
|
|
5794
5970
|
}
|
|
5795
5971
|
}
|
|
5796
5972
|
function isDirectory(path) {
|
|
5797
5973
|
try {
|
|
5798
|
-
return
|
|
5974
|
+
return statSync6(path).isDirectory();
|
|
5799
5975
|
} catch {
|
|
5800
5976
|
return false;
|
|
5801
5977
|
}
|
|
@@ -5803,35 +5979,35 @@ function isDirectory(path) {
|
|
|
5803
5979
|
function projectShadowsBunCommand(command, cwd) {
|
|
5804
5980
|
const packageJsonDir = nearestPackageJsonDir(cwd);
|
|
5805
5981
|
if (packageJsonDir !== undefined) {
|
|
5806
|
-
const scripts = readJsonObject(
|
|
5982
|
+
const scripts = readJsonObject(join9(packageJsonDir, "package.json"))?.["scripts"];
|
|
5807
5983
|
if (scripts !== null && typeof scripts === "object" && typeof scripts[command] === "string") {
|
|
5808
5984
|
return true;
|
|
5809
5985
|
}
|
|
5810
5986
|
}
|
|
5811
5987
|
if (command === "check")
|
|
5812
5988
|
return false;
|
|
5813
|
-
const base =
|
|
5989
|
+
const base = join9(cwd, command);
|
|
5814
5990
|
if (isFile(base) || RUNNABLE_EXTENSIONS.some((extension) => isFile(`${base}${extension}`)))
|
|
5815
5991
|
return true;
|
|
5816
|
-
if (isDirectory(base) && (isFile(
|
|
5992
|
+
if (isDirectory(base) && (isFile(join9(base, "package.json")) || RUNNABLE_EXTENSIONS.some((extension) => isFile(join9(base, `index${extension}`))))) {
|
|
5817
5993
|
return true;
|
|
5818
5994
|
}
|
|
5819
|
-
let dir =
|
|
5995
|
+
let dir = resolve12(cwd);
|
|
5820
5996
|
for (;; ) {
|
|
5821
|
-
if (BIN_SUFFIXES.some((suffix) =>
|
|
5997
|
+
if (BIN_SUFFIXES.some((suffix) => existsSync14(join9(dir, "node_modules", ".bin", `${command}${suffix}`))))
|
|
5822
5998
|
return true;
|
|
5823
|
-
const parent =
|
|
5999
|
+
const parent = dirname13(dir);
|
|
5824
6000
|
if (parent === dir)
|
|
5825
6001
|
return false;
|
|
5826
6002
|
dir = parent;
|
|
5827
6003
|
}
|
|
5828
6004
|
}
|
|
5829
6005
|
function nearestPackageJsonDir(start) {
|
|
5830
|
-
let dir =
|
|
6006
|
+
let dir = resolve12(start);
|
|
5831
6007
|
for (;; ) {
|
|
5832
|
-
if (
|
|
6008
|
+
if (existsSync14(join9(dir, "package.json")))
|
|
5833
6009
|
return dir;
|
|
5834
|
-
const parent =
|
|
6010
|
+
const parent = dirname13(dir);
|
|
5835
6011
|
if (parent === dir)
|
|
5836
6012
|
return;
|
|
5837
6013
|
dir = parent;
|
|
@@ -5839,7 +6015,7 @@ function nearestPackageJsonDir(start) {
|
|
|
5839
6015
|
}
|
|
5840
6016
|
function binaryIdentity(bunPath) {
|
|
5841
6017
|
try {
|
|
5842
|
-
const stats =
|
|
6018
|
+
const stats = statSync6(bunPath);
|
|
5843
6019
|
return `${stats.mtimeMs}:${stats.size}`;
|
|
5844
6020
|
} catch {
|
|
5845
6021
|
return "missing";
|
|
@@ -5859,7 +6035,7 @@ function bunHasCommand(bunPath, command, timeoutMs = PROBE_TIMEOUT_MS2) {
|
|
|
5859
6035
|
return probe;
|
|
5860
6036
|
}
|
|
5861
6037
|
async function probeOnce(bunPath, command, timeoutMs) {
|
|
5862
|
-
const emptyDir = mkdtempSync(
|
|
6038
|
+
const emptyDir = mkdtempSync(join9(tmpdir2(), "omo-bun-probe-"));
|
|
5863
6039
|
const timeout = AbortSignal.timeout(timeoutMs);
|
|
5864
6040
|
try {
|
|
5865
6041
|
const help = await runBunCommand(bunPath, [command, "--help"], emptyDir, timeout);
|
|
@@ -5869,7 +6045,7 @@ async function probeOnce(bunPath, command, timeoutMs) {
|
|
|
5869
6045
|
return false;
|
|
5870
6046
|
if (command !== "format")
|
|
5871
6047
|
return true;
|
|
5872
|
-
const probeFile =
|
|
6048
|
+
const probeFile = join9(emptyDir, "probe.ts");
|
|
5873
6049
|
writeFileSync3(probeFile, UNFORMATTED_PROBE);
|
|
5874
6050
|
const write = await runBunCommand(bunPath, ["format", "--write", "probe.ts"], emptyDir, timeout);
|
|
5875
6051
|
if (write.exitCode === null)
|
|
@@ -6814,9 +6990,9 @@ function currentRequestContext(env = process.env) {
|
|
|
6814
6990
|
const home = env["HOME"] ?? homedir4();
|
|
6815
6991
|
return parseLspRequestContext({
|
|
6816
6992
|
cwd,
|
|
6817
|
-
projectConfigPaths: [
|
|
6818
|
-
userConfigPath:
|
|
6819
|
-
installDecisionsPath:
|
|
6993
|
+
projectConfigPaths: [join10(cwd, ".codex", "lsp-client.json")],
|
|
6994
|
+
userConfigPath: join10(home, ".codex", "lsp-client.json"),
|
|
6995
|
+
installDecisionsPath: join10(home, ".codex", "lsp-install-decisions.json"),
|
|
6820
6996
|
capabilities: { installDecisionTool: true }
|
|
6821
6997
|
});
|
|
6822
6998
|
}
|
|
@@ -6985,7 +7161,7 @@ function resolveDaemonRuntime2(env, defaults) {
|
|
|
6985
7161
|
if (!isAbsolute6(cliOverride)) {
|
|
6986
7162
|
throw new InvalidRuntimeOverrideError2("cli_must_be_absolute", `${OMO_LSP_DAEMON_CLI2} must be an absolute path to an existing regular file`);
|
|
6987
7163
|
}
|
|
6988
|
-
const stat =
|
|
7164
|
+
const stat = statSync7(cliOverride, { throwIfNoEntry: false });
|
|
6989
7165
|
if (!stat) {
|
|
6990
7166
|
throw new InvalidRuntimeOverrideError2("cli_not_found", `${OMO_LSP_DAEMON_CLI2} points to a missing file`);
|
|
6991
7167
|
}
|