@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,271 @@
1
+ <purpose>
2
+ Sub-step of discuss-phase.md — discuss_areas step. Walks through each selected grey area with the user, collects decisions, and records them for CONTEXT.md.
3
+ </purpose>
4
+
5
+ <step name="discuss_areas">
6
+ Discuss each selected area with the user. Flow depends on advisor mode.
7
+
8
+ **If ADVISOR_MODE is true:**
9
+
10
+ Table-first discussion flow — present research-backed comparison tables, then capture user picks.
11
+
12
+ **For each selected area:**
13
+
14
+ 1. **Present the synthesized comparison table + rationale paragraph** (from advisor_research step)
15
+
16
+ 2. **Use AskUserQuestion:**
17
+ - header: "{area_name}"
18
+ - question: "Which approach for {area_name}?"
19
+ - options: Extract from the table's Option column (AskUserQuestion adds "Other" automatically)
20
+
21
+ 3. **Record the user's selection:**
22
+ - If user picks from table options → record as locked decision for that area
23
+ - If user picks "Other" → receive their input, reflect it back for confirmation, record
24
+
25
+ **Thinking partner (conditional):**
26
+ If `features.thinking_partner` is enabled in config, check the user's answer for tradeoff signals
27
+ (see `references/thinking-partner.md` for signal list). If tradeoff detected:
28
+
29
+ ```
30
+ I notice competing priorities here — {option_A} optimizes for {goal_A} while {option_B} optimizes for {goal_B}.
31
+
32
+ Want me to think through the tradeoffs before we lock this in?
33
+ [Yes, analyze] / [No, decision made]
34
+ ```
35
+
36
+ If yes: provide 3-5 bullet analysis (what each optimizes/sacrifices, alignment with PROJECT.md goals, recommendation). Then return to normal flow.
37
+ If no or thinking_partner disabled: continue to next area.
38
+
39
+ 4. **After recording pick, Claude decides whether follow-up questions are needed:**
40
+ - If the pick has ambiguity that would affect downstream planning → ask 1-2 targeted follow-up questions using AskUserQuestion
41
+ - If the pick is clear and self-contained → move to next area
42
+ - Do NOT ask the standard 4 questions — the table already provided the context
43
+
44
+ 5. **After all areas processed:**
45
+ - header: "Done"
46
+ - question: "That covers [list areas]. Ready to create context?"
47
+ - options: "Create context" / "Revisit an area"
48
+
49
+ **Scope creep handling (advisor mode):**
50
+ If user mentions something outside the phase domain:
51
+ ```
52
+ "[Feature] sounds like a new capability — that belongs in its own phase.
53
+ I'll note it as a deferred idea.
54
+
55
+ Back to [current area]: [return to current question]"
56
+ ```
57
+
58
+ Track deferred ideas internally.
59
+
60
+ ---
61
+
62
+ **If ADVISOR_MODE is false:**
63
+
64
+ For each selected area, conduct a focused discussion loop.
65
+
66
+ **Research-before-questions mode:** Check if `workflow.research_before_questions` is enabled in config (from init context or `.planning/config.json`). When enabled, before presenting questions for each area:
67
+ 1. Do a brief web search for best practices related to the area topic
68
+ 2. Summarize the top findings in 2-3 bullet points
69
+ 3. Present the research alongside the question so the user can make a more informed decision
70
+
71
+ Example with research enabled:
72
+ ```
73
+ Let's talk about [Authentication Strategy].
74
+
75
+ 📊 Best practices research:
76
+ • OAuth 2.0 + PKCE is the current standard for SPAs (replaces implicit flow)
77
+ • Session tokens with httpOnly cookies preferred over localStorage for XSS protection
78
+ • Consider passkey/WebAuthn support — adoption is accelerating in 2025-2026
79
+
80
+ With that context: How should users authenticate?
81
+ ```
82
+
83
+ When disabled (default), skip the research and present questions directly as before.
84
+
85
+ **Text mode support:** Parse optional `--text` from `$ARGUMENTS`.
86
+ - Accept `--text` flag OR read `workflow.text_mode` from config (from init context)
87
+ - When active, replace ALL `AskUserQuestion` calls with plain-text numbered lists
88
+ - User types a number to select, or types free text for "Other"
89
+ - This is required for Claude Code remote sessions (`/rc` mode) where TUI menus
90
+ don't work through the Claude App
91
+
92
+ **Batch mode support:** Parse optional `--batch` from `$ARGUMENTS`.
93
+ - Accept `--batch`, `--batch=N`, or `--batch N`
94
+
95
+ **Analyze mode support:** Parse optional `--analyze` from `$ARGUMENTS`.
96
+ When `--analyze` is active, before presenting each question (or question group in batch mode), provide a brief **trade-off analysis** for the decision:
97
+ - 2-3 options with pros/cons based on codebase context and common patterns
98
+ - A recommended approach with reasoning
99
+ - Known pitfalls or constraints from prior phases
100
+
101
+ Example with `--analyze`:
102
+ ```
103
+ **Trade-off analysis: Authentication strategy**
104
+
105
+ | Approach | Pros | Cons |
106
+ |----------|------|------|
107
+ | Session cookies | Simple, httpOnly prevents XSS | Requires CSRF protection, sticky sessions |
108
+ | JWT (stateless) | Scalable, no server state | Token size, revocation complexity |
109
+ | OAuth 2.0 + PKCE | Industry standard for SPAs | More setup, redirect flow UX |
110
+
111
+ 💡 Recommended: OAuth 2.0 + PKCE — your app has social login in requirements (REQ-04) and this aligns with the existing NextAuth setup in `src/lib/auth.ts`.
112
+
113
+ How should users authenticate?
114
+ ```
115
+
116
+ This gives the user context to make informed decisions without extra prompting. When `--analyze` is absent, present questions directly as before.
117
+ - Accept `--batch`, `--batch=N`, or `--batch N`
118
+ - Default to 4 questions per batch when no number is provided
119
+ - Clamp explicit sizes to 2-5 so a batch stays answerable
120
+ - If `--batch` is absent, keep the existing one-question-at-a-time flow
121
+
122
+ **Philosophy:** stay adaptive, but let the user choose the pacing.
123
+ - Default mode: 4 single-question turns, then check whether to continue
124
+ - `--batch` mode: 1 grouped turn with 2-5 numbered questions, then check whether to continue
125
+
126
+ Each answer (or answer set, in batch mode) should reveal the next question or next batch.
127
+
128
+ **Auto mode (`--auto`):** For each area, Claude selects the recommended option (first option, or the one explicitly marked "recommended") for every question without using AskUserQuestion. Log each auto-selected choice:
129
+ ```
130
+ [auto] [Area] — Q: "[question text]" → Selected: "[chosen option]" (recommended default)
131
+ ```
132
+ After all areas are auto-resolved, skip the "Explore more gray areas" prompt and proceed directly to write_context.
133
+
134
+ **CRITICAL — Auto-mode pass cap:**
135
+ In `--auto` mode, the discuss step MUST complete in a **single pass**. After writing CONTEXT.md once, you are DONE — proceed immediately to write_context and then auto_advance. Do NOT re-read your own CONTEXT.md to find "gaps", "undefined types", or "missing decisions" and run additional passes. This creates a self-feeding loop where each pass generates references that the next pass treats as gaps, consuming unbounded time and resources.
136
+
137
+ Check the pass cap from config:
138
+ ```bash
139
+ MAX_PASSES=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow.max_discuss_passes 2>/dev/null || echo "3")
140
+ ```
141
+
142
+ If you have already written and committed CONTEXT.md, the discuss step is complete. Move on.
143
+
144
+ **Interactive mode (no `--auto`):**
145
+
146
+ **For each area:**
147
+
148
+ 1. **Announce the area:**
149
+ ```
150
+ Let's talk about [Area].
151
+ ```
152
+
153
+ 2. **Ask questions using the selected pacing:**
154
+
155
+ **Default (no `--batch`): Ask 4 questions using AskUserQuestion**
156
+ - header: "[Area]" (max 12 chars — abbreviate if needed)
157
+ - question: Specific decision for this area
158
+ - options: 2-3 concrete choices (AskUserQuestion adds "Other" automatically), with the recommended choice highlighted and brief explanation why
159
+ - **Annotate options with code context** when relevant:
160
+ ```
161
+ "How should posts be displayed?"
162
+ - Cards (reuses existing Card component — consistent with Messages)
163
+ - List (simpler, would be a new pattern)
164
+ - Timeline (needs new Timeline component — none exists yet)
165
+ ```
166
+ - Include "You decide" as an option when reasonable — captures Claude discretion
167
+ - **Context7 for library choices:** When a gray area involves library selection (e.g., "magic links" → query next-auth docs) or API approach decisions, use `mcp__context7__*` tools to fetch current documentation and inform the options. Don't use Context7 for every question — only when library-specific knowledge improves the options.
168
+
169
+ **Batch mode (`--batch`): Ask 2-5 numbered questions in one plain-text turn**
170
+ - Group closely related questions for the current area into a single message
171
+ - Keep each question concrete and answerable in one reply
172
+ - When options are helpful, include short inline choices per question rather than a separate AskUserQuestion for every item
173
+ - After the user replies, reflect back the captured decisions, note any unanswered items, and ask only the minimum follow-up needed before moving on
174
+ - Preserve adaptiveness between batches: use the full set of answers to decide the next batch or whether the area is sufficiently clear
175
+
176
+ 3. **After the current set of questions, check:**
177
+ - header: "[Area]" (max 12 chars)
178
+ - question: "More questions about [area], or move to next? (Remaining: [list other unvisited areas])"
179
+ - options: "More questions" / "Next area"
180
+
181
+ When building the question text, list the remaining unvisited areas so the user knows what's ahead. For example: "More questions about Layout, or move to next? (Remaining: Loading behavior, Content ordering)"
182
+
183
+ If "More questions" → ask another 4 single questions, or another 2-5 question batch when `--batch` is active, then check again
184
+ If "Next area" → proceed to next selected area
185
+ If "Other" (free text) → interpret intent: continuation phrases ("chat more", "keep going", "yes", "more") map to "More questions"; advancement phrases ("done", "move on", "next", "skip") map to "Next area". If ambiguous, ask: "Continue with more questions about [area], or move to the next area?"
186
+
187
+ 4. **After all initially-selected areas complete:**
188
+ - Summarize what was captured from the discussion so far
189
+ - Increment internal PASS_COUNT (starts at 1 for the initial area set)
190
+ - If PASS_COUNT >= MAX_PASSES: display "Max discussion passes ({MAX_PASSES}) reached — proceeding to write context." and go directly to write_context WITHOUT prompting.
191
+ - Otherwise, AskUserQuestion:
192
+ - header: "Done"
193
+ - question: "We've discussed [list areas]. Which gray areas remain unclear? ({MAX_PASSES - PASS_COUNT} pass(es) remaining)"
194
+ - options: "Explore more gray areas" / "I'm ready for context"
195
+ - If "Explore more gray areas":
196
+ - Identify 2-4 additional gray areas based on what was learned
197
+ - Return to present_gray_areas logic with these new areas
198
+ - Increment PASS_COUNT; if PASS_COUNT >= MAX_PASSES, skip the end-of-set prompt and go directly to write_context after this round
199
+ - Loop: discuss new areas, then prompt again (if passes remain)
200
+ - If "I'm ready for context": Proceed to write_context
201
+
202
+ **Canonical ref accumulation during discussion:**
203
+ When the user references a doc, spec, or ADR during any answer — e.g., "read adr-014", "check the MCP spec", "per browse-spec.md" — immediately:
204
+ 1. Read the referenced doc (or confirm it exists)
205
+ 2. Add it to the canonical refs accumulator with full relative path
206
+ 3. Use what you learned from the doc to inform subsequent questions
207
+
208
+ These user-referenced docs are often MORE important than ROADMAP.md refs because they represent docs the user specifically wants downstream agents to follow. Never drop them.
209
+
210
+ **Question design:**
211
+ - Options should be concrete, not abstract ("Cards" not "Option A")
212
+ - Each answer should inform the next question or next batch
213
+ - If user picks "Other" to provide freeform input (e.g., "let me describe it", "something else", or an open-ended reply), ask your follow-up as plain text — NOT another AskUserQuestion. Wait for them to type at the normal prompt, then reflect their input back and confirm before resuming AskUserQuestion or the next numbered batch.
214
+
215
+ **Scope creep handling:**
216
+ If user mentions something outside the phase domain:
217
+ ```
218
+ "[Feature] sounds like a new capability — that belongs in its own phase.
219
+ I'll note it as a deferred idea.
220
+
221
+ Back to [current area]: [return to current question]"
222
+ ```
223
+
224
+ Track deferred ideas internally.
225
+
226
+ **Incremental checkpoint — save after each area completes:**
227
+
228
+ After each area is resolved (user says "Next area" or area auto-resolves in `--auto` mode), immediately write a checkpoint file with all decisions captured so far. This prevents data loss if the session is interrupted mid-discussion.
229
+
230
+ **Checkpoint file:** `${phase_dir}/${padded_phase}-DISCUSS-CHECKPOINT.json`
231
+
232
+ Write after each area:
233
+ ```json
234
+ {
235
+ "phase": "{PHASE_NUMBER}",
236
+ "phase_name": "{phase_name}",
237
+ "timestamp": "{ISO timestamp}",
238
+ "areas_completed": ["Area 1", "Area 2"],
239
+ "areas_remaining": ["Area 3", "Area 4"],
240
+ "decisions": {
241
+ "Area 1": [
242
+ {"question": "...", "answer": "...", "options_presented": ["..."]},
243
+ {"question": "...", "answer": "...", "options_presented": ["..."]}
244
+ ],
245
+ "Area 2": [
246
+ {"question": "...", "answer": "...", "options_presented": ["..."]}
247
+ ]
248
+ },
249
+ "deferred_ideas": ["..."],
250
+ "canonical_refs": ["..."]
251
+ }
252
+ ```
253
+
254
+ This is a structured checkpoint, not the final CONTEXT.md — the `write_context` step still produces the canonical output. But if the session dies, the next `/rihal-discuss-phase` invocation can detect this checkpoint and offer to resume from it instead of starting from scratch.
255
+
256
+ **On session resume:** In the `check_existing` step, also check for `*-DISCUSS-CHECKPOINT.json`. If found and no CONTEXT.md exists:
257
+ - Display: "Found interrupted discussion checkpoint ({N} areas completed). Resume from checkpoint?"
258
+ - Options: "Resume" / "Start fresh"
259
+ - On "Resume": Load the checkpoint, skip completed areas, continue from where it left off
260
+ - On "Start fresh": Delete the checkpoint, proceed as normal
261
+
262
+ **After write_context completes successfully:** Delete the checkpoint file — the canonical CONTEXT.md now has all decisions.
263
+
264
+ **Track discussion log data internally:**
265
+ For each question asked, accumulate:
266
+ - Area name
267
+ - All options presented (label + description)
268
+ - Which option the user selected (or their free-text response)
269
+ - Any follow-up notes or clarifications the user provided
270
+ This data is used to generate DISCUSSION-LOG.md in the `write_context` step.
271
+ </step>
@@ -5,11 +5,23 @@ You are a thinking partner, not an interviewer. The user is the visionary — yo
5
5
  </purpose>
