autoworkflow 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,130 +2,108 @@
2
2
 
3
3
  > Event-driven actions that control Claude's workflow behavior.
4
4
  > These triggers fire automatically based on context and events.
5
+ >
6
+ > **IMPLEMENTATION:** All triggers are now implemented as shell scripts in `.claude/hooks/`
5
7
 
6
8
  ---
7
9
 
8
- ## Trigger Definitions
10
+ ## Trigger Implementation Map
9
11
 
10
- ### `on:conversation_start`
12
+ | Trigger | Hook Script | Event |
13
+ |---------|-------------|-------|
14
+ | `on:conversation_start` | `session-check.sh` | UserPromptSubmit |
15
+ | `on:blueprint_missing` | `session-check.sh` + `blueprint-generator.sh` | UserPromptSubmit |
16
+ | `on:init_needed` | `session-check.sh` | UserPromptSubmit |
17
+ | `on:task_received` | `session-check.sh` | UserPromptSubmit |
18
+ | `on:phase_transition` | `phase-transition.sh` | Manual call |
19
+ | `on:implementation_complete` | `post-edit.sh` | PostToolUse (Write\|Edit) |
20
+ | `on:verification_failed` | `post-edit.sh` | PostToolUse (Write\|Edit) |
21
+ | `on:verification_passed` | `post-edit.sh` | PostToolUse (Write\|Edit) |
22
+ | `on:commit_requested` | `pre-tool-router.sh` → `pre-commit-check.sh` | PreToolUse (Bash) |
11
23
 
12
- **When:** Claude begins a new conversation or task
13
- **Action:**
14
- 1. Check if autoworkflow needs initialization
15
- 2. Read root `CLAUDE.md` (entry point)
16
- 3. Check if `instructions/BLUEPRINT.md` exists
17
- 4. If NO → Trigger `on:blueprint_missing`
18
- 5. If YES → Load blueprint and proceed
19
- 6. Load `system/router.md` to determine task type
20
- 7. Load `system/gates.md` for blocking rules
21
- 8. Await user request
24
+ ---
25
+
26
+ ## State Management
27
+
28
+ All workflow state is stored in `.claude/.autoworkflow/`:
22
29
 
23
30
  ```
24
- TRIGGER: conversation_start
25
- ├── Check: node_modules/autoworkflow exists AND CLAUDE.md missing?
26
- │ └── YES Trigger: on:init_needed
27
- ├── Read: CLAUDE.md
28
- ├── Check: instructions/BLUEPRINT.md exists?
29
- ├── NO → Trigger: on:blueprint_missing
30
- │ └── YES Read: instructions/BLUEPRINT.md
31
- ├── Read: system/router.md
32
- ├── Read: system/gates.md
33
- └── State: READY
31
+ .claude/.autoworkflow/
32
+ ├── session-id # Current session identifier
33
+ ├── phase # Current workflow phase
34
+ ├── task-type # Classified task type
35
+ ├── verify-iteration # Current verify loop count
36
+ ├── verify-status # PASSED/FAILED/BLOCKED
37
+ ├── audit-iteration # Current audit loop count
38
+ ├── audit-status # PASSED/FAILED/BLOCKED
39
+ ├── gate-status # Last gate check result
40
+ ├── gate-errors # Number of gate errors
41
+ ├── plan-approved # Plan approval status
42
+ ├── changed-files # List of modified files
43
+ └── blueprint-checked # Blueprint check done flag
34
44
  ```
35
45
 
36
46
  ---
37
47
 
38
- ### `on:init_needed`
48
+ ## Trigger Definitions
39
49
 
40
- **When:** autoworkflow is in node_modules but CLAUDE.md is missing
41
- **Action:**
42
- 1. Notify user that autoworkflow needs setup
43
- 2. Suggest running /init command
50
+ ### `on:conversation_start`
44
51
 
