feat(stores): set one default store for every repo on your machine#1363
feat(stores): set one default store for every repo on your machine#1363clay-good wants to merge 1 commit into
Conversation
Adds a machine-level `defaultStore` to the global config. When no --store flag, local planning root, or project-level `store:` pointer resolves, root resolution now consults `defaultStore` before erroring — so users who plan many code repos into one store can set it once instead of editing every repo's openspec/config.yaml. Purely additive: existing precedence (--store > local root > project pointer) is unchanged; the fallback only replaces the failure path. A stale or unregistered defaultStore degrades to the existing error, reshaped to point at clearing the global default. Closes #1359 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughAdds ChangesGlobal default store fallback
Estimated code review effort: 3 (Moderate) | ~20 minutes ### Sequence Diagram(s) sequenceDiagram
participant Command
participant resolveOpenSpecRoot
participant GlobalConfig
participant StoreRegistry
Command->>resolveOpenSpecRoot: resolve without explicit store
resolveOpenSpecRoot->>GlobalConfig: read defaultStore
GlobalConfig-->>resolveOpenSpecRoot: store id
resolveOpenSpecRoot->>StoreRegistry: resolve default store
StoreRegistry-->>resolveOpenSpecRoot: root or stale-store error
resolveOpenSpecRoot-->>Command: selected root or guidance
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying openspec-docs with
|
| Latest commit: |
35c07af
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3f0b2644.openspec-docs.pages.dev |
| Branch Preview URL: | https://feat-global-default-store.openspec-docs.pages.dev |
Closes #1359.
What was missing
Stores let many code repos share one planning repo, but there was no machine-level default. To use a store without typing
--storeon every command, you had to addstore: <id>to every repo'sopenspec/config.yaml. No global equivalent existed.What it does
Adds
defaultStoreto the global config. Set it once:openspec config set defaultStore team-plansNow any command run outside a planning root — with no
--storeand no project pointer — resolves to that store. It's the last step in root resolution, so nothing about precedence changes:Purely additive:
--store, a local root, and a projectstore:pointer all still win. Existing users see no change unless they opt in. A stale or unregistereddefaultStoredegrades to the existing error, reshaped to say how to fix or clear it.Proof it works
Real output from the built CLI (
bin/openspec.js) against a registeredteam-plansstore, run from a scratch dir with no local root:Before — no default set:
After
openspec config set defaultStore team-plans:Stale default (unregistered id):
config get/unset defaultStoreround-trip; unsetting reverts to the selection-hint error.Tests
test/core/root-selection.test.ts— 6 new cases: resolves the default; local root, project pointer, and--storeeach win over it; stale-default degrade error; falls through to the hint when unset. Harness now pinsXDG_CONFIG_HOMEso no test reads the developer's real config.test/commands/config.test.ts—set/get/unset defaultStoreround-trip + key validation (acceptsdefaultStore, rejects nested keys).Full suite green except the 17 pre-existing environment-only
zsh-installerfailures (oh-my-zsh; unaffected by this change).Scope
config-schema.ts(schema field + known key),global-config.ts(interface field),root-selection.ts(fallback step + degrade helper), docs (stores user guide + cli.md). No changes to store registration, metadata, or existing resolution precedence.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
defaultStoresetting for OpenSpec.Bug Fixes
Documentation