-
Notifications
You must be signed in to change notification settings - Fork 6.3k
fix: wire after_tasks and after_implement hook events into command templates #1702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
69ea6b8
fix: wire after_tasks and after_implement hook events into command te…
mnriem cf6c7ae
fix: clarify hook condition handling and add YAML error guidance in t…
mnriem 5728b5c
Fix/extension hooks not triggered (#1)
dhilipkumars 62de547
Merge branch 'main' into fix/extension-hooks-not-triggered
mnriem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| hooks: | ||
| before_implement: | ||
| - id: pre_test | ||
| enabled: true | ||
| optional: false | ||
| extension: "test-extension" | ||
| command: "pre_implement_test" | ||
| description: "Test before implement hook execution" | ||
|
|
||
| after_implement: | ||
| - id: post_test | ||
| enabled: true | ||
| optional: true | ||
| extension: "test-extension" | ||
| command: "post_implement_test" | ||
| description: "Test after implement hook execution" | ||
| prompt: "Would you like to run the post-implement test?" | ||
|
|
||
| before_tasks: | ||
| - id: pre_tasks_test | ||
| enabled: true | ||
| optional: false | ||
| extension: "test-extension" | ||
| command: "pre_tasks_test" | ||
| description: "Test before tasks hook execution" | ||
|
|
||
| after_tasks: | ||
| - id: post_tasks_test | ||
| enabled: true | ||
| optional: true | ||
| extension: "test-extension" | ||
| command: "post_tasks_test" | ||
| description: "Test after tasks hook execution" | ||
| prompt: "Would you like to run the post-tasks test?" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Testing Extension Hooks | ||
|
|
||
| This directory contains a mock project to verify that LLM agents correctly identify and execute hook commands defined in `.specify/extensions.yml`. | ||
|
|
||
| ## Test 1: Testing `before_tasks` and `after_tasks` | ||
|
|
||
| 1. Open a chat with an LLM (like GitHub Copilot) in this project. | ||
| 2. Ask it to generate tasks for the current directory: | ||
| > "Please follow `/speckit.tasks` for the `./tests/hooks` directory." | ||
| 3. **Expected Behavior**: | ||
| - Before doing any generation, the LLM should notice the `AUTOMATIC Pre-Hook` in `.specify/extensions.yml` under `before_tasks`. | ||
| - It should state it is executing `EXECUTE_COMMAND: pre_tasks_test`. | ||
| - It should then proceed to read the `.md` docs and produce a `tasks.md`. | ||
| - After generation, it should output the optional `after_tasks` hook (`post_tasks_test`) block, asking if you want to run it. | ||
|
|
||
| ## Test 2: Testing `before_implement` and `after_implement` | ||
|
|
||
| *(Requires `tasks.md` from Test 1 to exist)* | ||
|
|
||
| 1. In the same (or new) chat, ask the LLM to implement the tasks: | ||
| > "Please follow `/speckit.implement` for the `./tests/hooks` directory." | ||
| 2. **Expected Behavior**: | ||
| - The LLM should first check for `before_implement` hooks. | ||
| - It should state it is executing `EXECUTE_COMMAND: pre_implement_test` BEFORE doing any actual task execution. | ||
| - It should evaluate the checklists and execute the code writing tasks. | ||
| - Upon completion, it should output the optional `after_implement` hook (`post_implement_test`) block. | ||
|
|
||
| ## How it works | ||
|
|
||
| The templates for these commands in `templates/commands/tasks.md` and `templates/commands/implement.md` contains strict ordered lists. The new `before_*` hooks are explicitly formulated in a **Pre-Execution Checks** section prior to the outline to ensure they're evaluated first without breaking template step numbers. | ||
mnriem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Test Setup for Hooks | ||
|
|
||
| This feature is designed to test if LLMs correctly invoke Spec Kit extensions hooks when generating tasks and implementing code. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - **User Story 1:** I want a test script that prints "Hello hooks!". |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - [ ] T001 [US1] Create script that prints 'Hello hooks!' in hello.py |
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.
Uh oh!
There was an error while loading. Please reload this page.