chati-dev 2.0.8 → 2.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 (134) hide show
  1. package/README.md +32 -21
  2. package/assets/logo - co/314/201pia.png +0 -0
  3. package/assets/logo - co/314/201pia.svg" +42 -0
  4. package/bin/chati.js +3 -3
  5. package/framework/agents/{planning → discover}/brief.md +24 -2
  6. package/framework/agents/{planning → discover}/brownfield-wu.md +1 -1
  7. package/framework/agents/{planning → discover}/greenfield-wu.md +1 -1
  8. package/framework/agents/{planning → plan}/architect.md +1 -1
  9. package/framework/agents/{planning → plan}/detail.md +1 -1
  10. package/framework/agents/{planning → plan}/phases.md +1 -1
  11. package/framework/agents/{planning → plan}/tasks.md +1 -1
  12. package/framework/agents/{planning → plan}/ux.md +1 -1
  13. package/framework/agents/quality/qa-implementation.md +53 -4
  14. package/framework/agents/quality/qa-planning.md +53 -2
  15. package/framework/config.yaml +3 -3
  16. package/framework/constitution.md +4 -4
  17. package/framework/context/quality.md +1 -1
  18. package/framework/context/root.md +5 -4
  19. package/framework/data/entity-registry.yaml +35 -11
  20. package/framework/domains/agents/brief.yaml +14 -0
  21. package/framework/domains/agents/qa-implementation.yaml +16 -0
  22. package/framework/domains/agents/qa-planning.yaml +16 -0
  23. package/framework/domains/constitution.yaml +6 -2
  24. package/framework/domains/workflows/brownfield-discovery.yaml +5 -4
  25. package/framework/domains/workflows/quick-flow.yaml +23 -0
  26. package/framework/hooks/mode-governance.js +14 -2
  27. package/framework/hooks/model-governance.js +5 -1
  28. package/framework/hooks/prism-engine.js +1 -1
  29. package/framework/hooks/session-digest.js +6 -2
  30. package/framework/hooks/settings.json +11 -0
  31. package/framework/i18n/en.yaml +3 -3
  32. package/framework/i18n/es.yaml +3 -3
  33. package/framework/i18n/fr.yaml +3 -3
  34. package/framework/i18n/pt.yaml +3 -3
  35. package/framework/intelligence/context-engine.md +2 -2
  36. package/framework/intelligence/decision-engine.md +2 -2
  37. package/framework/manifest.json +5 -0
  38. package/framework/manifest.sig +1 -0
  39. package/framework/orchestrator/chati.md +68 -20
  40. package/framework/patterns/elicitation-library.yaml +592 -0
  41. package/framework/patterns/elicitation.md +2 -0
  42. package/framework/quality-gates/planning-gate.md +1 -1
  43. package/framework/schemas/session.schema.json +36 -3
  44. package/framework/tasks/architect-api-design.md +1 -1
  45. package/framework/tasks/architect-consolidate.md +1 -1
  46. package/framework/tasks/architect-db-design.md +1 -1
  47. package/framework/tasks/architect-design.md +1 -1
  48. package/framework/tasks/architect-security-review.md +1 -1
  49. package/framework/tasks/architect-stack-selection.md +1 -1
  50. package/framework/tasks/brief-consolidate.md +1 -1
  51. package/framework/tasks/brief-constraint-identify.md +1 -1
  52. package/framework/tasks/brief-extract-requirements.md +1 -1
  53. package/framework/tasks/brief-stakeholder-map.md +1 -1
  54. package/framework/tasks/brief-validate-completeness.md +1 -1
  55. package/framework/tasks/brownfield-wu-architecture-map.md +1 -1
  56. package/framework/tasks/brownfield-wu-deep-discovery.md +1 -1
  57. package/framework/tasks/brownfield-wu-dependency-scan.md +1 -1
  58. package/framework/tasks/brownfield-wu-migration-plan.md +1 -1
  59. package/framework/tasks/brownfield-wu-report.md +1 -1
  60. package/framework/tasks/brownfield-wu-risk-assess.md +1 -1
  61. package/framework/tasks/detail-acceptance-criteria.md +1 -1
  62. package/framework/tasks/detail-consolidate.md +1 -1
  63. package/framework/tasks/detail-edge-case-analysis.md +1 -1
  64. package/framework/tasks/detail-expand-prd.md +1 -1
  65. package/framework/tasks/detail-nfr-extraction.md +1 -1
  66. package/framework/tasks/greenfield-wu-analyze-empty.md +1 -1
  67. package/framework/tasks/greenfield-wu-report.md +1 -1
  68. package/framework/tasks/greenfield-wu-scaffold-detection.md +1 -1
  69. package/framework/tasks/greenfield-wu-tech-stack-assess.md +1 -1
  70. package/framework/tasks/orchestrator-deviation.md +2 -2
  71. package/framework/tasks/orchestrator-escalate.md +1 -1
  72. package/framework/tasks/orchestrator-handoff.md +3 -3
  73. package/framework/tasks/orchestrator-mode-switch.md +16 -5
  74. package/framework/tasks/orchestrator-preview.md +181 -0
  75. package/framework/tasks/orchestrator-resume.md +2 -2
  76. package/framework/tasks/orchestrator-route.md +5 -4
  77. package/framework/tasks/orchestrator-status.md +4 -4
  78. package/framework/tasks/orchestrator-suggest-mode.md +7 -7
  79. package/framework/tasks/phases-breakdown.md +1 -1
  80. package/framework/tasks/phases-dependency-mapping.md +1 -1
  81. package/framework/tasks/phases-mvp-scoping.md +1 -1
  82. package/framework/tasks/qa-impl-consolidate.md +2 -2
  83. package/framework/tasks/qa-impl-verdict.md +2 -2
  84. package/framework/tasks/qa-planning-consolidate.md +1 -1
  85. package/framework/tasks/qa-planning-coverage-plan.md +2 -2
  86. package/framework/tasks/qa-planning-gate-define.md +1 -1
  87. package/framework/tasks/qa-planning-risk-matrix.md +1 -1
  88. package/framework/tasks/qa-planning-test-strategy.md +1 -1
  89. package/framework/tasks/tasks-acceptance-write.md +1 -1
  90. package/framework/tasks/tasks-consolidate.md +1 -1
  91. package/framework/tasks/tasks-decompose.md +1 -1
  92. package/framework/tasks/tasks-estimate.md +1 -1
  93. package/framework/tasks/ux-a11y-check.md +1 -1
  94. package/framework/tasks/ux-component-map.md +1 -1
  95. package/framework/tasks/ux-consolidate.md +1 -1
  96. package/framework/tasks/ux-user-flow.md +1 -1
  97. package/framework/tasks/ux-wireframe.md +1 -1
  98. package/framework/templates/quick-brief-tmpl.yaml +90 -0
  99. package/framework/workflows/brownfield-discovery.yaml +7 -7
  100. package/framework/workflows/brownfield-fullstack.yaml +24 -10
  101. package/framework/workflows/brownfield-service.yaml +41 -5
  102. package/framework/workflows/brownfield-ui.yaml +41 -5
  103. package/framework/workflows/greenfield-fullstack.yaml +24 -10
  104. package/framework/workflows/quick-flow.yaml +125 -0
  105. package/package.json +4 -4
  106. package/scripts/bundle-framework.js +1 -1
  107. package/scripts/populate-entity-registry.js +1 -1
  108. package/scripts/semantic-lint.js +2 -2
  109. package/scripts/validate-agents.js +2 -1
  110. package/scripts/validate-package.js +1 -1
  111. package/scripts/validate-tasks.js +1 -1
  112. package/src/autonomy/progress-reporter.js +26 -19
  113. package/src/context/engine.js +1 -1
  114. package/src/context/layers/l1-global.js +17 -5
  115. package/src/dashboard/layout.js +2 -1
  116. package/src/gates/g1-planning-complete.js +10 -10
  117. package/src/installer/core.js +14 -12
  118. package/src/installer/templates.js +1 -1
  119. package/src/installer/validator.js +8 -8
  120. package/src/intelligence/registry-manager.js +4 -4
  121. package/src/memory/session-digest.js +1 -1
  122. package/src/orchestrator/agent-selector.js +11 -11
  123. package/src/orchestrator/intent-classifier.js +12 -8
  124. package/src/orchestrator/pipeline-manager.js +100 -3
  125. package/src/orchestrator/pipeline-state.js +1 -1
  126. package/src/orchestrator/session-manager.js +13 -4
  127. package/src/preview/detector.js +238 -0
  128. package/src/preview/index.js +20 -0
  129. package/src/preview/launcher.js +235 -0
  130. package/src/preview/log-buffer.js +103 -0
  131. package/src/tasks/executor.js +1 -1
  132. package/src/tasks/loader.js +1 -1
  133. package/src/terminal/prompt-builder.js +10 -10
  134. package/src/wizard/i18n.js +3 -3
