@hanzlaa/rcode 3.4.3 → 3.4.5

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 +5 -5
  5. package/cli/index.js +0 -0
  6. package/cli/install.js +128 -3
  7. package/cli/lib/manifest.cjs +1 -1
  8. package/cli/uninstall.js +8 -0
  9. package/dist/rcode.js +19 -1
  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
@@ -93,7 +93,9 @@ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
93
93
  AGENT_SKILLS_MAPPER=$(node .rihal/bin/rihal-tools.cjs agent-skills rihal-codebase-mapper 2>/dev/null)
94
94
  ```
95
95
 
96
- Extract from init JSON: `mapper_model`, `commit_docs`, `codebase_dir`, `existing_maps`, `has_maps`, `codebase_dir_exists`.
96
+ Extract from init JSON: `mapper_model`, `commit_docs`, `codebase_dir`, `existing_maps`, `has_maps`, `codebase_dir_exists`, `response_language`.
97
+
98
+ **If `response_language` is set:** include `Respond in {response_language}.` in all spawned subagent prompts.
97
99
  </step>
98
100
 
99
101
  <step name="check_existing">
@@ -167,6 +169,7 @@ Use Task tool with `subagent_type="rihal-codebase-mapper"`, `model="{mapper_mode
167
169
  ```
168
170
  Task(
169
171
  subagent_type="rihal-codebase-mapper",
172
+ model="sonnet",
170
173
  model="{mapper_model}",
171
174
  run_in_background=true,
172
175
  description="Map codebase tech stack",
@@ -188,6 +191,7 @@ ${AGENT_SKILLS_MAPPER}"
188
191
  ```
