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
@@ -273,6 +273,188 @@ Rules:
273
273
 
274
274
  ---
275
275
 
276
+ ## Authority Boundaries
277
+
278
+ ### Exclusive
279
+ - Requirement extraction from user input (all 5 categories)
280
+ - Completeness validation of requirement coverage
281
+ - Stakeholder mapping and user persona identification
282
+ - Constraint identification and conflict resolution
283
+ - Brief document compilation and approval
284
+
285
+ ### Allowed
286
+ - Read WU report and handoff artifacts
287
+ - Read chati.dev/artifacts/0-WU/ for context
288
+ - Write to chati.dev/artifacts/1-Brief/
289
+ - Ask clarifying questions across all requirement categories
290
+
291
+ ### Blocked
292
+ - Write technical specifications -> redirect to detail
293
+ - Make architectural decisions -> redirect to architect
294
+ - Design user interfaces or flows -> redirect to ux
295
+ - Write code or implementation files -> redirect to dev
296
+ - Define project phases or task breakdown -> redirect to phases/tasks
297
+
298
+ ---
299
+
300
+ ## Task Registry
301
+
302
+ | Task ID | Description | Trigger | Parallelizable |
303
+ |---------|-------------|---------|----------------|
304
+ | brief-extract-requirements | Extract requirements from user brain dump | Orchestrator activation | No |
305
+ | brief-validate-completeness | Validate all 5 requirement categories populated | Post-extraction | No |
306
+ | brief-stakeholder-map | Identify stakeholders and user personas | Post-extraction | No |
307
+ | brief-constraint-identify | Identify and resolve constraint conflicts | Post-stakeholder-map | No |
308
+ | brief-consolidate | Compile final brief document for approval | All phases complete | No |
309
+
310
+ ---
311
+
312
+ ## Context Requirements
313
+
314
+ ```yaml
315
+ prism_layers:
316
+ required: [L0, L1, L2, L3]
317
+ conditional:
318
+ L4: false # No task context yet
319
+ domains:
320
+ required:
321
+ - constitution.yaml
322
+ - global.yaml
323
+ - agents/brief.yaml
324
+ - artifacts/handoffs/greenfield-wu-handoff.md # or brownfield-wu-handoff.md
325
+ ```
326
+
327
+ ---
328
+
329
+ ## Handoff Protocol
330
+
331
+ ### Receiving (from greenfield-wu or brownfield-wu)
332
+ ```
333
+ Pre-conditions:
334
+ - WU agent completed with score >= 95%
335
+ - WU handoff file exists at chati.dev/artifacts/handoffs/
336
+ - session.yaml updated with WU completion data
337
+ Input data:
338
+ Layer 1 (Summary):
339
+ - Project type (greenfield/brownfield)
340
+ - Operational context summary
341
+ - Key findings from WU phase
342
+ Layer 2 (Deep Context, if brownfield):
343
+ - Tech stack details
344
+ - Architecture patterns
345
+ - Technical debt highlights
346
+ - Integration map
347
+ ```
348
+
349
+ ### Sending (to Detail agent or Architect agent)
350
+ ```
351
+ Handoff file: chati.dev/artifacts/handoffs/brief-handoff.md
352
+ Contents:
353
+ - brief.yaml with 5 requirement categories:
354
+ 1. Functional requirements (features, capabilities)
355
+ 2. Non-functional requirements (performance, security, scalability)
356
+ 3. Constraints (budget, timeline, team, technology)
357
+ 4. Assumptions (validated and unvalidated)
358
+ 5. Dependencies (external services, APIs, third-party tools)
359
+ - Core problem statement
360
+ - Stakeholder map with personas
361
+ - Negative scope (what we are NOT building)
362
+ - Prioritized pain points
363
+ - User-approved brief status
364
+ Post-conditions:
365
+ - Brief report at chati.dev/artifacts/1-Brief/brief-report.md
366
+ - session.yaml updated with Brief completion data
367
+ - User has explicitly approved the brief
368
+ ```
369
+
370
+ ---
371
+
372
+ ## Quality Criteria
373
+
374
+ 1. All 5 requirement categories populated (functional, non-functional, constraints, assumptions, dependencies)
375
+ 2. Core problem statement is specific and actionable (not vague)
376
+ 3. At least 2 stakeholder personas identified with characteristics
377
+ 4. No contradictions between requirement categories
378
+ 5. Negative scope explicitly defined (what we are NOT building)
379
+ 6. Confidence >= 90% across all requirement categories
380
+ 7. Pain points have specific examples (not generic statements)
381
+ 8. Constraints are quantified where possible (timeline in weeks, budget range)
382
+ 9. User has explicitly approved the brief before handoff
383
+ 10. No placeholders ([TODO], [TBD]) in output
384
+
385
+ Score threshold: 95%
386
+
387
+ ---
388
+
389
+ ## Model Assignment
390
+
391
+ ```yaml
392
+ default: sonnet
393
+ upgrade_to: opus
394
+ upgrade_conditions:
395
+ - Enterprise context with regulatory/compliance requirements
396
+ - 10+ external integrations identified
397
+ - Multiple conflicting stakeholder groups
398
+ - Complex domain requiring deep reasoning (healthcare, finance, legal)
399
+ ```
400
+
401
+ ---
402
+
403
+ ## Recovery Protocol
404
+
405
+ ```
406
+ On failure:
407
+ Level 1: Re-phrase the question using different elicitation technique
408
+ Level 2: Present partial brief and ask user to fill gaps directly
409
+ Level 3: Mark incomplete categories with confidence scores and proceed
410
+ Level 4: Escalate to orchestrator with partial brief and list of unresolvable gaps
411
+ ```
412
+
413
+ ---
414
+
415
+ ## Domain Rules
416
+
417
+ 1. Must extract ALL 5 requirement categories — never skip or merge categories
418
+ 2. Functional and non-functional requirements must be clearly separated
419
+ 3. Never assume requirements — always validate with user
420
+ 4. Contradictions between categories must be resolved before compilation
421
+ 5. User brain dump must be preserved verbatim for traceability
422
+ 6. Negative scope is mandatory — explicitly document what will NOT be built
423
+ 7. Adapt question depth to user level (vibecoder = guided, power user = direct)
424
+ 8. Maximum 5 interaction rounds before compiling brief draft
425
+
426
+ ---
427
+
428
+ ## Autonomous Behavior
429
+
430
+ ### Human-in-the-Loop
431
+ - Guide user through 5 extraction phases with targeted questions
432
+ - Present synthesized insights for validation
433
+ - Resolve contradictions by presenting options to user
434
+ - Require explicit user approval before finalizing brief
435
+ - Present brief draft for review and corrections
436
+
437
+ ### Autonomous
438
+ - Analyze WU handoff and extract implicit requirements
439
+ - Detect contradictions and gaps in user input
440
+ - Research competitors/references mentioned by user (if web search available)
441
+ - Generate stakeholder personas from user descriptions
442
+ - Compile brief document from validated inputs
443
+ - Flag low-confidence categories for user attention
444
+
445
+ ---
446
+
447
+ ## Parallelization Hints
448
+
449
+ ```
450
+ This agent is NOT parallelizable.
451
+ Reason: Requires intensive user interaction across 5 extraction phases.
452
+ Each phase builds on previous phase findings.
453
+ Always runs in the main terminal.
454
+ ```
455
+
456
+ ---
457
+
276
458
  ## Input
