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
|
@@ -23,7 +23,6 @@ var DEFAULT_MAX_DIRECTORY_FILES = 50;
|
|
|
23
23
|
var REQUEST_TIMEOUT_MS = 15000;
|
|
24
24
|
var INIT_TIMEOUT_MS = 60000;
|
|
25
25
|
var IDLE_TIMEOUT_MS = 5 * 60000;
|
|
26
|
-
var MAX_RESIDENT_CLIENTS = 6;
|
|
27
26
|
var REAPER_INTERVAL_MS = 60000;
|
|
28
27
|
var STOP_HARD_KILL_TIMEOUT_MS = 5000;
|
|
29
28
|
var STOP_SIGKILL_GRACE_MS = 1000;
|
|
@@ -616,7 +615,6 @@ class LspClientTransport {
|
|
|
616
615
|
this.diagnosticsStore = new Map;
|
|
617
616
|
this.workspaceApplyEditHandler = null;
|
|
618
617
|
this.diagnosticPullSupported = false;
|
|
619
|
-
this.documentFormattingSupported = false;
|
|
620
618
|
this.requestTimeoutMs = timeouts.requestTimeoutMs ?? REQUEST_TIMEOUT_MS;
|
|
621
619
|
this.initializeTimeoutMs = timeouts.initializeTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
622
620
|
}
|
|
@@ -638,12 +636,6 @@ class LspClientTransport {
|
|
|
638
636
|
isDiagnosticPullSupported() {
|
|
639
637
|
return this.diagnosticPullSupported;
|
|
640
638
|
}
|
|
641
|
-
setDocumentFormattingSupported(supported) {
|
|
642
|
-
this.documentFormattingSupported = supported;
|
|
643
|
-
}
|
|
644
|
-
isDocumentFormattingSupported() {
|
|
645
|
-
return this.documentFormattingSupported;
|
|
646
|
-
}
|
|
647
639
|
handlePublishDiagnostics(params) {
|
|
648
640
|
this.diagnosticsStore.set(params.uri, [...params.diagnostics]);
|
|
649
641
|
}
|
|
@@ -857,14 +849,6 @@ function supportsDiagnosticPull(capabilities) {
|
|
|
857
849
|
return false;
|
|
858
850
|
return Object.hasOwn(capabilities, "diagnosticProvider");
|
|
859
851
|
}
|
|
860
|
-
function supportsDocumentFormatting(capabilities) {
|
|
861
|
-
if (capabilities === undefined)
|
|
862
|
-
return false;
|
|
863
|
-
const provider = capabilities.documentFormattingProvider;
|
|
864
|
-
if (provider === undefined || provider === null || provider === false)
|
|
865
|
-
return false;
|
|
866
|
-
return provider === true || typeof provider === "object";
|
|
867
|
-
}
|
|
868
852
|
|
|
869
853
|
class LspClientConnection extends LspClientTransport {
|
|
870
854
|
async initialize() {
|
|
@@ -881,7 +865,6 @@ class LspClientConnection extends LspClientTransport {
|
|
|
881
865
|
references: {},
|
|
882
866
|
documentSymbol: { hierarchicalDocumentSymbolSupport: true },
|
|
883
867
|
publishDiagnostics: {},
|
|
884
|
-
formatting: { dynamicRegistration: false },
|
|
885
868
|
rename: {
|
|
886
869
|
prepareSupport: true,
|
|
887
870
|
prepareSupportDefaultBehavior: 1
|
|
@@ -923,7 +906,6 @@ class LspClientConnection extends LspClientTransport {
|
|
|
923
906
|
initializationOptions: this.server.initialization
|
|
924
907
|
}, { timeoutMs: this.initializeTimeoutMs });
|
|
925
908
|
this.setDiagnosticPullSupported(supportsDiagnosticPull(result?.capabilities));
|
|
926
|
-
this.setDocumentFormattingSupported(supportsDocumentFormatting(result?.capabilities));
|
|
927
909
|
await this.sendNotification("initialized", {});
|
|
928
910
|
await this.sendNotification("workspace/didChangeConfiguration", {
|
|
929
911
|
settings: { json: { validate: { enable: true } } }
|
|
@@ -2518,18 +2500,6 @@ class LspClient extends LspClientConnection {
|
|
|
2518
2500
|
textDocument: { uri: pathToFileURL3(absPath).href }
|
|
2519
2501
|
}, options);
|
|
2520
2502
|
}
|
|
2521
|
-
async formatDocument(filePath, options, signal) {
|
|
2522
|
-
if (!this.isDocumentFormattingSupported())
|
|
2523
|
-
return null;
|
|
2524
|
-
const absPath = this.resolveWorkspacePath(filePath);
|
|
2525
|
-
await this.openFile(absPath);
|
|
2526
|
-
const requestOptions = signal === undefined ? {} : { signal };
|
|
2527
|
-
const edits = await this.sendRequest("textDocument/formatting", {
|
|
2528
|
-
textDocument: { uri: pathToFileURL3(absPath).href },
|
|
2529
|
-
options
|
|
2530
|
-
}, requestOptions);
|
|
2531
|
-
return edits ?? [];
|
|
2532
|
-
}
|
|
2533
2503
|
async workspaceSymbols(query, signal) {
|
|
2534
2504
|
const options = signal === undefined ? {} : { signal };
|
|
2535
2505
|
return this.sendRequest("workspace/symbol", { query }, options);
|
|
@@ -2782,7 +2752,6 @@ class LspManager {
|
|
|
2782
2752
|
this.disposed = false;
|
|
2783
2753
|
this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS;
|
|
2784
2754
|
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
2785
|
-
this.maxResidentClients = options.maxResidentClients ?? MAX_RESIDENT_CLIENTS;
|
|
2786
2755
|
this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
|
|
2787
2756
|
this.clientFactory = options.clientFactory ?? ((root, server) => new LspClient(root, server));
|
|
2788
2757
|
this.now = options.now ?? (() => Date.now());
|
|
@@ -2816,26 +2785,6 @@ class LspManager {
|
|
|
2816
2785
|
}
|
|
2817
2786
|
}
|
|
2818
2787
|
}
|
|
2819
|
-
evictForAdmission() {
|
|
2820
|
-
while (this.clients.size >= this.maxResidentClients) {
|
|
2821
|
-
const victim = this.leastRecentlyUsedIdleClient();
|
|
2822
|
-
if (!victim)
|
|
2823
|
-
return;
|
|
2824
|
-
this.clients.delete(victim.key);
|
|
2825
|
-
stopClientBestEffort(victim.managed.client);
|
|
2826
|
-
}
|
|
2827
|
-
}
|
|
2828
|
-
leastRecentlyUsedIdleClient() {
|
|
2829
|
-
let candidate = null;
|
|
2830
|
-
for (const [key, managed] of this.clients) {
|
|
2831
|
-
if (managed.refCount > 0 || managed.pendingWaiters > 0 || managed.isInitializing)
|
|
2832
|
-
continue;
|
|
2833
|
-
if (candidate === null || managed.lastUsedAt < candidate.managed.lastUsedAt) {
|
|
2834
|
-
candidate = { key, managed };
|
|
2835
|
-
}
|
|
2836
|
-
}
|
|
2837
|
-
return candidate;
|
|
2838
|
-
}
|
|
2839
2788
|
async tryDeleteIfOrphaned(key, managed) {
|
|
2840
2789
|
if (managed.refCount === 0 && managed.pendingWaiters === 0 && !managed.isInitializing && this.clients.get(key) === managed) {
|
|
2841
2790
|
this.clients.delete(key);
|
|
@@ -2882,7 +2831,6 @@ class LspManager {
|
|
|
2882
2831
|
managed.lastUsedAt = this.now();
|
|
2883
2832
|
return managed.client;
|
|
2884
2833
|
}
|
|
2885
|
-
this.evictForAdmission();
|
|
2886
2834
|
const client = this.clientFactory(root, server);
|
|
2887
2835
|
const initStartedAt = this.now();
|
|
2888
2836
|
const initPromise = (async () => {
|
|
@@ -2945,7 +2893,6 @@ class LspManager {
|
|
|
2945
2893
|
const key = this.getKey(root, server.id);
|
|
2946
2894
|
if (this.clients.has(key))
|
|
2947
2895
|
return;
|
|
2948
|
-
this.evictForAdmission();
|
|
2949
2896
|
const client = this.clientFactory(root, server);
|
|
2950
2897
|
const initStartedAt = this.now();
|
|
2951
2898
|
const initPromise = (async () => {
|
|
@@ -4174,7 +4121,7 @@ function createIdleTimer(idleTimeoutMs, log, onTimeout) {
|
|
|
4174
4121
|
}
|
|
4175
4122
|
// ../lsp-core/src/lsp/client-wrapper.ts
|
|
4176
4123
|
import { existsSync as existsSync11, realpathSync as realpathSync5, statSync as statSync4 } from "node:fs";
|
|
4177
|
-
import { basename as basename3, dirname as
|
|
4124
|
+
import { basename as basename3, dirname as dirname9, join as join5, resolve as resolve7 } from "node:path";
|
|
4178
4125
|
|
|
4179
4126
|
// ../lsp-core/src/lsp/outside-context-workspace.ts
|
|
4180
4127
|
import { existsSync as existsSync7, realpathSync as realpathSync4 } from "node:fs";
|
|
@@ -4213,6 +4160,57 @@ function nearestExistingAncestor(directory) {
|
|
|
4213
4160
|
return current;
|
|
4214
4161
|
}
|
|
4215
4162
|
|
|
4163
|
+
// ../lsp-core/src/lsp/server-install-state.ts
|
|
4164
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
4165
|
+
import { dirname as dirname8 } from "node:path";
|
|
4166
|
+
function getInstallDecisionsPath() {
|
|
4167
|
+
return lspRequestContext().installDecisionsPath;
|
|
4168
|
+
}
|
|
4169
|
+
function loadInstallDecisions() {
|
|
4170
|
+
const path2 = getInstallDecisionsPath();
|
|
4171
|
+
if (!existsSync8(path2))
|
|
4172
|
+
return {};
|
|
4173
|
+
try {
|
|
4174
|
+
const parsed = JSON.parse(readFileSync4(path2, "utf8"));
|
|
4175
|
+
return isInstallDecisions(parsed) ? parsed : {};
|
|
4176
|
+
} catch {
|
|
4177
|
+
return {};
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
4180
|
+
function loadInstallDecision(serverId) {
|
|
4181
|
+
return loadInstallDecisions()[serverId];
|
|
4182
|
+
}
|
|
4183
|
+
function recordInstallDecision(serverId, decision, decidedAt = new Date().toISOString()) {
|
|
4184
|
+
const decisions = loadInstallDecisions();
|
|
4185
|
+
decisions[serverId] = { decision, decidedAt };
|
|
4186
|
+
writeInstallDecisions(decisions);
|
|
4187
|
+
}
|
|
4188
|
+
function isInstallDecision(value) {
|
|
4189
|
+
return value === "declined" || value === "allowed";
|
|
4190
|
+
}
|
|
4191
|
+
function writeInstallDecisions(decisions) {
|
|
4192
|
+
const path2 = getInstallDecisionsPath();
|
|
4193
|
+
mkdirSync3(dirname8(path2), { recursive: true });
|
|
4194
|
+
const tmpPath = `${path2}.tmp`;
|
|
4195
|
+
writeFileSync2(tmpPath, `${JSON.stringify(decisions, null, 2)}
|
|
4196
|
+
`, "utf8");
|
|
4197
|
+
renameSync2(tmpPath, path2);
|
|
4198
|
+
}
|
|
4199
|
+
function isInstallDecisions(value) {
|
|
4200
|
+
return isRecord5(value) && Object.values(value).every(isInstallDecisionRecord);
|
|
4201
|
+
}
|
|
4202
|
+
function isInstallDecisionRecord(value) {
|
|
4203
|
+
if (!isRecord5(value))
|
|
4204
|
+
return false;
|
|
4205
|
+
return isInstallDecision(value["decision"]) && typeof value["decidedAt"] === "string";
|
|
4206
|
+
}
|
|
4207
|
+
function isRecord5(value) {
|
|
4208
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4209
|
+
}
|
|
4210
|
+
|
|
4211
|
+
// ../lsp-core/src/lsp/config-loader.ts
|
|
4212
|
+
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
|
|
4213
|
+
|
|
4216
4214
|
// ../lsp-core/src/lsp/server-definitions.ts
|
|
4217
4215
|
var LSP_INSTALL_HINTS = {
|
|
4218
4216
|
typescript: "npm install -g typescript-language-server typescript",
|
|
@@ -4258,26 +4256,6 @@ var LSP_INSTALL_HINTS = {
|
|
|
4258
4256
|
julials: `julia -e 'using Pkg; Pkg.add("LanguageServer")'`,
|
|
4259
4257
|
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"
|
|
4260
4258
|
};
|
|
4261
|
-
var LSP_LOCAL_INSTALL_HINTS = {
|
|
4262
|
-
typescript: "bun add -d typescript-language-server typescript",
|
|
4263
|
-
vue: "bun add -d @vue/language-server",
|
|
4264
|
-
eslint: "bun add -d vscode-langservers-extracted",
|
|
4265
|
-
oxlint: "bun add -d oxlint",
|
|
4266
|
-
biome: "bun add -d @biomejs/biome",
|
|
4267
|
-
svelte: "bun add -d svelte-language-server",
|
|
4268
|
-
astro: "bun add -d @astrojs/language-server",
|
|
4269
|
-
bash: "bun add -d bash-language-server",
|
|
4270
|
-
"bash-ls": "bun add -d bash-language-server",
|
|
4271
|
-
"yaml-ls": "bun add -d yaml-language-server",
|
|
4272
|
-
php: "bun add -d intelephense",
|
|
4273
|
-
prisma: "bun add -d prisma",
|
|
4274
|
-
dockerfile: "bun add -d dockerfile-language-server-nodejs",
|
|
4275
|
-
pyright: "uv add --dev pyright",
|
|
4276
|
-
basedpyright: "uv add --dev basedpyright",
|
|
4277
|
-
ruff: "uv add --dev ruff",
|
|
4278
|
-
ty: "uv add --dev ty",
|
|
4279
|
-
"ruby-lsp": "bundle add ruby-lsp --group development"
|
|
4280
|
-
};
|
|
4281
4259
|
var BUILTIN_SERVERS = {
|
|
4282
4260
|
typescript: {
|
|
4283
4261
|
command: ["typescript-language-server", "--stdio"],
|
|
@@ -4380,56 +4358,7 @@ var BUILTIN_SERVERS = {
|
|
|
4380
4358
|
}
|
|
4381
4359
|
};
|
|
4382
4360
|
|
|
4383
|
-
// ../lsp-core/src/lsp/server-install-state.ts
|
|
4384
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
4385
|
-
import { dirname as dirname8 } from "node:path";
|
|
4386
|
-
function getInstallDecisionsPath() {
|
|
4387
|
-
return lspRequestContext().installDecisionsPath;
|
|
4388
|
-
}
|
|
4389
|
-
function loadInstallDecisions() {
|
|
4390
|
-
const path2 = getInstallDecisionsPath();
|
|
4391
|
-
if (!existsSync8(path2))
|
|
4392
|
-
return {};
|
|
4393
|
-
try {
|
|
4394
|
-
const parsed = JSON.parse(readFileSync4(path2, "utf8"));
|
|
4395
|
-
return isInstallDecisions(parsed) ? parsed : {};
|
|
4396
|
-
} catch {
|
|
4397
|
-
return {};
|
|
4398
|
-
}
|
|
4399
|
-
}
|
|
4400
|
-
function loadInstallDecision(serverId) {
|
|
4401
|
-
return loadInstallDecisions()[serverId];
|
|
4402
|
-
}
|
|
4403
|
-
function recordInstallDecision(serverId, decision, decidedAt = new Date().toISOString()) {
|
|
4404
|
-
const decisions = loadInstallDecisions();
|
|
4405
|
-
decisions[serverId] = { decision, decidedAt };
|
|
4406
|
-
writeInstallDecisions(decisions);
|
|
4407
|
-
}
|
|
4408
|
-
function isInstallDecision(value) {
|
|
4409
|
-
return value === "declined" || value === "allowed";
|
|
4410
|
-
}
|
|
4411
|
-
function writeInstallDecisions(decisions) {
|
|
4412
|
-
const path2 = getInstallDecisionsPath();
|
|
4413
|
-
mkdirSync3(dirname8(path2), { recursive: true });
|
|
4414
|
-
const tmpPath = `${path2}.tmp`;
|
|
4415
|
-
writeFileSync2(tmpPath, `${JSON.stringify(decisions, null, 2)}
|
|
4416
|
-
`, "utf8");
|
|
4417
|
-
renameSync2(tmpPath, path2);
|
|
4418
|
-
}
|
|
4419
|
-
function isInstallDecisions(value) {
|
|
4420
|
-
return isRecord5(value) && Object.values(value).every(isInstallDecisionRecord);
|
|
4421
|
-
}
|
|
4422
|
-
function isInstallDecisionRecord(value) {
|
|
4423
|
-
if (!isRecord5(value))
|
|
4424
|
-
return false;
|
|
4425
|
-
return isInstallDecision(value["decision"]) && typeof value["decidedAt"] === "string";
|
|
4426
|
-
}
|
|
4427
|
-
function isRecord5(value) {
|
|
4428
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4429
|
-
}
|
|
4430
|
-
|
|
4431
4361
|
// ../lsp-core/src/lsp/config-loader.ts
|
|
4432
|
-
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
|
|
4433
4362
|
function getProjectConfigPaths() {
|
|
4434
4363
|
return lspRequestContext().projectConfigPaths;
|
|
4435
4364
|
}
|
|
@@ -4626,154 +4555,53 @@ function getDisabledServerIds() {
|
|
|
4626
4555
|
|
|
4627
4556
|
// ../lsp-core/src/lsp/server-installation.ts
|
|
4628
4557
|
import { existsSync as existsSync10 } from "node:fs";
|
|
4629
|
-
import { delimiter as delimiter3,
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
"requirements.txt",
|
|
4640
|
-
"setup.py",
|
|
4641
|
-
"setup.cfg",
|
|
4642
|
-
"Pipfile",
|
|
4643
|
-
"pyrightconfig.json",
|
|
4644
|
-
"ruff.toml",
|
|
4645
|
-
".ruff.toml"
|
|
4646
|
-
],
|
|
4647
|
-
binDirs: [
|
|
4648
|
-
join4(".venv", "bin"),
|
|
4649
|
-
join4(".venv", "Scripts"),
|
|
4650
|
-
join4("venv", "bin"),
|
|
4651
|
-
join4("venv", "Scripts"),
|
|
4652
|
-
join4(".env", "bin"),
|
|
4653
|
-
join4(".env", "Scripts")
|
|
4654
|
-
]
|
|
4655
|
-
},
|
|
4656
|
-
{
|
|
4657
|
-
markers: ["Gemfile", "Gemfile.lock"],
|
|
4658
|
-
binDirs: [join4("vendor", "bundle", "bin"), "bin"]
|
|
4659
|
-
},
|
|
4660
|
-
{
|
|
4661
|
-
markers: ["go.mod", "go.sum", "go.work"],
|
|
4662
|
-
binDirs: ["bin"]
|
|
4663
|
-
}
|
|
4664
|
-
];
|
|
4665
|
-
var resolutionCache = new Map;
|
|
4666
|
-
var probeCount = 0;
|
|
4667
|
-
function probe(path2) {
|
|
4668
|
-
probeCount += 1;
|
|
4669
|
-
return existsSync10(path2);
|
|
4670
|
-
}
|
|
4671
|
-
function executableSuffixes(platform, pathExt) {
|
|
4672
|
-
if (platform !== "win32")
|
|
4673
|
-
return [""];
|
|
4674
|
-
const configured = pathExt ?? process.env["PATHEXT"] ?? "";
|
|
4675
|
-
const systemExts = configured.split(";").filter((entry) => entry.length > 0).map((entry) => entry.toLowerCase());
|
|
4676
|
-
return [...new Set(["", ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])];
|
|
4677
|
-
}
|
|
4678
|
-
function probeWithSuffixes(directory, command, suffixes) {
|
|
4679
|
-
for (const suffix of suffixes) {
|
|
4680
|
-
const candidate = join4(directory, command + suffix);
|
|
4681
|
-
if (probe(candidate))
|
|
4682
|
-
return candidate;
|
|
4558
|
+
import { delimiter as delimiter3, join as join4 } from "node:path";
|
|
4559
|
+
function isServerInstalled(command, _workingDirectory) {
|
|
4560
|
+
if (command.length === 0)
|
|
4561
|
+
return false;
|
|
4562
|
+
const [cmd] = command;
|
|
4563
|
+
if (!cmd)
|
|
4564
|
+
return false;
|
|
4565
|
+
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
4566
|
+
if (existsSync10(cmd))
|
|
4567
|
+
return true;
|
|
4683
4568
|
}
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
for (const binDir of rule.binDirs) {
|
|
4694
|
-
const found = probeWithSuffixes(join4(current, binDir), command, suffixes);
|
|
4695
|
-
if (found !== null)
|
|
4696
|
-
return found;
|
|
4697
|
-
}
|
|
4569
|
+
const isWindows = process.platform === "win32";
|
|
4570
|
+
let exts = [""];
|
|
4571
|
+
if (isWindows) {
|
|
4572
|
+
const pathExt = process.env["PATHEXT"] ?? "";
|
|
4573
|
+
if (pathExt) {
|
|
4574
|
+
const systemExts = pathExt.split(";").filter(Boolean);
|
|
4575
|
+
exts = [...new Set([...exts, ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])];
|
|
4576
|
+
} else {
|
|
4577
|
+
exts = ["", ".exe", ".cmd", ".bat", ".ps1"];
|
|
4698
4578
|
}
|
|
4699
|
-
if (probe(join4(current, ".git")))
|
|
4700
|
-
return null;
|
|
4701
|
-
if (boundary !== undefined && current === boundary)
|
|
4702
|
-
return null;
|
|
4703
|
-
const parent = dirname9(current);
|
|
4704
|
-
if (parent === current)
|
|
4705
|
-
return null;
|
|
4706
|
-
current = parent;
|
|
4707
4579
|
}
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
let pathEnv = pathEnvOverride ?? process.env["PATH"] ?? "";
|
|
4711
|
-
if (platform === "win32" && !pathEnv) {
|
|
4580
|
+
let pathEnv = process.env["PATH"] ?? "";
|
|
4581
|
+
if (isWindows && !pathEnv) {
|
|
4712
4582
|
pathEnv = process.env["Path"] ?? "";
|
|
4713
4583
|
}
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4584
|
+
const paths = pathEnv.split(delimiter3);
|
|
4585
|
+
for (const p of paths) {
|
|
4586
|
+
for (const suffix of exts) {
|
|
4587
|
+
if (existsSync10(join4(p, cmd + suffix))) {
|
|
4588
|
+
return true;
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4720
4591
|
}
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
if (command.length === 0)
|
|
4725
|
-
return null;
|
|
4726
|
-
const [cmd] = command;
|
|
4727
|
-
if (cmd === undefined || cmd.length === 0)
|
|
4728
|
-
return null;
|
|
4729
|
-
const platform = options.platform ?? process.platform;
|
|
4730
|
-
const suffixes = executableSuffixes(platform, options.pathExt);
|
|
4731
|
-
if (cmd.includes("/") || cmd.includes("\\")) {
|
|
4732
|
-
const explicit = isAbsolute5(cmd) ? cmd : resolve7(workingDirectory ?? process.cwd(), cmd);
|
|
4733
|
-
return probe(explicit) ? explicit : null;
|
|
4734
|
-
}
|
|
4735
|
-
const cacheKey = JSON.stringify([
|
|
4736
|
-
workingDirectory ?? "",
|
|
4737
|
-
cmd,
|
|
4738
|
-
platform,
|
|
4739
|
-
options.stopAt ?? "",
|
|
4740
|
-
options.pathExt ?? "",
|
|
4741
|
-
options.pathEnv ?? process.env["PATH"] ?? ""
|
|
4742
|
-
]);
|
|
4743
|
-
const cached = resolutionCache.get(cacheKey);
|
|
4744
|
-
if (cached !== undefined)
|
|
4745
|
-
return cached;
|
|
4746
|
-
let resolved = null;
|
|
4747
|
-
if (workingDirectory !== undefined && workingDirectory.length > 0) {
|
|
4748
|
-
resolved = resolveLocal(cmd, workingDirectory, suffixes, options.stopAt);
|
|
4749
|
-
}
|
|
4750
|
-
resolved ??= resolveFromPath(cmd, suffixes, platform, options.pathEnv);
|
|
4751
|
-
if (resolved === null && cmd === "node")
|
|
4752
|
-
resolved = cmd;
|
|
4753
|
-
resolutionCache.set(cacheKey, resolved);
|
|
4754
|
-
return resolved;
|
|
4755
|
-
}
|
|
4756
|
-
function isServerInstalled(command, workingDirectory, options = {}) {
|
|
4757
|
-
if (command.length === 0)
|
|
4758
|
-
return false;
|
|
4759
|
-
return resolveServerBinary(command, workingDirectory, options) !== null;
|
|
4592
|
+
if (cmd === "node")
|
|
4593
|
+
return true;
|
|
4594
|
+
return false;
|
|
4760
4595
|
}
|
|
4761
4596
|
|
|
4762
4597
|
// ../lsp-core/src/lsp/server-resolution.ts
|
|
4763
|
-
function withResolvedCommand(command, binaryPath) {
|
|
4764
|
-
return [binaryPath, ...command.slice(1)];
|
|
4765
|
-
}
|
|
4766
4598
|
function findServerForExtension(ext) {
|
|
4767
4599
|
const servers = getMergedServers();
|
|
4768
|
-
const workingDirectory = contextCwd();
|
|
4769
4600
|
for (const server2 of servers) {
|
|
4770
|
-
if (
|
|
4771
|
-
continue;
|
|
4772
|
-
const binaryPath = resolveServerBinary(server2.command, workingDirectory);
|
|
4773
|
-
if (binaryPath !== null) {
|
|
4601
|
+
if (server2.extensions.includes(ext) && isServerInstalled(server2.command)) {
|
|
4774
4602
|
const resolvedServer = {
|
|
4775
4603
|
id: server2.id,
|
|
4776
|
-
command:
|
|
4604
|
+
command: server2.command,
|
|
4777
4605
|
extensions: server2.extensions,
|
|
4778
4606
|
priority: server2.priority
|
|
4779
4607
|
};
|
|
@@ -4820,7 +4648,6 @@ function findServerForExtension(ext) {
|
|
|
4820
4648
|
function getAllServers() {
|
|
4821
4649
|
const servers = getMergedServers();
|
|
4822
4650
|
const disabled = getDisabledServerIds();
|
|
4823
|
-
const workingDirectory = contextCwd();
|
|
4824
4651
|
const result = [];
|
|
4825
4652
|
const seen = new Set;
|
|
4826
4653
|
for (const server2 of servers) {
|
|
@@ -4828,7 +4655,7 @@ function getAllServers() {
|
|
|
4828
4655
|
continue;
|
|
4829
4656
|
result.push({
|
|
4830
4657
|
id: server2.id,
|
|
4831
|
-
installed: isServerInstalled(server2.command
|
|
4658
|
+
installed: isServerInstalled(server2.command),
|
|
4832
4659
|
extensions: server2.extensions,
|
|
4833
4660
|
disabled: false,
|
|
4834
4661
|
source: server2.source,
|
|
@@ -4842,7 +4669,7 @@ function getAllServers() {
|
|
|
4842
4669
|
const builtin = BUILTIN_SERVERS[id];
|
|
4843
4670
|
result.push({
|
|
4844
4671
|
id,
|
|
4845
|
-
installed: builtin ? isServerInstalled(builtin.command
|
|
4672
|
+
installed: builtin ? isServerInstalled(builtin.command) : false,
|
|
4846
4673
|
extensions: builtin?.extensions ?? [],
|
|
4847
4674
|
disabled: true,
|
|
4848
4675
|
source: "disabled",
|
|
@@ -4865,7 +4692,7 @@ function findWorkspaceRoot(filePath) {
|
|
|
4865
4692
|
const abs = resolveReadablePathInsideContext(filePath);
|
|
4866
4693
|
let dir = abs;
|
|
4867
4694
|
if (!isDirectoryPath(dir)) {
|
|
4868
|
-
dir =
|
|
4695
|
+
dir = dirname9(dir);
|
|
4869
4696
|
}
|
|
4870
4697
|
if (!isPathInside(cwd, abs))
|
|
4871
4698
|
return findWorkspaceRootOutsideContext(dir);
|
|
@@ -4881,13 +4708,13 @@ function findWorkspaceRoot(filePath) {
|
|
|
4881
4708
|
}
|
|
4882
4709
|
if (dir === cwd)
|
|
4883
4710
|
break;
|
|
4884
|
-
dir =
|
|
4711
|
+
dir = dirname9(dir);
|
|
4885
4712
|
}
|
|
4886
4713
|
return fallbackRoot;
|
|
4887
4714
|
}
|
|
4888
4715
|
function resolveReadablePathInsideContext(filePath) {
|
|
4889
4716
|
const cwd = contextCwd();
|
|
4890
|
-
const abs =
|
|
4717
|
+
const abs = resolve7(cwd, filePath);
|
|
4891
4718
|
if (isPathInside(cwd, abs))
|
|
4892
4719
|
return abs;
|
|
4893
4720
|
const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
|
|
@@ -4913,7 +4740,7 @@ function rebaseThroughCanonicalAncestor(path2, cwd) {
|
|
|
4913
4740
|
if (isPathInside(cwd, canonical))
|
|
4914
4741
|
return suffix.length === 0 ? canonical : join5(canonical, ...suffix);
|
|
4915
4742
|
}
|
|
4916
|
-
const parent =
|
|
4743
|
+
const parent = dirname9(current);
|
|
4917
4744
|
if (parent === current)
|
|
4918
4745
|
return;
|
|
4919
4746
|
suffix.unshift(basename3(current));
|
|
@@ -4936,7 +4763,7 @@ function nearestExistingDirectoryInsideContext(directory, cwd) {
|
|
|
4936
4763
|
return canonical;
|
|
4937
4764
|
if (current === cwd)
|
|
4938
4765
|
return;
|
|
4939
|
-
current =
|
|
4766
|
+
current = dirname9(current);
|
|
4940
4767
|
}
|
|
4941
4768
|
return;
|
|
4942
4769
|
}
|
|
@@ -4963,19 +4790,6 @@ function formatServerLookupError(result) {
|
|
|
4963
4790
|
].join(`
|
|
4964
4791
|
`);
|
|
4965
4792
|
}
|
|
4966
|
-
function formatInstallOptions(serverId, installHint) {
|
|
4967
|
-
const localHint = LSP_LOCAL_INSTALL_HINTS[serverId];
|
|
4968
|
-
if (localHint === undefined) {
|
|
4969
|
-
return ["To install, run:", ` ${installHint}`];
|
|
4970
|
-
}
|
|
4971
|
-
return [
|
|
4972
|
-
"To install in THIS repository (preferred — no global install needed):",
|
|
4973
|
-
` ${localHint}`,
|
|
4974
|
-
"",
|
|
4975
|
-
"Or install it globally:",
|
|
4976
|
-
` ${installHint}`
|
|
4977
|
-
];
|
|
4978
|
-
}
|
|
4979
4793
|
function formatNotInstalled(result) {
|
|
4980
4794
|
const { server: server2, installHint } = result;
|
|
4981
4795
|
const extensions = server2.extensions.join(", ");
|
|
@@ -4990,19 +4804,19 @@ function formatNotInstalled(result) {
|
|
|
4990
4804
|
`Command not found: ${server2.command[0]}`,
|
|
4991
4805
|
""
|
|
4992
4806
|
];
|
|
4993
|
-
const installOptions = formatInstallOptions(server2.id, installHint);
|
|
4994
4807
|
if (decision === "allowed") {
|
|
4995
4808
|
return [
|
|
4996
4809
|
...header,
|
|
4997
4810
|
"The user has pre-authorized LSP installation. Run the install command, then retry this tool:",
|
|
4998
|
-
|
|
4811
|
+
` ${installHint}`
|
|
4999
4812
|
].join(`
|
|
5000
4813
|
`);
|
|
5001
4814
|
}
|
|
5002
4815
|
if (!context.capabilities.installDecisionTool) {
|
|
5003
4816
|
return [
|
|
5004
4817
|
...header,
|
|
5005
|
-
|
|
4818
|
+
"To install, run:",
|
|
4819
|
+
` ${installHint}`,
|
|
5006
4820
|
"",
|
|
5007
4821
|
"ACTION REQUIRED — ASK THE USER whether to install this LSP server.",
|
|
5008
4822
|
"Install-decision recording is unavailable in this harness; proceed without LSP if the user declines."
|
|
@@ -5011,7 +4825,8 @@ function formatNotInstalled(result) {
|
|
|
5011
4825
|
}
|
|
5012
4826
|
return [
|
|
5013
4827
|
...header,
|
|
5014
|
-
|
|
4828
|
+
"To install, run:",
|
|
4829
|
+
` ${installHint}`,
|
|
5015
4830
|
"",
|
|
5016
4831
|
"ACTION REQUIRED — ASK THE USER whether to install this LSP server.",
|
|
5017
4832
|
"- If the user agrees: run the install command above, then retry this tool.",
|
|
@@ -5067,7 +4882,7 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
|
5067
4882
|
|
|
5068
4883
|
// ../lsp-core/src/lsp/directory-diagnostics.ts
|
|
5069
4884
|
import { existsSync as existsSync12, lstatSync as lstatSync5, readdirSync as readdirSync3 } from "node:fs";
|
|
5070
|
-
import { join as join6, resolve as
|
|
4885
|
+
import { join as join6, resolve as resolve8 } from "node:path";
|
|
5071
4886
|
|
|
5072
4887
|
// ../lsp-core/src/lsp/formatters.ts
|
|
5073
4888
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -5222,7 +5037,7 @@ async function aggregateDiagnosticsForDirectory(directory, extension, severity,
|
|
|
5222
5037
|
if (!extension.startsWith(".")) {
|
|
5223
5038
|
throw new LspInvalidPathError(`Extension must start with a dot (e.g., ".ts", not "${extension}"). Use ".${extension}" instead.`);
|
|
5224
5039
|
}
|
|
5225
|
-
const absDir =
|
|
5040
|
+
const absDir = resolve8(options.workspaceRoot ?? contextCwd(), directory);
|
|
5226
5041
|
if (!existsSync12(absDir)) {
|
|
5227
5042
|
throw new LspInvalidPathError(`Directory does not exist: ${absDir}`);
|
|
5228
5043
|
}
|
|
@@ -5579,96 +5394,6 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
5579
5394
|
throw error;
|
|
5580
5395
|
}
|
|
5581
5396
|
}
|
|
5582
|
-
// ../lsp-core/src/lsp/format-document.ts
|
|
5583
|
-
import { readFileSync as readFileSync6, renameSync as renameSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
5584
|
-
var DEFAULT_FORMATTING_OPTIONS = {
|
|
5585
|
-
tabSize: 4,
|
|
5586
|
-
insertSpaces: false,
|
|
5587
|
-
trimTrailingWhitespace: true,
|
|
5588
|
-
insertFinalNewline: true,
|
|
5589
|
-
trimFinalNewlines: true
|
|
5590
|
-
};
|
|
5591
|
-
var UNCHANGED = { status: "unchanged", linesAdded: 0, linesRemoved: 0 };
|
|
5592
|
-
async function formatDocumentWithClient(client, filePath, options = {}) {
|
|
5593
|
-
const edits = await client.formatDocument(filePath, options.formattingOptions ?? DEFAULT_FORMATTING_OPTIONS, options.signal);
|
|
5594
|
-
if (edits === null)
|
|
5595
|
-
return { status: "unavailable", reason: "capability_not_advertised" };
|
|
5596
|
-
if (edits.length === 0)
|
|
5597
|
-
return UNCHANGED;
|
|
5598
|
-
const before = readFileSync6(filePath, "utf-8");
|
|
5599
|
-
const normalized = normalizeTextEdits(before, edits, 0);
|
|
5600
|
-
if (normalized.text === before)
|
|
5601
|
-
return UNCHANGED;
|
|
5602
|
-
writeAtomically(filePath, normalized.text);
|
|
5603
|
-
await client.openFile(filePath);
|
|
5604
|
-
return {
|
|
5605
|
-
status: "formatted",
|
|
5606
|
-
...lineDelta(normalized.edits)
|
|
5607
|
-
};
|
|
5608
|
-
}
|
|
5609
|
-
function lineDelta(edits) {
|
|
5610
|
-
let linesAdded = 0;
|
|
5611
|
-
let linesRemoved = 0;
|
|
5612
|
-
for (const edit of edits) {
|
|
5613
|
-
linesRemoved += edit.range.end.line - edit.range.start.line + 1;
|
|
5614
|
-
linesAdded += edit.newText.split(`
|
|
5615
|
-
`).length;
|
|
5616
|
-
}
|
|
5617
|
-
return { linesAdded, linesRemoved };
|
|
5618
|
-
}
|
|
5619
|
-
function writeAtomically(filePath, content) {
|
|
5620
|
-
const tempPath = `${filePath}.omo-format.tmp`;
|
|
5621
|
-
writeFileSync3(tempPath, content, "utf-8");
|
|
5622
|
-
try {
|
|
5623
|
-
renameSync3(tempPath, filePath);
|
|
5624
|
-
} catch (error) {
|
|
5625
|
-
try {
|
|
5626
|
-
unlinkSync2(tempPath);
|
|
5627
|
-
} catch {}
|
|
5628
|
-
throw error;
|
|
5629
|
-
}
|
|
5630
|
-
}
|
|
5631
|
-
|
|
5632
|
-
// ../lsp-core/src/tools/format.ts
|
|
5633
|
-
async function executeLspFormat(params, signal) {
|
|
5634
|
-
const filePath = requireString(params, "filePath");
|
|
5635
|
-
try {
|
|
5636
|
-
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => formatDocumentWithClient(client, resolvedFilePath, signal === undefined ? {} : { signal }), "format", clientOptions(signal));
|
|
5637
|
-
return text(describeResult(filePath, result), formatDetails(filePath, result));
|
|
5638
|
-
} catch (error) {
|
|
5639
|
-
const missingDependency = missingDependencyResult(error, {
|
|
5640
|
-
filePath,
|
|
5641
|
-
status: "unavailable",
|
|
5642
|
-
reason: "server_unavailable",
|
|
5643
|
-
linesAdded: 0,
|
|
5644
|
-
linesRemoved: 0
|
|
5645
|
-
});
|
|
5646
|
-
if (missingDependency)
|
|
5647
|
-
return missingDependency;
|
|
5648
|
-
throw error;
|
|
5649
|
-
}
|
|
5650
|
-
}
|
|
5651
|
-
function formatDetails(filePath, result) {
|
|
5652
|
-
if (result.status === "unavailable") {
|
|
5653
|
-
return { filePath, status: "unavailable", reason: result.reason, linesAdded: 0, linesRemoved: 0 };
|
|
5654
|
-
}
|
|
5655
|
-
return {
|
|
5656
|
-
filePath,
|
|
5657
|
-
status: result.status,
|
|
5658
|
-
linesAdded: result.linesAdded,
|
|
5659
|
-
linesRemoved: result.linesRemoved
|
|
5660
|
-
};
|
|
5661
|
-
}
|
|
5662
|
-
function describeResult(filePath, result) {
|
|
5663
|
-
if (result.status === "unavailable") {
|
|
5664
|
-
return `Formatting unavailable for ${filePath}: the language server does not advertise documentFormattingProvider.`;
|
|
5665
|
-
}
|
|
5666
|
-
if (result.status === "unchanged") {
|
|
5667
|
-
return `Already formatted: ${filePath}`;
|
|
5668
|
-
}
|
|
5669
|
-
return `Formatted ${filePath} (+${result.linesAdded}/-${result.linesRemoved} lines)`;
|
|
5670
|
-
}
|
|
5671
|
-
|
|
5672
5397
|
// ../lsp-core/src/tools/install-decision.ts
|
|
5673
5398
|
async function executeLspInstallDecision(params) {
|
|
5674
5399
|
const serverId = requireString(params, "server_id");
|
|
@@ -6001,16 +5726,6 @@ var LSP_MCP_TOOLS = [
|
|
|
6001
5726
|
}, ["filePath", "line", "character", "newName"]),
|
|
6002
5727
|
execute: executeLspRename
|
|
6003
5728
|
},
|
|
6004
|
-
{
|
|
6005
|
-
name: "format",
|
|
6006
|
-
aliases: ["lsp_format"],
|
|
6007
|
-
title: "LSP Format",
|
|
6008
|
-
description: "Format a source file with its language server and write the returned edits to disk.",
|
|
6009
|
-
inputSchema: objectSchema({
|
|
6010
|
-
filePath: { type: "string", description: "Source file path to format." }
|
|
6011
|
-
}, ["filePath"]),
|
|
6012
|
-
execute: executeLspFormat
|
|
6013
|
-
},
|
|
6014
5729
|
{
|
|
6015
5730
|
name: "install_decision",
|
|
6016
5731
|
aliases: ["lsp_install_decision"],
|
|
@@ -6230,9 +5945,6 @@ async function callToolViaDaemon(name, args, options) {
|
|
|
6230
5945
|
function callDiagnosticsViaDaemon(filePath, options) {
|
|
6231
5946
|
return callToolViaDaemon("diagnostics", { filePath, severity: "error" }, options);
|
|
6232
5947
|
}
|
|
6233
|
-
function callFormatViaDaemon(filePath, options) {
|
|
6234
|
-
return callToolViaDaemon("format", { filePath }, options);
|
|
6235
|
-
}
|
|
6236
5948
|
function currentRequestContext(env = process.env) {
|
|
6237
5949
|
const cwd = process.cwd();
|
|
6238
5950
|
const home = env["HOME"] ?? homedir3();
|
|
@@ -6255,7 +5967,7 @@ function withContext(args, context) {
|
|
|
6255
5967
|
function ensureDaemonAvailable(paths, ensure, signal) {
|
|
6256
5968
|
if (!signal)
|
|
6257
5969
|
return ensure(paths);
|
|
6258
|
-
return new Promise((
|
|
5970
|
+
return new Promise((resolve9, reject) => {
|
|
6259
5971
|
let settled = false;
|
|
6260
5972
|
const finish = (run) => {
|
|
6261
5973
|
if (settled)
|
|
@@ -6270,11 +5982,11 @@ function ensureDaemonAvailable(paths, ensure, signal) {
|
|
|
6270
5982
|
return;
|
|
6271
5983
|
}
|
|
6272
5984
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
6273
|
-
Promise.resolve().then(() => ensure(paths, signal)).then(() => finish(() =>
|
|
5985
|
+
Promise.resolve().then(() => ensure(paths, signal)).then(() => finish(() => resolve9()), (error) => finish(() => reject(signal.aborted ? new DaemonRequestCancelledError(false) : error)));
|
|
6274
5986
|
});
|
|
6275
5987
|
}
|
|
6276
5988
|
function sendToolCall(paths, token, name, args, options) {
|
|
6277
|
-
return new Promise((
|
|
5989
|
+
return new Promise((resolve9, reject) => {
|
|
6278
5990
|
const socket = connect(paths.socket);
|
|
6279
5991
|
const requestId = allocateProxyRequestId();
|
|
6280
5992
|
let settled = false;
|
|
@@ -6327,7 +6039,7 @@ function sendToolCall(paths, token, name, args, options) {
|
|
|
6327
6039
|
}
|
|
6328
6040
|
const result = toToolResult(message, requestId);
|
|
6329
6041
|
if (result)
|
|
6330
|
-
finish(() =>
|
|
6042
|
+
finish(() => resolve9(result));
|
|
6331
6043
|
else
|
|
6332
6044
|
finish(() => reject(new DaemonRequestError("invalid daemon response", requestWritten)));
|
|
6333
6045
|
});
|
|
@@ -6373,7 +6085,7 @@ function isRetryableTool(name) {
|
|
|
6373
6085
|
}
|
|
6374
6086
|
// src/proxy.ts
|
|
6375
6087
|
import { existsSync as existsSync13, realpathSync as realpathSync6 } from "node:fs";
|
|
6376
|
-
import { basename as basename4, delimiter as delimiter4, dirname as
|
|
6088
|
+
import { basename as basename4, delimiter as delimiter4, dirname as dirname10, isAbsolute as isAbsolute5 } from "node:path";
|
|
6377
6089
|
var DEFAULT_STARTUP_TIMEOUT_MS = 1e4;
|
|
6378
6090
|
async function runMcpStdioProxy(options = {}) {
|
|
6379
6091
|
const input = options.input ?? process.stdin;
|
|
@@ -6496,18 +6208,18 @@ function canonicalizePathList(value) {
|
|
|
6496
6208
|
return value.split(delimiter4).map((entry) => canonicalizePath(entry) ?? entry).join(delimiter4);
|
|
6497
6209
|
}
|
|
6498
6210
|
function canonicalizePath(value) {
|
|
6499
|
-
if (value === undefined || !
|
|
6211
|
+
if (value === undefined || !isAbsolute5(value) || !existsSync13(value))
|
|
6500
6212
|
return value;
|
|
6501
6213
|
return realpathSync6(value);
|
|
6502
6214
|
}
|
|
6503
6215
|
function projectRootFromOpenCodeConfigPath(path2) {
|
|
6504
6216
|
if (basename4(path2) !== "lsp.json" && basename4(path2) !== "lsp-client.json")
|
|
6505
6217
|
return;
|
|
6506
|
-
const configDir =
|
|
6218
|
+
const configDir = dirname10(path2);
|
|
6507
6219
|
const configDirName = basename4(configDir);
|
|
6508
6220
|
if (configDirName !== ".opencode" && configDirName !== ".omo")
|
|
6509
6221
|
return;
|
|
6510
|
-
return
|
|
6222
|
+
return dirname10(configDir);
|
|
6511
6223
|
}
|
|
6512
6224
|
export {
|
|
6513
6225
|
InvalidDaemonDirectoryError,
|