@rama_nigg/open-cursor 2.1.2 → 2.1.4
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/README.md +2 -0
- package/dist/index.js +54 -17
- package/dist/plugin-entry.js +54 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@ No prompt limits. No broken streams. Full thinking + tool support in Opencode. Y
|
|
|
15
15
|
curl -fsSL https://raw.githubusercontent.com/Nomadcxx/opencode-cursor/main/install.sh | bash
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
Note: if `npm` is available, `install.sh` installs/upgrades `@rama_nigg/open-cursor` and runs `open-cursor install`. Otherwise it falls back to building from source.
|
|
19
|
+
|
|
18
20
|
**Option B: npm Package (Use when published)**
|
|
19
21
|
|
|
20
22
|
Check whether the package is available on npm first:
|
package/dist/index.js
CHANGED
|
@@ -17478,6 +17478,31 @@ async function ensurePluginDirectory() {
|
|
|
17478
17478
|
function getGlobalKey() {
|
|
17479
17479
|
return "__opencode_cursor_proxy_server__";
|
|
17480
17480
|
}
|
|
17481
|
+
function resolveWorkspaceDirectory(worktree, directory) {
|
|
17482
|
+
const envWorkspace = process.env.CURSOR_ACP_WORKSPACE?.trim();
|
|
17483
|
+
if (envWorkspace) {
|
|
17484
|
+
return resolve(envWorkspace);
|
|
17485
|
+
}
|
|
17486
|
+
const envProjectDir = process.env.OPENCODE_CURSOR_PROJECT_DIR?.trim();
|
|
17487
|
+
if (envProjectDir) {
|
|
17488
|
+
return resolve(envProjectDir);
|
|
17489
|
+
}
|
|
17490
|
+
const configHome = process.env.XDG_CONFIG_HOME ? resolve(process.env.XDG_CONFIG_HOME) : join2(homedir2(), ".config");
|
|
17491
|
+
const configPrefix = join2(configHome, "opencode");
|
|
17492
|
+
const worktreeCandidate = worktree ? resolve(worktree) : "";
|
|
17493
|
+
if (worktreeCandidate && !worktreeCandidate.startsWith(configPrefix)) {
|
|
17494
|
+
return worktreeCandidate;
|
|
17495
|
+
}
|
|
17496
|
+
const dirCandidate = directory ? resolve(directory) : "";
|
|
17497
|
+
if (dirCandidate && !dirCandidate.startsWith(configPrefix)) {
|
|
17498
|
+
return dirCandidate;
|
|
17499
|
+
}
|
|
17500
|
+
const cwd = process.cwd();
|
|
17501
|
+
if (cwd && !cwd.startsWith(configPrefix)) {
|
|
17502
|
+
return cwd;
|
|
17503
|
+
}
|
|
17504
|
+
return dirCandidate || cwd || configPrefix;
|
|
17505
|
+
}
|
|
17481
17506
|
function parseToolLoopMode(value) {
|
|
17482
17507
|
const normalized = (value ?? "opencode").trim().toLowerCase();
|
|
17483
17508
|
if (normalized === "opencode" || normalized === "proxy-exec" || normalized === "off") {
|
|
@@ -18559,14 +18584,19 @@ function jsonSchemaToZod(jsonSchema) {
|
|
|
18559
18584
|
}
|
|
18560
18585
|
return zodShape;
|
|
18561
18586
|
}
|
|
18562
|
-
function resolveToolContextBaseDir(context) {
|
|
18563
|
-
const
|
|
18564
|
-
|
|
18565
|
-
|
|
18566
|
-
|
|
18567
|
-
|
|
18568
|
-
|
|
18569
|
-
|
|
18587
|
+
function resolveToolContextBaseDir(context, fallbackBaseDir) {
|
|
18588
|
+
const configHome = process.env.XDG_CONFIG_HOME ? resolve(process.env.XDG_CONFIG_HOME) : join2(homedir2(), ".config");
|
|
18589
|
+
const configPrefix = join2(configHome, "opencode");
|
|
18590
|
+
const worktree = typeof context?.worktree === "string" ? context.worktree.trim() : "";
|
|
18591
|
+
if (worktree)
|
|
18592
|
+
return worktree;
|
|
18593
|
+
const directory = typeof context?.directory === "string" ? context.directory.trim() : "";
|
|
18594
|
+
if (directory && !resolve(directory).startsWith(configPrefix))
|
|
18595
|
+
return directory;
|
|
18596
|
+
const fallback = typeof fallbackBaseDir === "string" ? fallbackBaseDir.trim() : "";
|
|
18597
|
+
if (fallback)
|
|
18598
|
+
return fallback;
|
|
18599
|
+
return directory || null;
|
|
18570
18600
|
}
|
|
18571
18601
|
function toAbsoluteWithBase(value, baseDir) {
|
|
18572
18602
|
if (typeof value !== "string") {
|
|
@@ -18578,8 +18608,8 @@ function toAbsoluteWithBase(value, baseDir) {
|
|
|
18578
18608
|
}
|
|
18579
18609
|
return resolve(baseDir, trimmed);
|
|
18580
18610
|
}
|
|
18581
|
-
function applyToolContextDefaults(toolName, rawArgs, context) {
|
|
18582
|
-
const baseDir = resolveToolContextBaseDir(context);
|
|
18611
|
+
function applyToolContextDefaults(toolName, rawArgs, context, fallbackBaseDir) {
|
|
18612
|
+
const baseDir = resolveToolContextBaseDir(context, fallbackBaseDir);
|
|
18583
18613
|
if (!baseDir) {
|
|
18584
18614
|
return rawArgs;
|
|
18585
18615
|
}
|
|
@@ -18606,7 +18636,7 @@ function applyToolContextDefaults(toolName, rawArgs, context) {
|
|
|
18606
18636
|
}
|
|
18607
18637
|
return args;
|
|
18608
18638
|
}
|
|
18609
|
-
function buildToolHookEntries(registry2) {
|
|
18639
|
+
function buildToolHookEntries(registry2, fallbackBaseDir) {
|
|
18610
18640
|
const entries = {};
|
|
18611
18641
|
const tools = registry2.list();
|
|
18612
18642
|
for (const t of tools) {
|
|
@@ -18619,7 +18649,7 @@ function buildToolHookEntries(registry2) {
|
|
|
18619
18649
|
args: zodArgs,
|
|
18620
18650
|
async execute(args, context) {
|
|
18621
18651
|
try {
|
|
18622
|
-
const normalizedArgs = applyToolContextDefaults(toolName, args, context);
|
|
18652
|
+
const normalizedArgs = applyToolContextDefaults(toolName, args, context, fallbackBaseDir);
|
|
18623
18653
|
return await handler(normalizedArgs);
|
|
18624
18654
|
} catch (error45) {
|
|
18625
18655
|
log13.warn("Tool hook execution failed", { tool: toolName, error: String(error45?.message || error45) });
|
|
@@ -18634,8 +18664,15 @@ function buildToolHookEntries(registry2) {
|
|
|
18634
18664
|
}
|
|
18635
18665
|
return entries;
|
|
18636
18666
|
}
|
|
18637
|
-
var log13, CURSOR_PROVIDER_ID = "cursor-acp", CURSOR_PROXY_HOST = "127.0.0.1", CURSOR_PROXY_DEFAULT_PORT = 32124, CURSOR_PROXY_DEFAULT_BASE_URL, REUSE_EXISTING_PROXY, FORCE_TOOL_MODE, EMIT_TOOL_UPDATES, FORWARD_TOOL_CALLS, TOOL_LOOP_MODE_RAW, TOOL_LOOP_MODE, TOOL_LOOP_MODE_VALID, PROVIDER_BOUNDARY_MODE_RAW, PROVIDER_BOUNDARY_MODE, PROVIDER_BOUNDARY_MODE_VALID, LEGACY_PROVIDER_BOUNDARY, PROVIDER_BOUNDARY, ENABLE_PROVIDER_BOUNDARY_AUTOFALLBACK, TOOL_LOOP_MAX_REPEAT_RAW, TOOL_LOOP_MAX_REPEAT, TOOL_LOOP_MAX_REPEAT_VALID, PROXY_EXECUTE_TOOL_CALLS, SUPPRESS_CONVERTER_TOOL_EVENTS, SHOULD_EMIT_TOOL_UPDATES, CursorPlugin = async ({ $, directory, client: client3, serverUrl }) => {
|
|
18638
|
-
|
|
18667
|
+
var log13, CURSOR_PROVIDER_ID = "cursor-acp", CURSOR_PROXY_HOST = "127.0.0.1", CURSOR_PROXY_DEFAULT_PORT = 32124, CURSOR_PROXY_DEFAULT_BASE_URL, REUSE_EXISTING_PROXY, FORCE_TOOL_MODE, EMIT_TOOL_UPDATES, FORWARD_TOOL_CALLS, TOOL_LOOP_MODE_RAW, TOOL_LOOP_MODE, TOOL_LOOP_MODE_VALID, PROVIDER_BOUNDARY_MODE_RAW, PROVIDER_BOUNDARY_MODE, PROVIDER_BOUNDARY_MODE_VALID, LEGACY_PROVIDER_BOUNDARY, PROVIDER_BOUNDARY, ENABLE_PROVIDER_BOUNDARY_AUTOFALLBACK, TOOL_LOOP_MAX_REPEAT_RAW, TOOL_LOOP_MAX_REPEAT, TOOL_LOOP_MAX_REPEAT_VALID, PROXY_EXECUTE_TOOL_CALLS, SUPPRESS_CONVERTER_TOOL_EVENTS, SHOULD_EMIT_TOOL_UPDATES, CursorPlugin = async ({ $, directory, worktree, client: client3, serverUrl }) => {
|
|
18668
|
+
const workspaceDirectory = resolveWorkspaceDirectory(worktree, directory);
|
|
18669
|
+
log13.debug("Plugin initializing", {
|
|
18670
|
+
directory,
|
|
18671
|
+
worktree,
|
|
18672
|
+
workspaceDirectory,
|
|
18673
|
+
cwd: process.cwd(),
|
|
18674
|
+
serverUrl: serverUrl?.toString()
|
|
18675
|
+
});
|
|
18639
18676
|
if (!TOOL_LOOP_MODE_VALID) {
|
|
18640
18677
|
log13.warn("Invalid CURSOR_ACP_TOOL_LOOP_MODE; defaulting to opencode", { value: TOOL_LOOP_MODE_RAW });
|
|
18641
18678
|
}
|
|
@@ -18667,7 +18704,7 @@ var log13, CURSOR_PROVIDER_ID = "cursor-acp", CURSOR_PROXY_HOST = "127.0.0.1", C
|
|
|
18667
18704
|
} else if (toolsEnabled && TOOL_LOOP_MODE === "off") {
|
|
18668
18705
|
log13.debug("Tool loop mode off; proxy-side tool execution disabled");
|
|
18669
18706
|
}
|
|
18670
|
-
const serverClient = legacyProxyToolPathsEnabled ? createOpencodeClient({ baseUrl: serverUrl.toString(), directory }) : null;
|
|
18707
|
+
const serverClient = legacyProxyToolPathsEnabled ? createOpencodeClient({ baseUrl: serverUrl.toString(), directory: workspaceDirectory }) : null;
|
|
18671
18708
|
const discovery = legacyProxyToolPathsEnabled ? new OpenCodeToolDiscovery(serverClient ?? client3) : null;
|
|
18672
18709
|
const localRegistry = new ToolRegistry;
|
|
18673
18710
|
registerDefaultTools(localRegistry);
|
|
@@ -18750,9 +18787,9 @@ var log13, CURSOR_PROVIDER_ID = "cursor-acp", CURSOR_PROXY_HOST = "127.0.0.1", C
|
|
|
18750
18787
|
log13.debug("Tools refreshed", { local: localTools.length, discovered: discoveredList.length, total: toolEntries.length });
|
|
18751
18788
|
return toolEntries;
|
|
18752
18789
|
}
|
|
18753
|
-
const proxyBaseURL = await ensureCursorProxyServer(
|
|
18790
|
+
const proxyBaseURL = await ensureCursorProxyServer(workspaceDirectory, router);
|
|
18754
18791
|
log13.debug("Proxy server started", { baseURL: proxyBaseURL });
|
|
18755
|
-
const toolHookEntries = buildToolHookEntries(localRegistry);
|
|
18792
|
+
const toolHookEntries = buildToolHookEntries(localRegistry, workspaceDirectory);
|
|
18756
18793
|
return {
|
|
18757
18794
|
tool: toolHookEntries,
|
|
18758
18795
|
auth: {
|
package/dist/plugin-entry.js
CHANGED
|
@@ -17478,6 +17478,31 @@ async function ensurePluginDirectory() {
|
|
|
17478
17478
|
function getGlobalKey() {
|
|
17479
17479
|
return "__opencode_cursor_proxy_server__";
|
|
17480
17480
|
}
|
|
17481
|
+
function resolveWorkspaceDirectory(worktree, directory) {
|
|
17482
|
+
const envWorkspace = process.env.CURSOR_ACP_WORKSPACE?.trim();
|
|
17483
|
+
if (envWorkspace) {
|
|
17484
|
+
return resolve2(envWorkspace);
|
|
17485
|
+
}
|
|
17486
|
+
const envProjectDir = process.env.OPENCODE_CURSOR_PROJECT_DIR?.trim();
|
|
17487
|
+
if (envProjectDir) {
|
|
17488
|
+
return resolve2(envProjectDir);
|
|
17489
|
+
}
|
|
17490
|
+
const configHome = process.env.XDG_CONFIG_HOME ? resolve2(process.env.XDG_CONFIG_HOME) : join3(homedir3(), ".config");
|
|
17491
|
+
const configPrefix = join3(configHome, "opencode");
|
|
17492
|
+
const worktreeCandidate = worktree ? resolve2(worktree) : "";
|
|
17493
|
+
if (worktreeCandidate && !worktreeCandidate.startsWith(configPrefix)) {
|
|
17494
|
+
return worktreeCandidate;
|
|
17495
|
+
}
|
|
17496
|
+
const dirCandidate = directory ? resolve2(directory) : "";
|
|
17497
|
+
if (dirCandidate && !dirCandidate.startsWith(configPrefix)) {
|
|
17498
|
+
return dirCandidate;
|
|
17499
|
+
}
|
|
17500
|
+
const cwd = process.cwd();
|
|
17501
|
+
if (cwd && !cwd.startsWith(configPrefix)) {
|
|
17502
|
+
return cwd;
|
|
17503
|
+
}
|
|
17504
|
+
return dirCandidate || cwd || configPrefix;
|
|
17505
|
+
}
|
|
17481
17506
|
function parseToolLoopMode(value) {
|
|
17482
17507
|
const normalized = (value ?? "opencode").trim().toLowerCase();
|
|
17483
17508
|
if (normalized === "opencode" || normalized === "proxy-exec" || normalized === "off") {
|
|
@@ -18559,14 +18584,19 @@ function jsonSchemaToZod(jsonSchema) {
|
|
|
18559
18584
|
}
|
|
18560
18585
|
return zodShape;
|
|
18561
18586
|
}
|
|
18562
|
-
function resolveToolContextBaseDir(context) {
|
|
18563
|
-
const
|
|
18564
|
-
|
|
18565
|
-
|
|
18566
|
-
|
|
18567
|
-
|
|
18568
|
-
|
|
18569
|
-
|
|
18587
|
+
function resolveToolContextBaseDir(context, fallbackBaseDir) {
|
|
18588
|
+
const configHome = process.env.XDG_CONFIG_HOME ? resolve2(process.env.XDG_CONFIG_HOME) : join3(homedir3(), ".config");
|
|
18589
|
+
const configPrefix = join3(configHome, "opencode");
|
|
18590
|
+
const worktree = typeof context?.worktree === "string" ? context.worktree.trim() : "";
|
|
18591
|
+
if (worktree)
|
|
18592
|
+
return worktree;
|
|
18593
|
+
const directory = typeof context?.directory === "string" ? context.directory.trim() : "";
|
|
18594
|
+
if (directory && !resolve2(directory).startsWith(configPrefix))
|
|
18595
|
+
return directory;
|
|
18596
|
+
const fallback = typeof fallbackBaseDir === "string" ? fallbackBaseDir.trim() : "";
|
|
18597
|
+
if (fallback)
|
|
18598
|
+
return fallback;
|
|
18599
|
+
return directory || null;
|
|
18570
18600
|
}
|
|
18571
18601
|
function toAbsoluteWithBase(value, baseDir) {
|
|
18572
18602
|
if (typeof value !== "string") {
|
|
@@ -18578,8 +18608,8 @@ function toAbsoluteWithBase(value, baseDir) {
|
|
|
18578
18608
|
}
|
|
18579
18609
|
return resolve2(baseDir, trimmed);
|
|
18580
18610
|
}
|
|
18581
|
-
function applyToolContextDefaults(toolName, rawArgs, context) {
|
|
18582
|
-
const baseDir = resolveToolContextBaseDir(context);
|
|
18611
|
+
function applyToolContextDefaults(toolName, rawArgs, context, fallbackBaseDir) {
|
|
18612
|
+
const baseDir = resolveToolContextBaseDir(context, fallbackBaseDir);
|
|
18583
18613
|
if (!baseDir) {
|
|
18584
18614
|
return rawArgs;
|
|
18585
18615
|
}
|
|
@@ -18606,7 +18636,7 @@ function applyToolContextDefaults(toolName, rawArgs, context) {
|
|
|
18606
18636
|
}
|
|
18607
18637
|
return args;
|
|
18608
18638
|
}
|
|
18609
|
-
function buildToolHookEntries(registry2) {
|
|
18639
|
+
function buildToolHookEntries(registry2, fallbackBaseDir) {
|
|
18610
18640
|
const entries = {};
|
|
18611
18641
|
const tools = registry2.list();
|
|
18612
18642
|
for (const t of tools) {
|
|
@@ -18619,7 +18649,7 @@ function buildToolHookEntries(registry2) {
|
|
|
18619
18649
|
args: zodArgs,
|
|
18620
18650
|
async execute(args, context) {
|
|
18621
18651
|
try {
|
|
18622
|
-
const normalizedArgs = applyToolContextDefaults(toolName, args, context);
|
|
18652
|
+
const normalizedArgs = applyToolContextDefaults(toolName, args, context, fallbackBaseDir);
|
|
18623
18653
|
return await handler(normalizedArgs);
|
|
18624
18654
|
} catch (error45) {
|
|
18625
18655
|
log13.warn("Tool hook execution failed", { tool: toolName, error: String(error45?.message || error45) });
|
|
@@ -18634,8 +18664,15 @@ function buildToolHookEntries(registry2) {
|
|
|
18634
18664
|
}
|
|
18635
18665
|
return entries;
|
|
18636
18666
|
}
|
|
18637
|
-
var log13, CURSOR_PROVIDER_ID2 = "cursor-acp", CURSOR_PROXY_HOST = "127.0.0.1", CURSOR_PROXY_DEFAULT_PORT = 32124, CURSOR_PROXY_DEFAULT_BASE_URL, REUSE_EXISTING_PROXY, FORCE_TOOL_MODE, EMIT_TOOL_UPDATES, FORWARD_TOOL_CALLS, TOOL_LOOP_MODE_RAW, TOOL_LOOP_MODE, TOOL_LOOP_MODE_VALID, PROVIDER_BOUNDARY_MODE_RAW, PROVIDER_BOUNDARY_MODE, PROVIDER_BOUNDARY_MODE_VALID, LEGACY_PROVIDER_BOUNDARY, PROVIDER_BOUNDARY, ENABLE_PROVIDER_BOUNDARY_AUTOFALLBACK, TOOL_LOOP_MAX_REPEAT_RAW, TOOL_LOOP_MAX_REPEAT, TOOL_LOOP_MAX_REPEAT_VALID, PROXY_EXECUTE_TOOL_CALLS, SUPPRESS_CONVERTER_TOOL_EVENTS, SHOULD_EMIT_TOOL_UPDATES, CursorPlugin = async ({ $, directory, client: client3, serverUrl }) => {
|
|
18638
|
-
|
|
18667
|
+
var log13, CURSOR_PROVIDER_ID2 = "cursor-acp", CURSOR_PROXY_HOST = "127.0.0.1", CURSOR_PROXY_DEFAULT_PORT = 32124, CURSOR_PROXY_DEFAULT_BASE_URL, REUSE_EXISTING_PROXY, FORCE_TOOL_MODE, EMIT_TOOL_UPDATES, FORWARD_TOOL_CALLS, TOOL_LOOP_MODE_RAW, TOOL_LOOP_MODE, TOOL_LOOP_MODE_VALID, PROVIDER_BOUNDARY_MODE_RAW, PROVIDER_BOUNDARY_MODE, PROVIDER_BOUNDARY_MODE_VALID, LEGACY_PROVIDER_BOUNDARY, PROVIDER_BOUNDARY, ENABLE_PROVIDER_BOUNDARY_AUTOFALLBACK, TOOL_LOOP_MAX_REPEAT_RAW, TOOL_LOOP_MAX_REPEAT, TOOL_LOOP_MAX_REPEAT_VALID, PROXY_EXECUTE_TOOL_CALLS, SUPPRESS_CONVERTER_TOOL_EVENTS, SHOULD_EMIT_TOOL_UPDATES, CursorPlugin = async ({ $, directory, worktree, client: client3, serverUrl }) => {
|
|
18668
|
+
const workspaceDirectory = resolveWorkspaceDirectory(worktree, directory);
|
|
18669
|
+
log13.debug("Plugin initializing", {
|
|
18670
|
+
directory,
|
|
18671
|
+
worktree,
|
|
18672
|
+
workspaceDirectory,
|
|
18673
|
+
cwd: process.cwd(),
|
|
18674
|
+
serverUrl: serverUrl?.toString()
|
|
18675
|
+
});
|
|
18639
18676
|
if (!TOOL_LOOP_MODE_VALID) {
|
|
18640
18677
|
log13.warn("Invalid CURSOR_ACP_TOOL_LOOP_MODE; defaulting to opencode", { value: TOOL_LOOP_MODE_RAW });
|
|
18641
18678
|
}
|
|
@@ -18667,7 +18704,7 @@ var log13, CURSOR_PROVIDER_ID2 = "cursor-acp", CURSOR_PROXY_HOST = "127.0.0.1",
|
|
|
18667
18704
|
} else if (toolsEnabled && TOOL_LOOP_MODE === "off") {
|
|
18668
18705
|
log13.debug("Tool loop mode off; proxy-side tool execution disabled");
|
|
18669
18706
|
}
|
|
18670
|
-
const serverClient = legacyProxyToolPathsEnabled ? createOpencodeClient({ baseUrl: serverUrl.toString(), directory }) : null;
|
|
18707
|
+
const serverClient = legacyProxyToolPathsEnabled ? createOpencodeClient({ baseUrl: serverUrl.toString(), directory: workspaceDirectory }) : null;
|
|
18671
18708
|
const discovery = legacyProxyToolPathsEnabled ? new OpenCodeToolDiscovery(serverClient ?? client3) : null;
|
|
18672
18709
|
const localRegistry = new ToolRegistry;
|
|
18673
18710
|
registerDefaultTools(localRegistry);
|
|
@@ -18750,9 +18787,9 @@ var log13, CURSOR_PROVIDER_ID2 = "cursor-acp", CURSOR_PROXY_HOST = "127.0.0.1",
|
|
|
18750
18787
|
log13.debug("Tools refreshed", { local: localTools.length, discovered: discoveredList.length, total: toolEntries.length });
|
|
18751
18788
|
return toolEntries;
|
|
18752
18789
|
}
|
|
18753
|
-
const proxyBaseURL = await ensureCursorProxyServer(
|
|
18790
|
+
const proxyBaseURL = await ensureCursorProxyServer(workspaceDirectory, router);
|
|
18754
18791
|
log13.debug("Proxy server started", { baseURL: proxyBaseURL });
|
|
18755
|
-
const toolHookEntries = buildToolHookEntries(localRegistry);
|
|
18792
|
+
const toolHookEntries = buildToolHookEntries(localRegistry, workspaceDirectory);
|
|
18756
18793
|
return {
|
|
18757
18794
|
tool: toolHookEntries,
|
|
18758
18795
|
auth: {
|
package/package.json
CHANGED