@vpxa/aikit 0.1.307 → 0.1.309

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.
Files changed (45) hide show
  1. package/package.json +1 -1
  2. package/packages/cli/dist/index.js +4 -4
  3. package/packages/cli/dist/{init-CyjUXjQw.js → init-VP9ig7OK.js} +1 -1
  4. package/packages/cli/dist/{templates-BQ1J4HzY.js → templates-WsJg6Pkc.js} +5 -5
  5. package/packages/server/dist/bin.js +1 -1
  6. package/packages/server/dist/index.js +1 -1
  7. package/packages/server/dist/repair-json-B6Q_HRoP.js +3 -0
  8. package/packages/server/dist/repair-json-D4mft_HA.js +4 -0
  9. package/packages/server/dist/{server-B_KbLM43.js → server-DZKWh8ZG.js} +176 -170
  10. package/packages/server/dist/{server-utMi-Qu3.js → server-RV1UYywi.js} +177 -169
  11. package/packages/server/dist/{server-http-B-TDT3t-.js → server-http-DeWcQphZ.js} +1 -1
  12. package/packages/server/dist/{server-http-BbuuthEP.js → server-http-Dk16rq4T.js} +1 -1
  13. package/packages/server/dist/server-stdio-Bx_Aa99F.js +1 -0
  14. package/packages/server/dist/server-stdio-CebgeeBc.js +2 -0
  15. package/packages/server/dist/{version-check-DSWaugPC.js → version-check-CdBHTxtt.js} +1 -1
  16. package/packages/server/dist/{version-check-6qDKknz4.js → version-check-CggUKvv8.js} +1 -1
  17. package/scaffold/INSTRUCTIONS.md +273 -0
  18. package/scaffold/dist/adapters/copilot.mjs +2 -9
  19. package/scaffold/dist/adapters/hermes-agent.mjs +2 -2
  20. package/scaffold/dist/adapters/hermes.mjs +8 -4
  21. package/scaffold/dist/adapters/hooks.mjs +1 -1
  22. package/scaffold/dist/adapters/intellij.mjs +7 -3
  23. package/scaffold/dist/adapters/skills.mjs +3 -1
  24. package/scaffold/dist/adapters/zed.mjs +6 -2
  25. package/scaffold/dist/definitions/agents.mjs +2 -2
  26. package/scaffold/dist/definitions/bodies.mjs +98 -369
  27. package/scaffold/dist/definitions/flows.mjs +6 -6
  28. package/scaffold/dist/definitions/prompts.mjs +12 -12
  29. package/scaffold/dist/definitions/protocols.mjs +117 -556
  30. package/scaffold/dist/definitions/skills/adr-skill.mjs +41 -197
  31. package/scaffold/dist/definitions/skills/aikit.mjs +52 -205
  32. package/scaffold/dist/definitions/skills/brainstorming.mjs +74 -112
  33. package/scaffold/dist/definitions/skills/browser-use.mjs +128 -184
  34. package/scaffold/dist/definitions/skills/c4-architecture.mjs +45 -106
  35. package/scaffold/dist/definitions/skills/docs.mjs +236 -380
  36. package/scaffold/dist/definitions/skills/frontend-design.mjs +96 -193
  37. package/scaffold/dist/definitions/skills/lesson-learned.mjs +57 -184
  38. package/scaffold/dist/definitions/skills/multi-agents-development.mjs +98 -408
  39. package/scaffold/dist/definitions/skills/present.mjs +193 -1
  40. package/scaffold/dist/definitions/skills/react.mjs +68 -111
  41. package/scaffold/dist/definitions/skills/repo-access.mjs +24 -169
  42. package/scaffold/dist/definitions/skills/requirements-clarity.mjs +45 -94
  43. package/scaffold/dist/definitions/skills/typescript.mjs +162 -230
  44. package/packages/server/dist/server-stdio-BUb39kqq.js +0 -2
  45. package/packages/server/dist/server-stdio-Ch7yAxNk.js +0 -1
