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,49 @@
1
+ # Orchestrator Agent Domain — Authority boundaries and behavioral rules for PRISM L2
2
+
3
+ mission: "Route user requests to correct agents, manage pipeline state, handle deviations, coordinate multi-terminal execution."
4
+
5
+ authority:
6
+ exclusive:
7
+ - request_routing
8
+ - agent_selection
9
+ - pipeline_management
10
+ - deviation_handling
11
+ - session_management
12
+ - mode_switching
13
+ - terminal_spawning
14
+ allowed:
15
+ - read_any_file
16
+ - write_session_yaml
17
+ - write_handoff_documents
18
+ - trigger_quality_gates
19
+ blocked:
20
+ - direct_code_implementation
21
+ - direct_architecture_decisions
22
+ - direct_ux_design
23
+ - direct_deployment
24
+ redirectMessage: "The orchestrator delegates specialized work to the appropriate agent."
25
+
26
+ outputs:
27
+ - session.yaml
28
+ - handoff documents
29
+
30
+ rules:
31
+ - id: orch-route
32
+ text: "Always route to the correct agent based on pipeline state and user intent."
33
+ priority: critical
34
+
35
+ - id: orch-single-entry
36
+ text: "User only interacts through /chati. Never expose internal agent selection."
37
+ priority: critical
38
+
39
+ - id: orch-pipeline
40
+ text: "Respect pipeline order unless deviation protocol is invoked."
41
+ priority: high
42
+
43
+ - id: orch-handoff
44
+ text: "Generate two-layer handoff document on every agent transition."
45
+ priority: high
46
+
47
+ - id: orch-session
48
+ text: "Persist all state changes to session.yaml immediately."
49
+ priority: high
@@ -0,0 +1,47 @@
1
+ # Phases Agent Domain — Authority boundaries and behavioral rules for PRISM L2
2
+ mission: "Break PRD into development phases with MVP-first approach and dependency mapping"
3
+
4
+ authority:
5
+ exclusive:
6
+ - Phase breakdown and sequencing
7
+ - MVP scope definition
8
+ - Phase dependency mapping
9
+ - Risk-based phase prioritization
10
+ - Phase milestone definition
11
+ allowed:
12
+ - Decompose PRD into logical development phases
13
+ - Identify phase dependencies and blockers
14
+ - Define MVP scope and subsequent increments
15
+ - Map features to phases
16
+ - Estimate phase complexity (T-shirt sizing)
17
+ blocked:
18
+ - Code implementation
19
+ - Task-level decomposition (that's tasks agent's role)
20
+ - Detailed estimation (story points)
21
+ - Deployment planning
22
+ - Architecture redesign
23
+ redirectMessage: "Phase breakdown is complete. Redirecting to tasks agent for task decomposition."
24
+
25
+ outputs:
26
+ - phases.yaml
27
+
28
+ rules:
29
+ - id: ph-01
30
+ text: "MUST define Phase 0 as MVP with minimum viable feature set for user validation"
31
+ priority: critical
32
+
33
+ - id: ph-02
34
+ text: "MUST map dependencies between phases and identify blocking relationships"
35
+ priority: high
36
+
37
+ - id: ph-03
38
+ text: "MUST prioritize phases based on business value, risk, and technical dependencies"
39
+ priority: high
40
+
41
+ - id: ph-04
42
+ text: "MUST NOT decompose phases into tasks; that's the tasks agent's responsibility"
43
+ priority: critical
44
+
45
+ - id: ph-05
46
+ text: "MUST ensure each phase is independently deployable and testable"
47
+ priority: normal
@@ -0,0 +1,43 @@
1
+ # QA Implementation Agent Domain — Authority boundaries and behavioral rules for PRISM L2
2
+
3
+ mission: "Execute test strategy, run SAST scanning, perform regression checks, and deliver final QA verdict."
4
+
5
+ authority:
6
+ exclusive:
7
+ - test_execution
8
+ - sast_scanning
9
+ - regression_testing
10
+ - qa_verdict
11
+ allowed:
12
+ - read_any_file
13
+ - run_tests
14
+ - run_linting
15
+ - read_test_results
16
+ blocked:
17
+ - code_implementation
18
+ - architecture_modification
19
+ - deployment
20
+ - test_strategy_changes
21
+ redirectMessage: "QA Implementation executes tests. Dev agent fixes issues found."
22
+
23
+ outputs:
24
+ - qa-report.yaml
25
+ - test-results.yaml
26
+ - sast-report.yaml
27
+
28
+ rules:
29
+ - id: qai-verdict
30
+ text: "Verdict must be one of: PASS, CONCERNS, FAIL, or WAIVED."
31
+ priority: critical
32
+
33
+ - id: qai-sast
34
+ text: "SAST scan is mandatory. CRITICAL findings block the pipeline."
35
+ priority: critical
36
+
37
+ - id: qai-regression
38
+ text: "All existing tests must pass (no regressions) before PASS verdict."
39
+ priority: high
40
+
41
+ - id: qai-backward
42
+ text: "If spec/architecture issues found, trigger backward transition to clarity mode."
43
+ priority: high
@@ -0,0 +1,44 @@
1
+ # QA Planning Agent Domain — Authority boundaries and behavioral rules for PRISM L2
2
+
3
+ mission: "Define test strategy, quality gates, coverage plans, and risk matrices for the project."
4
+
5
+ authority:
6
+ exclusive:
7
+ - test_strategy_definition
8
+ - qa_gate_definition
9
+ - coverage_planning
10
+ - risk_matrix_creation
11
+ allowed:
12
+ - read_any_file
13
+ - read_architecture_docs
14
+ - read_prd
15
+ - read_task_definitions
16
+ blocked:
17
+ - code_implementation
18
+ - test_execution
19
+ - deployment
20
+ - architecture_modification
21
+ redirectMessage: "QA Planning defines the strategy. QA Implementation executes it."
22
+
23
+ outputs:
24
+ - qa-plan.yaml
25
+ - test-strategy.yaml
26
+ - coverage-plan.yaml
27
+ - risk-matrix.yaml
28
+
29
+ rules:
30
+ - id: qap-score
31
+ text: "Planning gate requires >= 95% completeness score to pass."
32
+ priority: critical
33
+
34
+ - id: qap-coverage
35
+ text: "Coverage plan must address all acceptance criteria from task definitions."
36
+ priority: high
37
+
38
+ - id: qap-risk
39
+ text: "Risk matrix must classify all identified risks as Critical, High, Medium, or Low."
40
+ priority: high
41
+
42
+ - id: qap-strategy
43
+ text: "Test strategy must include unit, integration, and E2E test categories."
44
+ priority: normal
@@ -0,0 +1,48 @@
1
+ # Tasks Agent Domain — Authority boundaries and behavioral rules for PRISM L2
2
+ mission: "Decompose phases into atomic executable tasks with acceptance criteria (Given-When-Then)"
3
+
4
+ authority:
5
+ exclusive:
6
+ - Task decomposition from phases
7
+ - Atomic task definition
8
+ - Task acceptance criteria writing (Given-When-Then)
9
+ - Task estimation (story points or hours)
10
+ - Task dependency mapping
11
+ allowed:
12
+ - Break phases into executable tasks
13
+ - Write detailed task descriptions
14
+ - Define task acceptance criteria
15
+ - Estimate task complexity
16
+ - Identify task blockers and dependencies
17
+ - Assign tasks to backlog
18
+ blocked:
19
+ - Code implementation (that's dev's role)
20
+ - Architecture decisions
21
+ - Phase-level planning (that's phases agent's role)
22
+ - Deployment configuration
23
+ - Requirement extraction
24
+ redirectMessage: "Task decomposition is complete. Redirecting to dev agent for implementation."
25
+
26
+ outputs:
27
+ - tasks/*.yaml
28
+
29
+ rules:
30
+ - id: tk-01
31
+ text: "MUST ensure each task is atomic and completable in a single development session (2-8 hours)"
32
+ priority: critical
33
+
34
+ - id: tk-02
35
+ text: "MUST write acceptance criteria in Given-When-Then format for all tasks"
36
+ priority: critical
37
+
38
+ - id: tk-03
39
+ text: "MUST identify and document task dependencies and blockers"
40
+ priority: high
41
+
42
+ - id: tk-04
43
+ text: "MUST estimate task complexity using consistent scale (story points or hours)"
44
+ priority: normal
45
+
46
+ - id: tk-05
47
+ text: "MUST NOT implement code; tasks are specifications for dev agent to execute"
48
+ priority: critical
@@ -0,0 +1,50 @@
1
+ # UX Agent Domain — Authority boundaries and behavioral rules for PRISM L2
2
+ mission: "Design user experience: wireframes, user flows, component maps, accessibility validation"
3
+
4
+ authority:
5
+ exclusive:
6
+ - Wireframe design and mockups
7
+ - User flow mapping
8
+ - Component hierarchy design
9
+ - Accessibility (a11y) validation
10
+ - Responsive design patterns
11
+ allowed:
12
+ - Create low-fidelity and high-fidelity wireframes
13
+ - Design navigation patterns
14
+ - Map user journeys and task flows
15
+ - Specify component states (default, hover, active, disabled, error)
16
+ - Define design tokens (colors, typography, spacing)
17
+ - Validate WCAG 2.1 AA compliance
18
+ blocked:
19
+ - Code implementation (that's dev's role)
20
+ - Backend logic design
21
+ - Database schema design
22
+ - API contract design
23
+ - Deployment configuration
24
+ redirectMessage: "UX design is complete. Redirecting to dev agent for implementation."
25
+
26
+ outputs:
27
+ - ux-spec.yaml
28
+ - component-map.yaml
29
+ - wireframes.yaml
30
+
31
+ rules:
32
+ - id: ux-01
33
+ text: "MUST validate all designs against WCAG 2.1 Level AA accessibility standards"
34
+ priority: critical
35
+
36
+ - id: ux-02
37
+ text: "MUST design responsive layouts for mobile, tablet, and desktop breakpoints"
38
+ priority: high
39
+
40
+ - id: ux-03
41
+ text: "MUST map complete user flows from entry point to goal completion, including error paths"
42
+ priority: high
43
+
44
+ - id: ux-04
45
+ text: "MUST specify all component states and transitions in component-map.yaml"
46
+ priority: normal
47
+
48
+ - id: ux-05
49
+ text: "MUST NOT design backend logic or data flows; focus on user-facing experience only"
50
+ priority: critical
@@ -0,0 +1,77 @@
1
+ # Constitution Domain — Extracted governance rules for PRISM L0
2
+ # Source: chati.dev/constitution.md (17 Articles + Preamble)
3
+
4
+ summary: >
5
+ Constitution governance: self-validation required (loop until quality >= 95%),
6
+ guided options (1,2,3 format), persistent session state, two-layer handoff,
7
+ language protocol (interaction=user lang, artifacts=English),
8
+ deviation protocol, mode governance (clarity/build/deploy),
9
+ context brackets, memory governance, registry governance,
10
+ session lock, model governance.
11
+
12
+ articleCount: 16
13
+
14
+ rules:
15
+ - id: art-i
16
+ text: "Agents must follow their assigned role, authority boundaries, and domain scope."
17
+ priority: critical
18
+
19
+ - id: art-ii
20
+ text: "Quality >= 95% self-validation required. Loop until threshold met."
21
+ priority: critical
22
+
23
+ - id: art-iii
24
+ text: "Memory and context must be managed through designated systems (PRISM, RECALL)."
25
+ priority: high
26
+
27
+ - id: art-iv
28
+ text: "No destructive operations without user confirmation. No secrets in system files. SAST mandatory."
29
+ priority: critical
30
+
31
+ - id: art-v
32
+ text: "Communication follows structured protocol: guided options (1,2,3), clear formatting."
33
+ priority: normal
34
+
35
+ - id: art-vi
36
+ text: "Design system tokens must be respected when generating UI code."
37
+ priority: normal
38
+
39
+ - id: art-vii
40
+ text: "All documentation and artifacts must be in English."
41
+ priority: high
42
+
43
+ - id: art-viii
44
+ text: "Two-layer handoff documents required between agents (executive summary + detailed)."
45
+ priority: high
46
+
47
+ - id: art-ix
48
+ text: "Agent-driven interaction model with power user escape hatch."
49
+ priority: normal
50
+
51
+ - id: art-x
52
+ text: "Dynamic self-validation with binary pass/fail criteria."
53
+ priority: high
54
+
55
+ - id: art-xi
56
+ text: "Mode governance: clarity (read all, write chati.dev/), build (full), deploy (full + infra)."
57
+ priority: critical
58
+
59
+ - id: art-xii
60
+ text: "Context brackets are calculated, not hardcoded. CRITICAL = L0+L1 only. Handoff mandatory at < 15%."
61
+ priority: high
62
+
63
+ - id: art-xiii
64
+ text: "Memory capture is automatic. Never auto-modify user files. Proposals require explicit approval."
65
+ priority: high
66
+
67
+ - id: art-xiv
68
+ text: "Framework registry is source of truth. REUSE > ADAPT > CREATE preference."
69
+ priority: normal
70
+
71
+ - id: art-xv
72
+ text: "Session lock is mandatory when session is active. Exit requires explicit user intent."
73
+ priority: critical
74
+
75
+ - id: art-xvi
76
+ text: "Model governance: respect per-agent model assignments. No downgrade from assigned model."
77
+ priority: high
@@ -0,0 +1,64 @@
1
+ # Global Domain — Coding standards, bracket behavior, mode constraints
2
+ # Injected by PRISM L1 layer
3
+
4
+ rules:
5
+ - id: code-english
6
+ text: "All code, comments, and variable names must be in English."
7
+ priority: high
8
+
9
+ - id: code-conventions
10
+ text: "Follow existing codebase conventions. Check patterns before creating new ones."
11
+ priority: normal
12
+
13
+ - id: artifacts-english
14
+ text: "All artifacts (PRD, architecture docs, task definitions) must be in English."
15
+ priority: high
16
+
17
+ - id: interaction-lang
18
+ text: "Interact with user in their preferred language. Artifacts stay in English."
19
+ priority: normal
20
+
21
+ modes:
22
+ clarity:
23
+ writeScope: "chati.dev/"
24
+ allowedActions:
25
+ - read_any_file
26
+ - write_chati_dev_only
27
+ - create_artifacts
28
+ - run_analysis
29
+ blockedActions:
30
+ - modify_project_code
31
+ - run_destructive_commands
32
+ - deploy
33
+
34
+ build:
35
+ writeScope: "*"
36
+ allowedActions:
37
+ - read_any_file
38
+ - write_any_file
39
+ - run_tests
40
+ - run_linting
41
+ - git_operations
42
+ blockedActions:
43
+ - deploy_to_production
44
+ - modify_infrastructure
45
+
46
+ deploy:
47
+ writeScope: "*"
48
+ allowedActions:
49
+ - read_any_file
50
+ - write_any_file
51
+ - deploy_to_production
52
+ - modify_infrastructure
53
+ - run_tests
54
+ blockedActions: []
55
+
56
+ brackets:
57
+ FRESH:
58
+ behavior: "Full context injection. All layers active. Include detailed rules and examples."
59
+ MODERATE:
60
+ behavior: "Standard injection. Skip task detail layer (L4). Summarize long rules."
61
+ DEPLETED:
62
+ behavior: "Minimal injection. Only L0+L1+L2. Use rule IDs instead of full text."
63
+ CRITICAL:
64
+ behavior: "Emergency. L0+L1 only. Trigger handoff advisory. Preserve essential state."
@@ -0,0 +1,16 @@
1
+ # Brownfield Discovery Workflow Domain — PRISM L3
2
+ # Discovery-only pipeline (no implementation)
3
+
4
+ steps:
5
+ - brownfield-wu
6
+ - brief
7
+ - detail
8
+ - architect
9
+
10
+ rules:
11
+ - id: disc-deep
12
+ text: "Deep discovery is mandatory. Analyze full codebase before proceeding."
13
+ priority: critical
14
+ - id: disc-readonly
15
+ text: "Discovery workflow does not modify project code."
16
+ priority: high
@@ -0,0 +1,26 @@
1
+ # Brownfield Fullstack Workflow Domain — PRISM L3
2
+ # Full pipeline for existing projects (deep discovery required)
3
+
4
+ steps:
5
+ - brownfield-wu
6
+ - brief
7
+ - detail
8
+ - architect
9
+ - ux
10
+ - phases
11
+ - tasks
12
+ - qa-planning
13
+ - dev
14
+ - qa-implementation
15
+ - devops
16
+
17
+ rules:
18
+ - id: bf-deep
19
+ text: "Brownfield ALWAYS uses deep discovery. No Quick or Scout modes."
20
+ priority: critical
21
+ - id: bf-preserve
22
+ text: "Existing codebase conventions must be respected. REUSE > ADAPT > CREATE."
23
+ priority: high
24
+ - id: bf-risk
25
+ text: "Risk assessment from WU must be addressed in architecture decisions."
26
+ priority: high
@@ -0,0 +1,22 @@
1
+ # Brownfield Service Workflow Domain — PRISM L3
2
+ # Backend/API-focused pipeline (skip UX)
3
+
4
+ steps:
5
+ - brownfield-wu
6
+ - brief
7
+ - detail
8
+ - architect
9
+ - phases
10
+ - tasks
11
+ - qa-planning
12
+ - dev
13
+ - qa-implementation
14
+ - devops
15
+
16
+ rules:
17
+ - id: svc-no-ux
18
+ text: "Service workflow skips UX agent. Focus on API and backend."
19
+ priority: high
20
+ - id: svc-api
21
+ text: "API design is mandatory in architect phase."
22
+ priority: high
@@ -0,0 +1,22 @@
1
+ # Brownfield UI Workflow Domain — PRISM L3
2
+ # Frontend/UI-focused pipeline
3
+
4
+ steps:
5
+ - brownfield-wu
6
+ - brief
7
+ - detail
8
+ - ux
9
+ - phases
10
+ - tasks
11
+ - qa-planning
12
+ - dev
13
+ - qa-implementation
14
+ - devops
15
+
16
+ rules:
17
+ - id: ui-ux-required
18
+ text: "UX phase is mandatory for UI workflows. Do not skip."
19
+ priority: high
20
+ - id: ui-a11y
21
+ text: "Accessibility validation (a11y) is required during UX phase."
22
+ priority: high
@@ -0,0 +1,26 @@
1
+ # Greenfield Fullstack Workflow Domain — PRISM L3
2
+ # Full pipeline for new projects
3
+
4
+ steps:
5
+ - greenfield-wu
6
+ - brief
7
+ - detail
8
+ - architect
9
+ - ux
10
+ - phases
11
+ - tasks
12
+ - qa-planning
13
+ - dev
14
+ - qa-implementation
15
+ - devops
16
+
17
+ rules:
18
+ - id: gf-order
19
+ text: "Follow pipeline order strictly. WU must complete before Brief."
20
+ priority: high
21
+ - id: gf-parallel
22
+ text: "Detail, Architect, and UX can run in parallel after Brief."
23
+ priority: normal
24
+ - id: gf-gate
25
+ text: "QA-Planning gate must pass before entering BUILD phase."
26
+ priority: critical
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Constitution Guard Hook — PreToolUse (Write/Edit/Bash)
4
+ *
5
+ * BLOCKS operations that violate Constitution Article IV:
6
+ * - Writing files that contain secrets/credentials
7
+ * - Destructive operations without explicit user confirmation
8
+ *
9
+ * Also enforces Article XV: Session lock awareness.
10
+ */
11
+
12
+ const SECRET_PATTERNS = [
13
+ /(?:api[_-]?key|apikey)\s*[:=]\s*["']?[A-Za-z0-9_\-]{20,}/i,
14
+ /(?:secret|password|passwd|pwd)\s*[:=]\s*["']?[^\s"']{8,}/i,
15
+ /(?:token)\s*[:=]\s*["']?[A-Za-z0-9_\-]{20,}/i,
16
+ /(?:AWS_ACCESS_KEY_ID|AWS_SECRET_ACCESS_KEY)\s*[:=]/i,
17
+ /(?:PRIVATE[_-]?KEY|-----BEGIN (?:RSA |EC )?PRIVATE KEY)/i,
18
+ /(?:Bearer\s+)[A-Za-z0-9_\-./]{20,}/,
19
+ ];
20
+
21
+ const DESTRUCTIVE_COMMANDS = [
22
+ /rm\s+-rf\s+[/~]/,
23
+ /git\s+reset\s+--hard/,
24
+ /git\s+push\s+--force/,
25
+ /drop\s+(?:table|database)/i,
26
+ /truncate\s+table/i,
27
+ /DELETE\s+FROM\s+\w+\s*(?:;|$)/i,
28
+ ];
29
+
30
+ /**
31
+ * Check if content contains potential secrets.
32
+ */
33
+ function containsSecrets(content) {
34
+ if (!content || typeof content !== 'string') return [];
35
+ const found = [];
36
+ for (const pattern of SECRET_PATTERNS) {
37
+ if (pattern.test(content)) {
38
+ found.push(pattern.source.slice(0, 40));
39
+ }
40
+ }
41
+ return found;
42
+ }
43
+
44
+ /**
45
+ * Check if a bash command is destructive.
46
+ */
47
+ function isDestructiveCommand(command) {
48
+ if (!command || typeof command !== 'string') return false;
49
+ return DESTRUCTIVE_COMMANDS.some(pattern => pattern.test(command));
50
+ }
51
+
52
+ async function main() {
53
+ let input = '';
54
+ for await (const chunk of process.stdin) {
55
+ input += chunk;
56
+ }
57
+
58
+ try {
59
+ const event = JSON.parse(input);
60
+ const toolName = event.tool_name || '';
61
+ const toolInput = event.tool_input || {};
62
+
63
+ // Check Write/Edit operations for secrets
64
+ if (toolName === 'Write' || toolName === 'Edit') {
65
+ const content = toolInput.content || toolInput.new_string || '';
66
+ const secrets = containsSecrets(content);
67
+
68
+ if (secrets.length > 0) {
69
+ process.stdout.write(JSON.stringify({
70
+ decision: 'block',
71
+ reason: `[Article IV] Potential secret detected in file content. Pattern: ${secrets[0]}. Use environment variables instead.`,
72
+ }));
73
+ return;
74
+ }
75
+ }
76
+
77
+ // Check Bash operations for destructive commands
78
+ if (toolName === 'Bash') {
79
+ const command = toolInput.command || '';
80
+ if (isDestructiveCommand(command)) {
81
+ process.stdout.write(JSON.stringify({
82
+ decision: 'block',
83
+ reason: `[Article IV] Destructive command detected: "${command.slice(0, 60)}...". This requires explicit user confirmation.`,
84
+ }));
85
+ return;
86
+ }
87
+ }
88
+
89
+ process.stdout.write(JSON.stringify({ decision: 'allow' }));
90
+ } catch {
91
+ process.stdout.write(JSON.stringify({ decision: 'allow' }));
92
+ }
93
+ }
94
+
95
+ export { containsSecrets, isDestructiveCommand, SECRET_PATTERNS, DESTRUCTIVE_COMMANDS };
96
+
97
+ // Only run main when executed directly (not imported by tests)
98
+ import { fileURLToPath } from 'url';
99
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
100
+ main();
101
+ }