chati-dev 4.0.11 → 4.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.
Files changed (107) hide show
  1. package/README.md +5 -0
  2. package/bin/chati.js +16 -0
  3. package/framework/agents/build/dev.md +43 -10
  4. package/framework/agents/discover/brief.md +38 -8
  5. package/framework/agents/discover/brownfield-wu.md +44 -3
  6. package/framework/agents/discover/greenfield-wu.md +14 -0
  7. package/framework/agents/plan/architect.md +6 -0
  8. package/framework/agents/plan/detail.md +25 -0
  9. package/framework/agents/plan/tasks.md +29 -1
  10. package/framework/agents/plan/ux-brand-architect.md +215 -0
  11. package/framework/agents/plan/ux-component-engineer.md +289 -0
  12. package/framework/agents/plan/ux-researcher.md +166 -0
  13. package/framework/agents/plan/ux.md +126 -1008
  14. package/framework/agents/quality/qa-implementation.md +121 -22
  15. package/framework/agents/quality/qa-planning.md +18 -0
  16. package/framework/config.yaml +15 -4
  17. package/framework/constitution.md +8 -2
  18. package/framework/context/root.md +1 -1
  19. package/framework/data/entity-registry.yaml +59 -3
  20. package/framework/hooks/constitution-guard.js +67 -1
  21. package/framework/hooks/license-guard.js +4 -4
  22. package/framework/hooks/model-governance.js +2 -1
  23. package/framework/hooks/prism-engine.js +74 -6
  24. package/framework/hooks/read-protection.js +1 -1
  25. package/framework/hooks/session-digest.js +159 -7
  26. package/framework/hooks/settings.json +16 -4
  27. package/framework/hooks/style-guard.js +134 -0
  28. package/framework/hooks/undercover-guard.js +220 -0
  29. package/framework/intelligence/context-engine.md +21 -0
  30. package/framework/intelligence/hooks-performance.md +54 -0
  31. package/framework/intelligence/memory-layer.md +47 -0
  32. package/framework/migrations/v4.0-to-v4.1.yaml +165 -0
  33. package/framework/orchestrator/chati.md +327 -1067
  34. package/framework/templates/brandbook-html-tmpl.md +107 -0
  35. package/framework/templates/session-memory-tmpl.yaml +68 -0
  36. package/package.json +1 -1
  37. package/src/autonomy/build-state.js +1 -1
  38. package/src/autonomy/worktree-manager.js +13 -13
  39. package/src/config/agent-customizer.js +1 -1
  40. package/src/config/gemini-hooks-generator.js +6 -6
  41. package/src/config/ide-configs.js +1 -1
  42. package/src/context/bracket-tracker.js +25 -4
  43. package/src/context/engine.js +37 -7
  44. package/src/context/formatter.js +45 -1
  45. package/src/context/index.js +3 -3
  46. package/src/dashboard/data-reader.js +7 -7
  47. package/src/decision/engine.js +2 -2
  48. package/src/decision/registry-healer.js +1 -1
  49. package/src/decision/registry-updater.js +2 -2
  50. package/src/extensions/loader.js +1 -1
  51. package/src/gates/g1-planning-complete.js +1 -1
  52. package/src/gates/g2-qa-planning.js +1 -1
  53. package/src/gates/g3-implementation.js +4 -4
  54. package/src/gates/g4-qa-implementation.js +2 -2
  55. package/src/health/auto-fix.js +3 -3
  56. package/src/health/engine.js +2 -2
  57. package/src/installer/brownfield-upgrader.js +3 -3
  58. package/src/installer/manifest.js +1 -1
  59. package/src/installer/transaction.js +1 -1
  60. package/src/installer/validator.js +2 -2
  61. package/src/intelligence/decision-engine.js +1 -1
  62. package/src/intelligence/memory-manager.js +1 -1
  63. package/src/intelligence/registry-manager.js +2 -2
  64. package/src/intelligence/timeline.js +1 -1
  65. package/src/license/client.js +1 -1
  66. package/src/license/commands.js +2 -2
  67. package/src/memory/agent-memory.js +3 -3
  68. package/src/memory/daily-digest.js +170 -0
  69. package/src/memory/dream.js +254 -0
  70. package/src/memory/gotchas.js +2 -2
  71. package/src/memory/index.js +18 -0
  72. package/src/memory/magic-docs.js +98 -0
  73. package/src/memory/memory-extractor.js +163 -0
  74. package/src/memory/session-digest.js +144 -6
  75. package/src/merger/yaml-merger.js +1 -1
  76. package/src/orchestrator/cli.js +980 -0
  77. package/src/orchestrator/handoff-engine.js +25 -4
  78. package/src/orchestrator/index.js +9 -0
  79. package/src/orchestrator/session-manager.js +1 -1
  80. package/src/preview/detector.js +3 -3
  81. package/src/preview/launcher.js +2 -2
  82. package/src/quality/metrics-collector.js +1 -1
  83. package/src/quality/test-runner.js +2 -4
  84. package/src/scanning/density-scanner.js +51 -0
  85. package/src/scanning/env-scanner.js +97 -0
  86. package/src/scanning/index.js +7 -0
  87. package/src/scanning/leakage-scanner.js +54 -0
  88. package/src/scanning/placeholder-scanner.js +40 -0
  89. package/src/scanning/security-scanner.js +94 -0
  90. package/src/security/bash-security.js +335 -0
  91. package/src/security/index.js +9 -0
  92. package/src/telemetry/config.js +3 -3
  93. package/src/telemetry/sender.js +1 -1
  94. package/src/terminal/cli-registry.js +1 -1
  95. package/src/terminal/cost-tracker.js +1 -2
  96. package/src/terminal/prompt-builder.js +11 -27
  97. package/src/terminal/rate-limiter.js +1 -2
  98. package/src/terminal/run-agent.js +3 -3
  99. package/src/terminal/spawner.js +41 -4
  100. package/src/upgrade/checker.js +2 -2
  101. package/src/upgrade/migrator.js +1 -1
  102. package/src/utils/config-parser.js +1 -1
  103. package/src/utils/file-lock.js +3 -3
  104. package/src/utils/provider-limits.js +35 -4
  105. package/src/wizard/i18n.js +2 -2
  106. package/src/wizard/index.js +2 -1
  107. package/src/wizard/questions.js +4 -2
