From 5b9b6eb0b8d89ec6879c1df961c8ef5116cc5a3d Mon Sep 17 00:00:00 2001 From: MoerAI Date: Fri, 27 Mar 2026 21:00:01 +0900 Subject: [PATCH 1/2] fix(config): apply git_master defaults when section is missing (fixes #2040) --- src/config/schema.test.ts | 39 ++++++++++++++++++++++ src/config/schema/oh-my-opencode-config.ts | 6 +++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/config/schema.test.ts b/src/config/schema.test.ts index 7f4ad615f..d36e277d9 100644 --- a/src/config/schema.test.ts +++ b/src/config/schema.test.ts @@ -969,6 +969,45 @@ describe("GitMasterConfigSchema", () => { }) }) +describe("OhMyOpenCodeConfigSchema - git_master defaults (#2040)", () => { + test("git_master defaults are applied when section is missing from config", () => { + //#given + const config = {} + + //#when + const result = OhMyOpenCodeConfigSchema.safeParse(config) + + //#then + expect(result.success).toBe(true) + if (result.success) { + expect(result.data.git_master).toBeDefined() + expect(result.data.git_master.commit_footer).toBe(true) + expect(result.data.git_master.include_co_authored_by).toBe(true) + expect(result.data.git_master.git_env_prefix).toBe("GIT_MASTER=1") + } + }) + + test("git_master respects explicit false values", () => { + //#given + const config = { + git_master: { + commit_footer: false, + include_co_authored_by: false, + }, + } + + //#when + const result = OhMyOpenCodeConfigSchema.safeParse(config) + + //#then + expect(result.success).toBe(true) + if (result.success) { + expect(result.data.git_master.commit_footer).toBe(false) + expect(result.data.git_master.include_co_authored_by).toBe(false) + } + }) +}) + describe("skills schema", () => { test("accepts skills.sources configuration", () => { //#given diff --git a/src/config/schema/oh-my-opencode-config.ts b/src/config/schema/oh-my-opencode-config.ts index 434bfe7ee..5db7b0559 100644 --- a/src/config/schema/oh-my-opencode-config.ts +++ b/src/config/schema/oh-my-opencode-config.ts @@ -60,7 +60,11 @@ export const OhMyOpenCodeConfigSchema = z.object({ model_capabilities: ModelCapabilitiesConfigSchema.optional(), openclaw: OpenClawConfigSchema.optional(), babysitting: BabysittingConfigSchema.optional(), - git_master: GitMasterConfigSchema.optional(), + git_master: GitMasterConfigSchema.default({ + commit_footer: true, + include_co_authored_by: true, + git_env_prefix: "GIT_MASTER=1", + }), browser_automation_engine: BrowserAutomationConfigSchema.optional(), websearch: WebsearchConfigSchema.optional(), tmux: TmuxConfigSchema.optional(), From 2b2b2808958f42a894dc439fa453bcdb6f5cfae2 Mon Sep 17 00:00:00 2001 From: MoerAI Date: Fri, 27 Mar 2026 21:30:56 +0900 Subject: [PATCH 2/2] fix: apply Zod defaults to empty config fallback --- src/plugin-config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugin-config.ts b/src/plugin-config.ts index cf6f2f999..fd41e24c9 100644 --- a/src/plugin-config.ts +++ b/src/plugin-config.ts @@ -188,9 +188,9 @@ export function loadPluginConfig( migrateLegacyConfigFile(projectDetected.path); } - // Load user config first (base) + // Load user config first (base). Parse empty config through Zod to apply field defaults. let config: OhMyOpenCodeConfig = - loadConfigFromPath(userConfigPath, ctx) ?? {}; + loadConfigFromPath(userConfigPath, ctx) ?? OhMyOpenCodeConfigSchema.parse({}); // Override with project config const projectConfig = loadConfigFromPath(projectConfigPath, ctx);