45
- ```
46
- TRIGGER: init_needed
47
- ├── Notify: "AutoWorkflow detected but not initialized"
48
- ├── Suggest: "Run /init to set up workflow files"
49
- └── Await: user response
50
- ```
52
+ **When:** Claude begins a new conversation or task
53
+ **Hook:** `.claude/hooks/session-check.sh`
54
+ **Event:** `UserPromptSubmit`
55
+
56
+ **Actions:**
57
+ 1. Initialize session state (create session-id)
58
+ 2. Reset iteration counters
59
+ 3. Check if autoworkflow needs initialization
60
+ 4. Check if `instructions/BLUEPRINT.md` exists
61
+ 5. If NO → Trigger `on:blueprint_missing`
62
+ 6. If YES → Load blueprint and proceed
63
+ 7. Show current workflow state
51
64
 
52
- **Output Format:**
65
+ ```bash
66
+ # Implementation
67
+ ./.claude/hooks/session-check.sh
53
68
  ```
54
- 📦 **AutoWorkflow detected in node_modules**
55
69
 
56
- The workflow files haven't been copied to your project yet.
70
+ ---
57
71
 
58
- Run `/init` to set up:
59
- - CLAUDE.md (entry point)
60
- - system/ (triggers, loops, gates)
61
- - instructions/ (workflow, rules, blueprint)
62
- - .claude/ (commands)
63
- - scripts/ (automation)
64
- - hooks/ (git hooks)
72
+ ### `on:init_needed`
65
73
 
66
- Or run `/init --all` to include .vscode and config templates.
67
- ```
74
+ **When:** autoworkflow is in node_modules but CLAUDE.md is missing
75
+ **Hook:** `.claude/hooks/session-check.sh`
76
+ **Trigger Condition:** `[ -d "node_modules/autoworkflow" ] && [ ! -f "CLAUDE.md" ]`
77
+
78
+ **Actions:**
79
+ 1. Notify user that autoworkflow needs setup
80
+ 2. Suggest running `npx autoworkflow init`
68
81
 
69
82
  ---
70
83
 
71
84
  ### `on:blueprint_missing`
72
85
 
73
86
  **When:** BLUEPRINT.md does not exist at session start
87
+ **Hook:** `.claude/hooks/session-check.sh` + `.claude/hooks/blueprint-generator.sh`
74
88
  **Behavior:** AUTOMATIC - runs without asking permission
75
89
 
76
- **IMPORTANT:** This trigger runs AUTOMATICALLY. Do NOT ask "Should I run the audit?" - just run it.
77
- Only ask for approval when SAVING the generated files, not when starting the scan.
90
+ **IMPORTANT:** This trigger runs AUTOMATICALLY:
91
+ - Do NOT ask "Should I run the audit?"
92
+ - Do NOT wait for permission to start
93
+ - Just notify and run immediately
94
+ - Only ask permission when presenting results to SAVE
78
95
 
79
- **Action:**
96
+ **Actions:**
80
97
  1. Notify user (brief message)
81
98
  2. **RUN audit immediately** (no permission needed)
82
- 3. Generate BOTH AI_RULES.md updates AND BLUEPRINT.md
83
- 4. Present proposed updates to user
84
- 5. Ask approval to SAVE (not to start)
99
+ 3. Scan: package.json, src/, pages/, components/, api/
100
+ 4. Generate BOTH AI_RULES.md updates AND BLUEPRINT.md
101
+ 5. Present proposed updates to user
102
+ 6. Ask approval to SAVE (not to start)
85
103
 
86
- ```
87
- TRIGGER: blueprint_missing
88
- ├── Notify: "No BLUEPRINT.md found. Running project audit..." ← Just notify
89
- ├── RUN IMMEDIATELY (no permission needed): ← Auto-run
90
- │ ├── cat package.json → Tech stack
91
- │ ├── find src -type d → File structure
92
- │ ├── ls src/pages/ → Routes
93
- │ ├── ls src/components/ → Components
94
- │ ├── find src/api/ → API endpoints
95
- │ └── grep -r "fetch\|/api/" → Connections
96
-
97
- ├── Generate: AI_RULES.md updates (Tech Stack, File Structure)
98
- ├── Generate: BLUEPRINT.md (Features, Routes, APIs)
99
- ├── Present: both updates to user
100
- ├── Await: approval TO SAVE (not to start) ← Only save needs approval
101
- └── Save: both files after approval
102
- ```
103
-
104
- **DO NOT:**
105
- - Ask "Should I run the audit?"
106
- - Ask "Do you want me to scan the project?"
107
- - Wait for permission to start scanning
108
-
109
- **DO:**
110
- - Notify and immediately start scanning
111
- - Only ask permission when presenting results to save
112
-
113
- **Output Format:**
114
- ```
115
- ⚠️ No BLUEPRINT.md found.
116
-
117
- Running project audit now...
118
-
119
- [scanning happens automatically]
120
-
121
- ---
122
-
123
- ## 🔍 Audit Complete
124
-
125
- [present AI_RULES.md updates]
126
- [present BLUEPRINT.md content]
127
-
128
- **Should I save these files?** (yes/no/edit first)
104
+ ```bash
105
+ # To run the blueprint generator:
106
+ ./.claude/hooks/blueprint-generator.sh
129
107
  ```
