@hanzlaa/rcode 3.4.4 → 3.4.6

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 (213) hide show
  1. package/AGENTS.md +1 -1
  2. package/CONTRIBUTING.md +63 -1
  3. package/README.md +9 -4
  4. package/cli/generate-command-skills.cjs +21 -9
  5. package/cli/index.js +0 -0
  6. package/cli/install.js +126 -7
  7. package/cli/lib/manifest.cjs +1 -1
  8. package/cli/uninstall.js +8 -0
  9. package/dist/rcode.js +1279 -2004
  10. package/package.json +16 -17
  11. package/rihal/agents/rihal-ahmed.md +2 -1
  12. package/rihal/agents/rihal-code-fixer.md +46 -0
  13. package/rihal/agents/rihal-code-reviewer.md +46 -1
  14. package/rihal/agents/rihal-deviation-analyzer.md +1 -0
  15. package/rihal/agents/rihal-docs-auditor.md +106 -1
  16. package/rihal/agents/rihal-edge-case-hunter.md +47 -1
  17. package/rihal/agents/rihal-executor.md +1 -1
  18. package/rihal/agents/rihal-khalid.md +40 -1
  19. package/rihal/agents/rihal-layla.md +2 -1
  20. package/rihal/agents/rihal-nasser.md +2 -1
  21. package/rihal/agents/rihal-noor.md +3 -2
  22. package/rihal/agents/rihal-nyquist-auditor.md +1 -1
  23. package/rihal/agents/rihal-phase-researcher.md +46 -1
  24. package/rihal/agents/rihal-planner.md +1 -1
  25. package/rihal/agents/rihal-profiler.md +45 -2
  26. package/rihal/agents/rihal-project-researcher.md +47 -0
  27. package/rihal/agents/rihal-remediation-planner.md +45 -0
  28. package/rihal/agents/rihal-roadmapper.md +46 -0
  29. package/rihal/agents/rihal-security-adversary.md +46 -1
  30. package/rihal/agents/rihal-security-auditor.md +45 -1
  31. package/rihal/agents/rihal-ui-auditor.md +44 -1
  32. package/rihal/agents/rihal-ux-designer.md +41 -1
  33. package/rihal/agents/rihal-zahra.md +2 -1
  34. package/rihal/agents/rihal-zayd.md +2 -1
  35. package/rihal/bin/lib/config.cjs +13 -1
  36. package/rihal/bin/lib/council-panel.cjs +185 -23
  37. package/rihal/bin/lib/roadmap.cjs +27 -2
  38. package/rihal/bin/rihal-tools.cjs +1837 -99
  39. package/rihal/commands/audit.md +2 -2
  40. package/rihal/commands/capture.md +12 -0
  41. package/rihal/commands/diagnose-issues.md +18 -0
  42. package/rihal/commands/discuss-phase-power.md +18 -0
  43. package/rihal/commands/feature-drift.md +18 -0
  44. package/rihal/commands/karpathy-audit.md +18 -0
  45. package/rihal/commands/lens-audit.md +70 -0
  46. package/rihal/commands/new-project-research.md +18 -0
  47. package/rihal/commands/new-project-roadmap.md +18 -0
  48. package/rihal/commands/phase.md +11 -0
  49. package/rihal/references/continuation-format.md +3 -3
  50. package/rihal/references/output-format.md +79 -0
  51. package/rihal/references/revision-loop.md +1 -1
  52. package/rihal/references/verb-dictionary.md +85 -28
  53. package/rihal/skills/actions/1-analysis/rihal-prfaq/SKILL.md +1 -1
  54. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/SKILL.md +12 -2
  55. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/steps/step-04-final-validation.md +12 -0
  56. package/rihal/skills/actions/2-plan/rihal-create-prd/SKILL.md +12 -2
  57. package/rihal/skills/actions/2-plan/rihal-create-story/SKILL.md +12 -2
  58. package/rihal/skills/actions/4-implementation/rihal-browser-verify/SKILL.md +1 -1
  59. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/SKILL.md +1 -1
  60. package/rihal/skills/actions/4-implementation/rihal-ci/SKILL.md +1 -1
  61. package/rihal/skills/actions/4-implementation/rihal-code-review/SKILL.md +16 -4
  62. package/rihal/skills/actions/4-implementation/rihal-debug/SKILL.md +14 -1
  63. package/rihal/skills/actions/4-implementation/rihal-git-flow/SKILL.md +1 -1
  64. package/rihal/skills/actions/4-implementation/rihal-harden/SKILL.md +1 -1
  65. package/rihal/skills/actions/4-implementation/rihal-incremental/SKILL.md +1 -1
  66. package/rihal/skills/actions/4-implementation/rihal-migrate/SKILL.md +1 -1
  67. package/rihal/skills/actions/4-implementation/rihal-perf/SKILL.md +1 -1
  68. package/rihal/skills/actions/4-implementation/rihal-prove-it/SKILL.md +1 -1
  69. package/rihal/skills/actions/4-implementation/rihal-scaffold-project/steps/step-01-target.md +6 -0
  70. package/rihal/skills/actions/4-implementation/rihal-source-truth/SKILL.md +1 -1
  71. package/rihal/skills/actions/4-implementation/rihal-sprint-planning/SKILL.md +14 -3
  72. package/rihal/skills/actions/4-implementation/rihal-trim/SKILL.md +1 -1
  73. package/rihal/skills/agents/ahmed-hassani-director/SKILL.md +15 -1
  74. package/rihal/skills/agents/dalil-scout/SKILL.md +14 -2
  75. package/rihal/skills/agents/fatima-qa/SKILL.md +16 -1
  76. package/rihal/skills/agents/haitham-frontend/SKILL.md +13 -1
  77. package/rihal/skills/agents/hanzla-engineer/SKILL.md +13 -1
  78. package/rihal/skills/agents/hussain-pm/SKILL.md +16 -1
  79. package/rihal/skills/agents/hussain-sm/SKILL.md +14 -1
  80. package/rihal/skills/agents/layla-designer/SKILL.md +13 -1
  81. package/rihal/skills/agents/majlis-council/SKILL.md +16 -1
  82. package/rihal/skills/agents/mariam-marketing/SKILL.md +14 -1
  83. package/rihal/skills/agents/nasser-eng-manager/SKILL.md +16 -1
  84. package/rihal/skills/agents/noor-writer/SKILL.md +15 -1
  85. package/rihal/skills/agents/raees-orchestrator/SKILL.md +15 -1
  86. package/rihal/skills/agents/rihal-cross-platform-auditor/SKILL.md +162 -0
  87. package/rihal/skills/agents/rihal-dep-auditor/SKILL.md +151 -0
  88. package/rihal/skills/agents/rihal-deviation-analyzer/SKILL.md +78 -0
  89. package/rihal/skills/agents/rihal-i18n-auditor/SKILL.md +152 -0
  90. package/rihal/skills/agents/rihal-observability-auditor/SKILL.md +156 -0
  91. package/rihal/skills/agents/sadiq-analyst/SKILL.md +12 -2
  92. package/rihal/skills/agents/waleed-architect/SKILL.md +12 -2
  93. package/rihal/skills/agents/yousef-backend/SKILL.md +12 -2
  94. package/rihal/skills/agents/zahra-branding/SKILL.md +15 -1
  95. package/rihal/skills/agents/zayd-ml/SKILL.md +13 -1
  96. package/rihal/skills/core/rihal-advanced-elicitation/SKILL.md +2 -2
  97. package/rihal/skills/core/rihal-auth-audit/SKILL.md +1 -1
  98. package/rihal/skills/core/rihal-brainstorming/SKILL.md +13 -2
  99. package/rihal/skills/core/rihal-client-gate/SKILL.md +1 -1
  100. package/rihal/skills/core/rihal-clone-website/SKILL.md +11 -1
  101. package/rihal/skills/core/rihal-deploy-unify/SKILL.md +1 -1
  102. package/rihal/skills/core/rihal-distillator/SKILL.md +2 -2
  103. package/rihal/skills/core/rihal-editorial-review-prose/SKILL.md +1 -1
  104. package/rihal/skills/core/rihal-editorial-review-structure/SKILL.md +2 -2
  105. package/rihal/skills/core/rihal-help/SKILL.md +18 -1
  106. package/rihal/skills/core/rihal-incident-record/SKILL.md +1 -1
  107. package/rihal/skills/core/rihal-index-docs/SKILL.md +1 -1
  108. package/rihal/skills/core/rihal-memory-audit/SKILL.md +18 -1
  109. package/rihal/skills/core/rihal-memory-init/SKILL.md +13 -1
  110. package/rihal/skills/core/rihal-memory-update/SKILL.md +13 -1
  111. package/rihal/skills/core/rihal-mvp-graduate/SKILL.md +1 -1
  112. package/rihal/skills/core/rihal-ocr-consistency/SKILL.md +1 -1
  113. package/rihal/skills/core/rihal-rebrand/SKILL.md +1 -1
  114. package/rihal/skills/core/rihal-review-adversarial-general/SKILL.md +1 -1
  115. package/rihal/skills/core/rihal-review-edge-case-hunter/SKILL.md +17 -1
  116. package/rihal/skills/core/rihal-shard-doc/SKILL.md +1 -1
  117. package/rihal/skills/core/rihal-theme-system/SKILL.md +1 -1
  118. package/rihal/team.yaml +0 -7
  119. package/rihal/templates/RESEARCH.md +84 -0
  120. package/rihal/templates/VALIDATION.md +45 -0
  121. package/rihal/templates/memory/INDEX.md +1 -0
  122. package/rihal/templates/memory/project/design-system.md +128 -0
  123. package/rihal/templates/summary.md +33 -3
  124. package/rihal/workflows/add-tests.md +1 -1
  125. package/rihal/workflows/add-todo.md +6 -0
  126. package/rihal/workflows/analyze-dependencies.md +6 -0
  127. package/rihal/workflows/audit-fix.md +12 -0
  128. package/rihal/workflows/audit-milestone.md +2 -2
  129. package/rihal/workflows/audit.md +23 -14
  130. package/rihal/workflows/autonomous-smart-discuss.md +247 -0
  131. package/rihal/workflows/autonomous.md +54 -267
  132. package/rihal/workflows/capture.md +60 -0
  133. package/rihal/workflows/chain.md +1 -1
  134. package/rihal/workflows/code-review-fix.md +6 -3
  135. package/rihal/workflows/code-review.md +34 -10
  136. package/rihal/workflows/complete-milestone.md +17 -8
  137. package/rihal/workflows/correct-course.md +6 -0
  138. package/rihal/workflows/council.md +37 -23
  139. package/rihal/workflows/create-architecture.md +31 -0
  140. package/rihal/workflows/create-epics-and-stories.md +7 -1
  141. package/rihal/workflows/create-prd.md +25 -0
  142. package/rihal/workflows/dashboard.md +1 -1
  143. package/rihal/workflows/debug.md +8 -0
  144. package/rihal/workflows/decisions.md +1 -1
  145. package/rihal/workflows/diff.md +6 -0
  146. package/rihal/workflows/discuss-phase-discuss-areas.md +271 -0
  147. package/rihal/workflows/discuss-phase.md +27 -266
  148. package/rihal/workflows/do.md +51 -12
  149. package/rihal/workflows/docs-update.md +3 -0
  150. package/rihal/workflows/document-project.md +7 -1
  151. package/rihal/workflows/edit-prd.md +31 -0
  152. package/rihal/workflows/enable-hooks.md +1 -1
  153. package/rihal/workflows/execute-regression-gates.md +131 -0
  154. package/rihal/workflows/execute-sprint.md +31 -2
  155. package/rihal/workflows/execute-verify-phase-goal.md +136 -0
  156. package/rihal/workflows/execute-waves.md +404 -0
  157. package/rihal/workflows/execute.md +101 -642
  158. package/rihal/workflows/feature-drift.md +243 -0
  159. package/rihal/workflows/forensics.md +10 -2
  160. package/rihal/workflows/health.md +65 -16
  161. package/rihal/workflows/help.md +36 -9
  162. package/rihal/workflows/import.md +17 -3
  163. package/rihal/workflows/init.md +20 -10
  164. package/rihal/workflows/install.md +2 -10
  165. package/rihal/workflows/lens-audit.md +689 -0
  166. package/rihal/workflows/map-codebase.md +7 -1
  167. package/rihal/workflows/memory-audit.md +67 -5
  168. package/rihal/workflows/memory-distill.md +10 -0
  169. package/rihal/workflows/memory-init.md +4 -0
  170. package/rihal/workflows/memory-update.md +4 -0
  171. package/rihal/workflows/new-milestone.md +7 -1
  172. package/rihal/workflows/new-project-create-roadmap.md +176 -0
  173. package/rihal/workflows/new-project-define-requirements.md +160 -0
  174. package/rihal/workflows/new-project-research-decision.md +247 -0
  175. package/rihal/workflows/new-project.md +3 -557
  176. package/rihal/workflows/note.md +1 -1
  177. package/rihal/workflows/phase.md +54 -0
  178. package/rihal/workflows/plan-milestone-gaps.md +1 -1
  179. package/rihal/workflows/plan-prd-express.md +108 -0
  180. package/rihal/workflows/plan-research-validation.md +313 -0
  181. package/rihal/workflows/plan-spawn-planner.md +204 -0
  182. package/rihal/workflows/plan.md +91 -532
  183. package/rihal/workflows/plant-seed.md +1 -1
  184. package/rihal/workflows/pr-branch.md +1 -1
  185. package/rihal/workflows/profile-user.md +1 -1
  186. package/rihal/workflows/quick.md +3 -3
  187. package/rihal/workflows/remove-phase.md +6 -1
  188. package/rihal/workflows/remove-workspace.md +6 -0
  189. package/rihal/workflows/rerun.md +1 -1
  190. package/rihal/workflows/research-phase.md +4 -2
  191. package/rihal/workflows/resume-work.md +8 -3
  192. package/rihal/workflows/retrospective.md +31 -0
  193. package/rihal/workflows/review-adversarial.md +12 -0
  194. package/rihal/workflows/review.md +6 -0
  195. package/rihal/workflows/scaffold-project.md +31 -0
  196. package/rihal/workflows/scan.md +10 -0
  197. package/rihal/workflows/secure-phase.md +15 -2
  198. package/rihal/workflows/session-report.md +32 -7
  199. package/rihal/workflows/ship.md +7 -2
  200. package/rihal/workflows/show.md +6 -0
  201. package/rihal/workflows/sprint-status.md +4 -4
  202. package/rihal/workflows/status.md +2 -2
  203. package/rihal/workflows/ui-phase.md +1 -1
  204. package/rihal/workflows/undo.md +2 -3
  205. package/rihal/workflows/update.md +2 -2
  206. package/rihal/workflows/validate-phase.md +1 -1
  207. package/rihal/workflows/validate-prd.md +31 -0
  208. package/rihal/workflows/verify-phase.md +38 -5
  209. package/rihal/workflows/verify-work.md +25 -11
  210. package/rihal/workflows/workstream.md +20 -8
  211. package/server/lib/html/client.js +13 -63
  212. package/server/lib/html/shell.js +0 -1
  213. package/server/lib/scanner.js +33 -2
