Skip to content

Share skills hook note post-processing#2679

Open
puneetdixit200 wants to merge 2 commits into
github:mainfrom
puneetdixit200:fix-skills-hook-note-postprocess
Open

Share skills hook note post-processing#2679
puneetdixit200 wants to merge 2 commits into
github:mainfrom
puneetdixit200:fix-skills-hook-note-postprocess

Conversation

@puneetdixit200
Copy link
Copy Markdown

Summary

  • Move hook command dot-to-hyphen note injection into shared skills post-processing.
  • Run shared post-processing during skills setup so generated skills stay consistent.
  • Keep per-integration frontmatter additions layered on top.

Fixes #2523

Tests

  • git diff --check
  • uvx ruff check src/
  • uv run python -m pytest tests/integrations/test_integration_base_skills.py tests/integrations/test_integration_claude.py tests/integrations/test_integration_copilot.py tests/integrations/test_integration_vibe.py tests/integrations/test_integration_codex.py tests/integrations/test_integration_agy.py tests/integrations/test_integration_devin.py tests/integrations/test_integration_cursor_agent.py tests/integrations/test_integration_kimi.py tests/integrations/test_integration_lingma.py tests/integrations/test_integration_trae.py -q
  • uv run pytest -q
  • uv run specify --help

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance: AI assistance helped inspect the integration flow and draft the implementation and tests. I reviewed the final diff and ran the checks listed above.

@puneetdixit200 puneetdixit200 requested a review from mnriem as a code owner May 22, 2026 18:16
Copilot AI review requested due to automatic review settings May 22, 2026 18:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR centralizes “hook command dot-to-hyphen conversion” guidance by moving hook-note injection into the shared skills integration base, then updates integrations and tests to rely on the shared behavior.

Changes:

  • Add shared hook-note injection to the base skills post-processing pipeline.
  • Update Claude/Vibe/Copilot integrations to use base post-processing and remove duplicated logic.
  • Add/adjust integration tests to verify hook guidance appears only where expected and remains idempotent.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/integrations/test_integration_copilot.py Adds coverage that Copilot skills include shared hook guidance and still inject mode frontmatter.
tests/integrations/test_integration_claude.py Refactors tests to validate shared base behavior and removes Claude-specific injection calls.
tests/integrations/test_integration_base_skills.py Adds base-level test ensuring hook sections include dotted-command conversion guidance.
src/specify_cli/integrations/vibe/init.py Switches to base post-processing instead of bespoke post-generation rewriting.
src/specify_cli/integrations/copilot/init.py Injects hook guidance for Copilot skills (but not via super() yet).
src/specify_cli/integrations/claude/init.py Removes duplicated hook-note injector and delegates shared behavior to base post-processing.
src/specify_cli/integrations/base.py Introduces shared hook-note injection and applies post-processing during skill generation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1400 to +1428
@staticmethod
def _inject_hook_command_note(content: str) -> str:
"""Insert a dot-to-hyphen note before each hook output instruction.

Targets the line ``- For each executable hook, output the following``
and inserts the note on the line before it, matching its indentation.
Skips if the note is already present.
"""
if "replace dots" in content:
return content

def repl(m: re.Match[str]) -> str:
indent = m.group(1)
instruction = m.group(2)
eol = m.group(3)
return (
indent
+ _HOOK_COMMAND_NOTE.rstrip("\n")
+ eol
+ indent
+ instruction
+ eol
)

return re.sub(
r"(?m)^(\s*)(- For each executable hook, output the following[^\r\n]*)(\r\n|\n|$)",
repl,
content,
)
Comment on lines 1545 to 1553
dst = self.write_file_and_record(
skill_content, skill_file, project_root, manifest
)
content = dst.read_text(encoding="utf-8")
updated = self.post_process_skill_content(content)
if updated != content:
dst.write_bytes(updated.encode("utf-8"))
self.record_file_in_manifest(dst, project_root, manifest)
created.append(dst)
Comment on lines 258 to 264
"""Inject shared hook guidance and Copilot ``mode:`` frontmatter.

Inserts ``mode: speckit.<stem>`` before the closing ``---`` so
Copilot can associate the skill with its agent mode.
"""
content = SkillsIntegration._inject_hook_command_note(content)
lines = content.splitlines(keepends=True)
Comment thread src/specify_cli/integrations/base.py Outdated
Comment on lines +1408 to +1409
if "replace dots" in content:
return content
Apply skill content post-processing before the initial write, use an exact hook-note sentinel for idempotence, and route Copilot skill post-processing through the shared helper before adding mode frontmatter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lift hook command note injection into SkillsIntegration base class

2 participants