130
108
 
131
109
  ---
@@ -133,52 +111,87 @@ Running project audit now...
133
111
  ### `on:task_received`
134
112
 
135
113
  **When:** User provides a task or request
136
- **Action:**
137
- 1. Route task through `system/router.md`
138
- 2. Identify task type (feature, fix, refactor, etc.)
139
- 3. Load appropriate workflow from `instructions/CLAUDE.md`
140
- 4. Enter ANALYZE phase
141
-
142
- ```
143
- TRIGGER: task_received
144
- ├── Parse: user request
145
- ├── Route: system/router.md task_type
146
- ├── Load: instructions/CLAUDE.md#workflow
147
- └── Enter: ANALYZE phase
148
- ```
114
+ **Hook:** `.claude/hooks/session-check.sh`
115
+ **Function:** `classify_task()`
116
+
117
+ **Classification Keywords:**
118
+
119
+ | Task Type | Keywords |
120
+ |-----------|----------|
121
+ | query | what, how, why, explain, show me, find |
122
+ | feature | add, create, implement, build, new |
123
+ | fix | fix, bug, broken, error, issue, problem |
124
+ | refactor | refactor, clean up, restructure, rename |
125
+ | style | style, css, color, layout, design |
126
+ | docs | document, readme, comment, jsdoc |
127
+ | test | test, spec, coverage, unit test |
128
+ | perf | performance, optimize, speed, slow |
129
+ | security | security, vulnerability, auth |
130
+ | config | config, setting, environment, setup |
131
+
132
+ **Actions:**
133
+ 1. Parse user request
134
+ 2. Classify task type
135
+ 3. Save to `.claude/.autoworkflow/task-type`
136
+ 4. Set phase to ANALYZE
137
+ 5. Display workflow for task type
149
138
 
150
139
  ---
151
140
 
152
141
  ### `on:phase_transition`
153
142
 
154
143
  **When:** Moving from one workflow phase to another
155
- **Action:**
156
- 1. Check `system/gates.md` for phase gate
157
- 2. If gate passes → proceed to next phase
158
- 3. If gate fails → BLOCK and report
144
+ **Hook:** `.claude/hooks/phase-transition.sh`
145
+ **Usage:** Manual invocation
159
146
 
