fix(schemas): honor canonical root selection - #1616
Conversation
📝 WalkthroughWalkthroughThe ChangesSchema root selection
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as schemas CLI
participant Resolver as resolveRootForCommand
participant Lister as listSchemasWithInfo
CLI->>Resolver: resolve root from store and project context
Resolver-->>CLI: resolved root or diagnostics
CLI->>Lister: list schemas from resolved root
Lister-->>CLI: schema results
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@skills/openspec-onboard/SKILL.md`:
- Line 14: Remove view from the shared store-scoped command list in the
generator source while retaining schemas, then regenerate the committed skill
artifacts. Apply the resulting change to skills/openspec-onboard/SKILL.md (line
14), skills/openspec-propose/SKILL.md (line 28),
skills/openspec-sync-specs/SKILL.md (line 16),
skills/openspec-update-change/SKILL.md (line 14), and
skills/openspec-verify-change/SKILL.md (line 14); all listed files require the
same generated update.
In `@src/commands/workflow/schemas.ts`:
- Around line 25-29: Update the resolveRootForCommand options in schemasCommand
to set allowImplicitRoot: true, enabling schema discovery without an OpenSpec
root while preserving strict handling of explicit store failures.
In `@test/commands/schemas.test.ts`:
- Around line 117-132: Strengthen the successful JSON assertions in the schemas
CLI test by validating the complete entry for store-only, including its
documented description, artifacts, and source fields and their expected values.
Keep the existing exit, stderr, inclusion, and exclusion assertions, and use the
parsed schema result from parseSchemas rather than only checking the name.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6e375e19-a242-4f60-b1cf-8b329573ab96
📒 Files selected for processing (29)
docs/agent-contract.mddocs/cli.mddocs/stores-beta/user-guide.mdopenspec/changes/fix-schemas-root-selection/.openspec.yamlopenspec/changes/fix-schemas-root-selection/design.mdopenspec/changes/fix-schemas-root-selection/proposal.mdopenspec/changes/fix-schemas-root-selection/specs/schema-resolution/spec.mdopenspec/changes/fix-schemas-root-selection/tasks.mdskills/openspec-apply-change/SKILL.mdskills/openspec-archive-change/SKILL.mdskills/openspec-bulk-archive-change/SKILL.mdskills/openspec-continue-change/SKILL.mdskills/openspec-explore/SKILL.mdskills/openspec-ff-change/SKILL.mdskills/openspec-new-change/SKILL.mdskills/openspec-onboard/SKILL.mdskills/openspec-propose/SKILL.mdskills/openspec-sync-specs/SKILL.mdskills/openspec-update-change/SKILL.mdskills/openspec-verify-change/SKILL.mdsrc/cli/index.tssrc/commands/workflow/schemas.tssrc/core/completions/command-registry.tssrc/core/templates/workflows/propose.tssrc/core/templates/workflows/store-selection.tstest/commands/schemas.test.tstest/core/completions/command-registry.test.tstest/core/templates/propose.test.tstest/core/templates/skill-templates-parity.test.ts
alfred-openspec
left a comment
There was a problem hiding this comment.
The root-selection implementation and tests are sound, but the edited Stores guide still says view has no --store support even though it already does. Remove view from that cwd-only sentence, then this is ready.
|
@alfred-openspec addressed: removed |
view already accepts --store <id> (registered in src/cli/index.ts), so listing it among the commands that act on the current directory only was incorrect. Remove it; templates and the deprecated noun forms remain. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
200198f to
cb4f468
Compare
|
Rebased onto current
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@skills/openspec-apply-change/SKILL.md`:
- Line 14: Update the store-selection guidance in the skill generator so --store
<id> is appended only after a registered standalone store is selected or an
existing command hint establishes it. Keep commands targeting the nearest local
openspec/ root unscoped, remove the blanket instruction that rewrites every
example, and regenerate SKILL.md from the updated generator.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e3fb1a71-0a65-4fcd-9d91-c949762294d1
📒 Files selected for processing (5)
docs/cli.mdskills/openspec-apply-change/SKILL.mdsrc/cli/index.tssrc/core/completions/command-registry.tstest/core/templates/skill-templates-parity.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/core/completions/command-registry.ts
- docs/cli.md
- src/cli/index.ts
- test/core/templates/skill-templates-parity.test.ts
| Implement tasks from an OpenSpec change. | ||
|
|
||
| **Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root. | ||
| **Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `schemas`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root. |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Keep --store <id> conditional.
The instruction to append --store <id> to every unscoped example conflicts with the local-root behavior described later on the same line. Agents can pass an unbound store identifier and fail workflows that do not use a registered standalone store.
Append the flag only after a registered standalone store is selected or a command hint establishes the store. Keep local-root examples unscoped. Update the skill generator and regenerate this file.
Based on learnings: generated workflow skills must use --store <id> conditionally and must keep default local-root examples free of an unbound placeholder.
🧰 Tools
🪛 LanguageTool
[style] ~14-~14: It’s more common nowadays to write this noun as one word.
Context: ...ec change. Store selection: If the user names a store (a store is a standalone OpenSp...
(RECOMMENDED_COMPOUNDS)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@skills/openspec-apply-change/SKILL.md` at line 14, Update the store-selection
guidance in the skill generator so --store <id> is appended only after a
registered standalone store is selected or an existing command hint establishes
it. Keep commands targeting the nearest local openspec/ root unscoped, remove
the blanket instruction that rewrites every example, and regenerate SKILL.md
from the updated generator.
Source: Learnings
alfred-openspec
left a comment
There was a problem hiding this comment.
The Stores guide now correctly removes view from the cwd-only, no-store list. Root-selection code remains unchanged from the reviewed head; fresh build, 59 schemas, completion, template, and parity tests, strict change validation, and the exact-head hosted matrix pass.
…ion-AI#1640) Six user-facing fixes merged after v1.8.0 without a changeset, so they would ship in v1.9.0 with no changelog entry and their authors uncredited. All are patch fixes; the release target stays at 1.9.0. Covers: Fission-AI#1637, Fission-AI#1607, Fission-AI#1632, Fission-AI#1616, Fission-AI#1612, Fission-AI#1523. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Summary
openspec schemasthrough the canonical OpenSpec root-selection precedence.--store <id>and the standard hidden--store-pathrejection path while preserving successful human output and the bare JSON array.Root cause
schemasCommand()always read schemas fromprocess.cwd(), and the command did not expose--store. As a result, schema discovery ignored an explicitly selected registered store and could disagree with the canonical root chosen by the rest of the workflow.Impact
Schema discovery now follows the same authoritative root as other root-scoped commands. Existing successful output shapes remain compatible; ambiguous registered-store environments fail closed with actionable diagnostics instead of silently reading the wrong directory.
Validation
pnpm run lintpnpm run buildpnpm test— 3,867 tests passedpnpm exec openspec validate fix-schemas-root-selection --strictgit diff --checkWindows/pwsh path behavior, including the store path containing spaces, remains gated by the repository CI matrix.
AI disclosure
Generated and verified with Codex using
gpt-5.6-solat max reasoning effort.Summary by CodeRabbit
New Features
openspec schemasnow supports--store <id>and standard project/store root selection.Bug Fixes
Documentation
Tests