Share skills hook note post-processing#2679
Open
puneetdixit200 wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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 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.
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.
Summary
Fixes #2523
Tests
git diff --checkuvx 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 -quv run pytest -quv run specify --helpAI Disclosure