6
6
 
7
7
  <required_reading>
8
- @.rihal/references/domain-probes.md
9
- @.rihal/references/gate-prompts.md
10
8
  @.rihal/references/universal-anti-patterns.md
11
9
  </required_reading>
12
10
 
11
+ <conditional_reading>
12
+ Load these only when the phase involves user-facing features or product decisions:
13
+ - If phase goal contains UI/product/design/integration signals: `@.rihal/references/domain-probes.md` (213 lines of domain-specific question banks)
14
+ - At the final approval step only: `@.rihal/references/gate-prompts.md` (212 lines of quality gate decision trees)
15
+
16
+ To detect phase type before loading:
17
+ ```bash
18
+ PHASE_GOAL=$(grep -A5 "^## Phase ${PHASE_NUMBER}" .planning/ROADMAP.md 2>/dev/null | head -5)
19
+ echo "$PHASE_GOAL" | grep -iE "UI|UX|product|feature|integration|API|user|screen|flow|dashboard" > /dev/null 2>&1
20
+ HAS_PRODUCT_SIGNALS=$?
21
+ ```
22
+ Only include domain-probes.md when `HAS_PRODUCT_SIGNALS` is 0.
23
+ </conditional_reading>
24
+
13
25
  <downstream_awareness>
14
26
  **CONTEXT.md feeds into:**