@@ -2,7 +2,7 @@
2
2
  id: architect-consolidate
3
3
  agent: architect
4
4
  trigger: architect-security-review
5
- phase: planning
5
+ phase: plan
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [architecture-final.yaml]
@@ -2,7 +2,7 @@
2
2
  id: architect-db-design
3
3
  agent: architect
4
4
  trigger: architect-api-design
5
- phase: planning
5
+ phase: plan
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [db-design.yaml]
@@ -2,7 +2,7 @@
2
2
  id: architect-design
3
3
  agent: architect
4
4
  trigger: detail
5
- phase: planning
5
+ phase: plan
6
6
  requires_input: false
7
7
  parallelizable: true
8
8
  outputs: [architecture.yaml]
@@ -2,7 +2,7 @@
2
2
  id: architect-security-review
3
3
  agent: architect
4
4
  trigger: architect-db-design
5
- phase: planning
5
+ phase: plan
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [security-review.yaml]
@@ -2,7 +2,7 @@
2
2
  id: architect-stack-selection
3
3
  agent: architect
4
4
  trigger: architect-design
5
- phase: planning
5
+ phase: plan
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [stack-selection.yaml]
@@ -2,7 +2,7 @@
2
2
  id: brief-consolidate
3
3
  agent: brief
4
4
  trigger: brief-constraint-identify
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [brief.yaml]
@@ -2,7 +2,7 @@
2
2
  id: brief-constraint-identify
