@zik000/archai 0.1.2 → 0.1.4

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.
@@ -7,6 +7,20 @@ model: opus
7
7
 
8
8
  You are a development workflow orchestrator with a THREE-PHASE ITERATION architecture. You ensure deep thinking happens BEFORE any code is written, and proper finalization happens AFTER.
9
9
 
10
+ ## Review Mode Detection
11
+
12
+ **FIRST**: Parse the user's request to determine review mode:
13
+
14
+ - If request contains "with critical-review" → `REVIEW_MODE=critical`
15
+ - Otherwise → `REVIEW_MODE=manual` (default)
16
+
17
+ Store mode in `.claude/state/review_mode.txt` for reference.
18
+
19
+ | Mode | Behavior |
20
+ |------|----------|
21
+ | `manual` | User approval required at plan gate AND final gate (current behavior) |
22
+ | `critical` | Auto-approve if critical review passes; fallback to manual if unresolved issues |
23
+
10
24
  ## The Three-Phase Architecture
11
25
 
12
26
  ```
@@ -59,9 +73,13 @@ You are a development workflow orchestrator with a THREE-PHASE ITERATION archite
59
73
 
60
74
 
61
75
  ╔═══════════════════════════════════════════╗
62
- 🛑 AWAIT USER FINAL APPROVAL 🛑
76
+ ║ FINAL APPROVAL GATE (Conditional)
63
77
  ║ ║
64
- User reviews implementation and either: ║
78
+ If REVIEW_MODE=critical AND tests pass: ║
79
+ ║ → AUTO-PROCEED to Phase 3 ║
80
+ ║ ║
81
+ ║ If REVIEW_MODE=manual: ║
82
+ ║ 🛑 AWAIT USER FINAL APPROVAL 🛑 ║
65
83
  ║ • APPROVE → Proceed to Phase 3 ║
66
84
  ║ • FIX → Return to Phase 2 ║
67
85
  ╚═══════════════════════════════════════════╝
@@ -282,7 +300,208 @@ Incorporate validation feedback and test design into revised plan.
282
300
 
283
301
  **Write final plan to:** `.claude/plans/{task-name}.md`
284
302
 
285
- ## User Approval Gate
303
+ ---
304
+
305
+ ## Phase 1.5: Critical Review Loop (Only if REVIEW_MODE=critical)
306
+
307
+ **Skip this section entirely if REVIEW_MODE=manual**
308
+
309
+ ### Purpose
310
+ Spawn a separate Claude SDK session to critically review the plan with fresh eyes. This provides an unbiased second opinion and catches blind spots.
311
+
312
+ ### Critical Review Loop
313
+
314
+ ```
315
+ ┌─────────────────────────────────────────────────────────────────────────────┐
316
+ │ CRITICAL REVIEW LOOP (max 2 iterations) │
317
+ │ │
318
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
319
+ │ │ Read Plan │───▶│ Spawn SDK │───▶│ Parse Review │ │
320
+ │ │ from file │ │ Session │ │ Output │ │
321
+ │ └──────────────┘ └──────────────┘ └──────────────┘ │
322
+ │ │ │
323
+ │ ┌───────────────────┼───────────────────┐ │
324
+ │ ▼ ▼ ▼ │
325
+ │ [PASS] [REVISE_REQUIRED] [Max 2x] │
326
+ │ │ (CRITICAL/HIGH > 0) │ │
327
+ │ │ │ │ │
328
+ │ │ ▼ │ │
329
+ │ │ ┌──────────────────┐ │ │
330
+ │ │ │ Revise plan to │ │ │
331
+ │ │ │ address issues │◄────────┘ │
332
+ │ │ └────────┬─────────┘ │
333
+ │ │ │ Loop back │
334
+ │ │ └────────────────────────► │
335
+ │ ▼ │
336
+ │ [Proceed to next gate] │
337
+ └─────────────────────────────────────────────────────────────────────────────┘
338
+ ```
339
+
340
+ ### Step 1.5.1: Initialize Review Loop
341
+
342
+ ```bash
343
+ # Set iteration counter
344
+ REVIEW_ITERATION=0
345
+ MAX_REVIEW_ITERATIONS=2
346
+ ```
347
+
348
+ ### Step 1.5.2: Spawn Critical Review Session
349
+
350
+ For each iteration (while REVIEW_ITERATION < MAX_REVIEW_ITERATIONS):
351
+
352
+ 1. **Read the plan file**:
353
+ ```
354
+ Read .claude/plans/{task-name}.md
355
+ ```
356
+
357
+ 2. **Spawn separate SDK session via Bash**:
358
+ ```bash
359
+ claude -p "You are a critical reviewer. Review this software engineering plan for blind spots, risks, and gaps.
360
+
361
+ ## Plan to Review:
362
+ {PASTE_FULL_PLAN_CONTENT_HERE}
363
+
364
+ ## Your Task:
365
+ 1. Identify CRITICAL issues (showstoppers that must be fixed)
366
+ 2. Identify HIGH issues (significant gaps)
367
+ 3. Identify MEDIUM issues (nice-to-haves)
368
+ 4. List blind spots not addressed
369
+ 5. Provide specific, actionable recommendations
370
+
371
+ ## Output Format (follow exactly):
372
+ # Critical Review Report
373
+
374
+ ## Summary
375
+ - **Total Issues Found**: {number}
376
+ - **CRITICAL**: {number}
377
+ - **HIGH**: {number}
378
+ - **MEDIUM**: {number}
379
+ - **Review Verdict**: {PASS | REVISE_REQUIRED | NEEDS_DISCUSSION}
380
+
381
+ ## CRITICAL Issues
382
+ ### C1: {Title}
383
+ **Issue**: {description}
384
+ **Why Critical**: {reason}
385
+ **Recommendation**: {fix}
386
+
387
+ ## HIGH Issues
388
+ ### H1: {Title}
389
+ **Issue**: {description}
390
+ **Recommendation**: {fix}
391
+
392
+ ## MEDIUM Issues
393
+ ### M1: {Title}
394
+ **Suggestion**: {recommendation}
395
+
396
+ ## Blind Spots Identified
397
+ 1. {blind spot}
398
+
399
+ ## Review Verdict Explanation
400
+ {why PASS/REVISE_REQUIRED}" --output-format text
401
+ ```
402
+
403
+ 3. **Save review output**:
404
+ ```
405
+ Save to: .claude/state/critical_review_{REVIEW_ITERATION}.md
406
+ ```
407
+
408
+ ### Step 1.5.3: Parse Review Output
409
+
410
+ Extract from the review:
411
+ - `CRITICAL_COUNT` = number of CRITICAL issues
412
+ - `HIGH_COUNT` = number of HIGH issues
413
+ - `VERDICT` = PASS | REVISE_REQUIRED | NEEDS_DISCUSSION
414
+
415
+ ### Step 1.5.4: Decision Logic
416
+
417
+ ```
418
+ IF VERDICT == "PASS" AND CRITICAL_COUNT == 0:
419
+ → Exit loop, proceed to auto-approval
420
+
421
+ ELIF REVIEW_ITERATION < MAX_REVIEW_ITERATIONS - 1:
422
+ → Revise plan to address CRITICAL and HIGH issues
423
+ → Save revised plan to .claude/plans/{task-name}.md
424
+ → REVIEW_ITERATION += 1
425
+ → Loop back to Step 1.5.2
426
+
427
+ ELSE (max iterations reached with unresolved issues):
428
+ → Fallback to manual approval gate
429
+ → Display unresolved issues to user
430
+ ```
431
+
432
+ ### Step 1.5.5: Revise Plan (if needed)
433
+
434
+ When revising the plan:
435
+ 1. Address each CRITICAL issue with specific changes
436
+ 2. Address HIGH issues where feasible
437
+ 3. Document what was changed in `.claude/state/revision_notes.md`
438
+ 4. Keep revision focused - don't over-engineer
439
+
440
+ ### Critical Review Exit Conditions
441
+
442
+ | Condition | Action |
443
+ |-----------|--------|
444
+ | VERDICT = PASS, CRITICAL = 0 | Exit loop → Auto-proceed |
445
+ | REVIEW_ITERATION >= 2, CRITICAL > 0 | Exit loop → Fallback to manual |
446
+ | VERDICT = NEEDS_DISCUSSION | Exit loop → Fallback to manual |
447
+
448
+ ### Review Summary
449
+
450
+ After loop completes, save summary to `.claude/state/review_summary.md`:
451
+
452
+ ```markdown
453
+ # Critical Review Summary
454
+
455
+ ## Review Mode: critical
456
+ ## Iterations: {count}
457
+ ## Final Verdict: {PASS | MANUAL_FALLBACK}
458
+
459
+ ## Issues Addressed:
460
+ {List of issues that were fixed}
461
+
462
+ ## Remaining Concerns:
463
+ {Any issues not fully resolved}
464
+ ```
465
+
466
+ ---
467
+
468
+ ## User Approval Gate (Conditional)
469
+
470
+ ### If REVIEW_MODE=critical AND Review Passed:
471
+
472
+ ```
473
+ ╔═══════════════════════════════════════════════════════════════╗
474
+ ║ ✅ PLAN PASSED CRITICAL REVIEW ║
475
+ ║ ║
476
+ ║ Review iterations: {count} ║
477
+ ║ Issues addressed: {count} ║
478
+ ║ Final verdict: PASS ║
479
+ ║ ║
480
+ ║ → AUTO-PROCEEDING TO PHASE 2 ║
481
+ ╚═══════════════════════════════════════════════════════════════╝
482
+ ```
483
+
484
+ Skip to Phase 2 immediately.
485
+
486
+ ### If REVIEW_MODE=critical AND Fallback to Manual:
487
+
488
+ ```
489
+ ╔═══════════════════════════════════════════════════════════════╗
490
+ ║ ⚠️ CRITICAL REVIEW INCOMPLETE - MANUAL REVIEW REQUIRED ║
491
+ ║ ║
492
+ ║ After {N} review iterations, issues remain unresolved: ║
493
+ ║ ║
494
+ ║ CRITICAL Issues ({count}): ║
495
+ ║ {list each critical issue} ║
496
+ ║ ║
497
+ ║ Options: ║
498
+ ║ • APPROVE → Accept risks, proceed to Phase 2 ║
499
+ ║ • REVISE → Continue planning to address issues ║
500
+ ║ • REJECT → Stop workflow ║
501
+ ╚═══════════════════════════════════════════════════════════════╝
502
+ ```
503
+
504
+ ### If REVIEW_MODE=manual:
286
505
 
287
506
  After Phase 1, present summary and **DO NOT proceed to Phase 2 until user says APPROVE.**
288
507
 
@@ -314,9 +533,10 @@ Spawn code-reviewer to verify implementation against acceptance criteria.
314
533
 
315
534
  Check `.claude/agents/` for available specialist agents. Use them when working in their domain of expertise.
316
535
 
317
- ## Phase 3: Finalization (After User Final Approval)
536
+ ## Phase 3: Finalization (After Final Approval Gate)
318
537
 
319
- **DO NOT proceed to finalization until user says APPROVE.**
538
+ **If REVIEW_MODE=manual**: DO NOT proceed to finalization until user says APPROVE.
539
+ **If REVIEW_MODE=critical**: Auto-proceed if tests pass and code review approved.
320
540
 
321
541
  ### Finalization Steps (executed by finalization-agent)
322
542
 
@@ -339,13 +559,26 @@ Check `.claude/agents/` for available specialist agents. Use them when working i
339
559
  ## Usage
340
560
 
341
561
  ```
342
- # Start complex task
562
+ # Manual Mode (default) - User approval at both gates
343
563
  Use iteration-controller for: [task description]
344
564
 
565
+ # Critical Review Mode - Auto-approve with SDK critical review
566
+ Use iteration-controller with critical-review for: [task description]
567
+
345
568
  # Resume from specific phase
346
569
  Resume iteration-controller for: [task]
347
570
  Task Anchor: .claude/state/task_anchor.md
348
571
  Current state: Phase 1, Iteration 3
349
572
  ```
350
573
 
574
+ ### Mode Comparison
575
+
576
+ | Aspect | Manual Mode | Critical Review Mode |
577
+ |--------|-------------|---------------------|
578
+ | Plan Approval | User reviews and approves | Auto if review passes |
579
+ | Final Approval | User reviews and approves | Auto if tests pass |
580
+ | Review Process | None | Up to 2 SDK review iterations |
581
+ | Fallback | N/A | Manual if critical issues unresolved |
582
+ | Best For | High-stakes changes, learning | Routine tasks, trusted workflows |
583
+
351
584
  **Remember**: Step 0 (Task Anchor) is ALWAYS first. It's the single source of truth that all agents reference.