15
27
 
@@ -279,13 +291,13 @@ Extract from these:
279
291
  - **REQUIREMENTS.md** — Acceptance criteria, constraints, must-haves vs nice-to-haves
280
292
  - **STATE.md** — Current progress, any flags or session notes
281
293
 
282
- **Step 2: Read all prior CONTEXT.md files**
294
+ **Step 2: Read prior CONTEXT.md files (most recent 5 phases — cap prevents context overflow)**
283
295
  ```bash
284
- # Find all CONTEXT.md files from phases before current
285
- (find .planning/phases -name "*-CONTEXT.md" 2>/dev/null || true) | sort
296
+ # Find CONTEXT.md files from phases before current, limit to 5 most recent
297
+ (find .planning/phases -name "*-CONTEXT.md" 2>/dev/null || true) | sort | tail -5
286
298
  ```
287
299
 
288
- For each CONTEXT.md where phase number < current phase:
300
+ For each CONTEXT.md where phase number < current phase (max 5):
289
301
  - Read the `<decisions>` section — these are locked preferences
290
302
  - Read `<specifics>` — particular references or "I want it like X" moments
291
303
  - Note any patterns (e.g., "user consistently prefers minimal UI", "user rejected single-key shortcuts")
@@ -584,273 +596,22 @@ After user selects gray areas in present_gray_areas, spawn parallel research age
584
596
 