3
3
  agent: brief
4
4
  trigger: brief-stakeholder-map
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: true
7
7
  parallelizable: false
8
8
  outputs: [constraints.yaml]
@@ -2,7 +2,7 @@
2
2
  id: brief-extract-requirements
3
3
  agent: brief
4
4
  trigger: orchestrator
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: true
7
7
  parallelizable: false
8
8
  outputs: [requirements-raw.yaml]
@@ -2,7 +2,7 @@
2
2
  id: brief-stakeholder-map
3
3
  agent: brief
4
4
  trigger: brief-validate-completeness
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: true
7
7
  parallelizable: false
8
8
  outputs: [stakeholder-map.yaml]
@@ -2,7 +2,7 @@
2
2
  id: brief-validate-completeness
3
3
  agent: brief
4
4
  trigger: brief-extract-requirements
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: true
7
7
  parallelizable: false
8
8
  outputs: [validation-report.yaml]
@@ -2,7 +2,7 @@
2
2
  id: brownfield-wu-architecture-map
3
3
  agent: brownfield-wu
4
4
  trigger: brownfield-wu-dependency-scan
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: false
7
7
  parallelizable: true
8
8
  outputs: [architecture-map.yaml]
@@ -2,7 +2,7 @@
2
2
  id: brownfield-wu-deep-discovery
3
3
  agent: brownfield-wu
4
4
  trigger: orchestrator
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [discovery.yaml]
@@ -2,7 +2,7 @@
2
2
  id: brownfield-wu-dependency-scan
3
3
  agent: brownfield-wu
4
4
  trigger: brownfield-wu-deep-discovery
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: false
7
7
  parallelizable: true
8
8
  outputs: [dependencies.yaml]
@@ -2,7 +2,7 @@
2
2
  id: brownfield-wu-migration-plan
3
3
  agent: brownfield-wu
4
4
  trigger: brownfield-wu-risk-assess
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: true
7
7
  parallelizable: false
8
8
  outputs: [migration-plan.yaml]
@@ -2,7 +2,7 @@
2
2
  id: brownfield-wu-report
3
3
  agent: brownfield-wu
