Skip to content

fix: support hyphenated command names in __SPECKIT_COMMAND_<NAME>__ tokens - #4361

Open
minzzang144 wants to merge 3 commits into
github:mainfrom
minzzang144:fix/4198-command-ref-token-hyphen
Open

fix: support hyphenated command names in __SPECKIT_COMMAND_<NAME>__ tokens#4361
minzzang144 wants to merge 3 commits into
github:mainfrom
minzzang144:fix/4198-command-ref-token-hyphen

Conversation

@minzzang144

Copy link
Copy Markdown

Description

__SPECKIT_COMMAND_<NAME>__ tokens can't represent a hyphen in a command name, so referencing a hyphenated command (e.g. the bundled speckit.agent-context.update) silently resolves to the wrong path. This widens the character class in both resolve_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 updates extensions/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

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest (ran via .venv/bin/python -m pytest tests per the guidance in CONTRIBUTING.md/AGENTS.md to avoid resolving specify_cli to another checkout): 7145 passed. The 9 failures present are Python-parity template tests that also fail on main without this change, unrelated to this fix.
  • Tested with a sample project (if applicable): ran specify init --integration claude --script sh --non-interactive against this branch and confirmed the scaffolded project has no unresolved __SPECKIT_COMMAND tokens 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

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

This change was written with AI assistance (Claude Code). I reviewed the diff and ran the test suite myself before opening this PR.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants