diff --git a/packages/opencode/src/command/index.ts b/packages/opencode/src/command/index.ts index 3da260ea645b..c91a9935e37a 100644 --- a/packages/opencode/src/command/index.ts +++ b/packages/opencode/src/command/index.ts @@ -95,6 +95,7 @@ export const layer = Layer.effect( } for (const [name, command] of Object.entries(cfg.command ?? {})) { + if (!command.template) continue commands[name] = { name, agent: command.agent, @@ -102,7 +103,7 @@ export const layer = Layer.effect( description: command.description, source: "command", get template() { - return command.template + return command.template! }, subtask: command.subtask, hints: hints(command.template), diff --git a/packages/opencode/src/config/command.ts b/packages/opencode/src/config/command.ts index fa64aef8c3bb..bd1300237fda 100644 --- a/packages/opencode/src/config/command.ts +++ b/packages/opencode/src/config/command.ts @@ -13,7 +13,7 @@ import { ConfigModelID } from "./model-id" const log = Log.create({ service: "config" }) export const Info = Schema.Struct({ - template: Schema.String, + template: Schema.optional(Schema.String), description: Schema.optional(Schema.String), agent: Schema.optional(Schema.String), model: Schema.optional(ConfigModelID), diff --git a/packages/opencode/test/config/config.test.ts b/packages/opencode/test/config/config.test.ts index 90e78efcdbaa..2ce828ccabfe 100644 --- a/packages/opencode/test/config/config.test.ts +++ b/packages/opencode/test/config/config.test.ts @@ -727,6 +727,30 @@ test("handles command configuration", async () => { }) }) +test("accepts partial command override without template", async () => { + await using tmp = await tmpdir({ + init: async (dir) => { + await writeConfig(dir, { + $schema: "https://opencode.ai/config.json", + command: { + commit: { + model: "anthropic/claude-4-6-sonnet", + }, + }, + }) + }, + }) + await WithInstance.provide({ + directory: tmp.path, + fn: async () => { + const config = await load() + expect(config.command?.["commit"]).toEqual({ + model: "anthropic/claude-4-6-sonnet", + }) + }, + }) +}) + test("migrates autoshare to share field", async () => { await using tmp = await tmpdir({ init: async (dir) => {