4
4
  trigger: brownfield-wu-migration-plan
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [wu-report.yaml]
@@ -2,7 +2,7 @@
2
2
  id: brownfield-wu-risk-assess
3
3
  agent: brownfield-wu
4
4
  trigger: brownfield-wu-architecture-map
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [risk-assessment.yaml]
@@ -2,7 +2,7 @@
2
2
  id: detail-acceptance-criteria
3
3
  agent: detail
4
4
  trigger: detail-edge-case-analysis
5
- phase: planning
5
+ phase: plan
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [acceptance-criteria.yaml]
@@ -2,7 +2,7 @@
2
2
  id: detail-consolidate
3
3
  agent: detail
4
4
  trigger: detail-acceptance-criteria
5
- phase: planning
5
+ phase: plan
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [prd.yaml]
@@ -2,7 +2,7 @@
2
2
  id: detail-edge-case-analysis
3
3
  agent: detail
4
4
  trigger: detail-nfr-extraction
5
- phase: planning
5
+ phase: plan
6
6
  requires_input: false
7
7
  parallelizable: true
8
8
  outputs: [edge-cases.yaml]
@@ -2,7 +2,7 @@
2
2
  id: detail-expand-prd
3
3
  agent: detail
4
4
  trigger: brief
5
- phase: planning
5
+ phase: plan
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [prd-draft.yaml]
@@ -2,7 +2,7 @@
2
2
  id: detail-nfr-extraction
3
3
  agent: detail
4
4
  trigger: detail-expand-prd
5
- phase: planning
5
+ phase: plan
6
6
  requires_input: false
7
7
  parallelizable: true
8
8
  outputs: [nfr.yaml]
@@ -2,7 +2,7 @@
2
2
  id: greenfield-wu-analyze-empty
3
3
  agent: greenfield-wu
4
4
  trigger: orchestrator
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [wu-analysis.yaml]
@@ -2,7 +2,7 @@
2
2
  id: greenfield-wu-report
3
3
  agent: greenfield-wu
4
4
  trigger: greenfield-wu-tech-stack-assess
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [wu-report.yaml]
@@ -2,7 +2,7 @@
2
2
  id: greenfield-wu-scaffold-detection
3
3
  agent: greenfield-wu
4
4
  trigger: greenfield-wu-analyze-empty
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: false
7
7
  parallelizable: false
8
8
  outputs: [scaffold-report.yaml]
@@ -2,7 +2,7 @@
2
2
  id: greenfield-wu-tech-stack-assess
3
3
  agent: greenfield-wu
4
4
  trigger: greenfield-wu-scaffold-detection
5
- phase: planning
5
+ phase: discover
6
6
  requires_input: true
7
7
  parallelizable: false
8
8
  outputs: [tech-stack.yaml]
@@ -54,7 +54,7 @@ Identify which artifacts are impacted:
54
54
  ### 4. Assess Impact Scope
55
55
  Evaluate the ripple effects:
56
56
  - **Localized**: Change affects only current/next agent
57
- - **Phase-wide**: Change affects current phase (e.g., all of PLANNING)
57
+ - **Phase-wide**: Change affects current phase (e.g., all of DISCOVER or PLAN)
58
58
  - **Mode-wide**: Change affects entire mode (e.g., planning → build transition)
59
59
  - **Global**: Change affects entire project plan
60
60
 
@@ -172,7 +172,7 @@ deviation_plan:
172
172
  urgency: "medium"
173
173
 
174
174
  impact_assessment:
175
- scope: "phase-wide" # Affects multiple PLANNING agents
175
+ scope: "phase-wide" # Affects multiple DISCOVER/PLAN agents
176
176
  affected_agents:
177
177
  - agent: "detail"
178
178
  status: "completed"
@@ -191,7 +191,7 @@ escalation_report:
191
191
  context:
192
192
  previous_agent: "detail"
193
193
  session_mode: "planning"
194
- pipeline_position: "PLANNING/architect"
194
+ pipeline_position: "PLAN/architect"
195
195
 
196
196
  root_cause_analysis:
197
197
  primary_cause: "dependency-missing"
@@ -77,7 +77,7 @@ Modify `.chati/session.yaml`:
77
77
 
