GeezerVison is showing github.com — [bug-fix] Fix command-token-hyphen-gap: add verbatim token form for hyphenated command names by github-actions[bot] · Pull Request #4204 · github/spec-kit
Conversation
Bug fix — command-token-hyphen-gap
Proposed fix for issue #4198, applying the remediation from the bug assessment.
Verdict: Valid · Severity: medium
Summary
Extends resolve_command_refs() with a new verbatim token form __SPECKIT_COMMAND(speckit.agent-context.update)__ that carries the command ID verbatim, resolving correctly for both . and - invoke separators. The existing uppercase form is unchanged.
Changes
| File |
Change |
Notes |
src/specify_cli/integrations/base.py |
modified |
resolve_command_refs() now handles both the existing uppercase form and the new verbatim form via a combined regex; updated docstring |
tests/integrations/test_base.py |
added tests |
7 new test cases covering verbatim form with ./- separators, custom prefix, mixed usage, and an explicit regression guard for the unchanged uppercase form |
Tests Added or Updated
TestResolveCommandRefs::test_verbatim_dot_separator_with_hyphen — verbatim form + . separator → /speckit.agent-context.update
TestResolveCommandRefs::test_verbatim_hyphen_separator_with_hyphen — verbatim form + - separator → /speckit-agent-context-update
TestResolveCommandRefs::test_verbatim_dollar_prefix — verbatim form with $ prefix
TestResolveCommandRefs::test_verbatim_simple_command_no_hyphens — verbatim form also works for non-hyphenated commands
TestResolveCommandRefs::test_verbatim_and_uppercase_mixed — both forms coexist in the same string
TestResolveCommandRefs::test_uppercase_form_unaffected_by_verbatim_support — regression guard: uppercase form behavior is unchanged
Local Verification
- Commands run:
python3 -c "..." (inline test of resolve_command_refs logic) → all 7 cases passed
- No project venv/pytest available in this runner environment; logic was verified by extracting and running the function directly.
Deviations from Assessment
The preferred remediation called for the verbatim form to have the invoke_separator rewrite applied "only to the existing uppercase form". Implemented as: for the verbatim form, . separators in the command ID are replaced with the separator, and hyphens are kept as-is (they naturally collapse to the separator when separator is -). This gives the correct result for both separator styles and is consistent with what the assessment described.
Callers (extensions/__init__.py, presets/__init__.py, agents.py, shared_infra.py) were not modified — they pass content through resolve_command_refs() unchanged, so the new token form will work anywhere the existing one does.
Risks & Review Notes
- Backward compatibility: the existing
__SPECKIT_COMMAND_<NAME>__ form is unaffected; the two regex alternatives are disjoint.
- Bundled
agent-context extension: speckit.agent-context.update is the only hyphenated bundled command identified; no existing token in core_pack currently references it via __SPECKIT_COMMAND__ syntax, so there is no migration needed for bundled content.
- Documentation: authoring guides that document the uppercase token form should eventually be updated to mention the verbatim form as the correct choice when hyphens are present (tracked in the assessment as a separate improvement).
Refs #4198 · cc @minzzang144
Generated by 🛠️ Fix Bug from Labeled Issue for issue #4198 · 388.7 AIC · ⌖ 17.1 AIC · ⊞ 36.4K · ◷
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…command names
Apply the remediation from the bug assessment on issue #4198.
Extends resolve_command_refs() with a new verbatim token form
__SPECKIT_COMMAND(speckit.agent-context.update)__ that carries the
command ID verbatim. Dots are replaced by the invoke_separator; hyphens
within segments are preserved (and collapse naturally to the separator
when separator is '-'). The existing uppercase __SPECKIT_COMMAND_NAME__
form is unchanged.
Refs #4198
Assisted-by: GitHub Copilot (model: claude-sonnet-4.6, autonomous)
Co-authored-by: Copilot <[email protected]>
PR #4204 added the verbatim `__SPECKIT_COMMAND(...)__` token form to the
central `resolve_command_refs()` (used for command-file agents and presets),
but the parallel resolver in `_register_extension_skills()` — the sole
writer of extension SKILL.md content when the active integration is in
skills mode — still matched only the uppercase form. A verbatim token
therefore leaked into SKILL.md as a raw literal.
Teach that resolver the verbatim form as well, carrying the command id
verbatim so hyphenated names (e.g. `speckit.agent-context.update`) survive
intact. Adds regression tests exercising `_register_extension_skills`
directly for both dollar- and slash-skills agents.
Assisted-by: GitHub Copilot (model: Claude Opus 4.8, autonomous)
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: e7f0535c-26ca-4f4a-af95-d6b240dfd0e4
|
Pushed dcb5f36 to close a gap this PR leaves open.
This PR wires the new verbatim __SPECKIT_COMMAND(...)__ token into the central resolve_command_refs(), which covers command-file agents and presets. But extension command bodies rendered as skills go through a separate resolver in ExtensionManager._register_extension_skills() — and that resolver is the sole writer of extension SKILL.md content when the active integration is in skills mode (_active_command_registration_scope() returns an empty set for command-backed integrations in skills mode, so the registrar writes nothing). That resolver still matched only the uppercase form, so a verbatim token leaked into SKILL.md as a raw literal.
The commit teaches _register_extension_skills() the verbatim form too (same combined regex as resolve_command_refs), carrying the command id verbatim so hyphenated names like speckit.agent-context.update survive. Added two regression tests that drive _register_extension_skills directly for a dollar-skills agent (codex) and a slash-skills agent (claude); both fail without the source change. Full test_extensions.py, test_presets.py, and integrations/test_base.py suites pass (1225).
Posted on behalf of @mnriem by GitHub Copilot (model: Claude Opus 4.8), acting autonomously.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds a verbatim command-reference token to correctly support hyphenated command IDs across integration invocation styles.
Changes:
- Supports
__SPECKIT_COMMAND(...)__ tokens.
- Handles extension skill registration paths.
- Adds unit and integration regression tests.
Show a summary per file
| File |
Description |
src/specify_cli/integrations/base.py |
Implements verbatim token resolution. |
src/specify_cli/extensions/__init__.py |
Resolves verbatim tokens in extension skills. |
tests/integrations/test_base.py |
Tests resolver behavior and compatibility. |
tests/test_extensions.py |
Tests Codex and Claude skill rendering. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Balanced
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
+ "speckit"
|
|
|
+ separator
|
|
|
+ m.group(1).lower().replace("_", separator),
|
|
|
r"__SPECKIT_COMMAND_([A-Z][A-Z0-9_]*)__|__SPECKIT_COMMAND\(([^)]+)\)__",
|
Comment on lines
+1610
to
+1611
|
|
r"__SPECKIT_COMMAND_([A-Z][A-Z0-9_]*)__"
|
|
|
r"|__SPECKIT_COMMAND\(([^)]+)\)__",
|
|
Please address Copilot feedback
|
minzzang144 reacted with rocket emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@mnriem
Thanks for picking this up so fast, and for catching the skills-mode gap, @mnriem — I hadn't realized that labeling the issue would kick off an implementation + PR automatically. The ideas in the original issue were meant as loose sketches for someone with the actual context to sanity-check, not concrete proposals, so now that I see where they landed, I'd like to revisit one more direction before this settles.
Option 1 — the currently implemented direction: the verbatim form (__SPECKIT_COMMAND(speckit.agent-context.update)__)
- 👍 You can copy-paste the command id verbatim, no encoding rule to remember
- 👍 The code change is localized (one new branch added alongside the existing one)
- 👎 It introduces a second grammar with a completely different notation from the uppercase form (uppercase snake_case vs. a lowercase dotted-hyphenated id wrapped in parens) — now there are two rules to learn instead of one
- 👎 The capture is
[^)]+, which is too permissive — malformed input (spaces, newlines, arbitrary text) passes through silently and gets turned into an invalid invocation with no warning. That's exactly the "silent failure" mode the original issue was trying to prevent, just relocated to the new form (needs a separate validation step)
- 👎 The
speckit. prefix has to be repeated inside the parens, which is redundant since the token name already says COMMAND
Option 2 — a direction I'd like to propose: widen the uppercase form's character class to allow the literal hyphen
Command names are constrained to speckit.<segment>(.<segment>)*, where each segment is [a-z0-9-]+ (see EXTENSION_COMMAND_NAME_PATTERN) — a segment can never contain an underscore. So instead of introducing a new grammar, the existing regex's character class can simply be widened:
# original, pre-PR
r"__SPECKIT_COMMAND_([A-Z][A-Z0-9_]*)__"
# proposed
r"__SPECKIT_COMMAND_([A-Z][A-Z0-9_-]*)__"
The decode logic doesn't even need to change — .replace("_", separator) already leaves - untouched. This works regardless of how many hyphens appear per segment, or where they fall (start, middle, end):
__SPECKIT_COMMAND_AGENT-CONTEXT_UPDATE__ → speckit.agent-context.update
__SPECKIT_COMMAND_CODE-REVIEW_REQUEST-CHANGES__ → speckit.code-review.request-changes
- 👍 No new grammar — the notation stays singular
- 👍 The narrow character class filters out malformed input for free, solving Option 1's silent-failure problem without any separate validation logic
- 👍 No redundant prefix; the parallel branches in
resolve_command_refs/_register_extension_skills collapse back into one, simplifying the implementation
- 👍 It's consistent with the actual command-name grammar, guaranteeing lossless representation (a segment never contains
_, so there's no dot/hyphen collision possible)
- 👎 The mixed uppercase-and-hyphen shape (
AGENT-CONTEXT) may look aesthetically odd, less like a "valid identifier"
- 🤔 This extension only allows the hyphen. How far to widen the character class is really a policy call — for now I'd propose extending it only as far as the actual command-name grammar requires (
[a-z0-9-]), but if other special characters become necessary down the line, that would need its own discussion.
- 👎 Some of what's already implemented and tested on this branch would need to be walked back
My take: I lean toward Option 2 — it reaches the same safety guarantees as Option 1 without a second grammar or extra validation logic, more simply. That said, there's a real cost to reverting work already on this branch, so I'll leave the final call to the maintainers.
On docs: either direction, extensions/EXTENSION-DEVELOPMENT-GUIDE.md's "Referencing other commands" section (roughly lines 297–325) — which still only documents the uppercase form, states the token "does not carry hyphens within a segment," and has a stale skills-mode limitation callout — no longer matches reality and should be updated.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
minzzang144 reacted with thumbs up emoji
minzzang144 reacted with eyes emoji
All reactions
-
👍
1 reaction
-
👀
1 reaction
|
@mnriem
I understand the direction (Option 2), but I'd like to check on process before moving — this is actually my first time contributing to this repo, so I'm a bit unsure what's expected here.
I noticed this PR's branch lives directly in github/spec-kit rather than a fork, so I don't have push access to it. And given how much label-driven automation and Copilot commits have already been involved in getting this issue/PR to this point, I wasn't sure whether there's some other process I'm not aware of (e.g. opening a new issue, or a specific label that re-triggers automation) — so I wanted to ask rather than guess.
On my end, I've already forked the repo and have Option 2 implemented locally (code changes + tests + docs update), ready to push. Based on CONTRIBUTING.md, my understanding is that I should open a new PR and reference/link this one — but let me know if that's the right approach, or if you'd prefer something else, and I'll proceed accordingly.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
minzzang144
added a commit
to minzzang144/spec-kit
that referenced
this pull request
Aug 31, 2026
…upport
The existing hyphen tests in tests/test_extensions.py go through
CommandRegistrar.register_commands_for_agent(), which only exercises
the shared resolve_command_refs() resolver. _register_extension_skills()
in extensions/__init__.py is a separate resolver (the sole writer of
extension SKILL.md content in skills mode, per @mnriem's note on
github#4204) that was left without direct coverage even though its own
character class was widened in the same commit.
Adds test_skill_registration_resolves_hyphenated_command_ref_tokens,
parametrized across all 6 agents like its sibling
test_skill_registration_resolves_command_ref_tokens, exercising
_register_extension_skills() directly via
install_from_directory(..., register_commands=False).
Verified this is a real regression test: reverting the character
class in extensions/__init__.py makes all 6 cases fail with the raw
token leaking into SKILL.md; restoring it makes all 6 pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The new regexes accept malformed multiline tokens that can corrupt rendered template content.
Review details
Suppressed comments (2)
src/specify_cli/extensions/init.py:1611
- This duplicate verbatim matcher also accepts arbitrary and multiline content instead of a canonical command ID. In extension skill rendering, an accidentally unclosed token can then absorb later lines up to the next
)__ and remove that prose from the generated SKILL.md; apply the same constrained command-ID grammar used by the shared resolver.
r"__SPECKIT_COMMAND_([A-Z][A-Z0-9_]*)__"
r"|__SPECKIT_COMMAND\(([^)]+)\)__",
src/specify_cli/integrations/base.py:657
- The verbatim alternative accepts any non-
) text, including whitespace and newlines, rather than the documented canonical command ID. A malformed token can therefore consume multiple lines and silently rewrite unrelated template prose (for example, speckit.plan\nunrelated prose\n is captured and emitted). Restrict this branch to dotted lowercase speckit IDs so malformed tokens remain visible instead of corrupting rendered content.
r"__SPECKIT_COMMAND_([A-Z][A-Z0-9_]*)__|__SPECKIT_COMMAND\(([^)]+)\)__",
- Files reviewed: 4/4 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Superseded by #4356, which is now linked directly to canonical issue #4198. That PR implements the requested option 2 by widening the existing token grammar, preserving the established token form and minimizing behavioral change.
Posted on behalf of @mnriem by GitHub Copilot (model: GPT-5.6 Sol).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
mnriem
mnriem requested changes
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
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.
|