chati-dev 1.4.0 → 2.0.2

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 (208) hide show
  1. package/README.md +40 -24
  2. package/framework/agents/build/dev.md +343 -0
  3. package/framework/agents/clarity/architect.md +112 -0
  4. package/framework/agents/clarity/brief.md +182 -0
  5. package/framework/agents/clarity/brownfield-wu.md +181 -0
  6. package/framework/agents/clarity/detail.md +110 -0
  7. package/framework/agents/clarity/greenfield-wu.md +153 -0
  8. package/framework/agents/clarity/ux.md +112 -0
  9. package/framework/config.yaml +3 -3
  10. package/framework/constitution.md +31 -1
  11. package/framework/context/governance.md +37 -0
  12. package/framework/context/protocols.md +34 -0
  13. package/framework/context/quality.md +27 -0
  14. package/framework/context/root.md +24 -0
  15. package/framework/data/entity-registry.yaml +1 -1
  16. package/framework/domains/agents/architect.yaml +51 -0
  17. package/framework/domains/agents/brief.yaml +47 -0
  18. package/framework/domains/agents/brownfield-wu.yaml +49 -0
  19. package/framework/domains/agents/detail.yaml +47 -0
  20. package/framework/domains/agents/dev.yaml +49 -0
  21. package/framework/domains/agents/devops.yaml +43 -0
  22. package/framework/domains/agents/greenfield-wu.yaml +47 -0
  23. package/framework/domains/agents/orchestrator.yaml +49 -0
  24. package/framework/domains/agents/phases.yaml +47 -0
  25. package/framework/domains/agents/qa-implementation.yaml +43 -0
  26. package/framework/domains/agents/qa-planning.yaml +44 -0
  27. package/framework/domains/agents/tasks.yaml +48 -0
  28. package/framework/domains/agents/ux.yaml +50 -0
  29. package/framework/domains/constitution.yaml +77 -0
  30. package/framework/domains/global.yaml +64 -0
  31. package/framework/domains/workflows/brownfield-discovery.yaml +16 -0
  32. package/framework/domains/workflows/brownfield-fullstack.yaml +26 -0
  33. package/framework/domains/workflows/brownfield-service.yaml +22 -0
  34. package/framework/domains/workflows/brownfield-ui.yaml +22 -0
  35. package/framework/domains/workflows/greenfield-fullstack.yaml +26 -0
  36. package/framework/hooks/constitution-guard.js +101 -0
  37. package/framework/hooks/mode-governance.js +92 -0
  38. package/framework/hooks/model-governance.js +76 -0
  39. package/framework/hooks/prism-engine.js +89 -0
  40. package/framework/hooks/session-digest.js +60 -0
  41. package/framework/hooks/settings.json +44 -0
  42. package/framework/i18n/en.yaml +3 -3
  43. package/framework/i18n/es.yaml +3 -3
  44. package/framework/i18n/fr.yaml +3 -3
  45. package/framework/i18n/pt.yaml +3 -3
  46. package/framework/intelligence/decision-engine.md +1 -1
  47. package/framework/migrations/v1.4-to-v2.0.yaml +167 -0
  48. package/framework/migrations/v2.0-to-v2.0.1.yaml +132 -0
  49. package/framework/orchestrator/chati.md +284 -6
  50. package/framework/tasks/architect-api-design.md +63 -0
  51. package/framework/tasks/architect-consolidate.md +47 -0
  52. package/framework/tasks/architect-db-design.md +73 -0
  53. package/framework/tasks/architect-design.md +95 -0
  54. package/framework/tasks/architect-security-review.md +62 -0
  55. package/framework/tasks/architect-stack-selection.md +53 -0
  56. package/framework/tasks/brief-consolidate.md +249 -0
  57. package/framework/tasks/brief-constraint-identify.md +277 -0
  58. package/framework/tasks/brief-extract-requirements.md +339 -0
  59. package/framework/tasks/brief-stakeholder-map.md +176 -0
  60. package/framework/tasks/brief-validate-completeness.md +121 -0
  61. package/framework/tasks/brownfield-wu-architecture-map.md +394 -0
  62. package/framework/tasks/brownfield-wu-deep-discovery.md +312 -0
  63. package/framework/tasks/brownfield-wu-dependency-scan.md +359 -0
  64. package/framework/tasks/brownfield-wu-migration-plan.md +483 -0
  65. package/framework/tasks/brownfield-wu-report.md +325 -0
  66. package/framework/tasks/brownfield-wu-risk-assess.md +424 -0
  67. package/framework/tasks/detail-acceptance-criteria.md +372 -0
  68. package/framework/tasks/detail-consolidate.md +138 -0
  69. package/framework/tasks/detail-edge-case-analysis.md +300 -0
  70. package/framework/tasks/detail-expand-prd.md +389 -0
  71. package/framework/tasks/detail-nfr-extraction.md +223 -0
  72. package/framework/tasks/dev-code-review.md +404 -0
  73. package/framework/tasks/dev-consolidate.md +543 -0
  74. package/framework/tasks/dev-debug.md +322 -0
  75. package/framework/tasks/dev-implement.md +252 -0
  76. package/framework/tasks/dev-iterate.md +411 -0
  77. package/framework/tasks/dev-pr-prepare.md +497 -0
  78. package/framework/tasks/dev-refactor.md +342 -0
  79. package/framework/tasks/dev-test-write.md +306 -0
  80. package/framework/tasks/devops-ci-setup.md +412 -0
  81. package/framework/tasks/devops-consolidate.md +712 -0
  82. package/framework/tasks/devops-deploy-config.md +598 -0
  83. package/framework/tasks/devops-monitoring-setup.md +658 -0
  84. package/framework/tasks/devops-release-prepare.md +673 -0
  85. package/framework/tasks/greenfield-wu-analyze-empty.md +169 -0
  86. package/framework/tasks/greenfield-wu-report.md +266 -0
  87. package/framework/tasks/greenfield-wu-scaffold-detection.md +203 -0
  88. package/framework/tasks/greenfield-wu-tech-stack-assess.md +255 -0
  89. package/framework/tasks/orchestrator-deviation.md +260 -0
  90. package/framework/tasks/orchestrator-escalate.md +276 -0
  91. package/framework/tasks/orchestrator-handoff.md +243 -0
  92. package/framework/tasks/orchestrator-health.md +372 -0
  93. package/framework/tasks/orchestrator-mode-switch.md +262 -0
  94. package/framework/tasks/orchestrator-resume.md +189 -0
  95. package/framework/tasks/orchestrator-route.md +169 -0
  96. package/framework/tasks/orchestrator-spawn-terminal.md +358 -0
  97. package/framework/tasks/orchestrator-status.md +260 -0
  98. package/framework/tasks/orchestrator-suggest-mode.md +372 -0
  99. package/framework/tasks/phases-breakdown.md +91 -0
  100. package/framework/tasks/phases-dependency-mapping.md +67 -0
  101. package/framework/tasks/phases-mvp-scoping.md +94 -0
  102. package/framework/tasks/qa-impl-consolidate.md +522 -0
  103. package/framework/tasks/qa-impl-performance-test.md +487 -0
  104. package/framework/tasks/qa-impl-regression-check.md +413 -0
  105. package/framework/tasks/qa-impl-sast-scan.md +402 -0
  106. package/framework/tasks/qa-impl-test-execute.md +344 -0
  107. package/framework/tasks/qa-impl-verdict.md +339 -0
  108. package/framework/tasks/qa-planning-consolidate.md +309 -0
  109. package/framework/tasks/qa-planning-coverage-plan.md +338 -0
  110. package/framework/tasks/qa-planning-gate-define.md +339 -0
  111. package/framework/tasks/qa-planning-risk-matrix.md +631 -0
  112. package/framework/tasks/qa-planning-test-strategy.md +217 -0
  113. package/framework/tasks/tasks-acceptance-write.md +75 -0
  114. package/framework/tasks/tasks-consolidate.md +57 -0
  115. package/framework/tasks/tasks-decompose.md +80 -0
  116. package/framework/tasks/tasks-estimate.md +66 -0
  117. package/framework/tasks/ux-a11y-check.md +49 -0
  118. package/framework/tasks/ux-component-map.md +55 -0
  119. package/framework/tasks/ux-consolidate.md +46 -0
  120. package/framework/tasks/ux-user-flow.md +46 -0
  121. package/framework/tasks/ux-wireframe.md +76 -0
  122. package/package.json +2 -2
  123. package/scripts/bundle-framework.js +2 -0
  124. package/scripts/changelog-generator.js +222 -0
  125. package/scripts/codebase-mapper.js +728 -0
  126. package/scripts/commit-message-generator.js +167 -0
  127. package/scripts/coverage-analyzer.js +260 -0
  128. package/scripts/dependency-analyzer.js +280 -0
  129. package/scripts/framework-analyzer.js +308 -0
  130. package/scripts/generate-constitution-domain.js +253 -0
  131. package/scripts/health-check.js +481 -0
  132. package/scripts/ide-sync.js +327 -0
  133. package/scripts/performance-analyzer.js +325 -0
  134. package/scripts/plan-tracker.js +278 -0
  135. package/scripts/populate-entity-registry.js +481 -0
  136. package/scripts/pr-review.js +317 -0
  137. package/scripts/rollback-manager.js +310 -0
  138. package/scripts/stuck-detector.js +343 -0
  139. package/scripts/test-quality-assessment.js +257 -0
  140. package/scripts/validate-agents.js +367 -0
  141. package/scripts/validate-tasks.js +465 -0
  142. package/src/autonomy/autonomous-gate.js +293 -0
  143. package/src/autonomy/index.js +51 -0
  144. package/src/autonomy/mode-manager.js +225 -0
  145. package/src/autonomy/mode-suggester.js +283 -0
  146. package/src/autonomy/progress-reporter.js +268 -0
  147. package/src/autonomy/safety-net.js +320 -0
  148. package/src/context/bracket-tracker.js +79 -0
  149. package/src/context/domain-loader.js +107 -0
  150. package/src/context/engine.js +144 -0
  151. package/src/context/formatter.js +184 -0
  152. package/src/context/index.js +4 -0
  153. package/src/context/layers/l0-constitution.js +28 -0
  154. package/src/context/layers/l1-global.js +37 -0
  155. package/src/context/layers/l2-agent.js +39 -0
  156. package/src/context/layers/l3-workflow.js +42 -0
  157. package/src/context/layers/l4-task.js +24 -0
  158. package/src/decision/analyzer.js +167 -0
  159. package/src/decision/engine.js +270 -0
  160. package/src/decision/index.js +38 -0
  161. package/src/decision/registry-healer.js +450 -0
  162. package/src/decision/registry-updater.js +330 -0
  163. package/src/gates/circuit-breaker.js +119 -0
  164. package/src/gates/g1-planning-complete.js +153 -0
  165. package/src/gates/g2-qa-planning.js +153 -0
  166. package/src/gates/g3-implementation.js +188 -0
  167. package/src/gates/g4-qa-implementation.js +207 -0
  168. package/src/gates/g5-deploy-ready.js +180 -0
  169. package/src/gates/gate-base.js +144 -0
  170. package/src/gates/index.js +46 -0
  171. package/src/installer/brownfield-upgrader.js +249 -0
  172. package/src/installer/core.js +82 -11
  173. package/src/installer/file-hasher.js +51 -0
  174. package/src/installer/manifest.js +117 -0
  175. package/src/installer/templates.js +17 -15
  176. package/src/installer/transaction.js +229 -0
  177. package/src/installer/validator.js +18 -1
  178. package/src/intelligence/registry-manager.js +2 -2
  179. package/src/memory/agent-memory.js +255 -0
  180. package/src/memory/gotchas-injector.js +72 -0
  181. package/src/memory/gotchas.js +361 -0
  182. package/src/memory/index.js +35 -0
  183. package/src/memory/search.js +233 -0
  184. package/src/memory/session-digest.js +239 -0
  185. package/src/merger/env-merger.js +112 -0
  186. package/src/merger/index.js +56 -0
  187. package/src/merger/replace-merger.js +51 -0
  188. package/src/merger/yaml-merger.js +127 -0
  189. package/src/orchestrator/agent-selector.js +285 -0
  190. package/src/orchestrator/deviation-handler.js +350 -0
  191. package/src/orchestrator/handoff-engine.js +271 -0
  192. package/src/orchestrator/index.js +67 -0
  193. package/src/orchestrator/intent-classifier.js +264 -0
  194. package/src/orchestrator/pipeline-manager.js +492 -0
  195. package/src/orchestrator/pipeline-state.js +223 -0
  196. package/src/orchestrator/session-manager.js +409 -0
  197. package/src/tasks/executor.js +195 -0
  198. package/src/tasks/handoff.js +226 -0
  199. package/src/tasks/index.js +4 -0
  200. package/src/tasks/loader.js +210 -0
  201. package/src/tasks/router.js +182 -0
  202. package/src/terminal/collector.js +216 -0
  203. package/src/terminal/index.js +30 -0
  204. package/src/terminal/isolation.js +129 -0
  205. package/src/terminal/monitor.js +277 -0
  206. package/src/terminal/spawner.js +269 -0
  207. package/src/upgrade/checker.js +1 -1
  208. package/src/wizard/i18n.js +3 -3