78
78
  ### 7. Determine Next Agent
79
79
  Based on pipeline position and mode:
80
- - **PLANNING**: Follow sequence (wu → brief → detail → architect → ux → phases → tasks → qa-planning)
80
+ - **DISCOVER → PLAN**: Follow sequence (wu → brief → detail → architect → ux → phases → tasks → qa-planning)
81
81
  - **BUILD**: dev → qa-implementation
82
82
  - **DEPLOY**: devops
83
83
  - Handle special transitions (e.g., qa-planning → dev requires mode switch)
@@ -171,7 +171,7 @@ handoff_document:
171
171
  quality_score: 8.5
172
172
  duration_minutes: 45
173
173
  mode: "planning"
174
- phase: "PLANNING"
174
+ phase: "DISCOVER"
175
175
 
176
176
  summary: |
177
177
  Completed detailed requirements analysis for HealthCare Portal.
@@ -228,7 +228,7 @@ handoff_document:
228
228
 
229
229
  session_update:
230
230
  agent_status: "completed"
231
- pipeline_progress: 37.5 # 3 of 8 PLANNING agents done
231
+ pipeline_progress: 37.5 # 3 of 8 DISCOVER/PLAN agents done
232
232
  mode_transition_check:
233
233
  eligible: false
234
234
  reason: "QA-Planning not yet complete"
@@ -54,7 +54,7 @@ Verify mode-specific requirements are met:
54
54
  **For planning → build**:
55
55
  - QA-Planning agent completed
56
56
  - QA-Planning score >= 95%
57
- - All PLANNING agents complete or skipped
57
+ - All DISCOVER/PLAN agents complete or skipped
58
58
  - No blocking issues
59
59
 
60
60
  **For build → validate**:
@@ -86,6 +86,17 @@ Assess readiness for transition:
86
86
  - Blocker status
87
87
  - Return confidence: high (>90%), medium (70-90%), low (<70%)
88
88
 
89
+ ### 6.5. User Preview Gate (BUILD → DEPLOY only)
90
+ When transitioning from BUILD to DEPLOY, the pipeline returns `nextAction: 'user_preview'` instead of advancing automatically. The orchestrator must:
91
+ 1. Execute `orchestrator-preview` task to launch a local dev server
92
+ 2. Collect user feedback (approve/adjust/rethink)
93
+ 3. Only proceed to DEPLOY after user explicitly approves
94
+ 4. Server lifecycle is user-controlled (never killed implicitly)
95
+
96
+ See `orchestrator-preview.md` for the full preview flow.
97
+
98
+ This step is skipped for transitions that don't involve BUILD → DEPLOY (e.g., PLAN → BUILD proceeds normally).
99
+
89
100
  ### 7. Execute or Suggest Transition
90
101
  Based on autonomous_gate and confidence:
91
102
  - **Auto-transition**: confidence high + autonomous enabled → execute
@@ -128,7 +139,7 @@ If user wants to force transition despite low confidence:
128
139
 
129
140
  ### When Backward Transition is Needed
130
141
  If QA-Implementation finds fundamental spec problems:
131
- 1. Identify which PLANNING agent needs to re-run
142
+ 1. Identify which DISCOVER/PLAN agent needs to re-run
132
143
  2. Mark affected agents as `needs_revalidation`
133
144
  3. Set mode to `planning`
134
145
  4. Route to earliest affected agent
@@ -182,7 +193,7 @@ mode_transition:
182
193
  from_state:
183
194
  mode: "planning"
184
195
  current_agent: "qa-planning"
185
- pipeline_position: "PLANNING/qa-planning"
196
+ pipeline_position: "PLAN/qa-planning"
186
197
 
187
198
  to_state:
188
199
  mode: "build"
@@ -208,7 +219,7 @@ mode_transition:
208
219
  score: 95
209
220
  level: "high"
210
221
  factors:
211
- - "All PLANNING agents completed"
222
+ - "All DISCOVER/PLAN agents completed"
212
223
  - "QA-Planning score excellent (97.5%)"
213
224
  - "Only 2 minor open questions"
214
225
  - "No blockers"
@@ -251,7 +262,7 @@ mode_transition:
251
262
  deviation_protocol: false
252
263
 
