oh-my-opencode 5.0.0-beta.4 → 5.0.0-beta.6
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 +496 -377
- package/dist/cli-node/index.js +496 -377
- package/dist/index.js +1136 -1104
- package/dist/skills/coding-agent-sessions/SKILL.md +3 -2
- package/dist/skills/coding-agent-sessions/references/all-platforms.md +1 -1
- package/dist/skills/coding-agent-sessions/references/senpi.md +4 -4
- package/dist/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +1 -1
- package/dist/tui.js +20 -1
- package/package.json +15 -14
- package/packages/lsp-core/src/lsp/client-wrapper.test.ts +60 -7
- package/packages/lsp-core/src/lsp/client-wrapper.ts +69 -16
- package/packages/lsp-core/src/lsp/workspace-edit-adversarial.test.ts +20 -1
- package/packages/lsp-core/src/tools/diagnostics.ts +3 -3
- package/packages/lsp-core/src/tools/navigation.ts +4 -2
- package/packages/lsp-core/src/tools/rename.ts +4 -2
- package/packages/lsp-core/src/tools/symbols.ts +1 -1
- package/packages/lsp-daemon/dist/cli.js +83 -29
- package/packages/lsp-daemon/dist/client.js +76 -22
- package/packages/lsp-daemon/dist/index.js +81 -27
- package/packages/lsp-tools-mcp/dist/cli.js +76 -22
- package/packages/lsp-tools-mcp/dist/mcp.js +76 -22
- package/packages/lsp-tools-mcp/dist/tools.js +76 -22
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- 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 +14 -1
- package/packages/omo-codex/plugin/components/codegraph/dist/serve.js +14 -1
- 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 +83 -29
- 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/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/start-work-continuation/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/start-work-continuation/package.json +1 -1
- 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 +24 -12
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +24 -12
- 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-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-start-work-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-start-work-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/package-lock.json +13 -13
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/SKILL.md +3 -2
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/references/all-platforms.md +1 -1
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/references/senpi.md +4 -4
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +1 -1
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +39 -16
- package/packages/shared-skills/skills/coding-agent-sessions/SKILL.md +3 -2
- package/packages/shared-skills/skills/coding-agent-sessions/references/all-platforms.md +1 -1
- package/packages/shared-skills/skills/coding-agent-sessions/references/senpi.md +4 -4
- package/packages/shared-skills/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +1 -1
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import { argv, stderr } from "node:process";
|
|
5
5
|
|
|
6
6
|
// src/proxy.ts
|
|
7
|
-
import { existsSync as existsSync12, realpathSync as
|
|
8
|
-
import { basename as
|
|
7
|
+
import { existsSync as existsSync12, realpathSync as realpathSync5 } from "node:fs";
|
|
8
|
+
import { basename as basename4, delimiter as delimiter4, dirname as dirname9, isAbsolute as isAbsolute5 } from "node:path";
|
|
9
9
|
|
|
10
10
|
// ../mcp-stdio-core/src/record.ts
|
|
11
11
|
function isPlainRecord(value) {
|
|
@@ -315,8 +315,8 @@ function createIdleTimer(idleTimeoutMs, log, onTimeout) {
|
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
317
|
// ../lsp-core/src/lsp/client-wrapper.ts
|
|
318
|
-
import { existsSync as existsSync9, statSync as statSync3 } from "node:fs";
|
|
319
|
-
import { dirname as dirname6, join as join4, resolve as resolve7 } from "node:path";
|
|
318
|
+
import { existsSync as existsSync9, realpathSync as realpathSync4, statSync as statSync3 } from "node:fs";
|
|
319
|
+
import { basename as basename3, dirname as dirname6, join as join4, resolve as resolve7 } from "node:path";
|
|
320
320
|
|
|
321
321
|
// ../lsp-core/src/request-context.ts
|
|
322
322
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -4029,32 +4029,86 @@ function isDirectoryPath(filePath) {
|
|
|
4029
4029
|
}
|
|
4030
4030
|
}
|
|
4031
4031
|
function findWorkspaceRoot(filePath) {
|
|
4032
|
-
const
|
|
4032
|
+
const cwd = contextCwd();
|
|
4033
|
+
const abs = resolveReadablePathInsideContext(filePath);
|
|
4033
4034
|
let dir = abs;
|
|
4034
4035
|
if (!isDirectoryPath(dir)) {
|
|
4035
4036
|
dir = dirname6(dir);
|
|
4036
4037
|
}
|
|
4037
|
-
|
|
4038
|
-
while (dir
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4038
|
+
const fallbackRoot = nearestExistingDirectoryInsideContext(dir, cwd) ?? cwd;
|
|
4039
|
+
while (isPathInside(cwd, dir)) {
|
|
4040
|
+
const canonicalDir = existingDirectoryInsideContext(dir, cwd);
|
|
4041
|
+
if (canonicalDir !== undefined) {
|
|
4042
|
+
for (const marker of WORKSPACE_MARKERS) {
|
|
4043
|
+
if (existsSync9(join4(dir, marker))) {
|
|
4044
|
+
return canonicalDir;
|
|
4045
|
+
}
|
|
4042
4046
|
}
|
|
4043
4047
|
}
|
|
4044
|
-
|
|
4048
|
+
if (dir === cwd)
|
|
4049
|
+
break;
|
|
4045
4050
|
dir = dirname6(dir);
|
|
4046
4051
|
}
|
|
4047
|
-
return
|
|
4052
|
+
return fallbackRoot;
|
|
4048
4053
|
}
|
|
4049
|
-
function
|
|
4054
|
+
function resolveReadablePathInsideContext(filePath) {
|
|
4050
4055
|
const cwd = contextCwd();
|
|
4051
4056
|
const abs = resolve7(cwd, filePath);
|
|
4057
|
+
if (isPathInside(cwd, abs))
|
|
4058
|
+
return abs;
|
|
4059
|
+
const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
|
|
4060
|
+
if (rebased !== undefined)
|
|
4061
|
+
return rebased;
|
|
4062
|
+
const canonical = canonicalizeExistingOrNearestAncestor(abs);
|
|
4063
|
+
if (isPathInside(cwd, canonical))
|
|
4064
|
+
return canonical;
|
|
4065
|
+
throw new LspInvalidPathError(`LSP file path must be inside request cwd: ${filePath}`);
|
|
4066
|
+
}
|
|
4067
|
+
function resolvePathInsideContext(filePath) {
|
|
4068
|
+
const cwd = contextCwd();
|
|
4069
|
+
const abs = resolveReadablePathInsideContext(filePath);
|
|
4052
4070
|
const canonical = canonicalizeExistingOrNearestAncestor(abs);
|
|
4053
4071
|
if (!isPathInside(cwd, canonical)) {
|
|
4054
4072
|
throw new LspInvalidPathError(`LSP file path must be inside request cwd: ${filePath}`);
|
|
4055
4073
|
}
|
|
4056
4074
|
return canonical;
|
|
4057
4075
|
}
|
|
4076
|
+
function rebaseThroughCanonicalAncestor(path, cwd) {
|
|
4077
|
+
let current = path;
|
|
4078
|
+
const suffix = [];
|
|
4079
|
+
while (true) {
|
|
4080
|
+
if (existsSync9(current)) {
|
|
4081
|
+
const canonical = realpathSync4(current);
|
|
4082
|
+
if (isPathInside(cwd, canonical))
|
|
4083
|
+
return suffix.length === 0 ? canonical : join4(canonical, ...suffix);
|
|
4084
|
+
}
|
|
4085
|
+
const parent = dirname6(current);
|
|
4086
|
+
if (parent === current)
|
|
4087
|
+
return;
|
|
4088
|
+
suffix.unshift(basename3(current));
|
|
4089
|
+
current = parent;
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
function existingDirectoryInsideContext(directory, cwd) {
|
|
4093
|
+
if (!existsSync9(directory))
|
|
4094
|
+
return;
|
|
4095
|
+
const canonical = realpathSync4(directory);
|
|
4096
|
+
if (!statSync3(canonical).isDirectory())
|
|
4097
|
+
return;
|
|
4098
|
+
return isPathInside(cwd, canonical) ? canonical : undefined;
|
|
4099
|
+
}
|
|
4100
|
+
function nearestExistingDirectoryInsideContext(directory, cwd) {
|
|
4101
|
+
let current = directory;
|
|
4102
|
+
while (isPathInside(cwd, current)) {
|
|
4103
|
+
const canonical = existingDirectoryInsideContext(current, cwd);
|
|
4104
|
+
if (canonical !== undefined)
|
|
4105
|
+
return canonical;
|
|
4106
|
+
if (current === cwd)
|
|
4107
|
+
return;
|
|
4108
|
+
current = dirname6(current);
|
|
4109
|
+
}
|
|
4110
|
+
return;
|
|
4111
|
+
}
|
|
4058
4112
|
function formatServerLookupError(result) {
|
|
4059
4113
|
if (result.status === "not_installed") {
|
|
4060
4114
|
return formatNotInstalled(result);
|
|
@@ -4125,7 +4179,7 @@ function formatNotInstalled(result) {
|
|
|
4125
4179
|
].join(`
|
|
4126
4180
|
`);
|
|
4127
4181
|
}
|
|
4128
|
-
var
|
|
4182
|
+
var READ_ONLY_TOOLS = new Set([
|
|
4129
4183
|
"diagnostics",
|
|
4130
4184
|
"definition",
|
|
4131
4185
|
"references",
|
|
@@ -4134,7 +4188,7 @@ var READ_ONLY_RETRY_TOOLS = new Set([
|
|
|
4134
4188
|
"prepareRename"
|
|
4135
4189
|
]);
|
|
4136
4190
|
async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
4137
|
-
const absPath = resolvePathInsideContext(filePath);
|
|
4191
|
+
const absPath = READ_ONLY_TOOLS.has(toolName) ? resolveReadablePathInsideContext(filePath) : resolvePathInsideContext(filePath);
|
|
4138
4192
|
if (isDirectoryPath(absPath)) {
|
|
4139
4193
|
throw new LspInvalidPathError("Directory paths are not supported by this LSP tool. " + "Use lsp.diagnostics with a directory path for directory diagnostics.");
|
|
4140
4194
|
}
|
|
@@ -4149,9 +4203,9 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
|
4149
4203
|
const acquireAndCall = async (allowRetry) => {
|
|
4150
4204
|
const client = await manager.getClient(root, server2, options.signal);
|
|
4151
4205
|
try {
|
|
4152
|
-
return await fn(client, root);
|
|
4206
|
+
return await fn(client, root, absPath);
|
|
4153
4207
|
} catch (err) {
|
|
4154
|
-
if (allowRetry &&
|
|
4208
|
+
if (allowRetry && READ_ONLY_TOOLS.has(toolName) && isLspDeadConnectionError(err)) {
|
|
4155
4209
|
manager.invalidateClient(root, server2.id, client);
|
|
4156
4210
|
return acquireAndCall(false);
|
|
4157
4211
|
}
|
|
@@ -4606,7 +4660,7 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
4606
4660
|
const filePath = requireString(params, "filePath");
|
|
4607
4661
|
const severity = severityFilter(params);
|
|
4608
4662
|
try {
|
|
4609
|
-
const absPath =
|
|
4663
|
+
const absPath = resolveReadablePathInsideContext(filePath);
|
|
4610
4664
|
if (isDirectoryPath(absPath)) {
|
|
4611
4665
|
const extension = inferExtensionFromDirectory(absPath);
|
|
4612
4666
|
if (!extension) {
|
|
@@ -4635,7 +4689,7 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
4635
4689
|
};
|
|
4636
4690
|
return text(output2.output, details2);
|
|
4637
4691
|
}
|
|
4638
|
-
const result = await withLspClient(filePath, async (client) => client.diagnostics(
|
|
4692
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.diagnostics(resolvedFilePath, signal), "diagnostics", clientOptions(signal));
|
|
4639
4693
|
if (result.transientError) {
|
|
4640
4694
|
const message = result.transientError.message;
|
|
4641
4695
|
const details2 = {
|
|
@@ -4710,7 +4764,7 @@ async function executeLspGotoDefinition(params, signal) {
|
|
|
4710
4764
|
const line = requireNumber(params, "line");
|
|
4711
4765
|
const character = requireNumber(params, "character");
|
|
4712
4766
|
try {
|
|
4713
|
-
const result = await withLspClient(filePath, async (client) => client.definition(
|
|
4767
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.definition(resolvedFilePath, line, character, signal), "definition", clientOptions(signal));
|
|
4714
4768
|
const locations = !result ? [] : Array.isArray(result) ? result : [result];
|
|
4715
4769
|
const details = { filePath, line, character, locations };
|
|
4716
4770
|
if (locations.length === 0)
|
|
@@ -4735,7 +4789,7 @@ async function executeLspFindReferences(params, signal) {
|
|
|
4735
4789
|
const character = requireNumber(params, "character");
|
|
4736
4790
|
const includeDeclaration = optionalBoolean(params, "includeDeclaration") ?? true;
|
|
4737
4791
|
try {
|
|
4738
|
-
const result = await withLspClient(filePath, async (client) => client.references(
|
|
4792
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.references(resolvedFilePath, line, character, includeDeclaration, signal), "references", clientOptions(signal));
|
|
4739
4793
|
const references = Array.isArray(result) ? result : [];
|
|
4740
4794
|
const total = references.length;
|
|
4741
4795
|
const truncated = total > DEFAULT_MAX_REFERENCES;
|
|
@@ -4777,7 +4831,7 @@ async function executeLspPrepareRename(params, signal) {
|
|
|
4777
4831
|
const line = requireNumber(params, "line");
|
|
4778
4832
|
const character = requireNumber(params, "character");
|
|
4779
4833
|
try {
|
|
4780
|
-
const result = await withLspClient(filePath, async (client) => client.prepareRename(
|
|
4834
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.prepareRename(resolvedFilePath, line, character, signal), "prepareRename", clientOptions(signal));
|
|
4781
4835
|
const details = { filePath, line, character, result };
|
|
4782
4836
|
return text(formatPrepareRenameResult(result), details);
|
|
4783
4837
|
} catch (error) {
|
|
@@ -4798,7 +4852,7 @@ async function executeLspRename(params, signal) {
|
|
|
4798
4852
|
const character = requireNumber(params, "character");
|
|
4799
4853
|
const newName = requireString(params, "newName");
|
|
4800
4854
|
try {
|
|
4801
|
-
const result = await withLspClient(filePath, async (client) => client.rename(
|
|
4855
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.rename(resolvedFilePath, line, character, newName, signal), "rename", clientOptions(signal));
|
|
4802
4856
|
const details = { filePath, line, character, newName, apply: result.apply, edit: result.edit };
|
|
4803
4857
|
return text(formatApplyResult(result.apply), details, !result.apply.success);
|
|
4804
4858
|
} catch (error) {
|
|
@@ -4878,7 +4932,7 @@ async function executeLspSymbols(params, signal) {
|
|
|
4878
4932
|
const symbols2 = await withLspClient(filePath, async (client) => client.workspaceSymbols(query, signal), "workspaceSymbols", clientOptions(signal));
|
|
4879
4933
|
return formatSymbolsResult(filePath, scope, symbols2, limit, query);
|
|
4880
4934
|
}
|
|
4881
|
-
const symbols = await withLspClient(filePath, async (client) => client.documentSymbols(
|
|
4935
|
+
const symbols = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.documentSymbols(resolvedFilePath, signal), "documentSymbols", clientOptions(signal));
|
|
4882
4936
|
return formatSymbolsResult(filePath, scope, symbols, limit);
|
|
4883
4937
|
} catch (error) {
|
|
4884
4938
|
const query = optionalString(params, "query");
|
|
@@ -6160,13 +6214,13 @@ function canonicalizePathList(value) {
|
|
|
6160
6214
|
function canonicalizePath(value) {
|
|
6161
6215
|
if (value === undefined || !isAbsolute5(value) || !existsSync12(value))
|
|
6162
6216
|
return value;
|
|
6163
|
-
return
|
|
6217
|
+
return realpathSync5(value);
|
|
6164
6218
|
}
|
|
6165
6219
|
function projectRootFromOpenCodeConfigPath(path2) {
|
|
6166
|
-
if (
|
|
6220
|
+
if (basename4(path2) !== "lsp.json" && basename4(path2) !== "lsp-client.json")
|
|
6167
6221
|
return;
|
|
6168
6222
|
const configDir = dirname9(path2);
|
|
6169
|
-
const configDirName =
|
|
6223
|
+
const configDirName = basename4(configDir);
|
|
6170
6224
|
if (configDirName !== ".opencode" && configDirName !== ".omo")
|
|
6171
6225
|
return;
|
|
6172
6226
|
return dirname9(configDir);
|
|
@@ -6417,7 +6471,7 @@ function parseEndpoint(value) {
|
|
|
6417
6471
|
// src/version-reap.ts
|
|
6418
6472
|
import { execFile } from "node:child_process";
|
|
6419
6473
|
import { readdir, readFile, rm } from "node:fs/promises";
|
|
6420
|
-
import { basename as
|
|
6474
|
+
import { basename as basename5, dirname as dirname12, join as join8 } from "node:path";
|
|
6421
6475
|
var TERM_GRACE_MS = 5000;
|
|
6422
6476
|
var KILL_GRACE_MS = 1000;
|
|
6423
6477
|
var VERSION_ENTRY_PATTERN = /^v([A-Za-z0-9][A-Za-z0-9._+-]{0,127})$/;
|
|
@@ -6547,7 +6601,7 @@ function splitCmdline(buffer) {
|
|
|
6547
6601
|
function isNodeCliDaemonArgv(argv) {
|
|
6548
6602
|
if (argv.length < 2 || !argv.includes("daemon"))
|
|
6549
6603
|
return false;
|
|
6550
|
-
const executable =
|
|
6604
|
+
const executable = basename5(argv[0] ?? "");
|
|
6551
6605
|
if (!/^node(?:\.exe)?$/i.test(executable))
|
|
6552
6606
|
return false;
|
|
6553
6607
|
return argv.some((value) => value === "cli.js" || value.endsWith("/cli.js") || value.endsWith("\\cli.js"));
|
|
@@ -1141,8 +1141,8 @@ function createIdleTimer(idleTimeoutMs, log, onTimeout) {
|
|
|
1141
1141
|
};
|
|
1142
1142
|
}
|
|
1143
1143
|
// ../lsp-core/src/lsp/client-wrapper.ts
|
|
1144
|
-
import { existsSync as existsSync10, statSync as statSync4 } from "node:fs";
|
|
1145
|
-
import { dirname as dirname8, join as join4, resolve as resolve7 } from "node:path";
|
|
1144
|
+
import { existsSync as existsSync10, realpathSync as realpathSync4, statSync as statSync4 } from "node:fs";
|
|
1145
|
+
import { basename as basename3, dirname as dirname8, join as join4, resolve as resolve7 } from "node:path";
|
|
1146
1146
|
|
|
1147
1147
|
// ../lsp-core/src/lsp/effective-extension.ts
|
|
1148
1148
|
import { basename as basename2, extname } from "node:path";
|
|
@@ -4686,32 +4686,86 @@ function isDirectoryPath(filePath) {
|
|
|
4686
4686
|
}
|
|
4687
4687
|
}
|
|
4688
4688
|
function findWorkspaceRoot(filePath) {
|
|
4689
|
-
const
|
|
4689
|
+
const cwd = contextCwd();
|
|
4690
|
+
const abs = resolveReadablePathInsideContext(filePath);
|
|
4690
4691
|
let dir = abs;
|
|
4691
4692
|
if (!isDirectoryPath(dir)) {
|
|
4692
4693
|
dir = dirname8(dir);
|
|
4693
4694
|
}
|
|
4694
|
-
|
|
4695
|
-
while (dir
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4695
|
+
const fallbackRoot = nearestExistingDirectoryInsideContext(dir, cwd) ?? cwd;
|
|
4696
|
+
while (isPathInside(cwd, dir)) {
|
|
4697
|
+
const canonicalDir = existingDirectoryInsideContext(dir, cwd);
|
|
4698
|
+
if (canonicalDir !== undefined) {
|
|
4699
|
+
for (const marker of WORKSPACE_MARKERS) {
|
|
4700
|
+
if (existsSync10(join4(dir, marker))) {
|
|
4701
|
+
return canonicalDir;
|
|
4702
|
+
}
|
|
4699
4703
|
}
|
|
4700
4704
|
}
|
|
4701
|
-
|
|
4705
|
+
if (dir === cwd)
|
|
4706
|
+
break;
|
|
4702
4707
|
dir = dirname8(dir);
|
|
4703
4708
|
}
|
|
4704
|
-
return
|
|
4709
|
+
return fallbackRoot;
|
|
4705
4710
|
}
|
|
4706
|
-
function
|
|
4711
|
+
function resolveReadablePathInsideContext(filePath) {
|
|
4707
4712
|
const cwd = contextCwd();
|
|
4708
4713
|
const abs = resolve7(cwd, filePath);
|
|
4714
|
+
if (isPathInside(cwd, abs))
|
|
4715
|
+
return abs;
|
|
4716
|
+
const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
|
|
4717
|
+
if (rebased !== undefined)
|
|
4718
|
+
return rebased;
|
|
4719
|
+
const canonical = canonicalizeExistingOrNearestAncestor(abs);
|
|
4720
|
+
if (isPathInside(cwd, canonical))
|
|
4721
|
+
return canonical;
|
|
4722
|
+
throw new LspInvalidPathError(`LSP file path must be inside request cwd: ${filePath}`);
|
|
4723
|
+
}
|
|
4724
|
+
function resolvePathInsideContext(filePath) {
|
|
4725
|
+
const cwd = contextCwd();
|
|
4726
|
+
const abs = resolveReadablePathInsideContext(filePath);
|
|
4709
4727
|
const canonical = canonicalizeExistingOrNearestAncestor(abs);
|
|
4710
4728
|
if (!isPathInside(cwd, canonical)) {
|
|
4711
4729
|
throw new LspInvalidPathError(`LSP file path must be inside request cwd: ${filePath}`);
|
|
4712
4730
|
}
|
|
4713
4731
|
return canonical;
|
|
4714
4732
|
}
|
|
4733
|
+
function rebaseThroughCanonicalAncestor(path2, cwd) {
|
|
4734
|
+
let current = path2;
|
|
4735
|
+
const suffix = [];
|
|
4736
|
+
while (true) {
|
|
4737
|
+
if (existsSync10(current)) {
|
|
4738
|
+
const canonical = realpathSync4(current);
|
|
4739
|
+
if (isPathInside(cwd, canonical))
|
|
4740
|
+
return suffix.length === 0 ? canonical : join4(canonical, ...suffix);
|
|
4741
|
+
}
|
|
4742
|
+
const parent = dirname8(current);
|
|
4743
|
+
if (parent === current)
|
|
4744
|
+
return;
|
|
4745
|
+
suffix.unshift(basename3(current));
|
|
4746
|
+
current = parent;
|
|
4747
|
+
}
|
|
4748
|
+
}
|
|
4749
|
+
function existingDirectoryInsideContext(directory, cwd) {
|
|
4750
|
+
if (!existsSync10(directory))
|
|
4751
|
+
return;
|
|
4752
|
+
const canonical = realpathSync4(directory);
|
|
4753
|
+
if (!statSync4(canonical).isDirectory())
|
|
4754
|
+
return;
|
|
4755
|
+
return isPathInside(cwd, canonical) ? canonical : undefined;
|
|
4756
|
+
}
|
|
4757
|
+
function nearestExistingDirectoryInsideContext(directory, cwd) {
|
|
4758
|
+
let current = directory;
|
|
4759
|
+
while (isPathInside(cwd, current)) {
|
|
4760
|
+
const canonical = existingDirectoryInsideContext(current, cwd);
|
|
4761
|
+
if (canonical !== undefined)
|
|
4762
|
+
return canonical;
|
|
4763
|
+
if (current === cwd)
|
|
4764
|
+
return;
|
|
4765
|
+
current = dirname8(current);
|
|
4766
|
+
}
|
|
4767
|
+
return;
|
|
4768
|
+
}
|
|
4715
4769
|
function formatServerLookupError(result) {
|
|
4716
4770
|
if (result.status === "not_installed") {
|
|
4717
4771
|
return formatNotInstalled(result);
|
|
@@ -4782,7 +4836,7 @@ function formatNotInstalled(result) {
|
|
|
4782
4836
|
].join(`
|
|
4783
4837
|
`);
|
|
4784
4838
|
}
|
|
4785
|
-
var
|
|
4839
|
+
var READ_ONLY_TOOLS = new Set([
|
|
4786
4840
|
"diagnostics",
|
|
4787
4841
|
"definition",
|
|
4788
4842
|
"references",
|
|
@@ -4791,7 +4845,7 @@ var READ_ONLY_RETRY_TOOLS = new Set([
|
|
|
4791
4845
|
"prepareRename"
|
|
4792
4846
|
]);
|
|
4793
4847
|
async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
4794
|
-
const absPath = resolvePathInsideContext(filePath);
|
|
4848
|
+
const absPath = READ_ONLY_TOOLS.has(toolName) ? resolveReadablePathInsideContext(filePath) : resolvePathInsideContext(filePath);
|
|
4795
4849
|
if (isDirectoryPath(absPath)) {
|
|
4796
4850
|
throw new LspInvalidPathError("Directory paths are not supported by this LSP tool. " + "Use lsp.diagnostics with a directory path for directory diagnostics.");
|
|
4797
4851
|
}
|
|
@@ -4806,9 +4860,9 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
|
4806
4860
|
const acquireAndCall = async (allowRetry) => {
|
|
4807
4861
|
const client = await manager.getClient(root, server2, options.signal);
|
|
4808
4862
|
try {
|
|
4809
|
-
return await fn(client, root);
|
|
4863
|
+
return await fn(client, root, absPath);
|
|
4810
4864
|
} catch (err) {
|
|
4811
|
-
if (allowRetry &&
|
|
4865
|
+
if (allowRetry && READ_ONLY_TOOLS.has(toolName) && isLspDeadConnectionError(err)) {
|
|
4812
4866
|
manager.invalidateClient(root, server2.id, client);
|
|
4813
4867
|
return acquireAndCall(false);
|
|
4814
4868
|
}
|
|
@@ -5263,7 +5317,7 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
5263
5317
|
const filePath = requireString(params, "filePath");
|
|
5264
5318
|
const severity = severityFilter(params);
|
|
5265
5319
|
try {
|
|
5266
|
-
const absPath =
|
|
5320
|
+
const absPath = resolveReadablePathInsideContext(filePath);
|
|
5267
5321
|
if (isDirectoryPath(absPath)) {
|
|
5268
5322
|
const extension = inferExtensionFromDirectory(absPath);
|
|
5269
5323
|
if (!extension) {
|
|
@@ -5292,7 +5346,7 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
5292
5346
|
};
|
|
5293
5347
|
return text(output2.output, details2);
|
|
5294
5348
|
}
|
|
5295
|
-
const result = await withLspClient(filePath, async (client) => client.diagnostics(
|
|
5349
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.diagnostics(resolvedFilePath, signal), "diagnostics", clientOptions(signal));
|
|
5296
5350
|
if (result.transientError) {
|
|
5297
5351
|
const message = result.transientError.message;
|
|
5298
5352
|
const details2 = {
|
|
@@ -5367,7 +5421,7 @@ async function executeLspGotoDefinition(params, signal) {
|
|
|
5367
5421
|
const line = requireNumber(params, "line");
|
|
5368
5422
|
const character = requireNumber(params, "character");
|
|
5369
5423
|
try {
|
|
5370
|
-
const result = await withLspClient(filePath, async (client) => client.definition(
|
|
5424
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.definition(resolvedFilePath, line, character, signal), "definition", clientOptions(signal));
|
|
5371
5425
|
const locations = !result ? [] : Array.isArray(result) ? result : [result];
|
|
5372
5426
|
const details = { filePath, line, character, locations };
|
|
5373
5427
|
if (locations.length === 0)
|
|
@@ -5392,7 +5446,7 @@ async function executeLspFindReferences(params, signal) {
|
|
|
5392
5446
|
const character = requireNumber(params, "character");
|
|
5393
5447
|
const includeDeclaration = optionalBoolean(params, "includeDeclaration") ?? true;
|
|
5394
5448
|
try {
|
|
5395
|
-
const result = await withLspClient(filePath, async (client) => client.references(
|
|
5449
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.references(resolvedFilePath, line, character, includeDeclaration, signal), "references", clientOptions(signal));
|
|
5396
5450
|
const references = Array.isArray(result) ? result : [];
|
|
5397
5451
|
const total = references.length;
|
|
5398
5452
|
const truncated = total > DEFAULT_MAX_REFERENCES;
|
|
@@ -5434,7 +5488,7 @@ async function executeLspPrepareRename(params, signal) {
|
|
|
5434
5488
|
const line = requireNumber(params, "line");
|
|
5435
5489
|
const character = requireNumber(params, "character");
|
|
5436
5490
|
try {
|
|
5437
|
-
const result = await withLspClient(filePath, async (client) => client.prepareRename(
|
|
5491
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.prepareRename(resolvedFilePath, line, character, signal), "prepareRename", clientOptions(signal));
|
|
5438
5492
|
const details = { filePath, line, character, result };
|
|
5439
5493
|
return text(formatPrepareRenameResult(result), details);
|
|
5440
5494
|
} catch (error) {
|
|
@@ -5455,7 +5509,7 @@ async function executeLspRename(params, signal) {
|
|
|
5455
5509
|
const character = requireNumber(params, "character");
|
|
5456
5510
|
const newName = requireString(params, "newName");
|
|
5457
5511
|
try {
|
|
5458
|
-
const result = await withLspClient(filePath, async (client) => client.rename(
|
|
5512
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.rename(resolvedFilePath, line, character, newName, signal), "rename", clientOptions(signal));
|
|
5459
5513
|
const details = { filePath, line, character, newName, apply: result.apply, edit: result.edit };
|
|
5460
5514
|
return text(formatApplyResult(result.apply), details, !result.apply.success);
|
|
5461
5515
|
} catch (error) {
|
|
@@ -5535,7 +5589,7 @@ async function executeLspSymbols(params, signal) {
|
|
|
5535
5589
|
const symbols2 = await withLspClient(filePath, async (client) => client.workspaceSymbols(query, signal), "workspaceSymbols", clientOptions(signal));
|
|
5536
5590
|
return formatSymbolsResult(filePath, scope, symbols2, limit, query);
|
|
5537
5591
|
}
|
|
5538
|
-
const symbols = await withLspClient(filePath, async (client) => client.documentSymbols(
|
|
5592
|
+
const symbols = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.documentSymbols(resolvedFilePath, signal), "documentSymbols", clientOptions(signal));
|
|
5539
5593
|
return formatSymbolsResult(filePath, scope, symbols, limit);
|
|
5540
5594
|
} catch (error) {
|
|
5541
5595
|
const query = optionalString(params, "query");
|
|
@@ -4153,8 +4153,8 @@ function createIdleTimer(idleTimeoutMs, log, onTimeout) {
|
|
|
4153
4153
|
};
|
|
4154
4154
|
}
|
|
4155
4155
|
// ../lsp-core/src/lsp/client-wrapper.ts
|
|
4156
|
-
import { existsSync as existsSync10, statSync as statSync4 } from "node:fs";
|
|
4157
|
-
import { dirname as dirname8, join as join4, resolve as resolve7 } from "node:path";
|
|
4156
|
+
import { existsSync as existsSync10, realpathSync as realpathSync4, statSync as statSync4 } from "node:fs";
|
|
4157
|
+
import { basename as basename3, dirname as dirname8, join as join4, resolve as resolve7 } from "node:path";
|
|
4158
4158
|
|
|
4159
4159
|
// ../lsp-core/src/lsp/server-install-state.ts
|
|
4160
4160
|
import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
@@ -4685,32 +4685,86 @@ function isDirectoryPath(filePath) {
|
|
|
4685
4685
|
}
|
|
4686
4686
|
}
|
|
4687
4687
|
function findWorkspaceRoot(filePath) {
|
|
4688
|
-
const
|
|
4688
|
+
const cwd = contextCwd();
|
|
4689
|
+
const abs = resolveReadablePathInsideContext(filePath);
|
|
4689
4690
|
let dir = abs;
|
|
4690
4691
|
if (!isDirectoryPath(dir)) {
|
|
4691
4692
|
dir = dirname8(dir);
|
|
4692
4693
|
}
|
|
4693
|
-
|
|
4694
|
-
while (dir
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4694
|
+
const fallbackRoot = nearestExistingDirectoryInsideContext(dir, cwd) ?? cwd;
|
|
4695
|
+
while (isPathInside(cwd, dir)) {
|
|
4696
|
+
const canonicalDir = existingDirectoryInsideContext(dir, cwd);
|
|
4697
|
+
if (canonicalDir !== undefined) {
|
|
4698
|
+
for (const marker of WORKSPACE_MARKERS) {
|
|
4699
|
+
if (existsSync10(join4(dir, marker))) {
|
|
4700
|
+
return canonicalDir;
|
|
4701
|
+
}
|
|
4698
4702
|
}
|
|
4699
4703
|
}
|
|
4700
|
-
|
|
4704
|
+
if (dir === cwd)
|
|
4705
|
+
break;
|
|
4701
4706
|
dir = dirname8(dir);
|
|
4702
4707
|
}
|
|
4703
|
-
return
|
|
4708
|
+
return fallbackRoot;
|
|
4704
4709
|
}
|
|
4705
|
-
function
|
|
4710
|
+
function resolveReadablePathInsideContext(filePath) {
|
|
4706
4711
|
const cwd = contextCwd();
|
|
4707
4712
|
const abs = resolve7(cwd, filePath);
|
|
4713
|
+
if (isPathInside(cwd, abs))
|
|
4714
|
+
return abs;
|
|
4715
|
+
const rebased = rebaseThroughCanonicalAncestor(abs, cwd);
|
|
4716
|
+
if (rebased !== undefined)
|
|
4717
|
+
return rebased;
|
|
4718
|
+
const canonical = canonicalizeExistingOrNearestAncestor(abs);
|
|
4719
|
+
if (isPathInside(cwd, canonical))
|
|
4720
|
+
return canonical;
|
|
4721
|
+
throw new LspInvalidPathError(`LSP file path must be inside request cwd: ${filePath}`);
|
|
4722
|
+
}
|
|
4723
|
+
function resolvePathInsideContext(filePath) {
|
|
4724
|
+
const cwd = contextCwd();
|
|
4725
|
+
const abs = resolveReadablePathInsideContext(filePath);
|
|
4708
4726
|
const canonical = canonicalizeExistingOrNearestAncestor(abs);
|
|
4709
4727
|
if (!isPathInside(cwd, canonical)) {
|
|
4710
4728
|
throw new LspInvalidPathError(`LSP file path must be inside request cwd: ${filePath}`);
|
|
4711
4729
|
}
|
|
4712
4730
|
return canonical;
|
|
4713
4731
|
}
|
|
4732
|
+
function rebaseThroughCanonicalAncestor(path2, cwd) {
|
|
4733
|
+
let current = path2;
|
|
4734
|
+
const suffix = [];
|
|
4735
|
+
while (true) {
|
|
4736
|
+
if (existsSync10(current)) {
|
|
4737
|
+
const canonical = realpathSync4(current);
|
|
4738
|
+
if (isPathInside(cwd, canonical))
|
|
4739
|
+
return suffix.length === 0 ? canonical : join4(canonical, ...suffix);
|
|
4740
|
+
}
|
|
4741
|
+
const parent = dirname8(current);
|
|
4742
|
+
if (parent === current)
|
|
4743
|
+
return;
|
|
4744
|
+
suffix.unshift(basename3(current));
|
|
4745
|
+
current = parent;
|
|
4746
|
+
}
|
|
4747
|
+
}
|
|
4748
|
+
function existingDirectoryInsideContext(directory, cwd) {
|
|
4749
|
+
if (!existsSync10(directory))
|
|
4750
|
+
return;
|
|
4751
|
+
const canonical = realpathSync4(directory);
|
|
4752
|
+
if (!statSync4(canonical).isDirectory())
|
|
4753
|
+
return;
|
|
4754
|
+
return isPathInside(cwd, canonical) ? canonical : undefined;
|
|
4755
|
+
}
|
|
4756
|
+
function nearestExistingDirectoryInsideContext(directory, cwd) {
|
|
4757
|
+
let current = directory;
|
|
4758
|
+
while (isPathInside(cwd, current)) {
|
|
4759
|
+
const canonical = existingDirectoryInsideContext(current, cwd);
|
|
4760
|
+
if (canonical !== undefined)
|
|
4761
|
+
return canonical;
|
|
4762
|
+
if (current === cwd)
|
|
4763
|
+
return;
|
|
4764
|
+
current = dirname8(current);
|
|
4765
|
+
}
|
|
4766
|
+
return;
|
|
4767
|
+
}
|
|
4714
4768
|
function formatServerLookupError(result) {
|
|
4715
4769
|
if (result.status === "not_installed") {
|
|
4716
4770
|
return formatNotInstalled(result);
|
|
@@ -4781,7 +4835,7 @@ function formatNotInstalled(result) {
|
|
|
4781
4835
|
].join(`
|
|
4782
4836
|
`);
|
|
4783
4837
|
}
|
|
4784
|
-
var
|
|
4838
|
+
var READ_ONLY_TOOLS = new Set([
|
|
4785
4839
|
"diagnostics",
|
|
4786
4840
|
"definition",
|
|
4787
4841
|
"references",
|
|
@@ -4790,7 +4844,7 @@ var READ_ONLY_RETRY_TOOLS = new Set([
|
|
|
4790
4844
|
"prepareRename"
|
|
4791
4845
|
]);
|
|
4792
4846
|
async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
4793
|
-
const absPath = resolvePathInsideContext(filePath);
|
|
4847
|
+
const absPath = READ_ONLY_TOOLS.has(toolName) ? resolveReadablePathInsideContext(filePath) : resolvePathInsideContext(filePath);
|
|
4794
4848
|
if (isDirectoryPath(absPath)) {
|
|
4795
4849
|
throw new LspInvalidPathError("Directory paths are not supported by this LSP tool. " + "Use lsp.diagnostics with a directory path for directory diagnostics.");
|
|
4796
4850
|
}
|
|
@@ -4805,9 +4859,9 @@ async function withLspClient(filePath, fn, toolName, options = {}) {
|
|
|
4805
4859
|
const acquireAndCall = async (allowRetry) => {
|
|
4806
4860
|
const client = await manager.getClient(root, server2, options.signal);
|
|
4807
4861
|
try {
|
|
4808
|
-
return await fn(client, root);
|
|
4862
|
+
return await fn(client, root, absPath);
|
|
4809
4863
|
} catch (err) {
|
|
4810
|
-
if (allowRetry &&
|
|
4864
|
+
if (allowRetry && READ_ONLY_TOOLS.has(toolName) && isLspDeadConnectionError(err)) {
|
|
4811
4865
|
manager.invalidateClient(root, server2.id, client);
|
|
4812
4866
|
return acquireAndCall(false);
|
|
4813
4867
|
}
|
|
@@ -5262,7 +5316,7 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
5262
5316
|
const filePath = requireString(params, "filePath");
|
|
5263
5317
|
const severity = severityFilter(params);
|
|
5264
5318
|
try {
|
|
5265
|
-
const absPath =
|
|
5319
|
+
const absPath = resolveReadablePathInsideContext(filePath);
|
|
5266
5320
|
if (isDirectoryPath(absPath)) {
|
|
5267
5321
|
const extension = inferExtensionFromDirectory(absPath);
|
|
5268
5322
|
if (!extension) {
|
|
@@ -5291,7 +5345,7 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
5291
5345
|
};
|
|
5292
5346
|
return text(output2.output, details2);
|
|
5293
5347
|
}
|
|
5294
|
-
const result = await withLspClient(filePath, async (client) => client.diagnostics(
|
|
5348
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.diagnostics(resolvedFilePath, signal), "diagnostics", clientOptions(signal));
|
|
5295
5349
|
if (result.transientError) {
|
|
5296
5350
|
const message = result.transientError.message;
|
|
5297
5351
|
const details2 = {
|
|
@@ -5366,7 +5420,7 @@ async function executeLspGotoDefinition(params, signal) {
|
|
|
5366
5420
|
const line = requireNumber(params, "line");
|
|
5367
5421
|
const character = requireNumber(params, "character");
|
|
5368
5422
|
try {
|
|
5369
|
-
const result = await withLspClient(filePath, async (client) => client.definition(
|
|
5423
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.definition(resolvedFilePath, line, character, signal), "definition", clientOptions(signal));
|
|
5370
5424
|
const locations = !result ? [] : Array.isArray(result) ? result : [result];
|
|
5371
5425
|
const details = { filePath, line, character, locations };
|
|
5372
5426
|
if (locations.length === 0)
|
|
@@ -5391,7 +5445,7 @@ async function executeLspFindReferences(params, signal) {
|
|
|
5391
5445
|
const character = requireNumber(params, "character");
|
|
5392
5446
|
const includeDeclaration = optionalBoolean(params, "includeDeclaration") ?? true;
|
|
5393
5447
|
try {
|
|
5394
|
-
const result = await withLspClient(filePath, async (client) => client.references(
|
|
5448
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.references(resolvedFilePath, line, character, includeDeclaration, signal), "references", clientOptions(signal));
|
|
5395
5449
|
const references = Array.isArray(result) ? result : [];
|
|
5396
5450
|
const total = references.length;
|
|
5397
5451
|
const truncated = total > DEFAULT_MAX_REFERENCES;
|
|
@@ -5433,7 +5487,7 @@ async function executeLspPrepareRename(params, signal) {
|
|
|
5433
5487
|
const line = requireNumber(params, "line");
|
|
5434
5488
|
const character = requireNumber(params, "character");
|
|
5435
5489
|
try {
|
|
5436
|
-
const result = await withLspClient(filePath, async (client) => client.prepareRename(
|
|
5490
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.prepareRename(resolvedFilePath, line, character, signal), "prepareRename", clientOptions(signal));
|
|
5437
5491
|
const details = { filePath, line, character, result };
|
|
5438
5492
|
return text(formatPrepareRenameResult(result), details);
|
|
5439
5493
|
} catch (error) {
|
|
@@ -5454,7 +5508,7 @@ async function executeLspRename(params, signal) {
|
|
|
5454
5508
|
const character = requireNumber(params, "character");
|
|
5455
5509
|
const newName = requireString(params, "newName");
|
|
5456
5510
|
try {
|
|
5457
|
-
const result = await withLspClient(filePath, async (client) => client.rename(
|
|
5511
|
+
const result = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.rename(resolvedFilePath, line, character, newName, signal), "rename", clientOptions(signal));
|
|
5458
5512
|
const details = { filePath, line, character, newName, apply: result.apply, edit: result.edit };
|
|
5459
5513
|
return text(formatApplyResult(result.apply), details, !result.apply.success);
|
|
5460
5514
|
} catch (error) {
|
|
@@ -5534,7 +5588,7 @@ async function executeLspSymbols(params, signal) {
|
|
|
5534
5588
|
const symbols2 = await withLspClient(filePath, async (client) => client.workspaceSymbols(query, signal), "workspaceSymbols", clientOptions(signal));
|
|
5535
5589
|
return formatSymbolsResult(filePath, scope, symbols2, limit, query);
|
|
5536
5590
|
}
|
|
5537
|
-
const symbols = await withLspClient(filePath, async (client) => client.documentSymbols(
|
|
5591
|
+
const symbols = await withLspClient(filePath, async (client, _workspaceRoot, resolvedFilePath) => client.documentSymbols(resolvedFilePath, signal), "documentSymbols", clientOptions(signal));
|
|
5538
5592
|
return formatSymbolsResult(filePath, scope, symbols, limit);
|
|
5539
5593
|
} catch (error) {
|
|
5540
5594
|
const query = optionalString(params, "query");
|
|
@@ -6025,8 +6079,8 @@ function isRetryableTool(name) {
|
|
|
6025
6079
|
return name !== "rename" && name !== "lsp_rename";
|
|
6026
6080
|
}
|
|
6027
6081
|
// src/proxy.ts
|
|
6028
|
-
import { existsSync as existsSync12, realpathSync as
|
|
6029
|
-
import { basename as
|
|
6082
|
+
import { existsSync as existsSync12, realpathSync as realpathSync5 } from "node:fs";
|
|
6083
|
+
import { basename as basename4, delimiter as delimiter4, dirname as dirname9, isAbsolute as isAbsolute5 } from "node:path";
|
|
6030
6084
|
var DEFAULT_STARTUP_TIMEOUT_MS = 1e4;
|
|
6031
6085
|
async function runMcpStdioProxy(options = {}) {
|
|
6032
6086
|
const input = options.input ?? process.stdin;
|
|
@@ -6151,13 +6205,13 @@ function canonicalizePathList(value) {
|
|
|
6151
6205
|
function canonicalizePath(value) {
|
|
6152
6206
|
if (value === undefined || !isAbsolute5(value) || !existsSync12(value))
|
|
6153
6207
|
return value;
|
|
6154
|
-
return
|
|
6208
|
+
return realpathSync5(value);
|
|
6155
6209
|
}
|
|
6156
6210
|
function projectRootFromOpenCodeConfigPath(path2) {
|
|
6157
|
-
if (
|
|
6211
|
+
if (basename4(path2) !== "lsp.json" && basename4(path2) !== "lsp-client.json")
|
|
6158
6212
|
return;
|
|
6159
6213
|
const configDir = dirname9(path2);
|
|
6160
|
-
const configDirName =
|
|
6214
|
+
const configDirName = basename4(configDir);
|
|
6161
6215
|
if (configDirName !== ".opencode" && configDirName !== ".omo")
|
|
6162
6216
|
return;
|
|
6163
6217
|
return dirname9(configDir);
|