fix: support hyphenated command names in __SPECKIT_COMMAND_<NAME>__ tokens - #4361
Open
minzzang144 wants to merge 3 commits into
Open
fix: support hyphenated command names in __SPECKIT_COMMAND_<NAME>__ tokens#4361minzzang144 wants to merge 3 commits into
minzzang144 wants to merge 3 commits into
Conversation
Widens the uppercase command-ref token's character class from
[A-Z0-9_] to [A-Z0-9_-] in both resolve_command_refs() and the
extension-skills resolver, so a hyphenated command name (e.g.
speckit.agent-context.update) round-trips without a second token
grammar. Decode logic is unchanged since replace("_", separator)
already leaves literal hyphens untouched.
Implements the "Option 2" direction agreed with @mnriem in the
review discussion on github#4204, as an alternative to that PR's verbatim
__SPECKIT_COMMAND(...)__ form.
Fixes github#4198
This change was implemented with AI assistance (Claude Code); I
reviewed the diff and ran the full test suite myself before opening
this PR.
Adds cases for a hyphen adjacent to a digit, multiple hyphens within one segment, and more than two dotted segments, confirming the widened character class has no arbitrary limit on segment count.
STEP-2/RUN and MULTI-WORD-SEGMENT read unambiguously as synthetic test data, instead of awkwardly extending the real agent-context extension's command name with made-up suffixes.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for literal hyphens in command-reference tokens across command and extension-skill rendering.
Changes:
- Expands both token resolvers to accept hyphens.
- Updates extension-author documentation.
- Adds unit and integration-style regression tests.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/integrations/base.py |
Expands the shared token grammar. |
src/specify_cli/extensions/__init__.py |
Expands the extension-skills token grammar. |
tests/integrations/test_base.py |
Tests hyphenated token variants. |
tests/test_extensions.py |
Tests skill-format command registration. |
extensions/EXTENSION-DEVELOPMENT-GUIDE.md |
Documents hyphen encoding and skills behavior. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Balanced
|
|
||
| return re.sub( | ||
| r"__SPECKIT_COMMAND_([A-Z][A-Z0-9_]*)__", _replacement, body | ||
| r"__SPECKIT_COMMAND_([A-Z][A-Z0-9_-]*)__", _replacement, body |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
__SPECKIT_COMMAND_<NAME>__tokens can't represent a hyphen in a command name, so referencing a hyphenated command (e.g. the bundledspeckit.agent-context.update) silently resolves to the wrong path. This widens the character class in bothresolve_command_refs()(src/specify_cli/integrations/base.py) and the extension-skills resolver (src/specify_cli/extensions/__init__.py) from[A-Z][A-Z0-9_]*to[A-Z][A-Z0-9_-]*. No decode-logic change is needed —.replace("_", separator)already leaves a literal hyphen untouched. Also updatesextensions/EXTENSION-DEVELOPMENT-GUIDE.md's "Referencing other commands" section, which still stated hyphens couldn't be represented and had a stale skills-mode limitation note.Fixes #4198, Fixes #4328
Testing
uv run specify --helpuv sync && uv run pytest(ran via.venv/bin/python -m pytest testsper the guidance in CONTRIBUTING.md/AGENTS.md to avoid resolvingspecify_clito another checkout): 7145 passed. The 9 failures present are Python-parity template tests that also fail onmainwithout this change, unrelated to this fix.specify init --integration claude --script sh --non-interactiveagainst this branch and confirmed the scaffolded project has no unresolved__SPECKIT_COMMANDtokens left in it.Added 9 new unit test cases covering hyphen + each separator style, multiple hyphens within one segment, a hyphen adjacent to a digit, and an unlimited number of dotted segments.
AI Disclosure
This change was written with AI assistance (Claude Code). I reviewed the diff and ran the test suite myself before opening this PR.