oh-my-opencode 5.0.0-beta.24 → 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,6 +1,6 @@
|
|
|
1
1
|
// ../lsp-core/src/lsp/client-wrapper.ts
|
|
2
2
|
import { existsSync as existsSync10, realpathSync as realpathSync5, statSync as statSync3 } from "node:fs";
|
|
3
|
-
import { basename as basename3, dirname as
|
|
3
|
+
import { basename as basename3, dirname as dirname7, join as join5, resolve as resolve7 } from "node:path";
|
|
4
4
|
|
|
5
5
|
// ../lsp-core/src/request-context.ts
|
|
6
6
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -282,7 +282,6 @@ var DEFAULT_MAX_DIRECTORY_FILES = 50;
|
|
|
282
282
|
var REQUEST_TIMEOUT_MS = 15000;
|
|
283
283
|
var INIT_TIMEOUT_MS = 60000;
|
|
284
284
|
var IDLE_TIMEOUT_MS = 5 * 60000;
|
|
285
|
-
var MAX_RESIDENT_CLIENTS = 6;
|
|
286
285
|
var REAPER_INTERVAL_MS = 60000;
|
|
287
286
|
var STOP_HARD_KILL_TIMEOUT_MS = 5000;
|
|
288
287
|
var STOP_SIGKILL_GRACE_MS = 1000;
|
|
@@ -808,7 +807,6 @@ class LspClientTransport {
|
|
|
808
807
|
this.diagnosticsStore = new Map;
|
|
809
808
|
this.workspaceApplyEditHandler = null;
|
|
810
809
|
this.diagnosticPullSupported = false;
|
|
811
|
-
this.documentFormattingSupported = false;
|
|
812
810
|
this.requestTimeoutMs = timeouts.requestTimeoutMs ?? REQUEST_TIMEOUT_MS;
|
|
813
811
|
this.initializeTimeoutMs = timeouts.initializeTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
814
812
|
}
|
|
@@ -830,12 +828,6 @@ class LspClientTransport {
|
|
|
830
828
|
isDiagnosticPullSupported() {
|
|
831
829
|
return this.diagnosticPullSupported;
|
|
832
830
|
}
|
|
833
|
-
setDocumentFormattingSupported(supported) {
|
|
834
|
-
this.documentFormattingSupported = supported;
|
|
835
|
-
}
|
|
836
|
-
isDocumentFormattingSupported() {
|
|
837
|
-
return this.documentFormattingSupported;
|
|
838
|
-
}
|
|
839
831
|
handlePublishDiagnostics(params) {
|
|
840
832
|
this.diagnosticsStore.set(params.uri, [...params.diagnostics]);
|
|
841
833
|
}
|
|
@@ -1049,14 +1041,6 @@ function supportsDiagnosticPull(capabilities) {
|
|
|
1049
1041
|
return false;
|
|
1050
1042
|
return Object.hasOwn(capabilities, "diagnosticProvider");
|
|
1051
1043
|
}
|
|
1052
|
-
function supportsDocumentFormatting(capabilities) {
|
|
1053
|
-
if (capabilities === undefined)
|
|
1054
|
-
return false;
|
|
1055
|
-
const provider = capabilities.documentFormattingProvider;
|
|
1056
|
-
if (provider === undefined || provider === null || provider === false)
|
|
1057
|
-
return false;
|
|
1058
|
-
return provider === true || typeof provider === "object";
|
|
1059
|
-
}
|
|
1060
1044
|
|
|
1061
1045
|
class LspClientConnection extends LspClientTransport {
|
|
1062
1046
|
async initialize() {
|
|
@@ -1073,7 +1057,6 @@ class LspClientConnection extends LspClientTransport {
|
|
|
1073
1057
|
references: {},
|
|
1074
1058
|
documentSymbol: { hierarchicalDocumentSymbolSupport: true },
|
|
1075
1059
|
publishDiagnostics: {},
|
|
1076
|
-
formatting: { dynamicRegistration: false },
|
|
1077
1060
|
rename: {
|
|
1078
1061
|
prepareSupport: true,
|
|
1079
1062
|
prepareSupportDefaultBehavior: 1
|
|
@@ -1115,7 +1098,6 @@ class LspClientConnection extends LspClientTransport {
|
|
|
1115
1098
|
initializationOptions: this.server.initialization
|
|
1116
1099
|
}, { timeoutMs: this.initializeTimeoutMs });
|
|
1117
1100
|
this.setDiagnosticPullSupported(supportsDiagnosticPull(result?.capabilities));
|
|
1118
|
-
this.setDocumentFormattingSupported(supportsDocumentFormatting(result?.capabilities));
|
|
1119
1101
|
await this.sendNotification("initialized", {});
|
|
1120
1102
|
await this.sendNotification("workspace/didChangeConfiguration", {
|
|
1121
1103
|
settings: { json: { validate: { enable: true } } }
|
|
@@ -2700,18 +2682,6 @@ class LspClient extends LspClientConnection {
|
|
|
2700
2682
|
textDocument: { uri: pathToFileURL3(absPath).href }
|
|
2701
2683
|
}, options);
|
|
2702
2684
|
}
|
|
2703
|
-
async formatDocument(filePath, options, signal) {
|
|
2704
|
-
if (!this.isDocumentFormattingSupported())
|
|
2705
|
-
return null;
|
|
2706
|
-
const absPath = this.resolveWorkspacePath(filePath);
|
|
2707
|
-
await this.openFile(absPath);
|
|
2708
|
-
const requestOptions = signal === undefined ? {} : { signal };
|
|
2709
|
-
const edits = await this.sendRequest("textDocument/formatting", {
|
|
2710
|
-
textDocument: { uri: pathToFileURL3(absPath).href },
|
|
2711
|
-
options
|
|
2712
|
-
}, requestOptions);
|
|
2713
|
-
return edits ?? [];
|
|
2714
|
-
}
|
|
2715
2685
|
async workspaceSymbols(query, signal) {
|
|
2716
2686
|
const options = signal === undefined ? {} : { signal };
|
|
2717
2687
|
return this.sendRequest("workspace/symbol", { query }, options);
|
|
@@ -2964,7 +2934,6 @@ class LspManager {
|
|
|
2964
2934
|
this.disposed = false;
|
|
2965
2935
|
this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS;
|
|
2966
2936
|
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
2967
|
-
this.maxResidentClients = options.maxResidentClients ?? MAX_RESIDENT_CLIENTS;
|
|
2968
2937
|
this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
|
|
2969
2938
|
this.clientFactory = options.clientFactory ?? ((root, server) => new LspClient(root, server));
|
|
2970
2939
|
this.now = options.now ?? (() => Date.now());
|
|
@@ -2998,26 +2967,6 @@ class LspManager {
|
|
|
2998
2967
|
}
|
|
2999
2968
|
}
|
|
3000
2969
|
}
|
|
3001
|
-
evictForAdmission() {
|
|
3002
|
-
while (this.clients.size >= this.maxResidentClients) {
|
|
3003
|
-
const victim = this.leastRecentlyUsedIdleClient();
|
|
3004
|
-
if (!victim)
|
|
3005
|
-
return;
|
|
3006
|
-
this.clients.delete(victim.key);
|
|
3007
|
-
stopClientBestEffort(victim.managed.client);
|
|
3008
|
-
}
|
|
3009
|
-
}
|
|
3010
|
-
leastRecentlyUsedIdleClient() {
|
|
3011
|
-
let candidate = null;
|
|
3012
|
-
for (const [key, managed] of this.clients) {
|
|
3013
|
-
if (managed.refCount > 0 || managed.pendingWaiters > 0 || managed.isInitializing)
|
|
3014
|
-
continue;
|
|
3015
|
-
if (candidate === null || managed.lastUsedAt < candidate.managed.lastUsedAt) {
|
|
3016
|
-
candidate = { key, managed };
|
|
3017
|
-
}
|
|
3018
|
-
}
|
|
3019
|
-
return candidate;
|
|
3020
|
-
}
|
|
3021
2970
|
async tryDeleteIfOrphaned(key, managed) {
|
|
3022
2971
|
if (managed.refCount === 0 && managed.pendingWaiters === 0 && !managed.isInitializing && this.clients.get(key) === managed) {
|
|
3023
2972
|
this.clients.delete(key);
|
|
@@ -3064,7 +3013,6 @@ class LspManager {
|
|
|
3064
3013
|
managed.lastUsedAt = this.now();
|
|
3065
3014
|
return managed.client;
|
|
3066
3015
|
}
|
|
3067
|
-
this.evictForAdmission();
|
|
3068
3016
|
const client = this.clientFactory(root, server);
|
|
3069
3017
|
const initStartedAt = this.now();
|
|
3070
3018
|
const initPromise = (async () => {
|
|
@@ -3127,7 +3075,6 @@ class LspManager {
|
|
|
3127
3075
|
const key = this.getKey(root, server.id);
|
|
3128
3076
|
if (this.clients.has(key))
|
|
3129
3077
|
return;
|
|
3130
|
-
this.evictForAdmission();
|
|
3131
3078
|
const client = this.clientFactory(root, server);
|
|
3132
3079
|
const initStartedAt = this.now();
|
|
3133
3080
|
const initPromise = (async () => {
|
|
@@ -3253,6 +3200,57 @@ function nearestExistingAncestor(directory) {
|
|
|
3253
3200
|
return current;
|
|
3254
3201
|
}
|
|
3255
3202
|
|
|
3203
|
+
// ../lsp-core/src/lsp/server-install-state.ts
|
|
3204
|
+
import { existsSync as existsSync7, mkdirSync, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
3205
|
+
import { dirname as dirname6 } from "node:path";
|
|
3206
|
+
function getInstallDecisionsPath() {
|
|
3207
|
+
return lspRequestContext().installDecisionsPath;
|
|
3208
|
+
}
|
|
3209
|
+
function loadInstallDecisions() {
|
|
3210
|
+
const path = getInstallDecisionsPath();
|
|
3211
|
+
if (!existsSync7(path))
|
|
3212
|
+
return {};
|
|
3213
|
+
try {
|
|
3214
|
+
const parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
3215
|
+
return isInstallDecisions(parsed) ? parsed : {};
|
|
3216
|
+
} catch {
|
|
3217
|
+
return {};
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
function loadInstallDecision(serverId) {
|
|
3221
|
+
return loadInstallDecisions()[serverId];
|
|
3222
|
+
}
|
|
3223
|
+
function recordInstallDecision(serverId, decision, decidedAt = new Date().toISOString()) {
|
|
3224
|
+
const decisions = loadInstallDecisions();
|
|
3225
|
+
decisions[serverId] = { decision, decidedAt };
|
|
3226
|
+
writeInstallDecisions(decisions);
|
|
3227
|
+
}
|
|
3228
|
+
function isInstallDecision(value) {
|
|
3229
|
+
return value === "declined" || value === "allowed";
|
|
3230
|
+
}
|
|
3231
|
+
function writeInstallDecisions(decisions) {
|
|
3232
|
+
const path = getInstallDecisionsPath();
|
|
3233
|
+
mkdirSync(dirname6(path), { recursive: true });
|
|
3234
|
+
const tmpPath = `${path}.tmp`;
|
|
3235
|
+
writeFileSync2(tmpPath, `${JSON.stringify(decisions, null, 2)}
|
|
3236
|
+
`, "utf8");
|
|
3237
|
+
renameSync2(tmpPath, path);
|
|
3238
|
+
}
|
|
3239
|
+
function isInstallDecisions(value) {
|
|
3240
|
+
return isRecord5(value) && Object.values(value).every(isInstallDecisionRecord);
|
|
3241
|
+
}
|
|
3242
|
+
function isInstallDecisionRecord(value) {
|
|
3243
|
+
if (!isRecord5(value))
|
|
3244
|
+
return false;
|
|
3245
|
+
return isInstallDecision(value["decision"]) && typeof value["decidedAt"] === "string";
|
|
3246
|
+
}
|
|
3247
|
+
function isRecord5(value) {
|
|
3248
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3249
|
+
}
|
|
3250
|
+
|
|
3251
|
+
// ../lsp-core/src/lsp/config-loader.ts
|
|
3252
|
+
import { existsSync as existsSync8, readFileSync as readFileSync4 } from "node:fs";
|
|
3253
|
+
|
|
3256
3254
|
// ../lsp-core/src/lsp/server-definitions.ts
|
|
3257
3255
|
var LSP_INSTALL_HINTS = {
|
|
3258
3256
|
typescript: "npm install -g typescript-language-server typescript",
|
|
@@ -3298,26 +3296,6 @@ var LSP_INSTALL_HINTS = {
|
|
|
3298
3296
|
julials: `julia -e 'using Pkg; Pkg.add("LanguageServer")'`,
|
|
3299
3297
|
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"
|
|
3300
3298
|
};
|
|
3301
|
-
var LSP_LOCAL_INSTALL_HINTS = {
|
|
3302
|
-
typescript: "bun add -d typescript-language-server typescript",
|
|
3303
|
-
vue: "bun add -d @vue/language-server",
|
|
3304
|
-
eslint: "bun add -d vscode-langservers-extracted",
|
|
3305
|
-
oxlint: "bun add -d oxlint",
|
|
3306
|
-
biome: "bun add -d @biomejs/biome",
|
|
3307
|
-
svelte: "bun add -d svelte-language-server",
|
|
3308
|
-
astro: "bun add -d @astrojs/language-server",
|
|
3309
|
-
bash: "bun add -d bash-language-server",
|
|
3310
|
-
"bash-ls": "bun add -d bash-language-server",
|
|
3311
|
-
"yaml-ls": "bun add -d yaml-language-server",
|
|
3312
|
-
php: "bun add -d intelephense",
|
|
3313
|
-
prisma: "bun add -d prisma",
|
|
3314
|
-
dockerfile: "bun add -d dockerfile-language-server-nodejs",
|
|
3315
|
-
pyright: "uv add --dev pyright",
|
|
3316
|
-
basedpyright: "uv add --dev basedpyright",
|
|
3317
|
-
ruff: "uv add --dev ruff",
|
|
3318
|
-
ty: "uv add --dev ty",
|
|
3319
|
-
"ruby-lsp": "bundle add ruby-lsp --group development"
|
|
3320
|
-
};
|
|
3321
3299
|
var BUILTIN_SERVERS = {
|
|
3322
3300
|
typescript: {
|
|
3323
3301
|
command: ["typescript-language-server", "--stdio"],
|
|
@@ -3420,56 +3398,7 @@ var BUILTIN_SERVERS = {
|
|
|
3420
3398
|
}
|
|
3421
3399
|
};
|
|
3422
3400
|
|
|
3423
|
-
// ../lsp-core/src/lsp/server-install-state.ts
|
|
3424
|
-
import { existsSync as existsSync7, mkdirSync, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
3425
|
-
import { dirname as dirname6 } from "node:path";
|
|
3426
|
-
function getInstallDecisionsPath() {
|
|
3427
|
-
return lspRequestContext().installDecisionsPath;
|
|
3428
|
-
}
|
|
3429
|
-
function loadInstallDecisions() {
|
|
3430
|
-
const path = getInstallDecisionsPath();
|
|
3431
|
-
if (!existsSync7(path))
|
|
3432
|
-
return {};
|
|
3433
|
-
try {
|
|
3434
|
-
const parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
3435
|
-
return isInstallDecisions(parsed) ? parsed : {};
|
|
3436
|
-
} catch {
|
|
3437
|
-
return {};
|
|
3438
|
-
}
|
|
3439
|
-
}
|
|
3440
|
-
function loadInstallDecision(serverId) {
|
|
3441
|
-
return loadInstallDecisions()[serverId];
|
|
3442
|
-
}
|
|
3443
|
-
function recordInstallDecision(serverId, decision, decidedAt = new Date().toISOString()) {
|
|
3444
|
-
const decisions = loadInstallDecisions();
|
|
3445
|
-
decisions[serverId] = { decision, decidedAt };
|
|
3446
|
-
writeInstallDecisions(decisions);
|
|
3447
|
-
}
|
|
3448
|
-
function isInstallDecision(value) {
|
|
3449
|
-
return value === "declined" || value === "allowed";
|
|
3450
|
-
}
|
|
3451
|
-
function writeInstallDecisions(decisions) {
|
|
3452
|
-
const path = getInstallDecisionsPath();
|
|
3453
|
-
mkdirSync(dirname6(path), { recursive: true });
|
|
3454
|
-
const tmpPath = `${path}.tmp`;
|
|
3455
|
-
writeFileSync2(tmpPath, `${JSON.stringify(decisions, null, 2)}
|
|
3456
|
-
`, "utf8");
|
|
3457
|
-
renameSync2(tmpPath, path);
|
|
3458
|
-
}
|
|
3459
|
-
function isInstallDecisions(value) {
|
|
3460
|
-
return isRecord5(value) && Object.values(value).every(isInstallDecisionRecord);
|
|
3461
|
-
}
|
|
3462
|
-
function isInstallDecisionRecord(value) {
|
|
3463
|
-
if (!isRecord5(value))
|
|
3464
|
-
return false;
|
|
3465
|
-
return isInstallDecision(value["decision"]) && typeof value["decidedAt"] === "string";
|
|
3466
|
-
}
|
|
3467
|
-
function isRecord5(value) {
|
|
3468
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3469
|
-
}
|
|
3470
|
-
|
|
3471
3401
|
// ../lsp-core/src/lsp/config-loader.ts
|
|
3472
|
-
import { existsSync as existsSync8, readFileSync as readFileSync4 } from "node:fs";
|
|
3473
3402
|
function getProjectConfigPaths() {
|
|
3474
3403
|
return lspRequestContext().projectConfigPaths;
|
|
3475
3404
|
}
|
|
@@ -3666,154 +3595,53 @@ function getDisabledServerIds() {
|
|
|
3666
3595
|
|
|
3667
3596
|
// ../lsp-core/src/lsp/server-installation.ts
|
|
3668
3597
|
import { existsSync as existsSync9 } from "node:fs";
|
|
3669
|
-
import { delimiter as delimiter3,
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
"requirements.txt",
|
|
3680
|
-
"setup.py",
|
|
3681
|
-
"setup.cfg",
|
|
3682
|
-
"Pipfile",
|
|
3683
|
-
"pyrightconfig.json",
|
|
3684
|
-
"ruff.toml",
|
|
3685
|
-
".ruff.toml"
|
|
3686
|
-
],
|
|
3687
|
-
binDirs: [
|
|
3688
|
-
join4(".venv", "bin"),
|
|
3689
|
-
join4(".venv", "Scripts"),
|
|
3690
|
-
join4("venv", "bin"),
|
|
3691
|
-
join4("venv", "Scripts"),
|
|
3692
|
-
join4(".env", "bin"),
|
|
3693
|
-
join4(".env", "Scripts")
|
|
3694
|
-
]
|
|
3695
|
-
},
|
|
3696
|
-
{
|
|
3697
|
-
markers: ["Gemfile", "Gemfile.lock"],
|
|
3698
|
-
binDirs: [join4("vendor", "bundle", "bin"), "bin"]
|
|
3699
|
-
},
|
|
3700
|
-
{
|
|
3701
|
-
markers: ["go.mod", "go.sum", "go.work"],
|
|
3702
|
-
binDirs: ["bin"]
|
|
3703
|
-
}
|
|
3704
|
-
];
|
|
3705
|
-
var resolutionCache = new Map;
|
|
3706
|
-
var probeCount = 0;
|
|
3707
|
-
function probe(path) {
|
|
3708
|
-
probeCount += 1;
|
|
3709
|
-
return existsSync9(path);
|
|
3710
|
-
}
|
|
3711
|
-
function executableSuffixes(platform, pathExt) {
|
|
3712
|
-
if (platform !== "win32")
|
|
3713
|
-
return [""];
|
|
3714
|
-
const configured = pathExt ?? process.env["PATHEXT"] ?? "";
|
|
3715
|
-
const systemExts = configured.split(";").filter((entry) => entry.length > 0).map((entry) => entry.toLowerCase());
|
|
3716
|
-
return [...new Set(["", ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])];
|
|
3717
|
-
}
|
|
3718
|
-
function probeWithSuffixes(directory, command, suffixes) {
|
|
3719
|
-
for (const suffix of suffixes) {
|
|
3720
|
-
const candidate = join4(directory, command + suffix);
|
|
3721
|
-
if (probe(candidate))
|
|
3722
|
-
return candidate;
|
|
3598
|
+
import { delimiter as delimiter3, join as join4 } from "node:path";
|
|
3599
|
+
function isServerInstalled(command, _workingDirectory) {
|
|
3600
|
+
if (command.length === 0)
|
|
3601
|
+
return false;
|
|
3602
|
+
const [cmd] = command;
|
|
3603
|
+
if (!cmd)
|
|
3604
|
+
return false;
|
|
3605
|
+
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
3606
|
+
if (existsSync9(cmd))
|
|
3607
|
+
return true;
|
|
3723
3608
|
}
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
for (const binDir of rule.binDirs) {
|
|
3734
|
-
const found = probeWithSuffixes(join4(current, binDir), command, suffixes);
|
|
3735
|
-
if (found !== null)
|
|
3736
|
-
return found;
|
|
3737
|
-
}
|
|
3609
|
+
const isWindows = process.platform === "win32";
|
|
3610
|
+
let exts = [""];
|
|
3611
|
+
if (isWindows) {
|
|
3612
|
+
const pathExt = process.env["PATHEXT"] ?? "";
|
|
3613
|
+
if (pathExt) {
|
|
3614
|
+
const systemExts = pathExt.split(";").filter(Boolean);
|
|
3615
|
+
exts = [...new Set([...exts, ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])];
|
|
3616
|
+
} else {
|
|
3617
|
+
exts = ["", ".exe", ".cmd", ".bat", ".ps1"];
|
|
3738
3618
|
}
|
|
3739
|
-
if (probe(join4(current, ".git")))
|
|
3740
|
-
return null;
|
|
3741
|
-
if (boundary !== undefined && current === boundary)
|
|
3742
|
-
return null;
|
|
3743
|
-
const parent = dirname7(current);
|
|
3744
|
-
if (parent === current)
|
|
3745
|
-
return null;
|
|
3746
|
-
current = parent;
|
|
3747
3619
|
}
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
let pathEnv = pathEnvOverride ?? process.env["PATH"] ?? "";
|
|
3751
|
-
if (platform === "win32" && !pathEnv) {
|
|
3620
|
+
let pathEnv = process.env["PATH"] ?? "";
|
|
3621
|
+
if (isWindows && !pathEnv) {
|
|
3752
3622
|
pathEnv = process.env["Path"] ?? "";
|
|
3753
3623
|
}
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3624
|
+
const paths = pathEnv.split(delimiter3);
|
|
3625
|
+
for (const p of paths) {
|
|
3626
|
+
for (const suffix of exts) {
|
|
3627
|
+
if (existsSync9(join4(p, cmd + suffix))) {
|
|
3628
|
+
return true;
|
|
3629
|
+
}
|
|
3630
|
+
}
|
|
3760
3631
|
}
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
if (command.length === 0)
|
|
3765
|
-
return null;
|
|
3766
|
-
const [cmd] = command;
|
|
3767
|
-
if (cmd === undefined || cmd.length === 0)
|
|
3768
|
-
return null;
|
|
3769
|
-
const platform = options.platform ?? process.platform;
|
|
3770
|
-
const suffixes = executableSuffixes(platform, options.pathExt);
|
|
3771
|
-
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
3772
|
-
const explicit = isAbsolute3(cmd) ? cmd : resolve7(workingDirectory ?? process.cwd(), cmd);
|
|
3773
|
-
return probe(explicit) ? explicit : null;
|
|
3774
|
-
}
|
|
3775
|
-
const cacheKey = JSON.stringify([
|
|
3776
|
-
workingDirectory ?? "",
|
|
3777
|
-
cmd,
|
|
3778
|
-
platform,
|
|
3779
|
-
options.stopAt ?? "",
|
|
3780
|
-
options.pathExt ?? "",
|
|
3781
|
-
options.pathEnv ?? process.env["PATH"] ?? ""
|
|
3782
|
-
]);
|
|
3783
|
-
const cached = resolutionCache.get(cacheKey);
|
|
3784
|
-
if (cached !== undefined)
|
|
3785
|
-
return cached;
|
|
3786
|
-
let resolved = null;
|
|
3787
|
-
if (workingDirectory !== undefined && workingDirectory.length > 0) {
|
|
3788
|
-
resolved = resolveLocal(cmd, workingDirectory, suffixes, options.stopAt);
|
|
3789
|
-
}
|
|
3790
|
-
resolved ??= resolveFromPath(cmd, suffixes, platform, options.pathEnv);
|
|
3791
|
-
if (resolved === null && cmd === "node")
|
|
3792
|
-
resolved = cmd;
|
|
3793
|
-
resolutionCache.set(cacheKey, resolved);
|
|
3794
|
-
return resolved;
|
|
3795
|
-
}
|
|
3796
|
-
function isServerInstalled(command, workingDirectory, options = {}) {
|
|
3797
|
-
if (command.length === 0)
|
|
3798
|
-
return false;
|
|
3799
|
-
return resolveServerBinary(command, workingDirectory, options) !== null;
|
|
3632
|
+
if (cmd === "node")
|
|
3633
|
+
return true;
|
|
3634
|
+
return false;
|
|
3800
3635
|
}
|
|
3801
3636
|
|
|
3802
3637
|
// ../lsp-core/src/lsp/server-resolution.ts
|
|
3803
|
-
function withResolvedCommand(command, binaryPath) {
|
|
3804
|
-
return [binaryPath, ...command.slice(1)];
|
|
3805
|
-
}
|
|
3806
3638
|
function findServerForExtension(ext) {
|
|
3807
3639
|
const servers = getMergedServers();
|
|
3808
|
-
const workingDirectory = contextCwd();
|
|
3809
3640
|
for (const server of servers) {
|
|
3810
|
-
if (
|
|
3811
|
-
continue;
|
|
3812
|
-
const binaryPath = resolveServerBinary(server.command, workingDirectory);
|
|
3813
|
-
if (binaryPath !== null) {
|
|
3641
|
+
if (server.extensions.includes(ext) && isServerInstalled(server.command)) {
|
|
3814
3642
|
const resolvedServer = {
|
|
3815
3643
|
id: server.id,
|
|
3816
|
-
command:
|
|
3644
|
+
command: server.command,
|
|
3817
3645
|
extensions: server.extensions,
|
|
3818
3646
|
priority: server.priority
|
|
3819
3647
|
};
|
|
@@ -3860,7 +3688,6 @@ function findServerForExtension(ext) {
|
|
|
3860
3688
|
function getAllServers() {
|
|
3861
3689
|
const servers = getMergedServers();
|
|
3862
3690
|
const disabled = getDisabledServerIds();
|
|
3863
|
-
const workingDirectory = contextCwd();
|
|
3864
3691
|
const result = [];
|
|
3865
3692
|
const seen = new Set;
|
|
3866
3693
|
for (const server of servers) {
|
|
@@ -3868,7 +3695,7 @@ function getAllServers() {
|
|
|
3868
3695
|
continue;
|
|
3869
3696
|
result.push({
|
|
3870
3697
|
id: server.id,
|
|
3871
|
-
installed: isServerInstalled(server.command
|
|
3698
|
+
installed: isServerInstalled(server.command),
|
|
3872
3699
|
extensions: server.extensions,
|
|
3873
3700
|
disabled: false,
|
|
3874
3701
|
source: server.source,
|
|
@@ -3882,7 +3709,7 @@ function getAllServers() {
|
|
|
3882
3709
|
const builtin = BUILTIN_SERVERS[id];
|
|
3883
3710
|
result.push({
|
|
3884
3711
|
id,
|
|
3885
|
-
installed: builtin ? isServerInstalled(builtin.command
|
|
3712
|
+
installed: builtin ? isServerInstalled(builtin.command) : false,
|
|
3886
3713
|
extensions: builtin?.extensions ?? [],
|
|
3887
3714
|
disabled: true,
|
|
3888
3715
|
source: "disabled",
|
|
@@ -3905,7 +3732,7 @@ function findWorkspaceRoot(filePath) {
|
|
|
3905
3732
|
const abs = resolveReadablePathInsideContext(filePath);
|
|
3906
3733
|
let dir = abs;
|
|
3907
3734
|
if (!isDirectoryPath(dir)) {
|
|
3908
|
-
dir =
|
|
3735
|
+
dir = dirname7(dir);
|
|
3909
3736
|
}
|
|
3910
3737
|
if (!isPathInside(cwd, abs))
|
|
3911
3738
|
return findWorkspaceRootOutsideContext(dir);
|
|
@@ -3921,13 +3748,13 @@ function findWorkspaceRoot(filePath) {
|
|
|
3921
3748
|
}
|
|
3922
3749
|
if (dir === cwd)
|
|
3923
3750
|
break;
|
|
3924
|
-
dir =
|
|
3751
|
+
dir = dirname7(dir);
|
|
3925
3752
|
}
|
|
3926
3753
|
return fallbackRoot;
|
|
3927
3754
|
}
|
|
3928
3755
|
function resolveReadablePathInsideContext(filePath) {
|
|
3929
3756
|
const cwd = contextCwd();
|
|
3930
|
-
const abs =
|
|
3757
|
+
const abs = resolve7(cwd, filePath);
|
|
3931
3758
|
if (isPathInside(cwd, abs))
|
|
3932
3759
|
return abs;
|
|
3933
3760
|
const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
|
|
@@ -3953,7 +3780,7 @@ function rebaseThroughCanonicalAncestor(path, cwd) {
|
|
|
3953
3780
|
if (isPathInside(cwd, canonical))
|
|
3954
3781
|
return suffix.length === 0 ? canonical : join5(canonical, ...suffix);
|
|
3955
3782
|
}
|
|
3956
|
-
const parent =
|
|
3783
|
+
const parent = dirname7(current);
|
|
3957
3784
|
if (parent === current)
|
|
3958
3785
|
return;
|
|
3959
3786
|
suffix.unshift(basename3(current));
|
|
@@ -3976,7 +3803,7 @@ function nearestExistingDirectoryInsideContext(directory, cwd) {
|
|
|
3976
3803
|
return canonical;
|
|
3977
3804
|
if (current === cwd)
|
|
3978
3805
|
return;
|
|
3979
|
-
current =
|
|
3806
|
+
current = dirname7(current);
|
|
3980
3807
|
}
|
|
3981
3808
|
return;
|
|
3982
3809
|
}
|
|
@@ -4003,19 +3830,6 @@ function formatServerLookupError(result) {
|
|
|
4003
3830
|
].join(`
|
|
4004
3831
|
`);
|
|
4005
3832
|
}
|
|
4006
|
-
function formatInstallOptions(serverId, installHint) {
|
|
4007
|
-
const localHint = LSP_LOCAL_INSTALL_HINTS[serverId];
|
|
4008
|
-
if (localHint === undefined) {
|
|
4009
|
-
return ["To install, run:", ` ${installHint}`];
|
|
4010
|
-
}
|
|
4011
|
-
return [
|
|
4012
|
-
"To install in THIS repository (preferred — no global install needed):",
|
|
4013
|
-
` ${localHint}`,
|
|
4014
|
-
"",
|
|
4015
|
-
"Or install it globally:",
|
|
4016
|
-
` ${installHint}`
|
|
4017
|
-
];
|
|
4018
|
-
}
|
|
4019
3833
|
function formatNotInstalled(result) {
|
|
4020
3834
|
const { server, installHint } = result;
|
|
4021
3835
|
const extensions = server.extensions.join(", ");
|
|
@@ -4030,19 +3844,19 @@ function formatNotInstalled(result) {
|
|
|
4030
3844
|
`Command not found: ${server.command[0]}`,
|
|
4031
3845
|
""
|
|
4032
3846
|
];
|
|
4033
|
-
const installOptions = formatInstallOptions(server.id, installHint);
|
|
4034
3847
|
if (decision === "allowed") {
|
|
4035
3848
|
return [
|
|
4036
3849
|
...header,
|
|
4037
3850
|
"The user has pre-authorized LSP installation. Run the install command, then retry this tool:",
|
|
4038
|
-
|
|
3851
|
+
` ${installHint}`
|
|
4039
3852
|
].join(`
|
|
4040
3853
|
`);
|
|
4041
3854
|
}
|
|
4042
3855
|
if (!context.capabilities.installDecisionTool) {
|
|
4043
3856
|
return [
|
|
4044
3857
|
...header,
|
|
4045
|
-
|
|
3858
|
+
"To install, run:",
|
|
3859
|
+
` ${installHint}`,
|
|
4046
3860
|
"",
|
|
4047
3861
|
"ACTION REQUIRED — ASK THE USER whether to install this LSP server.",
|
|
4048
3862
|
"Install-decision recording is unavailable in this harness; proceed without LSP if the user declines."
|
|
@@ -4051,7 +3865,8 @@ function formatNotInstalled(result) {
|
|
|
4051
3865
|
}
|
|
4052
3866
|
return [
|
|
4053
3867
|
...header,
|
|
4054
|
-
|
|
3868
|
+
"To install, run:",
|
|
3869
|
+
` ${installHint}`,
|
|
4055
3870
|
"",
|
|
4056
3871
|
"ACTION REQUIRED — ASK THE USER whether to install this LSP server.",
|
|
4057
3872
|
"- If the user agrees: run the install command above, then retry this tool.",
|
|
@@ -4107,7 +3922,7 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
|
4107
3922
|
|
|
4108
3923
|
// ../lsp-core/src/lsp/directory-diagnostics.ts
|
|
4109
3924
|
import { existsSync as existsSync11, lstatSync as lstatSync4, readdirSync as readdirSync3 } from "node:fs";
|
|
4110
|
-
import { join as join6, resolve as
|
|
3925
|
+
import { join as join6, resolve as resolve8 } from "node:path";
|
|
4111
3926
|
|
|
4112
3927
|
// ../lsp-core/src/lsp/formatters.ts
|
|
4113
3928
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -4262,7 +4077,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
4262
4077
|
if (!extension.startsWith(".")) {
|
|
4263
4078
|
throw new LspInvalidPathError(`Extension must start with a dot (e.g., ".ts", not "${extension}"). Use ".${extension}" instead.`);
|
|
4264
4079
|
}
|
|
4265
|
-
const absDir =
|
|
4080
|
+
const absDir = resolve8(options.workspaceRoot ?? contextCwd(), directory);
|
|
4266
4081
|
if (!existsSync11(absDir)) {
|
|
4267
4082
|
throw new LspInvalidPathError(`Directory does not exist: ${absDir}`);
|
|
4268
4083
|
}
|
|
@@ -4619,96 +4434,6 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
4619
4434
|
throw error;
|
|
4620
4435
|
}
|
|
4621
4436
|
}
|
|
4622
|
-
// ../lsp-core/src/lsp/format-document.ts
|
|
4623
|
-
import { readFileSync as readFileSync5, renameSync as renameSync3, unlinkSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
4624
|
-
var DEFAULT_FORMATTING_OPTIONS = {
|
|
4625
|
-
tabSize: 4,
|
|
4626
|
-
insertSpaces: false,
|
|
4627
|
-
trimTrailingWhitespace: true,
|
|
4628
|
-
insertFinalNewline: true,
|
|
4629
|
-
trimFinalNewlines: true
|
|
4630
|
-
};
|
|
4631
|
-
var UNCHANGED = { status: "unchanged", linesAdded: 0, linesRemoved: 0 };
|
|
4632
|
-
async function formatDocumentWithClient(client, filePath, options = {}) {
|
|
4633
|
-
const edits = await client.formatDocument(filePath, options.formattingOptions ?? DEFAULT_FORMATTING_OPTIONS, options.signal);
|
|
4634
|
-
if (edits === null)
|
|
4635
|
-
return { status: "unavailable", reason: "capability_not_advertised" };
|
|
4636
|
-
if (edits.length === 0)
|
|
4637
|
-
return UNCHANGED;
|
|
4638
|
-
const before = readFileSync5(filePath, "utf-8");
|
|
4639
|
-
const normalized = normalizeTextEdits(before, edits, 0);
|
|
4640
|
-
if (normalized.text === before)
|
|
4641
|
-
return UNCHANGED;
|
|
4642
|
-
writeAtomically(filePath, normalized.text);
|
|
4643
|
-
await client.openFile(filePath);
|
|
4644
|
-
return {
|
|
4645
|
-
status: "formatted",
|
|
4646
|
-
...lineDelta(normalized.edits)
|
|
4647
|
-
};
|
|
4648
|
-
}
|
|
4649
|
-
function lineDelta(edits) {
|
|
4650
|
-
let linesAdded = 0;
|
|
4651
|
-
let linesRemoved = 0;
|
|
4652
|
-
for (const edit of edits) {
|
|
4653
|
-
linesRemoved += edit.range.end.line - edit.range.start.line + 1;
|
|
4654
|
-
linesAdded += edit.newText.split(`
|
|
4655
|
-
`).length;
|
|
4656
|
-
}
|
|
4657
|
-
return { linesAdded, linesRemoved };
|
|
4658
|
-
}
|
|
4659
|
-
function writeAtomically(filePath, content) {
|
|
4660
|
-
const tempPath = `${filePath}.omo-format.tmp`;
|
|
4661
|
-
writeFileSync3(tempPath, content, "utf-8");
|
|
4662
|
-
try {
|
|
4663
|
-
renameSync3(tempPath, filePath);
|
|
4664
|
-
} catch (error) {
|
|
4665
|
-
try {
|
|
4666
|
-
unlinkSync(tempPath);
|
|
4667
|
-
} catch {}
|
|
4668
|
-
throw error;
|
|
4669
|
-
}
|
|
4670
|
-
}
|
|
4671
|
-
|
|
4672
|
-
// ../lsp-core/src/tools/format.ts
|
|
4673
|
-
async function executeLspFormat(params, signal) {
|
|
4674
|
-
const filePath = requireString(params, "filePath");
|
|
4675
|
-
try {
|
|
4676
|
-
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => formatDocumentWithClient(client, resolvedFilePath, signal === undefined ? {} : { signal }), "format", clientOptions(signal));
|
|
4677
|
-
return text(describeResult(filePath, result), formatDetails(filePath, result));
|
|
4678
|
-
} catch (error) {
|
|
4679
|
-
const missingDependency = missingDependencyResult(error, {
|
|
4680
|
-
filePath,
|
|
4681
|
-
status: "unavailable",
|
|
4682
|
-
reason: "server_unavailable",
|
|
4683
|
-
linesAdded: 0,
|
|
4684
|
-
linesRemoved: 0
|
|
4685
|
-
});
|
|
4686
|
-
if (missingDependency)
|
|
4687
|
-
return missingDependency;
|
|
4688
|
-
throw error;
|
|
4689
|
-
}
|
|
4690
|
-
}
|
|
4691
|
-
function formatDetails(filePath, result) {
|
|
4692
|
-
if (result.status === "unavailable") {
|
|
4693
|
-
return { filePath, status: "unavailable", reason: result.reason, linesAdded: 0, linesRemoved: 0 };
|
|
4694
|
-
}
|
|
4695
|
-
return {
|
|
4696
|
-
filePath,
|
|
4697
|
-
status: result.status,
|
|
4698
|
-
linesAdded: result.linesAdded,
|
|
4699
|
-
linesRemoved: result.linesRemoved
|
|
4700
|
-
};
|
|
4701
|
-
}
|
|
4702
|
-
function describeResult(filePath, result) {
|
|
4703
|
-
if (result.status === "unavailable") {
|
|
4704
|
-
return `Formatting unavailable for ${filePath}: the language server does not advertise documentFormattingProvider.`;
|
|
4705
|
-
}
|
|
4706
|
-
if (result.status === "unchanged") {
|
|
4707
|
-
return `Already formatted: ${filePath}`;
|
|
4708
|
-
}
|
|
4709
|
-
return `Formatted ${filePath} (+${result.linesAdded}/-${result.linesRemoved} lines)`;
|
|
4710
|
-
}
|
|
4711
|
-
|
|
4712
4437
|
// ../lsp-core/src/tools/install-decision.ts
|
|
4713
4438
|
async function executeLspInstallDecision(params) {
|
|
4714
4439
|
const serverId = requireString(params, "server_id");
|
|
@@ -5041,16 +4766,6 @@ var LSP_MCP_TOOLS = [
|
|
|
5041
4766
|
}, ["filePath", "line", "character", "newName"]),
|
|
5042
4767
|
execute: executeLspRename
|
|
5043
4768
|
},
|
|
5044
|
-
{
|
|
5045
|
-
name: "format",
|
|
5046
|
-
aliases: ["lsp_format"],
|
|
5047
|
-
title: "LSP Format",
|
|
5048
|
-
description: "Format a source file with its language server and write the returned edits to disk.",
|
|
5049
|
-
inputSchema: objectSchema({
|
|
5050
|
-
filePath: { type: "string", description: "Source file path to format." }
|
|
5051
|
-
}, ["filePath"]),
|
|
5052
|
-
execute: executeLspFormat
|
|
5053
|
-
},
|
|
5054
4769
|
{
|
|
5055
4770
|
name: "install_decision",
|
|
5056
4771
|
aliases: ["lsp_install_decision"],
|
|
@@ -5088,7 +4803,6 @@ export {
|
|
|
5088
4803
|
coerceToolArguments,
|
|
5089
4804
|
executeLspDiagnostics,
|
|
5090
4805
|
executeLspFindReferences,
|
|
5091
|
-
executeLspFormat,
|
|
5092
4806
|
executeLspGotoDefinition,
|
|
5093
4807
|
executeLspInstallDecision,
|
|
5094
4808
|
executeLspPrepareRename,
|