@hanzlaa/rcode 3.4.4 → 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 +112 -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
@@ -0,0 +1,108 @@
1
+ <purpose>
2
+ Sub-step of plan.md — Step 3.5 PRD Express Path. Handles the --prd flag: parses a PRD document and auto-generates CONTEXT.md from it, bypassing manual discussion.
3
+ </purpose>
4
+
5
+ ## 3.5. Handle PRD Express Path
6
+
7
+ **Skip if:** No `--prd` flag in arguments.
8
+
9
+ **If `--prd <filepath>` provided:**
10
+
11
+ 1. Read the PRD file:
12
+ ```bash
13
+ PRD_CONTENT=$(cat "$PRD_FILE" 2>/dev/null)
14
+ if [ -z "$PRD_CONTENT" ]; then
15
+ echo "Error: PRD file not found: $PRD_FILE"
16
+ exit 1
17
+ fi
18
+ ```
19
+
20
+ 2. Display banner:
21
+ ```
22
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
23
+ Rihal ► PRD EXPRESS PATH
24
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
25
+
26
+ Using PRD: {PRD_FILE}
27
+ Generating CONTEXT.md from requirements...
28
+ ```
29
+
30
+ 3. Parse the PRD content and generate CONTEXT.md. The orchestrator should:
31
+ - Extract all requirements, user stories, acceptance criteria, and constraints from the PRD
32
+ - Map each to a locked decision (everything in the PRD is treated as a locked decision)
33
+ - Identify any areas the PRD doesn't cover and mark as "Claude's Discretion"
34
+ - **Extract canonical refs** from ROADMAP.md for this phase, plus any specs/ADRs referenced in the PRD — expand to full file paths (MANDATORY)
35
+ - Create CONTEXT.md in the phase directory
36
+
37
+ 4. Write CONTEXT.md:
38
+ ```markdown
39
+ # Phase [X]: [Name] - Context
40
+
41
+ **Gathered:** [date]
42
+ **Status:** Ready for planning
43
+ **Source:** PRD Express Path ({PRD_FILE})
44
+
45
+ <domain>
46
+ ## Phase Boundary
47
+
48
+ [Extracted from PRD — what this phase delivers]
49
+
50
+ </domain>
51
+
52
+ <decisions>
53
+ ## Implementation Decisions
54
+
55
+ {For each requirement/story/criterion in the PRD:}
56
+ ### [Category derived from content]
57
+ - [Requirement as locked decision]
58
+
59
+ ### Claude's Discretion
60
+ [Areas not covered by PRD — implementation details, technical choices]
61
+
62
+ </decisions>
63
+
64
+ <canonical_refs>
65
+ ## Canonical References
66
+
67
+ **Downstream agents MUST read these before planning or implementing.**
68
+
69
+ [MANDATORY. Extract from ROADMAP.md and any docs referenced in the PRD.
70
+ Use full relative paths. Group by topic area.]
71
+
72
+ ### [Topic area]
73
+ - `path/to/spec-or-adr.md` — [What it decides/defines]
74
+
75
+ [If no external specs: "No external specs — requirements fully captured in decisions above"]
76
+
77
+ </canonical_refs>
78
+
79
+ <specifics>
80
+ ## Specific Ideas
81
+
82
+ [Any specific references, examples, or concrete requirements from PRD]
83
+
84
+ </specifics>
85
+
86
+ <deferred>
87
+ ## Deferred Ideas
88
+
89
+ [Items in PRD explicitly marked as future/v2/out-of-scope]
90
+ [If none: "None — PRD covers phase scope"]
91
+
92
+ </deferred>
93
+
94
+ ---
95
+
96
+ *Phase: XX-name*
97
+ *Context gathered: [date] via PRD Express Path*
98
+ ```
99
+
100
+ 5. Commit:
101
+ ```bash
102
+ node ".rihal/bin/rihal-tools.cjs" commit "docs(${padded_phase}): generate context from PRD" --files "${phase_dir}/${padded_phase}-CONTEXT.md"
103
+ ```
104
+
105
+ 6. Set `context_content` to the generated CONTEXT.md content and continue to step 5 (Handle Research).
106
+
107
+ **Effect:** This completely bypasses step 4 (Load CONTEXT.md) since we just created it. The rest of the workflow (research, planning, verification) proceeds normally with the PRD-derived context.
108
+
@@ -0,0 +1,313 @@
1
+ <purpose>
2
+ Sub-steps of plan.md — Steps 5 through 5.7. Handles research, validation architecture, security threat model gate, UI design contract gate, and schema push detection.
3
+ </purpose>
4
+
5
+ ## 5. Handle Research
6
+
7
+ **Skip if:** `--gaps` flag or `--skip-research` flag or `--reviews` flag.
8
+
9
+ **If `has_research` is true (from init) AND no `--research` flag:** Use existing, skip to step 6.
10
+
11
+ **If RESEARCH.md missing AND `has_context` is true AND no `--research` flag:** Skip research silently and proceed to step 6. CONTEXT.md already captures the user's design decisions — re-researching adds tokens without new signal. Display: `Research skipped — CONTEXT.md found (use --research to force)`. This closes #588.
12
+
13
+ **If RESEARCH.md missing OR `--research` flag:**
14
+
15
+ **If no explicit flag (`--research` or `--skip-research`) and not `--auto`:**
16
+ Ask the user whether to research, with a contextual recommendation based on the phase:
17
+
18
+ If `TEXT_MODE` is true, present as a plain-text numbered list:
19
+ ```
20
+ Research before planning Phase {X}: {phase_name}?
21
+
22
+ 1. Research first (Recommended) — Investigate domain, patterns, and dependencies before planning. Best for new features, unfamiliar integrations, or architectural changes.
23
+ 2. Skip research — Plan directly from context and requirements. Best for bug fixes, simple refactors, or well-understood tasks.
24
+
25
+ Enter number:
26
+ ```
27
+
28
+ Otherwise use AskUserQuestion:
29
+ ```
30
+ AskUserQuestion([
31
+ {
32
+ question: "Research before planning Phase {X}: {phase_name}?",
33
+ header: "Research",
34
+ multiSelect: false,
35
+ options: [
36
+ { label: "Research first (Recommended)", description: "Investigate domain, patterns, and dependencies before planning. Best for new features, unfamiliar integrations, or architectural changes." },
37
+ { label: "Skip research", description: "Plan directly from context and requirements. Best for bug fixes, simple refactors, or well-understood tasks." }
38
+ ]
39
+ }
40
+ ])
41
+ ```
42
+
43
+ If user selects "Skip research": skip to step 6.
44
+
45
+ **If `--auto` and `research_enabled` is false:** Skip research silently (preserves automated behavior).
46
+
47
+ Display banner:
48
+ ```
49
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
50
+ Rihal ► RESEARCHING PHASE {X}
51
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
52
+
53
+ ◆ Spawning researcher...
54
+ ```
55
+
56
+ ### Spawn rihal-phase-researcher
57
+
58
+ ```bash
59
+ PHASE_DESC=$(node ".rihal/bin/rihal-tools.cjs" roadmap get-phase "${PHASE}" --pick section)
60
+ ```
61
+
62
+ Research prompt:
63
+
64
+ ```markdown
65
+ <objective>
66
+ Research how to implement Phase {phase_number}: {phase_name}
67
+ Answer: "What do I need to know to PLAN this phase well?"
68
+ </objective>
69
+
70
+ <files_to_read>
71
+ - {context_path} (USER DECISIONS from /rihal-discuss-phase)
72
+ - {requirements_path} (Project requirements)
73
+ - {state_path} (Project decisions and history)
74
+ </files_to_read>
75
+
76
+ ${AGENT_SKILLS_RESEARCHER}
77
+
78
+ <additional_context>
79
+ **Phase description:** {phase_description}
80
+ **Phase requirement IDs (MUST address):** {phase_req_ids}
81
+
82
+ **Project instructions:** Read ./CLAUDE.md if exists — follow project-specific guidelines
83
+ **Project skills:** Check .claude/skills/ or .agents/skills/ directory (if either exists) — read SKILL.md files, research should account for project skill patterns
84
+ </additional_context>
85
+
86
+ <output>
87
+ Write to: {phase_dir}/{phase_num}-RESEARCH.md
88
+
89
+ **MANDATORY section — include even if brief:**
90
+
91
+ ```markdown
92
+ ## Validation Architecture
93
+
94
+ | Concern | Test File | Command | When (Wave) |
95
+ |---------|-----------|---------|-------------|
96
+ | {feature} | {path/to/test.ts} | {run command} | Wave {N} |
97
+ ```
98
+
99
+ This section is required to enable Dimension 8 (Nyquist Compliance) in the plan checker. If no automated tests are feasible for this phase, write:
100
+
101
+ ```markdown
102
+ ## Validation Architecture
103
+
104
+ Manual verification only — no automated test files planned for this phase.
105
+ Reason: {explain why}
106
+ ```
107
+ </output>
108
+ ```
109
+
110
+ ```
111
+ Task(
112
+ prompt=research_prompt,
113
+ subagent_type="rihal-phase-researcher",
114
+ model="sonnet",
115
+ model="{researcher_model}",
116
+ description="Research Phase {phase}"
117
+ )
118
+ ```
119
+
120
+ ### Handle Researcher Return
121
+
122
+ - **`## RESEARCH COMPLETE`:** Display confirmation, continue to step 6
123
+ - **`## RESEARCH BLOCKED`:** Display blocker, offer: 1) Provide context, 2) Skip research, 3) Abort
124
+
125
+ ## 5.5. Create Validation Strategy
126
+
127
+ Skip if `nyquist_validation_enabled` is false OR `research_enabled` is false.
128
+
129
+ If `research_enabled` is false and `nyquist_validation_enabled` is true: warn "Nyquist validation enabled but research disabled — VALIDATION.md cannot be created without RESEARCH.md. Plans will lack validation requirements (Dimension 8)." Continue to step 6.
130
+
131
+ **But Nyquist is not applicable for this run** when all of the following are true:
132
+ - `research_enabled` is false
133
+ - `has_research` is false
134
+ - no `--research` flag was provided
135
+
136
+ In that case: **skip validation-strategy creation entirely**. Do **not** expect `RESEARCH.md` or `VALIDATION.md` for this run, and continue to Step 6.
137
+
138
+ ```bash
139
+ grep -l "## Validation Architecture" "${PHASE_DIR}"/*-RESEARCH.md 2>/dev/null || true
140
+ ```
141
+
142
+ **If found:**
143
+ 1. Read template: `.rihal/templates/VALIDATION.md`
144
+ 2. Write to `${PHASE_DIR}/${PADDED_PHASE}-VALIDATION.md` (use Write tool)
145
+ 3. Fill frontmatter: `{N}` → phase number, `{phase-slug}` → slug, `{date}` → current date
146
+ 4. Verify:
147
+ ```bash
148
+ test -f "${PHASE_DIR}/${PADDED_PHASE}-VALIDATION.md" && echo "VALIDATION_CREATED=true" || echo "VALIDATION_CREATED=false"
149
+ ```
150
+ 5. If `VALIDATION_CREATED=false`: STOP — do not proceed to Step 6
151
+ 6. If `commit_docs`: `commit "docs(phase-${PHASE}): add validation strategy"`
152
+
153
+ **If not found:** Warn and continue — plans may fail Dimension 8.
154
+
155
+ ## 5.55. Security Threat Model Gate
156
+
157
+ > Skip if `workflow.security_enforcement` is explicitly `false`. Absent = enabled.
158
+
159
+ ```bash
160
+ SECURITY_CFG=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
161
+ SECURITY_ASVS=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow.security_asvs_level --raw 2>/dev/null || echo "1")
162
+ SECURITY_BLOCK=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow.security_block_on --raw 2>/dev/null || echo "high")
163
+ ```
164
+
165
+ **If `SECURITY_CFG` is `false`:** Skip to step 5.6.
166
+
167
+ **If `SECURITY_CFG` is `true`:** Display banner:
168
+
169
+ ```
170
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
171
+ Rihal ► SECURITY THREAT MODEL REQUIRED (ASVS L{SECURITY_ASVS})
172
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
173
+
174
+ Each SPRINT.md must include a <threat_model> block.
175
+ Block on: {SECURITY_BLOCK} severity threats.
176
+ Opt out: set security_enforcement: false in .planning/config.json
177
+ ```
178
+
179
+ Continue to step 5.6. Security config is passed to the planner in step 8.
180
+
181
+ ## 5.6. UI Design Contract Gate
182
+
183
+ > Skip if `workflow.ui_phase` is explicitly `false` AND `workflow.ui_safety_gate` is explicitly `false` in `.planning/config.json`. If keys are absent, treat as enabled.
184
+
185
+ ```bash
186
+ UI_PHASE_CFG=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow.ui_phase 2>/dev/null || echo "true")
187
+ UI_GATE_CFG=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow.ui_safety_gate 2>/dev/null || echo "true")
188
+ ```
189
+
190
+ **If both are `false`:** Skip to step 6.
191
+
192
+ Check if phase has frontend indicators:
193
+
194
+ ```bash
195
+ PHASE_SECTION=$(node ".rihal/bin/rihal-tools.cjs" roadmap get-phase "${PHASE}" 2>/dev/null)
196
+ echo "$PHASE_SECTION" | grep -iE "UI|interface|frontend|component|layout|page|screen|view|form|dashboard|widget" > /dev/null 2>&1
197
+ HAS_UI=$?
198
+ ```
199
+
200
+ **If `HAS_UI` is 0 (frontend indicators found):**
201
+
202
+ Check for existing UI-SPEC:
203
+ ```bash
204
+ UI_SPEC_FILE=$(ls "${PHASE_DIR}"/*-UI-SPEC.md 2>/dev/null | head -1)
205
+ ```
206
+
207
+ **If UI-SPEC.md found:** Set `UI_SPEC_PATH=$UI_SPEC_FILE`. Display: `Using UI design contract: ${UI_SPEC_PATH}`
208
+
209
+ **If UI-SPEC.md missing AND `UI_GATE_CFG` is `true`:**
210
+
211
+ Read auto-chain state:
212
+ ```bash
213
+ AUTO_CHAIN=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
214
+ ```
215
+
216
+ **If `AUTO_CHAIN` is `true` (running inside a `--chain` or `--auto` pipeline):**
217
+
218
+ Auto-generate UI-SPEC without prompting:
219
+ ```
220
+ Skill(skill="rihal-ui-phase", args="${PHASE} --auto ${Rihal_WS}")
221
+ ```
222
+ After `rihal-ui-phase` returns, re-read:
223
+ ```bash
224
+ UI_SPEC_FILE=$(ls "${PHASE_DIR}"/*-UI-SPEC.md 2>/dev/null | head -1)
225
+ UI_SPEC_PATH="${UI_SPEC_FILE}"
226
+ ```
227
+ Continue to step 6.
228
+
229
+ **If `AUTO_CHAIN` is `false` (manual invocation):**
230
+
231
+ If `TEXT_MODE` is true, present as a plain-text numbered list:
232
+ ```
233
+ Phase {N} has frontend indicators but no UI-SPEC.md. Generate a design contract before planning?
234
+
235
+ 1. Generate UI-SPEC first — Run /rihal-ui-phase {N} then re-run /rihal-sprint-plan {N}
236
+ 2. Continue without UI-SPEC
237
+ 3. Not a frontend phase
238
+
239
+ Enter number:
240
+ ```
241
+
242
+ Otherwise use AskUserQuestion:
243
+ - header: "UI Design Contract"
244
+ - question: "Phase {N} has frontend indicators but no UI-SPEC.md. Generate a design contract before planning?"
245
+ - options:
246
+ - "Generate UI-SPEC first" → Display: "Run `/rihal-ui-phase {N} ${Rihal_WS}` then re-run `/rihal-sprint-plan {N} ${Rihal_WS}`". Exit workflow.
247
+ - "Continue without UI-SPEC" → Continue to step 6.
248
+ - "Not a frontend phase" → Continue to step 6.
249
+
250
+ **If `HAS_UI` is 1 (no frontend indicators):** Skip silently to step 5.7.
251
+
252
+ ## 5.7. Schema Push Detection Gate
253
+
254
+ > Detects schema-relevant files in the phase scope and injects a mandatory `[BLOCKING]` schema push task into the plan. Prevents false-positive verification where build/types pass because TypeScript types come from config, not the live database.
255
+
256
+ Check if any files in the phase scope match schema patterns:
257
+
258
+ ```bash
259
+ PHASE_SECTION=$(node ".rihal/bin/rihal-tools.cjs" roadmap get-phase "${PHASE}" --pick section 2>/dev/null)
260
+ ```
261
+
262
+ Scan `PHASE_SECTION`, `CONTEXT.md` (if loaded), and `RESEARCH.md` (if exists) for file paths matching these ORM patterns:
263
+
264
+ | ORM | File Patterns |
265
+ |-----|--------------|
266
+ | Payload CMS | `src/collections/**/*.ts`, `src/globals/**/*.ts` |
267
+ | Prisma | `prisma/schema.prisma`, `prisma/schema/*.prisma` |
268
+ | Drizzle | `drizzle/schema.ts`, `src/db/schema.ts`, `drizzle/*.ts` |
269
+ | Supabase | `supabase/migrations/*.sql` |
270
+ | TypeORM | `src/entities/**/*.ts`, `src/migrations/**/*.ts` |
271
+
272
+ Also check if any existing SPRINT.md files for this phase already reference these file patterns in `files_modified`.
273
+
274
+ **If schema-relevant files detected:**
275
+
276
+ Set `SCHEMA_PUSH_REQUIRED=true` and `SCHEMA_ORM={detected_orm}`.
277
+
278
+ Determine the push command for the detected ORM:
279
+
280
+ | ORM | Push Command | Non-TTY Workaround |
281
+ |-----|-------------|-------------------|
282
+ | Payload CMS | `npx payload migrate` | `CI=true PAYLOAD_MIGRATING=true npx payload migrate` |
283
+ | Prisma | `npx prisma db push` | `npx prisma db push --accept-data-loss` (if destructive) |
284
+ | Drizzle | `npx drizzle-kit push` | `npx drizzle-kit push` |
285
+ | Supabase | `supabase db push` | Set `SUPABASE_ACCESS_TOKEN` env var |
286
+ | TypeORM | `npx typeorm migration:run` | `npx typeorm migration:run -d src/data-source.ts` |
287
+
288
+ Inject the following into the planner prompt (step 8) as an additional constraint:
289
+
290
+ ```markdown
291
+ <schema_push_requirement>
292
+ **[BLOCKING] Schema Push Required**
293
+
294
+ This phase modifies schema-relevant files ({detected_files}). The planner MUST include
295
+ a `[BLOCKING]` task that runs the database schema push command AFTER all schema file
296
+ modifications are complete but BEFORE verification.
297
+
298
+ - ORM detected: {SCHEMA_ORM}
299
+ - Push command: {push_command}
300
+ - Non-TTY workaround: {env_hint}
301
+ - If push requires interactive prompts that cannot be suppressed, flag the task for
302
+ manual intervention with `autonomous: false`
303
+
304
+ This task is mandatory — the phase CANNOT pass verification without it. Build and
305
+ type checks will pass without the push (types come from config, not the live database),
306
+ creating a false-positive verification state.
307
+ </schema_push_requirement>
308
+ ```
309
+
310
+ Display: `Schema files detected ({SCHEMA_ORM}) — [BLOCKING] push task will be injected into plans`
311
+
312
+ **If no schema-relevant files detected:** Skip silently to step 6.
313
+
@@ -0,0 +1,204 @@
1
+ <purpose>
2
+ Sub-step of plan.md — Step 8 Spawn rihal-planner Agent. Spawns rihal-planner with full context to generate SPRINT.md plans. Includes deep-work rules and downstream consumer spec.
3
+ </purpose>
4
+
5
+ ## 8. Spawn rihal-planner Agent
6
+
7
+ Display banner:
8
+ ```
9
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
10
+ Rihal ► PLANNING PHASE {X}
11
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
12
+
13
+ ◆ Spawning planner...
14
+ ```
15
+
16
+ **Gap-closure planner prompt (when `GAPS_MODE=true`):**
17
+
18
+ When `GAPS_MODE=true`, use the prompt below in place of the standard planner prompt. The planner must emit **exactly one** new plan file at `${GAP_PLAN_PATH}` that closes the listed gaps. Do not create CONTEXT.md or RESEARCH.md references — gaps are grounded in already-shipped code.
19
+
20
+ ```markdown
21
+ <planning_context>
22
+ **Phase:** {phase_number}
23
+ **Mode:** gap_closure
24
+ **Phase goal:** {goal from ROADMAP.md}
25
+
26
+ <files_to_read>
27
+ - {VERIFICATION_FILE} (Authoritative verification report — source of truth for gaps)
28
+ - {state_path} (Project State)
29
+ - {roadmap_path} (Roadmap)
30
+ - {requirements_path} (Requirements)
31
+ - Existing plan files in this phase: {EXISTING_PLAN_FILES}
32
+ - Existing summary files in this phase: {EXISTING_SUMMARY_FILES}
33
+ </files_to_read>
34
+
35
+ ${AGENT_SKILLS_PLANNER}
36
+
37
+ <gap_list>
38
+ {Serialized GAP_LIST — for each gap include id, title, expected behavior, actual behavior, status (gap_found|partial), and source section.}
39
+ </gap_list>
40
+
41
+ <output>
42
+ Write a single new plan file to: {GAP_PLAN_PATH}
43
+
44
+ Frontmatter MUST include:
45
+ ---
46
+ phase: {phase_number}
47
+ plan_number: {NEXT_PLAN_NUMBER}
48
+ gap_closure: true
49
+ wave: 1
50
+ depends_on: []
51
+ files_modified: [...]
52
+ autonomous: true|false
53
+ ---
54
+
55
+ Each gap in the list MUST be addressed by at least one task. Use the anti-shallow execution rules below.
56
+ </output>
57
+ </planning_context>
58
+ ```
59
+
60
+ Proceed to the standard planner Task invocation below, but pass the gap-closure prompt above. After the planner returns, the normal plan-checker / revision loop (step 10+) runs unchanged.
61
+
62
+ ---
63
+
64
+ **Standard planner prompt (when `GAPS_MODE=false`):**
65
+
66
+ Planner prompt:
67
+
68
+ ```markdown
69
+ <planning_context>
70
+ **Phase:** {phase_number}
71
+ **Mode:** {standard | gap_closure | reviews}
72
+
73
+ <files_to_read>
74
+ - {state_path} (Project State)
75
+ - {roadmap_path} (Roadmap)
76
+ - {requirements_path} (Requirements)
77
+ - {context_path} (USER DECISIONS from /rihal-discuss-phase — read `<decisions>` for locked choices AND `<code_context>` for existing code patterns, reusable assets, and architectural notes gathered during discuss-phase)
78
+ - {research_path} (Technical Research)
79
+ - {verification_path} (Verification Gaps - if --gaps)
80
+ - {uat_path} (UAT Gaps - if --gaps)
81
+ - {reviews_path} (Cross-AI Review Feedback - if --reviews)
82
+ - {UI_SPEC_PATH} (UI Design Contract — visual/interaction specs, if exists)
83
+ ${CONTEXT_WINDOW >= 500000 ? `
84
+ **Cross-phase context (1M model enrichment — most recent 5 phases only to avoid context overflow):**
85
+ - Prior phase CONTEXT.md files (locked decisions from earlier phases — maintain consistency). Cap: read the 5 most recent phases by phase number only.
86
+ - Prior phase SUMMARY.md files (what was actually built — reuse patterns, avoid duplication). Cap: read the 5 most recent phases by phase number only. Specifically check **Provides** sections: these list functions, APIs, and models from earlier phases that this phase can reuse without rebuilding.
87
+ ` : ''}
88
+ </files_to_read>
89
+
90
+ ${AGENT_SKILLS_PLANNER}
91
+
92
+ **Phase requirement IDs (every ID MUST appear in a plan's `requirements` field):** {phase_req_ids}
93
+
94
+ **Project instructions:** Read ./CLAUDE.md if exists — follow project-specific guidelines
95
+ **Project skills:** Check .claude/skills/ or .agents/skills/ directory (if either exists) — read SKILL.md files, plans should account for project skill rules
96
+
97
+ </planning_context>
98
+
99
+ <downstream_consumer>
100
+ Output consumed by /rihal-execute. Plans need:
101
+ - Frontmatter (wave, depends_on, autonomous, **files_modified** — aggregated list of all file paths from `<files>` blocks across every task; used by executor for intra-wave parallel-safety overlap detection)
102
+ - Tasks in XML format with read_first, files, acceptance_criteria, verify (with `<automated>` child), and done fields (MANDATORY on every task)
103
+ - Verification criteria
104
+ - must_haves for goal-backward verification
105
+ </downstream_consumer>
106
+
107
+ <deep_work_rules>
108
+ ## Anti-Shallow Execution Rules (MANDATORY)
109
+
110
+ Every task MUST include these fields — they are NOT optional:
111
+
112
+ 1. **`<read_first>`** — Files the executor MUST read before touching anything. Always include:
113
+ - The file being modified (so executor sees current state, not assumptions)
114
+ - Any "source of truth" file referenced in CONTEXT.md (reference implementations, existing patterns, config files, schemas)
115
+ - Any file whose patterns, signatures, types, or conventions must be replicated or respected
116
+
117
+ 2. **`<files>`** — Exact files this task will modify or create. One path per line. Used by:
118
+ - Wave conflict checker (detects parallel tasks touching the same file)
119
+ - Verifier (confirms per-task file changes were actually made)
120
+ - Executor checkpoint (knows what to stage after each task)
121
+ - Example: `src/auth/auth.service.ts`, `tests/auth/auth.service.test.ts`
122
+
123
+ 3. **`<acceptance_criteria>`** — Verifiable conditions that prove the task was done correctly. Rules:
124
+ - Every criterion must be checkable with grep, file read, test command, or CLI output
125
+ - NEVER use subjective language ("looks correct", "properly configured", "consistent with")
126
+ - ALWAYS include exact strings, patterns, values, or command outputs that must be present
127
+ - Examples:
128
+ - Code: `auth.py contains def verify_token(` / `test_auth.py exits 0`
129
+ - Config: `.env.example contains DATABASE_URL=` / `Dockerfile contains HEALTHCHECK`
130
+ - Docs: `README.md contains '## Installation'` / `API.md lists all endpoints`
131
+ - Infra: `deploy.yml has rollback step` / `docker-compose.yml has healthcheck for db`
132
+
133
+ 4. **`<verify>`** — Shell commands that PROVE the acceptance criteria are met. Run by executor after task completes and by verifier during post-execution check. The block MUST contain an `<automated>` child with the exact commands to run (Dimension 8 hard-blocks without it). Rules:
134
+ - `<automated>` commands must exit 0 on success, non-zero on failure
135
+ - Prefer `grep -q` for presence checks, `test -f` for file existence, project test runner for behavior
136
+ - Keep commands short and composable — one check per line
137
+ - If test file doesn't exist yet (TDD tasks), write `<automated>MISSING</automated>` and add a Wave 0 task to create the test
138
+ - Example structure:
139
+ ```xml
140
+ <verify>
141
+ <automated>
142
+ grep -q 'def verify_token' src/auth.py
143
+ python -m pytest tests/test_auth.py -x -q 2>&1 | grep -q 'passed'
144
+ test -f src/components/Button.tsx
145
+ </automated>
146
+ </verify>
147
+ ```
148
+
149
+ 5. **`<done>`** — Observable acceptance state: a single sentence describing what is TRUE when this task is complete. Must be user/output-observable, not implementation-focused. Examples:
150
+ - `auth.py exports verify_token() and tests pass`
151
+ - `Button.tsx renders with correct className, no inline styles`
152
+ - `.env.example contains DATABASE_URL and REDIS_URL entries`
153
+
154
+ 6. **`<action>`** — Must include CONCRETE values, not references. Rules:
155
+ - NEVER say "align X with Y", "match X to Y", "update to be consistent" without specifying the exact target state
156
+ - ALWAYS include the actual values: config keys, function signatures, SQL statements, class names, import paths, env vars, etc.
157
+ - If CONTEXT.md has a comparison table or expected values, copy them into the action verbatim
158
+ - The executor should be able to complete the task from the action text alone, without needing to read CONTEXT.md or reference files (read_first is for verification, not discovery)
159
+
160
+ **Optional — use when the task extends or implements existing code:**
161
+
162
+ 7. **`<interfaces>`** — Relevant class/function/type signatures from existing code that this task must implement, extend, or call. Embed the actual signatures here so the executor does not burn tool calls re-reading files.
163
+ - Extract from `<read_first>` files during planning (planner already reads them)
164
+ - Include only what the executor needs: method signatures, interface definitions, relevant types
165
+ - Do NOT include full file contents — only the contract boundary
166
+ - Example:
167
+ ```typescript
168
+ // src/services/auth.service.ts
169
+ interface AuthService {
170
+ verifyToken(token: string): Promise<User>
171
+ refreshSession(userId: string): Promise<Session>
172
+ }
173
+ ```
174
+
175
+ **Why this matters:** Executor agents work from the plan text. Vague instructions like "update the config to match production" produce shallow one-line changes. Concrete instructions with `<files>`, `<verify>` commands, and embedded `<interfaces>` give the executor everything needed to do complete, correct work without extra tool calls.
176
+ </deep_work_rules>
177
+
178
+ <quality_gate>
179
+ - [ ] SPRINT.md files created in phase directory
180
+ - [ ] Each plan has valid frontmatter including `files_modified:` array aggregating all `<files>` paths across tasks (consumed by execute.md intra-wave overlap checker)
181
+ - [ ] Tasks are specific and actionable
182
+ - [ ] Every task has `<read_first>` with at least the file being modified
183
+ - [ ] Every task has `<files>` listing exact files this task will modify or create
184
+ - [ ] Every task has `<acceptance_criteria>` with grep-verifiable conditions
185
+ - [ ] Every task has `<verify>` with an `<automated>` child containing at least one shell command (Dimension 8 blocker)
186
+ - [ ] Every task has `<done>` with a single observable acceptance sentence (Dimension 2 requirement)
187
+ - [ ] Every `<action>` contains concrete values (no "align X with Y" without specifying what)
188
+ - [ ] Tasks extending existing code have `<interfaces>` with relevant signatures
189
+ - [ ] Dependencies correctly identified
190
+ - [ ] Waves assigned for parallel execution
191
+ - [ ] must_haves derived from phase goal
192
+ </quality_gate>
193
+ ```
194
+
195
+ ```
196
+ Task(
197
+ prompt=filled_prompt,
198
+ subagent_type="rihal-planner",
199
+ model="sonnet",
200
+ model="{planner_model}",
201
+ description="Plan Phase {phase}"
202
+ )
203
+ ```
204
+