@khalilgharbaoui/opencode-claude-code-plugin 0.4.20 → 0.4.22
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 +13 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +54 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -213,8 +213,11 @@ By default, when Claude Code's CLI uses `Bash`, `Edit`, `Write`, etc., it execut
|
|
|
213
213
|
| `"Edit"` | `Edit`, `MultiEdit` | `mcp__opencode_proxy__edit` |
|
|
214
214
|
| `"Write"` | `Write` | `mcp__opencode_proxy__write` |
|
|
215
215
|
| `"WebFetch"` | `WebFetch` | `mcp__opencode_proxy__webfetch` |
|
|
216
|
+
| `"Task"` | `Agent` | `mcp__opencode_proxy__task` |
|
|
216
217
|
|
|
217
|
-
|
|
218
|
+
The `Task` proxy is the way to let Claude orchestrate opencode's configured subagents (`build`, `general`, custom subagents defined in `opencode.json`) instead of Claude CLI's internal-only general-purpose / Explore / Plan options. With `"Task"` in `proxyTools` and `permission.task: allow` granted to the calling agent, a Claude session can invoke `task(subagent_type="build", prompt="...")` and the subagent runs natively under opencode (with its own permission UI, lifecycle, model assignment, and Tab visibility). Without `"Task"`, Claude's built-in `Agent` tool stays enabled and Claude orchestrates subagents internally with no opencode visibility.
|
|
219
|
+
|
|
220
|
+
Only those five values are actually proxied; anything else you put in `proxyTools` is ignored. Proxying `Edit` also disables `MultiEdit` — opencode has no batched-edit equivalent, so Claude is forced to fan out into single `Edit` calls that each flow through the permission UI.
|
|
218
221
|
|
|
219
222
|
To turn off proxying entirely:
|
|
220
223
|
|
|
@@ -440,6 +443,7 @@ plugin internals.
|
|
|
440
443
|
```bash
|
|
441
444
|
bun install
|
|
442
445
|
bun run typecheck # tsc --noEmit
|
|
446
|
+
bun run test # tsx --test (unit suite)
|
|
443
447
|
bun run build # tsup -> dist/
|
|
444
448
|
```
|
|
445
449
|
|
|
@@ -449,17 +453,25 @@ Source layout:
|
|
|
449
453
|
src/
|
|
450
454
|
index.ts # opencode plugin entry, config + provider hooks
|
|
451
455
|
models.ts # default models + variants
|
|
456
|
+
accounts.ts # multi-account expansion (per-account CLAUDE_CONFIG_DIR + wrapper script)
|
|
452
457
|
claude-code-language-model.ts # AI-SDK provider that drives `claude`
|
|
453
458
|
message-builder.ts # AI-SDK prompt → Claude CLI user message
|
|
459
|
+
tool-mapping.ts # Claude tool name ↔ opencode tool name mapping; internal-tool skip list
|
|
454
460
|
proxy-mcp.ts # in-process MCP server for proxied tools
|
|
461
|
+
proxy-broker.ts # pending proxy-call broker between proxy-mcp and opencode tool execution
|
|
455
462
|
mcp-bridge.ts # opencode → Claude --mcp-config translator
|
|
456
463
|
session-manager.ts # LRU cache of CLI subprocesses
|
|
457
464
|
cli-version.ts # detect Claude CLI version, gate optional flags
|
|
465
|
+
runtime-status.ts # runtime introspection of opencode (MCP status, tool registry)
|
|
458
466
|
logger.ts # DEBUG=opencode-claude-code stderr logger
|
|
467
|
+
tmp.ts # per-plugin temp directory helper
|
|
468
|
+
cleanup-stale.ts # remove legacy unscoped install from opencode's plugin cache
|
|
459
469
|
types.ts # public option types
|
|
460
470
|
opencode-types.ts # mirrored opencode types
|
|
461
471
|
```
|
|
462
472
|
|
|
473
|
+
For runtime gotchas, the v1.15.0 audit waterline, and the release flow, see [`AGENTS.md`](./AGENTS.md).
|
|
474
|
+
|
|
463
475
|
## Publishing (maintainers)
|
|
464
476
|
|
|
465
477
|
```bash
|
package/dist/index.d.ts
CHANGED
|
@@ -229,7 +229,15 @@ interface ClaudeCodeProviderSettings {
|
|
|
229
229
|
* opencode's tool executor (with its native permission UI) and returns
|
|
230
230
|
* the result.
|
|
231
231
|
*
|
|
232
|
-
* Supported: `bash`, `write`, `edit`, `webfetch`. Leave empty or unset to disable proxying.
|
|
232
|
+
* Supported: `bash`, `write`, `edit`, `webfetch`, `task`. Leave empty or unset to disable proxying.
|
|
233
|
+
*
|
|
234
|
+
* `task` proxies Claude CLI's `Agent` (subagent dispatch) tool through
|
|
235
|
+
* opencode's `task` tool, so subagent calls run under opencode's
|
|
236
|
+
* configured subagent set (build/general/custom) with opencode's
|
|
237
|
+
* permission and lifecycle handling, instead of Claude CLI's
|
|
238
|
+
* internal-only general-purpose / Explore / Plan options. The calling
|
|
239
|
+
* agent must have `permission.task: allow` for the target subagent
|
|
240
|
+
* (see opencode's agent docs).
|
|
233
241
|
*/
|
|
234
242
|
proxyTools?: string[];
|
|
235
243
|
/**
|
package/dist/index.js
CHANGED
|
@@ -989,6 +989,25 @@ function setOpencodeClient(client) {
|
|
|
989
989
|
opencodeClient = client;
|
|
990
990
|
}
|
|
991
991
|
}
|
|
992
|
+
var opencodeProjectDirectory;
|
|
993
|
+
function setOpencodeProjectDirectory(dir) {
|
|
994
|
+
opencodeProjectDirectory = dir;
|
|
995
|
+
}
|
|
996
|
+
function isUsableDirectory(d) {
|
|
997
|
+
return typeof d === "string" && d.length > 1 && d !== "/";
|
|
998
|
+
}
|
|
999
|
+
function resolveSpawnCwd(configured) {
|
|
1000
|
+
return resolveSpawnCwdFrom(
|
|
1001
|
+
configured,
|
|
1002
|
+
process.cwd(),
|
|
1003
|
+
opencodeProjectDirectory
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
function resolveSpawnCwdFrom(configured, live, captured) {
|
|
1007
|
+
if (configured) return configured;
|
|
1008
|
+
if (isUsableDirectory(live)) return live;
|
|
1009
|
+
return captured ?? live;
|
|
1010
|
+
}
|
|
992
1011
|
async function getRuntimeMcpStatus() {
|
|
993
1012
|
const client = opencodeClient;
|
|
994
1013
|
if (!client?.mcp?.status) return void 0;
|
|
@@ -1387,6 +1406,36 @@ var DEFAULT_PROXY_TOOLS = [
|
|
|
1387
1406
|
},
|
|
1388
1407
|
required: ["url"]
|
|
1389
1408
|
}
|
|
1409
|
+
},
|
|
1410
|
+
{
|
|
1411
|
+
name: "task",
|
|
1412
|
+
description: "Launch an opencode subagent to handle a complex multi-step task autonomously. Routed through opencode's task tool so subagent orchestration, permission, and lifecycle are handled by opencode. Use `subagent_type` to pick which configured subagent runs (e.g. `build`, `general`, `explore`, or any custom subagent declared in opencode.json). The call blocks until the subagent finishes; the 10-minute proxy timeout applies.",
|
|
1413
|
+
inputSchema: {
|
|
1414
|
+
type: "object",
|
|
1415
|
+
properties: {
|
|
1416
|
+
description: {
|
|
1417
|
+
type: "string",
|
|
1418
|
+
description: "A short (3-5 words) description of the task"
|
|
1419
|
+
},
|
|
1420
|
+
prompt: {
|
|
1421
|
+
type: "string",
|
|
1422
|
+
description: "The task for the agent to perform"
|
|
1423
|
+
},
|
|
1424
|
+
subagent_type: {
|
|
1425
|
+
type: "string",
|
|
1426
|
+
description: "The type of specialized agent to use for this task"
|
|
1427
|
+
},
|
|
1428
|
+
task_id: {
|
|
1429
|
+
type: "string",
|
|
1430
|
+
description: "Set this only if you mean to resume a previous task \u2014 pass the prior task_id to continue the same subagent session instead of creating a fresh one."
|
|
1431
|
+
},
|
|
1432
|
+
command: {
|
|
1433
|
+
type: "string",
|
|
1434
|
+
description: "The command that triggered this task"
|
|
1435
|
+
}
|
|
1436
|
+
},
|
|
1437
|
+
required: ["description", "prompt", "subagent_type"]
|
|
1438
|
+
}
|
|
1390
1439
|
}
|
|
1391
1440
|
];
|
|
1392
1441
|
async function createProxyMcpServer(tools = DEFAULT_PROXY_TOOLS) {
|
|
@@ -1623,7 +1672,8 @@ function disallowedToolFlags(tools) {
|
|
|
1623
1672
|
edit: ["Edit", "MultiEdit"],
|
|
1624
1673
|
glob: ["Glob"],
|
|
1625
1674
|
grep: ["Grep"],
|
|
1626
|
-
webfetch: ["WebFetch"]
|
|
1675
|
+
webfetch: ["WebFetch"],
|
|
1676
|
+
task: ["Agent"]
|
|
1627
1677
|
};
|
|
1628
1678
|
const out = [];
|
|
1629
1679
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -2385,7 +2435,7 @@ var ClaudeCodeLanguageModel = class {
|
|
|
2385
2435
|
}
|
|
2386
2436
|
async doGenerate(options) {
|
|
2387
2437
|
const warnings = [];
|
|
2388
|
-
const cwd = this.config.cwd
|
|
2438
|
+
const cwd = resolveSpawnCwd(this.config.cwd);
|
|
2389
2439
|
const scope = this.requestScope(options);
|
|
2390
2440
|
const affinity = this.sessionAffinity(options);
|
|
2391
2441
|
const sk = sessionKey(cwd, `${this.modelId}::${scope}::${affinity}`);
|
|
@@ -2695,7 +2745,7 @@ ${plan}
|
|
|
2695
2745
|
}
|
|
2696
2746
|
async doStream(options) {
|
|
2697
2747
|
const warnings = [];
|
|
2698
|
-
const cwd = this.config.cwd
|
|
2748
|
+
const cwd = resolveSpawnCwd(this.config.cwd);
|
|
2699
2749
|
const cliPath = this.config.cliPath;
|
|
2700
2750
|
const skipPermissions = this.config.skipPermissions !== false;
|
|
2701
2751
|
const scope = this.requestScope(options);
|
|
@@ -4188,10 +4238,6 @@ function cleanupOne(cacheRoot, ourDir) {
|
|
|
4188
4238
|
}
|
|
4189
4239
|
|
|
4190
4240
|
// src/index.ts
|
|
4191
|
-
var opencodeProjectDirectory;
|
|
4192
|
-
function isUsableDirectory(d) {
|
|
4193
|
-
return typeof d === "string" && d.length > 1 && d !== "/";
|
|
4194
|
-
}
|
|
4195
4241
|
function pickOpencodeDirectory(input) {
|
|
4196
4242
|
if (!input || typeof input !== "object") return void 0;
|
|
4197
4243
|
const ctx = input;
|
|
@@ -4329,7 +4375,6 @@ async function providerConfig(existing, providerID = PROVIDER_ID2, optionDefault
|
|
|
4329
4375
|
const mergedOptions = {
|
|
4330
4376
|
cliPath: "claude",
|
|
4331
4377
|
proxyTools: ["Bash", "Edit", "Write", "WebFetch"],
|
|
4332
|
-
...opencodeProjectDirectory ? { cwd: opencodeProjectDirectory } : {},
|
|
4333
4378
|
...optionDefaults,
|
|
4334
4379
|
...cleanProviderOptions(existing?.options),
|
|
4335
4380
|
providerID
|
|
@@ -4395,7 +4440,7 @@ var server = async (input) => {
|
|
|
4395
4440
|
if (input && typeof input === "object" && "client" in input) {
|
|
4396
4441
|
setOpencodeClient(input.client);
|
|
4397
4442
|
}
|
|
4398
|
-
|
|
4443
|
+
setOpencodeProjectDirectory(pickOpencodeDirectory(input));
|
|
4399
4444
|
return {
|
|
4400
4445
|
config: async (config) => {
|
|
4401
4446
|
config.provider ??= {};
|