@hanzlaa/rcode 3.4.33 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/AGENTS.md +6 -6
  2. package/CONTRIBUTING.md +2 -0
  3. package/LICENSE +21 -0
  4. package/README.md +66 -403
  5. package/cli/doctor.js +87 -1
  6. package/cli/install.js +122 -31
  7. package/cli/lib/schemas.cjs +318 -0
  8. package/cli/postinstall.js +19 -3
  9. package/dist/rcode.js +316 -23
  10. package/package.json +8 -4
  11. package/rihal/agents/rihal-cross-platform-auditor.md +1 -1
  12. package/rihal/agents/rihal-dep-auditor.md +1 -1
  13. package/rihal/agents/rihal-docs-auditor.md +3 -145
  14. package/rihal/agents/rihal-i18n-auditor.md +1 -1
  15. package/rihal/agents/rihal-nyquist-auditor.md +4 -156
  16. package/rihal/agents/rihal-observability-auditor.md +1 -1
  17. package/rihal/bin/rihal-hooks.cjs +394 -4
  18. package/rihal/bin/rihal-tools.cjs +891 -24
  19. package/rihal/commands/create-prd.md +18 -0
  20. package/rihal/commands/execute-milestone.md +18 -0
  21. package/rihal/commands/plan-milestone.md +18 -0
  22. package/rihal/commands/scaffold-milestone.md +18 -0
  23. package/rihal/commands/scaffold-skill.md +18 -0
  24. package/rihal/references/REFERENCES_INDEX.md +49 -7
  25. package/rihal/references/agent-contracts.md +10 -0
  26. package/rihal/references/design-tokens.md +98 -0
  27. package/rihal/references/docs-auditor-playbook.md +148 -0
  28. package/rihal/references/git-preflight.md +117 -0
  29. package/rihal/references/iterative-retrieval.md +85 -0
  30. package/rihal/references/nyquist-auditor-playbook.md +157 -0
  31. package/rihal/references/workstream-flag.md +2 -2
  32. package/rihal/skills/actions/1-analysis/rihal-prfaq/SKILL.md +9 -0
  33. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/SKILL.md +9 -0
  34. package/rihal/skills/actions/4-implementation/rihal-ci/SKILL.md +4 -0
  35. package/rihal/skills/actions/4-implementation/rihal-code-review/steps/step-02-review.md +2 -2
  36. package/rihal/skills/actions/4-implementation/rihal-harden/SKILL.md +4 -0
  37. package/rihal/skills/actions/4-implementation/rihal-migrate/SKILL.md +4 -0
  38. package/rihal/skills/agents/haitham-frontend/SKILL.md +2 -0
  39. package/rihal/templates/settings-hooks.json +39 -0
  40. package/rihal/workflows/check-todos.md +4 -0
  41. package/rihal/workflows/code-review-fix.md +4 -3
  42. package/rihal/workflows/code-review.md +1 -1
  43. package/rihal/workflows/debug.md +1 -1
  44. package/rihal/workflows/dev-story.md +4 -0
  45. package/rihal/workflows/diff.md +2 -2
  46. package/rihal/workflows/do.md +16 -8
  47. package/rihal/workflows/docs-update.md +2 -2
  48. package/rihal/workflows/enable-hooks.md +6 -1
  49. package/rihal/workflows/execute-milestone.md +139 -0
  50. package/rihal/workflows/execute-regression-gates.md +1 -1
  51. package/rihal/workflows/execute-sprint.md +54 -2
  52. package/rihal/workflows/execute-verify-phase-goal.md +31 -4
  53. package/rihal/workflows/execute-waves.md +33 -5
  54. package/rihal/workflows/execute.md +40 -6
  55. package/rihal/workflows/help.md +1 -1
  56. package/rihal/workflows/import.md +1 -1
  57. package/rihal/workflows/lens-audit.md +39 -23
  58. package/rihal/workflows/list-workspaces.md +1 -1
  59. package/rihal/workflows/map-codebase.md +4 -4
  60. package/rihal/workflows/new-milestone.md +18 -1
  61. package/rihal/workflows/new-project-research.md +53 -1
  62. package/rihal/workflows/new-workspace.md +1 -1
  63. package/rihal/workflows/plan-milestone.md +105 -0
  64. package/rihal/workflows/plan-research-validation.md +1 -1
  65. package/rihal/workflows/plan-spawn-planner.md +1 -1
  66. package/rihal/workflows/plan.md +31 -3
  67. package/rihal/workflows/plant-seed.md +6 -0
  68. package/rihal/workflows/quick.md +11 -5
  69. package/rihal/workflows/research-phase.md +24 -0
  70. package/rihal/workflows/scaffold-milestone.md +60 -0
  71. package/rihal/workflows/scaffold-skill.md +137 -0
  72. package/rihal/workflows/scan.md +1 -1
  73. package/rihal/workflows/session-report.md +43 -3
  74. package/rihal/workflows/verify-work.md +3 -3
  75. package/server/dashboard.js +52 -5
  76. package/server/lib/html/client.js +723 -11
  77. package/server/lib/html/css.js +2046 -466
  78. package/server/lib/html/shell.js +227 -134
  79. package/server/lib/scanner.js +33 -0
  80. package/server/orchestrator.js +438 -0
