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
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// src/client.ts
|
|
2
|
-
import { statSync as statSync5 } from "node:fs";
|
|
3
|
-
import { isAbsolute as isAbsolute6 } from "node:path";
|
|
4
|
-
|
|
5
1
|
// src/daemon-client.ts
|
|
6
2
|
import { connect } from "node:net";
|
|
7
3
|
import { homedir as homedir3 } from "node:os";
|
|
@@ -1143,7 +1139,7 @@ function createIdleTimer(idleTimeoutMs, log, onTimeout) {
|
|
|
1143
1139
|
}
|
|
1144
1140
|
// ../lsp-core/src/lsp/client-wrapper.ts
|
|
1145
1141
|
import { existsSync as existsSync11, realpathSync as realpathSync5, statSync as statSync4 } from "node:fs";
|
|
1146
|
-
import { basename as basename3, dirname as
|
|
1142
|
+
import { basename as basename3, dirname as dirname9, join as join5, resolve as resolve7 } from "node:path";
|
|
1147
1143
|
|
|
1148
1144
|
// ../lsp-core/src/lsp/effective-extension.ts
|
|
1149
1145
|
import { basename as basename2, extname } from "node:path";
|
|
@@ -1247,7 +1243,6 @@ var DEFAULT_MAX_DIRECTORY_FILES = 50;
|
|
|
1247
1243
|
var REQUEST_TIMEOUT_MS = 15000;
|
|
1248
1244
|
var INIT_TIMEOUT_MS = 60000;
|
|
1249
1245
|
var IDLE_TIMEOUT_MS = 5 * 60000;
|
|
1250
|
-
var MAX_RESIDENT_CLIENTS = 6;
|
|
1251
1246
|
var REAPER_INTERVAL_MS = 60000;
|
|
1252
1247
|
var STOP_HARD_KILL_TIMEOUT_MS = 5000;
|
|
1253
1248
|
var STOP_SIGKILL_GRACE_MS = 1000;
|
|
@@ -1773,7 +1768,6 @@ class LspClientTransport {
|
|
|
1773
1768
|
this.diagnosticsStore = new Map;
|
|
1774
1769
|
this.workspaceApplyEditHandler = null;
|
|
1775
1770
|
this.diagnosticPullSupported = false;
|
|
1776
|
-
this.documentFormattingSupported = false;
|
|
1777
1771
|
this.requestTimeoutMs = timeouts.requestTimeoutMs ?? REQUEST_TIMEOUT_MS;
|
|
1778
1772
|
this.initializeTimeoutMs = timeouts.initializeTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
1779
1773
|
}
|
|
@@ -1795,12 +1789,6 @@ class LspClientTransport {
|
|
|
1795
1789
|
isDiagnosticPullSupported() {
|
|
1796
1790
|
return this.diagnosticPullSupported;
|
|
1797
1791
|
}
|
|
1798
|
-
setDocumentFormattingSupported(supported) {
|
|
1799
|
-
this.documentFormattingSupported = supported;
|
|
1800
|
-
}
|
|
1801
|
-
isDocumentFormattingSupported() {
|
|
1802
|
-
return this.documentFormattingSupported;
|
|
1803
|
-
}
|
|
1804
1792
|
handlePublishDiagnostics(params) {
|
|
1805
1793
|
this.diagnosticsStore.set(params.uri, [...params.diagnostics]);
|
|
1806
1794
|
}
|
|
@@ -2014,14 +2002,6 @@ function supportsDiagnosticPull(capabilities) {
|
|
|
2014
2002
|
return false;
|
|
2015
2003
|
return Object.hasOwn(capabilities, "diagnosticProvider");
|
|
2016
2004
|
}
|
|
2017
|
-
function supportsDocumentFormatting(capabilities) {
|
|
2018
|
-
if (capabilities === undefined)
|
|
2019
|
-
return false;
|
|
2020
|
-
const provider = capabilities.documentFormattingProvider;
|
|
2021
|
-
if (provider === undefined || provider === null || provider === false)
|
|
2022
|
-
return false;
|
|
2023
|
-
return provider === true || typeof provider === "object";
|
|
2024
|
-
}
|
|
2025
2005
|
|
|
2026
2006
|
class LspClientConnection extends LspClientTransport {
|
|
2027
2007
|
async initialize() {
|
|
@@ -2038,7 +2018,6 @@ class LspClientConnection extends LspClientTransport {
|
|
|
2038
2018
|
references: {},
|
|
2039
2019
|
documentSymbol: { hierarchicalDocumentSymbolSupport: true },
|
|
2040
2020
|
publishDiagnostics: {},
|
|
2041
|
-
formatting: { dynamicRegistration: false },
|
|
2042
2021
|
rename: {
|
|
2043
2022
|
prepareSupport: true,
|
|
2044
2023
|
prepareSupportDefaultBehavior: 1
|
|
@@ -2080,7 +2059,6 @@ class LspClientConnection extends LspClientTransport {
|
|
|
2080
2059
|
initializationOptions: this.server.initialization
|
|
2081
2060
|
}, { timeoutMs: this.initializeTimeoutMs });
|
|
2082
2061
|
this.setDiagnosticPullSupported(supportsDiagnosticPull(result?.capabilities));
|
|
2083
|
-
this.setDocumentFormattingSupported(supportsDocumentFormatting(result?.capabilities));
|
|
2084
2062
|
await this.sendNotification("initialized", {});
|
|
2085
2063
|
await this.sendNotification("workspace/didChangeConfiguration", {
|
|
2086
2064
|
settings: { json: { validate: { enable: true } } }
|
|
@@ -3665,18 +3643,6 @@ class LspClient extends LspClientConnection {
|
|
|
3665
3643
|
textDocument: { uri: pathToFileURL3(absPath).href }
|
|
3666
3644
|
}, options);
|
|
3667
3645
|
}
|
|
3668
|
-
async formatDocument(filePath, options, signal) {
|
|
3669
|
-
if (!this.isDocumentFormattingSupported())
|
|
3670
|
-
return null;
|
|
3671
|
-
const absPath = this.resolveWorkspacePath(filePath);
|
|
3672
|
-
await this.openFile(absPath);
|
|
3673
|
-
const requestOptions = signal === undefined ? {} : { signal };
|
|
3674
|
-
const edits = await this.sendRequest("textDocument/formatting", {
|
|
3675
|
-
textDocument: { uri: pathToFileURL3(absPath).href },
|
|
3676
|
-
options
|
|
3677
|
-
}, requestOptions);
|
|
3678
|
-
return edits ?? [];
|
|
3679
|
-
}
|
|
3680
3646
|
async workspaceSymbols(query, signal) {
|
|
3681
3647
|
const options = signal === undefined ? {} : { signal };
|
|
3682
3648
|
return this.sendRequest("workspace/symbol", { query }, options);
|
|
@@ -3929,7 +3895,6 @@ class LspManager {
|
|
|
3929
3895
|
this.disposed = false;
|
|
3930
3896
|
this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS;
|
|
3931
3897
|
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
3932
|
-
this.maxResidentClients = options.maxResidentClients ?? MAX_RESIDENT_CLIENTS;
|
|
3933
3898
|
this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
|
|
3934
3899
|
this.clientFactory = options.clientFactory ?? ((root, server2) => new LspClient(root, server2));
|
|
3935
3900
|
this.now = options.now ?? (() => Date.now());
|
|
@@ -3963,26 +3928,6 @@ class LspManager {
|
|
|
3963
3928
|
}
|
|
3964
3929
|
}
|
|
3965
3930
|
}
|
|
3966
|
-
evictForAdmission() {
|
|
3967
|
-
while (this.clients.size >= this.maxResidentClients) {
|
|
3968
|
-
const victim = this.leastRecentlyUsedIdleClient();
|
|
3969
|
-
if (!victim)
|
|
3970
|
-
return;
|
|
3971
|
-
this.clients.delete(victim.key);
|
|
3972
|
-
stopClientBestEffort(victim.managed.client);
|
|
3973
|
-
}
|
|
3974
|
-
}
|
|
3975
|
-
leastRecentlyUsedIdleClient() {
|
|
3976
|
-
let candidate = null;
|
|
3977
|
-
for (const [key, managed] of this.clients) {
|
|
3978
|
-
if (managed.refCount > 0 || managed.pendingWaiters > 0 || managed.isInitializing)
|
|
3979
|
-
continue;
|
|
3980
|
-
if (candidate === null || managed.lastUsedAt < candidate.managed.lastUsedAt) {
|
|
3981
|
-
candidate = { key, managed };
|
|
3982
|
-
}
|
|
3983
|
-
}
|
|
3984
|
-
return candidate;
|
|
3985
|
-
}
|
|
3986
3931
|
async tryDeleteIfOrphaned(key, managed) {
|
|
3987
3932
|
if (managed.refCount === 0 && managed.pendingWaiters === 0 && !managed.isInitializing && this.clients.get(key) === managed) {
|
|
3988
3933
|
this.clients.delete(key);
|
|
@@ -4029,7 +3974,6 @@ class LspManager {
|
|
|
4029
3974
|
managed.lastUsedAt = this.now();
|
|
4030
3975
|
return managed.client;
|
|
4031
3976
|
}
|
|
4032
|
-
this.evictForAdmission();
|
|
4033
3977
|
const client = this.clientFactory(root, server2);
|
|
4034
3978
|
const initStartedAt = this.now();
|
|
4035
3979
|
const initPromise = (async () => {
|
|
@@ -4092,7 +4036,6 @@ class LspManager {
|
|
|
4092
4036
|
const key = this.getKey(root, server2.id);
|
|
4093
4037
|
if (this.clients.has(key))
|
|
4094
4038
|
return;
|
|
4095
|
-
this.evictForAdmission();
|
|
4096
4039
|
const client = this.clientFactory(root, server2);
|
|
4097
4040
|
const initStartedAt = this.now();
|
|
4098
4041
|
const initPromise = (async () => {
|
|
@@ -4218,6 +4161,57 @@ function nearestExistingAncestor(directory) {
|
|
|
4218
4161
|
return current;
|
|
4219
4162
|
}
|
|
4220
4163
|
|
|
4164
|
+
// ../lsp-core/src/lsp/server-install-state.ts
|
|
4165
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
4166
|
+
import { dirname as dirname8 } from "node:path";
|
|
4167
|
+
function getInstallDecisionsPath() {
|
|
4168
|
+
return lspRequestContext().installDecisionsPath;
|
|
4169
|
+
}
|
|
4170
|
+
function loadInstallDecisions() {
|
|
4171
|
+
const path2 = getInstallDecisionsPath();
|
|
4172
|
+
if (!existsSync8(path2))
|
|
4173
|
+
return {};
|
|
4174
|
+
try {
|
|
4175
|
+
const parsed = JSON.parse(readFileSync4(path2, "utf8"));
|
|
4176
|
+
return isInstallDecisions(parsed) ? parsed : {};
|
|
4177
|
+
} catch {
|
|
4178
|
+
return {};
|
|
4179
|
+
}
|
|
4180
|
+
}
|
|
4181
|
+
function loadInstallDecision(serverId) {
|
|
4182
|
+
return loadInstallDecisions()[serverId];
|
|
4183
|
+
}
|
|
4184
|
+
function recordInstallDecision(serverId, decision, decidedAt = new Date().toISOString()) {
|
|
4185
|
+
const decisions = loadInstallDecisions();
|
|
4186
|
+
decisions[serverId] = { decision, decidedAt };
|
|
4187
|
+
writeInstallDecisions(decisions);
|
|
4188
|
+
}
|
|
4189
|
+
function isInstallDecision(value) {
|
|
4190
|
+
return value === "declined" || value === "allowed";
|
|
4191
|
+
}
|
|
4192
|
+
function writeInstallDecisions(decisions) {
|
|
4193
|
+
const path2 = getInstallDecisionsPath();
|
|
4194
|
+
mkdirSync3(dirname8(path2), { recursive: true });
|
|
4195
|
+
const tmpPath = `${path2}.tmp`;
|
|
4196
|
+
writeFileSync2(tmpPath, `${JSON.stringify(decisions, null, 2)}
|
|
4197
|
+
`, "utf8");
|
|
4198
|
+
renameSync2(tmpPath, path2);
|
|
4199
|
+
}
|
|
4200
|
+
function isInstallDecisions(value) {
|
|
4201
|
+
return isRecord5(value) && Object.values(value).every(isInstallDecisionRecord);
|
|
4202
|
+
}
|
|
4203
|
+
function isInstallDecisionRecord(value) {
|
|
4204
|
+
if (!isRecord5(value))
|
|
4205
|
+
return false;
|
|
4206
|
+
return isInstallDecision(value["decision"]) && typeof value["decidedAt"] === "string";
|
|
4207
|
+
}
|
|
4208
|
+
function isRecord5(value) {
|
|
4209
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4210
|
+
}
|
|
4211
|
+
|
|
4212
|
+
// ../lsp-core/src/lsp/config-loader.ts
|
|
4213
|
+
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
|
|
4214
|
+
|
|
4221
4215
|
// ../lsp-core/src/lsp/server-definitions.ts
|
|
4222
4216
|
var LSP_INSTALL_HINTS = {
|
|
4223
4217
|
typescript: "npm install -g typescript-language-server typescript",
|
|
@@ -4263,26 +4257,6 @@ var LSP_INSTALL_HINTS = {
|
|
|
4263
4257
|
julials: `julia -e 'using Pkg; Pkg.add("LanguageServer")'`,
|
|
4264
4258
|
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"
|
|
4265
4259
|
};
|
|
4266
|
-
var LSP_LOCAL_INSTALL_HINTS = {
|
|
4267
|
-
typescript: "bun add -d typescript-language-server typescript",
|
|
4268
|
-
vue: "bun add -d @vue/language-server",
|
|
4269
|
-
eslint: "bun add -d vscode-langservers-extracted",
|
|
4270
|
-
oxlint: "bun add -d oxlint",
|
|
4271
|
-
biome: "bun add -d @biomejs/biome",
|
|
4272
|
-
svelte: "bun add -d svelte-language-server",
|
|
4273
|
-
astro: "bun add -d @astrojs/language-server",
|
|
4274
|
-
bash: "bun add -d bash-language-server",
|
|
4275
|
-
"bash-ls": "bun add -d bash-language-server",
|
|
4276
|
-
"yaml-ls": "bun add -d yaml-language-server",
|
|
4277
|
-
php: "bun add -d intelephense",
|
|
4278
|
-
prisma: "bun add -d prisma",
|
|
4279
|
-
dockerfile: "bun add -d dockerfile-language-server-nodejs",
|
|
4280
|
-
pyright: "uv add --dev pyright",
|
|
4281
|
-
basedpyright: "uv add --dev basedpyright",
|
|
4282
|
-
ruff: "uv add --dev ruff",
|
|
4283
|
-
ty: "uv add --dev ty",
|
|
4284
|
-
"ruby-lsp": "bundle add ruby-lsp --group development"
|
|
4285
|
-
};
|
|
4286
4260
|
var BUILTIN_SERVERS = {
|
|
4287
4261
|
typescript: {
|
|
4288
4262
|
command: ["typescript-language-server", "--stdio"],
|
|
@@ -4385,56 +4359,7 @@ var BUILTIN_SERVERS = {
|
|
|
4385
4359
|
}
|
|
4386
4360
|
};
|
|
4387
4361
|
|
|
4388
|
-
// ../lsp-core/src/lsp/server-install-state.ts
|
|
4389
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
4390
|
-
import { dirname as dirname8 } from "node:path";
|
|
4391
|
-
function getInstallDecisionsPath() {
|
|
4392
|
-
return lspRequestContext().installDecisionsPath;
|
|
4393
|
-
}
|
|
4394
|
-
function loadInstallDecisions() {
|
|
4395
|
-
const path2 = getInstallDecisionsPath();
|
|
4396
|
-
if (!existsSync8(path2))
|
|
4397
|
-
return {};
|
|
4398
|
-
try {
|
|
4399
|
-
const parsed = JSON.parse(readFileSync4(path2, "utf8"));
|
|
4400
|
-
return isInstallDecisions(parsed) ? parsed : {};
|
|
4401
|
-
} catch {
|
|
4402
|
-
return {};
|
|
4403
|
-
}
|
|
4404
|
-
}
|
|
4405
|
-
function loadInstallDecision(serverId) {
|
|
4406
|
-
return loadInstallDecisions()[serverId];
|
|
4407
|
-
}
|
|
4408
|
-
function recordInstallDecision(serverId, decision, decidedAt = new Date().toISOString()) {
|
|
4409
|
-
const decisions = loadInstallDecisions();
|
|
4410
|
-
decisions[serverId] = { decision, decidedAt };
|
|
4411
|
-
writeInstallDecisions(decisions);
|
|
4412
|
-
}
|
|
4413
|
-
function isInstallDecision(value) {
|
|
4414
|
-
return value === "declined" || value === "allowed";
|
|
4415
|
-
}
|
|
4416
|
-
function writeInstallDecisions(decisions) {
|
|
4417
|
-
const path2 = getInstallDecisionsPath();
|
|
4418
|
-
mkdirSync3(dirname8(path2), { recursive: true });
|
|
4419
|
-
const tmpPath = `${path2}.tmp`;
|
|
4420
|
-
writeFileSync2(tmpPath, `${JSON.stringify(decisions, null, 2)}
|
|
4421
|
-
`, "utf8");
|
|
4422
|
-
renameSync2(tmpPath, path2);
|
|
4423
|
-
}
|
|
4424
|
-
function isInstallDecisions(value) {
|
|
4425
|
-
return isRecord5(value) && Object.values(value).every(isInstallDecisionRecord);
|
|
4426
|
-
}
|
|
4427
|
-
function isInstallDecisionRecord(value) {
|
|
4428
|
-
if (!isRecord5(value))
|
|
4429
|
-
return false;
|
|
4430
|
-
return isInstallDecision(value["decision"]) && typeof value["decidedAt"] === "string";
|
|
4431
|
-
}
|
|
4432
|
-
function isRecord5(value) {
|
|
4433
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4434
|
-
}
|
|
4435
|
-
|
|
4436
4362
|
// ../lsp-core/src/lsp/config-loader.ts
|
|
4437
|
-
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
|
|
4438
4363
|
function getProjectConfigPaths() {
|
|
4439
4364
|
return lspRequestContext().projectConfigPaths;
|
|
4440
4365
|
}
|
|
@@ -4631,154 +4556,53 @@ function getDisabledServerIds() {
|
|
|
4631
4556
|
|
|
4632
4557
|
// ../lsp-core/src/lsp/server-installation.ts
|
|
4633
4558
|
import { existsSync as existsSync10 } from "node:fs";
|
|
4634
|
-
import { delimiter as delimiter3,
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
"requirements.txt",
|
|
4645
|
-
"setup.py",
|
|
4646
|
-
"setup.cfg",
|
|
4647
|
-
"Pipfile",
|
|
4648
|
-
"pyrightconfig.json",
|
|
4649
|
-
"ruff.toml",
|
|
4650
|
-
".ruff.toml"
|
|
4651
|
-
],
|
|
4652
|
-
binDirs: [
|
|
4653
|
-
join4(".venv", "bin"),
|
|
4654
|
-
join4(".venv", "Scripts"),
|
|
4655
|
-
join4("venv", "bin"),
|
|
4656
|
-
join4("venv", "Scripts"),
|
|
4657
|
-
join4(".env", "bin"),
|
|
4658
|
-
join4(".env", "Scripts")
|
|
4659
|
-
]
|
|
4660
|
-
},
|
|
4661
|
-
{
|
|
4662
|
-
markers: ["Gemfile", "Gemfile.lock"],
|
|
4663
|
-
binDirs: [join4("vendor", "bundle", "bin"), "bin"]
|
|
4664
|
-
},
|
|
4665
|
-
{
|
|
4666
|
-
markers: ["go.mod", "go.sum", "go.work"],
|
|
4667
|
-
binDirs: ["bin"]
|
|
4668
|
-
}
|
|
4669
|
-
];
|
|
4670
|
-
var resolutionCache = new Map;
|
|
4671
|
-
var probeCount = 0;
|
|
4672
|
-
function probe(path2) {
|
|
4673
|
-
probeCount += 1;
|
|
4674
|
-
return existsSync10(path2);
|
|
4675
|
-
}
|
|
4676
|
-
function executableSuffixes(platform, pathExt) {
|
|
4677
|
-
if (platform !== "win32")
|
|
4678
|
-
return [""];
|
|
4679
|
-
const configured = pathExt ?? process.env["PATHEXT"] ?? "";
|
|
4680
|
-
const systemExts = configured.split(";").filter((entry) => entry.length > 0).map((entry) => entry.toLowerCase());
|
|
4681
|
-
return [...new Set(["", ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])];
|
|
4682
|
-
}
|
|
4683
|
-
function probeWithSuffixes(directory, command, suffixes) {
|
|
4684
|
-
for (const suffix of suffixes) {
|
|
4685
|
-
const candidate = join4(directory, command + suffix);
|
|
4686
|
-
if (probe(candidate))
|
|
4687
|
-
return candidate;
|
|
4559
|
+
import { delimiter as delimiter3, join as join4 } from "node:path";
|
|
4560
|
+
function isServerInstalled(command, _workingDirectory) {
|
|
4561
|
+
if (command.length === 0)
|
|
4562
|
+
return false;
|
|
4563
|
+
const [cmd] = command;
|
|
4564
|
+
if (!cmd)
|
|
4565
|
+
return false;
|
|
4566
|
+
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
4567
|
+
if (existsSync10(cmd))
|
|
4568
|
+
return true;
|
|
4688
4569
|
}
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
for (const binDir of rule.binDirs) {
|
|
4699
|
-
const found = probeWithSuffixes(join4(current, binDir), command, suffixes);
|
|
4700
|
-
if (found !== null)
|
|
4701
|
-
return found;
|
|
4702
|
-
}
|
|
4570
|
+
const isWindows = process.platform === "win32";
|
|
4571
|
+
let exts = [""];
|
|
4572
|
+
if (isWindows) {
|
|
4573
|
+
const pathExt = process.env["PATHEXT"] ?? "";
|
|
4574
|
+
if (pathExt) {
|
|
4575
|
+
const systemExts = pathExt.split(";").filter(Boolean);
|
|
4576
|
+
exts = [...new Set([...exts, ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])];
|
|
4577
|
+
} else {
|
|
4578
|
+
exts = ["", ".exe", ".cmd", ".bat", ".ps1"];
|
|
4703
4579
|
}
|
|
4704
|
-
if (probe(join4(current, ".git")))
|
|
4705
|
-
return null;
|
|
4706
|
-
if (boundary !== undefined && current === boundary)
|
|
4707
|
-
return null;
|
|
4708
|
-
const parent = dirname9(current);
|
|
4709
|
-
if (parent === current)
|
|
4710
|
-
return null;
|
|
4711
|
-
current = parent;
|
|
4712
4580
|
}
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
let pathEnv = pathEnvOverride ?? process.env["PATH"] ?? "";
|
|
4716
|
-
if (platform === "win32" && !pathEnv) {
|
|
4581
|
+
let pathEnv = process.env["PATH"] ?? "";
|
|
4582
|
+
if (isWindows && !pathEnv) {
|
|
4717
4583
|
pathEnv = process.env["Path"] ?? "";
|
|
4718
4584
|
}
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4585
|
+
const paths = pathEnv.split(delimiter3);
|
|
4586
|
+
for (const p of paths) {
|
|
4587
|
+
for (const suffix of exts) {
|
|
4588
|
+
if (existsSync10(join4(p, cmd + suffix))) {
|
|
4589
|
+
return true;
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4725
4592
|
}
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
if (command.length === 0)
|
|
4730
|
-
return null;
|
|
4731
|
-
const [cmd] = command;
|
|
4732
|
-
if (cmd === undefined || cmd.length === 0)
|
|
4733
|
-
return null;
|
|
4734
|
-
const platform = options.platform ?? process.platform;
|
|
4735
|
-
const suffixes = executableSuffixes(platform, options.pathExt);
|
|
4736
|
-
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
4737
|
-
const explicit = isAbsolute5(cmd) ? cmd : resolve7(workingDirectory ?? process.cwd(), cmd);
|
|
4738
|
-
return probe(explicit) ? explicit : null;
|
|
4739
|
-
}
|
|
4740
|
-
const cacheKey = JSON.stringify([
|
|
4741
|
-
workingDirectory ?? "",
|
|
4742
|
-
cmd,
|
|
4743
|
-
platform,
|
|
4744
|
-
options.stopAt ?? "",
|
|
4745
|
-
options.pathExt ?? "",
|
|
4746
|
-
options.pathEnv ?? process.env["PATH"] ?? ""
|
|
4747
|
-
]);
|
|
4748
|
-
const cached = resolutionCache.get(cacheKey);
|
|
4749
|
-
if (cached !== undefined)
|
|
4750
|
-
return cached;
|
|
4751
|
-
let resolved = null;
|
|
4752
|
-
if (workingDirectory !== undefined && workingDirectory.length > 0) {
|
|
4753
|
-
resolved = resolveLocal(cmd, workingDirectory, suffixes, options.stopAt);
|
|
4754
|
-
}
|
|
4755
|
-
resolved ??= resolveFromPath(cmd, suffixes, platform, options.pathEnv);
|
|
4756
|
-
if (resolved === null && cmd === "node")
|
|
4757
|
-
resolved = cmd;
|
|
4758
|
-
resolutionCache.set(cacheKey, resolved);
|
|
4759
|
-
return resolved;
|
|
4760
|
-
}
|
|
4761
|
-
function isServerInstalled(command, workingDirectory, options = {}) {
|
|
4762
|
-
if (command.length === 0)
|
|
4763
|
-
return false;
|
|
4764
|
-
return resolveServerBinary(command, workingDirectory, options) !== null;
|
|
4593
|
+
if (cmd === "node")
|
|
4594
|
+
return true;
|
|
4595
|
+
return false;
|
|
4765
4596
|
}
|
|
4766
4597
|
|
|
4767
4598
|
// ../lsp-core/src/lsp/server-resolution.ts
|
|
4768
|
-
function withResolvedCommand(command, binaryPath) {
|
|
4769
|
-
return [binaryPath, ...command.slice(1)];
|
|
4770
|
-
}
|
|
4771
4599
|
function findServerForExtension(ext) {
|
|
4772
4600
|
const servers = getMergedServers();
|
|
4773
|
-
const workingDirectory = contextCwd();
|
|
4774
4601
|
for (const server2 of servers) {
|
|
4775
|
-
if (
|
|
4776
|
-
continue;
|
|
4777
|
-
const binaryPath = resolveServerBinary(server2.command, workingDirectory);
|
|
4778
|
-
if (binaryPath !== null) {
|
|
4602
|
+
if (server2.extensions.includes(ext) && isServerInstalled(server2.command)) {
|
|
4779
4603
|
const resolvedServer = {
|
|
4780
4604
|
id: server2.id,
|
|
4781
|
-
command:
|
|
4605
|
+
command: server2.command,
|
|
4782
4606
|
extensions: server2.extensions,
|
|
4783
4607
|
priority: server2.priority
|
|
4784
4608
|
};
|
|
@@ -4825,7 +4649,6 @@ function findServerForExtension(ext) {
|
|
|
4825
4649
|
function getAllServers() {
|
|
4826
4650
|
const servers = getMergedServers();
|
|
4827
4651
|
const disabled = getDisabledServerIds();
|
|
4828
|
-
const workingDirectory = contextCwd();
|
|
4829
4652
|
const result = [];
|
|
4830
4653
|
const seen = new Set;
|
|
4831
4654
|
for (const server2 of servers) {
|
|
@@ -4833,7 +4656,7 @@ function getAllServers() {
|
|
|
4833
4656
|
continue;
|
|
4834
4657
|
result.push({
|
|
4835
4658
|
id: server2.id,
|
|
4836
|
-
installed: isServerInstalled(server2.command
|
|
4659
|
+
installed: isServerInstalled(server2.command),
|
|
4837
4660
|
extensions: server2.extensions,
|
|
4838
4661
|
disabled: false,
|
|
4839
4662
|
source: server2.source,
|
|
@@ -4847,7 +4670,7 @@ function getAllServers() {
|
|
|
4847
4670
|
const builtin = BUILTIN_SERVERS[id];
|
|
4848
4671
|
result.push({
|
|
4849
4672
|
id,
|
|
4850
|
-
installed: builtin ? isServerInstalled(builtin.command
|
|
4673
|
+
installed: builtin ? isServerInstalled(builtin.command) : false,
|
|
4851
4674
|
extensions: builtin?.extensions ?? [],
|
|
4852
4675
|
disabled: true,
|
|
4853
4676
|
source: "disabled",
|
|
@@ -4870,7 +4693,7 @@ function findWorkspaceRoot(filePath) {
|
|
|
4870
4693
|
const abs = resolveReadablePathInsideContext(filePath);
|
|
4871
4694
|
let dir = abs;
|
|
4872
4695
|
if (!isDirectoryPath(dir)) {
|
|
4873
|
-
dir =
|
|
4696
|
+
dir = dirname9(dir);
|
|
4874
4697
|
}
|
|
4875
4698
|
if (!isPathInside(cwd, abs))
|
|
4876
4699
|
return findWorkspaceRootOutsideContext(dir);
|
|
@@ -4886,13 +4709,13 @@ function findWorkspaceRoot(filePath) {
|
|
|
4886
4709
|
}
|
|
4887
4710
|
if (dir === cwd)
|
|
4888
4711
|
break;
|
|
4889
|
-
dir =
|
|
4712
|
+
dir = dirname9(dir);
|
|
4890
4713
|
}
|
|
4891
4714
|
return fallbackRoot;
|
|
4892
4715
|
}
|
|
4893
4716
|
function resolveReadablePathInsideContext(filePath) {
|
|
4894
4717
|
const cwd = contextCwd();
|
|
4895
|
-
const abs =
|
|
4718
|
+
const abs = resolve7(cwd, filePath);
|
|
4896
4719
|
if (isPathInside(cwd, abs))
|
|
4897
4720
|
return abs;
|
|
4898
4721
|
const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
|
|
@@ -4918,7 +4741,7 @@ function rebaseThroughCanonicalAncestor(path2, cwd) {
|
|
|
4918
4741
|
if (isPathInside(cwd, canonical))
|
|
4919
4742
|
return suffix.length === 0 ? canonical : join5(canonical, ...suffix);
|
|
4920
4743
|
}
|
|
4921
|
-
const parent =
|
|
4744
|
+
const parent = dirname9(current);
|
|
4922
4745
|
if (parent === current)
|
|
4923
4746
|
return;
|
|
4924
4747
|
suffix.unshift(basename3(current));
|
|
@@ -4941,7 +4764,7 @@ function nearestExistingDirectoryInsideContext(directory, cwd) {
|
|
|
4941
4764
|
return canonical;
|
|
4942
4765
|
if (current === cwd)
|
|
4943
4766
|
return;
|
|
4944
|
-
current =
|
|
4767
|
+
current = dirname9(current);
|
|
4945
4768
|
}
|
|
4946
4769
|
return;
|
|
4947
4770
|
}
|
|
@@ -4968,19 +4791,6 @@ function formatServerLookupError(result) {
|
|
|
4968
4791
|
].join(`
|
|
4969
4792
|
`);
|
|
4970
4793
|
}
|
|
4971
|
-
function formatInstallOptions(serverId, installHint) {
|
|
4972
|
-
const localHint = LSP_LOCAL_INSTALL_HINTS[serverId];
|
|
4973
|
-
if (localHint === undefined) {
|
|
4974
|
-
return ["To install, run:", ` ${installHint}`];
|
|
4975
|
-
}
|
|
4976
|
-
return [
|
|
4977
|
-
"To install in THIS repository (preferred — no global install needed):",
|
|
4978
|
-
` ${localHint}`,
|
|
4979
|
-
"",
|
|
4980
|
-
"Or install it globally:",
|
|
4981
|
-
` ${installHint}`
|
|
4982
|
-
];
|
|
4983
|
-
}
|
|
4984
4794
|
function formatNotInstalled(result) {
|
|
4985
4795
|
const { server: server2, installHint } = result;
|
|
4986
4796
|
const extensions = server2.extensions.join(", ");
|
|
@@ -4995,19 +4805,19 @@ function formatNotInstalled(result) {
|
|
|
4995
4805
|
`Command not found: ${server2.command[0]}`,
|
|
4996
4806
|
""
|
|
4997
4807
|
];
|
|
4998
|
-
const installOptions = formatInstallOptions(server2.id, installHint);
|
|
4999
4808
|
if (decision === "allowed") {
|
|
5000
4809
|
return [
|
|
5001
4810
|
...header,
|
|
5002
4811
|
"The user has pre-authorized LSP installation. Run the install command, then retry this tool:",
|
|
5003
|
-
|
|
4812
|
+
` ${installHint}`
|
|
5004
4813
|
].join(`
|
|
5005
4814
|
`);
|
|
5006
4815
|
}
|
|
5007
4816
|
if (!context.capabilities.installDecisionTool) {
|
|
5008
4817
|
return [
|
|
5009
4818
|
...header,
|
|
5010
|
-
|
|
4819
|
+
"To install, run:",
|
|
4820
|
+
` ${installHint}`,
|
|
5011
4821
|
"",
|
|
5012
4822
|
"ACTION REQUIRED — ASK THE USER whether to install this LSP server.",
|
|
5013
4823
|
"Install-decision recording is unavailable in this harness; proceed without LSP if the user declines."
|
|
@@ -5016,7 +4826,8 @@ function formatNotInstalled(result) {
|
|
|
5016
4826
|
}
|
|
5017
4827
|
return [
|
|
5018
4828
|
...header,
|
|
5019
|
-
|
|
4829
|
+
"To install, run:",
|
|
4830
|
+
` ${installHint}`,
|
|
5020
4831
|
"",
|
|
5021
4832
|
"ACTION REQUIRED — ASK THE USER whether to install this LSP server.",
|
|
5022
4833
|
"- If the user agrees: run the install command above, then retry this tool.",
|
|
@@ -5072,7 +4883,7 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
|
5072
4883
|
|
|
5073
4884
|
// ../lsp-core/src/lsp/directory-diagnostics.ts
|
|
5074
4885
|
import { existsSync as existsSync12, lstatSync as lstatSync5, readdirSync as readdirSync3 } from "node:fs";
|
|
5075
|
-
import { join as join6, resolve as
|
|
4886
|
+
import { join as join6, resolve as resolve8 } from "node:path";
|
|
5076
4887
|
|
|
5077
4888
|
// ../lsp-core/src/lsp/formatters.ts
|
|
5078
4889
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -5227,7 +5038,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
5227
5038
|
if (!extension.startsWith(".")) {
|
|
5228
5039
|
throw new LspInvalidPathError(`Extension must start with a dot (e.g., ".ts", not "${extension}"). Use ".${extension}" instead.`);
|
|
5229
5040
|
}
|
|
5230
|
-
const absDir =
|
|
5041
|
+
const absDir = resolve8(options.workspaceRoot ?? contextCwd(), directory);
|
|
5231
5042
|
if (!existsSync12(absDir)) {
|
|
5232
5043
|
throw new LspInvalidPathError(`Directory does not exist: ${absDir}`);
|
|
5233
5044
|
}
|
|
@@ -5584,96 +5395,6 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
5584
5395
|
throw error;
|
|
5585
5396
|
}
|
|
5586
5397
|
}
|
|
5587
|
-
// ../lsp-core/src/lsp/format-document.ts
|
|
5588
|
-
import { readFileSync as readFileSync6, renameSync as renameSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
5589
|
-
var DEFAULT_FORMATTING_OPTIONS = {
|
|
5590
|
-
tabSize: 4,
|
|
5591
|
-
insertSpaces: false,
|
|
5592
|
-
trimTrailingWhitespace: true,
|
|
5593
|
-
insertFinalNewline: true,
|
|
5594
|
-
trimFinalNewlines: true
|
|
5595
|
-
};
|
|
5596
|
-
var UNCHANGED = { status: "unchanged", linesAdded: 0, linesRemoved: 0 };
|
|
5597
|
-
async function formatDocumentWithClient(client, filePath, options = {}) {
|
|
5598
|
-
const edits = await client.formatDocument(filePath, options.formattingOptions ?? DEFAULT_FORMATTING_OPTIONS, options.signal);
|
|
5599
|
-
if (edits === null)
|
|
5600
|
-
return { status: "unavailable", reason: "capability_not_advertised" };
|
|
5601
|
-
if (edits.length === 0)
|
|
5602
|
-
return UNCHANGED;
|
|
5603
|
-
const before = readFileSync6(filePath, "utf-8");
|
|
5604
|
-
const normalized = normalizeTextEdits(before, edits, 0);
|
|
5605
|
-
if (normalized.text === before)
|
|
5606
|
-
return UNCHANGED;
|
|
5607
|
-
writeAtomically(filePath, normalized.text);
|
|
5608
|
-
await client.openFile(filePath);
|
|
5609
|
-
return {
|
|
5610
|
-
status: "formatted",
|
|
5611
|
-
...lineDelta(normalized.edits)
|
|
5612
|
-
};
|
|
5613
|
-
}
|
|
5614
|
-
function lineDelta(edits) {
|
|
5615
|
-
let linesAdded = 0;
|
|
5616
|
-
let linesRemoved = 0;
|
|
5617
|
-
for (const edit of edits) {
|
|
5618
|
-
linesRemoved += edit.range.end.line - edit.range.start.line + 1;
|
|
5619
|
-
linesAdded += edit.newText.split(`
|
|
5620
|
-
`).length;
|
|
5621
|
-
}
|
|
5622
|
-
return { linesAdded, linesRemoved };
|
|
5623
|
-
}
|
|
5624
|
-
function writeAtomically(filePath, content) {
|
|
5625
|
-
const tempPath = `${filePath}.omo-format.tmp`;
|
|
5626
|
-
writeFileSync3(tempPath, content, "utf-8");
|
|
5627
|
-
try {
|
|
5628
|
-
renameSync3(tempPath, filePath);
|
|
5629
|
-
} catch (error) {
|
|
5630
|
-
try {
|
|
5631
|
-
unlinkSync2(tempPath);
|
|
5632
|
-
} catch {}
|
|
5633
|
-
throw error;
|
|
5634
|
-
}
|
|
5635
|
-
}
|
|
5636
|
-
|
|
5637
|
-
// ../lsp-core/src/tools/format.ts
|
|
5638
|
-
async function executeLspFormat(params, signal) {
|
|
5639
|
-
const filePath = requireString(params, "filePath");
|
|
5640
|
-
try {
|
|
5641
|
-
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => formatDocumentWithClient(client, resolvedFilePath, signal === undefined ? {} : { signal }), "format", clientOptions(signal));
|
|
5642
|
-
return text(describeResult(filePath, result), formatDetails(filePath, result));
|
|
5643
|
-
} catch (error) {
|
|
5644
|
-
const missingDependency = missingDependencyResult(error, {
|
|
5645
|
-
filePath,
|
|
5646
|
-
status: "unavailable",
|
|
5647
|
-
reason: "server_unavailable",
|
|
5648
|
-
linesAdded: 0,
|
|
5649
|
-
linesRemoved: 0
|
|
5650
|
-
});
|
|
5651
|
-
if (missingDependency)
|
|
5652
|
-
return missingDependency;
|
|
5653
|
-
throw error;
|
|
5654
|
-
}
|
|
5655
|
-
}
|
|
5656
|
-
function formatDetails(filePath, result) {
|
|
5657
|
-
if (result.status === "unavailable") {
|
|
5658
|
-
return { filePath, status: "unavailable", reason: result.reason, linesAdded: 0, linesRemoved: 0 };
|
|
5659
|
-
}
|
|
5660
|
-
return {
|
|
5661
|
-
filePath,
|
|
5662
|
-
status: result.status,
|
|
5663
|
-
linesAdded: result.linesAdded,
|
|
5664
|
-
linesRemoved: result.linesRemoved
|
|
5665
|
-
};
|
|
5666
|
-
}
|
|
5667
|
-
function describeResult(filePath, result) {
|
|
5668
|
-
if (result.status === "unavailable") {
|
|
5669
|
-
return `Formatting unavailable for ${filePath}: the language server does not advertise documentFormattingProvider.`;
|
|
5670
|
-
}
|
|
5671
|
-
if (result.status === "unchanged") {
|
|
5672
|
-
return `Already formatted: ${filePath}`;
|
|
5673
|
-
}
|
|
5674
|
-
return `Formatted ${filePath} (+${result.linesAdded}/-${result.linesRemoved} lines)`;
|
|
5675
|
-
}
|
|
5676
|
-
|
|
5677
5398
|
// ../lsp-core/src/tools/install-decision.ts
|
|
5678
5399
|
async function executeLspInstallDecision(params) {
|
|
5679
5400
|
const serverId = requireString(params, "server_id");
|
|
@@ -6006,16 +5727,6 @@ var LSP_MCP_TOOLS = [
|
|
|
6006
5727
|
}, ["filePath", "line", "character", "newName"]),
|
|
6007
5728
|
execute: executeLspRename
|
|
6008
5729
|
},
|
|
6009
|
-
{
|
|
6010
|
-
name: "format",
|
|
6011
|
-
aliases: ["lsp_format"],
|
|
6012
|
-
title: "LSP Format",
|
|
6013
|
-
description: "Format a source file with its language server and write the returned edits to disk.",
|
|
6014
|
-
inputSchema: objectSchema({
|
|
6015
|
-
filePath: { type: "string", description: "Source file path to format." }
|
|
6016
|
-
}, ["filePath"]),
|
|
6017
|
-
execute: executeLspFormat
|
|
6018
|
-
},
|
|
6019
5730
|
{
|
|
6020
5731
|
name: "install_decision",
|
|
6021
5732
|
aliases: ["lsp_install_decision"],
|
|
@@ -6235,9 +5946,6 @@ async function callToolViaDaemon(name, args, options) {
|
|
|
6235
5946
|
function callDiagnosticsViaDaemon(filePath, options) {
|
|
6236
5947
|
return callToolViaDaemon("diagnostics", { filePath, severity: "error" }, options);
|
|
6237
5948
|
}
|
|
6238
|
-
function callFormatViaDaemon(filePath, options) {
|
|
6239
|
-
return callToolViaDaemon("format", { filePath }, options);
|
|
6240
|
-
}
|
|
6241
5949
|
function currentRequestContext(env = process.env) {
|
|
6242
5950
|
const cwd = process.cwd();
|
|
6243
5951
|
const home = env["HOME"] ?? homedir3();
|
|
@@ -6260,7 +5968,7 @@ function withContext(args, context) {
|
|
|
6260
5968
|
function ensureDaemonAvailable(paths, ensure, signal) {
|
|
6261
5969
|
if (!signal)
|
|
6262
5970
|
return ensure(paths);
|
|
6263
|
-
return new Promise((
|
|
5971
|
+
return new Promise((resolve9, reject) => {
|
|
6264
5972
|
let settled = false;
|
|
6265
5973
|
const finish = (run) => {
|
|
6266
5974
|
if (settled)
|
|
@@ -6275,11 +5983,11 @@ function ensureDaemonAvailable(paths, ensure, signal) {
|
|
|
6275
5983
|
return;
|
|
6276
5984
|
}
|
|
6277
5985
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
6278
|
-
Promise.resolve().then(() => ensure(paths, signal)).then(() => finish(() =>
|
|
5986
|
+
Promise.resolve().then(() => ensure(paths, signal)).then(() => finish(() => resolve9()), (error) => finish(() => reject(signal.aborted ? new DaemonRequestCancelledError(false) : error)));
|
|
6279
5987
|
});
|
|
6280
5988
|
}
|
|
6281
5989
|
function sendToolCall(paths, token, name, args, options) {
|
|
6282
|
-
return new Promise((
|
|
5990
|
+
return new Promise((resolve9, reject) => {
|
|
6283
5991
|
const socket = connect(paths.socket);
|
|
6284
5992
|
const requestId = allocateProxyRequestId();
|
|
6285
5993
|
let settled = false;
|
|
@@ -6332,7 +6040,7 @@ function sendToolCall(paths, token, name, args, options) {
|
|
|
6332
6040
|
}
|
|
6333
6041
|
const result = toToolResult(message, requestId);
|
|
6334
6042
|
if (result)
|
|
6335
|
-
finish(() =>
|
|
6043
|
+
finish(() => resolve9(result));
|
|
6336
6044
|
else
|
|
6337
6045
|
finish(() => reject(new DaemonRequestError("invalid daemon response", requestWritten)));
|
|
6338
6046
|
});
|
|
@@ -6378,6 +6086,8 @@ function isRetryableTool(name) {
|
|
|
6378
6086
|
}
|
|
6379
6087
|
|
|
6380
6088
|
// src/client.ts
|
|
6089
|
+
import { statSync as statSync5 } from "node:fs";
|
|
6090
|
+
import { isAbsolute as isAbsolute5 } from "node:path";
|
|
6381
6091
|
var OMO_LSP_DAEMON_DIR2 = "OMO_LSP_DAEMON_DIR";
|
|
6382
6092
|
var OMO_LSP_DAEMON_CLI2 = "OMO_LSP_DAEMON_CLI";
|
|
6383
6093
|
var OMO_LSP_DAEMON_VERSION2 = "OMO_LSP_DAEMON_VERSION";
|
|
@@ -6406,12 +6116,12 @@ function resolveDaemonRuntime2(env, defaults) {
|
|
|
6406
6116
|
throw new InvalidRuntimeOverrideError2("paired_values_required", `${OMO_LSP_DAEMON_CLI2} and ${OMO_LSP_DAEMON_VERSION2} must be set together`);
|
|
6407
6117
|
}
|
|
6408
6118
|
if (!hasCliOverride || !hasVersionOverride) {
|
|
6409
|
-
if (!
|
|
6119
|
+
if (!isAbsolute5(defaults.cliPath)) {
|
|
6410
6120
|
throw new InvalidRuntimeOverrideError2("packaged_cli_must_be_absolute", "Packaged LSP daemon CLI path must be absolute");
|
|
6411
6121
|
}
|
|
6412
6122
|
return { cliPath: defaults.cliPath, version: validateDaemonVersion2(defaults.version) };
|
|
6413
6123
|
}
|
|
6414
|
-
if (!
|
|
6124
|
+
if (!isAbsolute5(cliOverride)) {
|
|
6415
6125
|
throw new InvalidRuntimeOverrideError2("cli_must_be_absolute", `${OMO_LSP_DAEMON_CLI2} must be an absolute path to an existing regular file`);
|
|
6416
6126
|
}
|
|
6417
6127
|
const stat = statSync5(cliOverride, { throwIfNoEntry: false });
|
|
@@ -6429,9 +6139,6 @@ function callToolViaDaemon2(name, args, options) {
|
|
|
6429
6139
|
function callDiagnosticsViaDaemon2(filePath, options) {
|
|
6430
6140
|
return callDiagnosticsViaDaemon(filePath, options);
|
|
6431
6141
|
}
|
|
6432
|
-
function callFormatViaDaemon2(filePath, options) {
|
|
6433
|
-
return callFormatViaDaemon(filePath, options);
|
|
6434
|
-
}
|
|
6435
6142
|
function currentRequestContext2(env = process.env) {
|
|
6436
6143
|
return currentRequestContext(env);
|
|
6437
6144
|
}
|
|
@@ -6441,7 +6148,6 @@ export {
|
|
|
6441
6148
|
OMO_LSP_DAEMON_DIR2 as OMO_LSP_DAEMON_DIR,
|
|
6442
6149
|
OMO_LSP_DAEMON_VERSION2 as OMO_LSP_DAEMON_VERSION,
|
|
6443
6150
|
callDiagnosticsViaDaemon2 as callDiagnosticsViaDaemon,
|
|
6444
|
-
callFormatViaDaemon2 as callFormatViaDaemon,
|
|
6445
6151
|
callToolViaDaemon2 as callToolViaDaemon,
|
|
6446
6152
|
currentRequestContext2 as currentRequestContext,
|
|
6447
6153
|
resolveDaemonRuntime2 as resolveDaemonRuntime,
|