Skip to content

Commit dc74cef

Browse files
mnriemdhilipkumars
authored andcommitted
fix: wire after_tasks and after_implement hook events into command templates (github#1702)
* fix: wire after_tasks and after_implement hook events into command templates (github#1701) The HookExecutor backend in extensions.py was fully implemented but check_hooks_for_event() was never called by anything — the core command templates had no instructions to check .specify/extensions.yml. Add a final step to templates/commands/tasks.md (step 6, after_tasks) and templates/commands/implement.md (step 10, after_implement) that instructs the AI agent to: - Read .specify/extensions.yml if it exists - Filter hooks.{event} to enabled: true entries - Evaluate any condition fields and skip non-matching hooks - Output the RFC-specified hook message format, including EXECUTE_COMMAND: markers for mandatory (optional: false) hooks Bumps version to 0.1.7. * fix: clarify hook condition handling and add YAML error guidance in templates - Replace ambiguous "evaluate any condition value" instruction with explicit guidance to skip hooks with non-empty conditions, deferring evaluation to HookExecutor - Add instruction to skip hook checking silently if extensions.yml cannot be parsed or is invalid * Fix/extension hooks not triggered (#1) * feat(templates): implement before-hooks check as pre-execution phase * test(hooks): create scenario for LLMs/Agents on hooks --------- Co-authored-by: Dhilip <s.dhilipkumar@gmail.com>
1 parent 24b8837 commit dc74cef

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

templates/commands/implement.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,40 @@ $ARGUMENTS
3535

3636
You **MUST** consider the user input before proceeding (if not empty).
3737

38+
## Pre-Execution Checks
39+
40+
**Check for extension hooks (before implementation)**:
41+
- Check if `.specify/extensions.yml` exists in the project root.
42+
- If it exists, read it and look for entries under the `hooks.before_implement` key
43+
- If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
44+
- Filter to only hooks where `enabled: true`
45+
- For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
46+
- If the hook has no `condition` field, or it is null/empty, treat the hook as executable
47+
- If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
48+
- For each executable hook, output the following based on its `optional` flag:
49+
- **Optional hook** (`optional: true`):
50+
```
51+
## Extension Hooks
52+
53+
**Optional Pre-Hook**: {extension}
54+
Command: `/{command}`
55+
Description: {description}
56+
57+
Prompt: {prompt}
58+
To execute: `/{command}`
59+
```
60+
- **Mandatory hook** (`optional: false`):
61+
```
62+
## Extension Hooks
63+
64+
**Automatic Pre-Hook**: {extension}
65+
Executing: `/{command}`
66+
EXECUTE_COMMAND: {command}
67+
68+
Wait for the result of the hook command before proceeding to the Outline.
69+
```
70+
- If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
71+
3872
## Multi-Repository Workspace Detection
3973
4074
**Before executing any tasks:**
@@ -51,6 +85,7 @@ You **MUST** consider the user input before proceeding (if not empty).
5185
- **Single-repo**: Work continues on the current branch in the active repository
5286
- **Multi-repo**: Create matching feature branches in all affected repositories using the same branch name as the `*-document` repository
5387
88+
5489
## Outline
5590
5691
0. **Multi-Repository Branch Setup**:

0 commit comments

Comments
 (0)