Skip to content

Commit 6d52344

Browse files
saphidclaude
andcommitted
fix(opencode): nested custom commands like /git/commit run as commands
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 5b9731c commit 6d52344

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,15 +2240,15 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
22402240
// session.command returns 204 without an inbox id; the stream drops before session.inbox.enqueued provides it.
22412241
const { runtime, thread } = yield* resumed([
22422242
out("command.list", "<any>"),
2243-
reply("command.list", { location: { directory: WORK }, data: [{ name: "hello" }] }),
2243+
reply("command.list", { location: { directory: WORK }, data: [{ name: "git/hello" }] }),
22442244
out("message.list", { sessionID: SESSION, order: "desc", limit: "1" }),
22452245
reply("message.list", {
22462246
data: [
22472247
{ id: "msg_idle_before", time: { created: 1 }, type: "idle", outcome: "succeeded" },
22482248
],
22492249
cursor: {},
22502250
}),
2251-
out("session.command", { sessionID: SESSION, name: "hello", text: "WORLD" }),
2251+
out("session.command", { sessionID: SESSION, name: "git/hello", text: "WORLD" }),
22522252
reply("session.command", null),
22532253
{ type: "runtime_exit", status: "success" } as const,
22542254
out("event.subscribe"),
@@ -2285,7 +2285,7 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
22852285
);
22862286
yield* runtime.startTurn({
22872287
...turnInput(thread),
2288-
message: { ...turnInput(thread).message, text: "/hello WORLD" },
2288+
message: { ...turnInput(thread).message, text: "/git/hello WORLD" },
22892289
});
22902290
const collected = yield* Fiber.join(events);
22912291
const texts = collected.flatMap((event) =>

‎packages/provider-opencode/src/server/adapter.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ describe("OpenCodeAdapterV2", () => {
13631363
return { stream: nativeEvents.stream };
13641364
},
13651365
},
1366-
command: { list: async () => ({ data: [{ name: "review" }] }) },
1366+
command: { list: async () => ({ data: [{ name: "git/review" }] }) },
13671367
session: {
13681368
create: async () => ({ data: { id: sessionId, time: { created: 1, updated: 1 } } }),
13691369
command: async (input: {
@@ -1382,9 +1382,9 @@ describe("OpenCodeAdapterV2", () => {
13821382
},
13831383
},
13841384
});
1385-
const start = yield* harness.startTurn("/review staged changes").pipe(Effect.forkScoped);
1385+
const start = yield* harness.startTurn("/git/review staged changes").pipe(Effect.forkScoped);
13861386
const call = yield* Queue.take(calls);
1387-
assert.equal(call.command, "review");
1387+
assert.equal(call.command, "git/review");
13881388
assert.equal(call.arguments, "staged changes");
13891389
assert.equal(call.model, "anthropic/claude-sonnet");
13901390
yield* Effect.promise(() =>

‎packages/provider-opencode/src/server/adapter.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2977,7 +2977,7 @@ export const makeOpenCodeAdapterV2 = Effect.fn("makeOpenCodeAdapterV2")(function
29772977
.map((part) => part.text)
29782978
.join("\n")
29792979
.trim();
2980-
const match = text?.match(/^\/([^\s/]+)(?:\s+([\s\S]*))?$/);
2980+
const match = text?.match(/^\/(\S+)(?:\s+([\s\S]*))?$/);
29812981
const command = match
29822982
? (yield* OpenCodeRuntime.loadOpenCodeCommands(client).pipe(
29832983
Effect.timeout("10 seconds"),

‎packages/provider-opencode/src/server/v2/adapter.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ const agentFor = (input: ProviderAdapter.ProviderAdapterV2TurnInput) =>
626626
input.runtimePolicy.interactionMode === "plan" ? "plan" : "build";
627627

628628
const commandOf = (text: string) => {
629-
const match = /^\/([^\s/]+)(?:\s+([\s\S]*))?$/.exec(text.trim());
629+
const match = /^\/(\S+)(?:\s+([\s\S]*))?$/.exec(text.trim());
630630
return match === null ? undefined : { name: match[1]!, text: match[2] ?? "" };
631631
};
632632

0 commit comments

Comments
 (0)