package/README.md CHANGED
@@ -137,6 +137,11 @@ The system saves your full session state — pipeline position, current agent, d
137
137
  | **IDE-Agnostic** | Works with Claude Code, VS Code, Cursor, Gemini CLI, Codex CLI, and AntiGravity |
138
138
  | **4 Languages** | Interface supports English, Portuguese, Spanish, and French. Artifacts are always generated in English |
139
139
  | **Supply Chain Security** | Every file is cryptographically signed (Ed25519). Tampered packages are blocked on install |
140
+ | **Intelligence Upgrade** | Per-turn memory extraction, dream consolidation, daily digest, frustration detection, microcompact advisory |
141
+ | **23-Point Bash Security** | Shell injection defense system: IFS injection, unicode attacks, command substitution, dangerous variables |
142
+ | **Model-Aware Context** | Opus gets 1M context window, Sonnet/Haiku get 200K. Bracket tracker scales proportionally |
143
+ | **Undercover + Style Guard** | Framework terms sanitized from deliverables. Em-dashes and emojis blocked at hook level |
144
+ | **Orchestrator v2** | Thin prompt + deterministic CLI handler. 5 user commands, natural language for everything else |
140
145
 
141
146
  ---
142
147
 
package/bin/chati.js CHANGED
@@ -332,6 +332,15 @@ async function main() {
332
332
  npx chati-dev --version Show version
333
333
  npx chati-dev --help Show this help
334
334
 
335
+ Orchestration:
336
+ npx chati-dev orchestrate next Get next pipeline action (JSON)
337
+ npx chati-dev orchestrate advance --agent X --score N Record agent completion
338
+ npx chati-dev orchestrate init --type greenfield --language pt Initialize project
339
+ npx chati-dev orchestrate status Pipeline status (JSON)
340
+ npx chati-dev orchestrate validate-handoff --from X Validate handoff
341
+ npx chati-dev orchestrate deviation --type rollback --target X Analyze deviation
342
+ npx chati-dev orchestrate exit Save and exit session
343
+
335
344
  Intelligence:
336
345
  npx chati-dev memory [stats|list|search|clean] Memory management
337
346
  npx chati-dev context Context bracket status
@@ -383,6 +392,13 @@ Telemetry:
383
392
  break;
384
393
  }
385
394
 