160
- ```
161
- TRIGGER: phase_transition(from, to)
162
- ├── Check: system/gates.md#{to}_gate
163
- ├── If PASS → Enter: {to} phase
164
- └── If FAIL → BLOCK: report gate failure
147
+ **Commands:**
148
+ ```bash
149
+ # Transition between phases (checks gates)
150
+ ./.claude/hooks/phase-transition.sh transition PLAN IMPLEMENT
151
+
152
+ # Record plan approval
153
+ ./.claude/hooks/phase-transition.sh approve
154
+
155
+ # Record plan rejection
156
+ ./.claude/hooks/phase-transition.sh reject
157
+
158
+ # Reset workflow state
159
+ ./.claude/hooks/phase-transition.sh reset
160
+
161
+ # Show current state
162
+ ./.claude/hooks/phase-transition.sh status
165
163
  ```
166
164
 
165
+ **Gate Checks:**
166
+ - `PLAN` → Checks analyze_gate
167
+ - `IMPLEMENT` → Checks plan_approval_gate (BLOCKING)
168
+ - `AUDIT` → Checks verify_gate
169
+ - `COMMIT` → Checks verify_gate + audit_gate
170
+
167
171
  ---
168
172
 
169
173
  ### `on:implementation_complete`
170
174
 
171
175
  **When:** Claude finishes writing/modifying code
172
- **Action:**
176
+ **Hook:** `.claude/hooks/post-edit.sh`
177
+ **Event:** `PostToolUse` for `Write|Edit`
178
+
179
+ **Actions:**
173
180
  1. Enter VERIFY phase automatically
174
- 2. Start `verify_loop` from `system/loops.md`
175
- 3. Report results
181
+ 2. Run `npm run verify` (or typecheck + lint)
182
+ 3. Track iteration count (max 10)
183
+ 4. If PASS → Reset counter, proceed to AUDIT or COMMIT
184
+ 5. If FAIL → Enter FIX phase, report errors
176
185
 
186
+ **Output:**
177
187
  ```
178
- TRIGGER: implementation_complete
179
- ├── Enter: VERIFY phase
180
- ├── Start: system/loops.md#verify_loop
181
- └── Report: verification results
188
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
189
+ AUTOWORKFLOW: VERIFY LOOP (Iteration 1/10)
190
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
191
+
192
+ Running: npm run verify
193
+
194
+ ✅ VERIFICATION PASSED
182
195
  ```
183
196
 
184
197
  ---
@@ -186,54 +199,60 @@ TRIGGER: implementation_complete
186
199
  ### `on:verification_failed`
187
200
 
188
201
  **When:** `npm run verify` returns errors
189
- **Action:**
190
- 1. Parse error output
191
- 2. Enter FIX phase
192
- 3. Start `fix_loop` from `system/loops.md`
202
+ **Hook:** `.claude/hooks/post-edit.sh`
203
+ **Automatic:** Triggers when verification fails
193
204
 
194
- ```
195
- TRIGGER: verification_failed
196
- ├── Parse: error output
197
- ├── Enter: FIX phase
198
- ├── Start: system/loops.md#fix_loop
199
- └── Return to: VERIFY phase when fixed
200
- ```
205
+ **Actions:**
206
+ 1. Parse error output
207
+ 2. Increment iteration counter
208
+ 3. Set phase to FIX
209
+ 4. Report errors with file:line
210
+ 5. Wait for fixes, then re-verify on next edit
201
211
 
202
212
  ---
203
213
 
204
214
  ### `on:verification_passed`
205
215
 
206
216
  **When:** `npm run verify` returns success
207
- **Action:**
208
- 1. Check if audits required (new feature/component)
209
- 2. If yes → enter AUDIT phase
210
- 3. If no → proceed to COMMIT gate
217
+ **Hook:** `.claude/hooks/post-edit.sh`
218
+ **Automatic:** Triggers when verification passes
211
219
 
212
- ```
213
- TRIGGER: verification_passed
214
- ├── Check: is_audit_required?
215
- ├── If YESEnter: AUDIT phase
216
- ├── If NOCheck: system/gates.md#pre_commit_gate
217
- └── Report: ready status
218
- ```
220
+ **Actions:**
221
+ 1. Reset iteration counter
222
+ 2. Check if audits required (feature/refactor)
223
+ 3. If yesSet phase to AUDIT
224
+ 4. If noSet phase to PRE_COMMIT
219
225
 
220
226
  ---
221
227
 
222
228
  ### `on:commit_requested`
223
229
 
224
- **When:** User asks to commit or workflow reaches commit phase
225
- **Action:**
226
- 1. Check `system/gates.md#pre_commit_gate`
227
- 2. All gates must pass
228
- 3. If blocked report and await fix
229
- 4. If passed ask for commit confirmation
230
+ **When:** User asks to commit or runs git commit
231
+ **Hook:** `.claude/hooks/pre-tool-router.sh` → `.claude/hooks/pre-commit-check.sh`
232
+ **Event:** `PreToolUse` for `Bash` (only git commit commands)
233
+
234
+ **Gate Checks (all must pass):**
235
+ 1. TypeScript errors = 0
236
+ 2. ESLint warnings = 0
237
+ 3. No TODO/FIXME in staged files
238
+ 4. No console.log in staged files
239
+ 5. No orphan features (audit:ui)
240
+ 6. No circular dependencies (audit:cycles)
241
+ 7. Conventional commit format
242
+
243
+ **On FAIL:** Exit with code 1 → BLOCKS the commit
230
244
 