@@ -0,0 +1,132 @@
1
+ # Migration: v2.0.0 → v2.0.1
2
+ # chati.dev Modular CLAUDE.md Pattern
3
+ # Run: npx chati-dev upgrade
4
+
5
+ from_version: "2.0.0"
6
+ to_version: "2.0.1"
7
+ created_at: "2026-02-13"
8
+ description: "Modular CLAUDE.md — .claude/rules/chati/ auto-loading, CLAUDE.local.md for runtime state"
9
+
10
+ # Pre-conditions
11
+ preconditions:
12
+ - check: version_gte
13
+ value: "2.0.0"
14
+ message: "Must be on v2.0.0+ to upgrade to v2.0.1"
15
+ - check: constitution_articles
16
+ value: 17
17
+ message: "Constitution must have 17 articles (v2.0.0)"
18
+
19
+ # Backup these before proceeding
20
+ backup:
21
+ directories:
22
+ - chati.dev/
23
+ - .chati/
24
+ files:
25
+ - CLAUDE.md
26
+ - CLAUDE.local.md
27
+
28
+ # Operations (executed in order)
29
+ operations:
30
+ # 1. Create context directory
31
+ - type: create_directory
32
+ paths:
33
+ - chati.dev/context
34
+
35
+ # 2. Copy context source files
36
+ - type: copy_directory
37
+ source: framework/context
38
+ destination: chati.dev/context
39
+ strategy: replace
40
+ description: "Install context source files (root.md, governance.md, protocols.md, quality.md)"
41
+
42
+ # 2b. Deploy context files to .claude/rules/chati/ (auto-loaded by Claude Code)
43
+ - type: create_directory
44
+ paths:
45
+ - .claude/rules/chati
46
+
47
+ - type: copy_directory
48
+ source: framework/context
49
+ destination: .claude/rules/chati
50
+ strategy: replace
51
+ description: "Deploy context files for Claude Code auto-loading (no @ imports needed)"
52
+
53
+ # 3. Create CLAUDE.local.md (runtime state)
54
+ - type: create_file
55
+ path: CLAUDE.local.md
56
+ content: |
57
+ # chati.dev Runtime State
58
+
59
+ ## Session Lock
60
+ **Status: INACTIVE** — Type `/chati` to activate.
61
+
62
+ <!-- SESSION-LOCK:INACTIVE -->
63
+
64
+ ## Current State
65
+ - **Agent**: None (ready to start)
66
+ - **Pipeline**: Pre-start
67
+ - **Mode**: interactive
68
+
69
+ ## Recent Decisions
70
+ _No decisions yet. Start with /chati._
71
+
72
+ ---
73
+ _Auto-updated by chati.dev orchestrator_
74
+ condition: not_exists
75
+
76
+ # 4. Migrate CLAUDE.md to minimal version (no @ imports — rules auto-loaded)
77
+ - type: update_file
78
+ path: CLAUDE.md
79
+ strategy: replace
80
+ description: "Replace bloated CLAUDE.md with minimal version (framework rules auto-loaded from .claude/rules/chati/)"
81
+
82
+ # 5. Update orchestrator (session lock → CLAUDE.local.md)
83
+ - type: copy_file
84
+ source: framework/orchestrator/chati.md
85
+ destination: chati.dev/orchestrator/chati.md
86
+ strategy: replace
87
+ description: "Update orchestrator to reference CLAUDE.local.md instead of CLAUDE.md for session lock"
88
+
89
+ # 6. Update config version
90
+ - type: update_yaml
91
+ path: chati.dev/config.yaml
92
+ changes:
93
+ version: "2.0.1"
94
+ updated_at: "auto"
95
+ installer_version: "2.0.1"
96
+
97
+ # 7. Update .gitignore for CLAUDE.local.md
98
+ - type: append_file
99
+ path: .gitignore
100
+ content: |
101
+ # chati.dev v2.0.1 — runtime state (not committed)
102
+ CLAUDE.local.md
103
+ condition: not_contains
104
+ check_string: "CLAUDE.local.md"
105
+
106
+ # Post-migration validation
107
+ validation:
108
+ - check: file_exists
109
+ path: chati.dev/context/root.md
110
+ - check: file_exists
111
+ path: chati.dev/context/governance.md
112
+ - check: file_exists
113
+ path: chati.dev/context/protocols.md
114
+ - check: file_exists
115
+ path: chati.dev/context/quality.md
116
+ - check: file_exists
117
+ path: CLAUDE.local.md
118
+ - check: file_exists
119
+ path: .claude/rules/chati/root.md
120
+ - check: file_exists
121
+ path: .claude/rules/chati/governance.md
122
+ - check: yaml_field
123
+ path: chati.dev/config.yaml
124
+ field: version
125
+ value: "2.0.1"
126
+
127
+ # Rollback instructions
128
+ rollback:
129
+ description: "Restore from .chati/backup-{timestamp}/ created during upgrade"
130
+ steps:
131
+ - "npx chati-dev upgrade --rollback"
132
+ - "Or manually: cp -r .chati/backup-{timestamp}/CLAUDE.md CLAUDE.md"
@@ -518,14 +518,14 @@ Once `/chati` is invoked and a session is active, the orchestrator LOCKS the ses
518
518
  When /chati is invoked:
