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
|
@@ -8,13 +8,11 @@ import { argv, execPath as execPath2, stderr } from "node:process";
|
|
|
8
8
|
import { stdin as processStdin } from "node:process";
|
|
9
9
|
|
|
10
10
|
// src/codex-hook.ts
|
|
11
|
-
import { readFileSync as
|
|
11
|
+
import { readFileSync as readFileSync9, realpathSync as realpathSync8 } from "node:fs";
|
|
12
12
|
import { homedir as homedir3 } from "node:os";
|
|
13
|
-
import { join as join12, resolve as
|
|
13
|
+
import { join as join12, resolve as resolve11 } from "node:path";
|
|
14
14
|
|
|
15
15
|
// ../../../../lsp-daemon/dist/client.js
|
|
16
|
-
import { statSync as statSync5 } from "node:fs";
|
|
17
|
-
import { isAbsolute as isAbsolute6 } from "node:path";
|
|
18
16
|
import { connect } from "node:net";
|
|
19
17
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
20
18
|
import { existsSync, realpathSync, statSync } from "node:fs";
|
|
@@ -45,7 +43,7 @@ import { fileURLToPath } from "node:url";
|
|
|
45
43
|
import { statSync as statSync2 } from "node:fs";
|
|
46
44
|
import { isAbsolute as isAbsolute2 } from "node:path";
|
|
47
45
|
import { existsSync as existsSync11, realpathSync as realpathSync5, statSync as statSync4 } from "node:fs";
|
|
48
|
-
import { basename as basename3, dirname as
|
|
46
|
+
import { basename as basename3, dirname as dirname9, join as join5, resolve as resolve7 } from "node:path";
|
|
49
47
|
import { basename as basename2, extname } from "node:path";
|
|
50
48
|
import { resolve as resolve6 } from "node:path";
|
|
51
49
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
@@ -70,13 +68,14 @@ import { existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as rea
|
|
|
70
68
|
import { dirname as dirname8 } from "node:path";
|
|
71
69
|
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
|
|
72
70
|
import { existsSync as existsSync10 } from "node:fs";
|
|
73
|
-
import { delimiter as delimiter3,
|
|
71
|
+
import { delimiter as delimiter3, join as join4 } from "node:path";
|
|
74
72
|
import { existsSync as existsSync12, lstatSync as lstatSync5, readdirSync as readdirSync3 } from "node:fs";
|
|
75
|
-
import { join as join6, resolve as
|
|
73
|
+
import { join as join6, resolve as resolve8 } from "node:path";
|
|
76
74
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
77
75
|
import { lstatSync as lstatSync6, readdirSync as readdirSync4 } from "node:fs";
|
|
78
76
|
import { join as join7 } from "node:path";
|
|
79
|
-
import {
|
|
77
|
+
import { statSync as statSync5 } from "node:fs";
|
|
78
|
+
import { isAbsolute as isAbsolute5 } from "node:path";
|
|
80
79
|
|
|
81
80
|
class LspRequestContextParseError extends Error {
|
|
82
81
|
constructor(code, message) {
|
|
@@ -763,7 +762,6 @@ var DEFAULT_MAX_DIRECTORY_FILES = 50;
|
|
|
763
762
|
var REQUEST_TIMEOUT_MS = 15000;
|
|
764
763
|
var INIT_TIMEOUT_MS = 60000;
|
|
765
764
|
var IDLE_TIMEOUT_MS = 5 * 60000;
|
|
766
|
-
var MAX_RESIDENT_CLIENTS = 6;
|
|
767
765
|
var REAPER_INTERVAL_MS = 60000;
|
|
768
766
|
var STOP_HARD_KILL_TIMEOUT_MS = 5000;
|
|
769
767
|
var STOP_SIGKILL_GRACE_MS = 1000;
|
|
@@ -1279,7 +1277,6 @@ class LspClientTransport {
|
|
|
1279
1277
|
this.diagnosticsStore = new Map;
|
|
1280
1278
|
this.workspaceApplyEditHandler = null;
|
|
1281
1279
|
this.diagnosticPullSupported = false;
|
|
1282
|
-
this.documentFormattingSupported = false;
|
|
1283
1280
|
this.requestTimeoutMs = timeouts.requestTimeoutMs ?? REQUEST_TIMEOUT_MS;
|
|
1284
1281
|
this.initializeTimeoutMs = timeouts.initializeTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
1285
1282
|
}
|
|
@@ -1301,12 +1298,6 @@ class LspClientTransport {
|
|
|
1301
1298
|
isDiagnosticPullSupported() {
|
|
1302
1299
|
return this.diagnosticPullSupported;
|
|
1303
1300
|
}
|
|
1304
|
-
setDocumentFormattingSupported(supported) {
|
|
1305
|
-
this.documentFormattingSupported = supported;
|
|
1306
|
-
}
|
|
1307
|
-
isDocumentFormattingSupported() {
|
|
1308
|
-
return this.documentFormattingSupported;
|
|
1309
|
-
}
|
|
1310
1301
|
handlePublishDiagnostics(params) {
|
|
1311
1302
|
this.diagnosticsStore.set(params.uri, [...params.diagnostics]);
|
|
1312
1303
|
}
|
|
@@ -1518,14 +1509,6 @@ function supportsDiagnosticPull(capabilities) {
|
|
|
1518
1509
|
return false;
|
|
1519
1510
|
return Object.hasOwn(capabilities, "diagnosticProvider");
|
|
1520
1511
|
}
|
|
1521
|
-
function supportsDocumentFormatting(capabilities) {
|
|
1522
|
-
if (capabilities === undefined)
|
|
1523
|
-
return false;
|
|
1524
|
-
const provider = capabilities.documentFormattingProvider;
|
|
1525
|
-
if (provider === undefined || provider === null || provider === false)
|
|
1526
|
-
return false;
|
|
1527
|
-
return provider === true || typeof provider === "object";
|
|
1528
|
-
}
|
|
1529
1512
|
|
|
1530
1513
|
class LspClientConnection extends LspClientTransport {
|
|
1531
1514
|
async initialize() {
|
|
@@ -1542,7 +1525,6 @@ class LspClientConnection extends LspClientTransport {
|
|
|
1542
1525
|
references: {},
|
|
1543
1526
|
documentSymbol: { hierarchicalDocumentSymbolSupport: true },
|
|
1544
1527
|
publishDiagnostics: {},
|
|
1545
|
-
formatting: { dynamicRegistration: false },
|
|
1546
1528
|
rename: {
|
|
1547
1529
|
prepareSupport: true,
|
|
1548
1530
|
prepareSupportDefaultBehavior: 1
|
|
@@ -1584,7 +1566,6 @@ class LspClientConnection extends LspClientTransport {
|
|
|
1584
1566
|
initializationOptions: this.server.initialization
|
|
1585
1567
|
}, { timeoutMs: this.initializeTimeoutMs });
|
|
1586
1568
|
this.setDiagnosticPullSupported(supportsDiagnosticPull(result?.capabilities));
|
|
1587
|
-
this.setDocumentFormattingSupported(supportsDocumentFormatting(result?.capabilities));
|
|
1588
1569
|
await this.sendNotification("initialized", {});
|
|
1589
1570
|
await this.sendNotification("workspace/didChangeConfiguration", {
|
|
1590
1571
|
settings: { json: { validate: { enable: true } } }
|
|
@@ -3123,18 +3104,6 @@ class LspClient extends LspClientConnection {
|
|
|
3123
3104
|
textDocument: { uri: pathToFileURL3(absPath).href }
|
|
3124
3105
|
}, options);
|
|
3125
3106
|
}
|
|
3126
|
-
async formatDocument(filePath, options, signal) {
|
|
3127
|
-
if (!this.isDocumentFormattingSupported())
|
|
3128
|
-
return null;
|
|
3129
|
-
const absPath = this.resolveWorkspacePath(filePath);
|
|
3130
|
-
await this.openFile(absPath);
|
|
3131
|
-
const requestOptions = signal === undefined ? {} : { signal };
|
|
3132
|
-
const edits = await this.sendRequest("textDocument/formatting", {
|
|
3133
|
-
textDocument: { uri: pathToFileURL3(absPath).href },
|
|
3134
|
-
options
|
|
3135
|
-
}, requestOptions);
|
|
3136
|
-
return edits ?? [];
|
|
3137
|
-
}
|
|
3138
3107
|
async workspaceSymbols(query, signal) {
|
|
3139
3108
|
const options = signal === undefined ? {} : { signal };
|
|
3140
3109
|
return this.sendRequest("workspace/symbol", { query }, options);
|
|
@@ -3383,7 +3352,6 @@ class LspManager {
|
|
|
3383
3352
|
this.disposed = false;
|
|
3384
3353
|
this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS;
|
|
3385
3354
|
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
3386
|
-
this.maxResidentClients = options.maxResidentClients ?? MAX_RESIDENT_CLIENTS;
|
|
3387
3355
|
this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
|
|
3388
3356
|
this.clientFactory = options.clientFactory ?? ((root, server2) => new LspClient(root, server2));
|
|
3389
3357
|
this.now = options.now ?? (() => Date.now());
|
|
@@ -3417,26 +3385,6 @@ class LspManager {
|
|
|
3417
3385
|
}
|
|
3418
3386
|
}
|
|
3419
3387
|
}
|
|
3420
|
-
evictForAdmission() {
|
|
3421
|
-
while (this.clients.size >= this.maxResidentClients) {
|
|
3422
|
-
const victim = this.leastRecentlyUsedIdleClient();
|
|
3423
|
-
if (!victim)
|
|
3424
|
-
return;
|
|
3425
|
-
this.clients.delete(victim.key);
|
|
3426
|
-
stopClientBestEffort(victim.managed.client);
|
|
3427
|
-
}
|
|
3428
|
-
}
|
|
3429
|
-
leastRecentlyUsedIdleClient() {
|
|
3430
|
-
let candidate = null;
|
|
3431
|
-
for (const [key, managed] of this.clients) {
|
|
3432
|
-
if (managed.refCount > 0 || managed.pendingWaiters > 0 || managed.isInitializing)
|
|
3433
|
-
continue;
|
|
3434
|
-
if (candidate === null || managed.lastUsedAt < candidate.managed.lastUsedAt) {
|
|
3435
|
-
candidate = { key, managed };
|
|
3436
|
-
}
|
|
3437
|
-
}
|
|
3438
|
-
return candidate;
|
|
3439
|
-
}
|
|
3440
3388
|
async tryDeleteIfOrphaned(key, managed) {
|
|
3441
3389
|
if (managed.refCount === 0 && managed.pendingWaiters === 0 && !managed.isInitializing && this.clients.get(key) === managed) {
|
|
3442
3390
|
this.clients.delete(key);
|
|
@@ -3483,7 +3431,6 @@ class LspManager {
|
|
|
3483
3431
|
managed.lastUsedAt = this.now();
|
|
3484
3432
|
return managed.client;
|
|
3485
3433
|
}
|
|
3486
|
-
this.evictForAdmission();
|
|
3487
3434
|
const client = this.clientFactory(root, server2);
|
|
3488
3435
|
const initStartedAt = this.now();
|
|
3489
3436
|
const initPromise = (async () => {
|
|
@@ -3546,7 +3493,6 @@ class LspManager {
|
|
|
3546
3493
|
const key = this.getKey(root, server2.id);
|
|
3547
3494
|
if (this.clients.has(key))
|
|
3548
3495
|
return;
|
|
3549
|
-
this.evictForAdmission();
|
|
3550
3496
|
const client = this.clientFactory(root, server2);
|
|
3551
3497
|
const initStartedAt = this.now();
|
|
3552
3498
|
const initPromise = (async () => {
|
|
@@ -3656,6 +3602,50 @@ function nearestExistingAncestor(directory) {
|
|
|
3656
3602
|
}
|
|
3657
3603
|
return current;
|
|
3658
3604
|
}
|
|
3605
|
+
function getInstallDecisionsPath() {
|
|
3606
|
+
return lspRequestContext().installDecisionsPath;
|
|
3607
|
+
}
|
|
3608
|
+
function loadInstallDecisions() {
|
|
3609
|
+
const path2 = getInstallDecisionsPath();
|
|
3610
|
+
if (!existsSync8(path2))
|
|
3611
|
+
return {};
|
|
3612
|
+
try {
|
|
3613
|
+
const parsed = JSON.parse(readFileSync4(path2, "utf8"));
|
|
3614
|
+
return isInstallDecisions(parsed) ? parsed : {};
|
|
3615
|
+
} catch {
|
|
3616
|
+
return {};
|
|
3617
|
+
}
|
|
3618
|
+
}
|
|
3619
|
+
function loadInstallDecision(serverId) {
|
|
3620
|
+
return loadInstallDecisions()[serverId];
|
|
3621
|
+
}
|
|
3622
|
+
function recordInstallDecision(serverId, decision, decidedAt = new Date().toISOString()) {
|
|
3623
|
+
const decisions = loadInstallDecisions();
|
|
3624
|
+
decisions[serverId] = { decision, decidedAt };
|
|
3625
|
+
writeInstallDecisions(decisions);
|
|
3626
|
+
}
|
|
3627
|
+
function isInstallDecision(value) {
|
|
3628
|
+
return value === "declined" || value === "allowed";
|
|
3629
|
+
}
|
|
3630
|
+
function writeInstallDecisions(decisions) {
|
|
3631
|
+
const path2 = getInstallDecisionsPath();
|
|
3632
|
+
mkdirSync3(dirname8(path2), { recursive: true });
|
|
3633
|
+
const tmpPath = `${path2}.tmp`;
|
|
3634
|
+
writeFileSync2(tmpPath, `${JSON.stringify(decisions, null, 2)}
|
|
3635
|
+
`, "utf8");
|
|
3636
|
+
renameSync2(tmpPath, path2);
|
|
3637
|
+
}
|
|
3638
|
+
function isInstallDecisions(value) {
|
|
3639
|
+
return isRecord5(value) && Object.values(value).every(isInstallDecisionRecord);
|
|
3640
|
+
}
|
|
3641
|
+
function isInstallDecisionRecord(value) {
|
|
3642
|
+
if (!isRecord5(value))
|
|
3643
|
+
return false;
|
|
3644
|
+
return isInstallDecision(value["decision"]) && typeof value["decidedAt"] === "string";
|
|
3645
|
+
}
|
|
3646
|
+
function isRecord5(value) {
|
|
3647
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3648
|
+
}
|
|
3659
3649
|
var LSP_INSTALL_HINTS = {
|
|
3660
3650
|
typescript: "npm install -g typescript-language-server typescript",
|
|
3661
3651
|
deno: "Install Deno from https://deno.land",
|
|
@@ -3700,26 +3690,6 @@ var LSP_INSTALL_HINTS = {
|
|
|
3700
3690
|
julials: `julia -e 'using Pkg; Pkg.add("LanguageServer")'`,
|
|
3701
3691
|
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"
|
|
3702
3692
|
};
|
|
3703
|
-
var LSP_LOCAL_INSTALL_HINTS = {
|
|
3704
|
-
typescript: "bun add -d typescript-language-server typescript",
|
|
3705
|
-
vue: "bun add -d @vue/language-server",
|
|
3706
|
-
eslint: "bun add -d vscode-langservers-extracted",
|
|
3707
|
-
oxlint: "bun add -d oxlint",
|
|
3708
|
-
biome: "bun add -d @biomejs/biome",
|
|
3709
|
-
svelte: "bun add -d svelte-language-server",
|
|
3710
|
-
astro: "bun add -d @astrojs/language-server",
|
|
3711
|
-
bash: "bun add -d bash-language-server",
|
|
3712
|
-
"bash-ls": "bun add -d bash-language-server",
|
|
3713
|
-
"yaml-ls": "bun add -d yaml-language-server",
|
|
3714
|
-
php: "bun add -d intelephense",
|
|
3715
|
-
prisma: "bun add -d prisma",
|
|
3716
|
-
dockerfile: "bun add -d dockerfile-language-server-nodejs",
|
|
3717
|
-
pyright: "uv add --dev pyright",
|
|
3718
|
-
basedpyright: "uv add --dev basedpyright",
|
|
3719
|
-
ruff: "uv add --dev ruff",
|
|
3720
|
-
ty: "uv add --dev ty",
|
|
3721
|
-
"ruby-lsp": "bundle add ruby-lsp --group development"
|
|
3722
|
-
};
|
|
3723
3693
|
var BUILTIN_SERVERS = {
|
|
3724
3694
|
typescript: {
|
|
3725
3695
|
command: ["typescript-language-server", "--stdio"],
|
|
@@ -3821,50 +3791,6 @@ var BUILTIN_SERVERS = {
|
|
|
3821
3791
|
extensions: [".razor", ".cshtml"]
|
|
3822
3792
|
}
|
|
3823
3793
|
};
|
|
3824
|
-
function getInstallDecisionsPath() {
|
|
3825
|
-
return lspRequestContext().installDecisionsPath;
|
|
3826
|
-
}
|
|
3827
|
-
function loadInstallDecisions() {
|
|
3828
|
-
const path2 = getInstallDecisionsPath();
|
|
3829
|
-
if (!existsSync8(path2))
|
|
3830
|
-
return {};
|
|
3831
|
-
try {
|
|
3832
|
-
const parsed = JSON.parse(readFileSync4(path2, "utf8"));
|
|
3833
|
-
return isInstallDecisions(parsed) ? parsed : {};
|
|
3834
|
-
} catch {
|
|
3835
|
-
return {};
|
|
3836
|
-
}
|
|
3837
|
-
}
|
|
3838
|
-
function loadInstallDecision(serverId) {
|
|
3839
|
-
return loadInstallDecisions()[serverId];
|
|
3840
|
-
}
|
|
3841
|
-
function recordInstallDecision(serverId, decision, decidedAt = new Date().toISOString()) {
|
|
3842
|
-
const decisions = loadInstallDecisions();
|
|
3843
|
-
decisions[serverId] = { decision, decidedAt };
|
|
3844
|
-
writeInstallDecisions(decisions);
|
|
3845
|
-
}
|
|
3846
|
-
function isInstallDecision(value) {
|
|
3847
|
-
return value === "declined" || value === "allowed";
|
|
3848
|
-
}
|
|
3849
|
-
function writeInstallDecisions(decisions) {
|
|
3850
|
-
const path2 = getInstallDecisionsPath();
|
|
3851
|
-
mkdirSync3(dirname8(path2), { recursive: true });
|
|
3852
|
-
const tmpPath = `${path2}.tmp`;
|
|
3853
|
-
writeFileSync2(tmpPath, `${JSON.stringify(decisions, null, 2)}
|
|
3854
|
-
`, "utf8");
|
|
3855
|
-
renameSync2(tmpPath, path2);
|
|
3856
|
-
}
|
|
3857
|
-
function isInstallDecisions(value) {
|
|
3858
|
-
return isRecord5(value) && Object.values(value).every(isInstallDecisionRecord);
|
|
3859
|
-
}
|
|
3860
|
-
function isInstallDecisionRecord(value) {
|
|
3861
|
-
if (!isRecord5(value))
|
|
3862
|
-
return false;
|
|
3863
|
-
return isInstallDecision(value["decision"]) && typeof value["decidedAt"] === "string";
|
|
3864
|
-
}
|
|
3865
|
-
function isRecord5(value) {
|
|
3866
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3867
|
-
}
|
|
3868
3794
|
function getProjectConfigPaths() {
|
|
3869
3795
|
return lspRequestContext().projectConfigPaths;
|
|
3870
3796
|
}
|
|
@@ -4058,151 +3984,50 @@ function getDisabledServerIds() {
|
|
|
4058
3984
|
}
|
|
4059
3985
|
return disabled;
|
|
4060
3986
|
}
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
"requirements.txt",
|
|
4071
|
-
"setup.py",
|
|
4072
|
-
"setup.cfg",
|
|
4073
|
-
"Pipfile",
|
|
4074
|
-
"pyrightconfig.json",
|
|
4075
|
-
"ruff.toml",
|
|
4076
|
-
".ruff.toml"
|
|
4077
|
-
],
|
|
4078
|
-
binDirs: [
|
|
4079
|
-
join4(".venv", "bin"),
|
|
4080
|
-
join4(".venv", "Scripts"),
|
|
4081
|
-
join4("venv", "bin"),
|
|
4082
|
-
join4("venv", "Scripts"),
|
|
4083
|
-
join4(".env", "bin"),
|
|
4084
|
-
join4(".env", "Scripts")
|
|
4085
|
-
]
|
|
4086
|
-
},
|
|
4087
|
-
{
|
|
4088
|
-
markers: ["Gemfile", "Gemfile.lock"],
|
|
4089
|
-
binDirs: [join4("vendor", "bundle", "bin"), "bin"]
|
|
4090
|
-
},
|
|
4091
|
-
{
|
|
4092
|
-
markers: ["go.mod", "go.sum", "go.work"],
|
|
4093
|
-
binDirs: ["bin"]
|
|
4094
|
-
}
|
|
4095
|
-
];
|
|
4096
|
-
var resolutionCache = new Map;
|
|
4097
|
-
var probeCount = 0;
|
|
4098
|
-
function probe(path2) {
|
|
4099
|
-
probeCount += 1;
|
|
4100
|
-
return existsSync10(path2);
|
|
4101
|
-
}
|
|
4102
|
-
function executableSuffixes(platform, pathExt) {
|
|
4103
|
-
if (platform !== "win32")
|
|
4104
|
-
return [""];
|
|
4105
|
-
const configured = pathExt ?? process.env["PATHEXT"] ?? "";
|
|
4106
|
-
const systemExts = configured.split(";").filter((entry) => entry.length > 0).map((entry) => entry.toLowerCase());
|
|
4107
|
-
return [...new Set(["", ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])];
|
|
4108
|
-
}
|
|
4109
|
-
function probeWithSuffixes(directory, command, suffixes) {
|
|
4110
|
-
for (const suffix of suffixes) {
|
|
4111
|
-
const candidate = join4(directory, command + suffix);
|
|
4112
|
-
if (probe(candidate))
|
|
4113
|
-
return candidate;
|
|
3987
|
+
function isServerInstalled(command, _workingDirectory) {
|
|
3988
|
+
if (command.length === 0)
|
|
3989
|
+
return false;
|
|
3990
|
+
const [cmd] = command;
|
|
3991
|
+
if (!cmd)
|
|
3992
|
+
return false;
|
|
3993
|
+
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
3994
|
+
if (existsSync10(cmd))
|
|
3995
|
+
return true;
|
|
4114
3996
|
}
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
for (const binDir of rule.binDirs) {
|
|
4125
|
-
const found = probeWithSuffixes(join4(current, binDir), command, suffixes);
|
|
4126
|
-
if (found !== null)
|
|
4127
|
-
return found;
|
|
4128
|
-
}
|
|
3997
|
+
const isWindows = process.platform === "win32";
|
|
3998
|
+
let exts = [""];
|
|
3999
|
+
if (isWindows) {
|
|
4000
|
+
const pathExt = process.env["PATHEXT"] ?? "";
|
|
4001
|
+
if (pathExt) {
|
|
4002
|
+
const systemExts = pathExt.split(";").filter(Boolean);
|
|
4003
|
+
exts = [...new Set([...exts, ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])];
|
|
4004
|
+
} else {
|
|
4005
|
+
exts = ["", ".exe", ".cmd", ".bat", ".ps1"];
|
|
4129
4006
|
}
|
|
4130
|
-
if (probe(join4(current, ".git")))
|
|
4131
|
-
return null;
|
|
4132
|
-
if (boundary !== undefined && current === boundary)
|
|
4133
|
-
return null;
|
|
4134
|
-
const parent = dirname9(current);
|
|
4135
|
-
if (parent === current)
|
|
4136
|
-
return null;
|
|
4137
|
-
current = parent;
|
|
4138
4007
|
}
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
let pathEnv = pathEnvOverride ?? process.env["PATH"] ?? "";
|
|
4142
|
-
if (platform === "win32" && !pathEnv) {
|
|
4008
|
+
let pathEnv = process.env["PATH"] ?? "";
|
|
4009
|
+
if (isWindows && !pathEnv) {
|
|
4143
4010
|
pathEnv = process.env["Path"] ?? "";
|
|
4144
4011
|
}
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4012
|
+
const paths = pathEnv.split(delimiter3);
|
|
4013
|
+
for (const p of paths) {
|
|
4014
|
+
for (const suffix of exts) {
|
|
4015
|
+
if (existsSync10(join4(p, cmd + suffix))) {
|
|
4016
|
+
return true;
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4151
4019
|
}
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
if (command.length === 0)
|
|
4156
|
-
return null;
|
|
4157
|
-
const [cmd] = command;
|
|
4158
|
-
if (cmd === undefined || cmd.length === 0)
|
|
4159
|
-
return null;
|
|
4160
|
-
const platform = options.platform ?? process.platform;
|
|
4161
|
-
const suffixes = executableSuffixes(platform, options.pathExt);
|
|
4162
|
-
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
4163
|
-
const explicit = isAbsolute5(cmd) ? cmd : resolve7(workingDirectory ?? process.cwd(), cmd);
|
|
4164
|
-
return probe(explicit) ? explicit : null;
|
|
4165
|
-
}
|
|
4166
|
-
const cacheKey = JSON.stringify([
|
|
4167
|
-
workingDirectory ?? "",
|
|
4168
|
-
cmd,
|
|
4169
|
-
platform,
|
|
4170
|
-
options.stopAt ?? "",
|
|
4171
|
-
options.pathExt ?? "",
|
|
4172
|
-
options.pathEnv ?? process.env["PATH"] ?? ""
|
|
4173
|
-
]);
|
|
4174
|
-
const cached = resolutionCache.get(cacheKey);
|
|
4175
|
-
if (cached !== undefined)
|
|
4176
|
-
return cached;
|
|
4177
|
-
let resolved = null;
|
|
4178
|
-
if (workingDirectory !== undefined && workingDirectory.length > 0) {
|
|
4179
|
-
resolved = resolveLocal(cmd, workingDirectory, suffixes, options.stopAt);
|
|
4180
|
-
}
|
|
4181
|
-
resolved ??= resolveFromPath(cmd, suffixes, platform, options.pathEnv);
|
|
4182
|
-
if (resolved === null && cmd === "node")
|
|
4183
|
-
resolved = cmd;
|
|
4184
|
-
resolutionCache.set(cacheKey, resolved);
|
|
4185
|
-
return resolved;
|
|
4186
|
-
}
|
|
4187
|
-
function isServerInstalled(command, workingDirectory, options = {}) {
|
|
4188
|
-
if (command.length === 0)
|
|
4189
|
-
return false;
|
|
4190
|
-
return resolveServerBinary(command, workingDirectory, options) !== null;
|
|
4191
|
-
}
|
|
4192
|
-
function withResolvedCommand(command, binaryPath) {
|
|
4193
|
-
return [binaryPath, ...command.slice(1)];
|
|
4020
|
+
if (cmd === "node")
|
|
4021
|
+
return true;
|
|
4022
|
+
return false;
|
|
4194
4023
|
}
|
|
4195
4024
|
function findServerForExtension(ext) {
|
|
4196
4025
|
const servers = getMergedServers();
|
|
4197
|
-
const workingDirectory = contextCwd();
|
|
4198
4026
|
for (const server2 of servers) {
|
|
4199
|
-
if (
|
|
4200
|
-
continue;
|
|
4201
|
-
const binaryPath = resolveServerBinary(server2.command, workingDirectory);
|
|
4202
|
-
if (binaryPath !== null) {
|
|
4027
|
+
if (server2.extensions.includes(ext) && isServerInstalled(server2.command)) {
|
|
4203
4028
|
const resolvedServer = {
|
|
4204
4029
|
id: server2.id,
|
|
4205
|
-
command:
|
|
4030
|
+
command: server2.command,
|
|
4206
4031
|
extensions: server2.extensions,
|
|
4207
4032
|
priority: server2.priority
|
|
4208
4033
|
};
|
|
@@ -4249,7 +4074,6 @@ function findServerForExtension(ext) {
|
|
|
4249
4074
|
function getAllServers() {
|
|
4250
4075
|
const servers = getMergedServers();
|
|
4251
4076
|
const disabled = getDisabledServerIds();
|
|
4252
|
-
const workingDirectory = contextCwd();
|
|
4253
4077
|
const result = [];
|
|
4254
4078
|
const seen = new Set;
|
|
4255
4079
|
for (const server2 of servers) {
|
|
@@ -4257,7 +4081,7 @@ function getAllServers() {
|
|
|
4257
4081
|
continue;
|
|
4258
4082
|
result.push({
|
|
4259
4083
|
id: server2.id,
|
|
4260
|
-
installed: isServerInstalled(server2.command
|
|
4084
|
+
installed: isServerInstalled(server2.command),
|
|
4261
4085
|
extensions: server2.extensions,
|
|
4262
4086
|
disabled: false,
|
|
4263
4087
|
source: server2.source,
|
|
@@ -4271,7 +4095,7 @@ function getAllServers() {
|
|
|
4271
4095
|
const builtin = BUILTIN_SERVERS[id];
|
|
4272
4096
|
result.push({
|
|
4273
4097
|
id,
|
|
4274
|
-
installed: builtin ? isServerInstalled(builtin.command
|
|
4098
|
+
installed: builtin ? isServerInstalled(builtin.command) : false,
|
|
4275
4099
|
extensions: builtin?.extensions ?? [],
|
|
4276
4100
|
disabled: true,
|
|
4277
4101
|
source: "disabled",
|
|
@@ -4292,7 +4116,7 @@ function findWorkspaceRoot(filePath) {
|
|
|
4292
4116
|
const abs = resolveReadablePathInsideContext(filePath);
|
|
4293
4117
|
let dir = abs;
|
|
4294
4118
|
if (!isDirectoryPath(dir)) {
|
|
4295
|
-
dir =
|
|
4119
|
+
dir = dirname9(dir);
|
|
4296
4120
|
}
|
|
4297
4121
|
if (!isPathInside(cwd, abs))
|
|
4298
4122
|
return findWorkspaceRootOutsideContext(dir);
|
|
@@ -4308,13 +4132,13 @@ function findWorkspaceRoot(filePath) {
|
|
|
4308
4132
|
}
|
|
4309
4133
|
if (dir === cwd)
|
|
4310
4134
|
break;
|
|
4311
|
-
dir =
|
|
4135
|
+
dir = dirname9(dir);
|
|
4312
4136
|
}
|
|
4313
4137
|
return fallbackRoot;
|
|
4314
4138
|
}
|
|
4315
4139
|
function resolveReadablePathInsideContext(filePath) {
|
|
4316
4140
|
const cwd = contextCwd();
|
|
4317
|
-
const abs =
|
|
4141
|
+
const abs = resolve7(cwd, filePath);
|
|
4318
4142
|
if (isPathInside(cwd, abs))
|
|
4319
4143
|
return abs;
|
|
4320
4144
|
const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
|
|
@@ -4340,7 +4164,7 @@ function rebaseThroughCanonicalAncestor(path2, cwd) {
|
|
|
4340
4164
|
if (isPathInside(cwd, canonical))
|
|
4341
4165
|
return suffix.length === 0 ? canonical : join5(canonical, ...suffix);
|
|
4342
4166
|
}
|
|
4343
|
-
const parent =
|
|
4167
|
+
const parent = dirname9(current);
|
|
4344
4168
|
if (parent === current)
|
|
4345
4169
|
return;
|
|
4346
4170
|
suffix.unshift(basename3(current));
|
|
@@ -4363,7 +4187,7 @@ function nearestExistingDirectoryInsideContext(directory, cwd) {
|
|
|
4363
4187
|
return canonical;
|
|
4364
4188
|
if (current === cwd)
|
|
4365
4189
|
return;
|
|
4366
|
-
current =
|
|
4190
|
+
current = dirname9(current);
|
|
4367
4191
|
}
|
|
4368
4192
|
return;
|
|
4369
4193
|
}
|
|
@@ -4390,19 +4214,6 @@ function formatServerLookupError(result) {
|
|
|
4390
4214
|
].join(`
|
|
4391
4215
|
`);
|
|
4392
4216
|
}
|
|
4393
|
-
function formatInstallOptions(serverId, installHint) {
|
|
4394
|
-
const localHint = LSP_LOCAL_INSTALL_HINTS[serverId];
|
|
4395
|
-
if (localHint === undefined) {
|
|
4396
|
-
return ["To install, run:", ` ${installHint}`];
|
|
4397
|
-
}
|
|
4398
|
-
return [
|
|
4399
|
-
"To install in THIS repository (preferred — no global install needed):",
|
|
4400
|
-
` ${localHint}`,
|
|
4401
|
-
"",
|
|
4402
|
-
"Or install it globally:",
|
|
4403
|
-
` ${installHint}`
|
|
4404
|
-
];
|
|
4405
|
-
}
|
|
4406
4217
|
function formatNotInstalled(result) {
|
|
4407
4218
|
const { server: server2, installHint } = result;
|
|
4408
4219
|
const extensions = server2.extensions.join(", ");
|
|
@@ -4417,19 +4228,19 @@ function formatNotInstalled(result) {
|
|
|
4417
4228
|
`Command not found: ${server2.command[0]}`,
|
|
4418
4229
|
""
|
|
4419
4230
|
];
|
|
4420
|
-
const installOptions = formatInstallOptions(server2.id, installHint);
|
|
4421
4231
|
if (decision === "allowed") {
|
|
4422
4232
|
return [
|
|
4423
4233
|
...header,
|
|
4424
4234
|
"The user has pre-authorized LSP installation. Run the install command, then retry this tool:",
|
|
4425
|
-
|
|
4235
|
+
` ${installHint}`
|
|
4426
4236
|
].join(`
|
|
4427
4237
|
`);
|
|
4428
4238
|
}
|
|
4429
4239
|
if (!context.capabilities.installDecisionTool) {
|
|
4430
4240
|
return [
|
|
4431
4241
|
...header,
|
|
4432
|
-
|
|
4242
|
+
"To install, run:",
|
|
4243
|
+
` ${installHint}`,
|
|
4433
4244
|
"",
|
|
4434
4245
|
"ACTION REQUIRED — ASK THE USER whether to install this LSP server.",
|
|
4435
4246
|
"Install-decision recording is unavailable in this harness; proceed without LSP if the user declines."
|
|
@@ -4438,7 +4249,8 @@ function formatNotInstalled(result) {
|
|
|
4438
4249
|
}
|
|
4439
4250
|
return [
|
|
4440
4251
|
...header,
|
|
4441
|
-
|
|
4252
|
+
"To install, run:",
|
|
4253
|
+
` ${installHint}`,
|
|
4442
4254
|
"",
|
|
4443
4255
|
"ACTION REQUIRED — ASK THE USER whether to install this LSP server.",
|
|
4444
4256
|
"- If the user agrees: run the install command above, then retry this tool.",
|
|
@@ -4640,7 +4452,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
4640
4452
|
if (!extension.startsWith(".")) {
|
|
4641
4453
|
throw new LspInvalidPathError(`Extension must start with a dot (e.g., ".ts", not "${extension}"). Use ".${extension}" instead.`);
|
|
4642
4454
|
}
|
|
4643
|
-
const absDir =
|
|
4455
|
+
const absDir = resolve8(options.workspaceRoot ?? contextCwd(), directory);
|
|
4644
4456
|
if (!existsSync12(absDir)) {
|
|
4645
4457
|
throw new LspInvalidPathError(`Directory does not exist: ${absDir}`);
|
|
4646
4458
|
}
|
|
@@ -4981,91 +4793,6 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
4981
4793
|
throw error;
|
|
4982
4794
|
}
|
|
4983
4795
|
}
|
|
4984
|
-
var DEFAULT_FORMATTING_OPTIONS = {
|
|
4985
|
-
tabSize: 4,
|
|
4986
|
-
insertSpaces: false,
|
|
4987
|
-
trimTrailingWhitespace: true,
|
|
4988
|
-
insertFinalNewline: true,
|
|
4989
|
-
trimFinalNewlines: true
|
|
4990
|
-
};
|
|
4991
|
-
var UNCHANGED = { status: "unchanged", linesAdded: 0, linesRemoved: 0 };
|
|
4992
|
-
async function formatDocumentWithClient(client, filePath, options = {}) {
|
|
4993
|
-
const edits = await client.formatDocument(filePath, options.formattingOptions ?? DEFAULT_FORMATTING_OPTIONS, options.signal);
|
|
4994
|
-
if (edits === null)
|
|
4995
|
-
return { status: "unavailable", reason: "capability_not_advertised" };
|
|
4996
|
-
if (edits.length === 0)
|
|
4997
|
-
return UNCHANGED;
|
|
4998
|
-
const before = readFileSync6(filePath, "utf-8");
|
|
4999
|
-
const normalized = normalizeTextEdits(before, edits, 0);
|
|
5000
|
-
if (normalized.text === before)
|
|
5001
|
-
return UNCHANGED;
|
|
5002
|
-
writeAtomically(filePath, normalized.text);
|
|
5003
|
-
await client.openFile(filePath);
|
|
5004
|
-
return {
|
|
5005
|
-
status: "formatted",
|
|
5006
|
-
...lineDelta(normalized.edits)
|
|
5007
|
-
};
|
|
5008
|
-
}
|
|
5009
|
-
function lineDelta(edits) {
|
|
5010
|
-
let linesAdded = 0;
|
|
5011
|
-
let linesRemoved = 0;
|
|
5012
|
-
for (const edit of edits) {
|
|
5013
|
-
linesRemoved += edit.range.end.line - edit.range.start.line + 1;
|
|
5014
|
-
linesAdded += edit.newText.split(`
|
|
5015
|
-
`).length;
|
|
5016
|
-
}
|
|
5017
|
-
return { linesAdded, linesRemoved };
|
|
5018
|
-
}
|
|
5019
|
-
function writeAtomically(filePath, content) {
|
|
5020
|
-
const tempPath = `${filePath}.omo-format.tmp`;
|
|
5021
|
-
writeFileSync3(tempPath, content, "utf-8");
|
|
5022
|
-
try {
|
|
5023
|
-
renameSync3(tempPath, filePath);
|
|
5024
|
-
} catch (error) {
|
|
5025
|
-
try {
|
|
5026
|
-
unlinkSync2(tempPath);
|
|
5027
|
-
} catch {}
|
|
5028
|
-
throw error;
|
|
5029
|
-
}
|
|
5030
|
-
}
|
|
5031
|
-
async function executeLspFormat(params, signal) {
|
|
5032
|
-
const filePath = requireString(params, "filePath");
|
|
5033
|
-
try {
|
|
5034
|
-
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => formatDocumentWithClient(client, resolvedFilePath, signal === undefined ? {} : { signal }), "format", clientOptions(signal));
|
|
5035
|
-
return text(describeResult(filePath, result), formatDetails(filePath, result));
|
|
5036
|
-
} catch (error) {
|
|
5037
|
-
const missingDependency = missingDependencyResult(error, {
|
|
5038
|
-
filePath,
|
|
5039
|
-
status: "unavailable",
|
|
5040
|
-
reason: "server_unavailable",
|
|
5041
|
-
linesAdded: 0,
|
|
5042
|
-
linesRemoved: 0
|
|
5043
|
-
});
|
|
5044
|
-
if (missingDependency)
|
|
5045
|
-
return missingDependency;
|
|
5046
|
-
throw error;
|
|
5047
|
-
}
|
|
5048
|
-
}
|
|
5049
|
-
function formatDetails(filePath, result) {
|
|
5050
|
-
if (result.status === "unavailable") {
|
|
5051
|
-
return { filePath, status: "unavailable", reason: result.reason, linesAdded: 0, linesRemoved: 0 };
|
|
5052
|
-
}
|
|
5053
|
-
return {
|
|
5054
|
-
filePath,
|
|
5055
|
-
status: result.status,
|
|
5056
|
-
linesAdded: result.linesAdded,
|
|
5057
|
-
linesRemoved: result.linesRemoved
|
|
5058
|
-
};
|
|
5059
|
-
}
|
|
5060
|
-
function describeResult(filePath, result) {
|
|
5061
|
-
if (result.status === "unavailable") {
|
|
5062
|
-
return `Formatting unavailable for ${filePath}: the language server does not advertise documentFormattingProvider.`;
|
|
5063
|
-
}
|
|
5064
|
-
if (result.status === "unchanged") {
|
|
5065
|
-
return `Already formatted: ${filePath}`;
|
|
5066
|
-
}
|
|
5067
|
-
return `Formatted ${filePath} (+${result.linesAdded}/-${result.linesRemoved} lines)`;
|
|
5068
|
-
}
|
|
5069
4796
|
async function executeLspInstallDecision(params) {
|
|
5070
4797
|
const serverId = requireString(params, "server_id");
|
|
5071
4798
|
const decision = params["decision"];
|
|
@@ -5385,16 +5112,6 @@ var LSP_MCP_TOOLS = [
|
|
|
5385
5112
|
}, ["filePath", "line", "character", "newName"]),
|
|
5386
5113
|
execute: executeLspRename
|
|
5387
5114
|
},
|
|
5388
|
-
{
|
|
5389
|
-
name: "format",
|
|
5390
|
-
aliases: ["lsp_format"],
|
|
5391
|
-
title: "LSP Format",
|
|
5392
|
-
description: "Format a source file with its language server and write the returned edits to disk.",
|
|
5393
|
-
inputSchema: objectSchema({
|
|
5394
|
-
filePath: { type: "string", description: "Source file path to format." }
|
|
5395
|
-
}, ["filePath"]),
|
|
5396
|
-
execute: executeLspFormat
|
|
5397
|
-
},
|
|
5398
5115
|
{
|
|
5399
5116
|
name: "install_decision",
|
|
5400
5117
|
aliases: ["lsp_install_decision"],
|
|
@@ -5461,7 +5178,7 @@ function withContext(args, context) {
|
|
|
5461
5178
|
function ensureDaemonAvailable(paths, ensure, signal) {
|
|
5462
5179
|
if (!signal)
|
|
5463
5180
|
return ensure(paths);
|
|
5464
|
-
return new Promise((
|
|
5181
|
+
return new Promise((resolve9, reject) => {
|
|
5465
5182
|
let settled = false;
|
|
5466
5183
|
const finish = (run) => {
|
|
5467
5184
|
if (settled)
|
|
@@ -5476,11 +5193,11 @@ function ensureDaemonAvailable(paths, ensure, signal) {
|
|
|
5476
5193
|
return;
|
|
5477
5194
|
}
|
|
5478
5195
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
5479
|
-
Promise.resolve().then(() => ensure(paths, signal)).then(() => finish(() =>
|
|
5196
|
+
Promise.resolve().then(() => ensure(paths, signal)).then(() => finish(() => resolve9()), (error) => finish(() => reject(signal.aborted ? new DaemonRequestCancelledError(false) : error)));
|
|
5480
5197
|
});
|
|
5481
5198
|
}
|
|
5482
5199
|
function sendToolCall(paths, token, name, args, options) {
|
|
5483
|
-
return new Promise((
|
|
5200
|
+
return new Promise((resolve9, reject) => {
|
|
5484
5201
|
const socket = connect(paths.socket);
|
|
5485
5202
|
const requestId = allocateProxyRequestId();
|
|
5486
5203
|
let settled = false;
|
|
@@ -5533,7 +5250,7 @@ function sendToolCall(paths, token, name, args, options) {
|
|
|
5533
5250
|
}
|
|
5534
5251
|
const result = toToolResult(message, requestId);
|
|
5535
5252
|
if (result)
|
|
5536
|
-
finish(() =>
|
|
5253
|
+
finish(() => resolve9(result));
|
|
5537
5254
|
else
|
|
5538
5255
|
finish(() => reject(new DaemonRequestError("invalid daemon response", requestWritten)));
|
|
5539
5256
|
});
|
|
@@ -5604,12 +5321,12 @@ function resolveDaemonRuntime2(env, defaults) {
|
|
|
5604
5321
|
throw new InvalidRuntimeOverrideError2("paired_values_required", `${OMO_LSP_DAEMON_CLI2} and ${OMO_LSP_DAEMON_VERSION2} must be set together`);
|
|
5605
5322
|
}
|
|
5606
5323
|
if (!hasCliOverride || !hasVersionOverride) {
|
|
5607
|
-
if (!
|
|
5324
|
+
if (!isAbsolute5(defaults.cliPath)) {
|
|
5608
5325
|
throw new InvalidRuntimeOverrideError2("packaged_cli_must_be_absolute", "Packaged LSP daemon CLI path must be absolute");
|
|
5609
5326
|
}
|
|
5610
5327
|
return { cliPath: defaults.cliPath, version: validateDaemonVersion2(defaults.version) };
|
|
5611
5328
|
}
|
|
5612
|
-
if (!
|
|
5329
|
+
if (!isAbsolute5(cliOverride)) {
|
|
5613
5330
|
throw new InvalidRuntimeOverrideError2("cli_must_be_absolute", `${OMO_LSP_DAEMON_CLI2} must be an absolute path to an existing regular file`);
|
|
5614
5331
|
}
|
|
5615
5332
|
const stat = statSync5(cliOverride, { throwIfNoEntry: false });
|
|
@@ -5731,7 +5448,7 @@ function extensionKey(filePath) {
|
|
|
5731
5448
|
// ../../../../lsp-core/src/request-context.ts
|
|
5732
5449
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
5733
5450
|
import { existsSync as existsSync13, realpathSync as realpathSync6, statSync as statSync6 } from "node:fs";
|
|
5734
|
-
import { basename as basename4, delimiter as delimiter4, dirname as dirname2, isAbsolute as
|
|
5451
|
+
import { basename as basename4, delimiter as delimiter4, dirname as dirname2, isAbsolute as isAbsolute6, join as join8, relative as relative5, resolve as resolve9 } from "node:path";
|
|
5735
5452
|
|
|
5736
5453
|
class LspRequestContextParseError2 extends Error {
|
|
5737
5454
|
constructor(code, message) {
|
|
@@ -5772,14 +5489,14 @@ function parseLspRequestContext2(value) {
|
|
|
5772
5489
|
};
|
|
5773
5490
|
}
|
|
5774
5491
|
function canonicalCwd2(cwd) {
|
|
5775
|
-
const resolved =
|
|
5492
|
+
const resolved = resolve9(cwd);
|
|
5776
5493
|
if (!existsSync13(resolved) || !statSync6(resolved).isDirectory()) {
|
|
5777
5494
|
throw new LspRequestContextParseError2("invalid_cwd", `LSP request cwd must be an existing directory: ${cwd}`);
|
|
5778
5495
|
}
|
|
5779
5496
|
return realpathSync6(resolved);
|
|
5780
5497
|
}
|
|
5781
5498
|
function canonicalizeExistingOrNearestAncestor2(path2) {
|
|
5782
|
-
let current =
|
|
5499
|
+
let current = resolve9(path2);
|
|
5783
5500
|
const suffix = [];
|
|
5784
5501
|
while (true) {
|
|
5785
5502
|
try {
|
|
@@ -5822,14 +5539,14 @@ function stringArrayField2(value, field) {
|
|
|
5822
5539
|
return fieldValue;
|
|
5823
5540
|
}
|
|
5824
5541
|
function requireAbsolutePath2(path2, field) {
|
|
5825
|
-
if (!
|
|
5542
|
+
if (!isAbsolute6(path2)) {
|
|
5826
5543
|
throw new LspRequestContextParseError2("relative_path", `LSP request context.${field} must be absolute: ${path2}`);
|
|
5827
5544
|
}
|
|
5828
5545
|
}
|
|
5829
5546
|
function isPathInside2(parent, child) {
|
|
5830
|
-
const childPath =
|
|
5547
|
+
const childPath = resolve9(child);
|
|
5831
5548
|
const relativePath = relative5(parent, childPath);
|
|
5832
|
-
return relativePath === "" || !relativePath.startsWith("..") && !
|
|
5549
|
+
return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute6(relativePath);
|
|
5833
5550
|
}
|
|
5834
5551
|
function isMissingPathError2(error) {
|
|
5835
5552
|
const code = errorCode2(error);
|
|
@@ -5852,9 +5569,9 @@ function errorCode2(error) {
|
|
|
5852
5569
|
}
|
|
5853
5570
|
|
|
5854
5571
|
// src/daemon-cli-path.ts
|
|
5855
|
-
import { existsSync as existsSync15, readFileSync as
|
|
5572
|
+
import { existsSync as existsSync15, readFileSync as readFileSync6 } from "node:fs";
|
|
5856
5573
|
import { createRequire as createRequire2 } from "node:module";
|
|
5857
|
-
import { dirname as
|
|
5574
|
+
import { dirname as dirname10, join as join10 } from "node:path";
|
|
5858
5575
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
5859
5576
|
var requireFromHere2 = createRequire2(import.meta.url);
|
|
5860
5577
|
var PACKAGE_LSP_DAEMON_CLI = "@code-yeongyu/lsp-daemon/cli";
|
|
@@ -5901,7 +5618,7 @@ function resolveConfiguredLspDaemonCli(cliPath) {
|
|
|
5901
5618
|
}
|
|
5902
5619
|
function readDaemonPackageVersion(cliPath) {
|
|
5903
5620
|
try {
|
|
5904
|
-
const parsed = JSON.parse(
|
|
5621
|
+
const parsed = JSON.parse(readFileSync6(join10(dirname10(cliPath), "package.json"), "utf8"));
|
|
5905
5622
|
if (isRecord9(parsed) && typeof parsed["version"] === "string" && parsed["version"].length > 0) {
|
|
5906
5623
|
return parsed["version"];
|
|
5907
5624
|
}
|
|
@@ -5916,9 +5633,9 @@ function isRecord9(value) {
|
|
|
5916
5633
|
}
|
|
5917
5634
|
|
|
5918
5635
|
// src/lsp-session-state.ts
|
|
5919
|
-
import { mkdirSync as mkdirSync4, readFileSync as
|
|
5636
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync8, writeFileSync as writeFileSync3 } from "node:fs";
|
|
5920
5637
|
import { homedir } from "node:os";
|
|
5921
|
-
import { dirname as
|
|
5638
|
+
import { dirname as dirname12, join as join11 } from "node:path";
|
|
5922
5639
|
function sessionIdFrom(input) {
|
|
5923
5640
|
return typeof input.session_id === "string" && input.session_id.length > 0 ? input.session_id : undefined;
|
|
5924
5641
|
}
|
|
@@ -5949,7 +5666,7 @@ function sessionStatePath(sessionId) {
|
|
|
5949
5666
|
}
|
|
5950
5667
|
function readSessionState(path2) {
|
|
5951
5668
|
try {
|
|
5952
|
-
const parsed = JSON.parse(
|
|
5669
|
+
const parsed = JSON.parse(readFileSync8(path2, "utf8"));
|
|
5953
5670
|
if (isRecord10(parsed) && isLspSessionState(parsed))
|
|
5954
5671
|
return normalizeSessionState(parsed);
|
|
5955
5672
|
return emptyState();
|
|
@@ -5960,8 +5677,8 @@ function readSessionState(path2) {
|
|
|
5960
5677
|
}
|
|
5961
5678
|
}
|
|
5962
5679
|
function writeSessionState(path2, state) {
|
|
5963
|
-
mkdirSync4(
|
|
5964
|
-
|
|
5680
|
+
mkdirSync4(dirname12(path2), { recursive: true });
|
|
5681
|
+
writeFileSync3(path2, `${JSON.stringify(state)}
|
|
5965
5682
|
`);
|
|
5966
5683
|
}
|
|
5967
5684
|
function emptyState() {
|
|
@@ -6104,8 +5821,8 @@ function notConfiguredAvailability(details) {
|
|
|
6104
5821
|
return typeof extension === "string" && extension.length > 0 ? { extension } : undefined;
|
|
6105
5822
|
}
|
|
6106
5823
|
function codexLspRequestContext(env = process.env, cwd = process.cwd()) {
|
|
6107
|
-
const canonicalCwd3 = realpathSync8(
|
|
6108
|
-
const codexHome =
|
|
5824
|
+
const canonicalCwd3 = realpathSync8(resolve11(cwd));
|
|
5825
|
+
const codexHome = resolve11(env["CODEX_HOME"]?.trim() || join12(homedir3(), ".codex"));
|
|
6109
5826
|
return parseLspRequestContext2({
|
|
6110
5827
|
cwd: canonicalCwd3,
|
|
6111
5828
|
projectConfigPaths: [join12(canonicalCwd3, ".codex", "lsp-client.json")],
|
|
@@ -6204,7 +5921,7 @@ function isContextPressureTranscript(transcriptPath) {
|
|
|
6204
5921
|
if (typeof transcriptPath !== "string")
|
|
6205
5922
|
return false;
|
|
6206
5923
|
try {
|
|
6207
|
-
return hasContextPressureMarker(
|
|
5924
|
+
return hasContextPressureMarker(readFileSync9(transcriptPath, "utf8"));
|
|
6208
5925
|
} catch (error) {
|
|
6209
5926
|
if (error instanceof Error)
|
|
6210
5927
|
return false;
|
|
@@ -6287,14 +6004,14 @@ main().catch((error) => {
|
|
|
6287
6004
|
async function runPackageLspMcpCli() {
|
|
6288
6005
|
const cliPath = resolveLspDaemonCliPath();
|
|
6289
6006
|
const child = spawn3(execPath2, [cliPath, "mcp"], { stdio: "inherit", windowsHide: true });
|
|
6290
|
-
await new Promise((
|
|
6007
|
+
await new Promise((resolve10, reject) => {
|
|
6291
6008
|
child.once("error", reject);
|
|
6292
6009
|
child.once("exit", (code, signal) => {
|
|
6293
6010
|
if (code !== null && code !== 0)
|
|
6294
6011
|
process.exitCode = code;
|
|
6295
6012
|
if (code === null && signal !== null)
|
|
6296
6013
|
process.exitCode = 1;
|
|
6297
|
-
|
|
6014
|
+
resolve10();
|
|
6298
6015
|
});
|
|
6299
6016
|
});
|
|
6300
6017
|
}
|