@khalilgharbaoui/opencode-claude-code-plugin 0.4.20 → 0.4.21
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 +9 -0
- package/dist/index.js +22 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -440,6 +440,7 @@ plugin internals.
|
|
|
440
440
|
```bash
|
|
441
441
|
bun install
|
|
442
442
|
bun run typecheck # tsc --noEmit
|
|
443
|
+
bun run test # tsx --test (unit suite)
|
|
443
444
|
bun run build # tsup -> dist/
|
|
444
445
|
```
|
|
445
446
|
|
|
@@ -449,17 +450,25 @@ Source layout:
|
|
|
449
450
|
src/
|
|
450
451
|
index.ts # opencode plugin entry, config + provider hooks
|
|
451
452
|
models.ts # default models + variants
|
|
453
|
+
accounts.ts # multi-account expansion (per-account CLAUDE_CONFIG_DIR + wrapper script)
|
|
452
454
|
claude-code-language-model.ts # AI-SDK provider that drives `claude`
|
|
453
455
|
message-builder.ts # AI-SDK prompt → Claude CLI user message
|
|
456
|
+
tool-mapping.ts # Claude tool name ↔ opencode tool name mapping; internal-tool skip list
|
|
454
457
|
proxy-mcp.ts # in-process MCP server for proxied tools
|
|
458
|
+
proxy-broker.ts # pending proxy-call broker between proxy-mcp and opencode tool execution
|
|
455
459
|
mcp-bridge.ts # opencode → Claude --mcp-config translator
|
|
456
460
|
session-manager.ts # LRU cache of CLI subprocesses
|
|
457
461
|
cli-version.ts # detect Claude CLI version, gate optional flags
|
|
462
|
+
runtime-status.ts # runtime introspection of opencode (MCP status, tool registry)
|
|
458
463
|
logger.ts # DEBUG=opencode-claude-code stderr logger
|
|
464
|
+
tmp.ts # per-plugin temp directory helper
|
|
465
|
+
cleanup-stale.ts # remove legacy unscoped install from opencode's plugin cache
|
|
459
466
|
types.ts # public option types
|
|
460
467
|
opencode-types.ts # mirrored opencode types
|
|
461
468
|
```
|
|
462
469
|
|
|
470
|
+
For runtime gotchas, the v1.15.0 audit waterline, and the release flow, see [`AGENTS.md`](./AGENTS.md).
|
|
471
|
+
|
|
463
472
|
## Publishing (maintainers)
|
|
464
473
|
|
|
465
474
|
```bash
|
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;
|
|
@@ -2385,7 +2404,7 @@ var ClaudeCodeLanguageModel = class {
|
|
|
2385
2404
|
}
|
|
2386
2405
|
async doGenerate(options) {
|
|
2387
2406
|
const warnings = [];
|
|
2388
|
-
const cwd = this.config.cwd
|
|
2407
|
+
const cwd = resolveSpawnCwd(this.config.cwd);
|
|
2389
2408
|
const scope = this.requestScope(options);
|
|
2390
2409
|
const affinity = this.sessionAffinity(options);
|
|
2391
2410
|
const sk = sessionKey(cwd, `${this.modelId}::${scope}::${affinity}`);
|
|
@@ -2695,7 +2714,7 @@ ${plan}
|
|
|
2695
2714
|
}
|
|
2696
2715
|
async doStream(options) {
|
|
2697
2716
|
const warnings = [];
|
|
2698
|
-
const cwd = this.config.cwd
|
|
2717
|
+
const cwd = resolveSpawnCwd(this.config.cwd);
|
|
2699
2718
|
const cliPath = this.config.cliPath;
|
|
2700
2719
|
const skipPermissions = this.config.skipPermissions !== false;
|
|
2701
2720
|
const scope = this.requestScope(options);
|
|
@@ -4188,10 +4207,6 @@ function cleanupOne(cacheRoot, ourDir) {
|
|
|
4188
4207
|
}
|
|
4189
4208
|
|
|
4190
4209
|
// src/index.ts
|
|
4191
|
-
var opencodeProjectDirectory;
|
|
4192
|
-
function isUsableDirectory(d) {
|
|
4193
|
-
return typeof d === "string" && d.length > 1 && d !== "/";
|
|
4194
|
-
}
|
|
4195
4210
|
function pickOpencodeDirectory(input) {
|
|
4196
4211
|
if (!input || typeof input !== "object") return void 0;
|
|
4197
4212
|
const ctx = input;
|
|
@@ -4329,7 +4344,6 @@ async function providerConfig(existing, providerID = PROVIDER_ID2, optionDefault
|
|
|
4329
4344
|
const mergedOptions = {
|
|
4330
4345
|
cliPath: "claude",
|
|
4331
4346
|
proxyTools: ["Bash", "Edit", "Write", "WebFetch"],
|
|
4332
|
-
...opencodeProjectDirectory ? { cwd: opencodeProjectDirectory } : {},
|
|
4333
4347
|
...optionDefaults,
|
|
4334
4348
|
...cleanProviderOptions(existing?.options),
|
|
4335
4349
|
providerID
|
|
@@ -4395,7 +4409,7 @@ var server = async (input) => {
|
|
|
4395
4409
|
if (input && typeof input === "object" && "client" in input) {
|
|
4396
4410
|
setOpencodeClient(input.client);
|
|
4397
4411
|
}
|
|
4398
|
-
|
|
4412
|
+
setOpencodeProjectDirectory(pickOpencodeDirectory(input));
|
|
4399
4413
|
return {
|
|
4400
4414
|
config: async (config) => {
|
|
4401
4415
|
config.provider ??= {};
|