519
519
  1. Load session state (Step 1-2 above)
520
520
  2. SET session lock = ACTIVE
521
- 3. Update CLAUDE.md with Session Lock block (see template below)
521
+ 3. Update CLAUDE.local.md with Session Lock block (see template below)
522
522
  4. ALL subsequent messages are intercepted by the orchestrator
523
523
  5. Messages are routed to current_agent
524
524
  ```
525
525
 
526
- ### Session Lock Block (CLAUDE.md)
526
+ ### Session Lock Block (CLAUDE.local.md)
527
527
 
528
- When the session is active, CLAUDE.md MUST contain this block:
528
+ When the session is active, CLAUDE.local.md MUST contain this block:
529
529
 
530
530
  ```markdown
531
531
  ## ⚠️ Session Lock — ACTIVE
@@ -541,7 +541,8 @@ When the session is active, CLAUDE.md MUST contain this block:
541
541
  6. The ONLY way to exit is via explicit exit commands (see below)
542
542
  ```
543
543
 
544
- This block is injected into CLAUDE.md when the session starts and removed when the user exits.
544
+ This block is injected into CLAUDE.local.md when the session starts and removed when the user exits.
545
+ CLAUDE.local.md is auto-gitignored — runtime state is never committed.
545
546
 
546
547
  ### Message Routing (while locked)
547
548
 
@@ -598,7 +599,7 @@ When exit is triggered:
598
599
  - Decisions made this session
599
600
  - Current progress and partial work
600
601
  - Pending items
601
- 3. Update CLAUDE.md:
602
+ 3. Update CLAUDE.local.md:
602
603
  - REMOVE Session Lock block
603
604
  - UPDATE project status with current state
604
605
  - ADD resume instructions:
@@ -617,7 +618,7 @@ When exit is triggered:
617
618
  When user types /chati after a previous exit:
618
619
  -> Normal Step 5 (Session Resume) flow
619
620
  -> Session Lock is RE-ACTIVATED
620
- -> CLAUDE.md lock block is RE-INJECTED
621
+ -> CLAUDE.local.md lock block is RE-INJECTED
621
622
  -> User is back in the system seamlessly
622
623
  ```
