autoworkflow 1.2.0 → 2.0.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.
@@ -0,0 +1,348 @@
1
+ # System Loops
2
+
3
+ > Repeat-until definitions for automated fix and verification cycles.
4
+ > These loops ensure quality gates are met before proceeding.
5
+
6
+ ---
7
+
8
+ ## Loop Definitions
9
+
10
+ ### `verify_loop`
11
+
12
+ **Purpose:** Run verification until it passes or max iterations reached
13
+ **Max Iterations:** 10
14
+ **Commands:** `npm run verify` (typecheck + lint)
15
+
16
+ ```
17
+ LOOP: verify_loop
18
+ ├── MAX_ITERATIONS: 10
19
+ ├── COMMAND: npm run verify
20
+
21
+ ├── DO:
22
+ │ 1. Run: npm run verify
23
+ │ 2. Capture: output and exit code
24
+ │ 3. Parse: errors if any
25
+
26
+ ├── UNTIL: exit_code == 0
27
+
28
+ ├── ON_SUCCESS:
29
+ │ └── Report: "✅ Verification passed"
30
+ │ └── Trigger: on:verification_passed
31
+
32
+ ├── ON_FAIL (errors exist):
33
+ │ └── Report: errors with file:line
34
+ │ └── Enter: fix_loop
35
+ │ └── Return to: verify_loop
36
+
37
+ └── ON_MAX_ITERATIONS:
38
+ └── Report: "⛔ Max fix attempts reached"
39
+ └── List: remaining errors
40
+ └── Ask: user for guidance
41
+ ```
42
+
43
+ **Output Format (Success):**
44
+ ```
45
+ ✅ VERIFICATION PASSED
46
+
47
+ Iteration: 1/10
48
+ TypeScript: ✓ No errors
49
+ ESLint: ✓ No warnings
50
+
51
+ Ready to proceed.
52
+ ```
53
+
54
+ **Output Format (Failure):**
55
+ ```
56
+ ❌ VERIFICATION FAILED (Iteration 2/10)
57
+
58
+ Found 3 error(s):
59
+
60
+ 1. src/components/Button.tsx:15
61
+ Error: Property 'onClick' is missing in type...
62
+
63
+ 2. src/hooks/useAuth.ts:42
64
+ Error: Type 'string' is not assignable to type 'number'
65
+
66
+ 3. src/pages/Home.tsx:8
67
+ Warning: 'unused' is defined but never used
68
+
69
+ Entering fix loop...
70
+ ```
71
+
72
+ ---
73
+
74
+ ### `fix_loop`
75
+
76
+ **Purpose:** Fix errors one by one until all resolved
77
+ **Max Iterations:** 10 (shared with verify_loop)
78
+ **Strategy:** Fix most critical errors first
79
+
80
+ ```
81
+ LOOP: fix_loop
82
+ ├── MAX_ITERATIONS: 10 (total with verify)
83
+ ├── INPUT: parsed_errors[]
84
+
85
+ ├── DO:
86
+ │ 1. Sort: errors by severity (error > warning)
87
+ │ 2. For each error:
88
+ │ a. Identify: file and line
89
+ │ b. Read: surrounding context
90
+ │ c. Determine: fix strategy
91
+ │ d. Apply: fix
92
+ │ e. Mark: error as addressed
93
+ │ 3. After all fixes: return to verify_loop
94
+
95
+ ├── UNTIL: all errors fixed OR max_iterations
96
+
97
+ ├── ON_ERROR_FIXED:
98
+ │ └── Report: "Fixed: [error description]"
99
+ │ └── Continue: to next error
100
+
101
+ ├── ON_ALL_FIXED:
102
+ │ └── Report: "All errors addressed"
103
+ │ └── Return to: verify_loop
104
+
105
+ └── ON_STUCK (can't fix):
106
+ └── Report: "Unable to fix: [error]"
107
+ └── Ask: user for guidance
108
+ ```
109
+
110
+ **Output Format:**
111
+ ```
112
+ 🔧 FIX LOOP (Iteration 3/10)
113
+
114
+ Fixing 3 errors...
115
+
116
+ [1/3] src/components/Button.tsx:15
117
+ Error: Property 'onClick' is missing
118
+ Fix: Added onClick prop to interface
119
+ Status: ✅ Fixed
120
+
121
+ [2/3] src/hooks/useAuth.ts:42
122
+ Error: Type mismatch
123
+ Fix: Changed return type to string
124
+ Status: ✅ Fixed
125
+
126
+ [3/3] src/pages/Home.tsx:8
127
+ Warning: Unused variable
128
+ Fix: Removed unused import
129
+ Status: ✅ Fixed
130
+
131
+ All errors addressed. Re-running verification...
132
+ ```
133
+
134
+ ---
135
+
136
+ ### `audit_loop`
137
+
138
+ **Purpose:** Run all audit checks until they pass
139
+ **Max Iterations:** 5
140
+ **Commands:** UI enforcement, circular deps, etc.
141
+
142
+ ```
143
+ LOOP: audit_loop
144
+ ├── MAX_ITERATIONS: 5
145
+ ├── CHECKS:
146
+ │ 1. npm run audit:ui (orphan features)
147
+ │ 2. npm run audit:cycles (circular deps)
148
+
149
+ ├── DO:
150
+ │ 1. Run: npm run audit:ui
151
+ │ 2. If fail → Enter: ui_fix_loop
152
+ │ 3. Run: npm run audit:cycles
153
+ │ 4. If fail → Enter: cycle_fix_loop
154
+
155
+ ├── UNTIL: all audits pass
156
+
157
+ ├── ON_SUCCESS:
158
+ │ └── Report: "✅ All audits passed"
159
+ │ └── Proceed to: pre_commit_gate
160
+
161
+ ├── ON_UI_FAIL:
162
+ │ └── Report: orphan features found
163
+ │ └── BLOCK: "Must add UI for: [features]"
164
+ │ └── Enter: ui_fix_loop
165
+
166
+ ├── ON_CYCLE_FAIL:
167
+ │ └── Report: circular dependencies found
168
+ │ └── BLOCK: "Must resolve cycles: [A → B → A]"
169
+ │ └── Enter: cycle_fix_loop
170
+
171
+ └── ON_MAX_ITERATIONS:
172
+ └── Report: "⛔ Cannot resolve audit issues"
173
+ └── Ask: user for guidance
174
+ ```
175
+
176
+ **Output Format:**
177
+ ```
178
+ 🔍 AUDIT LOOP (Iteration 1/5)
179
+
180
+ [1/2] UI Enforcement Check
181
+ Command: npm run audit:ui
182
+ Result: ⛔ FAILED
183
+
184
+ Orphan features detected:
185
+ - /api/users endpoint has no UI
186
+ - useAuth hook is not used by any component
187
+
188
+ BLOCKED: Must add UI before commit.
189
+
190
+ [2/2] Circular Dependencies Check
191
+ Command: npm run audit:cycles
192
+ Result: ✅ PASSED
193
+
194
+ No circular dependencies found.
195
+
196
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
197
+ ⛔ AUDIT BLOCKED
198
+
199
+ Missing UI for:
200
+ - [ ] UserList component for /api/users
201
+ - [ ] Component using useAuth hook
202
+
203
+ Build these components to proceed.
204
+ ```
205
+
206
+ ---
207
+
208
+ ### `ui_fix_loop`
209
+
210
+ **Purpose:** Ensure all backend features have corresponding UI
211
+ **Strategy:** Build missing UI components
212
+
213
+ ```
214
+ LOOP: ui_fix_loop
215
+ ├── MAX_ITERATIONS: 3
216
+ ├── INPUT: orphan_features[]
217
+
218
+ ├── DO:
219
+ │ For each orphan feature:
220
+ │ 1. Identify: what UI is needed
221
+ │ 2. Create: component/page
222
+ │ 3. Connect: to backend/API
223
+ │ 4. Add: route/navigation
224
+ │ 5. Verify: user can access it
225
+
226
+ ├── UNTIL: no orphan features
227
+
228
+ ├── ON_UI_ADDED:
229
+ │ └── Report: "Added UI for: [feature]"
230
+ │ └── Re-run: audit:ui
231
+
232
+ └── ON_CANNOT_ADD (needs clarification):
233
+ └── Ask: "How should [feature] be exposed to users?"
234
+ ```
235
+
236
+ ---
237
+
238
+ ### `cycle_fix_loop`
239
+
240
+ **Purpose:** Resolve circular dependencies
241
+ **Strategy:** Refactor imports to break cycles
242
+
243
+ ```
244
+ LOOP: cycle_fix_loop
245
+ ├── MAX_ITERATIONS: 3
246
+ ├── INPUT: circular_deps[]
247
+
248
+ ├── DO:
249
+ │ For each cycle:
250
+ │ 1. Identify: cycle path (A → B → C → A)
251
+ │ 2. Analyze: which import can be removed/moved
252
+ │ 3. Refactor: extract shared code or reorder imports
253
+ │ 4. Verify: cycle is broken
254
+
255
+ ├── UNTIL: no circular dependencies
256
+
257
+ ├── ON_CYCLE_BROKEN:
258
+ │ └── Report: "Resolved cycle: [path]"
259
+ │ └── Re-run: audit:cycles
260
+
261
+ └── ON_CANNOT_BREAK (architectural issue):
262
+ └── Report: "Cycle requires architectural change"
263
+ └── Ask: user for guidance
264
+ ```
265
+
266
+ ---
267
+
268
+ ### `pre_commit_check_loop`
269
+
270
+ **Purpose:** Run all pre-commit checks
271
+ **Strategy:** Check each blocking rule
272
+
273
+ ```
274
+ LOOP: pre_commit_check_loop
275
+ ├── MAX_ITERATIONS: 1 (check only, no auto-fix)
276
+ ├── CHECKS:
277
+ │ 1. TODO/FIXME comments
278
+ │ 2. console.log statements
279
+ │ 3. TypeScript errors
280
+ │ 4. ESLint warnings
281
+ │ 5. Orphan features
282
+ │ 6. Circular dependencies
283
+
284
+ ├── DO:
285
+ │ 1. Check: git diff for TODO/FIXME
286
+ │ 2. Check: git diff for console.log
287
+ │ 3. Run: npm run verify
288
+ │ 4. Run: npm run audit:ui
289
+ │ 5. Run: npm run audit:cycles
290
+
291
+ ├── ON_ALL_PASS:
292
+ │ └── Report: "✅ All pre-commit checks passed"
293
+ │ └── Proceed to: commit
294
+
295
+ └── ON_ANY_FAIL:
296
+ └── Report: blocking issues
297
+ └── BLOCK: cannot commit
298
+ └── Route to: appropriate fix loop
299
+ ```
300
+
301
+ ---
302
+
303
+ ## Loop Nesting
304
+
305
+ Loops can trigger other loops:
306
+
307
+ ```
308
+ verify_loop
309
+ └── on fail → fix_loop
310
+ └── return → verify_loop
311
+
312
+ audit_loop
313
+ └── on ui_fail → ui_fix_loop
314
+ │ └── return → audit_loop
315
+ └── on cycle_fail → cycle_fix_loop
316
+ └── return → audit_loop
317
+ ```
318
+
319
+ ---
320
+
321
+ ## Iteration Tracking
322
+
323
+ Claude MUST track iterations across loops:
324
+
325
+ ```
326
+ ## Current Loop Status
327
+
328
+ | Loop | Iteration | Max | Status |
329
+ |------|-----------|-----|--------|
330
+ | verify_loop | 3 | 10 | running |
331
+ | fix_loop | 2 | 10 | completed |
332
+ | audit_loop | 1 | 5 | pending |
333
+
334
+ Total fix attempts: 5/10
335
+ ```
336
+
337
+ ---
338
+
339
+ ## Emergency Exit
340
+
341
+ If loops cannot resolve issues:
342
+
343
+ 1. Report all remaining issues
344
+ 2. List what was tried
345
+ 3. Ask user: "I've attempted to fix these issues X times. Should I continue, or would you like to handle this manually?"
346
+ 4. Respect user's decision
347
+
348
+ Never enter infinite loops. Always have an exit condition.