@@ -93,7 +93,7 @@ Otherwise:
93
93
  ```
94
94
  ✓ {count} active workspaces
95
95
  Use --detail for full status
96
- Switch: /rihal-workspace <name>
96
+ Switch: /rihal-workstream switch --name <name>
97
97
  Remove: /rihal-remove-workspace <name>
98
98
  ```
99
99
 
@@ -169,7 +169,7 @@ Use Task tool with `subagent_type="rihal-codebase-mapper"`, `model="{mapper_mode
169
169
  ```
170
170
  Task(
171
171
  subagent_type="rihal-codebase-mapper",
172
- model="sonnet",
172
+ model="{model}",
173
173
  model="{mapper_model}",
174
174
  run_in_background=true,
175
175
  description="Map codebase tech stack",
@@ -191,7 +191,7 @@ ${AGENT_SKILLS_MAPPER}"
191
191
  ```
192
192
  Task(
193
193
  subagent_type="rihal-codebase-mapper",
194
- model="sonnet",
194
+ model="{model}",
195
195
  model="{mapper_model}",
196
196
  run_in_background=true,
197
197
  description="Map codebase architecture",
@@ -213,7 +213,7 @@ ${AGENT_SKILLS_MAPPER}"
213
213
  ```
214
214
  Task(
215
215
  subagent_type="rihal-codebase-mapper",
216
- model="sonnet",
216
+ model="{model}",
217
217
  model="{mapper_model}",
218
218
  run_in_background=true,
219
219
  description="Map codebase conventions",
@@ -235,7 +235,7 @@ ${AGENT_SKILLS_MAPPER}"
235
235
  ```
236
236
  Task(
237
237
  subagent_type="rihal-codebase-mapper",
238
- model="sonnet",
238
+ model="{model}",
239
239
  model="{mapper_model}",
240
240
  run_in_background=true,
241
241
  description="Map codebase concerns",
@@ -22,15 +22,32 @@ Valid rihal subagent types (use exact names — do not fall back to 'general-pur
22
22
  Parse `$ARGUMENTS` before anything else:
23
23
  - `--reset-phase-numbers` flag → restart roadmap phase numbering at `1`
24
24
  - `--dry-run` flag → show what would be written, do not commit
25
+ - `--from-draft <path>` flag → use an existing MILESTONE-CONTEXT.md or ROADMAP draft as the milestone definition (closes #740). When present, set `DRAFT_FILE=<path>` and `FROM_DRAFT_MODE=true`.
25
26
  - Remaining text → milestone name (optional)
26
27
 
27
- If the flag is absent, continue phase numbering from the previous milestone.
28
+ If `--from-draft` is absent, continue phase numbering from the previous milestone.
29
+
30
+ **From-draft mode (closes #740):**
31
+
32
+ When `FROM_DRAFT_MODE=true`:
33
+ 1. Read the draft file at `DRAFT_FILE`. Accept any markdown file — MILESTONE-CONTEXT.md, a scratch doc, or a ROADMAP partial.
34
+ 2. Extract milestone name (first `# Heading` or the filename stem), goals list, and any explicit phase list.
35
+ 3. Skip the interactive goal-gathering interview (steps 2–4). Jump directly to step 5 (Requirements scoping) using the draft as the source of truth.
36
+ 4. Surface a one-line banner:
37
+ ```
38
+ ◆ From-draft mode: using {DRAFT_FILE} as milestone definition (skipping goal interview)
39
+ ```
40
+ 5. If `DRAFT_FILE` does not exist, abort:
41
+ ```
42
+ Error: --from-draft file not found: {DRAFT_FILE}
43
+ ```
28
44
 
29
45
  Read these files in parallel:
30
46
  - `.planning/PROJECT.md` — existing project, validated requirements, decisions
31
47
  - `.planning/MILESTONES.md` — what shipped previously (may not exist on first milestone)
32
48
  - `.planning/STATE.md` — pending todos, blockers
33
49
  - `.planning/MILESTONE-CONTEXT.md` — if it exists (from a prior `/rihal-discuss` about the next milestone)
50
+ - `{DRAFT_FILE}` (if `FROM_DRAFT_MODE=true`)
34
51
 
35
52
  If `.planning/PROJECT.md` does not exist, STOP and redirect:
36
53
 
@@ -60,6 +60,15 @@ Task(prompt="<research_type>
60
60
  Project Research — Stack dimension for [domain].
61
61
  </research_type>
62
62
 
63
+ <objective>
64
+ Identify the standard stack for [domain].
65
+
66
+ Why this matters: this research feeds requirements definition and roadmap
67
+ creation for {project_name}. A sufficient result lets the roadmap pick
68
+ concrete libraries (with versions and rationale) and sequence build phases —
69
+ not a vague survey of options.
70
+ </objective>
71
+
63
72
  <milestone_context>
64
73
  [greenfield OR subsequent]
65
74
 
@@ -100,6 +109,15 @@ Task(prompt="<research_type>
100
109
  Project Research — Features dimension for [domain].
101
110
  </research_type>
102
111
 
112
+ <objective>
113
+ Identify the feature landscape for [domain].
114
+
115
+ Why this matters: this research feeds requirements definition and roadmap
116
+ creation for {project_name}. A sufficient result lets requirements separate
117
+ table stakes from differentiators and anti-features — not an undifferentiated
118
+ feature list.
119
+ </objective>
120
+
103
121
  <milestone_context>
104
122
  [greenfield OR subsequent]
105
123
 
@@ -140,6 +158,15 @@ Task(prompt="<research_type>
140
158
  Project Research — Architecture dimension for [domain].
141
159
  </research_type>
142
160
 
161
+ <objective>
162
+ Identify how [domain] systems are structured.
163
+
164
+ Why this matters: this research feeds requirements definition and roadmap
165
+ creation for {project_name}. A sufficient result lets the roadmap sequence
166
+ phases by component dependency and data flow — not a generic architecture
167
+ sketch.
168
+ </objective>
169
+
143
170
  <milestone_context>
144
171
  [greenfield OR subsequent]
145
172
 
@@ -180,6 +207,14 @@ Task(prompt="<research_type>
180
207
  Project Research — Pitfalls dimension for [domain].
181
208
  </research_type>
182
209
 
210
+ <objective>
211
+ Identify the common mistakes in [domain] projects.
212
+
213
+ Why this matters: this research feeds requirements definition and roadmap
214
+ creation for {project_name}. A sufficient result lets the roadmap assign each
215
+ pitfall a prevention step in a specific phase — not a generic warning list.
216
+ </objective>
217
+
183
218
  <milestone_context>
184
219
  [greenfield OR subsequent]
185
220
 
@@ -217,7 +252,24 @@ Use template: .rihal/templates/research-project/PITFALLS.md
217
252
  ", subagent_type="rihal-project-researcher", model="{researcher_model}", description="Pitfalls research")
218
253
  ```
219
254
 
220
- After all 4 agents complete, spawn synthesizer to create SUMMARY.md:
255
+ **Sufficiency loop (per dimension, runs before synthesis):**
256
+
257
+ @.rihal/references/iterative-retrieval.md
258
+
259
+ After the 4 parallel researchers return, evaluate each dimension's returned
260
+ artifact (STACK / FEATURES / ARCHITECTURE / PITFALLS) for sufficiency against
261
+ that dimension's `<objective>` — does it cover every sub-question, are
262
+ recommendations specific (versions/rationale) not vague, and were any
263
+ `## RESEARCH INCONCLUSIVE` or blocked signals returned. For any dimension
264
+ that is insufficient, re-dispatch that dimension's `rihal-project-researcher`
265
+ with a follow-up prompt naming the specific gaps and including the prior
266
+ result, asking only for the missing pieces. This loop is hard-capped at 3
267
+ cycles per dimension (initial + up to 2 follow-ups). After the cap, proceed
268
+ with the best result for that dimension and note residual gaps in its
269
+ artifact. Only then continue to synthesis.
270
+
271
+ After all 4 agents complete and the sufficiency loop has settled, spawn
272
+ synthesizer to create SUMMARY.md:
221
273
 
222
274
  ```
223
275
  Task(prompt="
@@ -139,7 +139,7 @@ Start work:
139
139
  /rihal-plan <task> --workspace={WORKSPACE_NAME}
140
140
 
141
141
  Switch context:
142
- /rihal-workspace {WORKSPACE_NAME}
142
+ /rihal-workstream switch --name {WORKSPACE_NAME}
143
143
  ```
144
144
 
145
145
  ## Success Criteria
@@ -0,0 +1,105 @@
1
+ <purpose>
2
+ Plan all phases in a milestone using parallel dependency-wave execution. Closes #732.
3
+ Groups independent phases into waves, spawns rihal-planner agents concurrently per wave, and verifies each SPRINT.md with rihal-sprint-checker before advancing.
4
+ </purpose>
5
+
6
+ <required_reading>
7
+ @.rihal/references/output-format.md
8
+ @.rihal/references/revision-loop.md
9
+ Read all files referenced by the invoking prompt's execution_context before starting.
10
+ </required_reading>
11
+
12
+ ## 1. Parse arguments and load context
13
+
14
+ Parse `$ARGUMENTS`:
15
+ - `--milestone <name>` — filter to a named milestone (optional)
16
+ - `--dry-run` — show wave plan without spawning agents
17
+ - `--skip-research` — skip rihal-phase-researcher for all phases
18
+ - `--wave <N>` — start from wave N (resume after partial failure)
19
+
20
+ ```bash
21
+ INIT_JSON=$(node ".rihal/bin/rihal-tools.cjs" state read 2>/dev/null || echo '{}')
22
+ ROADMAP_PHASES=$(node ".rihal/bin/rihal-tools.cjs" roadmap list-phases 2>/dev/null || echo '[]')
23
+ ```
24
+
25
+ ## 2. Build dependency wave graph
26
+
27
+ Read ROADMAP.md. For each planned phase:
28
+ 1. Extract its `**Dependencies:**` line (if present) — list of phase numbers it depends on.
29
+ 2. Phases with no dependencies → Wave 1.
30
+ 3. Phases whose all dependencies are in Wave N → Wave N+1.
31
+ 4. Repeat until all phases are assigned.
32
+
33
+ **Display wave plan:**
34
+ ```
35
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
36
+ RIHAL ► PLAN MILESTONE: {MILESTONE_NAME}
37
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
38
+
39
+ Wave 1 (parallel): Phase {N1}, Phase {N2}
40
+ Wave 2 (parallel): Phase {N3}
41
+ Wave 3 (serial): Phase {N4} ← depends on N3
42
+ ```
43
+
44
+ If `--dry-run`: print the plan and exit.
45
+
46
+ ## 3. Execute waves sequentially, phases in parallel
47
+
48
+ For each wave:
49
+
50
+ **3a. Spawn rihal-planner agents in parallel (one per phase in wave):**
51
+
52
+ Use `run_in_background: true` for each Agent dispatch. Wait for all to complete before next wave.
53
+
54
+ ```
55
+ ◆ Wave {N}: planning {count} phase(s) in parallel...
56
+ - Phase {N1}: {name}
57
+ - Phase {N2}: {name}
58
+ ```
59
+
60
+ Each planner agent receives:
61
+ - Phase number, name, goal from ROADMAP
62
+ - `--skip-research` if flag is set
63
+ - Research from RESEARCH.md if it exists
64
+
65
+ **3b. Verify each SPRINT.md with rihal-sprint-checker:**
66
+
67
+ After all planners in the wave complete, spawn rihal-sprint-checker for each SPRINT.md (in parallel, same run_in_background pattern). Collect CHECK.md results.
68
+
69
+ On `FAIL` for any phase:
70
+ ```
71
+ ⚠ Phase {N} sprint-checker FAIL — entering revision loop (max 2 iterations)
72
+ ```
73
+ Spawn a revision planner with checker feedback. Max 2 revision rounds per phase.
74
+
75
+ **3c. Advance to next wave:**
76
+
77
+ Only advance when all phases in the current wave have a passing CHECK.md.
78
+
79
+ ## 4. Completion summary
80
+
81
+ ```
82
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
83
+ RIHAL ► MILESTONE PLANNED ✓ {MILESTONE_NAME}
84
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
85
+
86
+ Waves: {N}
87
+ Phases planned: {M}
88
+ SPRINT.md files created: {M}
89
+
90
+ Next step: /rihal-execute-milestone
91
+ ```
92
+
93
+ ## Output Format
94
+
95
+ Open with wave-plan banner (step 2). Per-phase progress indicators. Closure banner (step 4).
96
+
97
+ ## Examples
98
+
99
+ **Happy path:** `/rihal-plan-milestone` → plans all pending phases in parallel dependency waves.
100
+
101
+ **Skip research:** `/rihal-plan-milestone --skip-research` → faster, uses CONTEXT.md if available.
102
+
103
+ **Resume:** `/rihal-plan-milestone --wave 2` → skip wave 1 (already planned), start from wave 2.
104
+
105
+ **Dry run:** `/rihal-plan-milestone --dry-run` → print wave assignment, exit.
@@ -111,7 +111,7 @@ Reason: {explain why}
111
111
  Task(
112
112
  prompt=research_prompt,
113
113
  subagent_type="rihal-phase-researcher",
114
- model="sonnet",
114
+ model="{model}",
115
115
  model="{researcher_model}",
116
116
  description="Research Phase {phase}"
117
117
  )
@@ -205,7 +205,7 @@ Every task MUST include these fields — they are NOT optional:
205
205
  Task(
206
206
  prompt=filled_prompt,
207
207
  subagent_type="rihal-planner",
208
- model="sonnet",
208
+ model="{model}",
209
209
  model="{planner_model}",
210
210
  description="Plan Phase {phase}"
211
211
  )
@@ -94,7 +94,7 @@ Parse JSON for: `researcher_model`, `planner_model`, `checker_model`, `research_
94
94
 
95
95
  ## 2. Parse and Normalize Arguments
96
96
 
97
- Extract from $ARGUMENTS: phase number (integer or decimal like `2.1`), flags (`--research`, `--skip-research`, `--gaps`, `--skip-verify`, `--prd <filepath>`, `--reviews`, `--text`).
97
+ Extract from $ARGUMENTS: phase number (integer or decimal like `2.1`), flags (`--research`, `--skip-research`, `--gaps`, `--skip-verify`, `--from-stub`, `--prd <filepath>`, `--reviews`, `--text`).
98
98
 
99
99
  Set `TEXT_MODE=true` if `--text` is present in $ARGUMENTS OR `text_mode` from init JSON is `true`. When `TEXT_MODE` is active, replace every `AskUserQuestion` call with a plain-text numbered list and ask the user to type their choice number. This is required for Claude Code remote sessions (`/rc` mode) where TUI menus don't work through the Claude App.
100
100
 
@@ -111,6 +111,34 @@ fi
111
111
 
112
112
  When `GAPS_MODE=true`, the workflow switches to **gap-closure planning**: read the phase's VERIFICATION.md, extract verification gaps classified `gap_found` or `partial`, and produce a single new numbered plan file (`NNN-NN-SPRINT.md`) that closes them. Research, CONTEXT.md gating, and VALIDATION.md creation are skipped — gaps are grounded in already-shipped code, not new design work.
113
113
 
114
+ **Detect from-stub mode (closes #736):**
115
+ ```bash
116
+ if [[ "$ARGUMENTS" =~ (^|[[:space:]])--from-stub($|[[:space:]]) ]]; then
117
+ FROM_STUB_MODE=true
118
+ else
119
+ FROM_STUB_MODE=false
120
+ fi
121
+ ```
122
+
123
+ When `FROM_STUB_MODE=true`, the workflow reads an existing stub `SPRINT.md` (or any `*-SPRINT.md`) already present in the phase directory and treats it as the authoritative task list — the researcher and CONTEXT.md gating are skipped. The stub is passed to the planner as `existing_stub_content` so it can refine, expand, and add implementation detail without rewriting the structure. This is the correct flow when a user has partially sketched a plan by hand or a prior workflow run created a skeleton.
124
+
125
+ **From-stub resolution:**
126
+ ```bash
127
+ if [[ "$FROM_STUB_MODE" == "true" ]]; then
128
+ STUB_FILE=$(ls "${PHASE_DIR}"/*-SPRINT.md 2>/dev/null | head -1)
129
+ if [[ -z "$STUB_FILE" ]]; then
130
+ echo "Error: --from-stub requires an existing SPRINT.md in the phase directory."
131
+ echo "Found: ${PHASE_DIR}"
132
+ echo " (create a stub manually then re-run with --from-stub)"
133
+ exit 1
134
+ fi
135
+ STUB_CONTENT=$(cat "$STUB_FILE")
136
+ echo "◆ From-stub mode: using $(basename $STUB_FILE) as planner input"
137
+ fi
138
+ ```
139
+
140
+ When `FROM_STUB_MODE=true`: skip steps 4 (CONTEXT.md), 5 (Research), 5.5 (Validation strategy). Jump directly to step 8 (Spawn rihal-planner). Pass `STUB_CONTENT` and `STUB_FILE` to the planner prompt so it refines rather than replaces the stub.
141
+
114
142
  **If no phase number:** Detect next unplanned phase from roadmap.
115
143
 
116
144
  **If `phase_found` is false:** Validate phase exists in ROADMAP.md. If valid, create the directory using `phase_slug` and `padded_phase` from init:
@@ -536,7 +564,7 @@ ${AGENT_SKILLS_CHECKER}
536
564
  Task(
537
565
  prompt=checker_prompt,
538
566
  subagent_type="rihal-sprint-checker",
539
- model="sonnet",
567
+ model="{model}",
540
568
  model="{checker_model}",
541
569
  description="Verify Phase {phase} plans"
542
570
  )
@@ -656,7 +684,7 @@ Return what changed.
656
684
  Task(
657
685
  prompt=revision_prompt,
658
686
  subagent_type="rihal-planner",
659
- model="sonnet",
687
+ model="{model}",
660
688
  model="{planner_model}",
661
689
  description="Revise Phase {phase} plans"
662
690
  )
@@ -155,6 +155,12 @@ File: .planning/seeds/SEED-{PADDED}-{slug}.md
155
155
 
156
156
  This seed will surface automatically when you run /rihal-new-milestone
157
157
  and the milestone scope matches the trigger condition.
158
+
159
+ ▶ Next Up
160
+ /rihal-status — review current focus before context-switching
161
+ /rihal-note "{$IDEA}" — capture related thoughts while fresh
162
+ /rihal-new-milestone — start the milestone that will consume this seed
163
+ /rihal-do — return to the dispatcher
158
164
  ```
159
165
  </step>
160
166
 
@@ -9,6 +9,7 @@ Closes the gap where /rihal-quick used to refuse + show a 4-option menu when giv
9
9
 
10
10
  <required_reading>
11
11
  @.rihal/references/verb-dictionary.md
12
+ @.rihal/references/git-preflight.md
12
13
  </required_reading>
13
14
 
14
15
  <process>
@@ -161,15 +162,20 @@ git commit -m "{type}: {concise description of what changed}"
161
162
  </step>
162
163
 
163
164
  <step name="log_to_state">
164
- If `.planning/STATE.md` exists with a "Quick Tasks Completed" table, append:
165
+ Append the completed task to `.planning/STATE.md`. Create the section if it
166
+ doesn't exist — projects initialized with `/rihal-new-project` use a STATE.md
167
+ shape that has no "Quick Tasks Completed" table by default (#601). Without
168
+ this fallback the entry was silently dropped on every fresh repo.
165
169
 
166
170
  ```bash
167
- if grep -q "Quick Tasks Completed" .planning/STATE.md 2>/dev/null; then
168
- echo "| $(date +%Y-%m-%d) | quick | $TASK | ✓ |" >> .planning/STATE.md
171
+ mkdir -p .planning
172
+ if [ ! -f .planning/STATE.md ]; then
173
+ printf '# Project State\n\n## Quick Tasks Completed\n\n| Date | Type | Task | Status |\n|------|------|------|--------|\n' > .planning/STATE.md
174
+ elif ! grep -q "Quick Tasks Completed" .planning/STATE.md 2>/dev/null; then
175
+ printf '\n## Quick Tasks Completed\n\n| Date | Type | Task | Status |\n|------|------|------|--------|\n' >> .planning/STATE.md
169
176
  fi
177
+ echo "| $(date +%Y-%m-%d) | quick | $TASK | ✓ |" >> .planning/STATE.md
170
178
  ```
171
-
172
- Skip silently if the table doesn't exist.
173
179
  </step>
174
180
 
175
181
  <step name="done">
@@ -53,8 +53,19 @@ AGENT_SKILLS_RESEARCHER=$(node ".rihal/bin/rihal-tools.cjs" agent-skills rihal-r
53
53
  Task(
54
54
  prompt="<objective>
55
55
  Research implementation approach for Phase {phase}: {name}
56
+
57
+ Why this phase matters: {description}
58
+ Broader goal: this research output must enable the planning step to break
59
+ Phase {phase} into concrete, buildable sprints — a sufficient result gives
60
+ planning specific approaches, libraries (with versions/rationale), and known
61
+ pitfalls, not a vague survey.
56
62
  </objective>
57
63
 
64
+ <objective_context>
65
+ Phase {phase} goal: {description}
66
+ Downstream consumer: /rihal-plan reads {phase}-RESEARCH.md to structure sprints.
67
+ </objective_context>
68
+
58
69
  <files_to_read>
59
70
  - {context_path} (USER DECISIONS from /rihal-discuss-phase)
60
71
  - {requirements_path} (Project requirements)
@@ -77,6 +88,19 @@ Write to: .planning/phases/${PHASE}-{slug}/${PHASE}-RESEARCH.md
77
88
 
78
89
  ## Step 5: Handle Return
79
90
 
91
+ @.rihal/references/iterative-retrieval.md
92
+
93
+ **Sufficiency loop (runs before routing):** When `rihal-phase-researcher`
94
+ returns its `## RESEARCH COMPLETE` summary, evaluate it for sufficiency
95
+ against the Step-4 objective — does it cover every dimension the phase goal
96
+ asked for, are recommendations specific (versions/rationale) not vague, and
97
+ were any `## RESEARCH INCONCLUSIVE` or blocked signals returned. If
98
+ insufficient, re-dispatch `rihal-phase-researcher` with a follow-up prompt
99
+ that names the specific gaps and includes the prior result, asking only for
100
+ the missing pieces. This loop is hard-capped at 3 cycles (initial + up to 2
101
+ follow-ups). After the cap, proceed with the best result and note residual
102
+ gaps in the RESEARCH.md artifact. Then offer the routing options below.
103
+
80
104
  - `## RESEARCH COMPLETE` — Display summary, offer: Plan/Dig deeper/Review/Done
81
105
  - `## CHECKPOINT REACHED` — Present to user, spawn continuation
82
106
  - `## RESEARCH INCONCLUSIVE` — Show attempts, offer: Add context/Try different mode/Manual
@@ -0,0 +1,60 @@
1
+ <purpose>
2
+ Bulk-create all phase directories for a milestone from a pipe-separated name list or from ROADMAP.md planned phases. Closes #731.
3
+ </purpose>
4
+
5
+ <process>
6
+
7
+ ## 1. Parse arguments
8
+
9
+ If `--names` is provided in `$ARGUMENTS`:
10
+
11
+ ```bash
12
+ node ".rihal/bin/rihal-tools.cjs" phase scaffold-milestone --names "${NAMES_ARG}" ${START_ARG:+--start $START_ARG}
13
+ ```
14
+
15
+ Print the result JSON and exit.
16
+
17
+ ## 2. Auto-detect from ROADMAP.md (when no --names)
18
+
19
+ Read `.planning/ROADMAP.md`. Extract all phase entries that:
20
+
21
+ - Have a `**Status:** Planned` line
22
+ - Do NOT have a corresponding directory under `.planning/phases/`
23
+
24
+ Collect their names in order. Build a pipe-separated list and pass to scaffold-milestone:
25
+
26
+ ```bash
27
+ PLANNED_NAMES="Phase A|Phase B|Phase C"
28
+ node ".rihal/bin/rihal-tools.cjs" phase scaffold-milestone --names "${PLANNED_NAMES}"
29
+ ```
30
+
31
+ ## 3. Report
32
+
33
+ Print a summary:
34
+
35
+ ```
36
+ ✓ Scaffolded {N} phase directories:
37
+ {number}-{slug}/
38
+ {number}-{slug}/
39
+ ...
40
+
41
+ Next step: /rihal-plan {first_number}
42
+ ```
43
+
44
+ </process>
45
+
46
+ ## Output Format
47
+
48
+ One line per created phase directory. Final "Next step" routing.
49
+
50
+ ## Examples
51
+
52
+ **With names:** `/rihal-scaffold-milestone --names "Auth System|Dashboard|API Layer"` → creates 3 phase dirs.
53
+
54
+ **Auto-detect:** `/rihal-scaffold-milestone` → reads ROADMAP.md, creates dirs for all Planned phases without existing directories.
55
+
56
+ ## Success Criteria
57
+
58
+ - [ ] Phase directories created under `.planning/phases/`
59
+ - [ ] Summary printed with one line per created directory
60
+ - [ ] Next-step routing printed
@@ -0,0 +1,137 @@
1
+ # Workflow: rihal-scaffold-skill
2
+
3
+ <purpose>
4
+ Create a new compliant SKILL.md file for a Rihal role in one command. Eliminates the friction of finding a folder, reading an existing skill, copying it, renaming, and chasing the 5-component compliance check.
5
+
6
+ Output: a SKILL.md that already passes `test/compliance.test.cjs` and is ready to be filled in.
7
+ </purpose>
8
+
9
+ ## Step 0 — Parse Arguments
10
+
11
+ Expected forms:
12
+
13
+ ```
14
+ /rihal-scaffold-skill --role <role> --name <skill-name>
15
+ /rihal-scaffold-skill --role pm --name sharper-prd-discovery
16
+ /rihal-scaffold-skill --help
17
+ ```
18
+
19
+ Required: `--role` (one of: `pm`, `qa`, `architect`, `frontend`, `backend`, `marketing`, `designer`, `writer`, `engineer`, `ml`, `branding`, `eng-manager`, `analyst`, `director`, `scout`).
20
+
21
+ Required: `--name` — kebab-case identifier. Validate it matches `^[a-z][a-z0-9-]+$`.
22
+
23
+ Optional: `--dry-run` — print the file content to stdout instead of writing.
24
+
25
+ If `$ARGUMENTS` is `--help` or empty, print usage and STOP.
26
+
27
+ ## Step 1 — Resolve target path
28
+
29
+ Map `--role` to a directory under `rihal/skills/actions/`. Group by role family:
30
+
31
+ | Role flag | Target directory |
32
+ |-----------|------------------|
33
+ | `pm` | `rihal/skills/actions/1-discovery/rihal-<name>/` |
34
+ | `architect` | `rihal/skills/actions/2-planning/rihal-<name>/` |
35
+ | `engineer`, `frontend`, `backend`, `ml` | `rihal/skills/actions/4-implementation/rihal-<name>/` |
36
+ | `qa` | `rihal/skills/actions/5-verification/rihal-<name>/` |
37
+ | `designer`, `branding` | `rihal/skills/actions/3-design/rihal-<name>/` |
38
+ | `marketing`, `writer`, `eng-manager`, `analyst`, `director`, `scout` | `rihal/skills/actions/6-other/rihal-<name>/` |
39
+
40
+ If the directory already exists, abort with: `Skill rihal-<name> already exists at <path>. Pick a different --name or delete the existing directory first.`
41
+
42
+ ## Step 2 — Write the template
43
+
44
+ Write `rihal/skills/actions/<group>/rihal-<name>/SKILL.md` with this content (substitute `<NAME>`, `<ROLE>`, `<DESCRIPTION_FILLER>`):
45
+
46
+ ```yaml
47
+ ---
48
+ name: rihal-<NAME>
49
+ description: >
50
+ <One-line summary of what this skill does. Activates when the user says
51
+ "<trigger phrase>", "<another phrase>". Do NOT use for: <negative
52
+ boundaries>.>
53
+ triggers:
54
+ - "<trigger phrase 1>"
55
+ - "<trigger phrase 2>"
56
+ - "<trigger phrase 3>"
57
+ - "<trigger phrase 4>"
58
+ - "<trigger phrase 5>"
59
+ ---
60
+
61
+ # <NAME> — <ROLE>
62
+
63
+ ## Overview
64
+
65
+ <2-3 sentences explaining what the skill does and when it's invoked. What
66
+ real-world problem does it solve? What does the user get back when they
67
+ invoke it?>
68
+
69
+ ## Workflow
70
+
71
+ <Step-by-step instructions the model follows. Use numbered steps. Each step
72
+ should be specific enough that two different models converge to similar
73
+ output. Reference rihal-tools subcommands where state changes are needed.>
74
+
75
+ 1. <First step>
76
+ 2. <Second step>
77
+ 3. <Third step>
78
+
79
+ ## Output Format
80
+
81
+ <Exact shape of the output. If markdown, include the headers. If JSON, the
82
+ schema. The compliance check expects this section verbatim — keep the
83
+ heading text as "## Output Format".>
84
+
85
+ ## Examples
86
+
87
+ ### Happy path
88
+
89
+ <Input → output example showing the skill at its best>
90
+
91
+ ### Edge case
92
+
93
+ <Input → output for a tricky variant (missing data, ambiguous request, etc.)>
94
+
95
+ ### Negative
96
+
97
+ <Input that should NOT trigger this skill — show the redirect>
98
+ ```
99
+
100
+ ## Step 3 — Verify compliance
101
+
102
+ Run the 5-component check on the new file:
103
+
104
+ ```bash
105
+ F="rihal/skills/actions/<group>/rihal-<name>/SKILL.md"
106
+ fails=""
107
+ grep -q "^triggers:" "$F" || fails="$fails triggers-frontmatter"
108
+ grep -q "^## Overview" "$F" || fails="$fails overview"
109
+ grep -q "^## Workflow" "$F" || fails="$fails workflow"
110
+ grep -q "^## Output Format" "$F" || fails="$fails output-format"
111
+ grep -q "^## Examples" "$F" || fails="$fails examples"
112
+
113
+ if [ -n "$fails" ]; then
114
+ echo "✖ Scaffolded skill missing components:$fails"
115
+ echo " This is a bug in the scaffolder template — file an issue."
116
+ exit 1
117
+ fi
118
+ ```
119
+
120
+ ## Step 4 — Confirm and Next Up
121
+
122
+ Print:
123
+
124
+ ```
125
+ ✓ Skill scaffolded: rihal-<NAME>
126
+ Location: rihal/skills/actions/<group>/rihal-<NAME>/SKILL.md
127
+
128
+ All 5 required components are present (triggers, Overview, Workflow,
129
+ Output Format, Examples). The placeholders need real content before
130
+ the skill becomes useful.
131
+
132
+ ▶ Next Up
133
+ $EDITOR rihal/skills/actions/<group>/rihal-<NAME>/SKILL.md
134
+ # fill in placeholders
135
+ npx @hanzlaa/rcode install --force # install to .claude/skills/
136
+ node --test test/compliance.test.cjs # verify compliance
137
+ ```
@@ -227,7 +227,7 @@ Task(
227
227
 
228
228
  This scope section is non-negotiable — the orchestrator will reject documents missing it.",
229
229
  subagent_type="rihal-codebase-mapper",
230
- model="sonnet",
230
+ model="{model}",
231
231
  model="{resolved_model}"
232
232
  )
233
233
  ```