231
245
  ```
232
- TRIGGER: commit_requested
233
- ├── Check: system/gates.md#pre_commit_gate
234
- ├── If BLOCKED → Report: blocking issues
235
- ├── If PASSED → Show: commit preview
236
- └── Await: user confirmation
246
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
247
+ AUTOWORKFLOW: PRE-COMMIT GATE
248
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
249
+
250
+ [1/7] TypeScript: PASS
251
+ [2/7] ESLint: ✅ PASS
252
+ [3/7] TODO/FIXME: ⛔ FAIL
253
+ └── Found in 2 file(s)
254
+
255
+ ⛔ GATE BLOCKED - 1 issue(s) must be fixed
237
256
  ```
238
257
 
239
258
  ---
@@ -241,76 +260,67 @@ TRIGGER: commit_requested
241
260
  ### `on:error_detected`
242
261
 
243
262
  **When:** Any error occurs during execution
244
- **Action:**
263
+ **Handling:** Inline in post-edit.sh and pre-commit-check.sh
264
+
265
+ **Actions:**
245
266
  1. Identify error type
246
267
  2. Route to appropriate fix strategy
247
268
  3. Enter FIX phase if code error
248
269
  4. Report if environmental error
249
270
 
250
- ```
251
- TRIGGER: error_detected(error_type)
252
- ├── Identify: error_type
253
- ├── If code_error → Enter: FIX phase
254
- ├── If env_error → Report: to user
255
- └── If unknown → Ask: user for guidance
256
- ```
257
-
258
271
  ---
259
272
 
260
273
  ### `on:file_changed`
261
274
 
262
275
  **When:** Claude modifies a file
263
- **Action:**
276
+ **Hook:** `.claude/hooks/post-edit.sh`
277
+ **Tracking:** Files added to `.claude/.autoworkflow/changed-files`
278
+
279
+ **Actions:**
264
280
  1. Mark file as changed
265
281
  2. Queue for verification
266
- 3. If in IMPLEMENT phase → continue
267
- 4. If outside phase → trigger verification
268
-
269
- ```
270
- TRIGGER: file_changed(file_path)
271
- ├── Track: changed_files.add(file_path)
272
- ├── If IMPLEMENT phase → Continue
273
- ├── If other phase → Queue: verification
274
- └── Update: state
275
- ```
282
+ 3. Auto-trigger verify loop
276
283
 
277
284
  ---
278
285
 
279
286
  ### `on:user_approval`
280
287
 
281
288
  **When:** User approves a plan or action
282
- **Action:**
283
- 1. Record approval
284
- 2. Proceed to next phase
285
- 3. If plan approval → enter IMPLEMENT
286
- 4. If commit approval → execute commit
289
+ **Hook:** `.claude/hooks/phase-transition.sh approve`
287
290
 
