loadConfig() falls back to ~/.gsd/defaults.json when no project config exists#1699
loadConfig() falls back to ~/.gsd/defaults.json when no project config exists#1699rodzved wants to merge 2 commits intogsd-build:mainfrom
Conversation
|
Update: Refactored the Before: Each config key was listed explicitly in the return object (29 lines), meaning any new key added to After: The fallback iterates over All 2159 tests still pass. |
|
This PR needs a rebase onto CI checks are also missing — likely due to the stale base. |
… config exists Closes gsd-build#1683
Avoids maintenance trap where new config keys added to the try block would need to be duplicated in the catch fallback path.
994d675 to
f7878f4
Compare
|
Rebased onto main to pick up #1708 ( |
Enhancement PR
Linked Issue
Closes #1683
What this enhancement improves
loadConfig()incore.cjs— the central config resolution used by all GSD commands.Before / After
Before:
When
.planning/config.jsonis missing,loadConfig()returns hardcoded defaults.~/.gsd/defaults.jsonis never consulted. Pre-project commands likemap-codebaseignore user globals entirely.After:
When
.planning/config.jsonis missing,loadConfig()reads~/.gsd/defaults.jsonas an intermediate fallback before falling back to hardcoded defaults.How it was implemented
get-shit-done/bin/lib/core.cjs— In thecatchblock ofloadConfig(), added~/.gsd/defaults.jsonreading with the same merge pattern used bybuildNewProjectConfig()inconfig.cjs. Supports both flat keys (model_profile) and nested keys (git.branching_strategy,workflow.research). Includesdepth→granularitymigration.docs/CONFIGURATION.md— Updated Global Defaults section to clarifydefaults.jsonapplies to all commands, not just/gsd-new-project. Added merge order documentation.tests/core.test.cjs— Added 3 new tests: defaults.json fallback, no-defaults.json fallback, nested key support. Sandboxed HOME inloadConfigdescribe block to isolate from developer's real~/.gsd/defaults.json.tests/commands.test.cjs— Sandboxed HOME inresolve-modeldescribe block for test isolation.tests/config.test.cjs��� Sandboxed HOME forconfig-ensure-sectiontest.Testing
How I verified the enhancement works
defaults.jsonvalues override hardcoded defaults when noconfig.jsonexistsconfig.jsonnordefaults.jsonexistsgit.*,workflow.*) are correctly resolved fromdefaults.jsonPlatforms tested
Runtimes tested
Scope confirmation
Checklist
Closes #NNN— PR will be auto-closed if missingapproved-enhancementlabel — PR will be closed if missingnpm test)Breaking changes
None. The merge order is additive — existing
.planning/config.jsonfiles take full precedence as before. Only the "no config.json exists" path changes, and that path currently returns hardcoded defaults which have no user-facing contract.