fix(validate): allow numeric-prefixed change names - #1435
Conversation
`validateChangeName` required a leading letter, so `openspec new change 100-add-feature` or `00001-add-auth` failed with "Change name must start with a letter". This contradicted the rest of OpenSpec: the shared kebab-id grammar in src/core/id.ts (store ids, workset names, change metadata ids) already allows a leading digit, and archive explicitly supports `YYYY-MM-DD-` prefixed change names as a convention (#1309). Reuse the canonical `isKebabId` grammar for change names so numeric prefixes work, keeping the tailored error messages for the other failure cases. Fully backward-compatible: every previously valid name still validates (`[a-z]` ⊂ `[a-z0-9]`), and consecutive/leading/trailing hyphens, uppercase, spaces, underscores and other characters are still rejected. Closes #850 Closes #1169 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 Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesNumeric-prefixed change names
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
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 `@test/utils/change-utils.test.ts`:
- Around line 44-47: Update the test case around validateChangeName to use an
all-numeric-and-hyphen fixture such as 101-01, preserving the expected valid
result; ensure the test title accurately describes that coverage.
🪄 Autofix (Beta)
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: 797bd081-bc7a-4e37-888a-e1dd97f34d48
📒 Files selected for processing (2)
src/utils/change-utils.tstest/utils/change-utils.test.ts
Address review of the numeric-prefix change: - add the required changeset (patch) - fix docs/cli.md which still said names "cannot start with a number" and advised prefixing ticket IDs with a word (website copy regenerates from this file at build time) - pin the all-numeric case (`100`) so accepting it is a conscious decision Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deploying openspec-docs with
|
| Latest commit: |
37f7217
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fc186505.openspec-docs.pages.dev |
| Branch Preview URL: | https://fix-allow-numeric-prefixed-c.openspec-docs.pages.dev |
CodeRabbit noted the 101-01-fix-auth fixture contains letters, so the old title 'all digits and hyphens' was inaccurate. Rename it to describe the tiered numeric-prefix case (#850); the dedicated all-numeric case is the separate '100' test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Merge-coordination note for whoever lands this (no action needed on the code itself): Two open PRs edit the same
Simplest path is to merge this small PR first. |
alfred-openspec
left a comment
There was a problem hiding this comment.
Clean, backward-compatible validator alignment. I verified numeric-prefixed changes through create, status, list, and archive, and the full 2,239-test suite passes at head 37f7217.
Status: LGTM — surgical, backward-compatible, all 2,238 tests pass.
What was wrong
openspec new change 100-add-feature(or00001-add-auth) failed with:validateChangeNamerequired change names to begin with a letter. But the rest of OpenSpec already treats a leading digit as legitimate:src/core/id.ts— shared by store ids, workset names, and change metadata ids — allows a leading digit (/^[a-z0-9]+(?:-[a-z0-9]+)*$/).YYYY-MM-DD--prefixed change names as "a common authoring convention" and avoids double-dating them (archive prepends today's date without detecting an existing date prefix (name gets double-dated) #1309).So OpenSpec shipped archive support for a naming convention its own creation gate refused to create. Users wanting ordering/tiering (
100-audit,200-implement,00001-add-auth) had to fork the CLI or create directories by hand.How it was fixed
validateChangeNamenow reuses the canonicalisKebabIdgrammar instead of its own stricter regex, and the now-unreachable "must start with a letter" branch is removed. The tailored error messages for every other case (uppercase, spaces, underscores, leading/trailing hyphens, consecutive hyphens, invalid characters) are unchanged.One import + one predicate swap + dead-branch removal — no new options, no schema/config surface, no workflow changes.
Proof it works
Before,
100-add-featureerrored. After (real CLI output):Backward compatibility is guaranteed:
[a-z]⊂[a-z0-9], so every previously valid name still validates. Added tests cover100-add-feature,00001-add-auth,101-01-fix-auth, and an end-to-endcreateChangefor a numeric-prefixed directory. Full suite: 2,238 passing.Notes
--number/--auto-numberflag suggested in feat(validation): allow numeric-prefixed change names for ordered/tiered workflows #850 and Support numbered change names (NNNNN-slug) for sequencing #1169) is intentionally out of scope — this PR only removes the validation barrier so wrapper tools and users can name changes as they choose. A dedicated flag can follow separately.Closes #850
Closes #1169
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
openspec new changenow accepts change names that begin with digits (including zero-padded and digit-only formats).Tests
Documentation
Bug Fixes