Skip to content

fix(cline): keep .md extension on speckit.* file names in command bodies - #5168

Open
kevin9327 wants to merge 3 commits into
github:mainfrom
kevin9327:fix/5097-cline-md-filenames
Open

kevin9327 wants to merge 3 commits into
github:mainfrom
kevin9327:fix/5097-cline-md-filenames

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

Fixes #5097

Problem

For Cline extension/preset commands, _hyphenate_body_refs (and _hyphenate_frontmatter_refs) rewrite every speckit.<a>.<b> token. A file name such as speckit.git.commit.md matches as a reference, so .specify/extensions/git/commands/speckit.git.commit.md becomes .../speckit-git-commit-md (extension lost).

Fix

Both helpers now share one compiled pattern and a small replacer that leaves a match ending in .md unchanged. Command references such as /speckit.git.commit are still hyphenated.

Evidence

  • Added test_cline_body_refs_keep_md_file_names and test_cline_frontmatter_refs_keep_md_file_names in tests/integrations/test_integration_cline.py.
  • On main both fail; with this change both pass.
  • pytest tests/integrations tests/test_extensions.py: 3632 passed, 8 skipped.

AI disclosure

Implemented by Grok Bot (an AI coding agent) acting on behalf of @kevin9327, running autonomously; model unknown/not exposed to the agent. Extent: code generation, tests, and this description. The commit carries an Assisted-by: trailer. I ran the tests above locally.

Cline's dot-to-hyphen rewrite matched `speckit.git.commit.md` as a command
reference and produced `speckit-git-commit-md`, dropping the extension.
Leave matches that end in `.md` untouched in both body and frontmatter.

Fixes github#5097

Assisted-by: Grok Bot (model: unknown, autonomous)
Signed-off-by: kevin9327 <5299031+kevin9327@users.noreply.github.com>

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.

🟡 Changes recommended

A moderate active issue remains because the .md suffix check misclassifies valid command references such as /speckit.foo.md, leaving required transformations incorrect in both body and frontmatter without a regression test.

1 open issue
What changed in this PR

This pull request updates Cline reference rewriting so command filenames ending in .md retain their extension while dotted command references remain hyphenated.

Changes:

  • Shares compiled matching and replacement logic for body and frontmatter references.
  • Preserves .md-suffixed command filenames.
  • Adds regression tests for body and frontmatter handling.
File Summary
tests/​integrations/​test_integration_cline.py Adds regression coverage for preserving .md command filenames in body and frontmatter references.
src/​specify_cli/​agents.py Centralizes Cline reference rewriting, but the .md suffix check also leaves valid command references such as /speckit.foo.md unchanged; this requires a context-aware distinction.

Review effort: Lite (auto)

Comment thread src/specify_cli/agents.py Outdated
@mnriem

mnriem commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

@mnriem mnriem added the author-awaiting Waiting on author response label Oct 29, 2026
A speckit.<ext>.md token is a command reference unless it has more
segments than a command can have or sits inside a path.

Assisted-by: Grok Bot (model: unknown, autonomous)
Signed-off-by: kevin9327 <5299031+kevin9327@users.noreply.github.com>
@mnriem mnriem added the triage-must-have Verdict: high-value, important work for Spec Kit — do first label Oct 29, 2026
@mnriem
mnriem requested an auto review from Copilot October 29, 2026 13:24

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.

🟡 Changes recommended

An active moderate issue remains because dotted preset command names can be misclassified as filenames, producing incorrect Cline references without a regression test.

1 open issue
1 resolved since last review

Review effort: Lite (auto)

Comment thread src/specify_cli/agents.py Outdated
Comment on lines +109 to +111
if ref.endswith(".md"):
if ref.count(".") > 2:
return ref

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a5afd73. I dropped the segment-count rule, since preset names can contain dots and it could not be made reliable. A speckit.*.md token now stays unchanged only when it sits inside a path (presets/foo/commands/speckit.foo.bar.md). Bare and slash-prefixed tokens (speckit.foo.bar.md, /speckit.foo.md) are hyphenated as command references in both the body and frontmatter. Added test_cline_refs_hyphenate_dotted_preset_command_ending_in_md, which fails without the change and passes with it. tests/integrations: 3148 passed, 8 skipped.

@mnriem

mnriem commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

Preset command names may contain dots, so speckit.foo.bar.md can be a
valid command whose last segment is md. The segment count therefore
cannot identify a file name. Keep a .md token unchanged only when it sits
inside a path; hyphenate bare and slash-prefixed tokens.

Assisted-by: Grok Bot (model: unknown, autonomous)
Signed-off-by: kevin9327 <5299031+kevin9327@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author-awaiting Waiting on author response triage-must-have Verdict: high-value, important work for Spec Kit — do first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Cline extension and preset commands have speckit.*.md file names rewritten to speckit-*-md

3 participants