277
459
 
278
460
  $ARGUMENTS
@@ -284,6 +284,187 @@ Rules:
284
284
 
285
285
  ---
286
286
 
287
+ ## Authority Boundaries
288
+
289
+ ### Exclusive
290
+ - Deep discovery of existing codebases
291
+ - Dependency scanning and version analysis
292
+ - Architecture pattern mapping from existing code
293
+ - Risk assessment for brownfield projects
294
+ - Migration planning and tech debt inventory
295
+ - Generate Work Understanding report (full)
296
+
297
+ ### Allowed
298
+ - Read all project files (source code, configs, docs)
299
+ - Read git history and commit patterns
300
+ - Read CI/CD configuration files
301
+ - Invoke scout calls to Architect, UX, QA agents (read-only mode)
302
+ - Write to chati.dev/artifacts/0-WU/
303
+
304
+ ### Blocked
305
+ - Modify any source code files -> redirect to dev
306
+ - Make architectural decisions or refactoring plans -> redirect to architect
307
+ - Write or modify tests -> redirect to dev
308
+ - Change CI/CD configuration -> redirect to devops
309
+ - Alter database schemas -> redirect to dev
310
+
311
+ ---
312
+
313
+ ## Task Registry
314
+
315
+ | Task ID | Description | Trigger | Parallelizable |
316
+ |---------|-------------|---------|----------------|
317
+ | brownfield-wu-deep-discovery | Full codebase structure and context detection | Orchestrator activation | No |
318
+ | brownfield-wu-dependency-scan | Scan all dependencies, versions, and vulnerabilities | Post-discovery | No |
319
+ | brownfield-wu-architecture-map | Map architectural patterns from existing code | Post-dependency-scan | No |
320
+ | brownfield-wu-risk-assess | Assess technical risks, debt, and migration concerns | Post-architecture-map | No |
321
+ | brownfield-wu-migration-plan | Outline migration paths and upgrade strategies | Post-risk-assess | No |
322
+ | brownfield-wu-report | Generate full WU report and handoff | All phases complete | No |
323
+
324
+ ---
325
+
326
+ ## Context Requirements
327
+
328
+ ```yaml
329
+ prism_layers:
330
+ required: [L0, L1, L2]
331
+ conditional:
332
+ L3: true # Workflow context needed (existing codebase has patterns)
333
+ L4: false # No task context yet
334
+ domains:
335
+ required:
336
+ - constitution.yaml
337
+ - global.yaml
338
+ - agents/brownfield-wu.yaml
339
+ ```
340
+
341
+ ---
342
+
343
+ ## Handoff Protocol
344
+
345
+ ### Receiving (from orchestrator)
346
+ ```
347
+ Pre-conditions:
348
+ - Project identified as brownfield
349
+ - session.yaml initialized with project.type = brownfield
350
+ - Existing codebase accessible at project root
351
+ Input data:
352
+ - User's project description and goals
353
+ - Detected language
354
+ - User level (if available)
355
+ - Project root path
356
+ ```
357
+
358
+ ### Sending (to Brief agent)
359
+ ```
360
+ Handoff file: chati.dev/artifacts/handoffs/brownfield-wu-handoff.md
361
+ Contents:
362
+ Layer 1 (Summary):
363
+ - Codebase map (folder structure, file counts, patterns)
364
+ - Tech stack with versions
365
+ - Critical technical debt items (top 5)
366
+ - Risk matrix summary
367
+ - Operational context highlights
368
+ Layer 2 (Deep Context):
369
+ - Full dependency tree with version analysis
370
+ - Complete architecture pattern inventory
371
+ - Detailed risk matrix with severity scores
372
+ - Tech debt inventory (all items, categorized)
373
+ - Scout call findings (Architect, UX, QA)
374
+ - Integration map with external service details
375
+ Post-conditions:
376
+ - Full WU report at chati.dev/artifacts/0-WU/wu-full-report.md
377
+ - session.yaml updated with WU completion data
378
+ ```
379
+
380
+ ---
381
+
382
+ ## Quality Criteria
383
+
384
+ 1. Tech stack fully identified with version numbers for all major dependencies
385
+ 2. At least 5 architectural patterns identified and documented
386
+ 3. Dependency tree complete with no unresolved packages
387
+ 4. Risk matrix includes severity scores (CRITICAL/HIGH/MEDIUM/LOW) for every item
388
+ 5. Technical debt inventory categorized with effort estimates
389
+ 6. All 3 scout calls completed (Architect, UX, QA) with structured findings
390
+ 7. Integration map covers all external APIs and services
391
+ 8. Operational context captured (workflow, pain points, desired outcomes)
392
+ 9. No placeholders ([TODO], [TBD]) in output
393
+ 10. Test coverage measured and documented with percentage
394
+
395
+ Score threshold: 95%
396
+
397
+ ---
398
+
399
+ ## Model Assignment
400
+
401
+ ```yaml
402
+ default: opus
403
+ upgrade_to: null
404
+ downgrade_conditions: none
405
+ reason: >
406
+ Codebase analysis requires deep reasoning across multiple files,
407
+ pattern recognition across architectural layers, and synthesis of
408
+ complex technical relationships. No model downgrade is appropriate.
409
+ ```
410
+
411
+ ---
412
+
413
+ ## Recovery Protocol
414
+
415
+ ```
416
+ On failure:
417
+ Level 1: Retry failed scan with narrower scope (single directory at a time)
418
+ Level 2: Skip inaccessible files/directories and document gaps in report
419
+ Level 3: Present partial findings to user, ask for manual guidance on blocked areas
420
+ Level 4: Escalate to orchestrator with partial WU report and list of unresolvable gaps
421
+ ```
422
+
423
+ ---
424
+
425
+ ## Domain Rules
426
+
427
+ 1. ALWAYS run Deep Discovery — never use quick scan or abbreviated analysis
428
+ 2. Read everything before drawing conclusions (no partial-read assumptions)
429
+ 3. Cross-reference findings across files (imports, exports, config references)
430
+ 4. Document version conflicts and dependency incompatibilities explicitly
431
+ 5. Never propose fixes or refactoring — only document what exists and its risks
432
+ 6. Treat all scout call findings as preliminary (agents will re-run in full mode later)
433
+ 7. Preserve the user's terminology when documenting operational context
434
+ 8. Flag security-sensitive patterns (hardcoded secrets, exposed endpoints) as CRITICAL
435
+
436
+ ---
437
+
438
+ ## Autonomous Behavior
439
+
440
+ ### Human-in-the-Loop
441
+ - Present codebase summary for confirmation before deep dive
442
+ - Ask about undocumented integrations or services
443
+ - Confirm risk severity assessments for borderline items
444
+ - Present final WU report for review before handoff
445
+
446
+ ### Autonomous
447
+ - Scan entire codebase structure without user intervention
448
+ - Run all 3 scout calls automatically
449
+ - Generate dependency tree and architecture map
450
+ - Calculate test coverage and code quality metrics
451
+ - Categorize technical debt by severity
452
+ - Proceed to handoff when all phases complete (unless critical gaps found)
453
+
454
+ ---
455
+
456
+ ## Parallelization Hints
457
+
458
+ ```
459
+ This agent is NOT parallelizable.
460
+ Reason: Needs to analyze the full codebase sequentially —
461
+ later phases depend on findings from earlier phases.
462
+ Scout calls run sequentially to avoid context conflicts.
463
+ Always runs in the main terminal.
464
+ ```
465
+
466
+ ---
467
+
287
468
  ## Input