585
597
  4. Store synthesized tables for use in discuss_areas.
586
598
 
587
- **If ADVISOR_MODE is false:** Skip this step entirely proceed directly from present_gray_areas to discuss_areas.
588
- </step>
589
-
590
- <step name="discuss_areas">
591
- Discuss each selected area with the user. Flow depends on advisor mode.
592
-
593
- **If ADVISOR_MODE is true:**
594
-
595
- Table-first discussion flow — present research-backed comparison tables, then capture user picks.
596
-
597
- **For each selected area:**
598
-
599
- 1. **Present the synthesized comparison table + rationale paragraph** (from advisor_research step)
600
-
601
- 2. **Use AskUserQuestion:**
602
- - header: "{area_name}"
603
- - question: "Which approach for {area_name}?"
604
- - options: Extract from the table's Option column (AskUserQuestion adds "Other" automatically)
605
-
606
- 3. **Record the user's selection:**
607
- - If user picks from table options → record as locked decision for that area
608
- - If user picks "Other" → receive their input, reflect it back for confirmation, record
609
-
610
- **Thinking partner (conditional):**
611
- If `features.thinking_partner` is enabled in config, check the user's answer for tradeoff signals
612
- (see `references/thinking-partner.md` for signal list). If tradeoff detected:
613
-
614
- ```
615
- I notice competing priorities here — {option_A} optimizes for {goal_A} while {option_B} optimizes for {goal_B}.
616
-
617
- Want me to think through the tradeoffs before we lock this in?
618
- [Yes, analyze] / [No, decision made]
619
- ```
620
-
621
- If yes: provide 3-5 bullet analysis (what each optimizes/sacrifices, alignment with PROJECT.md goals, recommendation). Then return to normal flow.
622
- If no or thinking_partner disabled: continue to next area.
623
-
624
- 4. **After recording pick, Claude decides whether follow-up questions are needed:**
625
- - If the pick has ambiguity that would affect downstream planning → ask 1-2 targeted follow-up questions using AskUserQuestion
626
- - If the pick is clear and self-contained → move to next area
627
- - Do NOT ask the standard 4 questions — the table already provided the context
599
+ **All-fail fallback:** If ALL Task() calls returned errors or empty results (no agent produced a usable table):
628
600
 