253
264
  user_notification: |
254
- ✓ Mode Transition: PLANNING → BUILD
265
+ ✓ Mode Transition: PLAN → BUILD
255
266
 
256
267
  QA-Planning completed with score 97.5% (>= 95% required).
257
268
  Autonomous transition to BUILD mode approved.
@@ -0,0 +1,181 @@
1
+ ---
2
+ id: orchestrator-preview
3
+ agent: orchestrator
4
+ trigger: user-preview-action
5
+ phase: build
6
+ requires_input: true
7
+ parallelizable: false
8
+ outputs: [preview-feedback, server-logs]
9
+ handoff_to: null
10
+ autonomous_gate: false
11
+ criteria:
12
+ - Server started successfully OR graceful fallback for non-visual projects
13
+ - User provided explicit feedback (approve/adjust/rethink)
14
+ - Server lifecycle managed by user decision (never killed implicitly)
15
+ - Adjustment feedback includes server logs context
16
+ ---
17
+
18
+ # Orchestrator Preview Task
19
+
20
+ ## Purpose
21
+ Launch a local preview server after QA-Implementation passes so the user can visually validate the build before deploying. The server stays alive until the user explicitly decides to kill it. Captures server logs for Dev agent context during iterative adjustments.
22
+
23
+ ## Prerequisites
24
+ - QA-Implementation completed with score >= 95%
25
+ - Pipeline state: `phase = 'build'`, `nextAction = 'user_preview'`
26
+ - Project directory with source code ready to run
27
+
28
+ ## Steps
29
+
30
+ ### 1. Detect Project Framework
31
+ Call `detectDevCommand(projectDir)` to identify:
32
+ - Framework (Next.js, Vite, Angular, Django, etc.)
33
+ - Dev command (`npm run dev`, `python manage.py runserver`, etc.)
34
+ - Default port
35
+
36
+ Also call `detectProjectKind(projectDir)` to determine UX messaging:
37
+ - `frontend` / `fullstack` / `static`: Visual preview (browser)
38
+ - `api`: Endpoint preview (suggest curl/Postman)
39
+ - `cli`: No server needed (show help command)
40
+ - `library`: No server needed (show test results/README)
41
+
42
+ ### 2. Handle Non-Visual Projects
43
+ If project kind is `cli` or `library`, or `detectDevCommand()` returns `null`:
44
+ - Skip server launch
45
+ - Present appropriate message:
46
+ - CLI: "Run `node bin/cli.js --help` to test your tool"
47
+ - Library: "Tests passed. Would you like to review the README?"
48
+ - Unknown: "Proceed to deploy, run tests, or review documentation?"
49
+ - Still collect user decision (approve/adjust/rethink)
50
+
51
+ ### 3. Find Available Port
52
+ Call `findAvailablePort(defaultPort)`:
53
+ - Starts at the framework's default port
54
+ - **NEVER kills existing processes** on occupied ports
55
+ - Scans incrementally (+1, +2, ...) up to 20 attempts
56
+ - Returns first available port
57
+
58
+ ### 4. Launch Preview Server
59
+ Call `launchPreview(projectDir, { command, args, port, framework })`:
60
+ - Spawns the dev server process
61
+ - Captures stdout/stderr into `LogBuffer` (circular, 200 lines)
62
+ - Waits for server health check (HTTP GET, 30s timeout)
63
+ - Opens browser automatically
64
+
65
+ ### 5. Present Preview to User
66
+ Display the running preview with 4 options:
67
+
68
+ ```
69
+ Your app is running at http://localhost:{PORT}
70
+ Opened in your browser.
71
+
72
+ What do you think?
73
+ 1. Deploy (keep local server running)
74
+ 2. Deploy (shut down local server)
75
+ 3. I need adjustments
76
+ 4. Rethink the approach
77
+ ```
78
+
79
+ ### 6. Process User Decision
80
+
81
+ #### Option 1: Deploy + Keep Server
82
+ - Call `confirmPreview(state, 'approve_keep')`
83
+ - Pipeline advances to DEPLOY phase
84
+ - Server stays alive (user can compare local vs production)
85
+ - Route to DevOps agent
86
+
87
+ #### Option 2: Deploy + Kill Server
88
+ - Kill the preview server process
89
+ - Call `confirmPreview(state, 'approve_kill')`
90
+ - Pipeline advances to DEPLOY phase
91
+ - Route to DevOps agent
92
+
93
+ #### Option 3: Adjustments
94
+ - Collect feedback: "What needs to change?"
95
+ - Capture server logs via `handle.logs.toContext()`
96
+ - Call `confirmPreview(state, 'adjust')`
97
+ - Route to Dev agent with context:
98
+ - User feedback (text)
99
+ - Server logs (last 200 lines)
100
+ - Filtered errors (stderr + error patterns)
101
+ - Active URL + port (server ALIVE, hot-reload active)
102
+ - After Dev completes adjustments:
103
+ - Re-run QA-Implementation (fast, diffs only)
104
+ - Return to Step 5 (user validates again)
105
+ - Loop until approval
106
+
107
+ #### Option 4: Rethink
108
+ - Server stays alive (user can reference it)
109
+ - Call `confirmPreview(state, 'rethink')`
110
+ - Activate deviation protocol
111
+ - Route to appropriate agent for rework
112
+ - When resolved, return to Step 5
113
+
114
+ ### 7. Post-Deploy Cleanup
115
+ After DevOps agent completes deployment successfully:
116
+ - Check if local preview server is still running
117
+ - If running, offer cleanup:
118
+
119
+ ```
120
+ Deploy completed successfully!
121
+ Your local server is still running at http://localhost:{PORT}.
122
+ Would you like to shut it down?
123
+ 1. Yes, shut it down
124
+ 2. No, keep it running (I want to compare)
125
+ ```
126
+
127
+ ## Decision Points
128
+
129
+ ### When Framework Detection Fails
130
+ If `detectDevCommand()` returns `null` but there's a `package.json`:
131
+ 1. Check for any script that looks like a server (dev, start, serve)
132
+ 2. If found, try running it
133
+ 3. If not found, treat as library/CLI project
134
+
135
+ ### When Server Fails to Start
136
+ If health check times out (30s):
137
+ 1. Show captured logs (errors from LogBuffer)
138
+ 2. Ask user: "Server failed to start. Want to see the error logs?"
139
+ 3. Options: Route to Dev for fix, proceed to deploy anyway, rethink
140
+
141
+ ### When Port Range Exhausted
142
+ If no port found in 20 attempts:
143
+ 1. Inform user: "Ports {start}-{start+19} are all in use"
144
+ 2. Ask user for a preferred port or to free one up
145
+ 3. Retry with user-provided port
146
+
147
+ ## Error Handling
148
+
149
+ ### Server Crash During Preview
150
+ - LogBuffer preserves crash output
151
+ - Notify user: "Server stopped unexpectedly"
152
+ - Show last error logs
153
+ - Options: Restart, route to Dev, proceed to deploy
154
+
155
+ ### Browser Failed to Open
156
+ - Show URL for manual access
157
+ - Continue normally (non-blocking)
158
+
159
+ ## Context for Dev Agent (Adjustments)
160
+
161
+ When routing to Dev agent after user requests adjustments, include:
162
+
163
+ ```yaml
164
+ preview_context:
165
+ user_feedback: "<text from user>"
166
+ server_url: "http://localhost:{PORT}"
167
+ server_alive: true
168
+ logs:
169
+ total_lines: 156
170
+ error_count: 3
171
+ errors:
172
+ - "TypeError: Cannot read properties of undefined (reading 'map')"
173
+ - "Warning: Each child in a list should have a unique key prop"
174
+ - "Error: ECONNREFUSED 127.0.0.1:5432"
175
+ recent_output:
176
+ - "[stdout] GET /api/users 200 12ms"
177
+ - "[stderr] TypeError: Cannot read properties..."
178
+ - "[stdout] GET /dashboard 200 45ms"
179
+ framework: "nextjs"
180
+ hot_reload: true
181
+ ```
@@ -50,7 +50,7 @@ Find the most recent agent with `status: completed`:
50
50
 