623
624
 
@@ -652,6 +653,283 @@ If agent fails repeatedly:
652
653
 
653
654
  ---
654
655
 
656
+ ## Authority Boundaries
657
+
658
+ ### Exclusive (only the orchestrator can do this)
659
+ - Route user messages to agents
660
+ - Activate/deactivate agents
661
+ - Execute mode transitions (clarity -> build -> validate -> deploy)
662
+ - Manage session lock (activate/deactivate)
663
+ - Handle deviations and re-routing
664
+ - Manage backlog items
665
+ - Spawn parallel terminals for agents
666
+ - Decide execution mode (human-in-the-loop vs autonomous)
667
+
668
+ ### Allowed (orchestrator may also do this)
669
+ - Read any file in the project (for state detection)
670
+ - Write to .chati/session.yaml (session state)
671
+ - Write to CLAUDE.md (session lock block)
672
+ - Present status dashboards
673
+ - Generate session digests
674
+
675
+ ### Blocked (orchestrator must NEVER do this)
676
+ - Write code or implementation files
677
+ - Write specification documents (artifacts)
678
+ - Modify constitution or config files
679
+ - Make architectural decisions -> redirect to architect agent
680
+ - Write tests -> redirect to dev agent
681
+ - Deploy or configure infrastructure -> redirect to devops agent
682
+ - Modify user's source code in any way
683
+
684
+ ### Redirect Messages
685
+ ```
686
+ If user asks for code: "I'll route this to the Dev agent who handles implementation."
687
+ If user asks about architecture: "Let me activate the Architect agent for this."
688
+ If user asks about testing: "The QA agent handles test strategy. Routing now."
689
+ If user asks about deployment: "DevOps agent manages deployment. Routing now."
690
+ ```
691
+
692
+ ---
693
+
694
+ ## Task Registry
695
+
696
+ | Task ID | Description | Trigger | Parallelizable |
697
+ |---------|-------------|---------|----------------|
698
+ | orchestrator-route | Route user intent to correct agent | Every user message | No |
699
+ | orchestrator-resume | Resume session from saved state | /chati or /chati resume | No |
700
+ | orchestrator-status | Display project dashboard | /chati status | No |
701
+ | orchestrator-handoff | Execute agent-to-agent handoff | Agent completion | No |
702
+ | orchestrator-deviation | Handle deviation from pipeline order | Agent deviation signal | No |
703
+ | orchestrator-escalate | Escalate after 3+ agent failures | Repeated failure | No |
704
+ | orchestrator-mode-switch | Execute mode transition | Quality gate pass | No |
705
+ | orchestrator-health | Run framework health check | /chati health or periodic | No |
706
+ | orchestrator-suggest-mode | Suggest execution mode | Post-Brief completion | No |
707
+ | orchestrator-spawn-terminal | Open parallel terminal for agent | Parallelizable task detected | No |
708
+
709
+ ---
710
+
711
+ ## Context Requirements
712
+
713
+ ```yaml
714
+ prism_layers:
715
+ required: [L0, L1] # Always need constitution + global rules
716
+ conditional:
717
+ L2: true # Agent domain (own domain for routing rules)
718
+ L3: true # Workflow (pipeline position awareness)
719
+ L4: false # No task-level context needed for routing
720
+ domains:
721
+ required:
722
+ - constitution.yaml # For enforcement
723
+ - global.yaml # For mode governance
724
+ optional:
725
+ - agents/*.yaml # When evaluating agent authority
726
+ - workflows/*.yaml # When determining pipeline position
727
+ ```
728
+
729
+ ---
730
+
731
+ ## Handoff Protocol
732
+
733
+ ### Receiving Handoffs (from agents)
734
+ ```
735
+ Pre-conditions:
736
+ - Agent self-validation score >= 95%
737
+ - Handoff file exists at chati.dev/artifacts/handoffs/{agent}-handoff.md
738
+ - session.yaml updated with agent completion data
739
+
740
+ On receive:
741
+ 1. Parse handoff file for: score, artifacts_produced, blockers, recommendations
742
+ 2. Update session.yaml: mark agent as completed
743
+ 3. Evaluate next agent in pipeline
744
+ 4. Check if mode transition is triggered
745
+ 5. Prepare context package for next agent
746
+ ```
747
+
748
+ ### Sending Handoffs (to agents)
749
+ ```
750
+ Context package includes:
751
+ - Previous agent's handoff summary
752
+ - Relevant artifacts references
753
+ - Pipeline position and remaining agents
754
+ - User level and language
755
+ - Execution mode (interactive/autonomous)
756
+ - Backlog items relevant to this agent
757
+
758
+ Post-conditions:
759
+ - session.yaml: current_agent updated
760
+ - CLAUDE.md: current state updated
761
+ - Agent file loaded and activated
762
+ ```
763
+
764
+ ---
765
+
766
+ ## Quality Criteria
767
+
768
+ Self-validation checklist for orchestrator decisions:
769
+
770
+ 1. **Routing accuracy**: Is the selected agent correct for the user's intent?
771
+ 2. **Mode compliance**: Does the operation respect current mode restrictions?
772
+ 3. **Pipeline integrity**: Does the routing follow the defined pipeline order?
773
+ 4. **Deviation handling**: Was the deviation properly logged and context preserved?
774
+ 5. **Session consistency**: Is session.yaml in sync with actual state?
775
+ 6. **Language consistency**: Are all interactions in the user's chosen language?
776
+ 7. **Constitution compliance**: Has no constitutional article been violated?
777
+ 8. **Handoff completeness**: Does the handoff contain all required data?
778
+ 9. **Backlog accuracy**: Are all captured items properly categorized?
779
+ 10. **User level adaptation**: Is guidance depth appropriate for user level?
780
+
781
+ Score threshold: 95% (same as agents)
782
+
783
+ ---
784
+
785
+ ## Model Assignment
786
+
787
+ ```yaml
788
+ default: sonnet
789
+ upgrade_to: opus
790
+ upgrade_conditions:
791
+ - Complex deviation requiring multi-agent re-routing
792
+ - Backward transition analysis (identifying root cause from QA findings)
793
+ - Mode override evaluation (assessing risk of skipping phases)
794
+ - Multi-terminal orchestration (coordinating parallel agents)
795
+ downgrade_to: haiku
796
+ downgrade_conditions:
797
+ - Simple status queries (/chati status)
798
+ - Direct pipeline continuation (no deviation, no branching)
799
+ ```
800
+
801
+ ---
802
+
803
+ ## Recovery Protocol
804
+
805
+ ```
806
+ Level 1 - Retry:
807
+ Condition: Agent fails once
808
+ Action: Re-activate same agent with additional context
809
+ Max retries: 2
810
+
811
+ Level 2 - Escalate:
812
+ Condition: Agent fails 3 consecutive times
813
+ Action:
814
+ 1. Log failure pattern in session.yaml
815
+ 2. Present options to user:
816
+ a. Retry with different approach
817
+ b. Skip agent (document risk)
818
+ c. Return to previous agent
819
+ 3. If autonomous mode: auto-select safest option
820
+
821
+ Level 3 - Session Recovery:
822
+ Condition: session.yaml corrupted or inconsistent
823
+ Action:
824
+ 1. Attempt reconstruction from CLAUDE.md + artifacts
825
+ 2. Validate reconstructed state against filesystem
826
+ 3. If reconstruction fails: start fresh session preserving artifacts
827
+
828
+ Level 4 - Graceful Degradation:
829
+ Condition: Critical system error
830
+ Action:
831
+ 1. Save current state to .chati/recovery/emergency-{timestamp}.yaml
832
+ 2. Notify user with recovery instructions
833
+ 3. Preserve all artifacts produced so far
834
+ ```
835
+
836
+ ---
837
+
838
+ ## Domain Rules
839
+
840
+ 1. **Single Entry Point**: The orchestrator is the ONLY way users interact with chati.dev. No agent is directly accessible.
841
+ 2. **Transparent Routing**: Users should understand which agent is active and why, but never need to manage agents directly.
842
+ 3. **State Preservation**: Every state change is logged in session.yaml. No action is lossy.
843
+ 4. **Fail-Safe Defaults**: When uncertain, default to the most restrictive mode (clarity) and the safest agent.
844
+ 5. **Progressive Disclosure**: Show complexity only when the user needs it. Start simple, reveal depth on demand.
845
+ 6. **Pipeline Respect**: Never skip pipeline steps without explicit user consent and documented risk.
846
+ 7. **Language Fidelity**: Interaction always in user's language. Artifacts always in English. No exceptions.
847
+ 8. **Constitution First**: Constitutional rules override all other logic. If there's a conflict, the constitution wins.
848
+
849
+ ---
850
+
851
+ ## Autonomous Behavior
852
+
853
+ ### Human-in-the-Loop Mode
854
+ ```
855
+ - Present status and options at each transition
856
+ - Wait for user confirmation before mode transitions
857
+ - Show quality gate results and ask for approval
858
+ - Present deviation analysis and let user decide
859
+ - Verbose logging of all decisions
860
+ ```
861
+
862
+ ### Autonomous Mode
863
+ ```
864
+ - Execute pipeline transitions silently when gates pass (score >= 95%)
865
+ - Auto-resolve simple deviations (redirect to correct agent)
866
+ - Pause only on:
867
+ - Quality gate failure (score < 95%)
868
+ - Critical blockers (C01-C14)
869
+ - Mode override requests
870
+ - 3+ consecutive agent failures
871
+ - Report progress periodically (after each agent completion)
872
+ - Batch backlog items for review at quality gates
873
+ ```
874
+
875
+ ### Mode Suggestion Logic
876
+ ```
877
+ After Brief agent completes, analyze:
878
+ - Project type: greenfield (suggest human-in-the-loop) | brownfield-known (suggest autonomous)
879
+ - Complexity: high (> 10 tasks estimated) -> human-in-the-loop
880
+ - Risk level: high (infra, security, DB) -> human-in-the-loop
881
+ - User history: first time -> human-in-the-loop | experienced -> autonomous
882
+ - Recent gotchas in this domain -> human-in-the-loop
883
+
884
+ Present suggestion with reasoning. User always has final say.
885
+ ```
886
+
887
+ ---
888
+
889
+ ## Parallelization Hints
890
+
891
+ ### Parallelizable Agent Groups
892
+ ```
893
+ Group 1 (post-Brief):
894
+ - Detail + Architect + UX
895
+ - Can run in 3 parallel terminals
896
+ - Each writes to isolated artifact directories
897
+ - Orchestrator collects and merges results
898
+
899
+ Group 2 (Dev tasks):
900
+ - Independent dev tasks can run in N parallel terminals
901
+ - Each terminal has isolated write scope
902
+ - Orchestrator monitors and collects results
903
+
904
+ NOT parallelizable:
905
+ - WU (needs user interaction)
906
+ - Brief (needs user interaction)
907
+ - Phases (depends on Detail + Architect + UX)
908
+ - Tasks (depends on Phases)
909
+ - QA-Planning (validates everything)
910
+ - QA-Implementation (validates everything)
911
+ - DevOps (deployment is sequential)
912
+ ```
913
+
914
+ ### Terminal Spawning Protocol
915
+ ```
916
+ 1. Identify parallelizable tasks in current pipeline position
917
+ 2. For each parallel task:
918
+ a. Create isolated write scope mapping
919
+ b. Prepare PRISM context with agent-specific domain
920
+ c. Spawn terminal with: agent file + context + write scope
921
+ 3. Monitor all terminals for:
922
+ - Completion (success/failure)
923
+ - Blocker detection (pause all if critical)
924
+ - Progress updates
925
+ 4. When all terminals complete:
926
+ a. Collect handoff files from all agents
927
+ b. Merge results into unified context
928
+ c. Continue pipeline with merged context
929
+ ```
930
+
931
+ ---
932
+
655
933
  ## Input