@@ -1,4 +1,4 @@
1
- var e=[{file:`architecture-review-prompt.md`,content:`# Architecture Review Prompt Template
1
+ var e=[{file:`references/architecture-review-prompt.md`,content:`# Architecture Review Prompt Template
2
2
 
3
3
  Use when dispatching **Architect-Reviewer-Alpha** and **Architect-Reviewer-Beta** for boundary, pattern, infra, or public API changes.
4
4
 
@@ -78,7 +78,7 @@ You are performing an architecture review. Focus on structural decisions, not co
78
78
  - Trigger for boundary, pattern, infra, or API-surface changes
79
79
  - Run Alpha and Beta in parallel
80
80
  - Shared blocker from both reviewers = likely real issue
81
- `},{file:`code-quality-review-prompt.md`,content:`# Code Quality Review Prompt Template
81
+ `},{file:`references/code-quality-review-prompt.md`,content:`# Code Quality Review Prompt Template
82
82
 
83
83
  Use when dispatching **Code-Reviewer-Alpha** and **Code-Reviewer-Beta** for dual code review. Same prompt; different models catch different issues.
84
84
 
@@ -168,7 +168,7 @@ You are performing a code review. Your job is to evaluate HOW the implementation
168
168
  - Use for dual review or pair with spec-review prompt
169
169
  - Blocker = REQUEST_CHANGES
170
170
  - Minor/Nit = APPROVE_WITH_SUGGESTIONS
171
- `},{file:`implementer-prompt.md`,content:`# Implementer Dispatch Prompt Template
171
+ `},{file:`references/implementer-prompt.md`,content:`# Implementer Dispatch Prompt Template
172
172
 
173
173
  Use when dispatching **Implementer**, **Frontend**, or **Refactor**. Provide all needed context; subagent should not search beyond scope.
174
174
 
@@ -258,7 +258,7 @@ Hit a wall and cannot proceed:
258
258
  - Keep scope to 1-3 files
259
259
  - Include failing test output for bug fixes
260
260
  - Add frontend or refactor-specific constraints when needed
261
- `},{file:`parallel-dispatch-example.md`,content:`# Parallel Dispatch Worked Example
261
+ `},{file:`references/parallel-dispatch-example.md`,content:`# Parallel Dispatch Worked Example
262
262
 
263
263
  Shows parallel feature decomposition and review flow.
264
264
 
@@ -411,436 +411,126 @@ metadata:
411
411
 
412
412
  # Multi-Agent Development
413
413
 
414
- Patterns for parallel multi-agent work: decomposition, dispatch, context, status, review, recovery.
414
+ Purpose: decompose work, dispatch focused agents, integrate evidence, recover cleanly. Orchestrator/Planner usually run as main agents; other agents usually run as subagents but must still handle direct mode.
415
415
 
416
- **Core Principle**: Dispatch focused agents with fresh context and explicit scope.
416
+ ## Operating Model
417
417
 
418
- ---
419
-
420
- ## §1 Agent Roles & Model Selection
421
-
422
- ### Role Categories
423
-
424
- | Role | Agents | When to Use | Parallelizable |
425
- |------|--------|-------------|----------------|
426
- | **Orchestration** | Orchestrator, Planner | Plan/control | No |
427
- | **Implementation** | Implementer, Frontend, Refactor | Code changes | Yes |
428
- | **Review** | Code-Reviewer-Alpha/Beta, Architect-Reviewer-Alpha/Beta | Verify | Yes |
429
-
430
- ### Model Selection by Task Complexity
431
-
432
- | Complexity Signal | Model Tier | Example Agents |
433
- |-------------------|-----------|----------------|
434
- | Mechanical (rename, move, add field) | Fast model | Explorer |
435
- | Standard (implement spec, write tests) | Mid-tier | Implementer/Refactor |
436
-
437
- **Upgrade signal**: \`BLOCKED\` or \`DONE_WITH_CONCERNS\` on Standard task → re-dispatch to stronger model.
438
-
439
- ---
440
-
441
- ## §2 Task Decomposition Rules
442
-
443
- ### The Golden Rule
444
- > **One task = one focused problem domain = 1-3 files maximum.**
445
-
446
- ### Decomposition Checklist
447
-
448
- For each task, specify:
449
- - [ ] **Target files** — exact paths
450
- - [ ] **Acceptance criteria** — testable done state
451
- - [ ] **Agent assignment** — who owns task
452
- - [ ] **Dependencies** — prerequisite tasks
453
-
454
- ### Sizing Guide
455
-
456
- | Task Size | Files | Example | Agent |
457
- |-----------|-------|---------|-------|
458
- | **Standard** | 2-3 files | Service + controller + test | Implementer |
459
-
460
- ### Splitting Strategies
461
- - **By layer**: Service + UI + tests
462
-
463
- ---
464
-
465
- ## §3 Independence Decision Tree
466
-
467
- Before marking tasks parallel, walk this tree:
468
-
469
- \`\`\`
470
- Task A and Task B — can they run in parallel?
471
-
472
- ├─ Do they share ANY files? (create, modify, or delete same file)
473
- │ ├─ YES → SEQUENTIAL (or merge into one task)
474
- │ └─ NO ↓
475
-
476
- ├─ Do they share mutable state? (env vars, globals, same DB table, shared config)
477
- │ ├─ YES → SEQUENTIAL
478
- │ └─ NO ↓
479
-
480
- ├─ Does B need A's output? (B reads file A creates, B uses A's new export)
481
- │ ├─ YES → SEQUENTIAL (A before B)
482
- │ └─ NO ↓
483
-
484
- ├─ Would A's result change B's approach? (A discovers something that affects B)
485
- │ ├─ YES → SEQUENTIAL or single agent
486
- │ └─ NO ↓
487
-
488
- ├─ Resource contention? (same port, same build process, same lock file)
489
- │ ├─ YES → SEQUENTIAL
490
- │ └─ NO ↓
491
-
492
- └─ ✅ SAFE TO PARALLELIZE
493
- \`\`\`
494
-
495
- ### Edge Cases
496
-
497
- | Situation | Verdict | Why |
498
- |-----------|---------|-----|
499
- | Same shared import only | ✅ Parallel | Read-only |
500
- | Same index/package file | ❌ Sequential | Shared edit |
501
-
502
- ### Integration Verification (after parallel batch completes)
503
-
504
- 1. **Conflict check**: unexpected overlap?
505
- 2. **Import check**: cross-references resolve?
506
- 3. **Full suite**: \`check({})\` + \`test_run({})\`
507
-
508
- ---
509
-
510
- ## §4 Parallel Dispatch Patterns
511
-
512
- ### Dispatch Rules
513
-
514
- 1. **Max 4 concurrent file-modifying agents** per batch
515
- 2. **Read-only agents have no limit** — Explorer, Researcher*, Reviewer*, Security
516
- 3. **Build dependency graph first** — dependency-free phases batch together
517
- 4. **Never dispatch two implementers to same file**
518
-
519
- ### Batch Strategy
520
-
521
- \`\`\`
522
- Phase Plan:
523
- Phase 1: [Task A, Task B, Task C] ← no dependencies between A/B/C
524
- Phase 2: [Task D, Task E] ← D depends on A, E depends on B
525
- Phase 3: [Task F] ← F depends on D and E
526
-
527
- Execution:
528
- Batch 1: dispatch(A, B, C) in parallel → review → gate
529
- Batch 2: dispatch(D, E) in parallel → review → gate
530
- Batch 3: dispatch(F) → review → gate
531
- \`\`\`
532
-
533
- ### Anti-Patterns
534
-
535
- | ❌ Don't | ✅ Do Instead |
536
- |----------|--------------|
537
- | Dispatch 6 implementers at once | Max 4, queue rest |
538
- | Give one agent 10 files | Split tasks |
539
- | Skip review after batch | ALWAYS review + integrate |
540
-
541
- ---
542
-
543
- ## §5 Context Crafting Guide
544
-
545
- ### The Controller Principle
546
- > **The Orchestrator provides ALL context. Subagents never search for it.**
547
-
548
- Fresh prompt only. No inherited session state.
549
-
550
- ### The 6-Point Prompt Template
551
-
552
- Every delegation prompt MUST include:
553
-
554
- \`\`\`markdown
555
- ## 1. Scope
556
- Files to create/modify: [exact paths]
557
- Files to NOT touch: [boundaries]
558
-
559
- ## 2. Goal
560
- [What the code should do — acceptance criteria, testable outcomes]
561
-
562
- ## 3. Architectural Context
563
- [Relevant patterns, conventions, existing code structure]
564
- [Include actual code snippets from compact/digest — don't tell agent to "go read X"]
565
-
566
- ## 4. Constraints
567
- - Follow [pattern/convention]
568
- - Do NOT modify [boundary files]
569
- - Use [specific library/approach]
570
-
571
- ## 5. FORGE Context
572
- Tier: [Floor/Standard/Critical]
573
- Evidence requirements: [what evidence to collect]
574
-
575
- ## 6. Self-Review & Status
576
- Before declaring DONE, verify:
577
- - [ ] All acceptance criteria met
578
- - [ ] No files outside scope modified
579
- - [ ] Tests pass (if applicable)
580
- - [ ] Code follows stated conventions
581
-
582
- End with status: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED
583
- \`\`\`
584
-
585
- ### What to Include vs Omit
586
-
587
- | ✅ Include | ❌ Omit |
588
- |-----------|---------|
589
- | Exact file paths and snippets | Full session history |
590
-
591
- ### Context Size Budget
592
-
593
- | Task Complexity | Context Target | Approach |
594
- |-----------------|---------------|----------|
595
- | Standard (2-3 files) | ~2000 tokens | \`digest\` + architecture |
596
-
597
- ---
418
+ - Main agent owns plan, flow, user comms, gates, and final synthesis.
419
+ - Subagents own one scoped research/review/implementation task.
420
+ - Fresh prompt only. Assume no inherited session state.
421
+ - Context flows through AI Kit: withdraw -> compact/digest -> dispatch -> deposit.
422
+ - Token goal: send decisions, constraints, snippets, paths; skip raw history.
598
423
 
599
- ## §6 Subagent Execution Cycle
424
+ ## Role Routing
600
425
 
601
- ### Lifecycle
426
+ | Need | Agent |
427
+ |---|---|
428
+ | Plan/lifecycle/gate | Orchestrator |
429
+ | Implementation plan | Planner |
430
+ | Feature/API/wiring | Implementer |
431
+ | UI/styling/a11y | Frontend |
432
+ | Cleanup/rename/reduce complexity | Refactor |
433
+ | Bug/root cause | Debugger |
434
+ | Auth/crypto/input/CVE | Security |
435
+ | Unknown code area | Explorer or Researcher |
436
+ | Docs | Documenter |
437
+ | Correctness review | Code-Reviewer-Alpha/Beta |
438
+ | Boundary review | Architect-Reviewer-Alpha/Beta |
602
439
 
603
- \`\`\`
604
- Orchestrator Subagent (fresh instance)
605
- │ │
606
- ├─ Craft focused prompt ──────────────►│
607
- │ (6-point template) │
608
- │ ├─ Understand scope
609
- │ ├─ Implement changes
610
- │ ├─ Self-review (checklist)
611
- │◄─────────────────── Return status ───┤
612
- │ │ (DONE/CONCERNS/NEEDS/BLOCKED)
613
- │ │
614
- ├─ Handle status (see §7) × (subagent terminates)
615
-
616
- ├─ Automated gate (check/test_run)
617
-
618
- ├─ Dispatch reviewers (see §8)
619
-
620
- └─ FORGE evidence_map gate
621
- \`\`\`
622
-
623
- ### Key Rules
624
-
625
- 1. **One subagent = one task**
626
- 2. **Controller provides context**
627
- 3. **Status is mandatory**
628
-
629
- ---
630
-
631
- ## §7 Implementer Status Protocol
632
-
633
- ### Status Codes
634
-
635
- Every implementer (Implementer, Frontend, Refactor) MUST end response with exactly ONE:
636
-
637
- | Status | Meaning | Orchestrator Action |
638
- |--------|---------|-------------------|
639
- | **DONE** | Complete, self-review passed | → Review → arch/security if needed → \`evidence_map\` gate |
640
- | **DONE_WITH_CONCERNS** | Complete, concerns raised | → Review + \`Assumed\` claims |
641
- | **NEEDS_CONTEXT** | Missing info | → Add context → re-dispatch |
642
- | **BLOCKED** | Cannot proceed | → Diagnose |
643
-
644
- ### BLOCKED Diagnosis Tree
645
-
646
- \`\`\`
647
- Agent returned BLOCKED
648
-
649
- ├─ Missing context? (needs info not in prompt)
650
- │ → Provide context, re-dispatch
651
-
652
- ├─ Wrong model? (task too complex for assigned model)
653
- │ → Re-dispatch to stronger model (e.g., Implementer → Debugger)
654
-
655
- ├─ Scope too broad? (agent overwhelmed)
656
- │ → Split task further, re-dispatch smaller pieces
657
-
658
- ├─ Plan wrong? (implementation approach won't work)
659
- │ → Re-plan this phase, check AI Kit for alternatives
660
-
661
- └─ External blocker? (dependency not ready, API unavailable)
662
- → Park task, proceed with independent work, revisit later
663
- \`\`\`
664
-
665
- ### FORGE Composition
666
-
667
- - **Status** = agent telemetry
668
- - **FORGE** = evidence-based quality gate
669
-
670
- \`\`\`
671
- DONE → proceed to code review → conditional architecture/security review → FORGE evidence_map → present results
672
- DONE_WITH_CONCERNS → concerns become 'Assumed' claims → reviewers validate them → evidence_map likely HOLDs
673
- NEEDS_CONTEXT → provide context, re-dispatch (no FORGE yet)
674
- BLOCKED → diagnose:
675
- contract/security issue → HARD_BLOCK
676
- resource/scope issue → re-plan, no FORGE
677
- \`\`\`
678
-
679
- **Critical rule**: Every \`DONE\` must complete code review and any conditional architecture/security review BEFORE \`evidence_map({ action: "gate" })\`.
680
-
681
- ---
682
-
683
- ## §8 Review Pipeline
684
-
685
- ### Ordered Review Pipeline
686
-
687
- \`\`\`
688
- Stage 1: Implementer Self-Review (embedded in agent output)
689
- └─ Checklist: scope respected, tests pass, conventions followed
690
-
691
- Stage 2: Dual Code Review (parallel)
692
- ├─ Code-Reviewer-Alpha (GPT-5.4): code quality + Spec Alignment
693
- └─ Code-Reviewer-Beta (Opus 4.6): code quality + Spec Alignment
694
- │ Both review same code, different model perspectives
695
- │ Spec Alignment = "Does this match what was asked?"
696
-
697
- Stage 3: Architecture Review (conditional)
698
- └─ Trigger only for boundary changes, new modules, or pattern shifts
699
-
700
- Stage 4: Security Review (conditional)
701
- └─ Trigger for auth, crypto, input handling, or external data
702
-
703
- Stage 5: FORGE Gate — evidence_map({ action: "gate" })
704
- └─ YIELD → stop and present results
705
- └─ HOLD → address flagged items → re-gate (**Max 2 retries** per task)
706
- └─ HARD_BLOCK → escalate to user
707
- \`\`\`
708
-
709
- Use \`check({})\` + \`test_run({})\` for reviewer evidence; not gate.
710
-
711
- ### Spec Alignment Dimension (for Code Reviewers)
712
-
713
- Check acceptance criteria, over-build, under-build, and expected file set.
714
-
715
- ### When to Skip Stages
716
-
717
- | Stage | Skip When |
718
- |-------|-----------|
719
- | Architecture Review | No new modules/boundary changes/patterns |
720
-
721
- ---
440
+ ## Decompose
722
441
 
723
- ## §9 Recovery & Escalation
442
+ One subtask = one problem domain + explicit file boundary.
724
443
 
725
- ### Retry Policy
444
+ For each task define:
445
+ - Goal and acceptance criteria.
446
+ - Files to create/modify/read; files not to touch.
447
+ - Dependencies and parallel batch.
448
+ - Required skills/tools/tests.
449
+ - FORGE tier, task_id, evidence expected.
726
450
 
727
- **Max 2 retries** per task. Include failure reason. Never reuse same prompt.
451
+ Split by layer, package, endpoint, component, test surface, or risk class. Merge tasks when they share writable files.
728
452
 
729
- ### Loop Detection
453
+ ## Parallelism
730
454
 
731
- If an agent returns the same error/status 2+ times:
732
- 1. **STOP**
733
- 2. Recheck approach
734
- 3. Change agent, model, decomposition, or escalate
455
+ Parallelize when tasks share no writable files, mutable state, generated artifact, port, lockfile, DB table, or output dependency.
735
456
 
736
- ### Emergency Procedures
457
+ Limits:
458
+ - File-modifying agents: max 4 concurrent, disjoint files only.
459
+ - Read-only agents: parallel freely.
460
+ - Shared index/config/package files: sequential.
461
+ - After each batch: integrate, check, test, review, gate before next dependent batch.
737
462
 
738
- When parallel batch causes cascading failures:
463
+ ## Dispatch Envelope
739
464
 
740
- \`\`\`
741
- STOP → Halt all running agents immediately
742
- ASSESS → git diff --stat + check({}) — how bad is it?
743
- CONTAIN Limited (1-3 files): fix or re-delegate
744
- Widespread (10+ files): git stash to preserve for analysis
745
- RECOVER → Partial: git checkout -- {specific files}
746
- Full: git stash (preserves) or git checkout . (discards)
747
- Nuclear: git reset --hard HEAD (last resort)
748
- DOCUMENT remember what went wrong, update plan
749
- \`\`\`
465
+ Every subagent prompt includes:
466
+ 1. Agent name and role.
467
+ 2. Goal + acceptance criteria.
468
+ 3. Files/boundary + do-not-touch list.
469
+ 4. Compressed context: relevant snippets, conventions, decisions, active flow paths.
470
+ 5. Constraints: skills to load, libraries/patterns, no present, no flow advance.
471
+ 6. FORGE: tier, task_id, evidence claims to add.
472
+ 7. Validation: expected check, test_run, or reason skipped.
473
+ 8. Return contract: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED, <=200 words unless blocked.
750
474
 
751
- ### Scope Tripwires
475
+ Use references/implementer-prompt.md for implementation dispatches and references/parallel-dispatch-example.md for batch shape.
752
476
 
753
- | Signal | Action |
754
- |--------|--------|
755
- | Agent modified **2x more files** than planned | Pause, review |
756
- | Agent returns \`ESCALATE\` or \`BLOCKED\` repeatedly | Diagnose before re-delegating |
757
- | Agent's output contradicts plan | Stop, compare, re-align |
758
- | Tests that were passing now fail | Immediate rollback of that agent's changes |
759
-
760
- ---
477
+ ## Context Broker
761
478
 
762
- ## §10 Common Mistakes & Red Flags
479
+ Before dispatch:
480
+ - knowledge({ action: 'withdraw', scope: 'flow', profile: '<role>', budget: 6000 })
481
+ - Add only missing snippets with compact/digest.
482
+ - Paste context into dispatch; do not tell subagent to rediscover basics.
763
483
 
764
- ### Delegation Anti-Patterns
484
+ After subagent work:
485
+ - Store durable findings with knowledge({ action: 'remember', scope: 'flow', ... }).
486
+ - Summarize status/files/decisions/blockers into stash or session digest.
487
+ - Flush flow context only when work completes.
765
488
 
766
- | Mistake | Why It Fails | ✅ Fix |
767
- |-----------|-------------|--------|
768
- | **Too broad scope** | Sprawling changes | Split tasks |
769
- | **Parallel on shared files** | Merge conflicts | Sequential or merge task |
770
-
771
- ### Red Flags in Agent Output
772
-
773
- | Flag | What It Means | Action |
774
- |------|--------------|--------|
775
- | Files outside scope | Scope creep | Roll back, re-delegate tighter |
776
-
777
- ---
489
+ Profiles: implementer, documenter, reviewer, researcher, debugger.
778
490
 
779
- ## §11 Flow Context Sharing
780
-
781
- ### Flow Context Broker
782
-
783
- The \`knowledge\` tool supports flow-scoped context sharing.
784
-
785
- **How it works:** auto-deposit captures tool output, Orchestrator calls \`withdraw\`, subagents can deposit findings, \`flush\` clears flow context.
786
-
787
- ### Orchestrator Workflow
788
-
789
- #### Before Dispatching a Subagent
790
-
791
- \`\`\`
792
- // Get role-filtered context for the subagent
793
- knowledge({ action: 'withdraw', profile: '<role>', budget: 6000 })
794
- // Profiles: implementer, documenter, reviewer, researcher, debugger
795
- \`\`\`
491
+ ## Status Handling
796
492
 
797
- Paste withdrawn context into "## 3. Architectural Context" from §5.
493
+ | Status | Meaning | Orchestrator action |
494
+ |---|---|---|
495
+ | DONE | Complete + self-check passed | review -> gate |
496
+ | DONE_WITH_CONCERNS | Complete but risk/assumption remains | review concern, add assumed claim |
497
+ | NEEDS_CONTEXT | Missing info | supply context, re-dispatch |
498
+ | BLOCKED | Cannot proceed | diagnose; split/change agent/escalate |
798
499
 
799
- #### After All Work Completes
500
+ Same failure twice -> stop loop, change plan/model/scope or ask user.
800
501
 
801
- \`\`\`
802
- // Clean up flow context on flow completion
803
- knowledge({ action: 'flush' })
804
- \`\`\`
805
-
806
- ### Subagent Deposit Pattern
807
-
808
- \`\`\`
809
- // Subagent deposits a finding for future agents
810
- knowledge({ action: 'remember', scope: 'flow', title: 'API validation pattern', content: '...' })
811
- \`\`\`
812
-
813
- ### Profile Filtering
814
-
815
- Use \`implementer\` profile for Implementer/Frontend/Refactor tasks.
816
-
817
- ### Budget Management
818
-
819
- \`budget\` caps returned context. Standard implementation: 6000.
820
-
821
- ### Integration with 6-Point Template
822
-
823
- Update the prompt template from §5 to include flow context:
824
-
825
- \`\`\`markdown
826
- ## 3. Architectural Context
827
- [Paste the result of knowledge({ action: 'withdraw', profile: '<role>' })]
828
- [Supplement with additional compact/digest if the withdrawn context is insufficient]
829
- \`\`\`
502
+ ## Review Pipeline
830
503
 
831
- ### Key Rules
504
+ Standard path:
505
+ 1. Implementer self-check.
506
+ 2. Code review. Use dual reviewers for Standard+ when risk warrants.
507
+ 3. Architecture review for boundary/new-module/public-contract changes.
508
+ 4. Security review for auth/crypto/input/external-data changes.
509
+ 5. evidence_map({ action: 'gate' }): YIELD -> present, HOLD -> fix/retry max 2, HARD_BLOCK -> user.
832
510
 
833
- 1. **Always withdraw before dispatch**
834
- 2. **Flush on completion**
835
- 3. **Profile matters**
511
+ Reviewers add CRITICAL/HIGH evidence only; Orchestrator gates.
836
512
 
837
- ## Prompt Template Reference
513
+ ## Recovery
514
+
515
+ Tripwires:
516
+ - Agent edits outside scope or 2x expected file count.
517
+ - Parallel batch conflicts on same file/artifact.
518
+ - Tests regress outside touched area.
519
+ - Subagent contradicts plan or local conventions.
520
+ - Auth/access failure appears.
521
+
522
+ Recovery order: pause -> inspect diff/check output -> contain scope -> re-dispatch with better context -> escalate if evidence remains missing.
838
523
 
839
- | Template | File | Use When |
840
- |----------|------|----------|
841
- | Implementer dispatch | [\`implementer-prompt.md\`](implementer-prompt.md) | Implementer/Frontend/Refactor |
842
- | Parallel dispatch example | [\`parallel-dispatch-example.md\`](parallel-dispatch-example.md) | Worked example |
843
- `},{file:`spec-review-prompt.md`,content:`# Spec Alignment Review Prompt Template
524
+ ## Reference Prompts
525
+
526
+ | Template | Load when |
527
+ |---|---|
528
+ | references/implementer-prompt.md | Implementation dispatch |
529
+ | references/code-quality-review-prompt.md | Code-review dispatch |
530
+ | references/architecture-review-prompt.md | Architecture review |
531
+ | references/spec-review-prompt.md | Acceptance/spec alignment |
532
+ | references/parallel-dispatch-example.md | Example batch/dependency shape |
533
+ `},{file:`references/spec-review-prompt.md`,content:`# Spec Alignment Review Prompt Template
844
534
 
845
535
  Use when dispatching a code reviewer who should emphasize spec alignment during code review.
846
536