51
51
  ### 4. Determine Next Agent
52
52
  Based on pipeline position and last completed agent:
53
- - **PLANNING pipeline**: greenfield-wu → brief → detail → architect → ux → phases → tasks → qa-planning
53
+ - **DISCOVER → PLAN pipeline**: greenfield-wu → brief → detail → architect → ux → phases → tasks → qa-planning
54
54
  - **BUILD pipeline**: dev → qa-implementation
55
55
  - **DEPLOY pipeline**: devops
56
56
  - Handle special cases (skipped, needs_revalidation)
@@ -163,7 +163,7 @@ session_state:
163
163
  language: "Portugues"
164
164
  current_mode: "planning"
165
165
  pipeline_position:
166
- phase: "PLANNING"
166
+ phase: "DISCOVER"
167
167
  last_completed_agent: "detail"
168
168
  next_agent: "architect"
169
169
  completion_percentage: 30
@@ -58,7 +58,8 @@ Check if the requested action is valid for current position:
58
58
 
59
59
  ### 5. Select Target Agent
60
60
  Based on intent and position, identify the appropriate agent:
61
- - **PLANNING agents**: greenfield-wu, brownfield-wu, brief, detail, architect, ux, phases, tasks, qa-planning
61
+ - **DISCOVER agents**: greenfield-wu, brownfield-wu, brief, detail
62
+ - **PLAN agents**: architect, ux, phases, tasks, qa-planning
62
63
  - **BUILD agents**: dev, qa-implementation