656
934
 
657
935
  $ARGUMENTS
@@ -0,0 +1,63 @@
1
+ ---
2
+ id: architect-api-design
3
+ agent: architect
4
+ trigger: architect-stack-selection
5
+ phase: clarity
6
+ requires_input: false
7
+ parallelizable: false
8
+ outputs: [api-design.yaml]
9
+ handoff_to: architect-db-design
10
+ autonomous_gate: true
11
+ criteria:
12
+ - All API endpoints specified with request/response schemas
13
+ - RESTful conventions followed
14
+ - Error responses documented
15
+ ---
16
+ # Design API Contracts
17
+
18
+ ## Purpose
19
+ Design complete API contracts with detailed request/response specifications.
20
+
21
+ ## Steps
22
+ Define endpoints:
23
+ - POST /api/auth/register
24
+ - POST /api/auth/login
25
+ - GET /api/posts
26
+ - POST /api/posts
27
+ - GET /api/posts/:id
28
+ - PUT /api/posts/:id
29
+ - DELETE /api/posts/:id
30
+ - GET /api/search
31
+
32
+ For each: method, path, auth required, request schema, response schema, error codes.
33
+
34
+ Use OpenAPI/Swagger format.
35
+
36
+ ## Output Format
37
+ ```yaml
38
+ # api-design.yaml
39
+ openapi: 3.0.0
40
+ paths:
41
+ /api/auth/register:
42
+ post:
43
+ summary: Register new user
44
+ requestBody:
45
+ schema:
46
+ type: object
47
+ properties:
48
+ email: {type: string, format: email}
49
+ password: {type: string, minLength: 8}
50
+ required: [email, password]
51
+ responses:
52
+ 201:
53
+ description: User created
54
+ content:
55
+ application/json:
56
+ schema:
57
+ type: object
58
+ properties:
59
+ user: {type: object}
60
+ token: {type: string}
61
+ 400: {description: Validation error}
62
+ 409: {description: Email already exists}
63
+ ```
@@ -0,0 +1,47 @@
1
+ ---
2
+ id: architect-consolidate
3
+ agent: architect
4
+ trigger: architect-security-review
5
+ phase: clarity
6
+ requires_input: false
7
+ parallelizable: false
8
+ outputs: [architecture-final.yaml]
9
+ handoff_to: phases
10
+ autonomous_gate: true
11
+ criteria:
12
+ - All architecture artifacts consolidated
13
+ - Architecture Decision Records documented
14
+ - Complete architecture package ready
15
+ ---
16
+ # Consolidate Architecture Documentation
17
+
18
+ ## Purpose
19
+ Merge all architecture artifacts into final comprehensive architecture document.
20
+
21
+ ## Steps
22
+ Combine: architecture.yaml, stack-selection.yaml, api-design.yaml, db-design.yaml, security-review.yaml
23
+
24
+ Add:
25
+ - System architecture diagram
26
+ - Deployment architecture
27
+ - ADRs for major decisions
28
+
29
+ ## Output Format
30
+ ```yaml
31
+ # architecture-final.yaml
32
+ timestamp: 2026-02-13T16:30:00Z
33
+ completeness: 100%
34
+ [All architecture details consolidated]
35
+ architecture_decisions:
36
+ - id: ADR-001
37
+ title: Use Supabase as Backend-as-a-Service
38
+ decision: Use Supabase instead of custom Node.js backend
39
+ rationale: Team lacks backend expertise, Supabase provides auth, database, storage
40
+ status: accepted
41
+ - id: ADR-002
42
+ title: Use TanStack Query for server state
43
+ decision: Use TanStack Query instead of Redux
44
+ rationale: Server state caching, automatic refetching, simpler than Redux
45
+ status: accepted
46
+ next_phase: phases
47
+ ```
@@ -0,0 +1,73 @@
1
+ ---
2
+ id: architect-db-design
3
+ agent: architect
4
+ trigger: architect-api-design
5
+ phase: clarity
6
+ requires_input: false
7
+ parallelizable: false
8
+ outputs: [db-design.yaml]
9
+ handoff_to: architect-security-review
10
+ autonomous_gate: true
11
+ criteria:
12
+ - Database schema defined with all tables and relationships
13
+ - Indexes specified for query optimization
14
+ - Constraints documented
15
+ ---
16
+ # Design Database Schema
17
+
18
+ ## Purpose
19
+ Create complete database schema with tables, relationships, indexes, and constraints.
20
+
21
+ ## Steps
22
+ Define tables:
23
+ - users (id, email, password_hash, created_at, updated_at)
24
+ - posts (id, user_id, title, content, tags, image_urls, published_at, created_at, updated_at)
25
+
26
+ Define indexes:
27
+ - users.email (unique)
28
+ - posts.user_id (foreign key, indexed)
29
+ - posts.published_at (for sorting)
30
+ - posts.tags (GIN index for array search in PostgreSQL)
31
+
32
+ Document relationships and cascade rules.
33
+
34
+ ## Output Format
35
+ ```yaml
36
+ # db-design.yaml
37
+ tables:
38
+ users:
39
+ columns:
40
+ id: uuid PRIMARY KEY DEFAULT gen_random_uuid()
41
+ email: text UNIQUE NOT NULL
42
+ password_hash: text NOT NULL
43
+ created_at: timestamp with time zone DEFAULT now()
44
+ updated_at: timestamp with time zone DEFAULT now()
45
+ indexes:
46
+ - name: idx_users_email
47
+ columns: [email]
48
+ unique: true
49
+ posts:
50
+ columns:
51
+ id: uuid PRIMARY KEY DEFAULT gen_random_uuid()
52
+ user_id: uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE
53
+ title: text NOT NULL CHECK (length(title) <= 200)
54
+ content: text NOT NULL
55
+ tags: text[] DEFAULT '{}'
56
+ image_urls: text[] DEFAULT '{}'
57
+ published_at: timestamp with time zone
58
+ created_at: timestamp with time zone DEFAULT now()
59
+ updated_at: timestamp with time zone DEFAULT now()
60
+ indexes:
61
+ - name: idx_posts_user_id
62
+ columns: [user_id]
63
+ - name: idx_posts_published_at
64
+ columns: [published_at]
65
+ - name: idx_posts_tags
66
+ columns: [tags]
67
+ type: GIN
68
+ relationships:
69
+ - from: posts.user_id
70
+ to: users.id
71
+ type: many_to_one
72
+ on_delete: CASCADE
73
+ ```