629
- 5. **After all areas processed:**
630
- - header: "Done"
631
- - question: "That covers [list areas]. Ready to create context?"
632
- - options: "Create context" / "Revisit an area"
633
-
634
- **Scope creep handling (advisor mode):**
635
- If user mentions something outside the phase domain:
601
+ Display:
636
602
  ```
637
- "[Feature] sounds like a new capability that belongs in its own phase.
638
- I'll note it as a deferred idea.
639
-
640
- Back to [current area]: [return to current question]"
603
+ ⚠ Advisor research failed for all {N} selected areas (subagent errors).
604
+ Falling back to direct discussion without pre-researched comparison tables.
641
605
  ```
642
606
 
643
- Track deferred ideas internally.
644
-
645
- ---
646
-
647
- **If ADVISOR_MODE is false:**
648
-
649
- For each selected area, conduct a focused discussion loop.
650
-
651
- **Research-before-questions mode:** Check if `workflow.research_before_questions` is enabled in config (from init context or `.planning/config.json`). When enabled, before presenting questions for each area:
652
- 1. Do a brief web search for best practices related to the area topic
653
- 2. Summarize the top findings in 2-3 bullet points
654
- 3. Present the research alongside the question so the user can make a more informed decision
655
-
656
- Example with research enabled:
657
- ```
658
- Let's talk about [Authentication Strategy].
659
-
660
- 📊 Best practices research:
661
- • OAuth 2.0 + PKCE is the current standard for SPAs (replaces implicit flow)
662
- • Session tokens with httpOnly cookies preferred over localStorage for XSS protection
663
- • Consider passkey/WebAuthn support — adoption is accelerating in 2025-2026
664
-
665
- With that context: How should users authenticate?
666
- ```
667
-
668
- When disabled (default), skip the research and present questions directly as before.
669
-
670
- **Text mode support:** Parse optional `--text` from `$ARGUMENTS`.
671
- - Accept `--text` flag OR read `workflow.text_mode` from config (from init context)
672
- - When active, replace ALL `AskUserQuestion` calls with plain-text numbered lists
673
- - User types a number to select, or types free text for "Other"
674
- - This is required for Claude Code remote sessions (`/rc` mode) where TUI menus
675
- don't work through the Claude App
607
+ Set ADVISOR_MODE=false for discuss_areas — proceed with unstructured discussion flow instead of table-first flow. Do NOT abort the overall discuss-phase workflow.
676
608
 