63
64
  - **DEPLOY agents**: devops
64
65
  - **Orchestrator actions**: status, health, deviation
@@ -151,16 +152,16 @@ routing_decision:
151
152
  intent_classification: "pipeline-next"
152
153
  target_type: "agent" # or "orchestrator-action"
153
154
  target: "detail"
154
- reason: "User completed brief, detail is next in PLANNING pipeline"
155
+ reason: "User completed brief, detail is next in DISCOVER pipeline"
155
156
  mode: "planning"
156
- pipeline_position: "PLANNING/detail"
157
+ pipeline_position: "DISCOVER/detail"
157
158
  context_package:
158
159
  previous_agent: "brief"
159
160
  handoff_file: ".chati/artifacts/handoffs/2026-02-13-brief.md"
160
161
  session_excerpt:
161
162
  mode: "planning"
162
163
  project_type: "greenfield"
163
- current_phase: "PLANNING"
164
+ current_phase: "DISCOVER"
164
165
  validation:
165
166
  mode_check: "passed"
166
167
  prerequisites_check: "passed"
@@ -46,7 +46,7 @@ For each agent in the pipeline, gather:
46
46
 
47
47
  ### 3. Calculate Pipeline Progress
48
48
  Determine overall completion for each mode:
49
- - **PLANNING**: 9 agents (greenfield-wu OR brownfield-wu, brief, detail, architect, ux, phases, tasks, qa-planning)
49
+ - **DISCOVER + PLAN**: 9 agents (greenfield-wu OR brownfield-wu, brief, detail, architect, ux, phases, tasks, qa-planning)
50
50
  - **BUILD**: 2 agents (dev, qa-implementation)
51
51
  - **DEPLOY**: 1 agent (devops)
52
52
  - Calculate percentage: completed / total
@@ -160,7 +160,7 @@ status_report:
160
160
 
161
161
  current_state:
162
162
  mode: "planning"
163
- phase: "PLANNING"
163
+ phase: "DISCOVER"
164
164
  last_activity: "2026-02-13T02:15:00Z"
165
165
  hours_since_activity: 8.25
166
166
 
@@ -240,10 +240,10 @@ status_report:
240
240
  visual_report: |
241
241
  ╔════════════════════════════════════════════════════════════╗
242
242
  ║ chati.dev Status - HealthCare Portal ║
243
- ║ Mode: PLANNING | Progress: 25% (3/12 agents) ║
243
+ ║ Mode: DISCOVER | Progress: 25% (3/12 agents) ║
244
244
  ╚════════════════════════════════════════════════════════════╝
245
245
 
246
- PLANNING Pipeline (37.5%)
246
+ DISCOVER / PLAN Pipeline (37.5%)
247
247
  ✓ brownfield-wu ✓ brief ✓ detail ◐ architect ○ ux ○ phases ○ tasks ○ qa-planning
248
248
 
249
249
  BUILD Pipeline (0%)