@@ -0,0 +1,247 @@
1
+ <purpose>
2
+ Sub-step of autonomous.md — smart discuss loop for a single phase. Proposes grey area answers in batch tables; user accepts or overrides. Produces identical CONTEXT.md output to regular discuss-phase.
3
+ </purpose>
4
+
5
+ <step name="smart_discuss">
6
+
7
+ ## Smart Discuss
8
+
9
+ Run smart discuss for the current phase. Proposes grey area answers in batch tables — the user accepts or overrides per area. Produces identical CONTEXT.md output to regular discuss-phase.
10
+
11
+ **Inputs:** `PHASE_NUM` (local loop alias for `PHASE_NUMBER` from the iterate loop) from execute_phase. Resolve phase paths:
12
+
13
+ ```bash
14
+ PHASE_NUM="${PHASE_NUM}" # local alias; other workflows use PHASE_NUMBER from init JSON
15
+ PADDED_PHASE=$(printf "%02d" "${PHASE_NUM%.*}")
16
+ PHASE_DIR=".planning/phases/${PADDED_PHASE}-${PHASE_SLUG}"
17
+ ```
18
+
19
+ ---
20
+
21
+ ### Sub-step 1: Load prior context
22
+
23
+ Read project-level and prior phase context to avoid re-asking decided questions.
24
+
25
+ **Read project files:**
26
+
27
+ ```bash
28
+ cat .planning/PROJECT.md 2>/dev/null || true
29
+ cat .planning/REQUIREMENTS.md 2>/dev/null || true
30
+ cat .planning/STATE.md 2>/dev/null || true
31
+ ```
32
+
33
+ Extract from these:
34
+ - **PROJECT.md** — Vision, principles, non-negotiables, user preferences
35
+ - **REQUIREMENTS.md** — Acceptance criteria, constraints, must-haves vs nice-to-haves
36
+ - **STATE.md** — Current progress, decisions logged so far
37
+
38
+ **Read prior CONTEXT.md files (most recent 5 phases — cap prevents context overflow on large projects):**
39
+
40
+ ```bash
41
+ (find .planning/phases -name "*-CONTEXT.md" -o -name "CONTEXT.md" 2>/dev/null || true) | sort | tail -5
42
+ ```
43
+
44
+ For each CONTEXT.md where phase number < current phase (max 5):
45
+ - Read the `<decisions>` section — these are locked preferences
46
+ - Read `<specifics>` — particular references or "I want it like X" moments
47
+ - Note patterns (e.g., "user consistently prefers minimal UI", "user rejected verbose output")
48
+
49
+ **Build internal prior_decisions context** (do not write to file).
50
+
51
+ If no prior context exists, continue without — expected for early phases.
52
+
53
+ ---
54
+
55
+ ### Sub-step 2: Scout Codebase
56
+
57
+ Lightweight codebase scan to inform grey area identification. Keep under ~5% context.
58
+
59
+ **Check for existing codebase maps:**
60
+
61
+ ```bash
62
+ ls .planning/codebase/*.md 2>/dev/null || true
63
+ ```
64
+
65
+ **If codebase maps exist:** Read the most relevant ones (CONVENTIONS.md, STRUCTURE.md, STACK.md based on phase type).
66
+
67
+ **If no codebase maps, do targeted grep:**
68
+
69
+ ```bash
70
+ grep -rl "{term1}\|{term2}" src/ app/ --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" 2>/dev/null | head -10 || true
71
+ ls src/components/ src/hooks/ src/lib/ src/utils/ 2>/dev/null || true
72
+ ```
73
+
74
+ Read the 3-5 most relevant files to understand existing patterns.
75
+
76
+ **Build internal codebase_context** (do not write to file):
77
+ - **Reusable assets** — existing components, hooks, utilities usable in this phase
78
+ - **Established patterns** — how the codebase does state management, styling, data fetching
79
+ - **Integration points** — where new code connects (routes, nav, providers)
80
+
81
+ ---
82
+
83
+ ### Sub-step 3: Analyze Phase and Generate Proposals
84
+
85
+ Extract `goal`, `requirements`, `success_criteria` from ROADMAP.md for this phase.
86
+
87
+ **Infrastructure detection — check FIRST:**
88
+
89
+ A phase is pure infrastructure when ALL are true:
90
+ 1. Goal keywords match: "scaffolding", "plumbing", "setup", "configuration", "migration", "refactor", "rename", "restructure", "upgrade", "infrastructure"
91
+ 2. AND success criteria are all technical: "file exists", "test passes", "config valid", "command runs"
92
+ 3. AND no user-facing behavior is described (no "users can", "displays", "shows", "presents")
93
+
94
+ **If infrastructure-only:** Skip Sub-step 4. Jump directly to Sub-step 5 with minimal CONTEXT.md. Display:
95
+
96
+ ```
97
+ Phase ${PHASE_NUM}: Infrastructure phase — skipping discuss, writing minimal context.
98
+ ```
99
+
100
+ **If NOT infrastructure — generate grey area proposals:**
101
+
102
+ Determine domain type from the phase goal:
103
+ - Something users **SEE** → visual: layout, interactions, states, density
104
+ - Something users **CALL** → interface: contracts, responses, errors, auth
105
+ - Something users **RUN** → execution: invocation, output, behavior modes, flags
106
+ - Something users **READ** → content: structure, tone, depth, flow
107
+ - Something being **ORGANIZED** → organization: criteria, grouping, exceptions, naming
108
+
109
+ Check prior_decisions — skip grey areas already decided in prior phases.
110
+
111
+ Generate **3-4 grey areas** with **~4 questions each**. For each question:
112
+ - **Pre-select a recommended answer** based on: prior decisions, codebase patterns, domain conventions, ROADMAP success criteria
113
+ - Generate **1-2 alternatives** per question
114
+ - **Annotate** with prior decision context and code context
115
+
116
+ ---
117
+
118
+ ### Sub-step 4: Present Proposals Per Area
119
+
120
+ Present grey areas **one at a time**. For each area (M of N), display a table:
121
+
122
+ ```
123
+ ### Grey Area {M}/{N}: {Area Name}
124
+
125
+ | # | Question | ✓ Recommended | Alternative(s) |
126
+ |---|----------|---------------|-----------------|
127
+ | 1 | {question} | {answer} — {rationale} | {alt1}; {alt2} |
128
+ | 2 | {question} | {answer} — {rationale} | {alt1} |
129
+ | 3 | {question} | {answer} — {rationale} | {alt1}; {alt2} |
130
+ | 4 | {question} | {answer} — {rationale} | {alt1} |
131
+ ```
132
+
133
+ Then prompt via **AskUserQuestion**:
134
+ - **header:** "Area {M}/{N}"
135
+ - **question:** "Accept these answers for {Area Name}?"
136
+ - **options:** Build dynamically — always "Accept all" first, then "Change Q1" through "Change QN" for each question (up to 4), then "Discuss deeper" last. Cap at 6 explicit options max.
137
+
138
+ **On "Accept all":** Record all recommended answers. Move to next area.
139
+
140
+ **On "Change QN":** Use AskUserQuestion with the alternatives for that specific question:
141
+ - **options:** List the 1-2 alternatives plus "You decide" (maps to Claude's Discretion)
142
+
143
+ Record the user's choice. Re-display updated table. Re-present acceptance prompt.
144
+
145
+ **On "Discuss deeper":** Switch to interactive mode — ask questions one at a time using AskUserQuestion with 2-3 concrete options per question plus "You decide". After 4 questions, prompt:
146
+ - **options:** "More questions" / "Next area"
147
+
148
+ **On "Other" (free text):** Interpret as a change request or general feedback. Incorporate, re-display, re-present.
149
+
150
+ **Scope creep handling:** If user mentions something outside the phase domain:
151
+
152
+ ```
153
+ "{Feature} sounds like a new capability — that belongs in its own phase.
154
+ I'll note it as a deferred idea.
155
+
156
+ Back to {current area}: {return to current question}"
157
+ ```
158
+
159
+ Track deferred ideas internally for inclusion in CONTEXT.md.
160
+
161
+ ---
162
+
163
+ ### Sub-step 5: Write CONTEXT.md
164
+
165
+ After all areas are resolved (or infrastructure skip), write the CONTEXT.md file.
166
+
167
+ **File path:** `${PHASE_DIR}/${PADDED_PHASE}-CONTEXT.md`
168
+
169
+ Use **exactly** this structure:
170
+
171
+ ```markdown
172
+ # Phase {PHASE_NUM}: {Phase Name} - Context
173
+
174
+ **Gathered:** {date}
175
+ **Status:** Ready for planning
176
+
177
+ <domain>
178
+ ## Phase Boundary
179
+
180
+ {Domain boundary statement from analysis}
181
+
182
+ </domain>
183
+
184
+ <decisions>
185
+ ## Implementation Decisions
186
+
187
+ ### {Area 1 Name}
188
+ - {Accepted/chosen answer for Q1}
189
+ - {Accepted/chosen answer for Q2}
190
+
191
+ ### {Area 2 Name}
192
+ - {Accepted/chosen answer for Q1}
193
+
194
+ ### Claude's Discretion
195
+ {Any "You decide" answers collected}
196
+
197
+ </decisions>
198
+
199
+ <code_context>
200
+ ## Existing Code Insights
201
+
202
+ ### Reusable Assets
203
+ - {From codebase scout}
204
+
205
+ ### Established Patterns
206
+ - {From codebase scout}
207
+
208
+ ### Integration Points
209
+ - {From codebase scout}
210
+
211
+ </code_context>
212
+
213
+ <specifics>
214
+ ## Specific Ideas
215
+
216
+ {Any specific references from discussion}
217
+ {If none: "No specific requirements — open to standard approaches"}
218
+
219
+ </specifics>
220
+
221
+ <deferred>
222
+ ## Deferred Ideas
223
+
224
+ {Ideas captured but out of scope}
225
+ {If none: "None — discussion stayed within phase scope"}
226
+
227
+ </deferred>
228
+ ```
229
+
230
+ Write the file.
231
+
232
+ **Commit (guarded):**
233
+
234
+ ```bash
235
+ git add "${PHASE_DIR}/${PADDED_PHASE}-CONTEXT.md" 2>/dev/null \
236
+ && git commit -m "docs(${PADDED_PHASE}): smart discuss context" 2>/dev/null \
237
+ || echo "ℹ .planning/ gitignored — context written, not committed"
238
+ ```
239
+
240
+ Display confirmation:
241
+
242
+ ```
243
+ Created: {path}
244
+ Decisions captured: {count} across {area_count} areas
245
+ ```
246
+
247
+ </step>
@@ -170,7 +170,9 @@ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
170
170
  STATE=$(node .rihal/bin/rihal-tools.cjs state read 2>/dev/null || echo '{}')
171
171
  ```
172
172
 
173
- Parse JSON for: `milestone_version`, `milestone_name`, `phase_count`, `completed_phases`, `roadmap_exists`, `state_exists`, `commit_docs`.
173
+ Parse JSON for: `milestone_version`, `milestone_name`, `phase_count`, `completed_phases`, `roadmap_exists`, `state_exists`, `commit_docs`, `response_language`.
174
+
175
+ **If `response_language` is set:** include `Respond in {response_language}.` in all spawned subagent prompts.
174
176
 
175
177
  **If `roadmap_exists` is false:** Error — "No ROADMAP.md found. Run `/rihal-new-milestone` first."
176
178
  **If `state_exists` is false:** Error — "No STATE.md found. Run `/rihal-new-milestone` first."
@@ -201,10 +203,10 @@ Parse ROADMAP.md directly (rihal-tools does not expose `roadmap analyze`):
201
203
 
202
204
  ```bash
203
205
  cat .planning/ROADMAP.md
204
- # For per-phase detail, inspect .planning/phases/<phase_slug>/ directory for PLAN.md, SPRINT.md, SUMMARY.md presence
206
+ # For per-phase detail, inspect .planning/phases/<phase_slug>/ directory for SPRINT.md, SUMMARY.md presence
205
207
  ```
206
208
 
207
- Build an internal `phases` array with: `number`, `name`, `goal`, `disk_status` (complete if SUMMARY.md exists, partial if PLAN.md exists without SUMMARY.md, planned if neither), `has_ui_hint`.
209
+ Build an internal `phases` array with: `number`, `name`, `goal`, `disk_status` (complete if SUMMARY.md exists, partial if SPRINT.md exists without SUMMARY.md, planned if neither), `has_ui_hint`.
208
210
 
209
211
  **Filter to incomplete phases:** Keep only phases where `disk_status !== "complete"`.
210
212
 
@@ -343,6 +345,13 @@ All implementation choices are at Claude's discretion — discuss phase was skip
343
345
 
344
346
  </decisions>
345
347
 
348
+ <canonical_refs>
349
+ ## Canonical References
350
+
351
+ No external specs pre-gathered — discuss phase skipped. Planner will extract canonical refs from ROADMAP.md during research.
352
+
353
+ </canonical_refs>
354
+
346
355
  <code_context>
347
356
  ## Existing Code Insights
348
357
 
@@ -468,7 +477,7 @@ Auto-invoke code review and fix chain. Autonomous mode chains both review and fi
468
477
 
469
478
  **Config gate:**
470
479
  ```bash
471
- CODE_REVIEW_ENABLED=$(node .rihal/bin/rihal-tools.cjs config 2>/dev/null | grep -oE '"code_review"[^,}]*' | grep -oE 'true|false' || echo "true")
480
+ CODE_REVIEW_ENABLED=$(node .rihal/bin/rihal-tools.cjs config 2>/dev/null | grep -oE '"code_review"[^,}]*' | grep -oE 'true|false' || echo "false")
472
481
  ```
473
482
  If `"false"`: display "Code review skipped (workflow.code_review=false)" and proceed to 3d.
474
483
 
@@ -501,7 +510,7 @@ Go to handle_blocker: "Execute phase ${PHASE_NUM} did not produce verification r
501
510
 
502
511
  Display:
503
512
  ```
504
- Phase ${PHASE_NUM} ${PHASE_NAME} — Verification passed
513
+ Phase ${PHASE_NUM} ${PHASE_NAME} — Verification passed
505
514
  ```
506
515
 
507
516
  Proceed to iterate step.
@@ -518,7 +527,7 @@ On **"Validate now"**: Present the specific items from VERIFICATION.md. After us
518
527
  - **question:** "Validation result?"
519
528
  - **options:** "All good — continue" / "Found issues"
520
529
 
521
- On "All good — continue": Display `Phase ${PHASE_NUM} Human validation passed` and proceed to iterate step.
530
+ On "All good — continue": Display `Phase ${PHASE_NUM} Human validation passed` and proceed to iterate step.
522
531
 
523
532
  On "Found issues": Go to handle_blocker with the user's reported issues as the description.
524
533
 
@@ -532,11 +541,14 @@ Read gap summary from VERIFICATION.md (score and missing items). Display:
532
541
  Score: {N}/{M} must-haves verified
533
542
  ```
534
543
 
535
- Ask user via AskUserQuestion:
544
+ **If `INTERACTIVE` is set:** Ask via AskUserQuestion:
536
545
  - **question:** "Gaps found in phase ${PHASE_NUM}. How to proceed?"
537
546
  - **options:** "Run gap closure" / "Continue without fixing" / "Stop autonomous mode"
547
+ - On "Stop": go to handle_blocker
548
+
549
+ **If `INTERACTIVE` is NOT set (default autonomous):** Auto-select "Run gap closure" — display `⚙ Phase ${PHASE_NUM}: auto-running gap closure` and proceed.
538
550
 
539
- On **"Run gap closure"**: Execute gap closure cycle (limit: 1 attempt):
551
+ Execute gap closure cycle (limit: 1 attempt):
540
552
 
541
553
  ```
542
554
  Skill(skill="rihal-plan", args="${PHASE_NUM} --gaps")
@@ -549,15 +561,12 @@ Re-execute:
549
561
  Skill(skill="rihal-execute", args="${PHASE_NUM} --no-transition")
550
562
  ```
551
563
 
552
- Re-read verification status. If `passed` or `human_needed`: route normally. If still `gaps_found` after this retry: ask via AskUserQuestion:
553
- - **options:** "Continue anyway" / "Stop autonomous mode"
564
+ Re-read verification status. If `passed` or `human_needed`: route normally. If still `gaps_found` after this retry:
565
+ - **If `INTERACTIVE`:** ask "Continue anyway / Stop autonomous mode"
566
+ - **Otherwise:** display `⏭ Phase ${PHASE_NUM}: gaps persist after closure — continuing` and proceed to iterate step.
554
567
 
555
568
  This limits gap closure to 1 automatic retry to prevent infinite loops.
556
569
 
557
- On **"Continue without fixing"**: Display `Phase ${PHASE_NUM} ⏭ Gaps deferred` and proceed to iterate step.
558
-
559
- On **"Stop autonomous mode"**: Go to handle_blocker with "User stopped — gaps remain in phase ${PHASE_NUM}".
560
-
561
570
  ### 3d.5. UI Review (Frontend Phases)
562
571
 
563
572
  > Run after any successful execution routing (passed, human_needed accepted, or gaps deferred/accepted) — before proceeding to the iterate step.
@@ -585,249 +594,8 @@ Display the review result summary (score from UI-REVIEW.md if produced). Continu
585
594
 
586
595
  </step>
587
596
 
588
- <step name="smart_discuss">
589
-
590
- ## Smart Discuss
591
-
592
- Run smart discuss for the current phase. Proposes grey area answers in batch tables — the user accepts or overrides per area. Produces identical CONTEXT.md output to regular discuss-phase.
593
-
594
- **Inputs:** `PHASE_NUM` from execute_phase. Resolve phase paths:
595
-
596
- ```bash
597
- PHASE_NUM="${PHASE_NUM}"
598
- PADDED_PHASE=$(printf "%02d" "${PHASE_NUM%.*}")
599
- PHASE_DIR=".planning/phases/${PADDED_PHASE}-${PHASE_SLUG}"
600
- ```
601
-
602
- ---
603
-
604
- ### Sub-step 1: Load prior context
605
-
606
- Read project-level and prior phase context to avoid re-asking decided questions.
607
-
608
- **Read project files:**
609
-
610
- ```bash
611
- cat .planning/PROJECT.md 2>/dev/null || true
612
- cat .planning/REQUIREMENTS.md 2>/dev/null || true
613
- cat .planning/STATE.md 2>/dev/null || true
614
- ```
615
-
616
- Extract from these:
617
- - **PROJECT.md** — Vision, principles, non-negotiables, user preferences
618
- - **REQUIREMENTS.md** — Acceptance criteria, constraints, must-haves vs nice-to-haves
619
- - **STATE.md** — Current progress, decisions logged so far
620
-
621
- **Read all prior CONTEXT.md files:**
622
-
623
- ```bash
624
- (find .planning/phases -name "*-CONTEXT.md" -o -name "CONTEXT.md" 2>/dev/null || true) | sort
625
- ```
626
-
627
- For each CONTEXT.md where phase number < current phase:
628
- - Read the `<decisions>` section — these are locked preferences
629
- - Read `<specifics>` — particular references or "I want it like X" moments
630
- - Note patterns (e.g., "user consistently prefers minimal UI", "user rejected verbose output")
631
-
632
- **Build internal prior_decisions context** (do not write to file).
633
-
634
- If no prior context exists, continue without — expected for early phases.
635
-
636
- ---
637
-
638
- ### Sub-step 2: Scout Codebase
639
-
640
- Lightweight codebase scan to inform grey area identification. Keep under ~5% context.
641
-
642
- **Check for existing codebase maps:**
643
-
644
- ```bash
645
- ls .planning/codebase/*.md 2>/dev/null || true
646
- ```
647
-
648
- **If codebase maps exist:** Read the most relevant ones (CONVENTIONS.md, STRUCTURE.md, STACK.md based on phase type).
649
-
650
- **If no codebase maps, do targeted grep:**
651
-
652
- ```bash
653
- grep -rl "{term1}\|{term2}" src/ app/ --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" 2>/dev/null | head -10 || true
654
- ls src/components/ src/hooks/ src/lib/ src/utils/ 2>/dev/null || true
655
- ```
656
-
657
- Read the 3-5 most relevant files to understand existing patterns.
658
-
659
- **Build internal codebase_context** (do not write to file):
660
- - **Reusable assets** — existing components, hooks, utilities usable in this phase
661
- - **Established patterns** — how the codebase does state management, styling, data fetching
662
- - **Integration points** — where new code connects (routes, nav, providers)
663
-
664
- ---
665
-
666
- ### Sub-step 3: Analyze Phase and Generate Proposals
667
-
668
- Extract `goal`, `requirements`, `success_criteria` from ROADMAP.md for this phase.
669
-
670
- **Infrastructure detection — check FIRST:**
671
-
672
- A phase is pure infrastructure when ALL are true:
673
- 1. Goal keywords match: "scaffolding", "plumbing", "setup", "configuration", "migration", "refactor", "rename", "restructure", "upgrade", "infrastructure"
674
- 2. AND success criteria are all technical: "file exists", "test passes", "config valid", "command runs"
675
- 3. AND no user-facing behavior is described (no "users can", "displays", "shows", "presents")
676
-
677
- **If infrastructure-only:** Skip Sub-step 4. Jump directly to Sub-step 5 with minimal CONTEXT.md. Display:
678
-
679
- ```
680
- Phase ${PHASE_NUM}: Infrastructure phase — skipping discuss, writing minimal context.
681
- ```
682
-
683
- **If NOT infrastructure — generate grey area proposals:**
684
-
685
- Determine domain type from the phase goal:
686
- - Something users **SEE** → visual: layout, interactions, states, density
687
- - Something users **CALL** → interface: contracts, responses, errors, auth
688
- - Something users **RUN** → execution: invocation, output, behavior modes, flags
689
- - Something users **READ** → content: structure, tone, depth, flow
690
- - Something being **ORGANIZED** → organization: criteria, grouping, exceptions, naming
691
-
692
- Check prior_decisions — skip grey areas already decided in prior phases.
693
-
694
- Generate **3-4 grey areas** with **~4 questions each**. For each question:
695
- - **Pre-select a recommended answer** based on: prior decisions, codebase patterns, domain conventions, ROADMAP success criteria
696
- - Generate **1-2 alternatives** per question
697
- - **Annotate** with prior decision context and code context
698
-
699
- ---
700
-
701
- ### Sub-step 4: Present Proposals Per Area
702
-
703
- Present grey areas **one at a time**. For each area (M of N), display a table:
704
-
705
- ```
706
- ### Grey Area {M}/{N}: {Area Name}
707
-
708
- | # | Question | ✅ Recommended | Alternative(s) |
709
- |---|----------|---------------|-----------------|
710
- | 1 | {question} | {answer} — {rationale} | {alt1}; {alt2} |
711
- | 2 | {question} | {answer} — {rationale} | {alt1} |
712
- | 3 | {question} | {answer} — {rationale} | {alt1}; {alt2} |
713
- | 4 | {question} | {answer} — {rationale} | {alt1} |
714
- ```
715
-
716
- Then prompt via **AskUserQuestion**:
717
- - **header:** "Area {M}/{N}"
718
- - **question:** "Accept these answers for {Area Name}?"
719
- - **options:** Build dynamically — always "Accept all" first, then "Change Q1" through "Change QN" for each question (up to 4), then "Discuss deeper" last. Cap at 6 explicit options max.
720
-
721
- **On "Accept all":** Record all recommended answers. Move to next area.
722
-
723
- **On "Change QN":** Use AskUserQuestion with the alternatives for that specific question:
724
- - **options:** List the 1-2 alternatives plus "You decide" (maps to Claude's Discretion)
725
-
726
- Record the user's choice. Re-display updated table. Re-present acceptance prompt.
727
-
728
- **On "Discuss deeper":** Switch to interactive mode — ask questions one at a time using AskUserQuestion with 2-3 concrete options per question plus "You decide". After 4 questions, prompt:
729
- - **options:** "More questions" / "Next area"
730
-
731
- **On "Other" (free text):** Interpret as a change request or general feedback. Incorporate, re-display, re-present.
732
-
733
- **Scope creep handling:** If user mentions something outside the phase domain:
734
-
735
- ```
736
- "{Feature} sounds like a new capability — that belongs in its own phase.
737
- I'll note it as a deferred idea.
738
-
739
- Back to {current area}: {return to current question}"
740
- ```
741
-
742
- Track deferred ideas internally for inclusion in CONTEXT.md.
743
-
744
- ---
745
-
746
- ### Sub-step 5: Write CONTEXT.md
747
-
748
- After all areas are resolved (or infrastructure skip), write the CONTEXT.md file.
749
-
750
- **File path:** `${PHASE_DIR}/${PADDED_PHASE}-CONTEXT.md`
597
+ @rihal/workflows/autonomous-smart-discuss.md
751
598
 
752
- Use **exactly** this structure:
753
-
754
- ```markdown
755
- # Phase {PHASE_NUM}: {Phase Name} - Context
756
-
757
- **Gathered:** {date}
758
- **Status:** Ready for planning
759
-
760
- <domain>
761
- ## Phase Boundary
762
-
763
- {Domain boundary statement from analysis}
764
-
765
- </domain>
766
-
767
- <decisions>
768
- ## Implementation Decisions
769
-
770
- ### {Area 1 Name}
771
- - {Accepted/chosen answer for Q1}
772
- - {Accepted/chosen answer for Q2}
773
-
774
- ### {Area 2 Name}
775
- - {Accepted/chosen answer for Q1}
776
-
777
- ### Claude's Discretion
778
- {Any "You decide" answers collected}
779
-
780
- </decisions>
781
-
782
- <code_context>
783
- ## Existing Code Insights
784
-
785
- ### Reusable Assets
786
- - {From codebase scout}
787
-
788
- ### Established Patterns
789
- - {From codebase scout}
790
-
791
- ### Integration Points
792
- - {From codebase scout}
793
-
794
- </code_context>
795
-
796
- <specifics>
797
- ## Specific Ideas
798
-
799
- {Any specific references from discussion}
800
- {If none: "No specific requirements — open to standard approaches"}
801
-
802
- </specifics>
803
-
804
- <deferred>
805
- ## Deferred Ideas
806
-
807
- {Ideas captured but out of scope}
808
- {If none: "None — discussion stayed within phase scope"}
809
-
810
- </deferred>
811
- ```
812
-
813
- Write the file.
814
-
815
- **Commit (guarded):**
816
-
817
- ```bash
818
- git add "${PHASE_DIR}/${PADDED_PHASE}-CONTEXT.md" 2>/dev/null \
819
- && git commit -m "docs(${PADDED_PHASE}): smart discuss context" 2>/dev/null \
820
- || echo "ℹ .planning/ gitignored — context written, not committed"
821
- ```
822
-
823
- Display confirmation:
824
-
825
- ```
826
- Created: {path}
827
- Decisions captured: {count} across {area_count} areas
828
- ```
829
-
830
- </step>
831
599
 
832
600
  <step name="iterate">
833
601
 
@@ -900,6 +668,25 @@ Check for blockers in the Blockers/Concerns section. If blockers are found, go t
900
668
 
901
669
  If incomplete phases remain: proceed to next phase, loop back to execute_phase.
902
670
 
671
+ **Token cost report and /clear offer (closes #586):**
672
+
673
+ After each phase completes, display a cost summary:
674
+
675
+ ```
676
+ Phase {N} ✓ {name} — {sprint_count} sprints, {revision_count} revision(s)
677
+ ```
678
+
679
+ Track `PHASES_COMPLETED` (increment after each iterate). Every 3 completed phases:
680
+
681
+ ```
682
+ ⚠ Context growing — {PHASES_COMPLETED} phases done in this session.
683
+ Tip: /clear now and resume to keep remaining phases lean:
684
+ /rihal-autonomous --from {next_phase} --to {TO_PHASE}
685
+ Continue anyway? [Yes, keep going] / [I'll clear now — show resume command]
686
+ ```
687
+
688
+ In `mode: yolo`: skip the offer and just print the resume command as an info line.
689
+
903
690
  **Interactive mode overlap:** When `INTERACTIVE` is set, the iterate step enables pipeline parallelism:
904
691
  1. After discuss completes for Phase N, dispatch plan+execute as background agents
905
692
  2. Immediately start discuss for Phase N+1 while Phase N builds
@@ -963,7 +750,7 @@ AUDIT_STATUS=$(grep "^status:" "${AUDIT_FILE}" 2>/dev/null | head -1 | cut -d: -
963
750
  **If `passed`:**
964
751
 
965
752
  ```
966
- Audit passed — proceeding to complete milestone
753
+ Audit passed — proceeding to complete milestone
967
754
  ```
968
755
 
969
756
  Proceed to 5b.
@@ -975,22 +762,22 @@ Read the gaps summary from the audit file. Display:
975
762
  ⚠ Audit: Gaps Found
976
763
  ```
977
764
 
978
- Ask user via AskUserQuestion:
765
+ **If `INTERACTIVE`:** Ask via AskUserQuestion:
979
766
  - **question:** "Milestone audit found gaps. How to proceed?"
980
767
  - **options:** "Continue anyway — accept gaps" / "Stop — fix gaps manually"
768
+ - On "Stop": Go to handle_blocker.
981
769
 
982
- On **"Continue anyway"**: Display `Audit ⏭ Gaps accepted` and proceed to 5b.
983
-
984
- On **"Stop"**: Go to handle_blocker.
770
+ **Otherwise (autonomous):** Display `Audit ⏭ Gaps accepted — continuing` and proceed to 5b.
985
771
 
986
772
  **If `tech_debt`:**
987
773
 
988
- Show the summary, then ask user via AskUserQuestion:
989
- - **options:** "Continue with tech debt" / "Stop — address debt first"
774
+ Show the summary, then:
990
775
 
991
- On **"Continue with tech debt"**: Proceed to 5b.
776
+ **If `INTERACTIVE`:** Ask via AskUserQuestion:
777
+ - **options:** "Continue with tech debt" / "Stop — address debt first"
778
+ - On "Stop": Go to handle_blocker.
992
779
 
993
- On **"Stop"**: Go to handle_blocker.
780
+ **Otherwise (autonomous):** Display `Tech debt noted — continuing` and proceed to 5b.
994
781
 
995
782
  ### 5b. Complete Milestone
996
783
 
@@ -1022,8 +809,8 @@ Cleanup shows its own dry-run and asks user for approval internally — this is
1022
809
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1023
810
 
1024
811
  Milestone: {milestone_version} — {milestone_name}
1025
- Status: Complete
1026
- Lifecycle: audit → complete → cleanup
812
+ Status: Complete
813
+ Lifecycle: audit → complete → cleanup
1027
814
 
1028
815
  Ship it! 🚀
1029
816
  ```