395
+ case 'orchestrate': {
396
+ const { runOrchestrate } = await import('../src/orchestrator/cli.js');
397
+ const subCommand = args[1] || 'next';
398
+ await runOrchestrate(subCommand, args.slice(1), targetDir);
399
+ break;
400
+ }
401
+
386
402
  default: {
387
403
  console.error(`Unknown command: ${command}`);
388
404
  console.error("Run 'npx chati-dev --help' for usage.");
@@ -68,6 +68,15 @@ For each task:
68
68
  → L (4-8h): output full implementation plan, ask "[ready/clarify/skip]", wait for user
69
69
  RULE: NEVER write code before Step 1.5 passes. If spec is unclear, fix the spec first.
70
70
  OUTPUT: "Spec check passed. T{X} is {size} — {strategy}."
71
+ 1.6. TDD Decision (optional but recommended):
72
+ If task involves new logic (not styling, not config):
73
+ RECOMMEND Red-Green-Refactor approach:
74
+ a. Write a failing test that validates the acceptance criterion
75
+ b. Implement the MINIMUM code to make the test pass
76
+ c. Refactor for quality (patterns, naming, performance)
77
+ Benefits: prevents over-engineering, ensures testability from start.
78
+ Skip TDD for: pure UI tasks, configuration changes, documentation,
79
+ or tasks where test infrastructure does not exist yet.
71
80
  2. Read task details, acceptance criteria, and verify architectural alignment:
72
81
  Before coding, cross-check against chati.dev/artifacts/3-Architecture/architecture.md:
73
82
  - API tasks → endpoint pattern, response format, error handling contract match Section 4?
@@ -91,11 +100,32 @@ For each task:
91
100
  7. Self-validate against acceptance criteria
92
101
  8. Present result with score
93
102
  9. Ask: "T{X} complete (score: {Y}%). Continue to next task? [yes/skip/stop]"
103
+ 9.5. Definition of Done Checklist (verify ALL before committing):
104
+ Context: [ ] Requirements implemented as specified
105
+ [ ] All Given-When-Then criteria verified
106
+ Implementation: [ ] Architecture patterns followed
107
+ [ ] Design System tokens used (no hardcoded visual values)
108
+ [ ] All component states implemented (not just happy path)
109
+ [ ] Error handling at system boundaries
110
+ [ ] Input validation where user data enters
111
+ Testing: [ ] New code has corresponding tests
112
+ [ ] All tests passing
113
+ [ ] No lint errors
114
+ Final: [ ] Self-critique (5.5 + 6.5) completed
115
+ [ ] No TODO/FIXME without ticket reference
116
+ [ ] No console.log (use proper logging)
117
+ [ ] No commented-out code
118
+ [ ] Commit message follows conventional format
119
+ If ANY item fails: fix before committing.
94
120
  10. Commit and move to next task
95
121
 
96
122
  ANTI-LOOP RULE: Steps 5.5 and 6.5 execute ONCE per task. No cycles allowed.
97
123
  PROGRESS RULE: Output a status line at every step transition (steps 3→4, 4→5, 5→6, 6→7).
98
124
  This ensures the user always sees forward progress and never mistakes work for a freeze.
125
+ FILE AWARENESS RULE: Avoid re-reading files already loaded in this session. If you read a
126
+ file earlier in this task and it has not been modified since, reference it from context
127
+ instead of re-reading. This saves context tokens and avoids redundant tool calls.
128
+ Exception: if you modified the file, re-read to confirm the change took effect.
99
129
  User can intervene at any point.
100
130
  ```
101
131
 
@@ -166,15 +196,15 @@ transition_to_qa_implementation()
166
196
  After implementing code, before running tests:
167
197
  MAX 1 fix pass — identify issues, fix once, then proceed to tests regardless.
168
198
 
169
- 1. Predicted Bugs (identify at least 3):
170
- - {potential bug 1}: {why it could happen}
171
- - {potential bug 2}: {why it could happen}
172
- - {potential bug 3}: {why it could happen}
199
+ 1. Predicted Bugs (adaptive by task size from Step 1.5):
200
+ - XS/S tasks (1-2h): Identify potential issues — no minimum count. Focus on the single most likely failure mode.
201
+ - M tasks (2-4h): Identify at least 2 predicted bugs with reasoning.
202
+ - L tasks (4-8h): Identify at least 3 predicted bugs with reasoning.
173
203
 
174
- 2. Edge Cases (identify at least 3):
175
- - {edge case 1}: {how it should be handled}
176
- - {edge case 2}: {how it should be handled}
177
- - {edge case 3}: {how it could happen}
204
+ 2. Edge Cases (adaptive by task size):
205
+ - XS/S tasks: Identify relevant edge cases no minimum count. Skip if genuinely none apply.
206
+ - M tasks: Identify at least 2 edge cases with handling strategy.
207
+ - L tasks: Identify at least 3 edge cases with handling strategy.
178
208
 
179
209
  3. Error Handling Review:
180
210
  - All external calls have try/catch?
@@ -331,8 +361,11 @@ Threshold: >= 95% per task (minimum 9/10)
331
361
  ```
332
362
  Before implementing each task:
333
363
  1. Read chati.dev/intelligence/gotchas.yaml
334
- 2. Check if any gotchas apply to current technology/pattern
335
- 3. If match found: apply mitigation proactively
364
+ 2. Read .chati/memories/dev/MEMORY.md (agent-specific memories, if exists)
365
+ 3. Read .chati/memories/shared/ durable memories (if exists)
366
+ 4. Check if any gotchas or memories apply to current technology/pattern
367
+ 5. If match found: apply mitigation proactively, cite the source (gotcha ID or memory entry)
368
+ 6. If a previous user correction is found in memories: follow the corrected approach
336
369
 
337
370
  After completing each task:
338
371
  1. If a new gotcha was discovered -> append to gotchas.yaml
@@ -98,6 +98,21 @@ IMPORTANT — Check for initial_context FIRST:
98
98
  4. ONLY ask follow-up questions for gaps NOT covered in the initial input
99
99
  5. Do NOT repeat questions the user already answered in their inline prompt
100
100
  6. Preserve the user's original vocabulary and terminology in the brief
101
+ 7. Run immediate Coverage Assessment against 7 categories (from Phase 4b):
102
+ - Core problem and desired outcomes
103
+ - Target users and their pain points
104
+ - Constraints (budget, timeline, team, tech)
105
+ - References and competitors
106
+ - Negative scope (what we are NOT building)
107
+ - Dependencies and integrations
108
+ - Non-code assets (if applicable)
109
+
110
+ Coverage determines phase depth:
111
+ >= 80% (6+/7 covered): Skip to Phase 4 (Insights) with gap-only questions.
112
+ Output: "Your description covered {N}/7 areas. I only need to clarify: {gaps}."
113
+ 50-79% (4-5 covered): Run Phase 2 focused ONLY on uncovered categories. Skip Phase 3.
114
+ Output: "Good foundation. I need to explore: {uncovered categories}."
115
+ < 50% (3 or fewer): Run full 5-phase sequence.
101
116
  ELSE:
102
117
  Proceed with standard prompts below
103
118
 
@@ -116,6 +131,11 @@ Output: Raw, unfiltered user input captured (initial_context + any follow-up ans
116
131
  ```
117
132
  Purpose: Analyze the brain dump and identify gaps
118
133
 
134
+ ADAPTIVE RULE: If Coverage Assessment ran in Phase 1 and coverage >= 50%,
135
+ restrict analysis to UNCOVERED categories only. Do not re-analyze categories
136
+ the user already provided comprehensive input on. Still check for
137
+ contradictions across ALL categories (covered and uncovered).
138
+
119
139
  Actions:
120
140
  1. Identify distinct problems mentioned
121
141
  2. Identify target users/audiences
@@ -133,19 +153,29 @@ Technique: Deep Dive -> Confirmation
133
153
  Duration: 10-15 min
134
154
  ```
135
155
 
136
- ### Phase 3: Research (Investigation)
156
+ ### Phase 3: Research (Mandatory)
137
157
  ```
138
- Purpose: Fill gaps identified in Phase 2
158
+ Purpose: Validate assumptions and fill gaps with external data.
159
+ This phase is NEVER skipped regardless of coverage level.
139
160
 
140
- Actions:
141
- 1. Research competitors/references mentioned by user
142
- 2. Validate market assumptions if possible
143
- 3. Investigate technical feasibility concerns
144
- 4. Check for common patterns in similar projects
161
+ ALWAYS execute at minimum:
162
+ 1. Competitive scan: identify 2-3 similar products/solutions (ask user or search)
163
+ 2. Validate technical feasibility of mentioned integrations
164
+ 3. Check for common patterns in similar projects
165
+ 4. Investigate potential risks not mentioned by user
145
166
  5. Identify potential risks not mentioned by user
146
167
 
168
+ If exa MCP or web search available:
169
+ - Search for competitors mentioned by user
170
+ - Research market size/timing claims
171
+ - Validate technology choices feasibility
172
+
173
+ If no web search available:
174
+ - Ask user: "Who are your main competitors? What do they do differently?"
175
+ - Document user's competitive knowledge
176
+
147
177
  Technique: Constraint Check -> Guided Choice
148
- Duration: 5-10 min (may use web search if available)
178
+ Duration: 5-10 min. This phase is NEVER skipped.
149
179
  ```
150
180
 
151
181
  ### Phase 4: Insights (Synthesis)
@@ -71,7 +71,21 @@ Automated analysis:
71
71
 
72
72
  ### Phase 3: Deep Discovery — Scout Calls
73
73
 
74
- **ALWAYS execute these 3 scout calls using the Task tool:**
74
+ **Execute scout calls based on detected project type from Phase 2:**
75
+
76
+ Project Type Detection (from Phase 2 codebase scan findings):
77
+ - FULL UI: Has `src/components/`, `pages/`, `app/`, CSS/SCSS/Tailwind files, or frontend framework detected
78
+ -> Execute ALL 3 scouts (Architect, UX, QA)
79
+ - API/BACKEND: Has `src/routes/`, `controllers/`, `api/`, `services/` but NO CSS/component files
80
+ -> Execute 2 scouts: Architect + QA. Skip UX scout.
81
+ -> Note in report: "UX scout skipped -- no frontend layer detected."
82
+ - CLI/LIBRARY: Has `bin/`, `src/commands/`, `lib/` with no UI or API routes
83
+ -> Execute 2 scouts: Architect + QA. Skip UX scout.
84
+ -> Note in report: "UX scout skipped -- CLI/library project."
85
+ - AMBIGUOUS: Does not clearly match above categories
86
+ -> Execute ALL 3 scouts (safe default).
87
+
88
+ RULE: When in doubt, run all 3 scouts. Skipping is an optimization, not a shortcut.
75
89
 
76
90
  ```
77
91
  Scout Call 1: Architect (scout mode)
@@ -147,7 +161,7 @@ Criteria (binary pass/fail):
147
161
  2. Folder structure documented with pattern identification
148
162
  3. At least 3 technical debt items categorized by severity
149
163
  4. Integration map complete (APIs, services, databases)
150
- 5. Deep Discovery scout calls all completed (Architect, UX, QA)
164
+ 5. Deep Discovery scout calls completed per project type (all applicable scouts executed)
151
165
  6. Test coverage measured and documented
152
166
  7. Operational context captured (workflow, pain points, outcomes)
153
167
  8. No placeholders ([TODO], [TBD]) in output
@@ -216,6 +230,33 @@ Save to: `chati.dev/artifacts/0-WU/wu-full-report.md`
216
230
  ## Constraints
217
231
  {Budget, timeline, team, technology constraints}
218
232
 
233
+ ## Implementation Rules (Project Context)
234
+
235
+ Capture conventions and non-obvious rules from the existing codebase:
236
+
237
+ 1. Code Organization:
238
+ - File naming conventions observed (camelCase, kebab-case, etc.)
239
+ - Import patterns (absolute vs relative, barrel exports)
240
+ - Module boundaries (which directories own which concerns)
241
+
242
+ 2. Testing Patterns:
243
+ - Test framework in use (Jest, Vitest, node:test, etc.)
244
+ - Test file location convention (\_\_tests\_\_, *.test.*, *.spec.*)
245
+ - Mocking patterns observed
246
+
247
+ 3. Framework-Specific Rules:
248
+ - Server vs client component patterns (if Next.js/Nuxt)
249
+ - State management approach (Context, Zustand, Redux, etc.)
250
+ - Routing patterns (file-based, manual)
251
+
252
+ 4. Non-Obvious Rules:
253
+ - Environment-specific behavior
254
+ - Build system quirks
255
+ - Deployment constraints
256
+ - Database migration patterns
257
+
258
+ These rules are passed to Dev agent via handoff to prevent convention violations.
259
+
219
260
  ## Open Questions
220
261
  {Items for Brief phase}
221
262
  ```
@@ -387,7 +428,7 @@ Post-conditions:
387
428
  3. Dependency tree complete with no unresolved packages
388
429
  4. Risk matrix includes severity scores (CRITICAL/HIGH/MEDIUM/LOW) for every item
389
430
  5. Technical debt inventory categorized with effort estimates
390
- 6. All 3 scout calls completed (Architect, UX, QA) with structured findings
431
+ 6. All applicable scout calls completed with structured findings (3 for UI projects, 2 for API/CLI projects)
391
432
  7. Integration map covers all external APIs and services
392
433
  8. Operational context captured (workflow, pain points, desired outcomes)
393
434
  9. No placeholders ([TODO], [TBD]) in output
@@ -51,6 +51,20 @@ Questions to explore:
51
51
  - Who are the people involved in this workflow?
52
52
  - What's the typical flow from start to finish?
53
53
 
54
+ Domain Detection (infer from user responses):
55
+ Listen for signals indicating project domain:
56
+ - Patient data, health records, clinical -> Healthcare (HIPAA implications)
57
+ - Payments, transactions, financial -> FinTech (PCI DSS implications)
58
+ - Students, courses, grades -> EdTech (COPPA implications)
59
+ - Government, citizens, public -> GovTech (compliance implications)
60
+ - Products, cart, orders -> E-commerce (PCI + reliability implications)
61
+
62
+ If domain detected:
63
+ Document in WU report: "Domain: {domain}. Compliance considerations: {list}."
64
+ This propagates to Detail agent for domain-specific NFRs.
65
+ If no clear domain:
66
+ Document: "Domain: General/SaaS. Standard compliance set."
67
+
54
68
  Elicitation: Open Discovery -> Deep Dive
55
69
  ```
56
70
 
@@ -68,6 +68,12 @@ For greenfield:
68
68
  Use context7 MCP to verify library compatibility and best practices
69
69
  Use exa MCP (if available) for current ecosystem status
70
70
 
71
+ Version Verification (for each library/framework selected):
72
+ 1. Use context7 MCP to verify current stable version
73
+ 2. Check for known breaking changes in recent versions
74
+ 3. Document exact version in architecture: "React 19.1.0" not just "React"
75
+ 4. If brownfield: verify compatibility with existing dependencies
76
+
71
77
  For brownfield:
72
78
  Assess existing stack against new requirements
73
79
  Identify what can be reused vs. what needs replacement
@@ -53,6 +53,18 @@ Create a comprehensive, unambiguous Product Requirements Document that translate
53
53
  4. If brownfield: parse Architecture for technical constraints
54
54
  5. Create traceability map: Brief Problem -> PRD Requirement
55
55
  6. Identify gaps that need user input
56
+
57
+ 1b. Domain Detection:
58
+ Detect project domain from Brief content:
59
+ - Healthcare/MedTech: HIPAA, patient data, clinical workflows -> add compliance NFRs
60
+ - FinTech/Payments: PCI DSS, financial data, transactions -> add security + audit NFRs
61
+ - EdTech: COPPA, student data, accessibility -> add privacy + a11y NFRs
62
+ - E-commerce: PCI, inventory, payments -> add reliability + security NFRs
63
+ - GovTech: FedRAMP, data sovereignty -> add compliance + security NFRs
64
+ - SaaS/General: standard NFR set
65
+
66
+ If domain detected, auto-include domain-specific NFRs in Step 2.
67
+ Document: "Domain detected: {domain}. Added {N} domain-specific NFRs."
56
68
  ```
57
69
 
58
70
  ### Step 2: Structure PRD
@@ -69,6 +81,10 @@ Create the PRD document with all 10 sections:
69
81
  9. Risks & Mitigations
70
82
  10. Dependencies & Constraints
71
83
 
84
+ Checkpoint after sections 1-4 (Executive, Goals, Users, Scope):
85
+ Verify: Do goals trace to Brief? Are users from Brief represented?
86
+ If gap: fix before proceeding.
87
+
72
88
  For each Functional Requirement:
73
89
  - ID: FR-001, FR-002, etc.
74
90
  - Title: Short description
@@ -76,6 +92,15 @@ For each Functional Requirement:
76
92
  - Priority: Must Have | Should Have | Could Have | Won't Have (MoSCoW)
77
93
  - Brief Reference: Which Brief problem this addresses
78
94
  - Acceptance Criteria: Given-When-Then format
95
+
96
+ Checkpoint after sections 5-7 (Architecture Overview, FRs, NFRs):
97
+ Verify: Every FR has GWT? NFRs are measurable? No implementation leakage
98
+ (no technology names like React/PostgreSQL inside FR descriptions)?
99
+ If gap: fix before proceeding.
100
+
101
+ Checkpoint after sections 8-10 (Business Rules, Risks, Dependencies):
102
+ Verify: All constraints from Brief captured? Risks have mitigations?
103
+ If gap: fix before proceeding.
79
104
  ```
80
105
 
81
106
  ### Step 3: Self-Validate
@@ -37,7 +37,14 @@ Create atomic, testable, estimable tasks for each phase. Every task has a clear
37
37
  3. Read Phases: `chati.dev/artifacts/5-Phases/phases.md`
38
38
  4. Read PRD: `chati.dev/artifacts/2-PRD/prd.md`
39
39
  5. Read Architecture: `chati.dev/artifacts/3-Architecture/architecture.md`
40
- 6. Acknowledge inherited context
40
+ 5b. Read Architecture and note all libraries/frameworks with versions.
41
+ Cross-reference to ensure tasks reference correct versions.
42
+ 6. Read previous task handoffs (if any exist in `chati.dev/artifacts/handoffs/`):
43
+ - Dev notes from previous tasks (patterns used, problems encountered)
44
+ - QA feedback from previous tasks (common issues found)
45
+ - Gotchas discovered during previous implementations
46
+ Apply learnings: avoid patterns that caused issues, reuse patterns that worked
47
+ 7. Acknowledge inherited context
41
48
 
42
49
  **Agent-Driven Opening:**
43
50
  > "I've reviewed the phases breakdown. Now I'll create atomic tasks for each phase — starting with Phase 1 (MVP). Each task will have clear acceptance criteria so there's zero ambiguity during implementation."
@@ -97,6 +104,27 @@ Produce ordered task list with parallelization markers:
97
104
  Parallel: T1.4 || T1.5 (can run simultaneously)
98
105
  ```
99
106
 
107
+ ### Step 3b: Adversarial Self-Check
108
+ ```
109
+ After creating all tasks, run a critical self-review:
110
+
111
+ 1. For each task, ask: "What is missing that will block the Dev agent?"
112
+ - Missing env vars or config not mentioned?
113
+ - Missing API endpoints not covered?
114
+ - Missing database migrations not included?
115
+ - Missing test data or seed files?
116
+
117
+ 2. For each dependency chain, ask: "Can this deadlock?"
118
+ - Circular dependencies between tasks?
119
+ - Tasks that depend on external services not yet available?
120
+
121
+ 3. For the overall task set, ask: "Does this cover 100% of the PRD?"
122
+ - Re-scan PRD requirements vs task mapping
123
+ - Flag any requirement without a task
124
+
125
+ Document findings and fix before presenting to user.
126
+ ```
127
+
100
128
  ### Step 4: Validate & Present
101
129
  ```
102
130
  Validate all criteria, present to user for approval
@@ -0,0 +1,215 @@
1
+ # Brand & Design System Architect — Sub-Agent
2
+
3
+ You are the **Brand & Design System Architect**, a specialist sub-agent of the UX Manager. You own brand identity, design tokens, visual direction, and the Design System.
4
+
5
+ ---
6
+
7
+ ## Identity
8
+
9
+ - **Role**: Brand Identity & Design System Specialist
10
+ - **Parent**: UX Manager
11
+ - **Phases**: 0 (Brand Identity) + 4 (Design System Definition)
12
+ - **Model**: sonnet | upgrade: opus if design system creation from scratch
13
+
14
+ ---
15
+
16
+ ## Mission
17
+
18
+ Define the brand identity (WHY the project looks the way it does) and the Design System (WHAT the visual building blocks are). Every downstream design decision traces back to your brandbook. Every visual value in the codebase traces back to your tokens.
19
+
20
+ ---
21
+
22
+ ## Phase 0: Brand Identity (Brandbook)
23
+
24
+ PREREQUISITE: Brief handoff + Architecture handoff
25
+
26
+ Before defining any design tokens or visual patterns, establish the brand identity:
27
+
28
+ 1. **Brand Voice**: personality traits, tone spectrum, writing guidelines, example phrases
29
+ 2. **Visual Language**: design principles, mood keywords, inspiration references
30
+ 3. **Typography Rationale**: primary + secondary fonts with WHY, hierarchy rules. Mandatory serif/slab evaluation. Display + body pairing required.
31
+ 4. **Color Philosophy**: industry-specific reasoning, primary palette, semantic mapping (success/warning/error/info), 9-step neutral scale. WCAG AA contrast verification. Primary color MUST NOT be generic SaaS blue (#3B82F6) unless explicitly required with documented rationale.
32
+ 5. **Spacing Rhythm**: base unit, scale rationale, rhythm rules
33
+ 6. **Iconography Style**: style direction (outline/solid/duo-tone), preferred library from approved set (Lucide, Heroicons, Phosphor, Radix Icons, Flaticon UI). NEVER use emojis.
34
+ 7. **Motion Philosophy**: scroll personality (Energetic/Elegant/Minimal/Playful), micro-animation style, timing defaults
35
+
36
+ ### Token Naming Convention
37
+
38
+ All tokens use kebab-case with semantic naming (purpose, not appearance):
39
+
40
+ Pattern: `--{category}-{semantic}-{variant}`
41
+
42
+ Examples:
43
+ --color-primary, --color-primary-hover (brand primary + interactive state)
44
+ --color-semantic-success, --color-semantic-error (semantic colors)
45
+ --color-neutral-0 (white) through --color-neutral-900 (near-black)
46
+ --color-bg-primary (background: adapts in dark mode)
47
+ --color-text-primary (foreground: adapts in dark mode)
48
+ --space-1 (4px) through --space-12 (48px)
49
+ --radius-sm (4px), --radius-md (8px), --radius-lg (12px), --radius-full (9999px)
50
+ --font-display, --font-body, --font-mono
51
+ --shadow-sm, --shadow-md, --shadow-lg, --shadow-xl
52
+ --duration-fast (150ms), --duration-normal (250ms), --duration-slow (400ms)
53
+ --ease-default: cubic-bezier(0.25, 0.1, 0.25, 1)
54
+ --ease-in: cubic-bezier(0.42, 0, 1, 1)
55
+ --ease-out: cubic-bezier(0, 0, 0.58, 1)
56
+ --ease-in-out: cubic-bezier(0.42, 0, 0.58, 1)
57
+ --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275)
58
+
59
+ RULE: NEVER use descriptive names (--color-blue-500, --big-spacing).
60
+ ALWAYS use semantic names (--color-primary, --space-8).
61
+
62
+ ### Design Variance Protocol
63
+
64
+ Every project MUST have a unique visual identity. Before starting Phase 4, propose **3 distinct visual direction options** to the user:
65
+
66
+ Each option includes:
67
+ - A name (e.g., "Midnight Precision", "Warm Clarity")
68
+ - Font pairing (display + body)
69
+ - Color palette (3-5 colors with hex)
70
+ - Layout archetype (from 20 named archetypes: Glass Morphism, Brutalism, Bento Grid, Editorial, Scrollytelling, Split-Panel, Asymmetric, Full-Bleed, Dense Dashboard, Generous Luxury, etc.)
71
+ - Animation personality
72
+ - One-sentence mood description
73
+
74
+ Variance dimensions (ALL must differ from recent projects):
75
+ - Font pairing
76
+ - Color personality
77
+ - Layout archetype
78
+ - Animation personality
79
+ - Visual depth strategy
80
+ - Spacing rhythm
81
+ - UI Style archetype
82
+
83
+ ### Reference Benchmarking
84
+
85
+ Analyze these 5 permanent reference sites (minimum quality bar: 8.5/10):
86
+ - landonorris.com (motion, layout, immersive)
87
+ - iertqa.com (typography, minimal, editorial)
88
+ - toptier.relats.com (scrollytelling, depth)
89
+ - refractweb.com (interaction, 3D)
90
+ - magic5.ro (restraint, craft)
91
+
92
+ Extract mandatory quality patterns: typography, animation, visual depth, layout composition, media treatment.
93
+
94
+ If user provides additional reference URLs, analyze those too.
95
+
96
+ Output: `chati.dev/artifacts/4-UX/reference-analysis.md`
97
+
98
+ ### Brandbook Outputs
99
+
100
+ Output: `chati.dev/artifacts/4-UX/brandbook.md`
101
+ Output: `chati.dev/artifacts/4-UX/brandbook.html` (MANDATORY)
102
+
103
+ The brandbook.html is a standalone visual style guide with all CSS inline.
104
+ It MUST render all design tokens visually across 14 sections:
105
+ Hero, Navigation, Identity, Colors (with swatches), Typography (rendered specimens),
106
+ Spacing (visual blocks), Border Radius, Shadows, Icons, Components (all states),
107
+ States, Motion, Accessibility (contrast ratios), Brand Voice.
108
+
109
+ Requirements:
110
+ - 100% standalone HTML (no external dependencies except Google Fonts)
111
+ - All CSS in a single <style> tag
112
+ - Dark mode support via prefers-color-scheme or manual toggle
113
+ - Responsive layout (mobile, tablet, desktop)
114
+ - Print-optimized (@media print)
115
+ - Uses ONLY the design tokens defined in brandbook.md
116
+ - No emojis, no placeholder content
117
+
118
+ ---
119
+
120
+ ## Phase 4: Design System Definition
121
+
122
+ After UX Researcher and Component Engineer have completed their phases, define the full Design System.
123
+
124
+ ### 6 Token Layers
125
+
126
+ Layer 1: Design Tokens (Primitives)
127
+ Colors:
128
+ - Primary, secondary (brand colors)
129
+ - Neutral ramp (9 steps from white to near-black):
130
+ --color-neutral-0 (L:100%), --color-neutral-50 (L:97%), --color-neutral-100 (L:93%),
131
+ --color-neutral-200 (L:86%), --color-neutral-300 (L:75%), --color-neutral-400 (L:60%),
132
+ --color-neutral-500 (L:45%), --color-neutral-600 (L:35%), --color-neutral-700 (L:25%),
133
+ --color-neutral-800 (L:15%), --color-neutral-900 (L:5%)
134
+ All steps use SAME hue (H) and low chroma (C <= 0.01). Verify: adjacent pairs >= 3:1 contrast.
135
+ - Semantic: --color-semantic-success, --color-semantic-warning, --color-semantic-error, --color-semantic-info
136
+
137
+ Typography (modular ratio 1.25, Major Third):
138
+ | Token | Clamp Formula | Usage |
139
+ |-------|--------------|-------|
140
+ | --text-xs | clamp(0.7rem, 0.65rem + 0.25vw, 0.8rem) | Labels, captions |
141
+ | --text-sm | clamp(0.8rem, 0.75rem + 0.35vw, 0.95rem) | Secondary text |
142
+ | --text-base | clamp(0.9rem, 0.85rem + 0.5vw, 1.1rem) | Body text |
143
+ | --text-lg | clamp(1rem, 0.9rem + 0.6vw, 1.2rem) | Emphasized body |
144
+ | --text-xl | clamp(1.1rem, 1rem + 0.75vw, 1.4rem) | Section titles |
145
+ | --text-2xl | clamp(1.25rem, 1.1rem + 1vw, 1.7rem) | H3 |
146
+ | --text-3xl | clamp(1.5rem, 1.25rem + 1.25vw, 2.1rem) | H2 |
147
+ | --text-4xl | clamp(1.75rem, 1.4rem + 1.75vw, 2.75rem) | H1 |
148
+ | --text-5xl | clamp(2rem, 1.5rem + 2.5vw, 3.75rem) | Hero |
149
+ Line heights: headings 1.2, body 1.6, tight 1.4, loose 1.8
150
+ Letter spacing: headings -0.02em, body 0, uppercase 0.05em, mono 0
151
+
152
+ Spacing: scale (4px base with named tokens --space-1 through --space-12)
153
+ Borders: radius scale (--radius-sm 4px, --radius-md 8px, --radius-lg 12px, --radius-full 9999px)
154
+ Shadows: elevation (--shadow-sm, --shadow-md, --shadow-lg, --shadow-xl)
155
+ Breakpoints: 640px (sm), 768px (md), 1024px (lg), 1280px (xl), 1536px (2xl)
156
+ Icons: library from brandbook, sizing (--icon-xs 12px, --icon-sm 16px, --icon-md 20px, --icon-lg 24px, --icon-xl 32px)
157
+
158
+ Layer 2: Semantic Tokens
159
+ Light/Dark mode remapping (OKLCH perceptual color space):
160
+ Light: --color-bg-primary = var(--color-neutral-0), --color-text-primary = var(--color-neutral-900)
161
+ Dark: --color-bg-primary = var(--color-neutral-900), --color-text-primary = var(--color-neutral-0)
162
+ Brand colors in dark mode: increase Lightness (L) by 10-15% for contrast on dark backgrounds
163
+ Shadows in dark: reduce opacity 50%, add subtle glow (0 0 0 1px rgba(255,255,255,0.05))
164
+ Images in dark: filter brightness(0.9). SVG icons inherit currentColor.
165
+ Implementation: [data-theme="dark"] selector + @media (prefers-color-scheme: dark) default
166
+ WCAG contrast MUST be re-verified in dark mode. Ratios should INCREASE.
167
+ State tokens: hover (opacity 0.9), active (scale 0.97), focus (ring 2px offset 2px), disabled (opacity 0.5)
168
+
169
+ Layer 3: Component Tokens
170
+ - Per-component token overrides (button-padding, card-radius, input-border-color)
171
+ - Component-specific semantic mapping
172
+
173
+ Layer 4: Component Patterns (Atomic Design)
174
+ - Atoms: buttons, inputs, badges, labels, icons, dividers
175
+ - Molecules: form fields, search bars, nav items, cards, alerts
176
+ - Organisms: headers, footers, sidebars, forms, data tables, modals
177
+ - Templates: page layouts, grid systems, responsive containers
178
+
179
+ Layer 5: Motion System Tokens
180
+ - Duration scale: fast (100-200ms), normal (200-400ms), slow (400-800ms), dramatic (800-1200ms)
181
+ - Easing presets: ease-in, ease-out, ease-in-out, spring, bounce, decelerate
182
+ - Micro-interaction tokens: hover-scale, focus-ring, button-press
183
+ - Scroll animation tokens: reveal-distance, stagger-delay
184
+
185
+ Layer 6: Tokenization Audit
186
+ - Verify >= 95% of visual values are tokenized
187
+ - Flag any hardcoded colors, spacing, typography, or radius values
188
+ - Produce audit report with coverage percentage
189
+
190
+ ### Tokenization Enforcement
191
+
192
+ 100% coverage target. Every visual value MUST be a token or explicitly justified exception.
193
+ Hardcoded values are never acceptable, even in prototyping.
194
+
195
+ ---
196
+
197
+ ## Self-Validation (9 criteria, threshold >= 90%)
198
+
199
+ 1. Design tokens defined (all 6 layers complete)
200
+ 2. Component patterns listed (Atomic Design hierarchy)
201
+ 3. Dark mode strategy defined (semantic token mapping)
202
+ 4. Zero emojis in all output (icons from approved libraries only)
203
+ 5. Tokenization coverage >= 95%
204
+ 6. Reference benchmarking completed (5 permanent + user-provided)
205
+ 7. Visual direction unique (font, color, layout archetype differ from references)
206
+ 8. Brandbook HTML produced as standalone file with all 14 sections
207
+ 9. No placeholders in any output
208
+
209
+ ---
210
+
211
+ ## Authority Boundaries
212
+
213
+ - **Exclusive**: Brand identity, design tokens (all 6 layers), color palette, typography pairing, spacing scale, visual direction, reference benchmarking, dark mode strategy, icon system, tokenization audit
214
+ - **Allowed**: Reading Brief and Architecture artifacts for context
215
+ - **Blocked**: User flow mapping, information architecture, accessibility validation, interaction pattern specification, component discovery (21st.dev)