fix(sdk): preserve nested keys from globalDefaults in configNewProject (#2745)
When building nested config sections (workflow, git, hooks, agent_skills, features), the deep merge was missing globalDefaults for those sections, causing user values from ~/.gsd/defaults.json to be silently dropped. Added globalDefaults spread at the correct precedence level (hardcoded < globalDefaults < userChoices) for all five nested keys, and added three test cases verifying the merge works end-to-end via HOME env var override. Closes #2673 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -406,22 +406,27 @@ export const configNewProject: QueryHandler = async (args, projectDir, workstrea
|
||||
...userChoices,
|
||||
git: {
|
||||
...(defaults.git as Record<string, unknown>),
|
||||
...((globalDefaults.git as Record<string, unknown>) || {}),
|
||||
...((userChoices.git as Record<string, unknown>) || {}),
|
||||
},
|
||||
workflow: {
|
||||
...(defaults.workflow as Record<string, unknown>),
|
||||
...((globalDefaults.workflow as Record<string, unknown>) || {}),
|
||||
...((userChoices.workflow as Record<string, unknown>) || {}),
|
||||
},
|
||||
hooks: {
|
||||
...(defaults.hooks as Record<string, unknown>),
|
||||
...((globalDefaults.hooks as Record<string, unknown>) || {}),
|
||||
...((userChoices.hooks as Record<string, unknown>) || {}),
|
||||
},
|
||||
agent_skills: {
|
||||
...((defaults.agent_skills as Record<string, unknown>) || {}),
|
||||
...((globalDefaults.agent_skills as Record<string, unknown>) || {}),
|
||||
...((userChoices.agent_skills as Record<string, unknown>) || {}),
|
||||
},
|
||||
features: {
|
||||
...((defaults.features as Record<string, unknown>) || {}),
|
||||
...((globalDefaults.features as Record<string, unknown>) || {}),
|
||||
...((userChoices.features as Record<string, unknown>) || {}),
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user