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.
- package/dist/cli/index.js +15 -15
- package/dist/cli-node/index.js +15 -15
- package/dist/index.js +13 -13
- package/dist/skills/browser/runtime/omowright/manifest.json +1 -1
- package/dist/tui.js +13 -13
- package/package.json +13 -13
- 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/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/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
- 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/skills/browser/runtime/omowright/manifest.json +1 -1
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +2 -2
- package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +1 -1
|
@@ -311,8 +311,8 @@ function createIdleTimer(idleTimeoutMs, log, onTimeout) {
|
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
313
|
// ../lsp-core/src/lsp/client-wrapper.ts
|
|
314
|
-
import { existsSync as
|
|
315
|
-
import { basename as basename3, dirname as
|
|
314
|
+
import { existsSync as existsSync11, realpathSync as realpathSync7, statSync as statSync4 } from "node:fs";
|
|
315
|
+
import { basename as basename3, dirname as dirname9, join as join6, resolve as resolve9 } from "node:path";
|
|
316
316
|
|
|
317
317
|
// ../lsp-core/src/request-context.ts
|
|
318
318
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -602,6 +602,24 @@ var realTimerProvider = {
|
|
|
602
602
|
setTimeout: (callback, delayMs) => setTimeout(callback, delayMs),
|
|
603
603
|
clearTimeout: (handle) => clearTimeout(handle)
|
|
604
604
|
};
|
|
605
|
+
function repeatEvery(timers, intervalMs, tick) {
|
|
606
|
+
let handle = null;
|
|
607
|
+
const arm = () => {
|
|
608
|
+
handle = timers.setTimeout(() => {
|
|
609
|
+
tick();
|
|
610
|
+
if (handle !== null)
|
|
611
|
+
arm();
|
|
612
|
+
}, intervalMs);
|
|
613
|
+
if (typeof handle.unref === "function")
|
|
614
|
+
handle.unref();
|
|
615
|
+
};
|
|
616
|
+
arm();
|
|
617
|
+
return () => {
|
|
618
|
+
if (handle !== null)
|
|
619
|
+
timers.clearTimeout(handle);
|
|
620
|
+
handle = null;
|
|
621
|
+
};
|
|
622
|
+
}
|
|
605
623
|
|
|
606
624
|
// ../lsp-core/src/lsp/constants.ts
|
|
607
625
|
var DEFAULT_MAX_REFERENCES = 200;
|
|
@@ -3264,30 +3282,54 @@ function abortError2(signal) {
|
|
|
3264
3282
|
return error;
|
|
3265
3283
|
}
|
|
3266
3284
|
|
|
3267
|
-
// ../lsp-core/src/lsp/
|
|
3268
|
-
function
|
|
3269
|
-
|
|
3270
|
-
const handler = () => {
|
|
3271
|
-
cleanup().catch((error) => {
|
|
3272
|
-
reportBestEffortCleanupError("signal cleanup", error);
|
|
3273
|
-
});
|
|
3274
|
-
};
|
|
3275
|
-
for (const signal of signals) {
|
|
3276
|
-
process.on(signal, handler);
|
|
3277
|
-
}
|
|
3278
|
-
return () => {
|
|
3279
|
-
for (const signal of signals) {
|
|
3280
|
-
process.removeListener(signal, handler);
|
|
3281
|
-
}
|
|
3282
|
-
};
|
|
3285
|
+
// ../lsp-core/src/lsp/client-key.ts
|
|
3286
|
+
function lspClientKey(root, server) {
|
|
3287
|
+
return JSON.stringify([root, server.id, server.command]);
|
|
3283
3288
|
}
|
|
3284
3289
|
|
|
3285
|
-
// ../lsp-core/src/lsp/
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3290
|
+
// ../lsp-core/src/lsp/client-startup.ts
|
|
3291
|
+
class ClientStartups {
|
|
3292
|
+
constructor(now, discard) {
|
|
3293
|
+
this.now = now;
|
|
3294
|
+
this.discard = discard;
|
|
3295
|
+
}
|
|
3296
|
+
begin(request) {
|
|
3297
|
+
const { client } = request;
|
|
3298
|
+
const startedAt = this.now();
|
|
3299
|
+
const initPromise = (async () => {
|
|
3300
|
+
await client.start();
|
|
3301
|
+
await client.initialize();
|
|
3302
|
+
})();
|
|
3303
|
+
const managed = {
|
|
3304
|
+
...request,
|
|
3305
|
+
refCount: 0,
|
|
3306
|
+
pendingWaiters: 0,
|
|
3307
|
+
lastUsedAt: startedAt,
|
|
3308
|
+
initPromise,
|
|
3309
|
+
isInitializing: true,
|
|
3310
|
+
initializingSince: startedAt
|
|
3311
|
+
};
|
|
3312
|
+
initPromise.then(() => {
|
|
3313
|
+
managed.isInitializing = false;
|
|
3314
|
+
managed.initializingSince = null;
|
|
3315
|
+
managed.initPromise = null;
|
|
3316
|
+
managed.lastUsedAt = this.now();
|
|
3317
|
+
}, () => this.discard(managed));
|
|
3318
|
+
return managed;
|
|
3319
|
+
}
|
|
3320
|
+
async wait(managed, initPromise, signal) {
|
|
3321
|
+
managed.pendingWaiters++;
|
|
3322
|
+
try {
|
|
3323
|
+
await awaitWithSignal(initPromise, signal);
|
|
3324
|
+
} catch (error) {
|
|
3325
|
+
this.detach(managed);
|
|
3326
|
+
throw error;
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
detach(managed) {
|
|
3330
|
+
managed.pendingWaiters--;
|
|
3331
|
+
if (managed.pendingWaiters === 0 && managed.refCount === 0 && managed.heldByWaiters)
|
|
3332
|
+
this.discard(managed);
|
|
3291
3333
|
}
|
|
3292
3334
|
}
|
|
3293
3335
|
function awaitWithSignal(promise, signal) {
|
|
@@ -3322,36 +3364,50 @@ function awaitWithSignal(promise, signal) {
|
|
|
3322
3364
|
});
|
|
3323
3365
|
}
|
|
3324
3366
|
|
|
3367
|
+
// ../lsp-core/src/lsp/process-signal-cleanup.ts
|
|
3368
|
+
function installProcessSignalCleanup(cleanup) {
|
|
3369
|
+
const signals = process.platform === "win32" ? ["SIGINT", "SIGTERM", "SIGBREAK"] : ["SIGINT", "SIGTERM"];
|
|
3370
|
+
const handler = () => {
|
|
3371
|
+
cleanup().catch((error) => {
|
|
3372
|
+
reportBestEffortCleanupError("signal cleanup", error);
|
|
3373
|
+
});
|
|
3374
|
+
};
|
|
3375
|
+
for (const signal of signals) {
|
|
3376
|
+
process.on(signal, handler);
|
|
3377
|
+
}
|
|
3378
|
+
return () => {
|
|
3379
|
+
for (const signal of signals) {
|
|
3380
|
+
process.removeListener(signal, handler);
|
|
3381
|
+
}
|
|
3382
|
+
};
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3385
|
+
// ../lsp-core/src/lsp/manager.ts
|
|
3386
|
+
async function stopClientBestEffort(client) {
|
|
3387
|
+
try {
|
|
3388
|
+
await client.stop();
|
|
3389
|
+
} catch (error) {
|
|
3390
|
+
reportBestEffortCleanupError("client stop", error);
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
|
|
3325
3394
|
class LspManager {
|
|
3326
3395
|
constructor(options = {}) {
|
|
3327
3396
|
this.clients = new Map;
|
|
3328
3397
|
this.pendingStops = new Map;
|
|
3329
3398
|
this.respawnBudgets = new Map;
|
|
3330
|
-
this.reaperHandle = null;
|
|
3331
3399
|
this.signalDisposer = null;
|
|
3332
3400
|
this.disposed = false;
|
|
3333
3401
|
this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS;
|
|
3334
3402
|
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
3335
3403
|
this.maxResidentClients = options.maxResidentClients ?? MAX_RESIDENT_CLIENTS;
|
|
3336
|
-
this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
|
|
3337
3404
|
this.clientFactory = options.clientFactory ?? ((root, server) => new LspClient(root, server));
|
|
3338
3405
|
this.now = options.now ?? (() => Date.now());
|
|
3339
|
-
this.
|
|
3406
|
+
this.startups = new ClientStartups(this.now, (managed) => this.discard(managed));
|
|
3407
|
+
const reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
|
|
3408
|
+
this.stopReaper = repeatEvery(options.timers ?? realTimerProvider, reaperIntervalMs, () => this.reapStale());
|
|
3340
3409
|
this.signalDisposer = installProcessSignalCleanup(() => this.stopAll());
|
|
3341
3410
|
}
|
|
3342
|
-
startReaper() {
|
|
3343
|
-
if (this.reaperHandle)
|
|
3344
|
-
return;
|
|
3345
|
-
this.reaperHandle = setInterval(() => {
|
|
3346
|
-
this.reapStale();
|
|
3347
|
-
}, this.reaperIntervalMs);
|
|
3348
|
-
if (typeof this.reaperHandle.unref === "function") {
|
|
3349
|
-
this.reaperHandle.unref();
|
|
3350
|
-
}
|
|
3351
|
-
}
|
|
3352
|
-
getKey(root, serverId) {
|
|
3353
|
-
return `${root}::${serverId}`;
|
|
3354
|
-
}
|
|
3355
3411
|
tombstoneStop(key, client) {
|
|
3356
3412
|
const stop = stopClientBestEffort(client);
|
|
3357
3413
|
this.pendingStops.set(key, stop);
|
|
@@ -3387,18 +3443,15 @@ class LspManager {
|
|
|
3387
3443
|
budget.deadGenerations = 0;
|
|
3388
3444
|
budget.exhaustedAt = null;
|
|
3389
3445
|
}
|
|
3446
|
+
startupExpired(managed, t) {
|
|
3447
|
+
return managed.isInitializing && managed.initializingSince !== null && t - managed.initializingSince > this.initTimeoutMs;
|
|
3448
|
+
}
|
|
3390
3449
|
reapStale() {
|
|
3391
3450
|
const t = this.now();
|
|
3392
|
-
for (const
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
this.
|
|
3396
|
-
continue;
|
|
3397
|
-
}
|
|
3398
|
-
if (!managed.isInitializing && managed.refCount === 0 && managed.pendingWaiters === 0 && t - managed.lastUsedAt > this.idleTimeoutMs) {
|
|
3399
|
-
this.clients.delete(key);
|
|
3400
|
-
this.tombstoneStop(key, managed.client);
|
|
3401
|
-
}
|
|
3451
|
+
for (const managed of [...this.clients.values()]) {
|
|
3452
|
+
const idle = !managed.isInitializing && managed.refCount === 0 && managed.pendingWaiters === 0 && t - managed.lastUsedAt > this.idleTimeoutMs;
|
|
3453
|
+
if (idle || this.startupExpired(managed, t))
|
|
3454
|
+
this.discard(managed);
|
|
3402
3455
|
}
|
|
3403
3456
|
}
|
|
3404
3457
|
evictForAdmission() {
|
|
@@ -3406,152 +3459,96 @@ class LspManager {
|
|
|
3406
3459
|
const victim = this.leastRecentlyUsedIdleClient();
|
|
3407
3460
|
if (!victim)
|
|
3408
3461
|
return;
|
|
3409
|
-
this.
|
|
3410
|
-
this.tombstoneStop(victim.key, victim.managed.client);
|
|
3462
|
+
this.discard(victim);
|
|
3411
3463
|
}
|
|
3412
3464
|
}
|
|
3413
3465
|
leastRecentlyUsedIdleClient() {
|
|
3414
3466
|
let candidate = null;
|
|
3415
|
-
for (const
|
|
3467
|
+
for (const managed of this.clients.values()) {
|
|
3416
3468
|
if (managed.refCount > 0 || managed.pendingWaiters > 0 || managed.isInitializing)
|
|
3417
3469
|
continue;
|
|
3418
|
-
if (candidate === null || managed.lastUsedAt < candidate.
|
|
3419
|
-
candidate =
|
|
3420
|
-
}
|
|
3470
|
+
if (candidate === null || managed.lastUsedAt < candidate.lastUsedAt)
|
|
3471
|
+
candidate = managed;
|
|
3421
3472
|
}
|
|
3422
3473
|
return candidate;
|
|
3423
3474
|
}
|
|
3424
|
-
|
|
3425
|
-
if (
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3475
|
+
discard(managed) {
|
|
3476
|
+
if (this.clients.get(managed.key) !== managed)
|
|
3477
|
+
return;
|
|
3478
|
+
this.clients.delete(managed.key);
|
|
3479
|
+
this.tombstoneStop(managed.key, managed.client);
|
|
3429
3480
|
}
|
|
3430
3481
|
async getClient(root, server, signal) {
|
|
3431
|
-
|
|
3432
|
-
throw new Error("LspManager has been disposed");
|
|
3433
|
-
}
|
|
3434
|
-
signal?.throwIfAborted();
|
|
3435
|
-
const key = this.getKey(root, server.id);
|
|
3482
|
+
const key = lspClientKey(root, server);
|
|
3436
3483
|
for (;; ) {
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
await awaitWithSignal(pendingStop, signal);
|
|
3484
|
+
if (this.disposed) {
|
|
3485
|
+
throw new Error("LspManager has been disposed");
|
|
3486
|
+
}
|
|
3441
3487
|
signal?.throwIfAborted();
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
let managed = this.clients.get(key);
|
|
3447
|
-
if (managed) {
|
|
3448
|
-
const t = this.now();
|
|
3449
|
-
if (managed.isInitializing && managed.initializingSince !== null && t - managed.initializingSince > this.initTimeoutMs) {
|
|
3450
|
-
this.clients.delete(key);
|
|
3451
|
-
await this.tombstoneStop(key, managed.client);
|
|
3452
|
-
managed = undefined;
|
|
3488
|
+
const pendingStop = this.pendingStops.get(key);
|
|
3489
|
+
if (pendingStop !== undefined) {
|
|
3490
|
+
await awaitWithSignal(pendingStop, signal);
|
|
3491
|
+
continue;
|
|
3453
3492
|
}
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3493
|
+
let managed = this.clients.get(key);
|
|
3494
|
+
if (managed !== undefined && this.startupExpired(managed, this.now())) {
|
|
3495
|
+
this.discard(managed);
|
|
3496
|
+
continue;
|
|
3497
|
+
}
|
|
3498
|
+
if (managed === undefined) {
|
|
3499
|
+
this.evictForAdmission();
|
|
3500
|
+
this.ensureRespawnAllowed(key, root, server.id);
|
|
3501
|
+
managed = this.startClient(key, root, server, true);
|
|
3502
|
+
}
|
|
3503
|
+
const { initPromise } = managed;
|
|
3504
|
+
if (initPromise !== null) {
|
|
3505
|
+
await this.startups.wait(managed, initPromise, signal);
|
|
3506
|
+
if (signal?.aborted) {
|
|
3507
|
+
this.startups.detach(managed);
|
|
3508
|
+
signal.throwIfAborted();
|
|
3464
3509
|
}
|
|
3465
3510
|
managed.pendingWaiters--;
|
|
3466
3511
|
}
|
|
3467
|
-
if (
|
|
3468
|
-
|
|
3469
|
-
signal.throwIfAborted();
|
|
3470
|
-
}
|
|
3512
|
+
if (this.clients.get(key) !== managed)
|
|
3513
|
+
continue;
|
|
3471
3514
|
if (!managed.client.isAlive()) {
|
|
3472
3515
|
this.recordDeadGeneration(key);
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
}
|
|
3476
|
-
await this.tombstoneStop(key, managed.client);
|
|
3477
|
-
return this.getClient(root, server, signal);
|
|
3516
|
+
this.discard(managed);
|
|
3517
|
+
continue;
|
|
3478
3518
|
}
|
|
3479
3519
|
this.markHealthyGeneration(key);
|
|
3480
3520
|
managed.refCount++;
|
|
3481
3521
|
managed.lastUsedAt = this.now();
|
|
3482
3522
|
return managed.client;
|
|
3483
3523
|
}
|
|
3484
|
-
|
|
3485
|
-
|
|
3524
|
+
}
|
|
3525
|
+
startClient(key, root, server, heldByWaiters) {
|
|
3486
3526
|
const client = this.clientFactory(root, server);
|
|
3487
|
-
const
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
const
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
pendingWaiters: 1,
|
|
3496
|
-
lastUsedAt: initStartedAt,
|
|
3497
|
-
initPromise,
|
|
3498
|
-
isInitializing: true,
|
|
3499
|
-
initializingSince: initStartedAt
|
|
3500
|
-
};
|
|
3501
|
-
this.clients.set(key, newManaged);
|
|
3502
|
-
try {
|
|
3503
|
-
await awaitWithSignal(initPromise, signal);
|
|
3504
|
-
} catch (err) {
|
|
3505
|
-
newManaged.pendingWaiters--;
|
|
3506
|
-
if (this.clients.get(key) === newManaged) {
|
|
3507
|
-
this.clients.delete(key);
|
|
3508
|
-
}
|
|
3509
|
-
await this.tombstoneStop(key, client);
|
|
3510
|
-
throw err;
|
|
3511
|
-
}
|
|
3512
|
-
newManaged.pendingWaiters--;
|
|
3513
|
-
newManaged.isInitializing = false;
|
|
3514
|
-
newManaged.initializingSince = null;
|
|
3515
|
-
newManaged.initPromise = null;
|
|
3516
|
-
if (signal?.aborted) {
|
|
3517
|
-
await this.tryDeleteIfOrphaned(key, newManaged);
|
|
3518
|
-
signal.throwIfAborted();
|
|
3519
|
-
}
|
|
3520
|
-
if (!client.isAlive()) {
|
|
3521
|
-
this.recordDeadGeneration(key);
|
|
3522
|
-
if (this.clients.get(key) === newManaged) {
|
|
3523
|
-
this.clients.delete(key);
|
|
3524
|
-
}
|
|
3525
|
-
await this.tombstoneStop(key, client);
|
|
3526
|
-
return this.getClient(root, server, signal);
|
|
3527
|
-
}
|
|
3528
|
-
this.markHealthyGeneration(key);
|
|
3529
|
-
newManaged.refCount++;
|
|
3530
|
-
newManaged.lastUsedAt = this.now();
|
|
3531
|
-
return client;
|
|
3532
|
-
}
|
|
3533
|
-
releaseClient(root, serverId) {
|
|
3534
|
-
const key = this.getKey(root, serverId);
|
|
3535
|
-
const managed = this.clients.get(key);
|
|
3527
|
+
const managed = this.startups.begin({ key, root, serverId: server.id, client, heldByWaiters });
|
|
3528
|
+
this.clients.set(key, managed);
|
|
3529
|
+
return managed;
|
|
3530
|
+
}
|
|
3531
|
+
releaseClient(root, server, client) {
|
|
3532
|
+
const managed = this.clients.get(lspClientKey(root, server));
|
|
3533
|
+
if (client !== undefined && managed?.client !== client)
|
|
3534
|
+
return;
|
|
3536
3535
|
if (managed && managed.refCount > 0) {
|
|
3537
3536
|
managed.refCount--;
|
|
3538
3537
|
managed.lastUsedAt = this.now();
|
|
3539
3538
|
}
|
|
3540
3539
|
}
|
|
3541
|
-
invalidateClient(root,
|
|
3542
|
-
const
|
|
3543
|
-
const managed = this.clients.get(key);
|
|
3540
|
+
invalidateClient(root, server, client) {
|
|
3541
|
+
const managed = this.clients.get(lspClientKey(root, server));
|
|
3544
3542
|
if (!managed)
|
|
3545
3543
|
return;
|
|
3546
3544
|
if (client && managed.client !== client)
|
|
3547
3545
|
return;
|
|
3548
|
-
this.
|
|
3549
|
-
this.tombstoneStop(key, managed.client);
|
|
3546
|
+
this.discard(managed);
|
|
3550
3547
|
}
|
|
3551
3548
|
warmupClient(root, server) {
|
|
3552
3549
|
if (this.disposed)
|
|
3553
3550
|
return;
|
|
3554
|
-
const key =
|
|
3551
|
+
const key = lspClientKey(root, server);
|
|
3555
3552
|
if (this.clients.has(key) || this.pendingStops.has(key))
|
|
3556
3553
|
return;
|
|
3557
3554
|
this.evictForAdmission();
|
|
@@ -3560,45 +3557,18 @@ class LspManager {
|
|
|
3560
3557
|
} catch {
|
|
3561
3558
|
return;
|
|
3562
3559
|
}
|
|
3563
|
-
|
|
3564
|
-
const initStartedAt = this.now();
|
|
3565
|
-
const initPromise = (async () => {
|
|
3566
|
-
await client.start();
|
|
3567
|
-
await client.initialize();
|
|
3568
|
-
})();
|
|
3569
|
-
const managed = {
|
|
3570
|
-
client,
|
|
3571
|
-
refCount: 0,
|
|
3572
|
-
pendingWaiters: 0,
|
|
3573
|
-
lastUsedAt: initStartedAt,
|
|
3574
|
-
initPromise,
|
|
3575
|
-
isInitializing: true,
|
|
3576
|
-
initializingSince: initStartedAt
|
|
3577
|
-
};
|
|
3578
|
-
this.clients.set(key, managed);
|
|
3579
|
-
initPromise.then(() => {
|
|
3580
|
-
managed.isInitializing = false;
|
|
3581
|
-
managed.initializingSince = null;
|
|
3582
|
-
managed.initPromise = null;
|
|
3583
|
-
managed.lastUsedAt = this.now();
|
|
3584
|
-
}, () => {
|
|
3585
|
-
if (this.clients.get(key) === managed) {
|
|
3586
|
-
this.clients.delete(key);
|
|
3587
|
-
}
|
|
3588
|
-
this.tombstoneStop(key, client);
|
|
3589
|
-
});
|
|
3560
|
+
this.startClient(key, root, server, false);
|
|
3590
3561
|
}
|
|
3591
|
-
isServerInitializing(root,
|
|
3592
|
-
const managed = this.clients.get(
|
|
3562
|
+
isServerInitializing(root, server) {
|
|
3563
|
+
const managed = this.clients.get(lspClientKey(root, server));
|
|
3593
3564
|
return managed?.isInitializing ?? false;
|
|
3594
3565
|
}
|
|
3595
3566
|
getSnapshot() {
|
|
3596
3567
|
const snapshots = [];
|
|
3597
|
-
for (const
|
|
3598
|
-
const [root, serverId] = key.split("::");
|
|
3568
|
+
for (const managed of this.clients.values()) {
|
|
3599
3569
|
snapshots.push({
|
|
3600
|
-
root,
|
|
3601
|
-
serverId,
|
|
3570
|
+
root: managed.root,
|
|
3571
|
+
serverId: managed.serverId,
|
|
3602
3572
|
refCount: managed.refCount,
|
|
3603
3573
|
pendingWaiters: managed.pendingWaiters,
|
|
3604
3574
|
lastUsedAt: managed.lastUsedAt,
|
|
@@ -3609,18 +3579,15 @@ class LspManager {
|
|
|
3609
3579
|
}
|
|
3610
3580
|
return snapshots;
|
|
3611
3581
|
}
|
|
3612
|
-
hasClient(root,
|
|
3613
|
-
return this.clients.has(
|
|
3582
|
+
hasClient(root, server) {
|
|
3583
|
+
return this.clients.has(lspClientKey(root, server));
|
|
3614
3584
|
}
|
|
3615
3585
|
clientCount() {
|
|
3616
3586
|
return this.clients.size;
|
|
3617
3587
|
}
|
|
3618
3588
|
async stopAll() {
|
|
3619
3589
|
this.disposed = true;
|
|
3620
|
-
|
|
3621
|
-
clearInterval(this.reaperHandle);
|
|
3622
|
-
this.reaperHandle = null;
|
|
3623
|
-
}
|
|
3590
|
+
this.stopReaper();
|
|
3624
3591
|
if (this.signalDisposer) {
|
|
3625
3592
|
this.signalDisposer();
|
|
3626
3593
|
this.signalDisposer = null;
|
|
@@ -3989,6 +3956,7 @@ function getMergedServers() {
|
|
|
3989
3956
|
extensions: config.extensions,
|
|
3990
3957
|
priority: -100,
|
|
3991
3958
|
source: "builtin",
|
|
3959
|
+
inheritsBuiltinCommand: true,
|
|
3992
3960
|
...config.initialization === undefined ? {} : { initialization: config.initialization }
|
|
3993
3961
|
});
|
|
3994
3962
|
}
|
|
@@ -4014,8 +3982,11 @@ function createServerFromEntry(id, entry, source) {
|
|
|
4014
3982
|
command: builtin.command,
|
|
4015
3983
|
extensions: entry.extensions ?? builtin.extensions,
|
|
4016
3984
|
priority: entry.priority ?? 0,
|
|
4017
|
-
source
|
|
3985
|
+
source,
|
|
3986
|
+
inheritsBuiltinCommand: true
|
|
4018
3987
|
});
|
|
3988
|
+
if (entry.initialization !== undefined)
|
|
3989
|
+
server.configuredInitialization = entry.initialization;
|
|
4019
3990
|
const initialization = mergeInitialization(builtin.initialization, entry.initialization);
|
|
4020
3991
|
if (initialization !== undefined) {
|
|
4021
3992
|
server.initialization = initialization;
|
|
@@ -4028,7 +3999,8 @@ function createServerFromEntry(id, entry, source) {
|
|
|
4028
3999
|
command: entry.command,
|
|
4029
4000
|
extensions: entry.extensions,
|
|
4030
4001
|
priority: entry.priority ?? 0,
|
|
4031
|
-
source
|
|
4002
|
+
source,
|
|
4003
|
+
inheritsBuiltinCommand: false
|
|
4032
4004
|
});
|
|
4033
4005
|
applyOptionalServerFields(server, entry);
|
|
4034
4006
|
return server;
|
|
@@ -4040,7 +4012,8 @@ function createServerFromEntry(id, entry, source) {
|
|
|
4040
4012
|
command: entry.command ?? builtin.command,
|
|
4041
4013
|
extensions: entry.extensions ?? builtin.extensions,
|
|
4042
4014
|
priority: entry.priority ?? 0,
|
|
4043
|
-
source
|
|
4015
|
+
source,
|
|
4016
|
+
inheritsBuiltinCommand: entry.command === undefined
|
|
4044
4017
|
});
|
|
4045
4018
|
applyOptionalServerFields(server, entry);
|
|
4046
4019
|
const builtinInitialization = entry.command === undefined ? builtin.initialization : undefined;
|
|
@@ -4063,7 +4036,8 @@ function createServer(input) {
|
|
|
4063
4036
|
command: input.command,
|
|
4064
4037
|
extensions: input.extensions,
|
|
4065
4038
|
priority: input.priority,
|
|
4066
|
-
source: input.source
|
|
4039
|
+
source: input.source,
|
|
4040
|
+
inheritsBuiltinCommand: input.inheritsBuiltinCommand
|
|
4067
4041
|
};
|
|
4068
4042
|
if (input.env !== undefined) {
|
|
4069
4043
|
server.env = input.env;
|
|
@@ -4079,6 +4053,7 @@ function applyOptionalServerFields(server, entry) {
|
|
|
4079
4053
|
}
|
|
4080
4054
|
if (entry.initialization !== undefined) {
|
|
4081
4055
|
server.initialization = entry.initialization;
|
|
4056
|
+
server.configuredInitialization = entry.initialization;
|
|
4082
4057
|
}
|
|
4083
4058
|
}
|
|
4084
4059
|
function isConfigJson(value) {
|
|
@@ -4170,14 +4145,24 @@ function readHead(path) {
|
|
|
4170
4145
|
}
|
|
4171
4146
|
}
|
|
4172
4147
|
|
|
4148
|
+
// ../lsp-core/src/lsp/native-typescript.ts
|
|
4149
|
+
import { existsSync as existsSync10, realpathSync as realpathSync6, statSync as statSync3 } from "node:fs";
|
|
4150
|
+
import { dirname as dirname8, join as join5, resolve as resolve8 } from "node:path";
|
|
4151
|
+
|
|
4173
4152
|
// ../lsp-core/src/lsp/server-installation.ts
|
|
4174
4153
|
import { existsSync as existsSync9 } from "node:fs";
|
|
4175
4154
|
import { delimiter as delimiter3, dirname as dirname7, isAbsolute as isAbsolute3, join as join4, resolve as resolve7 } from "node:path";
|
|
4155
|
+
var NODE_PROJECT_MARKERS = [
|
|
4156
|
+
"package.json",
|
|
4157
|
+
"bun.lock",
|
|
4158
|
+
"bun.lockb",
|
|
4159
|
+
"package-lock.json",
|
|
4160
|
+
"yarn.lock",
|
|
4161
|
+
"pnpm-lock.yaml"
|
|
4162
|
+
];
|
|
4163
|
+
var NODE_LOCAL_BIN_DIR = join4("node_modules", ".bin");
|
|
4176
4164
|
var LOCAL_BIN_RULES = [
|
|
4177
|
-
{
|
|
4178
|
-
markers: ["package.json", "bun.lock", "bun.lockb", "package-lock.json", "yarn.lock", "pnpm-lock.yaml"],
|
|
4179
|
-
binDirs: [join4("node_modules", ".bin")]
|
|
4180
|
-
},
|
|
4165
|
+
{ markers: NODE_PROJECT_MARKERS, binDirs: [NODE_LOCAL_BIN_DIR] },
|
|
4181
4166
|
{
|
|
4182
4167
|
markers: [
|
|
4183
4168
|
"pyproject.toml",
|
|
@@ -4305,6 +4290,57 @@ function isServerInstalled(command, workingDirectory, options = {}) {
|
|
|
4305
4290
|
return resolveServerBinary(command, workingDirectory, options) !== null;
|
|
4306
4291
|
}
|
|
4307
4292
|
|
|
4293
|
+
// ../lsp-core/src/lsp/native-typescript.ts
|
|
4294
|
+
function nativeTypescriptSearchDirectory(targetPath, workingDirectory) {
|
|
4295
|
+
try {
|
|
4296
|
+
const session = realpathSync6(workingDirectory);
|
|
4297
|
+
if (targetPath === undefined)
|
|
4298
|
+
return session;
|
|
4299
|
+
const target = canonicalizeExistingOrNearestAncestor(resolve8(workingDirectory, targetPath));
|
|
4300
|
+
if (!isPathInside(session, target))
|
|
4301
|
+
return session;
|
|
4302
|
+
return statSync3(target, { throwIfNoEntry: false })?.isDirectory() === true ? target : dirname8(target);
|
|
4303
|
+
} catch {
|
|
4304
|
+
return workingDirectory;
|
|
4305
|
+
}
|
|
4306
|
+
}
|
|
4307
|
+
function nativeTypescriptCommand(server, searchDirectory) {
|
|
4308
|
+
if (server.id !== "typescript" || !server.inheritsBuiltinCommand)
|
|
4309
|
+
return null;
|
|
4310
|
+
const found = findProjectTsc(searchDirectory);
|
|
4311
|
+
if (found === null)
|
|
4312
|
+
return null;
|
|
4313
|
+
const speaksLsp = !existsSync10(join5(found.packageDir, "lib", "tsserver.js"));
|
|
4314
|
+
return speaksLsp ? [found.tsc, "--lsp", "--stdio"] : null;
|
|
4315
|
+
}
|
|
4316
|
+
function findProjectTsc(searchDirectory) {
|
|
4317
|
+
const suffixes = executableSuffixes(process.platform, undefined);
|
|
4318
|
+
let current = searchDirectory;
|
|
4319
|
+
for (;; ) {
|
|
4320
|
+
if (NODE_PROJECT_MARKERS.some((marker) => probe(join5(current, marker)))) {
|
|
4321
|
+
const binDir = join5(current, NODE_LOCAL_BIN_DIR);
|
|
4322
|
+
const tsc = probeWithSuffixes(binDir, "tsc", suffixes);
|
|
4323
|
+
const packageDir = join5(binDir, "..", "typescript");
|
|
4324
|
+
if (tsc !== null && isRealDirectory(binDir) && existsSync10(join5(packageDir, "package.json"))) {
|
|
4325
|
+
return { tsc, packageDir };
|
|
4326
|
+
}
|
|
4327
|
+
}
|
|
4328
|
+
if (probe(join5(current, ".git")))
|
|
4329
|
+
return null;
|
|
4330
|
+
const parent = dirname8(current);
|
|
4331
|
+
if (parent === current)
|
|
4332
|
+
return null;
|
|
4333
|
+
current = parent;
|
|
4334
|
+
}
|
|
4335
|
+
}
|
|
4336
|
+
function isRealDirectory(directory) {
|
|
4337
|
+
try {
|
|
4338
|
+
return realpathSync6(directory) === directory;
|
|
4339
|
+
} catch {
|
|
4340
|
+
return false;
|
|
4341
|
+
}
|
|
4342
|
+
}
|
|
4343
|
+
|
|
4308
4344
|
// ../lsp-core/src/lsp/server-resolution.ts
|
|
4309
4345
|
function withResolvedCommand(command, binaryPath) {
|
|
4310
4346
|
return [binaryPath, ...command.slice(1)];
|
|
@@ -4313,12 +4349,27 @@ function usesBuiltinCommand(id, command) {
|
|
|
4313
4349
|
const builtin = BUILTIN_SERVERS[id]?.command;
|
|
4314
4350
|
return builtin !== undefined && builtin.length === command.length && builtin.every((part, index) => part === command[index]);
|
|
4315
4351
|
}
|
|
4316
|
-
function findServerForExtension(ext) {
|
|
4352
|
+
function findServerForExtension(ext, targetPath) {
|
|
4317
4353
|
const servers = getMergedServers();
|
|
4318
4354
|
const workingDirectory = contextCwd();
|
|
4355
|
+
const searchDirectory = nativeTypescriptSearchDirectory(targetPath, workingDirectory);
|
|
4319
4356
|
for (const server of servers) {
|
|
4320
4357
|
if (!server.extensions.includes(ext))
|
|
4321
4358
|
continue;
|
|
4359
|
+
const nativeTypescript = nativeTypescriptCommand(server, searchDirectory);
|
|
4360
|
+
if (nativeTypescript !== null) {
|
|
4361
|
+
return {
|
|
4362
|
+
status: "found",
|
|
4363
|
+
server: {
|
|
4364
|
+
id: server.id,
|
|
4365
|
+
command: withHostJsRuntime(server.id, nativeTypescript),
|
|
4366
|
+
extensions: server.extensions,
|
|
4367
|
+
priority: server.priority,
|
|
4368
|
+
...server.env === undefined ? {} : { env: server.env },
|
|
4369
|
+
...server.configuredInitialization === undefined ? {} : { initialization: server.configuredInitialization }
|
|
4370
|
+
}
|
|
4371
|
+
};
|
|
4372
|
+
}
|
|
4322
4373
|
const binaryPath = resolveServerBinary(server.command, workingDirectory);
|
|
4323
4374
|
if (binaryPath !== null) {
|
|
4324
4375
|
const resolvedServer = {
|
|
@@ -4371,6 +4422,7 @@ function getAllServers() {
|
|
|
4371
4422
|
const servers = getMergedServers();
|
|
4372
4423
|
const disabled = getDisabledServerIds();
|
|
4373
4424
|
const workingDirectory = contextCwd();
|
|
4425
|
+
const nativeSearchDirectory = nativeTypescriptSearchDirectory(undefined, workingDirectory);
|
|
4374
4426
|
const result = [];
|
|
4375
4427
|
const seen = new Set;
|
|
4376
4428
|
for (const server of servers) {
|
|
@@ -4378,7 +4430,7 @@ function getAllServers() {
|
|
|
4378
4430
|
continue;
|
|
4379
4431
|
result.push({
|
|
4380
4432
|
id: server.id,
|
|
4381
|
-
installed: isServerInstalled(server.command, workingDirectory),
|
|
4433
|
+
installed: isServerInstalled(server.command, workingDirectory) || nativeTypescriptCommand(server, nativeSearchDirectory) !== null,
|
|
4382
4434
|
extensions: server.extensions,
|
|
4383
4435
|
disabled: false,
|
|
4384
4436
|
source: server.source,
|
|
@@ -4405,7 +4457,7 @@ function getAllServers() {
|
|
|
4405
4457
|
// ../lsp-core/src/lsp/client-wrapper.ts
|
|
4406
4458
|
function isDirectoryPath(filePath) {
|
|
4407
4459
|
try {
|
|
4408
|
-
return
|
|
4460
|
+
return statSync4(filePath).isDirectory();
|
|
4409
4461
|
} catch {
|
|
4410
4462
|
return false;
|
|
4411
4463
|
}
|
|
@@ -4415,7 +4467,7 @@ function findWorkspaceRoot(filePath) {
|
|
|
4415
4467
|
const abs = resolveReadablePathInsideContext(filePath);
|
|
4416
4468
|
let dir = abs;
|
|
4417
4469
|
if (!isDirectoryPath(dir)) {
|
|
4418
|
-
dir =
|
|
4470
|
+
dir = dirname9(dir);
|
|
4419
4471
|
}
|
|
4420
4472
|
if (!isPathInside(cwd, abs))
|
|
4421
4473
|
return findWorkspaceRootOutsideContext(dir);
|
|
@@ -4424,7 +4476,7 @@ function findWorkspaceRoot(filePath) {
|
|
|
4424
4476
|
while (isPathInside(cwd, dir)) {
|
|
4425
4477
|
const canonicalDir = existingDirectoryInsideContext(dir, cwd);
|
|
4426
4478
|
if (canonicalDir !== undefined) {
|
|
4427
|
-
if (
|
|
4479
|
+
if (existsSync11(join6(dir, GIT_WORKSPACE_MARKER))) {
|
|
4428
4480
|
return canonicalDir;
|
|
4429
4481
|
}
|
|
4430
4482
|
if (nearestPackageRoot === undefined && hasProjectWorkspaceMarker(dir)) {
|
|
@@ -4433,16 +4485,16 @@ function findWorkspaceRoot(filePath) {
|
|
|
4433
4485
|
}
|
|
4434
4486
|
if (dir === cwd)
|
|
4435
4487
|
break;
|
|
4436
|
-
dir =
|
|
4488
|
+
dir = dirname9(dir);
|
|
4437
4489
|
}
|
|
4438
4490
|
return nearestPackageRoot ?? fallbackRoot;
|
|
4439
4491
|
}
|
|
4440
4492
|
function hasProjectWorkspaceMarker(directory) {
|
|
4441
|
-
return PROJECT_WORKSPACE_MARKERS.some((marker) =>
|
|
4493
|
+
return PROJECT_WORKSPACE_MARKERS.some((marker) => existsSync11(join6(directory, marker)));
|
|
4442
4494
|
}
|
|
4443
4495
|
function resolveReadablePathInsideContext(filePath) {
|
|
4444
4496
|
const cwd = contextCwd();
|
|
4445
|
-
const abs =
|
|
4497
|
+
const abs = resolve9(cwd, filePath);
|
|
4446
4498
|
if (isPathInside(cwd, abs))
|
|
4447
4499
|
return abs;
|
|
4448
4500
|
const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
|
|
@@ -4463,12 +4515,12 @@ function rebaseThroughCanonicalAncestor(path, cwd) {
|
|
|
4463
4515
|
let current = path;
|
|
4464
4516
|
const suffix = [];
|
|
4465
4517
|
while (true) {
|
|
4466
|
-
if (
|
|
4467
|
-
const canonical =
|
|
4518
|
+
if (existsSync11(current)) {
|
|
4519
|
+
const canonical = realpathSync7(current);
|
|
4468
4520
|
if (isPathInside(cwd, canonical))
|
|
4469
|
-
return suffix.length === 0 ? canonical :
|
|
4521
|
+
return suffix.length === 0 ? canonical : join6(canonical, ...suffix);
|
|
4470
4522
|
}
|
|
4471
|
-
const parent =
|
|
4523
|
+
const parent = dirname9(current);
|
|
4472
4524
|
if (parent === current)
|
|
4473
4525
|
return;
|
|
4474
4526
|
suffix.unshift(basename3(current));
|
|
@@ -4476,10 +4528,10 @@ function rebaseThroughCanonicalAncestor(path, cwd) {
|
|
|
4476
4528
|
}
|
|
4477
4529
|
}
|
|
4478
4530
|
function existingDirectoryInsideContext(directory, cwd) {
|
|
4479
|
-
if (!
|
|
4531
|
+
if (!existsSync11(directory))
|
|
4480
4532
|
return;
|
|
4481
|
-
const canonical =
|
|
4482
|
-
if (!
|
|
4533
|
+
const canonical = realpathSync7(directory);
|
|
4534
|
+
if (!statSync4(canonical).isDirectory())
|
|
4483
4535
|
return;
|
|
4484
4536
|
return isPathInside(cwd, canonical) ? canonical : undefined;
|
|
4485
4537
|
}
|
|
@@ -4491,7 +4543,7 @@ function nearestExistingDirectoryInsideContext(directory, cwd) {
|
|
|
4491
4543
|
return canonical;
|
|
4492
4544
|
if (current === cwd)
|
|
4493
4545
|
return;
|
|
4494
|
-
current =
|
|
4546
|
+
current = dirname9(current);
|
|
4495
4547
|
}
|
|
4496
4548
|
return;
|
|
4497
4549
|
}
|
|
@@ -4591,7 +4643,7 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
|
4591
4643
|
throw new LspInvalidPathError("Directory paths are not supported by this LSP tool. " + "Use lsp.diagnostics with a directory path for directory diagnostics.");
|
|
4592
4644
|
}
|
|
4593
4645
|
const ext = effectiveExtension(absPath);
|
|
4594
|
-
const result = findServerForExtension(ext);
|
|
4646
|
+
const result = findServerForExtension(ext, absPath);
|
|
4595
4647
|
if (result.status !== "found") {
|
|
4596
4648
|
throw new LspServerLookupError(formatServerLookupError(result), result);
|
|
4597
4649
|
}
|
|
@@ -4604,25 +4656,153 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
|
4604
4656
|
return await fn(client, root, absPath);
|
|
4605
4657
|
} catch (err) {
|
|
4606
4658
|
if (allowRetry && READ_ONLY_TOOLS.has(toolName) && isLspDeadConnectionError(err)) {
|
|
4607
|
-
manager.invalidateClient(root, server
|
|
4659
|
+
manager.invalidateClient(root, server, client);
|
|
4608
4660
|
return acquireAndCall(false);
|
|
4609
4661
|
}
|
|
4610
4662
|
if (err instanceof LspRequestTimeoutError) {
|
|
4611
|
-
if (manager.isServerInitializing(root, server
|
|
4663
|
+
if (manager.isServerInitializing(root, server)) {
|
|
4612
4664
|
throw new LspServerInitializingError(err);
|
|
4613
4665
|
}
|
|
4614
4666
|
}
|
|
4615
4667
|
throw err;
|
|
4616
4668
|
} finally {
|
|
4617
|
-
manager.releaseClient(root, server
|
|
4669
|
+
manager.releaseClient(root, server, client);
|
|
4618
4670
|
}
|
|
4619
4671
|
};
|
|
4620
4672
|
return acquireAndCall(true);
|
|
4621
4673
|
}
|
|
4622
4674
|
|
|
4623
4675
|
// ../lsp-core/src/lsp/directory-diagnostics.ts
|
|
4624
|
-
import { existsSync as
|
|
4625
|
-
import { join as
|
|
4676
|
+
import { existsSync as existsSync12, lstatSync as lstatSync4, readdirSync as readdirSync3 } from "node:fs";
|
|
4677
|
+
import { join as join7, resolve as resolve10 } from "node:path";
|
|
4678
|
+
|
|
4679
|
+
// ../lsp-core/src/lsp/directory-group-scan.ts
|
|
4680
|
+
async function scanServedGroups(options) {
|
|
4681
|
+
const { groups, signal } = options;
|
|
4682
|
+
const limit = Math.max(1, options.maxConcurrency);
|
|
4683
|
+
const fileSlots = createSlots(limit);
|
|
4684
|
+
let nextGroup = 0;
|
|
4685
|
+
let startedGroups = 0;
|
|
4686
|
+
let firstError;
|
|
4687
|
+
const runners = Array.from({ length: Math.min(limit, groups.length) }, async () => {
|
|
4688
|
+
for (;; ) {
|
|
4689
|
+
if (signal?.aborted)
|
|
4690
|
+
return;
|
|
4691
|
+
const group = groups[nextGroup];
|
|
4692
|
+
nextGroup += 1;
|
|
4693
|
+
if (group === undefined)
|
|
4694
|
+
return;
|
|
4695
|
+
let client;
|
|
4696
|
+
try {
|
|
4697
|
+
client = await acquireWithinInitTimeout(options, group);
|
|
4698
|
+
} catch (error) {
|
|
4699
|
+
if (signal?.aborted)
|
|
4700
|
+
return;
|
|
4701
|
+
firstError ??= error;
|
|
4702
|
+
options.onGroupUnavailable(group, error instanceof Error ? error.message : String(error));
|
|
4703
|
+
continue;
|
|
4704
|
+
}
|
|
4705
|
+
startedGroups += 1;
|
|
4706
|
+
try {
|
|
4707
|
+
await Promise.all(group.files.map(async (file) => {
|
|
4708
|
+
const release = await fileSlots.acquire();
|
|
4709
|
+
try {
|
|
4710
|
+
if (!signal?.aborted)
|
|
4711
|
+
await options.checkFile(client, file);
|
|
4712
|
+
} finally {
|
|
4713
|
+
release();
|
|
4714
|
+
}
|
|
4715
|
+
}));
|
|
4716
|
+
} finally {
|
|
4717
|
+
options.manager.releaseClient(group.root, group.server, client);
|
|
4718
|
+
}
|
|
4719
|
+
}
|
|
4720
|
+
});
|
|
4721
|
+
await Promise.all(runners);
|
|
4722
|
+
signal?.throwIfAborted();
|
|
4723
|
+
if (startedGroups === 0 && firstError !== undefined)
|
|
4724
|
+
throw firstError;
|
|
4725
|
+
}
|
|
4726
|
+
async function acquireWithinInitTimeout(options, group) {
|
|
4727
|
+
const { signal } = options;
|
|
4728
|
+
const timers = options.timers ?? realTimerProvider;
|
|
4729
|
+
const controller = new AbortController;
|
|
4730
|
+
const forwardAbort = () => controller.abort(signal?.reason);
|
|
4731
|
+
signal?.addEventListener("abort", forwardAbort, { once: true });
|
|
4732
|
+
if (signal?.aborted)
|
|
4733
|
+
forwardAbort();
|
|
4734
|
+
let timedOut = false;
|
|
4735
|
+
const timer = timers.setTimeout(() => {
|
|
4736
|
+
timedOut = true;
|
|
4737
|
+
controller.abort();
|
|
4738
|
+
}, INIT_TIMEOUT_MS);
|
|
4739
|
+
try {
|
|
4740
|
+
return await options.manager.getClient(group.root, group.server, controller.signal);
|
|
4741
|
+
} catch (error) {
|
|
4742
|
+
if (timedOut && signal?.aborted !== true) {
|
|
4743
|
+
throw new Error(`${group.server.id} did not start within ${INIT_TIMEOUT_MS}ms`);
|
|
4744
|
+
}
|
|
4745
|
+
throw error;
|
|
4746
|
+
} finally {
|
|
4747
|
+
timers.clearTimeout(timer);
|
|
4748
|
+
signal?.removeEventListener("abort", forwardAbort);
|
|
4749
|
+
}
|
|
4750
|
+
}
|
|
4751
|
+
function createSlots(limit) {
|
|
4752
|
+
let free = limit;
|
|
4753
|
+
const waiting = [];
|
|
4754
|
+
const release = () => {
|
|
4755
|
+
const next = waiting.shift();
|
|
4756
|
+
if (next === undefined)
|
|
4757
|
+
free += 1;
|
|
4758
|
+
else
|
|
4759
|
+
next();
|
|
4760
|
+
};
|
|
4761
|
+
return {
|
|
4762
|
+
acquire() {
|
|
4763
|
+
if (free > 0) {
|
|
4764
|
+
free -= 1;
|
|
4765
|
+
return Promise.resolve(release);
|
|
4766
|
+
}
|
|
4767
|
+
return new Promise((resolve) => waiting.push(() => resolve(release)));
|
|
4768
|
+
}
|
|
4769
|
+
};
|
|
4770
|
+
}
|
|
4771
|
+
|
|
4772
|
+
// ../lsp-core/src/lsp/directory-server-groups.ts
|
|
4773
|
+
import { dirname as dirname10 } from "node:path";
|
|
4774
|
+
function groupFilesByClient(files, extension, fixed = {}) {
|
|
4775
|
+
const byDirectory = new Map;
|
|
4776
|
+
const served = new Map;
|
|
4777
|
+
const unserved = new Map;
|
|
4778
|
+
for (const file of files) {
|
|
4779
|
+
const directory = dirname10(file);
|
|
4780
|
+
let resolution = byDirectory.get(directory);
|
|
4781
|
+
if (resolution === undefined) {
|
|
4782
|
+
resolution = resolveDirectory(directory, extension, fixed);
|
|
4783
|
+
byDirectory.set(directory, resolution);
|
|
4784
|
+
}
|
|
4785
|
+
if (resolution.kind === "served") {
|
|
4786
|
+
const group = served.get(resolution.key) ?? { root: resolution.root, server: resolution.server, files: [] };
|
|
4787
|
+
group.files.push(file);
|
|
4788
|
+
served.set(resolution.key, group);
|
|
4789
|
+
} else {
|
|
4790
|
+
const group = unserved.get(resolution.key) ?? { lookup: resolution.lookup, files: [] };
|
|
4791
|
+
group.files.push(file);
|
|
4792
|
+
unserved.set(resolution.key, group);
|
|
4793
|
+
}
|
|
4794
|
+
}
|
|
4795
|
+
return { served: [...served.values()], unserved: [...unserved.values()] };
|
|
4796
|
+
}
|
|
4797
|
+
function resolveDirectory(directory, extension, fixed) {
|
|
4798
|
+
const lookup = fixed.server === undefined ? findServerForExtension(extension, directory) : { status: "found", server: fixed.server };
|
|
4799
|
+
if (lookup.status !== "found") {
|
|
4800
|
+
const serverId = lookup.status === "not_installed" ? lookup.server.id : "";
|
|
4801
|
+
return { kind: "unserved", key: JSON.stringify([lookup.status, serverId]), lookup };
|
|
4802
|
+
}
|
|
4803
|
+
const root = fixed.workspaceRoot ?? findWorkspaceRoot(directory);
|
|
4804
|
+
return { kind: "served", key: lspClientKey(root, lookup.server), root, server: lookup.server };
|
|
4805
|
+
}
|
|
4626
4806
|
|
|
4627
4807
|
// ../lsp-core/src/lsp/formatters.ts
|
|
4628
4808
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -4752,7 +4932,7 @@ function collectFilesWithExtension(dir, extension, maxFiles) {
|
|
|
4752
4932
|
for (const entry of entries) {
|
|
4753
4933
|
if (files.length >= maxFiles)
|
|
4754
4934
|
return;
|
|
4755
|
-
const fullPath =
|
|
4935
|
+
const fullPath = join7(currentDir, entry);
|
|
4756
4936
|
let stat;
|
|
4757
4937
|
try {
|
|
4758
4938
|
stat = lstatSync4(fullPath);
|
|
@@ -4777,15 +4957,10 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
4777
4957
|
if (!extension.startsWith(".")) {
|
|
4778
4958
|
throw new LspInvalidPathError(`Extension must start with a dot (e.g., ".ts", not "${extension}"). Use ".${extension}" instead.`);
|
|
4779
4959
|
}
|
|
4780
|
-
const absDir =
|
|
4781
|
-
if (!
|
|
4960
|
+
const absDir = resolve10(options.workspaceRoot ?? contextCwd(), directory);
|
|
4961
|
+
if (!existsSync12(absDir)) {
|
|
4782
4962
|
throw new LspInvalidPathError(`Directory does not exist: ${absDir}`);
|
|
4783
4963
|
}
|
|
4784
|
-
const serverResult = options.server === undefined ? findServerForExtension(extension) : { status: "found", server: options.server };
|
|
4785
|
-
if (serverResult.status !== "found") {
|
|
4786
|
-
throw new LspServerLookupError(formatServerLookupError(serverResult));
|
|
4787
|
-
}
|
|
4788
|
-
const server = serverResult.server;
|
|
4789
4964
|
const allFiles = (options.listFiles ?? collectFilesWithExtension)(absDir, extension, maxFiles + 1);
|
|
4790
4965
|
const wasCapped = allFiles.length > maxFiles;
|
|
4791
4966
|
const filesToProcess = allFiles.slice(0, maxFiles);
|
|
@@ -4799,42 +4974,43 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
4799
4974
|
`);
|
|
4800
4975
|
return { output, totalDiagnostics: 0, fileFailures: [] };
|
|
4801
4976
|
}
|
|
4802
|
-
const
|
|
4977
|
+
const groups = groupFilesByClient(filesToProcess, extension, {
|
|
4978
|
+
...options.server === undefined ? {} : { server: options.server },
|
|
4979
|
+
...options.workspaceRoot === undefined ? {} : { workspaceRoot: options.workspaceRoot }
|
|
4980
|
+
});
|
|
4981
|
+
const firstUnserved = groups.unserved[0];
|
|
4982
|
+
if (groups.served.length === 0 && firstUnserved !== undefined) {
|
|
4983
|
+
throw new LspServerLookupError(formatServerLookupError(firstUnserved.lookup));
|
|
4984
|
+
}
|
|
4803
4985
|
const manager = options.manager ?? getLspManager();
|
|
4804
4986
|
const allDiagnostics = [];
|
|
4805
4987
|
const fileErrors = [];
|
|
4806
4988
|
const maxConcurrency = Math.max(1, options.maxConcurrency ?? DIRECTORY_DIAGNOSTICS_MAX_CONCURRENCY);
|
|
4989
|
+
for (const group of groups.unserved) {
|
|
4990
|
+
const error = formatServerLookupError(group.lookup).split(`
|
|
4991
|
+
`)[0] ?? "No LSP server";
|
|
4992
|
+
fileErrors.push(...group.files.map((file) => ({ file, error })));
|
|
4993
|
+
}
|
|
4807
4994
|
options.signal?.throwIfAborted();
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
diagnostic
|
|
4825
|
-
})));
|
|
4826
|
-
} catch (e) {
|
|
4827
|
-
fileErrors.push({
|
|
4828
|
-
file,
|
|
4829
|
-
error: e instanceof Error ? e.message : String(e)
|
|
4830
|
-
});
|
|
4831
|
-
}
|
|
4995
|
+
await scanServedGroups({
|
|
4996
|
+
manager,
|
|
4997
|
+
groups: groups.served,
|
|
4998
|
+
maxConcurrency,
|
|
4999
|
+
...options.signal === undefined ? {} : { signal: options.signal },
|
|
5000
|
+
...options.timers === undefined ? {} : { timers: options.timers },
|
|
5001
|
+
onGroupUnavailable: (group, error) => {
|
|
5002
|
+
fileErrors.push(...group.files.map((file) => ({ file, error })));
|
|
5003
|
+
},
|
|
5004
|
+
checkFile: async (client, file) => {
|
|
5005
|
+
try {
|
|
5006
|
+
const result = await client.diagnostics(file, options.signal);
|
|
5007
|
+
const filtered = filterDiagnosticsBySeverity(result.items, severity);
|
|
5008
|
+
allDiagnostics.push(...filtered.map((diagnostic) => ({ filePath: file, diagnostic })));
|
|
5009
|
+
} catch (e) {
|
|
5010
|
+
fileErrors.push({ file, error: e instanceof Error ? e.message : String(e) });
|
|
4832
5011
|
}
|
|
4833
|
-
}
|
|
4834
|
-
|
|
4835
|
-
} finally {
|
|
4836
|
-
manager.releaseClient(root, server.id);
|
|
4837
|
-
}
|
|
5012
|
+
}
|
|
5013
|
+
});
|
|
4838
5014
|
const displayDiagnostics = allDiagnostics.slice(0, DEFAULT_MAX_DIAGNOSTICS);
|
|
4839
5015
|
const wasDiagCapped = allDiagnostics.length > DEFAULT_MAX_DIAGNOSTICS;
|
|
4840
5016
|
const lines = [
|
|
@@ -4865,7 +5041,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
4865
5041
|
|
|
4866
5042
|
// ../lsp-core/src/lsp/infer-extension.ts
|
|
4867
5043
|
import { lstatSync as lstatSync5, readdirSync as readdirSync4 } from "node:fs";
|
|
4868
|
-
import { join as
|
|
5044
|
+
import { join as join8 } from "node:path";
|
|
4869
5045
|
var SKIP_DIRECTORIES2 = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]);
|
|
4870
5046
|
var MAX_SCAN_ENTRIES = 500;
|
|
4871
5047
|
function inferExtensionFromDirectory(directory) {
|
|
@@ -4883,7 +5059,7 @@ function inferExtensionFromDirectory(directory) {
|
|
|
4883
5059
|
for (const entry of entries) {
|
|
4884
5060
|
if (scanned >= MAX_SCAN_ENTRIES)
|
|
4885
5061
|
return;
|
|
4886
|
-
const fullPath =
|
|
5062
|
+
const fullPath = join8(dir, entry);
|
|
4887
5063
|
let stat;
|
|
4888
5064
|
try {
|
|
4889
5065
|
stat = lstatSync5(fullPath);
|
|
@@ -5002,7 +5178,7 @@ function missingDependencyAvailability(error) {
|
|
|
5002
5178
|
}
|
|
5003
5179
|
|
|
5004
5180
|
// ../lsp-core/src/lsp/bun-command-output.ts
|
|
5005
|
-
import { resolve as
|
|
5181
|
+
import { resolve as resolve11 } from "node:path";
|
|
5006
5182
|
var TSC_LINE = /^(.+?)\((\d+),(\d+)\): (error|warning|message) (TS\d+): (.*)$/;
|
|
5007
5183
|
var TSC_SEVERITY = { error: 1, warning: 2, message: 3 };
|
|
5008
5184
|
function parseBunCheckOutput(stdout, cwd) {
|
|
@@ -5013,7 +5189,7 @@ function parseBunCheckOutput(stdout, cwd) {
|
|
|
5013
5189
|
const [, path, lineNumber, column, severity, code, message] = match;
|
|
5014
5190
|
const start = { line: Number(lineNumber) - 1, character: Number(column) - 1 };
|
|
5015
5191
|
results.push({
|
|
5016
|
-
file:
|
|
5192
|
+
file: resolve11(cwd, path ?? ""),
|
|
5017
5193
|
diagnostic: {
|
|
5018
5194
|
range: { start, end: start },
|
|
5019
5195
|
severity: TSC_SEVERITY[severity ?? "error"] ?? 1,
|
|
@@ -5072,9 +5248,9 @@ function parseBunLintJson(stdout) {
|
|
|
5072
5248
|
|
|
5073
5249
|
// ../lsp-core/src/lsp/bun-project-checks.ts
|
|
5074
5250
|
import { spawn as spawn2 } from "node:child_process";
|
|
5075
|
-
import { existsSync as
|
|
5251
|
+
import { existsSync as existsSync13, mkdtempSync, readFileSync as readFileSync5, rmSync as rmSync2, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
|
|
5076
5252
|
import { homedir as homedir2, tmpdir } from "node:os";
|
|
5077
|
-
import { dirname as
|
|
5253
|
+
import { dirname as dirname11, join as join9, resolve as resolve12 } from "node:path";
|
|
5078
5254
|
var BUN_LOCKFILES = ["bun.lock", "bun.lockb", "bunfig.toml"];
|
|
5079
5255
|
var RUNNABLE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".cts", ".cjs", ".js", ".mjs", ".mts"];
|
|
5080
5256
|
var BIN_SUFFIXES = process.platform === "win32" ? [".exe", ".bunx", ".cmd", ""] : [""];
|
|
@@ -5083,18 +5259,18 @@ var UNFORMATTED_PROBE = `const a=1
|
|
|
5083
5259
|
`;
|
|
5084
5260
|
var probeCache = new Map;
|
|
5085
5261
|
function findBunProjectRoot(start, home = homedir2()) {
|
|
5086
|
-
const stopAt =
|
|
5087
|
-
let dir =
|
|
5262
|
+
const stopAt = resolve12(home);
|
|
5263
|
+
let dir = resolve12(start);
|
|
5088
5264
|
for (;; ) {
|
|
5089
5265
|
if (dir === stopAt)
|
|
5090
5266
|
return;
|
|
5091
|
-
if (BUN_LOCKFILES.some((name) =>
|
|
5267
|
+
if (BUN_LOCKFILES.some((name) => existsSync13(join9(dir, name))))
|
|
5092
5268
|
return dir;
|
|
5093
|
-
if (packageManagerIsBun(
|
|
5269
|
+
if (packageManagerIsBun(join9(dir, "package.json")))
|
|
5094
5270
|
return dir;
|
|
5095
|
-
if (
|
|
5271
|
+
if (existsSync13(join9(dir, ".git")))
|
|
5096
5272
|
return;
|
|
5097
|
-
const parent =
|
|
5273
|
+
const parent = dirname11(dir);
|
|
5098
5274
|
if (parent === dir)
|
|
5099
5275
|
return;
|
|
5100
5276
|
dir = parent;
|
|
@@ -5106,7 +5282,7 @@ function packageManagerIsBun(packageJsonPath) {
|
|
|
5106
5282
|
return typeof packageManager === "string" && packageManager.startsWith("bun@");
|
|
5107
5283
|
}
|
|
5108
5284
|
function readJsonObject(path) {
|
|
5109
|
-
if (!
|
|
5285
|
+
if (!existsSync13(path))
|
|
5110
5286
|
return;
|
|
5111
5287
|
try {
|
|
5112
5288
|
const parsed = JSON.parse(readFileSync5(path, "utf8"));
|
|
@@ -5117,14 +5293,14 @@ function readJsonObject(path) {
|
|
|
5117
5293
|
}
|
|
5118
5294
|
function isFile(path) {
|
|
5119
5295
|
try {
|
|
5120
|
-
return
|
|
5296
|
+
return statSync5(path).isFile();
|
|
5121
5297
|
} catch {
|
|
5122
5298
|
return false;
|
|
5123
5299
|
}
|
|
5124
5300
|
}
|
|
5125
5301
|
function isDirectory(path) {
|
|
5126
5302
|
try {
|
|
5127
|
-
return
|
|
5303
|
+
return statSync5(path).isDirectory();
|
|
5128
5304
|
} catch {
|
|
5129
5305
|
return false;
|
|
5130
5306
|
}
|
|
@@ -5132,35 +5308,35 @@ function isDirectory(path) {
|
|
|
5132
5308
|
function projectShadowsBunCommand(command, cwd) {
|
|
5133
5309
|
const packageJsonDir = nearestPackageJsonDir(cwd);
|
|
5134
5310
|
if (packageJsonDir !== undefined) {
|
|
5135
|
-
const scripts = readJsonObject(
|
|
5311
|
+
const scripts = readJsonObject(join9(packageJsonDir, "package.json"))?.["scripts"];
|
|
5136
5312
|
if (scripts !== null && typeof scripts === "object" && typeof scripts[command] === "string") {
|
|
5137
5313
|
return true;
|
|
5138
5314
|
}
|
|
5139
5315
|
}
|
|
5140
5316
|
if (command === "check")
|
|
5141
5317
|
return false;
|
|
5142
|
-
const base =
|
|
5318
|
+
const base = join9(cwd, command);
|
|
5143
5319
|
if (isFile(base) || RUNNABLE_EXTENSIONS.some((extension) => isFile(`${base}${extension}`)))
|
|
5144
5320
|
return true;
|
|
5145
|
-
if (isDirectory(base) && (isFile(
|
|
5321
|
+
if (isDirectory(base) && (isFile(join9(base, "package.json")) || RUNNABLE_EXTENSIONS.some((extension) => isFile(join9(base, `index${extension}`))))) {
|
|
5146
5322
|
return true;
|
|
5147
5323
|
}
|
|
5148
|
-
let dir =
|
|
5324
|
+
let dir = resolve12(cwd);
|
|
5149
5325
|
for (;; ) {
|
|
5150
|
-
if (BIN_SUFFIXES.some((suffix) =>
|
|
5326
|
+
if (BIN_SUFFIXES.some((suffix) => existsSync13(join9(dir, "node_modules", ".bin", `${command}${suffix}`))))
|
|
5151
5327
|
return true;
|
|
5152
|
-
const parent =
|
|
5328
|
+
const parent = dirname11(dir);
|
|
5153
5329
|
if (parent === dir)
|
|
5154
5330
|
return false;
|
|
5155
5331
|
dir = parent;
|
|
5156
5332
|
}
|
|
5157
5333
|
}
|
|
5158
5334
|
function nearestPackageJsonDir(start) {
|
|
5159
|
-
let dir =
|
|
5335
|
+
let dir = resolve12(start);
|
|
5160
5336
|
for (;; ) {
|
|
5161
|
-
if (
|
|
5337
|
+
if (existsSync13(join9(dir, "package.json")))
|
|
5162
5338
|
return dir;
|
|
5163
|
-
const parent =
|
|
5339
|
+
const parent = dirname11(dir);
|
|
5164
5340
|
if (parent === dir)
|
|
5165
5341
|
return;
|
|
5166
5342
|
dir = parent;
|
|
@@ -5168,7 +5344,7 @@ function nearestPackageJsonDir(start) {
|
|
|
5168
5344
|
}
|
|
5169
5345
|
function binaryIdentity(bunPath) {
|
|
5170
5346
|
try {
|
|
5171
|
-
const stats =
|
|
5347
|
+
const stats = statSync5(bunPath);
|
|
5172
5348
|
return `${stats.mtimeMs}:${stats.size}`;
|
|
5173
5349
|
} catch {
|
|
5174
5350
|
return "missing";
|
|
@@ -5188,7 +5364,7 @@ function bunHasCommand(bunPath, command, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
|
5188
5364
|
return probe;
|
|
5189
5365
|
}
|
|
5190
5366
|
async function probeOnce(bunPath, command, timeoutMs) {
|
|
5191
|
-
const emptyDir = mkdtempSync(
|
|
5367
|
+
const emptyDir = mkdtempSync(join9(tmpdir(), "omo-bun-probe-"));
|
|
5192
5368
|
const timeout = AbortSignal.timeout(timeoutMs);
|
|
5193
5369
|
try {
|
|
5194
5370
|
const help = await runBunCommand(bunPath, [command, "--help"], emptyDir, timeout);
|
|
@@ -5198,7 +5374,7 @@ async function probeOnce(bunPath, command, timeoutMs) {
|
|
|
5198
5374
|
return false;
|
|
5199
5375
|
if (command !== "format")
|
|
5200
5376
|
return true;
|
|
5201
|
-
const probeFile =
|
|
5377
|
+
const probeFile = join9(emptyDir, "probe.ts");
|
|
5202
5378
|
writeFileSync3(probeFile, UNFORMATTED_PROBE);
|
|
5203
5379
|
const write = await runBunCommand(bunPath, ["format", "--write", "probe.ts"], emptyDir, timeout);
|
|
5204
5380
|
if (write.exitCode === null)
|