189
192
  Task(
190
193
  subagent_type="rihal-codebase-mapper",
194
+ model="sonnet",
191
195
  model="{mapper_model}",
192
196
  run_in_background=true,
193
197
  description="Map codebase architecture",
@@ -209,6 +213,7 @@ ${AGENT_SKILLS_MAPPER}"
209
213
  ```
210
214
  Task(
211
215
  subagent_type="rihal-codebase-mapper",
216
+ model="sonnet",
212
217
  model="{mapper_model}",
213
218
  run_in_background=true,
214
219
  description="Map codebase conventions",
@@ -230,6 +235,7 @@ ${AGENT_SKILLS_MAPPER}"
230
235
  ```
231
236
  Task(
232
237
  subagent_type="rihal-codebase-mapper",
238
+ model="sonnet",
233
239
  model="{mapper_model}",
234
240
  run_in_background=true,
235
241
  description="Map codebase concerns",
@@ -1,12 +1,31 @@
1
1
  # Workflow: rcode-memory-audit
2
2
 
3
- Read-only audit of the Memory Bank. Produces a severity-tagged report. Never modifies files.
3
+ <purpose>
4
+ Audit the Memory Bank for stale entries, contradictions, missing sections, and content that should be archived. Read-only by default with severity-tagged report; `--fix` patches trivial items per Phase 6 D-1 / D-2.
5
+ </purpose>
6
+
7
+ Audit the Memory Bank. Default mode is read-only (severity-tagged report).
8
+ Optional `--fix` flag patches trivial items in place per Phase 6 D-1 / D-2.
4
9
 
5
10
  ---
6
11
 
7
12
  ## Inputs
8
13
 
9
- None required. Optional `--severity {critical|warn|info}` to filter output.
14
+ None required.
15
+
16
+ Optional flags:
17
+ - `--severity {critical|warn|info}` — filter report output
18
+ - `--fix` — opt-in auto-fix mode. Patches only items the auditor classifies
19
+ as severity=trivial (typos, stale ISO dates, broken relative paths,
20
+ factually-wrong-and-mechanically-correctable values). Hard-allowlisted
21
+ in code: items above trivial are never patched. Default OFF.
22
+
23
+ ```bash
24
+ FIX_MODE=false
25
+ if [[ "$ARGUMENTS" =~ (^|[[:space:]])--fix($|[[:space:]]) ]]; then
26
+ FIX_MODE=true
27
+ fi
28
+ ```
10
29
 
11
30
  ## Preconditions
12
31
 
@@ -71,13 +90,56 @@ If `--severity` filter passed, hide findings below the threshold.
71
90
 
72
91
  If zero findings: print `✓ Memory Bank is healthy. 0 findings.`
73
92
 
93
+ ### Step 9 — Apply fixes (only when `--fix` is set)
94
+
95
+ <step name="apply_fixes">
96
+ Skip if `FIX_MODE` is false.
97
+
98
+ For each finding from the audit:
99
+ - If severity is `trivial` (typo, stale ISO date, dead relative path,
100
+ provably-wrong factual value with an unambiguous replacement), patch in place.
101
+ - For all other severities (`info`, `warn`, `critical`), leave for human review
102
+ and keep them in the report — never patch.
103
+
104
+ Patching rule (HARD): use file Read+Edit (NOT regex sed) so fixes are exact
105
+ string replacements that fail loudly on ambiguity. Sed-based mass-replace is
106
+ forbidden because it silently rewrites unintended occurrences.
107
+
108
+ Atomic commit per fix:
109
+
110
+ ```bash
111
+ git add <file>
112
+ git commit -m "fix(memory): <what was stale> → <what's true now>"
113
+ ```
114
+
115
+ After the loop, log: `Memory --fix applied {N} trivial corrections across {M} commits.`
116
+
117
+ If a finding marked trivial fails to patch (file changed mid-flight, ambiguous
118
+ replacement, etc.), log it under "Skipped fixes" in the final report and
119
+ continue with the next finding — never abort the whole run on a single failure.
120
+ </step>
121
+
74
122
  ---
75
123
 
124
+ ## Guardrails
125
+
126
+ - `--fix` NEVER patches above trivial severity, even with a `--force` flag (don't accept --force here)
127
+ - `--fix` uses Read+Edit, not regex sed
128
+ - `--fix` commits each correction atomically (no batched commits)
129
+ - Default behavior (no `--fix`) is unchanged: report-only
130
+
76
131
  ## Post-conditions
77
132
 
78
- - No files modified
79
- - Report printed to stdout
133
+ - When `--fix` is OFF: no files modified; report printed to stdout
134
+ - When `--fix` is ON: only trivial items modified; each as its own commit; report still printed
80
135
 
81
136
  ## Reversibility
82
137
 
83
- Read-only — no state to revert.
138
+ - Default mode: read-only — no state to revert.
139
+ - `--fix` mode: each fix is its own atomic git commit, so individual fixes can be reverted with `git revert <hash>`.
140
+
141
+ ## Success criteria
142
+
143
+ - [ ] Default behavior unchanged — `--fix` off by default; report-only path preserved
144
+ - [ ] `--fix` patches only trivial items, each as atomic commit prefixed `fix(memory):`
145
+ - [ ] Report still printed even in `--fix` mode (so user sees what was/wasn't patched)
@@ -1,5 +1,9 @@
1
1
  # Workflow: rcode-memory-distill
2
2
 
3
+ <purpose>
4
+ Regenerate Memory Bank distillates with lossless compression — token-optimized snapshots of source files for fast LLM context loading. Idempotent: re-running on already-distilled content produces identical output.
5
+ </purpose>
6
+
3
7
  Regenerate Memory Bank distillates with lossless compression. Idempotent.
4
8
 
5
9
  ---
@@ -101,3 +105,9 @@ Print per-target:
101
105
  ## Reversibility
102
106
 
103
107
  Distillates are derived artefacts. Reverting a regeneration: `git checkout .rihal/memory/distillates/`.
108
+
109
+ ## On Completion
110
+
111
+ /rihal-memory-audit — audit all memory files for staleness
112
+ /rihal-next — get suggested next action
113
+ /rihal-resume-work — continue with current work context
@@ -1,5 +1,9 @@
1
1
  # Workflow: rcode-memory-init
2
2
 
3
+ <purpose>
4
+ Bootstrap the rcode Memory Bank for a project. Copies templates from `rihal/templates/memory/` into `.rihal/memory/`, then asks 5 seed questions to populate context. Idempotent: re-running on an initialised project produces a gap report instead of overwriting.
5
+ </purpose>
6
+
3
7
  Bootstraps the rcode Memory Bank in the current project. Idempotent — re-running on an initialised project switches to a gap report instead of overwriting.
4
8
 
5
9
  ---
@@ -1,5 +1,9 @@
1
1
  # Workflow: rcode-memory-update
2
2
 
3
+ <purpose>
4
+ Append-only surgical update to a single Memory Bank file. Adds a decision, known issue, stakeholder note, or milestone update from current conversation context. Never rewrites, never deletes — pure append.
5
+ </purpose>
6
+
3
7
  Append-only surgical update to a single Memory Bank file. Never rewrites, never deletes.
4
8
 
5
9
  ---
@@ -549,11 +549,16 @@ git add .planning/ROADMAP.md .planning/STATE.md .planning/REQUIREMENTS.md 2>/dev
549
549
  echo "ℹ .planning/ gitignored — roadmap written, not committed"
550
550
  ```
551
551
 
552
- Also record the milestone start in state:
552
+ Also record the milestone start in state and sync roadmapper phases:
553
553
 
554
554
  ```bash
555
555
  node ".rihal/bin/rihal-tools.cjs" state add-decision \
556
556
  --summary "Started milestone v[X.Y] [Name]: [N] phases, [X] requirements" 2>/dev/null || true
557
+
558
+ # Sync all roadmapper-created phases into state.json.
559
+ # rihal-roadmapper writes ROADMAP.md as text — it never calls `phase add` — so
560
+ # state.json has no phase entries until this runs. Closes #504.
561
+ node ".rihal/bin/rihal-tools.cjs" state sync --from-disk 2>/dev/null || true
557
562
  ```
558
563
 
559
564
  ## 11. Done
@@ -611,6 +616,7 @@ or
611
616
  - **Roadmapper returns ROADMAP BLOCKED:** surface the blocker, collect resolution, re-spawn.
612
617
  - **`rihal-tools.cjs state` fails:** continue — state tracking is optional, file artifacts are mandatory.
613
618
  - **`.planning/` is gitignored:** write files, print ℹ notice, do not error.
619
+ - **Phase archive completes but state.json write fails mid-sequence:** do NOT re-archive. Tell the user: "Phase archive completed but milestone state was not recorded. Recovery: run `node .rihal/bin/rihal-tools.cjs state sync --from-disk` then re-run `/rihal-new-milestone` — it will detect the existing archive and skip re-archiving."
614
620
  </on_error>
615
621
  </content>
616
622
  </invoke>
@@ -0,0 +1,176 @@
1
+ <purpose>
2
+ Sub-step of new-project.md — Step 8 Create Roadmap. Spawns rihal-roadmapper agent to build ROADMAP.md from requirements and project type. Includes approval gate and commit.
3
+ </purpose>
4
+
5
+ ## 8. Create Roadmap
6
+
7
+ Display stage banner:
8
+
9
+ ```
10
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
11
+ RIHAL ► CREATING ROADMAP
12
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
13
+
14
+ ◆ Spawning roadmapper...
15
+ ```
16
+
17
+ Spawn rihal-roadmapper agent:
18
+
19
+ ```
20
+ Task(prompt="
21
+ <planning_context>
22
+
23
+ <files_to_read>
24
+ - .planning/PROJECT.md (Project context)
25
+ - .planning/REQUIREMENTS.md (v1 Requirements)
26
+ - .planning/research/SUMMARY.md (Research findings - if exists)
27
+ - .planning/config.json (Granularity and mode settings)
28
+ </files_to_read>
29
+
30
+ ${AGENT_ROADMAPPER}
31
+
32
+ </planning_context>
33
+
34
+ <instructions>
35
+ Create roadmap:
36
+ 1. Derive phases from requirements (don't impose structure)
37
+ 2. Map every v1 requirement to exactly one phase
38
+ 3. Derive 2-5 success criteria per phase (observable user behaviors)
39
+ 4. Validate 100% coverage
40
+ 5. Write files immediately (ROADMAP.md, STATE.md, update REQUIREMENTS.md traceability)
41
+ 6. Return ROADMAP CREATED with summary
42
+
43
+ Write files first, then return. This ensures artifacts persist even if context is lost.
44
+ </instructions>
45
+ ", subagent_type="rihal-roadmapper", model="${ROADMAPPER_MODEL}", description="Create roadmap")
46
+ ```
47
+
48
+ **Handle roadmapper return:**
49
+
50
+ **If `## ROADMAP BLOCKED`:**
51
+
52
+ - Present blocker information
53
+ - Work with user to resolve
54
+ - Re-spawn when resolved
55
+
56
+ **If `## ROADMAP CREATED`:**
57
+
58
+ Read the created ROADMAP.md and present it nicely inline:
59
+
60
+ ```
61
+ ---
62
+
63
+ ## Proposed Roadmap
64
+
65
+ **[N] phases** | **[X] requirements mapped** | All v1 requirements covered ✓
66
+
67
+ | # | Phase | Goal | Requirements | Success Criteria |
68
+ |---|-------|------|--------------|------------------|
69
+ | 1 | [Name] | [Goal] | [REQ-IDs] | [count] |
70
+ | 2 | [Name] | [Goal] | [REQ-IDs] | [count] |
71
+ | 3 | [Name] | [Goal] | [REQ-IDs] | [count] |
72
+
73
+ ### Phase Details
74
+
75
+ **Phase 1: [Name]**
76
+ Goal: [goal]
77
+ Requirements: [REQ-IDs]
78
+ Success criteria:
79
+ 1. [criterion]
80
+ 2. [criterion]
81
+ 3. [criterion]
82
+
83
+ [... continue for all phases ...]
84
+
85
+ ---
86
+ ```
87
+
88
+ **If auto mode:** Skip approval gate — auto-approve and commit directly.
89
+
90
+ **CRITICAL: Ask for approval before committing (interactive mode only):**
91
+
92
+ Use AskUserQuestion:
93
+
94
+ - header: "Roadmap"
95
+ - question: "Does this roadmap structure work for you?"
96
+ - options:
97
+ - "Approve" — Commit and continue
98
+ - "Adjust phases" — Tell me what to change
99
+ - "Review full file" — Show raw ROADMAP.md
100
+
101
+ **If "Approve":** Continue to commit.
102
+
103
+ **If "Adjust phases":**
104
+
105
+ - Get user's adjustment notes
106
+ - Re-spawn roadmapper with revision context:
107
+
108
+ ```
109
+ Task(prompt="
110
+ <revision>
111
+ User feedback on roadmap:
112
+ [user's notes]
113
+
114
+ <files_to_read>
115
+ - .planning/ROADMAP.md (Current roadmap to revise)
116
+ </files_to_read>
117
+
118
+ ${AGENT_ROADMAPPER}
119
+
120
+ Update the roadmap based on feedback. Edit files in place.
121
+ Return ROADMAP REVISED with changes made.
122
+ </revision>
123
+ ", subagent_type="rihal-roadmapper", model="${ROADMAPPER_MODEL}", description="Revise roadmap")
124
+ ```
125
+
126
+ - Present revised roadmap
127
+ - Loop until user approves
128
+
129
+ **If "Review full file":** Display raw `cat .planning/ROADMAP.md`, then re-ask.
130
+
131
+ **Generate or refresh project instruction file before final commit:**
132
+
133
+ The rihal-tools CLI does not expose a `generate-claude-md` subcommand. Instead, if `$INSTRUCTION_FILE` does not already exist, write a minimal instruction file pointing at the rihal workflow docs:
134
+
135
+ ```markdown
136
+ # {INSTRUCTION_FILE} — project instructions
137
+
138
+ This project uses Rihal for planning and execution. See `.planning/PROJECT.md` for context and `.planning/ROADMAP.md` for phases.
139
+
140
+ Common commands:
141
+ - /rihal-progress — check status and next action
142
+ - /rihal-discuss-phase N — gather context before planning phase N
143
+ - /rihal-plan N — create a SPRINT.md for phase N
144
+ - /rihal-execute N — execute a SPRINT.md
145
+ - /rihal-verify-work — conversational UAT
146
+ - /rihal-complete-milestone — archive milestone and reset
147
+
148
+ Rules:
149
+ - Never run `git push` without explicit user authorization.
150
+ - No Claude/AI attribution in commits.
151
+ - Prefer editing existing files over creating new ones.
152
+ ```
153
+
154
+ If it already exists, leave it alone (respect user-customized content).
155
+
156
+ **Commit roadmap (guarded):**
157
+
158
+ ```bash
159
+ git add \
160
+ .planning/ROADMAP.md \
161
+ .planning/STATE.md \
162
+ .planning/REQUIREMENTS.md \
163
+ "$INSTRUCTION_FILE" 2>/dev/null \
164
+ && git commit -m "docs: create roadmap ([N] phases)" 2>/dev/null \
165
+ || echo "ℹ .planning/ gitignored — roadmap written, not committed (instruction file committed separately)"
166
+
167
+ # Fallback: also try committing just the instruction file if .planning was ignored
168
+ git add "$INSTRUCTION_FILE" 2>/dev/null && git commit -m "docs: add project instruction file" 2>/dev/null || true
169
+
170
+ # Sync all roadmapper-created phases into state.json.
171
+ # rihal-roadmapper writes ROADMAP.md as text — it never calls `phase add` — so
172
+ # state.json is empty after this step unless we sync it. Without this, every
173
+ # /rihal-status shows "N phases not registered" warnings immediately after init.
174
+ node ".rihal/bin/rihal-tools.cjs" state sync --from-disk 2>/dev/null || true
175
+ ```
176
+
@@ -0,0 +1,160 @@
1
+ <purpose>
2
+ Sub-step of new-project.md — Step 7 Define Requirements. Gathers functional requirements through conversation and writes REQUIREMENTS.md.
3
+ </purpose>
4
+
5
+ ## 7. Define Requirements
6
+
7
+ Display stage banner:
8
+
9
+ ```
10
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
11
+ RIHAL ► DEFINING REQUIREMENTS
12
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
13
+ ```
14
+
15
+ **Load context:**
16
+
17
+ Read PROJECT.md and extract:
18
+
19
+ - Core value (the ONE thing that must work)
20
+ - Stated constraints (budget, timeline, tech limitations)
21
+ - Any explicit scope boundaries
22
+
23
+ **If research exists:** Read research/FEATURES.md and extract feature categories.
24
+
25
+ **If auto mode:**
26
+
27
+ - Auto-include all table stakes features
28
+ - Include features explicitly mentioned in provided document
29
+ - Auto-defer differentiators not mentioned in document
30
+ - Skip per-category AskUserQuestion loops
31
+ - Skip "Any additions?" question
32
+ - Skip requirements approval gate
33
+ - Generate REQUIREMENTS.md and commit directly
34
+
35
+ **Present features by category (interactive mode only):**
36
+
37
+ ```
38
+ Here are the features for [domain]:
39
+
40
+ ## Authentication
41
+ **Table stakes:**
42
+ - Sign up with email/password
43
+ - Email verification
44
+ - Password reset
45
+ - Session management
46
+
47
+ **Differentiators:**
48
+ - Magic link login
49
+ - OAuth (Google, GitHub)
50
+ - 2FA
51
+
52
+ **Research notes:** [any relevant notes]
53
+
54
+ ---
55
+
56
+ ## [Next Category]
57
+ ...
58
+ ```
59
+
60
+ **If no research:** Gather requirements through conversation.
61
+
62
+ Ask: "What are the main things users need to be able to do?"
63
+
64
+ For each capability mentioned:
65
+
66
+ - Ask clarifying questions to make it specific
67
+ - Probe for related capabilities
68
+ - Group into categories
69
+
70
+ **Scope each category:**
71
+
72
+ For each category, use AskUserQuestion:
73
+
74
+ - header: "[Category]" (max 12 chars)
75
+ - question: "Which [category] features are in v1?"
76
+ - multiSelect: true
77
+ - options:
78
+ - "[Feature 1]" — [brief description]
79
+ - "[Feature 2]" — [brief description]
80
+ - "[Feature 3]" — [brief description]
81
+ - "None for v1" — Defer entire category
82
+
83
+ Track responses:
84
+
85
+ - Selected features → v1 requirements
86
+ - Unselected table stakes → v2
87
+ - Unselected differentiators → out of scope
88
+
89
+ **Identify gaps:**
90
+
91
+ Use AskUserQuestion:
92
+
93
+ - header: "Additions"
94
+ - question: "Any requirements research missed?"
95
+ - options:
96
+ - "No, research covered it" — Proceed
97
+ - "Yes, let me add some" — Capture additions
98
+
99
+ **Validate core value:**
100
+
101
+ Cross-check requirements against Core Value from PROJECT.md. If gaps detected, surface them.
102
+
103
+ **Generate REQUIREMENTS.md:**
104
+
105
+ Create `.planning/REQUIREMENTS.md` with:
106
+
107
+ - v1 Requirements grouped by category (checkboxes, REQ-IDs)
108
+ - v2 Requirements (deferred)
109
+ - Out of Scope (explicit exclusions with reasoning)
110
+ - Traceability section (empty, filled by roadmap)
111
+
112
+ **REQ-ID format:** `[CATEGORY]-[NUMBER]` (AUTH-01, CONTENT-02)
113
+
114
+ **Requirement quality criteria:**
115
+
116
+ Good requirements are:
117
+
118
+ - **Specific and testable:** "User can reset password via email link"
119
+ - **User-centric:** "User can X"
120
+ - **Atomic:** One capability per requirement
121
+ - **Independent:** Minimal dependencies on other requirements
122
+
123
+ Reject vague requirements. Push for specificity:
124
+
125
+ - "Handle authentication" → "User can log in with email/password and stay logged in across sessions"
126
+ - "Support sharing" → "User can share post via link that opens in recipient's browser"
127
+
128
+ **Present full requirements list (interactive mode only):**
129
+
130
+ Show every requirement for user confirmation:
131
+
132
+ ```
133
+ ## v1 Requirements
134
+
135
+ ### Authentication
136
+ - [ ] **AUTH-01**: User can create account with email/password
137
+ - [ ] **AUTH-02**: User can log in and stay logged in across sessions
138
+ - [ ] **AUTH-03**: User can log out from any page
139
+
140
+ ### Content
141
+ - [ ] **CONT-01**: User can create posts with text
142
+ - [ ] **CONT-02**: User can edit their own posts
143
+
144
+ [... full list ...]
145
+
146
+ ---
147
+
148
+ Does this capture what you're building? (yes / adjust)
149
+ ```
150
+
151
+ If "adjust": Return to scoping.
152
+
153
+ **Commit requirements (guarded):**
154
+
155
+ ```bash
156
+ git add .planning/REQUIREMENTS.md 2>/dev/null \
157
+ && git commit -m "docs: define v1 requirements" 2>/dev/null \
158
+ || echo "ℹ .planning/ gitignored — requirements written, not committed"
159
+ ```
160
+