288
- ```
289
- TRIGGER: user_approval(approval_type)
290
- ├── Record: approval
291
- ├── If plan_approval Enter: IMPLEMENT phase
292
- ├── If commit_approval Execute: git commit
293
- └── Continue: workflow
294
- ```
291
+ **Detection Keywords:**
292
+ - "yes" / "y" / "yeah" / "yep"
293
+ - "proceed" / "go ahead" / "do it"
294
+ - "approved" / "lgtm" / "looks good"
295
+ - "all" / "include all" (for suggestions)
296
+
297
+ **Actions:**
298
+ 1. Record approval to `.claude/.autoworkflow/plan-approved`
299
+ 2. Proceed to IMPLEMENT phase
295
300
 
296
301
  ---
297
302
 
298
303
  ### `on:user_rejection`
299
304
 
300
305
  **When:** User rejects a plan or action
301
- **Action:**
306
+ **Hook:** `.claude/hooks/phase-transition.sh reject`
307
+
308
+ **Actions:**
302
309
  1. Record rejection
303
310
  2. Ask for feedback
304
311
  3. Return to PLAN phase
305
- 4. Revise based on feedback
306
312
 
307
- ```
308
- TRIGGER: user_rejection
309
- ├── Record: rejection
310
- ├── Ask: "What should I change?"
311
- ├── Return to: PLAN phase
312
- └── Incorporate: user feedback
313
- ```
313
+ ---
314
+
315
+ ### `on:feature_complete`
316
+
317
+ **When:** A new feature, route, or API is successfully committed
318
+ **Handling:** Manual check after commit
319
+
320
+ **Actions:**
321
+ 1. Check if BLUEPRINT.md needs updating
322
+ 2. Present proposed updates
323
+ 3. Update after approval
314
324
 
315
325
  ---
316
326
 
@@ -373,44 +383,42 @@ When multiple triggers could fire, use this priority:
373
383
 
374
384
  ---
375
385
 
376
- ### `on:feature_complete`
377
-
378
- **When:** A new feature, route, or API is successfully committed
379
- **Action:**
380
- 1. Check if BLUEPRINT.md needs updating
381
- 2. Present proposed updates
382
- 3. Update after approval
383
-
384
- ```
385
- TRIGGER: feature_complete
386
- ├── Check: was new feature/route/api added?
387
- ├── If YES:
388
- │ ├── Generate: BLUEPRINT.md update
389
- │ ├── Present: proposed changes
390
- │ ├── Await: approval
391
- │ └── Update: BLUEPRINT.md
392
- └── If NO:
393
- └── Skip: no update needed
394
- ```
395
-
396
- **Update Triggers:**
397
- | Event | Action |
398
- |-------|--------|
399
- | New feature added | Add to Features section |
400
- | New route created | Add to Routes section |
401
- | New API endpoint | Add to API section |
402
- | Feature removed | Mark as deprecated or remove |
403
-
404
- **Output Format:**
405
- ```
406
- ## 📘 Blueprint Update
407
-
408
- Adding to BLUEPRINT.md:
409
- - Feature: [name] - [description]
410
- - Route: [path] → [Component]
411
- - API: [method] [endpoint]
412
-
413
- **Should I update BLUEPRINT.md?**
386
+ ## Hook Configuration
387
+
388
+ All hooks are configured in `.claude/settings.json`:
389
+
390
+ ```json
391
+ {
392
+ "hooks": {
393
+ "UserPromptSubmit": [
394
+ {
395
+ "matcher": "",
396
+ "hooks": [{
397
+ "type": "command",
398
+ "command": "./.claude/hooks/session-check.sh"
399
+ }]
400
+ }
401
+ ],
402
+ "PostToolUse": [
403
+ {
404
+ "matcher": "Write|Edit",
405
+ "hooks": [{
406
+ "type": "command",
407
+ "command": "./.claude/hooks/post-edit.sh"
408
+ }]
409
+ }
410
+ ],
411
+ "PreToolUse": [
412
+ {
413
+ "matcher": "Bash",
414
+ "hooks": [{
415
+ "type": "command",
416
+ "command": "./.claude/hooks/pre-tool-router.sh \"$TOOL_INPUT\""
417
+ }]
418
+ }
419
+ ]
420
+ }
421
+ }
414
422
  ```
415
423
 
416
424
  ---