677
- **Batch mode support:** Parse optional `--batch` from `$ARGUMENTS`.
678
- - Accept `--batch`, `--batch=N`, or `--batch N`
679
-
680
- **Analyze mode support:** Parse optional `--analyze` from `$ARGUMENTS`.
681
- When `--analyze` is active, before presenting each question (or question group in batch mode), provide a brief **trade-off analysis** for the decision:
682
- - 2-3 options with pros/cons based on codebase context and common patterns
683
- - A recommended approach with reasoning
684
- - Known pitfalls or constraints from prior phases
685
-
686
- Example with `--analyze`:
687
- ```
688
- **Trade-off analysis: Authentication strategy**
689
-
690
- | Approach | Pros | Cons |
691
- |----------|------|------|
692
- | Session cookies | Simple, httpOnly prevents XSS | Requires CSRF protection, sticky sessions |
693
- | JWT (stateless) | Scalable, no server state | Token size, revocation complexity |
694
- | OAuth 2.0 + PKCE | Industry standard for SPAs | More setup, redirect flow UX |
695
-
696
- 💡 Recommended: OAuth 2.0 + PKCE — your app has social login in requirements (REQ-04) and this aligns with the existing NextAuth setup in `src/lib/auth.ts`.
697
-
698
- How should users authenticate?
699
- ```
700
-
701
- This gives the user context to make informed decisions without extra prompting. When `--analyze` is absent, present questions directly as before.
702
- - Accept `--batch`, `--batch=N`, or `--batch N`
703
- - Default to 4 questions per batch when no number is provided
704
- - Clamp explicit sizes to 2-5 so a batch stays answerable
705
- - If `--batch` is absent, keep the existing one-question-at-a-time flow
706
-
707
- **Philosophy:** stay adaptive, but let the user choose the pacing.
708
- - Default mode: 4 single-question turns, then check whether to continue
709
- - `--batch` mode: 1 grouped turn with 2-5 numbered questions, then check whether to continue
710
-
711
- Each answer (or answer set, in batch mode) should reveal the next question or next batch.
712
-
713
- **Auto mode (`--auto`):** For each area, Claude selects the recommended option (first option, or the one explicitly marked "recommended") for every question without using AskUserQuestion. Log each auto-selected choice:
714
- ```
715
- [auto] [Area] — Q: "[question text]" → Selected: "[chosen option]" (recommended default)
716
- ```
717
- After all areas are auto-resolved, skip the "Explore more gray areas" prompt and proceed directly to write_context.
718
-
719
- **CRITICAL — Auto-mode pass cap:**
720
- In `--auto` mode, the discuss step MUST complete in a **single pass**. After writing CONTEXT.md once, you are DONE — proceed immediately to write_context and then auto_advance. Do NOT re-read your own CONTEXT.md to find "gaps", "undefined types", or "missing decisions" and run additional passes. This creates a self-feeding loop where each pass generates references that the next pass treats as gaps, consuming unbounded time and resources.
721
-
722
- Check the pass cap from config:
723
- ```bash
724
- MAX_PASSES=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow.max_discuss_passes 2>/dev/null || echo "3")
725
- ```
726
-
727
- If you have already written and committed CONTEXT.md, the discuss step is complete. Move on.
728
-
729
- **Interactive mode (no `--auto`):**
730
-
731
- **For each area:**
732
-
733
- 1. **Announce the area:**
734
- ```
735
- Let's talk about [Area].
736
- ```
737
-
738
- 2. **Ask questions using the selected pacing:**
739
-
740
- **Default (no `--batch`): Ask 4 questions using AskUserQuestion**
741
- - header: "[Area]" (max 12 chars — abbreviate if needed)
742
- - question: Specific decision for this area
743
- - options: 2-3 concrete choices (AskUserQuestion adds "Other" automatically), with the recommended choice highlighted and brief explanation why
744
- - **Annotate options with code context** when relevant:
745
- ```
746
- "How should posts be displayed?"
747
- - Cards (reuses existing Card component — consistent with Messages)
748
- - List (simpler, would be a new pattern)
749
- - Timeline (needs new Timeline component — none exists yet)
750
- ```
751
- - Include "You decide" as an option when reasonable — captures Claude discretion
752
- - **Context7 for library choices:** When a gray area involves library selection (e.g., "magic links" → query next-auth docs) or API approach decisions, use `mcp__context7__*` tools to fetch current documentation and inform the options. Don't use Context7 for every question — only when library-specific knowledge improves the options.
753
-
754
- **Batch mode (`--batch`): Ask 2-5 numbered questions in one plain-text turn**
755
- - Group closely related questions for the current area into a single message
756
- - Keep each question concrete and answerable in one reply
757
- - When options are helpful, include short inline choices per question rather than a separate AskUserQuestion for every item
758
- - After the user replies, reflect back the captured decisions, note any unanswered items, and ask only the minimum follow-up needed before moving on
759
- - Preserve adaptiveness between batches: use the full set of answers to decide the next batch or whether the area is sufficiently clear
760
-
761
- 3. **After the current set of questions, check:**
762
- - header: "[Area]" (max 12 chars)
763
- - question: "More questions about [area], or move to next? (Remaining: [list other unvisited areas])"
764
- - options: "More questions" / "Next area"
765
-
766
- When building the question text, list the remaining unvisited areas so the user knows what's ahead. For example: "More questions about Layout, or move to next? (Remaining: Loading behavior, Content ordering)"
767
-
768
- If "More questions" → ask another 4 single questions, or another 2-5 question batch when `--batch` is active, then check again
769
- If "Next area" → proceed to next selected area
770
- If "Other" (free text) → interpret intent: continuation phrases ("chat more", "keep going", "yes", "more") map to "More questions"; advancement phrases ("done", "move on", "next", "skip") map to "Next area". If ambiguous, ask: "Continue with more questions about [area], or move to the next area?"
771
-
772
- 4. **After all initially-selected areas complete:**
773
- - Summarize what was captured from the discussion so far
774
- - AskUserQuestion:
775
- - header: "Done"
776
- - question: "We've discussed [list areas]. Which gray areas remain unclear?"
777
- - options: "Explore more gray areas" / "I'm ready for context"
778
- - If "Explore more gray areas":
779
- - Identify 2-4 additional gray areas based on what was learned
780
- - Return to present_gray_areas logic with these new areas
781
- - Loop: discuss new areas, then prompt again
782
- - If "I'm ready for context": Proceed to write_context
783
-
784
- **Canonical ref accumulation during discussion:**
785
- When the user references a doc, spec, or ADR during any answer — e.g., "read adr-014", "check the MCP spec", "per browse-spec.md" — immediately:
786
- 1. Read the referenced doc (or confirm it exists)
787
- 2. Add it to the canonical refs accumulator with full relative path
788
- 3. Use what you learned from the doc to inform subsequent questions
789
-
790
- These user-referenced docs are often MORE important than ROADMAP.md refs because they represent docs the user specifically wants downstream agents to follow. Never drop them.
791
-
792
- **Question design:**
793
- - Options should be concrete, not abstract ("Cards" not "Option A")
794
- - Each answer should inform the next question or next batch
795
- - If user picks "Other" to provide freeform input (e.g., "let me describe it", "something else", or an open-ended reply), ask your follow-up as plain text — NOT another AskUserQuestion. Wait for them to type at the normal prompt, then reflect their input back and confirm before resuming AskUserQuestion or the next numbered batch.
796
-
797
- **Scope creep handling:**
798
- If user mentions something outside the phase domain:
799
- ```
800
- "[Feature] sounds like a new capability — that belongs in its own phase.
801
- I'll note it as a deferred idea.
802
-
803
- Back to [current area]: [return to current question]"
804
- ```
805
-
806
- Track deferred ideas internally.
807
-
808
- **Incremental checkpoint — save after each area completes:**
809
-
810
- After each area is resolved (user says "Next area" or area auto-resolves in `--auto` mode), immediately write a checkpoint file with all decisions captured so far. This prevents data loss if the session is interrupted mid-discussion.
811
-
812
- **Checkpoint file:** `${phase_dir}/${padded_phase}-DISCUSS-CHECKPOINT.json`
813
-
814
- Write after each area:
815
- ```json
816
- {
817
- "phase": "{PHASE_NUM}",
818
- "phase_name": "{phase_name}",
819
- "timestamp": "{ISO timestamp}",
820
- "areas_completed": ["Area 1", "Area 2"],
821
- "areas_remaining": ["Area 3", "Area 4"],
822
- "decisions": {
823
- "Area 1": [
824
- {"question": "...", "answer": "...", "options_presented": ["..."]},
825
- {"question": "...", "answer": "...", "options_presented": ["..."]}
826
- ],
827
- "Area 2": [
828
- {"question": "...", "answer": "...", "options_presented": ["..."]}
829
- ]
830
- },
831
- "deferred_ideas": ["..."],
832
- "canonical_refs": ["..."]
833
- }
834
- ```
835
-
836
- This is a structured checkpoint, not the final CONTEXT.md — the `write_context` step still produces the canonical output. But if the session dies, the next `/rihal-discuss-phase` invocation can detect this checkpoint and offer to resume from it instead of starting from scratch.
609
+ **If ADVISOR_MODE is false:** Skip this step entirely — proceed directly from present_gray_areas to discuss_areas.
610
+ </step>
837
611
 
