oh-my-opencode 5.0.0-beta.23 → 5.0.0-beta.25
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 +141 -184
- package/dist/cli-node/index.js +141 -184
- package/dist/index.js +1508 -1567
- package/dist/skills/debugging/SKILL.md +0 -2
- package/dist/skills/debugging/references/methodology/00-setup.md +0 -12
- package/dist/skills/debugging/references/methodology/02-investigate.md +0 -21
- package/dist/skills/debugging/references/runtimes/go.md +1 -15
- package/dist/skills/debugging/references/runtimes/native-binary.md +0 -38
- package/dist/skills/debugging/references/runtimes/node.md +0 -25
- package/dist/skills/debugging/references/runtimes/python.md +0 -13
- package/dist/skills/debugging/references/runtimes/rust.md +0 -41
- package/dist/tools/delegate-task/types.d.ts +0 -3
- package/dist/tui.js +0 -25
- package/package.json +15 -18
- package/packages/lsp-core/src/index.ts +0 -1
- package/packages/lsp-core/src/lsp/client-wrapper.ts +5 -25
- package/packages/lsp-core/src/lsp/client.ts +0 -26
- package/packages/lsp-core/src/lsp/connection.ts +0 -16
- package/packages/lsp-core/src/lsp/constants.ts +0 -1
- package/packages/lsp-core/src/lsp/manager.ts +1 -34
- package/packages/lsp-core/src/lsp/server-definitions.ts +0 -29
- package/packages/lsp-core/src/lsp/server-installation.ts +27 -200
- package/packages/lsp-core/src/lsp/server-resolution.ts +5 -18
- package/packages/lsp-core/src/lsp/transport.ts +0 -9
- package/packages/lsp-core/src/lsp/types.ts +0 -8
- package/packages/lsp-core/src/tool-surface.test.ts +1 -13
- package/packages/lsp-core/src/tools/definitions.ts +0 -14
- package/packages/lsp-core/src/tools/index.ts +0 -1
- package/packages/lsp-core/src/tools/types.ts +0 -10
- package/packages/lsp-daemon/dist/cli.js +144 -432
- package/packages/lsp-daemon/dist/client.d.ts +0 -10
- package/packages/lsp-daemon/dist/client.js +107 -401
- package/packages/lsp-daemon/dist/daemon-client.d.ts +0 -1
- package/packages/lsp-daemon/dist/daemon-client.js +0 -3
- package/packages/lsp-daemon/dist/index.js +107 -395
- package/packages/lsp-tools-mcp/dist/cli.js +99 -384
- package/packages/lsp-tools-mcp/dist/lsp/manager.js +0 -53
- package/packages/lsp-tools-mcp/dist/mcp.js +99 -384
- package/packages/lsp-tools-mcp/dist/tools.js +99 -385
- 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/codegraph/dist/cli.js +35 -69
- package/packages/omo-codex/plugin/components/codegraph/dist/serve.js +2 -21
- package/packages/omo-codex/plugin/components/codegraph/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 +121 -404
- 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/dist/cli.js +3 -3
- 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/rules/src/post-compact-budget.ts +3 -3
- package/packages/omo-codex/plugin/components/rules/test/post-compact-budget.test.ts +4 -4
- 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 +15 -30
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +15 -30
- 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 +2 -2
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +4 -4
- 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-codegraph-init-guidance.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/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-checking-codegraph-bootstrap.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-checking-ulw-execute-continuation.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/model-catalog.json +3 -3
- package/packages/omo-codex/plugin/package-lock.json +13 -13
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/scripts/migrate-codex-config/catalog.mjs +3 -3
- package/packages/omo-codex/plugin/skills/debugging/SKILL.md +0 -2
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/00-setup.md +0 -12
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/02-investigate.md +0 -21
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/go.md +1 -15
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/native-binary.md +0 -38
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/node.md +0 -25
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/python.md +0 -13
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/rust.md +0 -41
- package/packages/omo-codex/plugin/test/aggregate-model-catalog.test.mjs +1 -1
- package/packages/omo-codex/plugin/test/auto-update.test.mjs +2 -2
- package/packages/omo-codex/plugin/test/migrate-codex-config.test.mjs +8 -8
- package/packages/omo-codex/scripts/install-config-reasoning.test.mjs +2 -2
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +23 -38
- package/packages/shared-skills/skills/debugging/SKILL.md +0 -2
- package/packages/shared-skills/skills/debugging/references/methodology/00-setup.md +0 -12
- package/packages/shared-skills/skills/debugging/references/methodology/02-investigate.md +0 -21
- package/packages/shared-skills/skills/debugging/references/runtimes/go.md +1 -15
- package/packages/shared-skills/skills/debugging/references/runtimes/native-binary.md +0 -38
- package/packages/shared-skills/skills/debugging/references/runtimes/node.md +0 -25
- package/packages/shared-skills/skills/debugging/references/runtimes/python.md +0 -13
- package/packages/shared-skills/skills/debugging/references/runtimes/rust.md +0 -41
- package/dist/skills/debugging/references/scripts/dap.mjs +0 -267
- package/dist/skills/debugging/references/scripts/dap.test.ts +0 -86
- package/dist/skills/debugging/references/scripts/fixture-adapter.mjs +0 -59
- package/dist/skills/debugging/references/tools/dap.md +0 -103
- package/dist/skills/debugging/references/tools/frida.md +0 -193
- package/packages/lsp-core/src/lsp/format-document.test.ts +0 -143
- package/packages/lsp-core/src/lsp/format-document.ts +0 -90
- package/packages/lsp-core/src/lsp/manager-max-clients.test.ts +0 -151
- package/packages/lsp-core/src/lsp/server-installation.test.ts +0 -376
- package/packages/lsp-core/src/lsp/server-resolution-local-binary.test.ts +0 -170
- package/packages/lsp-core/src/tools/format.test.ts +0 -56
- package/packages/lsp-core/src/tools/format.ts +0 -56
- package/packages/omo-codex/plugin/skills/debugging/references/scripts/dap.mjs +0 -267
- package/packages/omo-codex/plugin/skills/debugging/references/scripts/fixture-adapter.mjs +0 -59
- package/packages/omo-codex/plugin/skills/debugging/references/tools/dap.md +0 -103
- package/packages/omo-codex/plugin/skills/debugging/references/tools/frida.md +0 -193
- package/packages/shared-skills/skills/debugging/references/scripts/dap.mjs +0 -267
- package/packages/shared-skills/skills/debugging/references/scripts/dap.test.ts +0 -86
- package/packages/shared-skills/skills/debugging/references/scripts/fixture-adapter.mjs +0 -59
- package/packages/shared-skills/skills/debugging/references/tools/dap.md +0 -103
- package/packages/shared-skills/skills/debugging/references/tools/frida.md +0 -193
|
@@ -5,7 +5,7 @@ import { argv, stderr } from "node:process";
|
|
|
5
5
|
|
|
6
6
|
// src/proxy.ts
|
|
7
7
|
import { existsSync as existsSync13, realpathSync as realpathSync6 } from "node:fs";
|
|
8
|
-
import { basename as basename4, delimiter as delimiter4, dirname as
|
|
8
|
+
import { basename as basename4, delimiter as delimiter4, dirname as dirname10, isAbsolute as isAbsolute5 } from "node:path";
|
|
9
9
|
|
|
10
10
|
// ../mcp-stdio-core/src/record.ts
|
|
11
11
|
function isPlainRecord(value) {
|
|
@@ -320,7 +320,7 @@ function createIdleTimer(idleTimeoutMs, log, onTimeout) {
|
|
|
320
320
|
}
|
|
321
321
|
// ../lsp-core/src/lsp/client-wrapper.ts
|
|
322
322
|
import { existsSync as existsSync10, realpathSync as realpathSync5, statSync as statSync3 } from "node:fs";
|
|
323
|
-
import { basename as basename3, dirname as
|
|
323
|
+
import { basename as basename3, dirname as dirname7, join as join5, resolve as resolve7 } from "node:path";
|
|
324
324
|
|
|
325
325
|
// ../lsp-core/src/request-context.ts
|
|
326
326
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -592,7 +592,6 @@ var DEFAULT_MAX_DIRECTORY_FILES = 50;
|
|
|
592
592
|
var REQUEST_TIMEOUT_MS = 15000;
|
|
593
593
|
var INIT_TIMEOUT_MS = 60000;
|
|
594
594
|
var IDLE_TIMEOUT_MS = 5 * 60000;
|
|
595
|
-
var MAX_RESIDENT_CLIENTS = 6;
|
|
596
595
|
var REAPER_INTERVAL_MS = 60000;
|
|
597
596
|
var STOP_HARD_KILL_TIMEOUT_MS = 5000;
|
|
598
597
|
var STOP_SIGKILL_GRACE_MS = 1000;
|
|
@@ -1118,7 +1117,6 @@ class LspClientTransport {
|
|
|
1118
1117
|
this.diagnosticsStore = new Map;
|
|
1119
1118
|
this.workspaceApplyEditHandler = null;
|
|
1120
1119
|
this.diagnosticPullSupported = false;
|
|
1121
|
-
this.documentFormattingSupported = false;
|
|
1122
1120
|
this.requestTimeoutMs = timeouts.requestTimeoutMs ?? REQUEST_TIMEOUT_MS;
|
|
1123
1121
|
this.initializeTimeoutMs = timeouts.initializeTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
1124
1122
|
}
|
|
@@ -1140,12 +1138,6 @@ class LspClientTransport {
|
|
|
1140
1138
|
isDiagnosticPullSupported() {
|
|
1141
1139
|
return this.diagnosticPullSupported;
|
|
1142
1140
|
}
|
|
1143
|
-
setDocumentFormattingSupported(supported) {
|
|
1144
|
-
this.documentFormattingSupported = supported;
|
|
1145
|
-
}
|
|
1146
|
-
isDocumentFormattingSupported() {
|
|
1147
|
-
return this.documentFormattingSupported;
|
|
1148
|
-
}
|
|
1149
1141
|
handlePublishDiagnostics(params) {
|
|
1150
1142
|
this.diagnosticsStore.set(params.uri, [...params.diagnostics]);
|
|
1151
1143
|
}
|
|
@@ -1359,14 +1351,6 @@ function supportsDiagnosticPull(capabilities) {
|
|
|
1359
1351
|
return false;
|
|
1360
1352
|
return Object.hasOwn(capabilities, "diagnosticProvider");
|
|
1361
1353
|
}
|
|
1362
|
-
function supportsDocumentFormatting(capabilities) {
|
|
1363
|
-
if (capabilities === undefined)
|
|
1364
|
-
return false;
|
|
1365
|
-
const provider = capabilities.documentFormattingProvider;
|
|
1366
|
-
if (provider === undefined || provider === null || provider === false)
|
|
1367
|
-
return false;
|
|
1368
|
-
return provider === true || typeof provider === "object";
|
|
1369
|
-
}
|
|
1370
1354
|
|
|
1371
1355
|
class LspClientConnection extends LspClientTransport {
|
|
1372
1356
|
async initialize() {
|
|
@@ -1383,7 +1367,6 @@ class LspClientConnection extends LspClientTransport {
|
|
|
1383
1367
|
references: {},
|
|
1384
1368
|
documentSymbol: { hierarchicalDocumentSymbolSupport: true },
|
|
1385
1369
|
publishDiagnostics: {},
|
|
1386
|
-
formatting: { dynamicRegistration: false },
|
|
1387
1370
|
rename: {
|
|
1388
1371
|
prepareSupport: true,
|
|
1389
1372
|
prepareSupportDefaultBehavior: 1
|
|
@@ -1425,7 +1408,6 @@ class LspClientConnection extends LspClientTransport {
|
|
|
1425
1408
|
initializationOptions: this.server.initialization
|
|
1426
1409
|
}, { timeoutMs: this.initializeTimeoutMs });
|
|
1427
1410
|
this.setDiagnosticPullSupported(supportsDiagnosticPull(result?.capabilities));
|
|
1428
|
-
this.setDocumentFormattingSupported(supportsDocumentFormatting(result?.capabilities));
|
|
1429
1411
|
await this.sendNotification("initialized", {});
|
|
1430
1412
|
await this.sendNotification("workspace/didChangeConfiguration", {
|
|
1431
1413
|
settings: { json: { validate: { enable: true } } }
|
|
@@ -3010,18 +2992,6 @@ class LspClient extends LspClientConnection {
|
|
|
3010
2992
|
textDocument: { uri: pathToFileURL3(absPath).href }
|
|
3011
2993
|
}, options);
|
|
3012
2994
|
}
|
|
3013
|
-
async formatDocument(filePath, options, signal) {
|
|
3014
|
-
if (!this.isDocumentFormattingSupported())
|
|
3015
|
-
return null;
|
|
3016
|
-
const absPath = this.resolveWorkspacePath(filePath);
|
|
3017
|
-
await this.openFile(absPath);
|
|
3018
|
-
const requestOptions = signal === undefined ? {} : { signal };
|
|
3019
|
-
const edits = await this.sendRequest("textDocument/formatting", {
|
|
3020
|
-
textDocument: { uri: pathToFileURL3(absPath).href },
|
|
3021
|
-
options
|
|
3022
|
-
}, requestOptions);
|
|
3023
|
-
return edits ?? [];
|
|
3024
|
-
}
|
|
3025
2995
|
async workspaceSymbols(query, signal) {
|
|
3026
2996
|
const options = signal === undefined ? {} : { signal };
|
|
3027
2997
|
return this.sendRequest("workspace/symbol", { query }, options);
|
|
@@ -3274,7 +3244,6 @@ class LspManager {
|
|
|
3274
3244
|
this.disposed = false;
|
|
3275
3245
|
this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS;
|
|
3276
3246
|
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
3277
|
-
this.maxResidentClients = options.maxResidentClients ?? MAX_RESIDENT_CLIENTS;
|
|
3278
3247
|
this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
|
|
3279
3248
|
this.clientFactory = options.clientFactory ?? ((root, server2) => new LspClient(root, server2));
|
|
3280
3249
|
this.now = options.now ?? (() => Date.now());
|
|
@@ -3308,26 +3277,6 @@ class LspManager {
|
|
|
3308
3277
|
}
|
|
3309
3278
|
}
|
|
3310
3279
|
}
|
|
3311
|
-
evictForAdmission() {
|
|
3312
|
-
while (this.clients.size >= this.maxResidentClients) {
|
|
3313
|
-
const victim = this.leastRecentlyUsedIdleClient();
|
|
3314
|
-
if (!victim)
|
|
3315
|
-
return;
|
|
3316
|
-
this.clients.delete(victim.key);
|
|
3317
|
-
stopClientBestEffort(victim.managed.client);
|
|
3318
|
-
}
|
|
3319
|
-
}
|
|
3320
|
-
leastRecentlyUsedIdleClient() {
|
|
3321
|
-
let candidate = null;
|
|
3322
|
-
for (const [key, managed] of this.clients) {
|
|
3323
|
-
if (managed.refCount > 0 || managed.pendingWaiters > 0 || managed.isInitializing)
|
|
3324
|
-
continue;
|
|
3325
|
-
if (candidate === null || managed.lastUsedAt < candidate.managed.lastUsedAt) {
|
|
3326
|
-
candidate = { key, managed };
|
|
3327
|
-
}
|
|
3328
|
-
}
|
|
3329
|
-
return candidate;
|
|
3330
|
-
}
|
|
3331
3280
|
async tryDeleteIfOrphaned(key, managed) {
|
|
3332
3281
|
if (managed.refCount === 0 && managed.pendingWaiters === 0 && !managed.isInitializing && this.clients.get(key) === managed) {
|
|
3333
3282
|
this.clients.delete(key);
|
|
@@ -3374,7 +3323,6 @@ class LspManager {
|
|
|
3374
3323
|
managed.lastUsedAt = this.now();
|
|
3375
3324
|
return managed.client;
|
|
3376
3325
|
}
|
|
3377
|
-
this.evictForAdmission();
|
|
3378
3326
|
const client = this.clientFactory(root, server2);
|
|
3379
3327
|
const initStartedAt = this.now();
|
|
3380
3328
|
const initPromise = (async () => {
|
|
@@ -3437,7 +3385,6 @@ class LspManager {
|
|
|
3437
3385
|
const key = this.getKey(root, server2.id);
|
|
3438
3386
|
if (this.clients.has(key))
|
|
3439
3387
|
return;
|
|
3440
|
-
this.evictForAdmission();
|
|
3441
3388
|
const client = this.clientFactory(root, server2);
|
|
3442
3389
|
const initStartedAt = this.now();
|
|
3443
3390
|
const initPromise = (async () => {
|
|
@@ -3563,6 +3510,57 @@ function nearestExistingAncestor(directory) {
|
|
|
3563
3510
|
return current;
|
|
3564
3511
|
}
|
|
3565
3512
|
|
|
3513
|
+
// ../lsp-core/src/lsp/server-install-state.ts
|
|
3514
|
+
import { existsSync as existsSync7, mkdirSync, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
3515
|
+
import { dirname as dirname6 } from "node:path";
|
|
3516
|
+
function getInstallDecisionsPath() {
|
|
3517
|
+
return lspRequestContext().installDecisionsPath;
|
|
3518
|
+
}
|
|
3519
|
+
function loadInstallDecisions() {
|
|
3520
|
+
const path = getInstallDecisionsPath();
|
|
3521
|
+
if (!existsSync7(path))
|
|
3522
|
+
return {};
|
|
3523
|
+
try {
|
|
3524
|
+
const parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
3525
|
+
return isInstallDecisions(parsed) ? parsed : {};
|
|
3526
|
+
} catch {
|
|
3527
|
+
return {};
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
function loadInstallDecision(serverId) {
|
|
3531
|
+
return loadInstallDecisions()[serverId];
|
|
3532
|
+
}
|
|
3533
|
+
function recordInstallDecision(serverId, decision, decidedAt = new Date().toISOString()) {
|
|
3534
|
+
const decisions = loadInstallDecisions();
|
|
3535
|
+
decisions[serverId] = { decision, decidedAt };
|
|
3536
|
+
writeInstallDecisions(decisions);
|
|
3537
|
+
}
|
|
3538
|
+
function isInstallDecision(value) {
|
|
3539
|
+
return value === "declined" || value === "allowed";
|
|
3540
|
+
}
|
|
3541
|
+
function writeInstallDecisions(decisions) {
|
|
3542
|
+
const path = getInstallDecisionsPath();
|
|
3543
|
+
mkdirSync(dirname6(path), { recursive: true });
|
|
3544
|
+
const tmpPath = `${path}.tmp`;
|
|
3545
|
+
writeFileSync2(tmpPath, `${JSON.stringify(decisions, null, 2)}
|
|
3546
|
+
`, "utf8");
|
|
3547
|
+
renameSync2(tmpPath, path);
|
|
3548
|
+
}
|
|
3549
|
+
function isInstallDecisions(value) {
|
|
3550
|
+
return isRecord5(value) && Object.values(value).every(isInstallDecisionRecord);
|
|
3551
|
+
}
|
|
3552
|
+
function isInstallDecisionRecord(value) {
|
|
3553
|
+
if (!isRecord5(value))
|
|
3554
|
+
return false;
|
|
3555
|
+
return isInstallDecision(value["decision"]) && typeof value["decidedAt"] === "string";
|
|
3556
|
+
}
|
|
3557
|
+
function isRecord5(value) {
|
|
3558
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3559
|
+
}
|
|
3560
|
+
|
|
3561
|
+
// ../lsp-core/src/lsp/config-loader.ts
|
|
3562
|
+
import { existsSync as existsSync8, readFileSync as readFileSync4 } from "node:fs";
|
|
3563
|
+
|
|
3566
3564
|
// ../lsp-core/src/lsp/server-definitions.ts
|
|
3567
3565
|
var LSP_INSTALL_HINTS = {
|
|
3568
3566
|
typescript: "npm install -g typescript-language-server typescript",
|
|
@@ -3608,26 +3606,6 @@ var LSP_INSTALL_HINTS = {
|
|
|
3608
3606
|
julials: `julia -e 'using Pkg; Pkg.add("LanguageServer")'`,
|
|
3609
3607
|
razor: "Razor runs through the Roslyn language server (cohosting). " + "Install: dotnet tool install -g roslyn-language-server --prerelease (requires v5.8.0+). See https://github.com/dotnet/razor"
|
|
3610
3608
|
};
|
|
3611
|
-
var LSP_LOCAL_INSTALL_HINTS = {
|
|
3612
|
-
typescript: "bun add -d typescript-language-server typescript",
|
|
3613
|
-
vue: "bun add -d @vue/language-server",
|
|
3614
|
-
eslint: "bun add -d vscode-langservers-extracted",
|
|
3615
|
-
oxlint: "bun add -d oxlint",
|
|
3616
|
-
biome: "bun add -d @biomejs/biome",
|
|
3617
|
-
svelte: "bun add -d svelte-language-server",
|
|
3618
|
-
astro: "bun add -d @astrojs/language-server",
|
|
3619
|
-
bash: "bun add -d bash-language-server",
|
|
3620
|
-
"bash-ls": "bun add -d bash-language-server",
|
|
3621
|
-
"yaml-ls": "bun add -d yaml-language-server",
|
|
3622
|
-
php: "bun add -d intelephense",
|
|
3623
|
-
prisma: "bun add -d prisma",
|
|
3624
|
-
dockerfile: "bun add -d dockerfile-language-server-nodejs",
|
|
3625
|
-
pyright: "uv add --dev pyright",
|
|
3626
|
-
basedpyright: "uv add --dev basedpyright",
|
|
3627
|
-
ruff: "uv add --dev ruff",
|
|
3628
|
-
ty: "uv add --dev ty",
|
|
3629
|
-
"ruby-lsp": "bundle add ruby-lsp --group development"
|
|
3630
|
-
};
|
|
3631
3609
|
var BUILTIN_SERVERS = {
|
|
3632
3610
|
typescript: {
|
|
3633
3611
|
command: ["typescript-language-server", "--stdio"],
|
|
@@ -3730,56 +3708,7 @@ var BUILTIN_SERVERS = {
|
|
|
3730
3708
|
}
|
|
3731
3709
|
};
|
|
3732
3710
|
|
|
3733
|
-
// ../lsp-core/src/lsp/server-install-state.ts
|
|
3734
|
-
import { existsSync as existsSync7, mkdirSync, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
3735
|
-
import { dirname as dirname6 } from "node:path";
|
|
3736
|
-
function getInstallDecisionsPath() {
|
|
3737
|
-
return lspRequestContext().installDecisionsPath;
|
|
3738
|
-
}
|
|
3739
|
-
function loadInstallDecisions() {
|
|
3740
|
-
const path = getInstallDecisionsPath();
|
|
3741
|
-
if (!existsSync7(path))
|
|
3742
|
-
return {};
|
|
3743
|
-
try {
|
|
3744
|
-
const parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
3745
|
-
return isInstallDecisions(parsed) ? parsed : {};
|
|
3746
|
-
} catch {
|
|
3747
|
-
return {};
|
|
3748
|
-
}
|
|
3749
|
-
}
|
|
3750
|
-
function loadInstallDecision(serverId) {
|
|
3751
|
-
return loadInstallDecisions()[serverId];
|
|
3752
|
-
}
|
|
3753
|
-
function recordInstallDecision(serverId, decision, decidedAt = new Date().toISOString()) {
|
|
3754
|
-
const decisions = loadInstallDecisions();
|
|
3755
|
-
decisions[serverId] = { decision, decidedAt };
|
|
3756
|
-
writeInstallDecisions(decisions);
|
|
3757
|
-
}
|
|
3758
|
-
function isInstallDecision(value) {
|
|
3759
|
-
return value === "declined" || value === "allowed";
|
|
3760
|
-
}
|
|
3761
|
-
function writeInstallDecisions(decisions) {
|
|
3762
|
-
const path = getInstallDecisionsPath();
|
|
3763
|
-
mkdirSync(dirname6(path), { recursive: true });
|
|
3764
|
-
const tmpPath = `${path}.tmp`;
|
|
3765
|
-
writeFileSync2(tmpPath, `${JSON.stringify(decisions, null, 2)}
|
|
3766
|
-
`, "utf8");
|
|
3767
|
-
renameSync2(tmpPath, path);
|
|
3768
|
-
}
|
|
3769
|
-
function isInstallDecisions(value) {
|
|
3770
|
-
return isRecord5(value) && Object.values(value).every(isInstallDecisionRecord);
|
|
3771
|
-
}
|
|
3772
|
-
function isInstallDecisionRecord(value) {
|
|
3773
|
-
if (!isRecord5(value))
|
|
3774
|
-
return false;
|
|
3775
|
-
return isInstallDecision(value["decision"]) && typeof value["decidedAt"] === "string";
|
|
3776
|
-
}
|
|
3777
|
-
function isRecord5(value) {
|
|
3778
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3779
|
-
}
|
|
3780
|
-
|
|
3781
3711
|
// ../lsp-core/src/lsp/config-loader.ts
|
|
3782
|
-
import { existsSync as existsSync8, readFileSync as readFileSync4 } from "node:fs";
|
|
3783
3712
|
function getProjectConfigPaths() {
|
|
3784
3713
|
return lspRequestContext().projectConfigPaths;
|
|
3785
3714
|
}
|
|
@@ -3976,154 +3905,53 @@ function getDisabledServerIds() {
|
|
|
3976
3905
|
|
|
3977
3906
|
// ../lsp-core/src/lsp/server-installation.ts
|
|
3978
3907
|
import { existsSync as existsSync9 } from "node:fs";
|
|
3979
|
-
import { delimiter as delimiter3,
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
"requirements.txt",
|
|
3990
|
-
"setup.py",
|
|
3991
|
-
"setup.cfg",
|
|
3992
|
-
"Pipfile",
|
|
3993
|
-
"pyrightconfig.json",
|
|
3994
|
-
"ruff.toml",
|
|
3995
|
-
".ruff.toml"
|
|
3996
|
-
],
|
|
3997
|
-
binDirs: [
|
|
3998
|
-
join4(".venv", "bin"),
|
|
3999
|
-
join4(".venv", "Scripts"),
|
|
4000
|
-
join4("venv", "bin"),
|
|
4001
|
-
join4("venv", "Scripts"),
|
|
4002
|
-
join4(".env", "bin"),
|
|
4003
|
-
join4(".env", "Scripts")
|
|
4004
|
-
]
|
|
4005
|
-
},
|
|
4006
|
-
{
|
|
4007
|
-
markers: ["Gemfile", "Gemfile.lock"],
|
|
4008
|
-
binDirs: [join4("vendor", "bundle", "bin"), "bin"]
|
|
4009
|
-
},
|
|
4010
|
-
{
|
|
4011
|
-
markers: ["go.mod", "go.sum", "go.work"],
|
|
4012
|
-
binDirs: ["bin"]
|
|
4013
|
-
}
|
|
4014
|
-
];
|
|
4015
|
-
var resolutionCache = new Map;
|
|
4016
|
-
var probeCount = 0;
|
|
4017
|
-
function probe(path) {
|
|
4018
|
-
probeCount += 1;
|
|
4019
|
-
return existsSync9(path);
|
|
4020
|
-
}
|
|
4021
|
-
function executableSuffixes(platform, pathExt) {
|
|
4022
|
-
if (platform !== "win32")
|
|
4023
|
-
return [""];
|
|
4024
|
-
const configured = pathExt ?? process.env["PATHEXT"] ?? "";
|
|
4025
|
-
const systemExts = configured.split(";").filter((entry) => entry.length > 0).map((entry) => entry.toLowerCase());
|
|
4026
|
-
return [...new Set(["", ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])];
|
|
4027
|
-
}
|
|
4028
|
-
function probeWithSuffixes(directory, command, suffixes) {
|
|
4029
|
-
for (const suffix of suffixes) {
|
|
4030
|
-
const candidate = join4(directory, command + suffix);
|
|
4031
|
-
if (probe(candidate))
|
|
4032
|
-
return candidate;
|
|
3908
|
+
import { delimiter as delimiter3, join as join4 } from "node:path";
|
|
3909
|
+
function isServerInstalled(command, _workingDirectory) {
|
|
3910
|
+
if (command.length === 0)
|
|
3911
|
+
return false;
|
|
3912
|
+
const [cmd] = command;
|
|
3913
|
+
if (!cmd)
|
|
3914
|
+
return false;
|
|
3915
|
+
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
3916
|
+
if (existsSync9(cmd))
|
|
3917
|
+
return true;
|
|
4033
3918
|
}
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
for (const binDir of rule.binDirs) {
|
|
4044
|
-
const found = probeWithSuffixes(join4(current, binDir), command, suffixes);
|
|
4045
|
-
if (found !== null)
|
|
4046
|
-
return found;
|
|
4047
|
-
}
|
|
3919
|
+
const isWindows = process.platform === "win32";
|
|
3920
|
+
let exts = [""];
|
|
3921
|
+
if (isWindows) {
|
|
3922
|
+
const pathExt = process.env["PATHEXT"] ?? "";
|
|
3923
|
+
if (pathExt) {
|
|
3924
|
+
const systemExts = pathExt.split(";").filter(Boolean);
|
|
3925
|
+
exts = [...new Set([...exts, ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])];
|
|
3926
|
+
} else {
|
|
3927
|
+
exts = ["", ".exe", ".cmd", ".bat", ".ps1"];
|
|
4048
3928
|
}
|
|
4049
|
-
if (probe(join4(current, ".git")))
|
|
4050
|
-
return null;
|
|
4051
|
-
if (boundary !== undefined && current === boundary)
|
|
4052
|
-
return null;
|
|
4053
|
-
const parent = dirname7(current);
|
|
4054
|
-
if (parent === current)
|
|
4055
|
-
return null;
|
|
4056
|
-
current = parent;
|
|
4057
3929
|
}
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
let pathEnv = pathEnvOverride ?? process.env["PATH"] ?? "";
|
|
4061
|
-
if (platform === "win32" && !pathEnv) {
|
|
3930
|
+
let pathEnv = process.env["PATH"] ?? "";
|
|
3931
|
+
if (isWindows && !pathEnv) {
|
|
4062
3932
|
pathEnv = process.env["Path"] ?? "";
|
|
4063
3933
|
}
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
3934
|
+
const paths = pathEnv.split(delimiter3);
|
|
3935
|
+
for (const p of paths) {
|
|
3936
|
+
for (const suffix of exts) {
|
|
3937
|
+
if (existsSync9(join4(p, cmd + suffix))) {
|
|
3938
|
+
return true;
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
4070
3941
|
}
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
if (command.length === 0)
|
|
4075
|
-
return null;
|
|
4076
|
-
const [cmd] = command;
|
|
4077
|
-
if (cmd === undefined || cmd.length === 0)
|
|
4078
|
-
return null;
|
|
4079
|
-
const platform = options.platform ?? process.platform;
|
|
4080
|
-
const suffixes = executableSuffixes(platform, options.pathExt);
|
|
4081
|
-
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
4082
|
-
const explicit = isAbsolute3(cmd) ? cmd : resolve7(workingDirectory ?? process.cwd(), cmd);
|
|
4083
|
-
return probe(explicit) ? explicit : null;
|
|
4084
|
-
}
|
|
4085
|
-
const cacheKey = JSON.stringify([
|
|
4086
|
-
workingDirectory ?? "",
|
|
4087
|
-
cmd,
|
|
4088
|
-
platform,
|
|
4089
|
-
options.stopAt ?? "",
|
|
4090
|
-
options.pathExt ?? "",
|
|
4091
|
-
options.pathEnv ?? process.env["PATH"] ?? ""
|
|
4092
|
-
]);
|
|
4093
|
-
const cached = resolutionCache.get(cacheKey);
|
|
4094
|
-
if (cached !== undefined)
|
|
4095
|
-
return cached;
|
|
4096
|
-
let resolved = null;
|
|
4097
|
-
if (workingDirectory !== undefined && workingDirectory.length > 0) {
|
|
4098
|
-
resolved = resolveLocal(cmd, workingDirectory, suffixes, options.stopAt);
|
|
4099
|
-
}
|
|
4100
|
-
resolved ??= resolveFromPath(cmd, suffixes, platform, options.pathEnv);
|
|
4101
|
-
if (resolved === null && cmd === "node")
|
|
4102
|
-
resolved = cmd;
|
|
4103
|
-
resolutionCache.set(cacheKey, resolved);
|
|
4104
|
-
return resolved;
|
|
4105
|
-
}
|
|
4106
|
-
function isServerInstalled(command, workingDirectory, options = {}) {
|
|
4107
|
-
if (command.length === 0)
|
|
4108
|
-
return false;
|
|
4109
|
-
return resolveServerBinary(command, workingDirectory, options) !== null;
|
|
3942
|
+
if (cmd === "node")
|
|
3943
|
+
return true;
|
|
3944
|
+
return false;
|
|
4110
3945
|
}
|
|
4111
3946
|
|
|
4112
3947
|
// ../lsp-core/src/lsp/server-resolution.ts
|
|
4113
|
-
function withResolvedCommand(command, binaryPath) {
|
|
4114
|
-
return [binaryPath, ...command.slice(1)];
|
|
4115
|
-
}
|
|
4116
3948
|
function findServerForExtension(ext) {
|
|
4117
3949
|
const servers = getMergedServers();
|
|
4118
|
-
const workingDirectory = contextCwd();
|
|
4119
3950
|
for (const server2 of servers) {
|
|
4120
|
-
if (
|
|
4121
|
-
continue;
|
|
4122
|
-
const binaryPath = resolveServerBinary(server2.command, workingDirectory);
|
|
4123
|
-
if (binaryPath !== null) {
|
|
3951
|
+
if (server2.extensions.includes(ext) && isServerInstalled(server2.command)) {
|
|
4124
3952
|
const resolvedServer = {
|
|
4125
3953
|
id: server2.id,
|
|
4126
|
-
command:
|
|
3954
|
+
command: server2.command,
|
|
4127
3955
|
extensions: server2.extensions,
|
|
4128
3956
|
priority: server2.priority
|
|
4129
3957
|
};
|
|
@@ -4170,7 +3998,6 @@ function findServerForExtension(ext) {
|
|
|
4170
3998
|
function getAllServers() {
|
|
4171
3999
|
const servers = getMergedServers();
|
|
4172
4000
|
const disabled = getDisabledServerIds();
|
|
4173
|
-
const workingDirectory = contextCwd();
|
|
4174
4001
|
const result = [];
|
|
4175
4002
|
const seen = new Set;
|
|
4176
4003
|
for (const server2 of servers) {
|
|
@@ -4178,7 +4005,7 @@ function getAllServers() {
|
|
|
4178
4005
|
continue;
|
|
4179
4006
|
result.push({
|
|
4180
4007
|
id: server2.id,
|
|
4181
|
-
installed: isServerInstalled(server2.command
|
|
4008
|
+
installed: isServerInstalled(server2.command),
|
|
4182
4009
|
extensions: server2.extensions,
|
|
4183
4010
|
disabled: false,
|
|
4184
4011
|
source: server2.source,
|
|
@@ -4192,7 +4019,7 @@ function getAllServers() {
|
|
|
4192
4019
|
const builtin = BUILTIN_SERVERS[id];
|
|
4193
4020
|
result.push({
|
|
4194
4021
|
id,
|
|
4195
|
-
installed: builtin ? isServerInstalled(builtin.command
|
|
4022
|
+
installed: builtin ? isServerInstalled(builtin.command) : false,
|
|
4196
4023
|
extensions: builtin?.extensions ?? [],
|
|
4197
4024
|
disabled: true,
|
|
4198
4025
|
source: "disabled",
|
|
@@ -4215,7 +4042,7 @@ function findWorkspaceRoot(filePath) {
|
|
|
4215
4042
|
const abs = resolveReadablePathInsideContext(filePath);
|
|
4216
4043
|
let dir = abs;
|
|
4217
4044
|
if (!isDirectoryPath(dir)) {
|
|
4218
|
-
dir =
|
|
4045
|
+
dir = dirname7(dir);
|
|
4219
4046
|
}
|
|
4220
4047
|
if (!isPathInside(cwd, abs))
|
|
4221
4048
|
return findWorkspaceRootOutsideContext(dir);
|
|
@@ -4231,13 +4058,13 @@ function findWorkspaceRoot(filePath) {
|
|
|
4231
4058
|
}
|
|
4232
4059
|
if (dir === cwd)
|
|
4233
4060
|
break;
|
|
4234
|
-
dir =
|
|
4061
|
+
dir = dirname7(dir);
|
|
4235
4062
|
}
|
|
4236
4063
|
return fallbackRoot;
|
|
4237
4064
|
}
|
|
4238
4065
|
function resolveReadablePathInsideContext(filePath) {
|
|
4239
4066
|
const cwd = contextCwd();
|
|
4240
|
-
const abs =
|
|
4067
|
+
const abs = resolve7(cwd, filePath);
|
|
4241
4068
|
if (isPathInside(cwd, abs))
|
|
4242
4069
|
return abs;
|
|
4243
4070
|
const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
|
|
@@ -4263,7 +4090,7 @@ function rebaseThroughCanonicalAncestor(path, cwd) {
|
|
|
4263
4090
|
if (isPathInside(cwd, canonical))
|
|
4264
4091
|
return suffix.length === 0 ? canonical : join5(canonical, ...suffix);
|
|
4265
4092
|
}
|
|
4266
|
-
const parent =
|
|
4093
|
+
const parent = dirname7(current);
|
|
4267
4094
|
if (parent === current)
|
|
4268
4095
|
return;
|
|
4269
4096
|
suffix.unshift(basename3(current));
|
|
@@ -4286,7 +4113,7 @@ function nearestExistingDirectoryInsideContext(directory, cwd) {
|
|
|
4286
4113
|
return canonical;
|
|
4287
4114
|
if (current === cwd)
|
|
4288
4115
|
return;
|
|
4289
|
-
current =
|
|
4116
|
+
current = dirname7(current);
|
|
4290
4117
|
}
|
|
4291
4118
|
return;
|
|
4292
4119
|
}
|
|
@@ -4313,19 +4140,6 @@ function formatServerLookupError(result) {
|
|
|
4313
4140
|
].join(`
|
|
4314
4141
|
`);
|
|
4315
4142
|
}
|
|
4316
|
-
function formatInstallOptions(serverId, installHint) {
|
|
4317
|
-
const localHint = LSP_LOCAL_INSTALL_HINTS[serverId];
|
|
4318
|
-
if (localHint === undefined) {
|
|
4319
|
-
return ["To install, run:", ` ${installHint}`];
|
|
4320
|
-
}
|
|
4321
|
-
return [
|
|
4322
|
-
"To install in THIS repository (preferred — no global install needed):",
|
|
4323
|
-
` ${localHint}`,
|
|
4324
|
-
"",
|
|
4325
|
-
"Or install it globally:",
|
|
4326
|
-
` ${installHint}`
|
|
4327
|
-
];
|
|
4328
|
-
}
|
|
4329
4143
|
function formatNotInstalled(result) {
|
|
4330
4144
|
const { server: server2, installHint } = result;
|
|
4331
4145
|
const extensions = server2.extensions.join(", ");
|
|
@@ -4340,19 +4154,19 @@ function formatNotInstalled(result) {
|
|
|
4340
4154
|
`Command not found: ${server2.command[0]}`,
|
|
4341
4155
|
""
|
|
4342
4156
|
];
|
|
4343
|
-
const installOptions = formatInstallOptions(server2.id, installHint);
|
|
4344
4157
|
if (decision === "allowed") {
|
|
4345
4158
|
return [
|
|
4346
4159
|
...header,
|
|
4347
4160
|
"The user has pre-authorized LSP installation. Run the install command, then retry this tool:",
|
|
4348
|
-
|
|
4161
|
+
` ${installHint}`
|
|
4349
4162
|
].join(`
|
|
4350
4163
|
`);
|
|
4351
4164
|
}
|
|
4352
4165
|
if (!context.capabilities.installDecisionTool) {
|
|
4353
4166
|
return [
|
|
4354
4167
|
...header,
|
|
4355
|
-
|
|
4168
|
+
"To install, run:",
|
|
4169
|
+
` ${installHint}`,
|
|
4356
4170
|
"",
|
|
4357
4171
|
"ACTION REQUIRED — ASK THE USER whether to install this LSP server.",
|
|
4358
4172
|
"Install-decision recording is unavailable in this harness; proceed without LSP if the user declines."
|
|
@@ -4361,7 +4175,8 @@ function formatNotInstalled(result) {
|
|
|
4361
4175
|
}
|
|
4362
4176
|
return [
|
|
4363
4177
|
...header,
|
|
4364
|
-
|
|
4178
|
+
"To install, run:",
|
|
4179
|
+
` ${installHint}`,
|
|
4365
4180
|
"",
|
|
4366
4181
|
"ACTION REQUIRED — ASK THE USER whether to install this LSP server.",
|
|
4367
4182
|
"- If the user agrees: run the install command above, then retry this tool.",
|
|
@@ -4417,7 +4232,7 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
|
4417
4232
|
|
|
4418
4233
|
// ../lsp-core/src/lsp/directory-diagnostics.ts
|
|
4419
4234
|
import { existsSync as existsSync11, lstatSync as lstatSync4, readdirSync as readdirSync3 } from "node:fs";
|
|
4420
|
-
import { join as join6, resolve as
|
|
4235
|
+
import { join as join6, resolve as resolve8 } from "node:path";
|
|
4421
4236
|
|
|
4422
4237
|
// ../lsp-core/src/lsp/formatters.ts
|
|
4423
4238
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -4572,7 +4387,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
4572
4387
|
if (!extension.startsWith(".")) {
|
|
4573
4388
|
throw new LspInvalidPathError(`Extension must start with a dot (e.g., ".ts", not "${extension}"). Use ".${extension}" instead.`);
|
|
4574
4389
|
}
|
|
4575
|
-
const absDir =
|
|
4390
|
+
const absDir = resolve8(options.workspaceRoot ?? contextCwd(), directory);
|
|
4576
4391
|
if (!existsSync11(absDir)) {
|
|
4577
4392
|
throw new LspInvalidPathError(`Directory does not exist: ${absDir}`);
|
|
4578
4393
|
}
|
|
@@ -4929,96 +4744,6 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
4929
4744
|
throw error;
|
|
4930
4745
|
}
|
|
4931
4746
|
}
|
|
4932
|
-
// ../lsp-core/src/lsp/format-document.ts
|
|
4933
|
-
import { readFileSync as readFileSync5, renameSync as renameSync3, unlinkSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
4934
|
-
var DEFAULT_FORMATTING_OPTIONS = {
|
|
4935
|
-
tabSize: 4,
|
|
4936
|
-
insertSpaces: false,
|
|
4937
|
-
trimTrailingWhitespace: true,
|
|
4938
|
-
insertFinalNewline: true,
|
|
4939
|
-
trimFinalNewlines: true
|
|
4940
|
-
};
|
|
4941
|
-
var UNCHANGED = { status: "unchanged", linesAdded: 0, linesRemoved: 0 };
|
|
4942
|
-
async function formatDocumentWithClient(client, filePath, options = {}) {
|
|
4943
|
-
const edits = await client.formatDocument(filePath, options.formattingOptions ?? DEFAULT_FORMATTING_OPTIONS, options.signal);
|
|
4944
|
-
if (edits === null)
|
|
4945
|
-
return { status: "unavailable", reason: "capability_not_advertised" };
|
|
4946
|
-
if (edits.length === 0)
|
|
4947
|
-
return UNCHANGED;
|
|
4948
|
-
const before = readFileSync5(filePath, "utf-8");
|
|
4949
|
-
const normalized = normalizeTextEdits(before, edits, 0);
|
|
4950
|
-
if (normalized.text === before)
|
|
4951
|
-
return UNCHANGED;
|
|
4952
|
-
writeAtomically(filePath, normalized.text);
|
|
4953
|
-
await client.openFile(filePath);
|
|
4954
|
-
return {
|
|
4955
|
-
status: "formatted",
|
|
4956
|
-
...lineDelta(normalized.edits)
|
|
4957
|
-
};
|
|
4958
|
-
}
|
|
4959
|
-
function lineDelta(edits) {
|
|
4960
|
-
let linesAdded = 0;
|
|
4961
|
-
let linesRemoved = 0;
|
|
4962
|
-
for (const edit of edits) {
|
|
4963
|
-
linesRemoved += edit.range.end.line - edit.range.start.line + 1;
|
|
4964
|
-
linesAdded += edit.newText.split(`
|
|
4965
|
-
`).length;
|
|
4966
|
-
}
|
|
4967
|
-
return { linesAdded, linesRemoved };
|
|
4968
|
-
}
|
|
4969
|
-
function writeAtomically(filePath, content) {
|
|
4970
|
-
const tempPath = `${filePath}.omo-format.tmp`;
|
|
4971
|
-
writeFileSync3(tempPath, content, "utf-8");
|
|
4972
|
-
try {
|
|
4973
|
-
renameSync3(tempPath, filePath);
|
|
4974
|
-
} catch (error) {
|
|
4975
|
-
try {
|
|
4976
|
-
unlinkSync(tempPath);
|
|
4977
|
-
} catch {}
|
|
4978
|
-
throw error;
|
|
4979
|
-
}
|
|
4980
|
-
}
|
|
4981
|
-
|
|
4982
|
-
// ../lsp-core/src/tools/format.ts
|
|
4983
|
-
async function executeLspFormat(params, signal) {
|
|
4984
|
-
const filePath = requireString(params, "filePath");
|
|
4985
|
-
try {
|
|
4986
|
-
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => formatDocumentWithClient(client, resolvedFilePath, signal === undefined ? {} : { signal }), "format", clientOptions(signal));
|
|
4987
|
-
return text(describeResult(filePath, result), formatDetails(filePath, result));
|
|
4988
|
-
} catch (error) {
|
|
4989
|
-
const missingDependency = missingDependencyResult(error, {
|
|
4990
|
-
filePath,
|
|
4991
|
-
status: "unavailable",
|
|
4992
|
-
reason: "server_unavailable",
|
|
4993
|
-
linesAdded: 0,
|
|
4994
|
-
linesRemoved: 0
|
|
4995
|
-
});
|
|
4996
|
-
if (missingDependency)
|
|
4997
|
-
return missingDependency;
|
|
4998
|
-
throw error;
|
|
4999
|
-
}
|
|
5000
|
-
}
|
|
5001
|
-
function formatDetails(filePath, result) {
|
|
5002
|
-
if (result.status === "unavailable") {
|
|
5003
|
-
return { filePath, status: "unavailable", reason: result.reason, linesAdded: 0, linesRemoved: 0 };
|
|
5004
|
-
}
|
|
5005
|
-
return {
|
|
5006
|
-
filePath,
|
|
5007
|
-
status: result.status,
|
|
5008
|
-
linesAdded: result.linesAdded,
|
|
5009
|
-
linesRemoved: result.linesRemoved
|
|
5010
|
-
};
|
|
5011
|
-
}
|
|
5012
|
-
function describeResult(filePath, result) {
|
|
5013
|
-
if (result.status === "unavailable") {
|
|
5014
|
-
return `Formatting unavailable for ${filePath}: the language server does not advertise documentFormattingProvider.`;
|
|
5015
|
-
}
|
|
5016
|
-
if (result.status === "unchanged") {
|
|
5017
|
-
return `Already formatted: ${filePath}`;
|
|
5018
|
-
}
|
|
5019
|
-
return `Formatted ${filePath} (+${result.linesAdded}/-${result.linesRemoved} lines)`;
|
|
5020
|
-
}
|
|
5021
|
-
|
|
5022
4747
|
// ../lsp-core/src/tools/install-decision.ts
|
|
5023
4748
|
async function executeLspInstallDecision(params) {
|
|
5024
4749
|
const serverId = requireString(params, "server_id");
|
|
@@ -5351,16 +5076,6 @@ var LSP_MCP_TOOLS = [
|
|
|
5351
5076
|
}, ["filePath", "line", "character", "newName"]),
|
|
5352
5077
|
execute: executeLspRename
|
|
5353
5078
|
},
|
|
5354
|
-
{
|
|
5355
|
-
name: "format",
|
|
5356
|
-
aliases: ["lsp_format"],
|
|
5357
|
-
title: "LSP Format",
|
|
5358
|
-
description: "Format a source file with its language server and write the returned edits to disk.",
|
|
5359
|
-
inputSchema: objectSchema({
|
|
5360
|
-
filePath: { type: "string", description: "Source file path to format." }
|
|
5361
|
-
}, ["filePath"]),
|
|
5362
|
-
execute: executeLspFormat
|
|
5363
|
-
},
|
|
5364
5079
|
{
|
|
5365
5080
|
name: "install_decision",
|
|
5366
5081
|
aliases: ["lsp_install_decision"],
|
|
@@ -5539,7 +5254,7 @@ function errorText(error) {
|
|
|
5539
5254
|
import { spawn as spawn2 } from "node:child_process";
|
|
5540
5255
|
import { closeSync as closeSync2, existsSync as existsSync12, mkdirSync as mkdirSync3, openSync as openSync2, writeSync as writeSync2 } from "node:fs";
|
|
5541
5256
|
import { Socket } from "node:net";
|
|
5542
|
-
import { dirname as
|
|
5257
|
+
import { dirname as dirname9, isAbsolute as isAbsolute4 } from "node:path";
|
|
5543
5258
|
import { argv0, execPath } from "node:process";
|
|
5544
5259
|
|
|
5545
5260
|
// src/ipc-protocol.ts
|
|
@@ -5553,11 +5268,11 @@ import {
|
|
|
5553
5268
|
lstatSync as lstatSync6,
|
|
5554
5269
|
mkdirSync as mkdirSync2,
|
|
5555
5270
|
openSync,
|
|
5556
|
-
readFileSync as
|
|
5557
|
-
unlinkSync
|
|
5271
|
+
readFileSync as readFileSync5,
|
|
5272
|
+
unlinkSync,
|
|
5558
5273
|
writeSync
|
|
5559
5274
|
} from "node:fs";
|
|
5560
|
-
import { dirname as
|
|
5275
|
+
import { dirname as dirname8 } from "node:path";
|
|
5561
5276
|
var OMO_DAEMON_PROTOCOL_VERSION = 1;
|
|
5562
5277
|
var AUTH_ERROR_CODE = -32001;
|
|
5563
5278
|
var PROTOCOL_ERROR_CODE = -32002;
|
|
@@ -5577,7 +5292,7 @@ function authEnvelope(token) {
|
|
|
5577
5292
|
}
|
|
5578
5293
|
function readAuthToken(paths) {
|
|
5579
5294
|
try {
|
|
5580
|
-
const token =
|
|
5295
|
+
const token = readFileSync5(paths.auth, "utf8").trim();
|
|
5581
5296
|
return token.length > 0 ? token : null;
|
|
5582
5297
|
} catch (error) {
|
|
5583
5298
|
if (error instanceof Error)
|
|
@@ -5593,7 +5308,7 @@ function readOrCreateAuthToken(paths) {
|
|
|
5593
5308
|
}
|
|
5594
5309
|
function rotateAuthToken(paths) {
|
|
5595
5310
|
try {
|
|
5596
|
-
|
|
5311
|
+
unlinkSync(paths.auth);
|
|
5597
5312
|
} catch (error) {
|
|
5598
5313
|
if (!(error instanceof Error))
|
|
5599
5314
|
throw error;
|
|
@@ -5665,7 +5380,7 @@ function setPrivateFileMode(path) {
|
|
|
5665
5380
|
chmodSync(path, 384);
|
|
5666
5381
|
}
|
|
5667
5382
|
function createAuthToken(paths) {
|
|
5668
|
-
ensurePrivateDirectory(
|
|
5383
|
+
ensurePrivateDirectory(dirname8(paths.auth));
|
|
5669
5384
|
const token = randomBytes(AUTH_TOKEN_BYTES).toString("base64url");
|
|
5670
5385
|
let fd;
|
|
5671
5386
|
try {
|
|
@@ -5746,7 +5461,7 @@ import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
|
5746
5461
|
|
|
5747
5462
|
// src/runtime-contract.ts
|
|
5748
5463
|
import { statSync as statSync4 } from "node:fs";
|
|
5749
|
-
import { isAbsolute as
|
|
5464
|
+
import { isAbsolute as isAbsolute3 } from "node:path";
|
|
5750
5465
|
var OMO_LSP_DAEMON_DIR = "OMO_LSP_DAEMON_DIR";
|
|
5751
5466
|
var OMO_LSP_DAEMON_CLI = "OMO_LSP_DAEMON_CLI";
|
|
5752
5467
|
var OMO_LSP_DAEMON_VERSION = "OMO_LSP_DAEMON_VERSION";
|
|
@@ -5783,12 +5498,12 @@ function resolveDaemonRuntime(env, defaults) {
|
|
|
5783
5498
|
throw new InvalidRuntimeOverrideError("paired_values_required", `${OMO_LSP_DAEMON_CLI} and ${OMO_LSP_DAEMON_VERSION} must be set together`);
|
|
5784
5499
|
}
|
|
5785
5500
|
if (!hasCliOverride || !hasVersionOverride) {
|
|
5786
|
-
if (!
|
|
5501
|
+
if (!isAbsolute3(defaults.cliPath)) {
|
|
5787
5502
|
throw new InvalidRuntimeOverrideError("packaged_cli_must_be_absolute", "Packaged LSP daemon CLI path must be absolute");
|
|
5788
5503
|
}
|
|
5789
5504
|
return { cliPath: defaults.cliPath, version: validateDaemonVersion(defaults.version) };
|
|
5790
5505
|
}
|
|
5791
|
-
if (!
|
|
5506
|
+
if (!isAbsolute3(cliOverride)) {
|
|
5792
5507
|
throw new InvalidRuntimeOverrideError("cli_must_be_absolute", `${OMO_LSP_DAEMON_CLI} must be an absolute path to an existing regular file`);
|
|
5793
5508
|
}
|
|
5794
5509
|
let cliStats;
|
|
@@ -5966,7 +5681,7 @@ async function probeDaemon(paths, timeoutMs = PROBE_TIMEOUT_MS, signal) {
|
|
|
5966
5681
|
return await pingDaemon(paths, token, timeoutMs, signal) !== null;
|
|
5967
5682
|
}
|
|
5968
5683
|
function pingDaemon(paths, token, timeoutMs = PROBE_TIMEOUT_MS, signal) {
|
|
5969
|
-
return new Promise((
|
|
5684
|
+
return new Promise((resolve9) => {
|
|
5970
5685
|
const socket = new Socket;
|
|
5971
5686
|
let settled = false;
|
|
5972
5687
|
let timer;
|
|
@@ -5978,7 +5693,7 @@ function pingDaemon(paths, token, timeoutMs = PROBE_TIMEOUT_MS, signal) {
|
|
|
5978
5693
|
clearTimeout(timer);
|
|
5979
5694
|
signal?.removeEventListener("abort", onAbort);
|
|
5980
5695
|
socket.destroy();
|
|
5981
|
-
|
|
5696
|
+
resolve9(value);
|
|
5982
5697
|
};
|
|
5983
5698
|
const onAbort = () => finish(null);
|
|
5984
5699
|
const decoder = createLineDecoder((message) => {
|
|
@@ -6002,7 +5717,7 @@ function pingDaemon(paths, token, timeoutMs = PROBE_TIMEOUT_MS, signal) {
|
|
|
6002
5717
|
});
|
|
6003
5718
|
}
|
|
6004
5719
|
function spawnDaemonProcess(paths) {
|
|
6005
|
-
mkdirSync3(
|
|
5720
|
+
mkdirSync3(dirname9(paths.log), { recursive: true });
|
|
6006
5721
|
const logFd = openSync2(paths.log, "a");
|
|
6007
5722
|
try {
|
|
6008
5723
|
const child = spawn2(resolveDaemonNodeExecutable(), [paths.cliPath, "daemon"], {
|
|
@@ -6025,7 +5740,7 @@ function spawnDaemonProcess(paths) {
|
|
|
6025
5740
|
function resolveDaemonNodeExecutable(cachedExecPath = execPath, originalArgv0 = argv0, pathExists = existsSync12) {
|
|
6026
5741
|
if (pathExists(cachedExecPath))
|
|
6027
5742
|
return cachedExecPath;
|
|
6028
|
-
if (
|
|
5743
|
+
if (isAbsolute4(originalArgv0) && pathExists(originalArgv0))
|
|
6029
5744
|
return originalArgv0;
|
|
6030
5745
|
return "node";
|
|
6031
5746
|
}
|
|
@@ -6038,7 +5753,7 @@ function defaultEnsureDaemonDeps() {
|
|
|
6038
5753
|
};
|
|
6039
5754
|
}
|
|
6040
5755
|
function sleepWithSignal(ms, signal) {
|
|
6041
|
-
return new Promise((
|
|
5756
|
+
return new Promise((resolve9) => {
|
|
6042
5757
|
let settled = false;
|
|
6043
5758
|
const finish = () => {
|
|
6044
5759
|
if (settled)
|
|
@@ -6046,7 +5761,7 @@ function sleepWithSignal(ms, signal) {
|
|
|
6046
5761
|
settled = true;
|
|
6047
5762
|
clearTimeout(timer);
|
|
6048
5763
|
signal?.removeEventListener("abort", finish);
|
|
6049
|
-
|
|
5764
|
+
resolve9();
|
|
6050
5765
|
};
|
|
6051
5766
|
const timer = setTimeout(finish, ms);
|
|
6052
5767
|
if (signal?.aborted) {
|
|
@@ -6061,7 +5776,7 @@ function awaitWithSignal2(promise, signal) {
|
|
|
6061
5776
|
return promise;
|
|
6062
5777
|
if (signal.aborted)
|
|
6063
5778
|
return Promise.reject(abortError3(signal));
|
|
6064
|
-
return new Promise((
|
|
5779
|
+
return new Promise((resolve9, reject) => {
|
|
6065
5780
|
let settled = false;
|
|
6066
5781
|
const finish = (run) => {
|
|
6067
5782
|
if (settled)
|
|
@@ -6072,7 +5787,7 @@ function awaitWithSignal2(promise, signal) {
|
|
|
6072
5787
|
};
|
|
6073
5788
|
const onAbort = () => finish(() => reject(abortError3(signal)));
|
|
6074
5789
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
6075
|
-
promise.then((value) => finish(() =>
|
|
5790
|
+
promise.then((value) => finish(() => resolve9(value)), (error) => finish(() => reject(error)));
|
|
6076
5791
|
});
|
|
6077
5792
|
}
|
|
6078
5793
|
function throwIfAborted(signal) {
|
|
@@ -6240,9 +5955,6 @@ async function callToolViaDaemon(name, args, options) {
|
|
|
6240
5955
|
function callDiagnosticsViaDaemon(filePath, options) {
|
|
6241
5956
|
return callToolViaDaemon("diagnostics", { filePath, severity: "error" }, options);
|
|
6242
5957
|
}
|
|
6243
|
-
function callFormatViaDaemon(filePath, options) {
|
|
6244
|
-
return callToolViaDaemon("format", { filePath }, options);
|
|
6245
|
-
}
|
|
6246
5958
|
function currentRequestContext(env = process.env) {
|
|
6247
5959
|
const cwd = process.cwd();
|
|
6248
5960
|
const home = env["HOME"] ?? homedir3();
|
|
@@ -6265,7 +5977,7 @@ function withContext(args, context) {
|
|
|
6265
5977
|
function ensureDaemonAvailable(paths, ensure, signal) {
|
|
6266
5978
|
if (!signal)
|
|
6267
5979
|
return ensure(paths);
|
|
6268
|
-
return new Promise((
|
|
5980
|
+
return new Promise((resolve9, reject) => {
|
|
6269
5981
|
let settled = false;
|
|
6270
5982
|
const finish = (run) => {
|
|
6271
5983
|
if (settled)
|
|
@@ -6280,11 +5992,11 @@ function ensureDaemonAvailable(paths, ensure, signal) {
|
|
|
6280
5992
|
return;
|
|
6281
5993
|
}
|
|
6282
5994
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
6283
|
-
Promise.resolve().then(() => ensure(paths, signal)).then(() => finish(() =>
|
|
5995
|
+
Promise.resolve().then(() => ensure(paths, signal)).then(() => finish(() => resolve9()), (error) => finish(() => reject(signal.aborted ? new DaemonRequestCancelledError(false) : error)));
|
|
6284
5996
|
});
|
|
6285
5997
|
}
|
|
6286
5998
|
function sendToolCall(paths, token, name, args, options) {
|
|
6287
|
-
return new Promise((
|
|
5999
|
+
return new Promise((resolve9, reject) => {
|
|
6288
6000
|
const socket = connect(paths.socket);
|
|
6289
6001
|
const requestId = allocateProxyRequestId();
|
|
6290
6002
|
let settled = false;
|
|
@@ -6337,7 +6049,7 @@ function sendToolCall(paths, token, name, args, options) {
|
|
|
6337
6049
|
}
|
|
6338
6050
|
const result = toToolResult(message, requestId);
|
|
6339
6051
|
if (result)
|
|
6340
|
-
finish(() =>
|
|
6052
|
+
finish(() => resolve9(result));
|
|
6341
6053
|
else
|
|
6342
6054
|
finish(() => reject(new DaemonRequestError("invalid daemon response", requestWritten)));
|
|
6343
6055
|
});
|
|
@@ -6505,18 +6217,18 @@ function canonicalizePathList(value) {
|
|
|
6505
6217
|
return value.split(delimiter4).map((entry) => canonicalizePath(entry) ?? entry).join(delimiter4);
|
|
6506
6218
|
}
|
|
6507
6219
|
function canonicalizePath(value) {
|
|
6508
|
-
if (value === undefined || !
|
|
6220
|
+
if (value === undefined || !isAbsolute5(value) || !existsSync13(value))
|
|
6509
6221
|
return value;
|
|
6510
6222
|
return realpathSync6(value);
|
|
6511
6223
|
}
|
|
6512
6224
|
function projectRootFromOpenCodeConfigPath(path2) {
|
|
6513
6225
|
if (basename4(path2) !== "lsp.json" && basename4(path2) !== "lsp-client.json")
|
|
6514
6226
|
return;
|
|
6515
|
-
const configDir =
|
|
6227
|
+
const configDir = dirname10(path2);
|
|
6516
6228
|
const configDirName = basename4(configDir);
|
|
6517
6229
|
if (configDirName !== ".opencode" && configDirName !== ".omo")
|
|
6518
6230
|
return;
|
|
6519
|
-
return
|
|
6231
|
+
return dirname10(configDir);
|
|
6520
6232
|
}
|
|
6521
6233
|
|
|
6522
6234
|
// src/daemon-server.ts
|
|
@@ -6525,12 +6237,12 @@ import { createServer as createServer2 } from "node:net";
|
|
|
6525
6237
|
|
|
6526
6238
|
// src/ownership.ts
|
|
6527
6239
|
import { randomUUID } from "node:crypto";
|
|
6528
|
-
import { existsSync as existsSync14, lstatSync as lstatSync7, readFileSync as
|
|
6529
|
-
import { dirname as
|
|
6240
|
+
import { existsSync as existsSync14, lstatSync as lstatSync7, readFileSync as readFileSync7, statSync as statSync5, unlinkSync as unlinkSync3 } from "node:fs";
|
|
6241
|
+
import { dirname as dirname12 } from "node:path";
|
|
6530
6242
|
|
|
6531
6243
|
// src/lock.ts
|
|
6532
|
-
import { closeSync as closeSync3, mkdirSync as mkdirSync4, openSync as openSync3, readFileSync as
|
|
6533
|
-
import { dirname as
|
|
6244
|
+
import { closeSync as closeSync3, mkdirSync as mkdirSync4, openSync as openSync3, readFileSync as readFileSync6, unlinkSync as unlinkSync2, writeSync as writeSync3 } from "node:fs";
|
|
6245
|
+
import { dirname as dirname11 } from "node:path";
|
|
6534
6246
|
function isProcessAlive2(pid) {
|
|
6535
6247
|
if (!Number.isInteger(pid) || pid <= 0)
|
|
6536
6248
|
return false;
|
|
@@ -6545,14 +6257,14 @@ function isProcessAlive2(pid) {
|
|
|
6545
6257
|
}
|
|
6546
6258
|
function readLockPid(lockPath) {
|
|
6547
6259
|
try {
|
|
6548
|
-
const pid = Number.parseInt(
|
|
6260
|
+
const pid = Number.parseInt(readFileSync6(lockPath, "utf8").trim(), 10);
|
|
6549
6261
|
return Number.isInteger(pid) ? pid : null;
|
|
6550
6262
|
} catch {
|
|
6551
6263
|
return null;
|
|
6552
6264
|
}
|
|
6553
6265
|
}
|
|
6554
6266
|
function tryAcquireLock(lockPath, ownerPid = process.pid) {
|
|
6555
|
-
mkdirSync4(
|
|
6267
|
+
mkdirSync4(dirname11(lockPath), { recursive: true });
|
|
6556
6268
|
for (let attempt = 0;attempt < 2; attempt += 1) {
|
|
6557
6269
|
const handle = writeLockFile(lockPath, ownerPid);
|
|
6558
6270
|
if (handle)
|
|
@@ -6584,7 +6296,7 @@ function reapStaleLock(lockPath) {
|
|
|
6584
6296
|
}
|
|
6585
6297
|
function unlinkQuietly(path2) {
|
|
6586
6298
|
try {
|
|
6587
|
-
|
|
6299
|
+
unlinkSync2(path2);
|
|
6588
6300
|
} catch (error) {
|
|
6589
6301
|
if (error instanceof Error)
|
|
6590
6302
|
return;
|
|
@@ -6635,11 +6347,11 @@ async function acquireStartupLease(paths, pingOwner) {
|
|
|
6635
6347
|
function ensureDaemonDirectories(paths) {
|
|
6636
6348
|
ensurePrivateDirectory(paths.dir);
|
|
6637
6349
|
if (process.platform !== "win32")
|
|
6638
|
-
ensurePrivateDirectory(
|
|
6350
|
+
ensurePrivateDirectory(dirname12(paths.socket));
|
|
6639
6351
|
}
|
|
6640
6352
|
function readDaemonOwner(paths) {
|
|
6641
6353
|
try {
|
|
6642
|
-
return parseOwner(JSON.parse(
|
|
6354
|
+
return parseOwner(JSON.parse(readFileSync7(paths.owner, "utf8")));
|
|
6643
6355
|
} catch (error) {
|
|
6644
6356
|
if (error instanceof Error)
|
|
6645
6357
|
return null;
|
|
@@ -6718,7 +6430,7 @@ function cleanupDeadOwner(paths, owner) {
|
|
|
6718
6430
|
if (process.platform !== "win32" && existsSync14(owner.endpoint.path)) {
|
|
6719
6431
|
const stat = lstatSync7(owner.endpoint.path);
|
|
6720
6432
|
if (stat.isSocket())
|
|
6721
|
-
|
|
6433
|
+
unlinkSync3(owner.endpoint.path);
|
|
6722
6434
|
}
|
|
6723
6435
|
unlinkQuietly(paths.pid);
|
|
6724
6436
|
unlinkQuietly(paths.endpoint);
|
|
@@ -6766,7 +6478,7 @@ function parseEndpoint(value) {
|
|
|
6766
6478
|
// src/version-reap.ts
|
|
6767
6479
|
import { execFile } from "node:child_process";
|
|
6768
6480
|
import { readdir, readFile, rm } from "node:fs/promises";
|
|
6769
|
-
import { basename as basename5, dirname as
|
|
6481
|
+
import { basename as basename5, dirname as dirname13, join as join9 } from "node:path";
|
|
6770
6482
|
var TERM_GRACE_MS = 5000;
|
|
6771
6483
|
var KILL_GRACE_MS = 1000;
|
|
6772
6484
|
var VERSION_ENTRY_PATTERN = /^v([A-Za-z0-9][A-Za-z0-9._+-]{0,127})$/;
|
|
@@ -6787,7 +6499,7 @@ async function attestDaemonCliProcess(pid, platform, deps = {}) {
|
|
|
6787
6499
|
return isNodeCliDaemonCommand(command.trim());
|
|
6788
6500
|
}
|
|
6789
6501
|
async function reapStaleDaemonVersions(ownPaths, deps = {}) {
|
|
6790
|
-
const baseDir =
|
|
6502
|
+
const baseDir = dirname13(ownPaths.dir);
|
|
6791
6503
|
const platform = deps.platform ?? process.platform;
|
|
6792
6504
|
const isAlive = deps.isAlive ?? isProcessAlive2;
|
|
6793
6505
|
const attest = deps.attest ?? ((pid) => attestDaemonCliProcess(pid, platform));
|
|
@@ -6908,13 +6620,13 @@ function defaultReadProcFile(path2) {
|
|
|
6908
6620
|
return readFile(path2);
|
|
6909
6621
|
}
|
|
6910
6622
|
function defaultExecuteForStdout(file, args) {
|
|
6911
|
-
return new Promise((
|
|
6623
|
+
return new Promise((resolve9) => {
|
|
6912
6624
|
execFile(file, [...args], { encoding: "utf8", maxBuffer: 1024 * 1024, timeout: 1000, windowsHide: true }, (error, stdout) => {
|
|
6913
6625
|
if (error !== null) {
|
|
6914
|
-
|
|
6626
|
+
resolve9(null);
|
|
6915
6627
|
return;
|
|
6916
6628
|
}
|
|
6917
|
-
|
|
6629
|
+
resolve9(stdout);
|
|
6918
6630
|
});
|
|
6919
6631
|
});
|
|
6920
6632
|
}
|
|
@@ -6933,7 +6645,7 @@ async function defaultWaitForExit(pid, timeoutMs) {
|
|
|
6933
6645
|
return true;
|
|
6934
6646
|
if (Date.now() >= deadline)
|
|
6935
6647
|
return false;
|
|
6936
|
-
await new Promise((
|
|
6648
|
+
await new Promise((resolve9) => setTimeout(resolve9, 100));
|
|
6937
6649
|
}
|
|
6938
6650
|
}
|
|
6939
6651
|
function defaultLog(message) {
|
|
@@ -7040,17 +6752,17 @@ async function assertSelfProbe(paths, token, owner) {
|
|
|
7040
6752
|
throw new DaemonStartupDeferredError("self_probe_failed");
|
|
7041
6753
|
}
|
|
7042
6754
|
function listen(server2, socketPath) {
|
|
7043
|
-
return new Promise((
|
|
6755
|
+
return new Promise((resolve9, reject) => {
|
|
7044
6756
|
const onError = (error) => reject(error);
|
|
7045
6757
|
server2.once("error", onError);
|
|
7046
6758
|
server2.listen(socketPath, () => {
|
|
7047
6759
|
server2.removeListener("error", onError);
|
|
7048
|
-
|
|
6760
|
+
resolve9();
|
|
7049
6761
|
});
|
|
7050
6762
|
});
|
|
7051
6763
|
}
|
|
7052
6764
|
function closeServer(server2) {
|
|
7053
|
-
return new Promise((
|
|
6765
|
+
return new Promise((resolve9) => server2.close(() => resolve9()));
|
|
7054
6766
|
}
|
|
7055
6767
|
function installSignalHandlers(close) {
|
|
7056
6768
|
const handler = () => {
|