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
|
@@ -25,7 +25,6 @@ var DEFAULT_MAX_DIRECTORY_FILES = 50;
|
|
|
25
25
|
var REQUEST_TIMEOUT_MS = 15000;
|
|
26
26
|
var INIT_TIMEOUT_MS = 60000;
|
|
27
27
|
var IDLE_TIMEOUT_MS = 5 * 60000;
|
|
28
|
-
var MAX_RESIDENT_CLIENTS = 6;
|
|
29
28
|
var REAPER_INTERVAL_MS = 60000;
|
|
30
29
|
var STOP_HARD_KILL_TIMEOUT_MS = 5000;
|
|
31
30
|
var STOP_SIGKILL_GRACE_MS = 1000;
|
|
@@ -618,7 +617,6 @@ class LspClientTransport {
|
|
|
618
617
|
this.diagnosticsStore = new Map;
|
|
619
618
|
this.workspaceApplyEditHandler = null;
|
|
620
619
|
this.diagnosticPullSupported = false;
|
|
621
|
-
this.documentFormattingSupported = false;
|
|
622
620
|
this.requestTimeoutMs = timeouts.requestTimeoutMs ?? REQUEST_TIMEOUT_MS;
|
|
623
621
|
this.initializeTimeoutMs = timeouts.initializeTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
624
622
|
}
|
|
@@ -640,12 +638,6 @@ class LspClientTransport {
|
|
|
640
638
|
isDiagnosticPullSupported() {
|
|
641
639
|
return this.diagnosticPullSupported;
|
|
642
640
|
}
|
|
643
|
-
setDocumentFormattingSupported(supported) {
|
|
644
|
-
this.documentFormattingSupported = supported;
|
|
645
|
-
}
|
|
646
|
-
isDocumentFormattingSupported() {
|
|
647
|
-
return this.documentFormattingSupported;
|
|
648
|
-
}
|
|
649
641
|
handlePublishDiagnostics(params) {
|
|
650
642
|
this.diagnosticsStore.set(params.uri, [...params.diagnostics]);
|
|
651
643
|
}
|
|
@@ -859,14 +851,6 @@ function supportsDiagnosticPull(capabilities) {
|
|
|
859
851
|
return false;
|
|
860
852
|
return Object.hasOwn(capabilities, "diagnosticProvider");
|
|
861
853
|
}
|
|
862
|
-
function supportsDocumentFormatting(capabilities) {
|
|
863
|
-
if (capabilities === undefined)
|
|
864
|
-
return false;
|
|
865
|
-
const provider = capabilities.documentFormattingProvider;
|
|
866
|
-
if (provider === undefined || provider === null || provider === false)
|
|
867
|
-
return false;
|
|
868
|
-
return provider === true || typeof provider === "object";
|
|
869
|
-
}
|
|
870
854
|
|
|
871
855
|
class LspClientConnection extends LspClientTransport {
|
|
872
856
|
async initialize() {
|
|
@@ -883,7 +867,6 @@ class LspClientConnection extends LspClientTransport {
|
|
|
883
867
|
references: {},
|
|
884
868
|
documentSymbol: { hierarchicalDocumentSymbolSupport: true },
|
|
885
869
|
publishDiagnostics: {},
|
|
886
|
-
formatting: { dynamicRegistration: false },
|
|
887
870
|
rename: {
|
|
888
871
|
prepareSupport: true,
|
|
889
872
|
prepareSupportDefaultBehavior: 1
|
|
@@ -925,7 +908,6 @@ class LspClientConnection extends LspClientTransport {
|
|
|
925
908
|
initializationOptions: this.server.initialization
|
|
926
909
|
}, { timeoutMs: this.initializeTimeoutMs });
|
|
927
910
|
this.setDiagnosticPullSupported(supportsDiagnosticPull(result?.capabilities));
|
|
928
|
-
this.setDocumentFormattingSupported(supportsDocumentFormatting(result?.capabilities));
|
|
929
911
|
await this.sendNotification("initialized", {});
|
|
930
912
|
await this.sendNotification("workspace/didChangeConfiguration", {
|
|
931
913
|
settings: { json: { validate: { enable: true } } }
|
|
@@ -2520,18 +2502,6 @@ class LspClient extends LspClientConnection {
|
|
|
2520
2502
|
textDocument: { uri: pathToFileURL3(absPath).href }
|
|
2521
2503
|
}, options);
|
|
2522
2504
|
}
|
|
2523
|
-
async formatDocument(filePath, options, signal) {
|
|
2524
|
-
if (!this.isDocumentFormattingSupported())
|
|
2525
|
-
return null;
|
|
2526
|
-
const absPath = this.resolveWorkspacePath(filePath);
|
|
2527
|
-
await this.openFile(absPath);
|
|
2528
|
-
const requestOptions = signal === undefined ? {} : { signal };
|
|
2529
|
-
const edits = await this.sendRequest("textDocument/formatting", {
|
|
2530
|
-
textDocument: { uri: pathToFileURL3(absPath).href },
|
|
2531
|
-
options
|
|
2532
|
-
}, requestOptions);
|
|
2533
|
-
return edits ?? [];
|
|
2534
|
-
}
|
|
2535
2505
|
async workspaceSymbols(query, signal) {
|
|
2536
2506
|
const options = signal === undefined ? {} : { signal };
|
|
2537
2507
|
return this.sendRequest("workspace/symbol", { query }, options);
|
|
@@ -2784,7 +2754,6 @@ class LspManager {
|
|
|
2784
2754
|
this.disposed = false;
|
|
2785
2755
|
this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS;
|
|
2786
2756
|
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
2787
|
-
this.maxResidentClients = options.maxResidentClients ?? MAX_RESIDENT_CLIENTS;
|
|
2788
2757
|
this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
|
|
2789
2758
|
this.clientFactory = options.clientFactory ?? ((root, server) => new LspClient(root, server));
|
|
2790
2759
|
this.now = options.now ?? (() => Date.now());
|
|
@@ -2818,26 +2787,6 @@ class LspManager {
|
|
|
2818
2787
|
}
|
|
2819
2788
|
}
|
|
2820
2789
|
}
|
|
2821
|
-
evictForAdmission() {
|
|
2822
|
-
while (this.clients.size >= this.maxResidentClients) {
|
|
2823
|
-
const victim = this.leastRecentlyUsedIdleClient();
|
|
2824
|
-
if (!victim)
|
|
2825
|
-
return;
|
|
2826
|
-
this.clients.delete(victim.key);
|
|
2827
|
-
stopClientBestEffort(victim.managed.client);
|
|
2828
|
-
}
|
|
2829
|
-
}
|
|
2830
|
-
leastRecentlyUsedIdleClient() {
|
|
2831
|
-
let candidate = null;
|
|
2832
|
-
for (const [key, managed] of this.clients) {
|
|
2833
|
-
if (managed.refCount > 0 || managed.pendingWaiters > 0 || managed.isInitializing)
|
|
2834
|
-
continue;
|
|
2835
|
-
if (candidate === null || managed.lastUsedAt < candidate.managed.lastUsedAt) {
|
|
2836
|
-
candidate = { key, managed };
|
|
2837
|
-
}
|
|
2838
|
-
}
|
|
2839
|
-
return candidate;
|
|
2840
|
-
}
|
|
2841
2790
|
async tryDeleteIfOrphaned(key, managed) {
|
|
2842
2791
|
if (managed.refCount === 0 && managed.pendingWaiters === 0 && !managed.isInitializing && this.clients.get(key) === managed) {
|
|
2843
2792
|
this.clients.delete(key);
|
|
@@ -2884,7 +2833,6 @@ class LspManager {
|
|
|
2884
2833
|
managed.lastUsedAt = this.now();
|
|
2885
2834
|
return managed.client;
|
|
2886
2835
|
}
|
|
2887
|
-
this.evictForAdmission();
|
|
2888
2836
|
const client = this.clientFactory(root, server);
|
|
2889
2837
|
const initStartedAt = this.now();
|
|
2890
2838
|
const initPromise = (async () => {
|
|
@@ -2947,7 +2895,6 @@ class LspManager {
|
|
|
2947
2895
|
const key = this.getKey(root, server.id);
|
|
2948
2896
|
if (this.clients.has(key))
|
|
2949
2897
|
return;
|
|
2950
|
-
this.evictForAdmission();
|
|
2951
2898
|
const client = this.clientFactory(root, server);
|
|
2952
2899
|
const initStartedAt = this.now();
|
|
2953
2900
|
const initPromise = (async () => {
|
|
@@ -3348,7 +3295,7 @@ function createIdleTimer(idleTimeoutMs, log, onTimeout) {
|
|
|
3348
3295
|
}
|
|
3349
3296
|
// ../lsp-core/src/lsp/client-wrapper.ts
|
|
3350
3297
|
import { existsSync as existsSync10, realpathSync as realpathSync5, statSync as statSync3 } from "node:fs";
|
|
3351
|
-
import { basename as basename3, dirname as
|
|
3298
|
+
import { basename as basename3, dirname as dirname7, join as join5, resolve as resolve7 } from "node:path";
|
|
3352
3299
|
|
|
3353
3300
|
// ../lsp-core/src/request-context.ts
|
|
3354
3301
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -3565,6 +3512,57 @@ function nearestExistingAncestor(directory) {
|
|
|
3565
3512
|
return current;
|
|
3566
3513
|
}
|
|
3567
3514
|
|
|
3515
|
+
// ../lsp-core/src/lsp/server-install-state.ts
|
|
3516
|
+
import { existsSync as existsSync7, mkdirSync, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
3517
|
+
import { dirname as dirname6 } from "node:path";
|
|
3518
|
+
function getInstallDecisionsPath() {
|
|
3519
|
+
return lspRequestContext().installDecisionsPath;
|
|
3520
|
+
}
|
|
3521
|
+
function loadInstallDecisions() {
|
|
3522
|
+
const path = getInstallDecisionsPath();
|
|
3523
|
+
if (!existsSync7(path))
|
|
3524
|
+
return {};
|
|
3525
|
+
try {
|
|
3526
|
+
const parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
3527
|
+
return isInstallDecisions(parsed) ? parsed : {};
|
|
3528
|
+
} catch {
|
|
3529
|
+
return {};
|
|
3530
|
+
}
|
|
3531
|
+
}
|
|
3532
|
+
function loadInstallDecision(serverId) {
|
|
3533
|
+
return loadInstallDecisions()[serverId];
|
|
3534
|
+
}
|
|
3535
|
+
function recordInstallDecision(serverId, decision, decidedAt = new Date().toISOString()) {
|
|
3536
|
+
const decisions = loadInstallDecisions();
|
|
3537
|
+
decisions[serverId] = { decision, decidedAt };
|
|
3538
|
+
writeInstallDecisions(decisions);
|
|
3539
|
+
}
|
|
3540
|
+
function isInstallDecision(value) {
|
|
3541
|
+
return value === "declined" || value === "allowed";
|
|
3542
|
+
}
|
|
3543
|
+
function writeInstallDecisions(decisions) {
|
|
3544
|
+
const path = getInstallDecisionsPath();
|
|
3545
|
+
mkdirSync(dirname6(path), { recursive: true });
|
|
3546
|
+
const tmpPath = `${path}.tmp`;
|
|
3547
|
+
writeFileSync2(tmpPath, `${JSON.stringify(decisions, null, 2)}
|
|
3548
|
+
`, "utf8");
|
|
3549
|
+
renameSync2(tmpPath, path);
|
|
3550
|
+
}
|
|
3551
|
+
function isInstallDecisions(value) {
|
|
3552
|
+
return isRecord5(value) && Object.values(value).every(isInstallDecisionRecord);
|
|
3553
|
+
}
|
|
3554
|
+
function isInstallDecisionRecord(value) {
|
|
3555
|
+
if (!isRecord5(value))
|
|
3556
|
+
return false;
|
|
3557
|
+
return isInstallDecision(value["decision"]) && typeof value["decidedAt"] === "string";
|
|
3558
|
+
}
|
|
3559
|
+
function isRecord5(value) {
|
|
3560
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3561
|
+
}
|
|
3562
|
+
|
|
3563
|
+
// ../lsp-core/src/lsp/config-loader.ts
|
|
3564
|
+
import { existsSync as existsSync8, readFileSync as readFileSync4 } from "node:fs";
|
|
3565
|
+
|
|
3568
3566
|
// ../lsp-core/src/lsp/server-definitions.ts
|
|
3569
3567
|
var LSP_INSTALL_HINTS = {
|
|
3570
3568
|
typescript: "npm install -g typescript-language-server typescript",
|
|
@@ -3610,26 +3608,6 @@ var LSP_INSTALL_HINTS = {
|
|
|
3610
3608
|
julials: `julia -e 'using Pkg; Pkg.add("LanguageServer")'`,
|
|
3611
3609
|
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"
|
|
3612
3610
|
};
|
|
3613
|
-
var LSP_LOCAL_INSTALL_HINTS = {
|
|
3614
|
-
typescript: "bun add -d typescript-language-server typescript",
|
|
3615
|
-
vue: "bun add -d @vue/language-server",
|
|
3616
|
-
eslint: "bun add -d vscode-langservers-extracted",
|
|
3617
|
-
oxlint: "bun add -d oxlint",
|
|
3618
|
-
biome: "bun add -d @biomejs/biome",
|
|
3619
|
-
svelte: "bun add -d svelte-language-server",
|
|
3620
|
-
astro: "bun add -d @astrojs/language-server",
|
|
3621
|
-
bash: "bun add -d bash-language-server",
|
|
3622
|
-
"bash-ls": "bun add -d bash-language-server",
|
|
3623
|
-
"yaml-ls": "bun add -d yaml-language-server",
|
|
3624
|
-
php: "bun add -d intelephense",
|
|
3625
|
-
prisma: "bun add -d prisma",
|
|
3626
|
-
dockerfile: "bun add -d dockerfile-language-server-nodejs",
|
|
3627
|
-
pyright: "uv add --dev pyright",
|
|
3628
|
-
basedpyright: "uv add --dev basedpyright",
|
|
3629
|
-
ruff: "uv add --dev ruff",
|
|
3630
|
-
ty: "uv add --dev ty",
|
|
3631
|
-
"ruby-lsp": "bundle add ruby-lsp --group development"
|
|
3632
|
-
};
|
|
3633
3611
|
var BUILTIN_SERVERS = {
|
|
3634
3612
|
typescript: {
|
|
3635
3613
|
command: ["typescript-language-server", "--stdio"],
|
|
@@ -3732,56 +3710,7 @@ var BUILTIN_SERVERS = {
|
|
|
3732
3710
|
}
|
|
3733
3711
|
};
|
|
3734
3712
|
|
|
3735
|
-
// ../lsp-core/src/lsp/server-install-state.ts
|
|
3736
|
-
import { existsSync as existsSync7, mkdirSync, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
3737
|
-
import { dirname as dirname6 } from "node:path";
|
|
3738
|
-
function getInstallDecisionsPath() {
|
|
3739
|
-
return lspRequestContext().installDecisionsPath;
|
|
3740
|
-
}
|
|
3741
|
-
function loadInstallDecisions() {
|
|
3742
|
-
const path = getInstallDecisionsPath();
|
|
3743
|
-
if (!existsSync7(path))
|
|
3744
|
-
return {};
|
|
3745
|
-
try {
|
|
3746
|
-
const parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
3747
|
-
return isInstallDecisions(parsed) ? parsed : {};
|
|
3748
|
-
} catch {
|
|
3749
|
-
return {};
|
|
3750
|
-
}
|
|
3751
|
-
}
|
|
3752
|
-
function loadInstallDecision(serverId) {
|
|
3753
|
-
return loadInstallDecisions()[serverId];
|
|
3754
|
-
}
|
|
3755
|
-
function recordInstallDecision(serverId, decision, decidedAt = new Date().toISOString()) {
|
|
3756
|
-
const decisions = loadInstallDecisions();
|
|
3757
|
-
decisions[serverId] = { decision, decidedAt };
|
|
3758
|
-
writeInstallDecisions(decisions);
|
|
3759
|
-
}
|
|
3760
|
-
function isInstallDecision(value) {
|
|
3761
|
-
return value === "declined" || value === "allowed";
|
|
3762
|
-
}
|
|
3763
|
-
function writeInstallDecisions(decisions) {
|
|
3764
|
-
const path = getInstallDecisionsPath();
|
|
3765
|
-
mkdirSync(dirname6(path), { recursive: true });
|
|
3766
|
-
const tmpPath = `${path}.tmp`;
|
|
3767
|
-
writeFileSync2(tmpPath, `${JSON.stringify(decisions, null, 2)}
|
|
3768
|
-
`, "utf8");
|
|
3769
|
-
renameSync2(tmpPath, path);
|
|
3770
|
-
}
|
|
3771
|
-
function isInstallDecisions(value) {
|
|
3772
|
-
return isRecord5(value) && Object.values(value).every(isInstallDecisionRecord);
|
|
3773
|
-
}
|
|
3774
|
-
function isInstallDecisionRecord(value) {
|
|
3775
|
-
if (!isRecord5(value))
|
|
3776
|
-
return false;
|
|
3777
|
-
return isInstallDecision(value["decision"]) && typeof value["decidedAt"] === "string";
|
|
3778
|
-
}
|
|
3779
|
-
function isRecord5(value) {
|
|
3780
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3781
|
-
}
|
|
3782
|
-
|
|
3783
3713
|
// ../lsp-core/src/lsp/config-loader.ts
|
|
3784
|
-
import { existsSync as existsSync8, readFileSync as readFileSync4 } from "node:fs";
|
|
3785
3714
|
function getProjectConfigPaths() {
|
|
3786
3715
|
return lspRequestContext().projectConfigPaths;
|
|
3787
3716
|
}
|
|
@@ -3978,154 +3907,53 @@ function getDisabledServerIds() {
|
|
|
3978
3907
|
|
|
3979
3908
|
// ../lsp-core/src/lsp/server-installation.ts
|
|
3980
3909
|
import { existsSync as existsSync9 } from "node:fs";
|
|
3981
|
-
import { delimiter as delimiter3,
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
"requirements.txt",
|
|
3992
|
-
"setup.py",
|
|
3993
|
-
"setup.cfg",
|
|
3994
|
-
"Pipfile",
|
|
3995
|
-
"pyrightconfig.json",
|
|
3996
|
-
"ruff.toml",
|
|
3997
|
-
".ruff.toml"
|
|
3998
|
-
],
|
|
3999
|
-
binDirs: [
|
|
4000
|
-
join4(".venv", "bin"),
|
|
4001
|
-
join4(".venv", "Scripts"),
|
|
4002
|
-
join4("venv", "bin"),
|
|
4003
|
-
join4("venv", "Scripts"),
|
|
4004
|
-
join4(".env", "bin"),
|
|
4005
|
-
join4(".env", "Scripts")
|
|
4006
|
-
]
|
|
4007
|
-
},
|
|
4008
|
-
{
|
|
4009
|
-
markers: ["Gemfile", "Gemfile.lock"],
|
|
4010
|
-
binDirs: [join4("vendor", "bundle", "bin"), "bin"]
|
|
4011
|
-
},
|
|
4012
|
-
{
|
|
4013
|
-
markers: ["go.mod", "go.sum", "go.work"],
|
|
4014
|
-
binDirs: ["bin"]
|
|
4015
|
-
}
|
|
4016
|
-
];
|
|
4017
|
-
var resolutionCache = new Map;
|
|
4018
|
-
var probeCount = 0;
|
|
4019
|
-
function probe(path) {
|
|
4020
|
-
probeCount += 1;
|
|
4021
|
-
return existsSync9(path);
|
|
4022
|
-
}
|
|
4023
|
-
function executableSuffixes(platform, pathExt) {
|
|
4024
|
-
if (platform !== "win32")
|
|
4025
|
-
return [""];
|
|
4026
|
-
const configured = pathExt ?? process.env["PATHEXT"] ?? "";
|
|
4027
|
-
const systemExts = configured.split(";").filter((entry) => entry.length > 0).map((entry) => entry.toLowerCase());
|
|
4028
|
-
return [...new Set(["", ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])];
|
|
4029
|
-
}
|
|
4030
|
-
function probeWithSuffixes(directory, command, suffixes) {
|
|
4031
|
-
for (const suffix of suffixes) {
|
|
4032
|
-
const candidate = join4(directory, command + suffix);
|
|
4033
|
-
if (probe(candidate))
|
|
4034
|
-
return candidate;
|
|
3910
|
+
import { delimiter as delimiter3, join as join4 } from "node:path";
|
|
3911
|
+
function isServerInstalled(command, _workingDirectory) {
|
|
3912
|
+
if (command.length === 0)
|
|
3913
|
+
return false;
|
|
3914
|
+
const [cmd] = command;
|
|
3915
|
+
if (!cmd)
|
|
3916
|
+
return false;
|
|
3917
|
+
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
3918
|
+
if (existsSync9(cmd))
|
|
3919
|
+
return true;
|
|
4035
3920
|
}
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
for (const binDir of rule.binDirs) {
|
|
4046
|
-
const found = probeWithSuffixes(join4(current, binDir), command, suffixes);
|
|
4047
|
-
if (found !== null)
|
|
4048
|
-
return found;
|
|
4049
|
-
}
|
|
3921
|
+
const isWindows = process.platform === "win32";
|
|
3922
|
+
let exts = [""];
|
|
3923
|
+
if (isWindows) {
|
|
3924
|
+
const pathExt = process.env["PATHEXT"] ?? "";
|
|
3925
|
+
if (pathExt) {
|
|
3926
|
+
const systemExts = pathExt.split(";").filter(Boolean);
|
|
3927
|
+
exts = [...new Set([...exts, ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])];
|
|
3928
|
+
} else {
|
|
3929
|
+
exts = ["", ".exe", ".cmd", ".bat", ".ps1"];
|
|
4050
3930
|
}
|
|
4051
|
-
if (probe(join4(current, ".git")))
|
|
4052
|
-
return null;
|
|
4053
|
-
if (boundary !== undefined && current === boundary)
|
|
4054
|
-
return null;
|
|
4055
|
-
const parent = dirname7(current);
|
|
4056
|
-
if (parent === current)
|
|
4057
|
-
return null;
|
|
4058
|
-
current = parent;
|
|
4059
3931
|
}
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
let pathEnv = pathEnvOverride ?? process.env["PATH"] ?? "";
|
|
4063
|
-
if (platform === "win32" && !pathEnv) {
|
|
3932
|
+
let pathEnv = process.env["PATH"] ?? "";
|
|
3933
|
+
if (isWindows && !pathEnv) {
|
|
4064
3934
|
pathEnv = process.env["Path"] ?? "";
|
|
4065
3935
|
}
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
3936
|
+
const paths = pathEnv.split(delimiter3);
|
|
3937
|
+
for (const p of paths) {
|
|
3938
|
+
for (const suffix of exts) {
|
|
3939
|
+
if (existsSync9(join4(p, cmd + suffix))) {
|
|
3940
|
+
return true;
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
4072
3943
|
}
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
if (command.length === 0)
|
|
4077
|
-
return null;
|
|
4078
|
-
const [cmd] = command;
|
|
4079
|
-
if (cmd === undefined || cmd.length === 0)
|
|
4080
|
-
return null;
|
|
4081
|
-
const platform = options.platform ?? process.platform;
|
|
4082
|
-
const suffixes = executableSuffixes(platform, options.pathExt);
|
|
4083
|
-
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
4084
|
-
const explicit = isAbsolute3(cmd) ? cmd : resolve7(workingDirectory ?? process.cwd(), cmd);
|
|
4085
|
-
return probe(explicit) ? explicit : null;
|
|
4086
|
-
}
|
|
4087
|
-
const cacheKey = JSON.stringify([
|
|
4088
|
-
workingDirectory ?? "",
|
|
4089
|
-
cmd,
|
|
4090
|
-
platform,
|
|
4091
|
-
options.stopAt ?? "",
|
|
4092
|
-
options.pathExt ?? "",
|
|
4093
|
-
options.pathEnv ?? process.env["PATH"] ?? ""
|
|
4094
|
-
]);
|
|
4095
|
-
const cached = resolutionCache.get(cacheKey);
|
|
4096
|
-
if (cached !== undefined)
|
|
4097
|
-
return cached;
|
|
4098
|
-
let resolved = null;
|
|
4099
|
-
if (workingDirectory !== undefined && workingDirectory.length > 0) {
|
|
4100
|
-
resolved = resolveLocal(cmd, workingDirectory, suffixes, options.stopAt);
|
|
4101
|
-
}
|
|
4102
|
-
resolved ??= resolveFromPath(cmd, suffixes, platform, options.pathEnv);
|
|
4103
|
-
if (resolved === null && cmd === "node")
|
|
4104
|
-
resolved = cmd;
|
|
4105
|
-
resolutionCache.set(cacheKey, resolved);
|
|
4106
|
-
return resolved;
|
|
4107
|
-
}
|
|
4108
|
-
function isServerInstalled(command, workingDirectory, options = {}) {
|
|
4109
|
-
if (command.length === 0)
|
|
4110
|
-
return false;
|
|
4111
|
-
return resolveServerBinary(command, workingDirectory, options) !== null;
|
|
3944
|
+
if (cmd === "node")
|
|
3945
|
+
return true;
|
|
3946
|
+
return false;
|
|
4112
3947
|
}
|
|
4113
3948
|
|
|
4114
3949
|
// ../lsp-core/src/lsp/server-resolution.ts
|
|
4115
|
-
function withResolvedCommand(command, binaryPath) {
|
|
4116
|
-
return [binaryPath, ...command.slice(1)];
|
|
4117
|
-
}
|
|
4118
3950
|
function findServerForExtension(ext) {
|
|
4119
3951
|
const servers = getMergedServers();
|
|
4120
|
-
const workingDirectory = contextCwd();
|
|
4121
3952
|
for (const server2 of servers) {
|
|
4122
|
-
if (
|
|
4123
|
-
continue;
|
|
4124
|
-
const binaryPath = resolveServerBinary(server2.command, workingDirectory);
|
|
4125
|
-
if (binaryPath !== null) {
|
|
3953
|
+
if (server2.extensions.includes(ext) && isServerInstalled(server2.command)) {
|
|
4126
3954
|
const resolvedServer = {
|
|
4127
3955
|
id: server2.id,
|
|
4128
|
-
command:
|
|
3956
|
+
command: server2.command,
|
|
4129
3957
|
extensions: server2.extensions,
|
|
4130
3958
|
priority: server2.priority
|
|
4131
3959
|
};
|
|
@@ -4172,7 +4000,6 @@ function findServerForExtension(ext) {
|
|
|
4172
4000
|
function getAllServers() {
|
|
4173
4001
|
const servers = getMergedServers();
|
|
4174
4002
|
const disabled = getDisabledServerIds();
|
|
4175
|
-
const workingDirectory = contextCwd();
|
|
4176
4003
|
const result = [];
|
|
4177
4004
|
const seen = new Set;
|
|
4178
4005
|
for (const server2 of servers) {
|
|
@@ -4180,7 +4007,7 @@ function getAllServers() {
|
|
|
4180
4007
|
continue;
|
|
4181
4008
|
result.push({
|
|
4182
4009
|
id: server2.id,
|
|
4183
|
-
installed: isServerInstalled(server2.command
|
|
4010
|
+
installed: isServerInstalled(server2.command),
|
|
4184
4011
|
extensions: server2.extensions,
|
|
4185
4012
|
disabled: false,
|
|
4186
4013
|
source: server2.source,
|
|
@@ -4194,7 +4021,7 @@ function getAllServers() {
|
|
|
4194
4021
|
const builtin = BUILTIN_SERVERS[id];
|
|
4195
4022
|
result.push({
|
|
4196
4023
|
id,
|
|
4197
|
-
installed: builtin ? isServerInstalled(builtin.command
|
|
4024
|
+
installed: builtin ? isServerInstalled(builtin.command) : false,
|
|
4198
4025
|
extensions: builtin?.extensions ?? [],
|
|
4199
4026
|
disabled: true,
|
|
4200
4027
|
source: "disabled",
|
|
@@ -4217,7 +4044,7 @@ function findWorkspaceRoot(filePath) {
|
|
|
4217
4044
|
const abs = resolveReadablePathInsideContext(filePath);
|
|
4218
4045
|
let dir = abs;
|
|
4219
4046
|
if (!isDirectoryPath(dir)) {
|
|
4220
|
-
dir =
|
|
4047
|
+
dir = dirname7(dir);
|
|
4221
4048
|
}
|
|
4222
4049
|
if (!isPathInside(cwd, abs))
|
|
4223
4050
|
return findWorkspaceRootOutsideContext(dir);
|
|
@@ -4233,13 +4060,13 @@ function findWorkspaceRoot(filePath) {
|
|
|
4233
4060
|
}
|
|
4234
4061
|
if (dir === cwd)
|
|
4235
4062
|
break;
|
|
4236
|
-
dir =
|
|
4063
|
+
dir = dirname7(dir);
|
|
4237
4064
|
}
|
|
4238
4065
|
return fallbackRoot;
|
|
4239
4066
|
}
|
|
4240
4067
|
function resolveReadablePathInsideContext(filePath) {
|
|
4241
4068
|
const cwd = contextCwd();
|
|
4242
|
-
const abs =
|
|
4069
|
+
const abs = resolve7(cwd, filePath);
|
|
4243
4070
|
if (isPathInside(cwd, abs))
|
|
4244
4071
|
return abs;
|
|
4245
4072
|
const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
|
|
@@ -4265,7 +4092,7 @@ function rebaseThroughCanonicalAncestor(path, cwd) {
|
|
|
4265
4092
|
if (isPathInside(cwd, canonical))
|
|
4266
4093
|
return suffix.length === 0 ? canonical : join5(canonical, ...suffix);
|
|
4267
4094
|
}
|
|
4268
|
-
const parent =
|
|
4095
|
+
const parent = dirname7(current);
|
|
4269
4096
|
if (parent === current)
|
|
4270
4097
|
return;
|
|
4271
4098
|
suffix.unshift(basename3(current));
|
|
@@ -4288,7 +4115,7 @@ function nearestExistingDirectoryInsideContext(directory, cwd) {
|
|
|
4288
4115
|
return canonical;
|
|
4289
4116
|
if (current === cwd)
|
|
4290
4117
|
return;
|
|
4291
|
-
current =
|
|
4118
|
+
current = dirname7(current);
|
|
4292
4119
|
}
|
|
4293
4120
|
return;
|
|
4294
4121
|
}
|
|
@@ -4315,19 +4142,6 @@ function formatServerLookupError(result) {
|
|
|
4315
4142
|
].join(`
|
|
4316
4143
|
`);
|
|
4317
4144
|
}
|
|
4318
|
-
function formatInstallOptions(serverId, installHint) {
|
|
4319
|
-
const localHint = LSP_LOCAL_INSTALL_HINTS[serverId];
|
|
4320
|
-
if (localHint === undefined) {
|
|
4321
|
-
return ["To install, run:", ` ${installHint}`];
|
|
4322
|
-
}
|
|
4323
|
-
return [
|
|
4324
|
-
"To install in THIS repository (preferred — no global install needed):",
|
|
4325
|
-
` ${localHint}`,
|
|
4326
|
-
"",
|
|
4327
|
-
"Or install it globally:",
|
|
4328
|
-
` ${installHint}`
|
|
4329
|
-
];
|
|
4330
|
-
}
|
|
4331
4145
|
function formatNotInstalled(result) {
|
|
4332
4146
|
const { server: server2, installHint } = result;
|
|
4333
4147
|
const extensions = server2.extensions.join(", ");
|
|
@@ -4342,19 +4156,19 @@ function formatNotInstalled(result) {
|
|
|
4342
4156
|
`Command not found: ${server2.command[0]}`,
|
|
4343
4157
|
""
|
|
4344
4158
|
];
|
|
4345
|
-
const installOptions = formatInstallOptions(server2.id, installHint);
|
|
4346
4159
|
if (decision === "allowed") {
|
|
4347
4160
|
return [
|
|
4348
4161
|
...header,
|
|
4349
4162
|
"The user has pre-authorized LSP installation. Run the install command, then retry this tool:",
|
|
4350
|
-
|
|
4163
|
+
` ${installHint}`
|
|
4351
4164
|
].join(`
|
|
4352
4165
|
`);
|
|
4353
4166
|
}
|
|
4354
4167
|
if (!context.capabilities.installDecisionTool) {
|
|
4355
4168
|
return [
|
|
4356
4169
|
...header,
|
|
4357
|
-
|
|
4170
|
+
"To install, run:",
|
|
4171
|
+
` ${installHint}`,
|
|
4358
4172
|
"",
|
|
4359
4173
|
"ACTION REQUIRED — ASK THE USER whether to install this LSP server.",
|
|
4360
4174
|
"Install-decision recording is unavailable in this harness; proceed without LSP if the user declines."
|
|
@@ -4363,7 +4177,8 @@ function formatNotInstalled(result) {
|
|
|
4363
4177
|
}
|
|
4364
4178
|
return [
|
|
4365
4179
|
...header,
|
|
4366
|
-
|
|
4180
|
+
"To install, run:",
|
|
4181
|
+
` ${installHint}`,
|
|
4367
4182
|
"",
|
|
4368
4183
|
"ACTION REQUIRED — ASK THE USER whether to install this LSP server.",
|
|
4369
4184
|
"- If the user agrees: run the install command above, then retry this tool.",
|
|
@@ -4419,7 +4234,7 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
|
4419
4234
|
|
|
4420
4235
|
// ../lsp-core/src/lsp/directory-diagnostics.ts
|
|
4421
4236
|
import { existsSync as existsSync11, lstatSync as lstatSync4, readdirSync as readdirSync3 } from "node:fs";
|
|
4422
|
-
import { join as join6, resolve as
|
|
4237
|
+
import { join as join6, resolve as resolve8 } from "node:path";
|
|
4423
4238
|
|
|
4424
4239
|
// ../lsp-core/src/lsp/formatters.ts
|
|
4425
4240
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -4574,7 +4389,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
4574
4389
|
if (!extension.startsWith(".")) {
|
|
4575
4390
|
throw new LspInvalidPathError(`Extension must start with a dot (e.g., ".ts", not "${extension}"). Use ".${extension}" instead.`);
|
|
4576
4391
|
}
|
|
4577
|
-
const absDir =
|
|
4392
|
+
const absDir = resolve8(options.workspaceRoot ?? contextCwd(), directory);
|
|
4578
4393
|
if (!existsSync11(absDir)) {
|
|
4579
4394
|
throw new LspInvalidPathError(`Directory does not exist: ${absDir}`);
|
|
4580
4395
|
}
|
|
@@ -4931,96 +4746,6 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
4931
4746
|
throw error;
|
|
4932
4747
|
}
|
|
4933
4748
|
}
|
|
4934
|
-
// ../lsp-core/src/lsp/format-document.ts
|
|
4935
|
-
import { readFileSync as readFileSync5, renameSync as renameSync3, unlinkSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
4936
|
-
var DEFAULT_FORMATTING_OPTIONS = {
|
|
4937
|
-
tabSize: 4,
|
|
4938
|
-
insertSpaces: false,
|
|
4939
|
-
trimTrailingWhitespace: true,
|
|
4940
|
-
insertFinalNewline: true,
|
|
4941
|
-
trimFinalNewlines: true
|
|
4942
|
-
};
|
|
4943
|
-
var UNCHANGED = { status: "unchanged", linesAdded: 0, linesRemoved: 0 };
|
|
4944
|
-
async function formatDocumentWithClient(client, filePath, options = {}) {
|
|
4945
|
-
const edits = await client.formatDocument(filePath, options.formattingOptions ?? DEFAULT_FORMATTING_OPTIONS, options.signal);
|
|
4946
|
-
if (edits === null)
|
|
4947
|
-
return { status: "unavailable", reason: "capability_not_advertised" };
|
|
4948
|
-
if (edits.length === 0)
|
|
4949
|
-
return UNCHANGED;
|
|
4950
|
-
const before = readFileSync5(filePath, "utf-8");
|
|
4951
|
-
const normalized = normalizeTextEdits(before, edits, 0);
|
|
4952
|
-
if (normalized.text === before)
|
|
4953
|
-
return UNCHANGED;
|
|
4954
|
-
writeAtomically(filePath, normalized.text);
|
|
4955
|
-
await client.openFile(filePath);
|
|
4956
|
-
return {
|
|
4957
|
-
status: "formatted",
|
|
4958
|
-
...lineDelta(normalized.edits)
|
|
4959
|
-
};
|
|
4960
|
-
}
|
|
4961
|
-
function lineDelta(edits) {
|
|
4962
|
-
let linesAdded = 0;
|
|
4963
|
-
let linesRemoved = 0;
|
|
4964
|
-
for (const edit of edits) {
|
|
4965
|
-
linesRemoved += edit.range.end.line - edit.range.start.line + 1;
|
|
4966
|
-
linesAdded += edit.newText.split(`
|
|
4967
|
-
`).length;
|
|
4968
|
-
}
|
|
4969
|
-
return { linesAdded, linesRemoved };
|
|
4970
|
-
}
|
|
4971
|
-
function writeAtomically(filePath, content) {
|
|
4972
|
-
const tempPath = `${filePath}.omo-format.tmp`;
|
|
4973
|
-
writeFileSync3(tempPath, content, "utf-8");
|
|
4974
|
-
try {
|
|
4975
|
-
renameSync3(tempPath, filePath);
|
|
4976
|
-
} catch (error) {
|
|
4977
|
-
try {
|
|
4978
|
-
unlinkSync(tempPath);
|
|
4979
|
-
} catch {}
|
|
4980
|
-
throw error;
|
|
4981
|
-
}
|
|
4982
|
-
}
|
|
4983
|
-
|
|
4984
|
-
// ../lsp-core/src/tools/format.ts
|
|
4985
|
-
async function executeLspFormat(params, signal) {
|
|
4986
|
-
const filePath = requireString(params, "filePath");
|
|
4987
|
-
try {
|
|
4988
|
-
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => formatDocumentWithClient(client, resolvedFilePath, signal === undefined ? {} : { signal }), "format", clientOptions(signal));
|
|
4989
|
-
return text(describeResult(filePath, result), formatDetails(filePath, result));
|
|
4990
|
-
} catch (error) {
|
|
4991
|
-
const missingDependency = missingDependencyResult(error, {
|
|
4992
|
-
filePath,
|
|
4993
|
-
status: "unavailable",
|
|
4994
|
-
reason: "server_unavailable",
|
|
4995
|
-
linesAdded: 0,
|
|
4996
|
-
linesRemoved: 0
|
|
4997
|
-
});
|
|
4998
|
-
if (missingDependency)
|
|
4999
|
-
return missingDependency;
|
|
5000
|
-
throw error;
|
|
5001
|
-
}
|
|
5002
|
-
}
|
|
5003
|
-
function formatDetails(filePath, result) {
|
|
5004
|
-
if (result.status === "unavailable") {
|
|
5005
|
-
return { filePath, status: "unavailable", reason: result.reason, linesAdded: 0, linesRemoved: 0 };
|
|
5006
|
-
}
|
|
5007
|
-
return {
|
|
5008
|
-
filePath,
|
|
5009
|
-
status: result.status,
|
|
5010
|
-
linesAdded: result.linesAdded,
|
|
5011
|
-
linesRemoved: result.linesRemoved
|
|
5012
|
-
};
|
|
5013
|
-
}
|
|
5014
|
-
function describeResult(filePath, result) {
|
|
5015
|
-
if (result.status === "unavailable") {
|
|
5016
|
-
return `Formatting unavailable for ${filePath}: the language server does not advertise documentFormattingProvider.`;
|
|
5017
|
-
}
|
|
5018
|
-
if (result.status === "unchanged") {
|
|
5019
|
-
return `Already formatted: ${filePath}`;
|
|
5020
|
-
}
|
|
5021
|
-
return `Formatted ${filePath} (+${result.linesAdded}/-${result.linesRemoved} lines)`;
|
|
5022
|
-
}
|
|
5023
|
-
|
|
5024
4749
|
// ../lsp-core/src/tools/install-decision.ts
|
|
5025
4750
|
async function executeLspInstallDecision(params) {
|
|
5026
4751
|
const serverId = requireString(params, "server_id");
|
|
@@ -5353,16 +5078,6 @@ var LSP_MCP_TOOLS = [
|
|
|
5353
5078
|
}, ["filePath", "line", "character", "newName"]),
|
|
5354
5079
|
execute: executeLspRename
|
|
5355
5080
|
},
|
|
5356
|
-
{
|
|
5357
|
-
name: "format",
|
|
5358
|
-
aliases: ["lsp_format"],
|
|
5359
|
-
title: "LSP Format",
|
|
5360
|
-
description: "Format a source file with its language server and write the returned edits to disk.",
|
|
5361
|
-
inputSchema: objectSchema({
|
|
5362
|
-
filePath: { type: "string", description: "Source file path to format." }
|
|
5363
|
-
}, ["filePath"]),
|
|
5364
|
-
execute: executeLspFormat
|
|
5365
|
-
},
|
|
5366
5081
|
{
|
|
5367
5082
|
name: "install_decision",
|
|
5368
5083
|
aliases: ["lsp_install_decision"],
|