838
- **On session resume:** In the `check_existing` step, also check for `*-DISCUSS-CHECKPOINT.json`. If found and no CONTEXT.md exists:
839
- - Display: "Found interrupted discussion checkpoint ({N} areas completed). Resume from checkpoint?"
840
- - Options: "Resume" / "Start fresh"
841
- - On "Resume": Load the checkpoint, skip completed areas, continue from where it left off
842
- - On "Start fresh": Delete the checkpoint, proceed as normal
843
612
 
844
- **After write_context completes successfully:** Delete the checkpoint file — the canonical CONTEXT.md now has all decisions.
613
+ @rihal/workflows/discuss-phase-discuss-areas.md
845
614
 
846
- **Track discussion log data internally:**
847
- For each question asked, accumulate:
848
- - Area name
849
- - All options presented (label + description)
850
- - Which option the user selected (or their free-text response)
851
- - Any follow-up notes or clarifications the user provided
852
- This data is used to generate DISCUSSION-LOG.md in the `write_context` step.
853
- </step>
854
615
 
855
616
  <step name="write_context">
856
617
  Create CONTEXT.md capturing decisions made.
@@ -1144,7 +905,7 @@ This keeps the auto-advance chain flat — discuss, plan, and execute all run at
1144
905
  - **PLANNING COMPLETE** → Planning done, execution didn't complete:
1145
906
  ```
1146
907
  Auto-advance partial: Planning complete, execution did not finish.
1147
- Continue: /rihal-execute-phase ${PHASE} ${Rihal_WS}
908
+ Continue: /rihal-execute ${PHASE} ${Rihal_WS}
1148
909
  ```
1149
910
  - **PLANNING INCONCLUSIVE / CHECKPOINT** → Stop chain:
1150
911
  ```