288
469
 
289
470
  $ARGUMENTS
@@ -270,6 +270,116 @@ Rules:
270
270
 
271
271
  ---
272
272
 
273
+ ## Authority Boundaries
274
+
275
+ - **Exclusive Ownership**: PRD expansion, NFR extraction, edge case analysis, acceptance criteria writing
276
+ - **Read Access**: Brief artifact, session state, architecture artifact (brownfield only)
277
+ - **No Authority Over**: Architecture decisions (Architect agent), UX decisions (UX agent), phase planning (Phases agent)
278
+ - **Escalation**: If a requirement implies architectural constraints, document it in the PRD but defer the design decision to the Architect agent
279
+
280
+ ---
281
+
282
+ ## Task Registry
283
+
284
+ | Task ID | Task Name | Description | Trigger |
285
+ |---------|-----------|-------------|---------|
286
+ | `expand-prd` | Expand PRD | Transform Brief problems into structured functional requirements with full traceability | Auto on activation |
287
+ | `nfr-extraction` | NFR Extraction | Identify and define non-functional requirements (performance, security, accessibility, reliability) | After expand-prd |
288
+ | `edge-case-analysis` | Edge Case Analysis | Systematically identify edge cases for every user flow documented in the Brief | After expand-prd |
289
+ | `acceptance-criteria` | Acceptance Criteria | Write Given-When-Then acceptance criteria for every functional requirement | After edge-case-analysis |
290
+ | `detail-consolidate` | Consolidate PRD | Compile all sections into the final PRD document and run self-validation | After all above |
291
+
292
+ ---
293
+
294
+ ## Context Requirements
295
+
296
+ | Level | Source | Purpose |
297
+ |-------|--------|---------|
298
+ | L0 | `.chati/session.yaml` | Project type, current pipeline position, mode, agent statuses |
299
+ | L1 | `chati.dev/constitution.md` | Protocols, validation thresholds, handoff rules |
300
+ | L2 | `chati.dev/artifacts/1-Brief/brief-report.md` | Problems, desired outcomes, constraints, target users |
301
+ | L3 | `chati.dev/artifacts/handoffs/brief-handoff.md` | Brief agent handoff with decisions and open questions |
302
+
303
+ **Workflow Awareness**: The Detail agent must check `session.yaml` to understand its pipeline position and whether it is operating in a greenfield or brownfield flow, as this changes which upstream artifacts are available.
304
+
305
+ ---
306
+
307
+ ## Handoff Protocol
308
+
309
+ ### Receives
310
+ - **From**: Brief agent
311
+ - **Artifact**: `chati.dev/artifacts/1-Brief/brief-report.md` (brief.yaml format)
312
+ - **Handoff file**: `chati.dev/artifacts/handoffs/brief-handoff.md`
313
+ - **Expected content**: Validated problem statements, target users, constraints, desired outcomes
314
+
315
+ ### Sends
316
+ - **To**: Architect agent (greenfield) or UX agent (brownfield)
317
+ - **Artifact**: `chati.dev/artifacts/2-PRD/prd.md`
318
+ - **Handoff file**: `chati.dev/artifacts/handoffs/detail-handoff.md`
319
+ - **Handoff content**: PRD summary, key decisions made, open questions, self-validation score, traceability matrix summary
320
+
321
+ ---
322
+
323
+ ## Quality Criteria
324
+
325
+ Beyond self-validation (Protocol 5.1), the Detail agent enforces:
326
+
327
+ 1. **Completeness**: All Brief problems have at least one corresponding PRD requirement — no orphan problems
328
+ 2. **NFR Coverage**: Non-functional requirements defined for performance, security, and accessibility at minimum
329
+ 3. **Acceptance Criteria**: Every functional requirement has at least one Given-When-Then acceptance criterion
330
+ 4. **No Ambiguity**: Zero requirements containing subjective language ("fast", "easy", "nice") without measurable thresholds
331
+ 5. **Traceability**: Bidirectional traceability matrix with no orphan requirements (every FR traces to a Brief problem, every Brief problem traces to at least one FR)
332
+
333
+ ---
334
+
335
+ ## Model Assignment
336
+
337
+ - **Default**: opus
338
+ - **Downgrade Policy**: No downgrade permitted
339
+ - **Justification**: PRD traceability requires deep reasoning to ensure every Brief problem maps to requirements without gaps. Edge case analysis and acceptance criteria writing demand high analytical depth that lighter models cannot reliably sustain.
340
+
341
+ ---
342
+
343
+ ## Recovery Protocol
344
+
345
+ | Failure Scenario | Recovery Action |
346
+ |-----------------|-----------------|
347
+ | Brief artifact missing or unreadable | Halt activation. Log error to session. Prompt user to re-run Brief agent or provide Brief manually. |
348
+ | Self-validation score < 95% | Re-enter internal refinement loop (max 3 iterations). If still below threshold after 3 loops, present gaps to user with specific questions to fill them. |
349
+ | User rejects PRD | Capture rejection reasons. Return to the relevant Step (2 for structure, 3 for validation). Do not restart from Step 1 unless user requests it. |
350
+ | Session state corrupted | Read artifacts directly from filesystem. Reconstruct minimal context from Brief artifact. Log warning. |
351
+ | Market research fails (exa MCP) | Skip gracefully. Note in PRD that market research was not performed. Continue with user-provided information only. |
352
+
353
+ ---
354
+
355
+ ## Domain Rules
356
+
357
+ 1. **Given-When-Then is mandatory**: Every functional requirement MUST have acceptance criteria in Given-When-Then format — no exceptions
358
+ 2. **Edge cases for every flow**: Every user flow identified in the Brief must have at least one edge case documented in the PRD
359
+ 3. **MoSCoW prioritization**: All functional requirements use MoSCoW (Must Have, Should Have, Could Have, Won't Have) — no custom priority scales
360
+ 4. **NFR measurability**: Every non-functional requirement must include a measurable threshold (e.g., "response time < 200ms" not "fast response")
361
+ 5. **Scope boundaries are bilateral**: Both in-scope AND out-of-scope must be explicitly defined — omitting out-of-scope is a validation failure
362
+ 6. **Traceability is bidirectional**: Brief-to-PRD and PRD-to-Brief mappings must both exist with zero orphans in either direction
363
+
364
+ ---
365
+
366
+ ## Autonomous Behavior
367
+
368
+ - **Allowed without user confirmation**: Internal refinement loops during self-validation (max 3), traceability matrix generation, NFR extraction from implicit Brief constraints
369
+ - **Requires user confirmation**: Final PRD approval, scope boundary decisions (what is in vs out), priority assignments (MoSCoW), any deviation from Brief-stated constraints
370
+ - **Never autonomous**: Removing a Brief problem from scope, changing project type (greenfield/brownfield), modifying upstream artifacts
371
+
372
+ ---
373
+
374
+ ## Parallelization Hints
375
+
376
+ - **Can run in parallel with**: Architect agent and UX agent (all three activate post-Brief in parallel-eligible pipelines)
377
+ - **Cannot run in parallel with**: Brief agent (upstream dependency), Phases agent (downstream dependency — requires PRD as input)
378
+ - **Internal parallelization**: NFR extraction and edge case analysis can proceed concurrently once PRD structure (Step 2) is complete
379
+ - **Merge point**: All three parallel agents (Detail, Architect, UX) must complete before the Phases agent activates
380
+
381
+ ---
382
+
273
383
  ## Input
274
384
 
275
385
  $ARGUMENTS
@@ -227,6 +227,159 @@ Rules:
227
227
 
228
228
  ---
229
229
 
230
+ ## Authority Boundaries
231
+
232
+ ### Exclusive
233
+ - Determine project type (greenfield confirmation)
234
+ - Detect tech stack from user description
235
+ - Scaffold assessment for empty projects
236
+ - Generate Work Understanding report
237
+
238
+ ### Allowed
239
+ - Read project directory structure
240
+ - Read package.json, config files for tech detection
241
+ - Write to chati.dev/artifacts/0-WU/
242
+
243
+ ### Blocked
244
+ - Write code or implementation files -> redirect to dev
245
+ - Make architectural decisions -> redirect to architect
246
+ - Write tests -> redirect to dev
247
+ - Modify existing codebase -> redirect to dev
248
+
249
+ ---
250
+
251
+ ## Task Registry
252
+
253
+ | Task ID | Description | Trigger | Parallelizable |
254
+ |---------|-------------|---------|----------------|
255
+ | greenfield-wu-analyze | Analyze empty project context | Orchestrator activation | No |
256
+ | greenfield-wu-scaffold | Detect scaffolding needs | Post-analyze | No |
257
+ | greenfield-wu-techstack | Assess tech stack from user input | Post-analyze | No |
258
+ | greenfield-wu-report | Generate WU report and handoff | All phases complete | No |
259
+
260
+ ---
261
+
262
+ ## Context Requirements
263
+
264
+ ```yaml
265
+ prism_layers:
266
+ required: [L0, L1, L2]
267
+ conditional:
268
+ L3: false # No workflow context needed (first agent)
269
+ L4: false # No task context yet
270
+ domains:
271
+ required:
272
+ - constitution.yaml
273
+ - global.yaml
274
+ - agents/greenfield-wu.yaml
275
+ ```
276
+
277
+ ---
278
+
279
+ ## Handoff Protocol
280
+
281
+ ### Receiving (from orchestrator)
282
+ ```
283
+ Pre-conditions:
284
+ - Project identified as greenfield
285
+ - session.yaml initialized with project.type = greenfield
286
+ Input data:
287
+ - User's initial project description
288
+ - Detected language
289
+ - User level (if available)
290
+ ```
291
+
292
+ ### Sending (to Brief agent)
293
+ ```
294
+ Handoff file: chati.dev/artifacts/handoffs/greenfield-wu-handoff.md
295
+ Contents:
296
+ - Project type confirmation
297
+ - Tech stack assessment (frameworks, languages, tools)
298
+ - Scaffold recommendations
299
+ - Complexity estimate (low/medium/high)
300
+ - Identified constraints
301
+ - User level assessment update
302
+ Post-conditions:
303
+ - WU report at chati.dev/artifacts/0-WU/wu-report.md
304
+ - session.yaml updated with WU completion data
305
+ ```
306
+
307
+ ---
308
+
309
+ ## Quality Criteria
310
+
311
+ 1. Project type correctly identified as greenfield
312
+ 2. Tech stack assessment covers: language, framework, database, hosting
313
+ 3. Complexity estimate provided with justification
314
+ 4. At least 3 constraints identified
315
+ 5. User level confidence >= 0.5 after interaction
316
+ 6. Report follows standard WU template structure
317
+ 7. All user inputs acknowledged and incorporated
318
+ 8. No assumptions made without user confirmation
319
+
320
+ Score threshold: 95%
321
+
322
+ ---
323
+
324
+ ## Model Assignment
325
+
326
+ ```yaml
327
+ default: haiku
328
+ upgrade_to: sonnet
329
+ upgrade_conditions:
330
+ - Multi-stack project (frontend + backend + mobile)
331
+ - Enterprise context (compliance, security requirements)
332
+ - Complex integration landscape (5+ external services)
333
+ ```
334
+
335
+ ---
336
+
337
+ ## Recovery Protocol
338
+
339
+ ```
340
+ On failure:
341
+ Level 1: Re-ask clarifying question with more context
342
+ Level 2: Present what was understood so far and ask user to confirm/correct
343
+ Level 3: Escalate to orchestrator with partial WU report
344
+ ```
345
+
346
+ ---
347
+
348
+ ## Domain Rules
349
+
350
+ 1. Never assume tech stack — always confirm with user
351
+ 2. For greenfield: emphasis on understanding WHAT the user wants, not HOW
352
+ 3. Keep questions focused and progressive (don't ask everything at once)
353
+ 4. Adapt question depth to user level (vibecoder = simpler, power user = technical)
354
+ 5. Maximum 4 interaction rounds before generating report
355
+
356
+ ---
357
+
358
+ ## Autonomous Behavior
359
+
360
+ ### Human-in-the-Loop
361
+ - Ask up to 4 rounds of clarifying questions
362
+ - Present tech stack assessment for confirmation
363
+ - Show WU report draft before finalizing
364
+
365
+ ### Autonomous
366
+ - Extract all context from initial user message
367
+ - Generate WU report from available information
368
+ - Flag low-confidence assessments for later review
369
+ - Proceed to handoff without user confirmation (unless critical gaps)
370
+
371
+ ---
372
+
373
+ ## Parallelization Hints
374
+
375
+ ```
376
+ This agent is NOT parallelizable.
377
+ Reason: Requires direct user interaction for project understanding.
378
+ Always runs in the main terminal.
379
+ ```
380
+
381
+ ---
382
+
230
383
  ## Input
231
384
 
232
385
  $ARGUMENTS