@hanzlaa/rcode 2.1.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 (676) hide show
  1. package/AGENTS.md +120 -0
  2. package/CLAUDE.md +120 -0
  3. package/CONTRIBUTING.md +298 -0
  4. package/README.md +436 -0
  5. package/cli/config.js +142 -0
  6. package/cli/context.js +213 -0
  7. package/cli/dashboard.js +38 -0
  8. package/cli/digest.js +66 -0
  9. package/cli/doctor.js +283 -0
  10. package/cli/github-sync.js +1016 -0
  11. package/cli/index.js +113 -0
  12. package/cli/install.js +946 -0
  13. package/cli/lib/config.cjs +334 -0
  14. package/cli/lib/fsutil.cjs +76 -0
  15. package/cli/lib/github.cjs +365 -0
  16. package/cli/lib/manifest.cjs +240 -0
  17. package/cli/lib/memory-bank.cjs +348 -0
  18. package/cli/lib/model-profiles.cjs +169 -0
  19. package/cli/lib/prompts.cjs +355 -0
  20. package/cli/postinstall.js +32 -0
  21. package/cli/set-mode.js +94 -0
  22. package/cli/set-profile.js +80 -0
  23. package/cli/show-model.js +82 -0
  24. package/cli/team.js +35 -0
  25. package/cli/tiers.js +49 -0
  26. package/cli/uninstall.js +600 -0
  27. package/cli/update.js +373 -0
  28. package/package.json +60 -0
  29. package/rihal/agents/rihal-advisor-researcher.md +116 -0
  30. package/rihal/agents/rihal-ahmed.md +66 -0
  31. package/rihal/agents/rihal-architect.md +79 -0
  32. package/rihal/agents/rihal-assumptions-analyzer.md +117 -0
  33. package/rihal/agents/rihal-code-fixer.md +74 -0
  34. package/rihal/agents/rihal-code-reviewer.md +75 -0
  35. package/rihal/agents/rihal-codebase-mapper.md +170 -0
  36. package/rihal/agents/rihal-debugger.md +140 -0
  37. package/rihal/agents/rihal-deviation-analyzer.md +74 -0
  38. package/rihal/agents/rihal-docs-auditor.md +77 -0
  39. package/rihal/agents/rihal-edge-case-hunter.md +75 -0
  40. package/rihal/agents/rihal-executor.md +113 -0
  41. package/rihal/agents/rihal-fatima.md +68 -0
  42. package/rihal/agents/rihal-haitham.md +75 -0
  43. package/rihal/agents/rihal-hanzla.md +59 -0
  44. package/rihal/agents/rihal-hussain-pm.md +82 -0
  45. package/rihal/agents/rihal-integration-checker.md +455 -0
  46. package/rihal/agents/rihal-khalid.md +59 -0
  47. package/rihal/agents/rihal-layla.md +57 -0
  48. package/rihal/agents/rihal-mariam.md +58 -0
  49. package/rihal/agents/rihal-nasser.md +57 -0
  50. package/rihal/agents/rihal-noor.md +60 -0
  51. package/rihal/agents/rihal-nyquist-auditor.md +182 -0
  52. package/rihal/agents/rihal-omar.md +57 -0
  53. package/rihal/agents/rihal-phase-researcher.md +84 -0
  54. package/rihal/agents/rihal-planner.md +176 -0
  55. package/rihal/agents/rihal-profiler.md +74 -0
  56. package/rihal/agents/rihal-project-researcher.md +80 -0
  57. package/rihal/agents/rihal-remediation-planner.md +78 -0
  58. package/rihal/agents/rihal-research-synthesizer.md +253 -0
  59. package/rihal/agents/rihal-roadmapper.md +73 -0
  60. package/rihal/agents/rihal-sadiq.md +72 -0
  61. package/rihal/agents/rihal-security-adversary.md +82 -0
  62. package/rihal/agents/rihal-security-auditor.md +78 -0
  63. package/rihal/agents/rihal-sprint-checker.md +124 -0
  64. package/rihal/agents/rihal-tech-writer.md +80 -0
  65. package/rihal/agents/rihal-ui-auditor.md +81 -0
  66. package/rihal/agents/rihal-ui-designer.md +6 -0
  67. package/rihal/agents/rihal-ux-designer.md +83 -0
  68. package/rihal/agents/rihal-verifier.md +124 -0
  69. package/rihal/agents/rihal-waleed.md +60 -0
  70. package/rihal/agents/rihal-yousef.md +78 -0
  71. package/rihal/agents/rihal-zahra.md +62 -0
  72. package/rihal/agents/rihal-zayd.md +78 -0
  73. package/rihal/agents/rules/codebase-mapper/detailed-guide.md +615 -0
  74. package/rihal/agents/rules/debugger/checkpoint-recovery.md +272 -0
  75. package/rihal/agents/rules/debugger/debug-session-state.md +261 -0
  76. package/rihal/agents/rules/debugger/hypothesis-templates.md +330 -0
  77. package/rihal/agents/rules/debugger/investigation-protocol.md +298 -0
  78. package/rihal/agents/rules/debugger/scientific-method.md +317 -0
  79. package/rihal/agents/rules/executor/authentication-gates.md +202 -0
  80. package/rihal/agents/rules/executor/deviation-rules.md +191 -0
  81. package/rihal/agents/rules/executor/execution-flow.md +116 -0
  82. package/rihal/agents/rules/executor/self-check.md +241 -0
  83. package/rihal/agents/rules/executor/stub-detection.md +267 -0
  84. package/rihal/agents/rules/executor/summary-creation.md +76 -0
  85. package/rihal/agents/rules/executor/task-commit-protocol.md +283 -0
  86. package/rihal/agents/rules/executor/tdd-flow.md +294 -0
  87. package/rihal/agents/rules/phase-researcher/detailed-guide.md +628 -0
  88. package/rihal/agents/rules/planner/common-patterns.md +373 -0
  89. package/rihal/agents/rules/planner/dependency-analysis.md +195 -0
  90. package/rihal/agents/rules/planner/goal-backward-thinking.md +220 -0
  91. package/rihal/agents/rules/planner/sprint-verification.md +202 -0
  92. package/rihal/agents/rules/planner/task-templates.md +296 -0
  93. package/rihal/agents/rules/project-researcher/detailed-guide.md +589 -0
  94. package/rihal/agents/rules/roadmapper/detailed-guide.md +620 -0
  95. package/rihal/agents/rules/sprint-checker/dimensions.md +414 -0
  96. package/rihal/agents/rules/sprint-checker/process.md +377 -0
  97. package/rihal/agents/rules/verifier/anti-patterns.md +94 -0
  98. package/rihal/agents/rules/verifier/artifact-verification.md +69 -0
  99. package/rihal/agents/rules/verifier/behavioral-spot-checks.md +49 -0
  100. package/rihal/agents/rules/verifier/context-loading.md +84 -0
  101. package/rihal/agents/rules/verifier/data-flow-trace.md +65 -0
  102. package/rihal/agents/rules/verifier/gap-output.md +51 -0
  103. package/rihal/agents/rules/verifier/key-links.md +56 -0
  104. package/rihal/agents/rules/verifier/requirements-coverage.md +28 -0
  105. package/rihal/agents/rules/verifier/verification-report.md +131 -0
  106. package/rihal/bin/lib/code-references.cjs +196 -0
  107. package/rihal/bin/lib/config.cjs +146 -0
  108. package/rihal/bin/lib/council-panel.cjs +501 -0
  109. package/rihal/bin/lib/roadmap.cjs +256 -0
  110. package/rihal/bin/lib/verify.cjs +118 -0
  111. package/rihal/bin/rihal-hooks.cjs +204 -0
  112. package/rihal/bin/rihal-tools.cjs +3554 -0
  113. package/rihal/brain/README.md +38 -0
  114. package/rihal/brain/best-practices/no-autonomous-bypass.md +37 -0
  115. package/rihal/brain/best-practices/research-citation-rule.md +39 -0
  116. package/rihal/brain/best-practices/state-sync-rule.md +43 -0
  117. package/rihal/brain/sources.yaml +59 -0
  118. package/rihal/commands/add-phase.md +18 -0
  119. package/rihal/commands/add-tests.md +18 -0
  120. package/rihal/commands/add-todo.md +8 -0
  121. package/rihal/commands/analyze-dependencies.md +11 -0
  122. package/rihal/commands/audit-fix.md +14 -0
  123. package/rihal/commands/audit-milestone.md +12 -0
  124. package/rihal/commands/audit-uat.md +18 -0
  125. package/rihal/commands/autonomous.md +19 -0
  126. package/rihal/commands/brainstorm.md +11 -0
  127. package/rihal/commands/chain.md +8 -0
  128. package/rihal/commands/check-implementation-readiness.md +8 -0
  129. package/rihal/commands/check-todos.md +18 -0
  130. package/rihal/commands/cleanup.md +18 -0
  131. package/rihal/commands/code-review-fix.md +14 -0
  132. package/rihal/commands/code-review.md +14 -0
  133. package/rihal/commands/complete-milestone.md +12 -0
  134. package/rihal/commands/config.md +8 -0
  135. package/rihal/commands/correct-course.md +8 -0
  136. package/rihal/commands/council.md +25 -0
  137. package/rihal/commands/create-epics-and-stories.md +8 -0
  138. package/rihal/commands/create-story.md +8 -0
  139. package/rihal/commands/dashboard.md +10 -0
  140. package/rihal/commands/debug.md +8 -0
  141. package/rihal/commands/decisions.md +10 -0
  142. package/rihal/commands/dev-story.md +8 -0
  143. package/rihal/commands/diff.md +10 -0
  144. package/rihal/commands/discuss-phase-power.md +11 -0
  145. package/rihal/commands/discuss-phase.md +19 -0
  146. package/rihal/commands/discuss.md +23 -0
  147. package/rihal/commands/do.md +22 -0
  148. package/rihal/commands/docs-update.md +14 -0
  149. package/rihal/commands/document-project.md +8 -0
  150. package/rihal/commands/enable-hooks.md +11 -0
  151. package/rihal/commands/execute-sprint.md +13 -0
  152. package/rihal/commands/execute.md +19 -0
  153. package/rihal/commands/explore.md +14 -0
  154. package/rihal/commands/export-to-github.md +11 -0
  155. package/rihal/commands/forensics.md +11 -0
  156. package/rihal/commands/from-template.md +11 -0
  157. package/rihal/commands/health.md +10 -0
  158. package/rihal/commands/help.md +8 -0
  159. package/rihal/commands/import.md +12 -0
  160. package/rihal/commands/inbox.md +12 -0
  161. package/rihal/commands/init.md +14 -0
  162. package/rihal/commands/insert-phase.md +11 -0
  163. package/rihal/commands/install.md +10 -0
  164. package/rihal/commands/karpathy-audit.md +12 -0
  165. package/rihal/commands/list-plans.md +11 -0
  166. package/rihal/commands/list-workspaces.md +10 -0
  167. package/rihal/commands/map-codebase.md +14 -0
  168. package/rihal/commands/milestone-summary.md +11 -0
  169. package/rihal/commands/new-milestone.md +12 -0
  170. package/rihal/commands/new-project-research.md +11 -0
  171. package/rihal/commands/new-project-roadmap.md +11 -0
  172. package/rihal/commands/new-project.md +13 -0
  173. package/rihal/commands/new-workspace.md +12 -0
  174. package/rihal/commands/next.md +19 -0
  175. package/rihal/commands/note.md +12 -0
  176. package/rihal/commands/notify-test.md +10 -0
  177. package/rihal/commands/pause-work.md +8 -0
  178. package/rihal/commands/plan-milestone-gaps.md +18 -0
  179. package/rihal/commands/plan.md +19 -0
  180. package/rihal/commands/plant-seed.md +18 -0
  181. package/rihal/commands/pr-branch.md +18 -0
  182. package/rihal/commands/profile-user.md +8 -0
  183. package/rihal/commands/progress.md +19 -0
  184. package/rihal/commands/quick.md +14 -0
  185. package/rihal/commands/remove-phase.md +18 -0
  186. package/rihal/commands/remove-workspace.md +11 -0
  187. package/rihal/commands/replay.md +11 -0
  188. package/rihal/commands/report.md +10 -0
  189. package/rihal/commands/rerun.md +11 -0
  190. package/rihal/commands/research-phase.md +18 -0
  191. package/rihal/commands/resume-work.md +8 -0
  192. package/rihal/commands/review-adversarial.md +8 -0
  193. package/rihal/commands/review-edge-case-hunter.md +8 -0
  194. package/rihal/commands/review.md +18 -0
  195. package/rihal/commands/scan.md +14 -0
  196. package/rihal/commands/secure-phase.md +14 -0
  197. package/rihal/commands/session-report.md +10 -0
  198. package/rihal/commands/settings.md +8 -0
  199. package/rihal/commands/ship.md +18 -0
  200. package/rihal/commands/show.md +10 -0
  201. package/rihal/commands/sprint-planning.md +20 -0
  202. package/rihal/commands/sprint-status.md +21 -0
  203. package/rihal/commands/stats.md +10 -0
  204. package/rihal/commands/status.md +21 -0
  205. package/rihal/commands/ui-phase.md +8 -0
  206. package/rihal/commands/ui-review.md +8 -0
  207. package/rihal/commands/undo.md +14 -0
  208. package/rihal/commands/update.md +11 -0
  209. package/rihal/commands/validate-phase.md +18 -0
  210. package/rihal/commands/verify-phase.md +18 -0
  211. package/rihal/commands/verify-work.md +19 -0
  212. package/rihal/commands/why.md +10 -0
  213. package/rihal/commands/workstream.md +11 -0
  214. package/rihal/config/model-profiles.json +226 -0
  215. package/rihal/config/model-profiles.schema.json +36 -0
  216. package/rihal/config.yaml +39 -0
  217. package/rihal/digests/README.md +50 -0
  218. package/rihal/digests/fatima.md +24 -0
  219. package/rihal/digests/hussain-pm.md +24 -0
  220. package/rihal/digests/mariam.md +24 -0
  221. package/rihal/digests/sadiq.md +24 -0
  222. package/rihal/digests/waleed.md +24 -0
  223. package/rihal/modules/core.yaml +101 -0
  224. package/rihal/modules/discovery.yaml +50 -0
  225. package/rihal/modules/execution.yaml +66 -0
  226. package/rihal/references/brain-methods.csv +9 -0
  227. package/rihal/references/checklist-architect.md +146 -0
  228. package/rihal/references/checklist-change.md +136 -0
  229. package/rihal/references/checklist-pm.md +154 -0
  230. package/rihal/references/checklist-po-master.md +100 -0
  231. package/rihal/references/checklist-story-dod.md +75 -0
  232. package/rihal/references/checklist-story-draft.md +53 -0
  233. package/rihal/references/checkpoints-index.md +53 -0
  234. package/rihal/references/checkpoints.md +778 -0
  235. package/rihal/references/codebase-grounding.md +76 -0
  236. package/rihal/references/command-redirect-format.md +62 -0
  237. package/rihal/references/commit-conventions.md +125 -0
  238. package/rihal/references/common-bug-patterns-index.md +44 -0
  239. package/rihal/references/common-bug-patterns.md +621 -0
  240. package/rihal/references/context-budget.md +104 -0
  241. package/rihal/references/continuation-format.md +249 -0
  242. package/rihal/references/council-protocol.md +91 -0
  243. package/rihal/references/domain-probes.md +213 -0
  244. package/rihal/references/elicitation-methods.csv +16 -0
  245. package/rihal/references/execution-protocol.md +155 -0
  246. package/rihal/references/gate-prompts.md +212 -0
  247. package/rihal/references/gates.md +127 -0
  248. package/rihal/references/git-integration.md +159 -0
  249. package/rihal/references/git-planning-commit.md +185 -0
  250. package/rihal/references/karpathy-guidelines.md +79 -0
  251. package/rihal/references/model-profiles.md +90 -0
  252. package/rihal/references/no-unauthorized-git-ops.md +73 -0
  253. package/rihal/references/output-format.md +319 -0
  254. package/rihal/references/output-realism.md +52 -0
  255. package/rihal/references/project-types.yaml +270 -0
  256. package/rihal/references/questioning.md +163 -0
  257. package/rihal/references/response-style.md +81 -0
  258. package/rihal/references/state-schema.md +366 -0
  259. package/rihal/references/tdd.md +263 -0
  260. package/rihal/references/thinking-models-debug.md +126 -0
  261. package/rihal/references/thinking-models-planning.md +127 -0
  262. package/rihal/references/ui-brand.md +254 -0
  263. package/rihal/references/verification-patterns-index.md +76 -0
  264. package/rihal/references/verification-patterns.md +612 -0
  265. package/rihal/references/workstream-flag.md +166 -0
  266. package/rihal/skills/SKILLS_INDEX.md +114 -0
  267. package/rihal/skills/_shared/no-autonomous-bypass.md +37 -0
  268. package/rihal/skills/_shared/research-citation-rule.md +39 -0
  269. package/rihal/skills/_shared/state-sync-rule.md +43 -0
  270. package/rihal/skills/actions/1-analysis/research/rihal-domain-research/SKILL.md +31 -0
  271. package/rihal/skills/actions/1-analysis/research/rihal-domain-research/domain-steps/step-01-init.md +137 -0
  272. package/rihal/skills/actions/1-analysis/research/rihal-domain-research/domain-steps/step-02-domain-analysis.md +229 -0
  273. package/rihal/skills/actions/1-analysis/research/rihal-domain-research/domain-steps/step-03-competitive-landscape.md +238 -0
  274. package/rihal/skills/actions/1-analysis/research/rihal-domain-research/domain-steps/step-04-regulatory-focus.md +206 -0
  275. package/rihal/skills/actions/1-analysis/research/rihal-domain-research/domain-steps/step-05-technical-trends.md +234 -0
  276. package/rihal/skills/actions/1-analysis/research/rihal-domain-research/domain-steps/step-06-research-synthesis.md +444 -0
  277. package/rihal/skills/actions/1-analysis/research/rihal-domain-research/research.template.md +29 -0
  278. package/rihal/skills/actions/1-analysis/research/rihal-domain-research/workflow.md +49 -0
  279. package/rihal/skills/actions/1-analysis/research/rihal-market-research/SKILL.md +30 -0
  280. package/rihal/skills/actions/1-analysis/research/rihal-market-research/research.template.md +29 -0
  281. package/rihal/skills/actions/1-analysis/research/rihal-market-research/steps/step-01-init.md +184 -0
  282. package/rihal/skills/actions/1-analysis/research/rihal-market-research/steps/step-02-customer-behavior.md +239 -0
  283. package/rihal/skills/actions/1-analysis/research/rihal-market-research/steps/step-03-customer-pain-points.md +251 -0
  284. package/rihal/skills/actions/1-analysis/research/rihal-market-research/steps/step-04-customer-decisions.md +261 -0
  285. package/rihal/skills/actions/1-analysis/research/rihal-market-research/steps/step-05-competitive-analysis.md +173 -0
  286. package/rihal/skills/actions/1-analysis/research/rihal-market-research/steps/step-06-research-completion.md +478 -0
  287. package/rihal/skills/actions/1-analysis/research/rihal-market-research/workflow.md +49 -0
  288. package/rihal/skills/actions/1-analysis/research/rihal-technical-research/SKILL.md +31 -0
  289. package/rihal/skills/actions/1-analysis/research/rihal-technical-research/research.template.md +29 -0
  290. package/rihal/skills/actions/1-analysis/research/rihal-technical-research/technical-steps/step-01-init.md +137 -0
  291. package/rihal/skills/actions/1-analysis/research/rihal-technical-research/technical-steps/step-02-technical-overview.md +239 -0
  292. package/rihal/skills/actions/1-analysis/research/rihal-technical-research/technical-steps/step-03-integration-patterns.md +248 -0
  293. package/rihal/skills/actions/1-analysis/research/rihal-technical-research/technical-steps/step-04-architectural-patterns.md +202 -0
  294. package/rihal/skills/actions/1-analysis/research/rihal-technical-research/technical-steps/step-05-implementation-research.md +233 -0
  295. package/rihal/skills/actions/1-analysis/research/rihal-technical-research/technical-steps/step-06-research-synthesis.md +487 -0
  296. package/rihal/skills/actions/1-analysis/research/rihal-technical-research/workflow.md +50 -0
  297. package/rihal/skills/actions/1-analysis/rihal-document-project/SKILL.md +30 -0
  298. package/rihal/skills/actions/1-analysis/rihal-document-project/checklist.md +245 -0
  299. package/rihal/skills/actions/1-analysis/rihal-document-project/documentation-requirements.csv +12 -0
  300. package/rihal/skills/actions/1-analysis/rihal-document-project/instructions.md +128 -0
  301. package/rihal/skills/actions/1-analysis/rihal-document-project/templates/deep-dive-template.md +345 -0
  302. package/rihal/skills/actions/1-analysis/rihal-document-project/templates/index-template.md +169 -0
  303. package/rihal/skills/actions/1-analysis/rihal-document-project/templates/project-overview-template.md +103 -0
  304. package/rihal/skills/actions/1-analysis/rihal-document-project/templates/project-scan-report-schema.json +160 -0
  305. package/rihal/skills/actions/1-analysis/rihal-document-project/templates/source-tree-template.md +135 -0
  306. package/rihal/skills/actions/1-analysis/rihal-document-project/workflow.md +27 -0
  307. package/rihal/skills/actions/1-analysis/rihal-document-project/workflows/deep-dive-instructions.md +299 -0
  308. package/rihal/skills/actions/1-analysis/rihal-document-project/workflows/deep-dive-workflow.md +34 -0
  309. package/rihal/skills/actions/1-analysis/rihal-document-project/workflows/full-scan-instructions.md +1107 -0
  310. package/rihal/skills/actions/1-analysis/rihal-document-project/workflows/full-scan-workflow.md +34 -0
  311. package/rihal/skills/actions/1-analysis/rihal-prfaq/SKILL.md +120 -0
  312. package/rihal/skills/actions/1-analysis/rihal-prfaq/agents/artifact-analyzer.md +60 -0
  313. package/rihal/skills/actions/1-analysis/rihal-prfaq/agents/web-researcher.md +49 -0
  314. package/rihal/skills/actions/1-analysis/rihal-prfaq/assets/prfaq-template.md +62 -0
  315. package/rihal/skills/actions/1-analysis/rihal-prfaq/references/customer-faq.md +55 -0
  316. package/rihal/skills/actions/1-analysis/rihal-prfaq/references/internal-faq.md +51 -0
  317. package/rihal/skills/actions/1-analysis/rihal-prfaq/references/press-release.md +60 -0
  318. package/rihal/skills/actions/1-analysis/rihal-prfaq/references/verdict.md +79 -0
  319. package/rihal/skills/actions/1-analysis/rihal-prfaq/rihal-manifest.json +16 -0
  320. package/rihal/skills/actions/1-analysis/rihal-product-brief/SKILL.md +112 -0
  321. package/rihal/skills/actions/1-analysis/rihal-product-brief/agents/artifact-analyzer.md +60 -0
  322. package/rihal/skills/actions/1-analysis/rihal-product-brief/agents/opportunity-reviewer.md +44 -0
  323. package/rihal/skills/actions/1-analysis/rihal-product-brief/agents/skeptic-reviewer.md +44 -0
  324. package/rihal/skills/actions/1-analysis/rihal-product-brief/agents/web-researcher.md +49 -0
  325. package/rihal/skills/actions/1-analysis/rihal-product-brief/prompts/contextual-discovery.md +57 -0
  326. package/rihal/skills/actions/1-analysis/rihal-product-brief/prompts/draft-and-review.md +86 -0
  327. package/rihal/skills/actions/1-analysis/rihal-product-brief/prompts/finalize.md +75 -0
  328. package/rihal/skills/actions/1-analysis/rihal-product-brief/prompts/guided-elicitation.md +70 -0
  329. package/rihal/skills/actions/1-analysis/rihal-product-brief/resources/brief-template.md +60 -0
  330. package/rihal/skills/actions/1-analysis/rihal-product-brief/rihal-manifest.json +17 -0
  331. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/SKILL.md +30 -0
  332. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/steps/step-01-validate-prerequisites.md +255 -0
  333. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/steps/step-02-design-epics.md +212 -0
  334. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/steps/step-03-create-stories.md +255 -0
  335. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/steps/step-04-final-validation.md +131 -0
  336. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/templates/epics-template.md +61 -0
  337. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/workflow.md +54 -0
  338. package/rihal/skills/actions/2-plan/rihal-create-milestone/SKILL.md +39 -0
  339. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/README.md +30 -0
  340. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-01-init.md +62 -0
  341. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-02-outcomes.md +64 -0
  342. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-03-sequencing.md +65 -0
  343. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-04-windows.md +60 -0
  344. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-05-kill-criteria.md +59 -0
  345. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-06-phase-stubs.md +56 -0
  346. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-07-backlog.md +44 -0
  347. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-08-write-roadmap.md +58 -0
  348. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-09-state-sync.md +62 -0
  349. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-10-complete.md +56 -0
  350. package/rihal/skills/actions/2-plan/rihal-create-milestone/workflow.md +93 -0
  351. package/rihal/skills/actions/2-plan/rihal-create-prd/SKILL.md +40 -0
  352. package/rihal/skills/actions/2-plan/rihal-create-prd/data/domain-complexity.csv +15 -0
  353. package/rihal/skills/actions/2-plan/rihal-create-prd/data/prd-purpose.md +197 -0
  354. package/rihal/skills/actions/2-plan/rihal-create-prd/data/project-types.csv +11 -0
  355. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-01-init.md +178 -0
  356. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-01b-continue.md +161 -0
  357. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-02-discovery.md +208 -0
  358. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-02b-vision.md +142 -0
  359. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-02c-executive-summary.md +158 -0
  360. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-03-success.md +214 -0
  361. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-04-journeys.md +201 -0
  362. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-05-domain.md +194 -0
  363. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-06-innovation.md +211 -0
  364. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-07-project-type.md +222 -0
  365. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-08-scoping.md +216 -0
  366. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-09-functional.md +219 -0
  367. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-10-nonfunctional.md +230 -0
  368. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-11-polish.md +221 -0
  369. package/rihal/skills/actions/2-plan/rihal-create-prd/steps-c/step-12-complete.md +115 -0
  370. package/rihal/skills/actions/2-plan/rihal-create-prd/templates/prd-template.md +10 -0
  371. package/rihal/skills/actions/2-plan/rihal-create-prd/workflow.md +64 -0
  372. package/rihal/skills/actions/2-plan/rihal-create-story/SKILL.md +31 -0
  373. package/rihal/skills/actions/2-plan/rihal-create-story/checklist.md +357 -0
  374. package/rihal/skills/actions/2-plan/rihal-create-story/discover-inputs.md +88 -0
  375. package/rihal/skills/actions/2-plan/rihal-create-story/template.md +49 -0
  376. package/rihal/skills/actions/2-plan/rihal-create-story/workflow.md +380 -0
  377. package/rihal/skills/actions/2-plan/rihal-create-ux-design/SKILL.md +31 -0
  378. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-01-init.md +135 -0
  379. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-01b-continue.md +127 -0
  380. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-02-discovery.md +190 -0
  381. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-03-core-experience.md +217 -0
  382. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-04-emotional-response.md +220 -0
  383. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-05-inspiration.md +235 -0
  384. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-06-design-system.md +253 -0
  385. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-07-defining-experience.md +255 -0
  386. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-08-visual-foundation.md +225 -0
  387. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-09-design-directions.md +225 -0
  388. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-10-user-journeys.md +242 -0
  389. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-11-component-strategy.md +249 -0
  390. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-12-ux-patterns.md +238 -0
  391. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-13-responsive-accessibility.md +265 -0
  392. package/rihal/skills/actions/2-plan/rihal-create-ux-design/steps/step-14-complete.md +171 -0
  393. package/rihal/skills/actions/2-plan/rihal-create-ux-design/ux-design-template.md +13 -0
  394. package/rihal/skills/actions/2-plan/rihal-create-ux-design/workflow.md +36 -0
  395. package/rihal/skills/actions/2-plan/rihal-edit-prd/SKILL.md +30 -0
  396. package/rihal/skills/actions/2-plan/rihal-edit-prd/steps-e/step-e-01-discovery.md +242 -0
  397. package/rihal/skills/actions/2-plan/rihal-edit-prd/steps-e/step-e-01b-legacy-conversion.md +204 -0
  398. package/rihal/skills/actions/2-plan/rihal-edit-prd/steps-e/step-e-02-review.md +245 -0
  399. package/rihal/skills/actions/2-plan/rihal-edit-prd/steps-e/step-e-03-edit.md +250 -0
  400. package/rihal/skills/actions/2-plan/rihal-edit-prd/steps-e/step-e-04-complete.md +165 -0
  401. package/rihal/skills/actions/2-plan/rihal-edit-prd/workflow.md +63 -0
  402. package/rihal/skills/actions/2-plan/rihal-frontend-design/SKILL.md +169 -0
  403. package/rihal/skills/actions/2-plan/rihal-validate-prd/SKILL.md +29 -0
  404. package/rihal/skills/actions/2-plan/rihal-validate-prd/data/domain-complexity.csv +15 -0
  405. package/rihal/skills/actions/2-plan/rihal-validate-prd/data/prd-purpose.md +197 -0
  406. package/rihal/skills/actions/2-plan/rihal-validate-prd/data/project-types.csv +11 -0
  407. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-01-discovery.md +221 -0
  408. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-02-format-detection.md +188 -0
  409. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-02b-parity-check.md +206 -0
  410. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-03-density-validation.md +171 -0
  411. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-04-brief-coverage-validation.md +211 -0
  412. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-05-measurability-validation.md +225 -0
  413. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-06-traceability-validation.md +214 -0
  414. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-07-implementation-leakage-validation.md +202 -0
  415. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-08-domain-compliance-validation.md +240 -0
  416. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-09-project-type-validation.md +260 -0
  417. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-10-smart-validation.md +206 -0
  418. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-11-holistic-quality-validation.md +261 -0
  419. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-12-completeness-validation.md +239 -0
  420. package/rihal/skills/actions/2-plan/rihal-validate-prd/steps-v/step-v-13-report-complete.md +229 -0
  421. package/rihal/skills/actions/2-plan/rihal-validate-prd/workflow.md +62 -0
  422. package/rihal/skills/actions/3-solutioning/rihal-check-implementation-readiness/SKILL.md +30 -0
  423. package/rihal/skills/actions/3-solutioning/rihal-check-implementation-readiness/steps/step-01-document-discovery.md +179 -0
  424. package/rihal/skills/actions/3-solutioning/rihal-check-implementation-readiness/steps/step-02-prd-analysis.md +168 -0
  425. package/rihal/skills/actions/3-solutioning/rihal-check-implementation-readiness/steps/step-03-epic-coverage-validation.md +169 -0
  426. package/rihal/skills/actions/3-solutioning/rihal-check-implementation-readiness/steps/step-04-ux-alignment.md +129 -0
  427. package/rihal/skills/actions/3-solutioning/rihal-check-implementation-readiness/steps/step-05-epic-quality-review.md +241 -0
  428. package/rihal/skills/actions/3-solutioning/rihal-check-implementation-readiness/steps/step-06-final-assessment.md +126 -0
  429. package/rihal/skills/actions/3-solutioning/rihal-check-implementation-readiness/templates/readiness-report-template.md +4 -0
  430. package/rihal/skills/actions/3-solutioning/rihal-check-implementation-readiness/workflow.md +49 -0
  431. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/SKILL.md +32 -0
  432. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/architecture-decision-template.md +12 -0
  433. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/data/domain-complexity.csv +13 -0
  434. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/data/project-types.csv +7 -0
  435. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/steps/step-01-init.md +153 -0
  436. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/steps/step-01b-continue.md +173 -0
  437. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/steps/step-02-context.md +224 -0
  438. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/steps/step-03-starter.md +329 -0
  439. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/steps/step-04-decisions.md +318 -0
  440. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/steps/step-05-patterns.md +359 -0
  441. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/steps/step-06-structure.md +379 -0
  442. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/steps/step-07-validation.md +359 -0
  443. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/steps/step-08-complete.md +76 -0
  444. package/rihal/skills/actions/3-solutioning/rihal-create-architecture/workflow.md +38 -0
  445. package/rihal/skills/actions/3-solutioning/rihal-generate-project-context/SKILL.md +31 -0
  446. package/rihal/skills/actions/3-solutioning/rihal-generate-project-context/project-context-template.md +21 -0
  447. package/rihal/skills/actions/3-solutioning/rihal-generate-project-context/steps/step-01-discover.md +186 -0
  448. package/rihal/skills/actions/3-solutioning/rihal-generate-project-context/steps/step-02-generate.md +321 -0
  449. package/rihal/skills/actions/3-solutioning/rihal-generate-project-context/steps/step-03-complete.md +278 -0
  450. package/rihal/skills/actions/3-solutioning/rihal-generate-project-context/workflow.md +43 -0
  451. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/SKILL.md +48 -0
  452. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/generate-trail.md +38 -0
  453. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/step-01-orientation.md +105 -0
  454. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/step-02-walkthrough.md +89 -0
  455. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/step-03-detail-pass.md +106 -0
  456. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/step-04-testing.md +74 -0
  457. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/step-05-wrapup.md +24 -0
  458. package/rihal/skills/actions/4-implementation/rihal-code-review/SKILL.md +31 -0
  459. package/rihal/skills/actions/4-implementation/rihal-code-review/steps/step-01-gather-context.md +62 -0
  460. package/rihal/skills/actions/4-implementation/rihal-code-review/steps/step-02-review.md +34 -0
  461. package/rihal/skills/actions/4-implementation/rihal-code-review/steps/step-03-triage.md +49 -0
  462. package/rihal/skills/actions/4-implementation/rihal-code-review/steps/step-04-present.md +129 -0
  463. package/rihal/skills/actions/4-implementation/rihal-code-review/workflow.md +55 -0
  464. package/rihal/skills/actions/4-implementation/rihal-correct-course/SKILL.md +29 -0
  465. package/rihal/skills/actions/4-implementation/rihal-correct-course/checklist.md +288 -0
  466. package/rihal/skills/actions/4-implementation/rihal-correct-course/workflow.md +267 -0
  467. package/rihal/skills/actions/4-implementation/rihal-dev-story/SKILL.md +36 -0
  468. package/rihal/skills/actions/4-implementation/rihal-dev-story/checklist.md +80 -0
  469. package/rihal/skills/actions/4-implementation/rihal-dev-story/workflow.md +450 -0
  470. package/rihal/skills/actions/4-implementation/rihal-qa-generate-e2e-tests/SKILL.md +31 -0
  471. package/rihal/skills/actions/4-implementation/rihal-qa-generate-e2e-tests/checklist.md +33 -0
  472. package/rihal/skills/actions/4-implementation/rihal-qa-generate-e2e-tests/workflow.md +136 -0
  473. package/rihal/skills/actions/4-implementation/rihal-retrospective/SKILL.md +30 -0
  474. package/rihal/skills/actions/4-implementation/rihal-retrospective/workflow.md +1479 -0
  475. package/rihal/skills/actions/4-implementation/rihal-scaffold-project/SKILL.md +77 -0
  476. package/rihal/skills/actions/4-implementation/rihal-scaffold-project/steps/step-01-target.md +17 -0
  477. package/rihal/skills/actions/4-implementation/rihal-scaffold-project/steps/step-02-safety.md +35 -0
  478. package/rihal/skills/actions/4-implementation/rihal-scaffold-project/steps/step-03-clone.md +50 -0
  479. package/rihal/skills/actions/4-implementation/rihal-scaffold-project/steps/step-04-post-setup.md +44 -0
  480. package/rihal/skills/actions/4-implementation/rihal-sprint-planning/SKILL.md +35 -0
  481. package/rihal/skills/actions/4-implementation/rihal-sprint-planning/checklist.md +43 -0
  482. package/rihal/skills/actions/4-implementation/rihal-sprint-planning/sprint-status-template.yaml +56 -0
  483. package/rihal/skills/actions/4-implementation/rihal-sprint-planning/workflow.md +284 -0
  484. package/rihal/skills/actions/4-implementation/rihal-sprint-status/SKILL.md +30 -0
  485. package/rihal/skills/actions/4-implementation/rihal-sprint-status/workflow.md +261 -0
  486. package/rihal/skills/agents/ahmed-hassani-director/SKILL.md +121 -0
  487. package/rihal/skills/agents/fatima-qa/SKILL.md +106 -0
  488. package/rihal/skills/agents/fatima-qa/skill-manifest.yaml +11 -0
  489. package/rihal/skills/agents/haitham-frontend/SKILL.md +120 -0
  490. package/rihal/skills/agents/hanzla-engineer/SKILL.md +109 -0
  491. package/rihal/skills/agents/hanzla-engineer/skill-manifest.yaml +11 -0
  492. package/rihal/skills/agents/hussain-pm/SKILL.md +107 -0
  493. package/rihal/skills/agents/hussain-pm/skill-manifest.yaml +11 -0
  494. package/rihal/skills/agents/hussain-sm/SKILL.md +104 -0
  495. package/rihal/skills/agents/hussain-sm/skill-manifest.yaml +11 -0
  496. package/rihal/skills/agents/layla-designer/SKILL.md +96 -0
  497. package/rihal/skills/agents/layla-designer/skill-manifest.yaml +11 -0
  498. package/rihal/skills/agents/majlis-council/SKILL.md +179 -0
  499. package/rihal/skills/agents/mariam-marketing/SKILL.md +133 -0
  500. package/rihal/skills/agents/nasser-eng-manager/SKILL.md +125 -0
  501. package/rihal/skills/agents/noor-writer/SKILL.md +104 -0
  502. package/rihal/skills/agents/noor-writer/explain-concept.md +20 -0
  503. package/rihal/skills/agents/noor-writer/mermaid-gen.md +20 -0
  504. package/rihal/skills/agents/noor-writer/skill-manifest.yaml +11 -0
  505. package/rihal/skills/agents/noor-writer/validate-doc.md +19 -0
  506. package/rihal/skills/agents/noor-writer/write-document.md +20 -0
  507. package/rihal/skills/agents/raees-orchestrator/SKILL.md +154 -0
  508. package/rihal/skills/agents/sadiq-analyst/SKILL.md +106 -0
  509. package/rihal/skills/agents/sadiq-analyst/skill-manifest.yaml +11 -0
  510. package/rihal/skills/agents/waleed-architect/SKILL.md +106 -0
  511. package/rihal/skills/agents/waleed-architect/skill-manifest.yaml +11 -0
  512. package/rihal/skills/agents/yousef-backend/SKILL.md +136 -0
  513. package/rihal/skills/agents/zahra-branding/SKILL.md +141 -0
  514. package/rihal/skills/agents/zayd-ml/SKILL.md +124 -0
  515. package/rihal/skills/core/module-help.csv +11 -0
  516. package/rihal/skills/core/module.yaml +25 -0
  517. package/rihal/skills/core/rihal-advanced-elicitation/SKILL.md +155 -0
  518. package/rihal/skills/core/rihal-advanced-elicitation/methods.csv +51 -0
  519. package/rihal/skills/core/rihal-advanced-elicitation/rihal-advanced-elicitation/SKILL.md +148 -0
  520. package/rihal/skills/core/rihal-advanced-elicitation/rihal-advanced-elicitation/methods.csv +51 -0
  521. package/rihal/skills/core/rihal-brainstorming/SKILL.md +82 -0
  522. package/rihal/skills/core/rihal-brainstorming/brain-methods.csv +62 -0
  523. package/rihal/skills/core/rihal-brainstorming/steps/step-01-session-setup.md +214 -0
  524. package/rihal/skills/core/rihal-brainstorming/steps/step-01b-continue.md +124 -0
  525. package/rihal/skills/core/rihal-brainstorming/steps/step-02a-user-selected.md +229 -0
  526. package/rihal/skills/core/rihal-brainstorming/steps/step-02b-ai-recommended.md +239 -0
  527. package/rihal/skills/core/rihal-brainstorming/steps/step-02c-random-selection.md +211 -0
  528. package/rihal/skills/core/rihal-brainstorming/steps/step-02d-progressive-flow.md +266 -0
  529. package/rihal/skills/core/rihal-brainstorming/steps/step-03-technique-execution.md +401 -0
  530. package/rihal/skills/core/rihal-brainstorming/steps/step-04-idea-organization.md +305 -0
  531. package/rihal/skills/core/rihal-brainstorming/template.md +15 -0
  532. package/rihal/skills/core/rihal-brainstorming/workflow.md +53 -0
  533. package/rihal/skills/core/rihal-clone-website/SKILL.md +395 -0
  534. package/rihal/skills/core/rihal-distillator/SKILL.md +205 -0
  535. package/rihal/skills/core/rihal-distillator/agents/distillate-compressor.md +116 -0
  536. package/rihal/skills/core/rihal-distillator/agents/round-trip-reconstructor.md +68 -0
  537. package/rihal/skills/core/rihal-distillator/resources/compression-rules.md +51 -0
  538. package/rihal/skills/core/rihal-distillator/resources/distillate-format-reference.md +227 -0
  539. package/rihal/skills/core/rihal-distillator/resources/splitting-strategy.md +78 -0
  540. package/rihal/skills/core/rihal-distillator/scripts/analyze_sources.py +300 -0
  541. package/rihal/skills/core/rihal-distillator/scripts/tests/test_analyze_sources.py +204 -0
  542. package/rihal/skills/core/rihal-editorial-review-prose/SKILL.md +108 -0
  543. package/rihal/skills/core/rihal-editorial-review-structure/SKILL.md +193 -0
  544. package/rihal/skills/core/rihal-help/SKILL.md +91 -0
  545. package/rihal/skills/core/rihal-index-docs/SKILL.md +80 -0
  546. package/rihal/skills/core/rihal-init/SKILL.md +119 -0
  547. package/rihal/skills/core/rihal-init/resources/core-module.yaml +25 -0
  548. package/rihal/skills/core/rihal-init/scripts/rihal_init.py +593 -0
  549. package/rihal/skills/core/rihal-init/scripts/tests/test_rihal_init.py +329 -0
  550. package/rihal/skills/core/rihal-party-mode/SKILL.md +77 -0
  551. package/rihal/skills/core/rihal-party-mode/steps/step-01-agent-loading.md +138 -0
  552. package/rihal/skills/core/rihal-party-mode/steps/step-02-discussion-orchestration.md +187 -0
  553. package/rihal/skills/core/rihal-party-mode/steps/step-03-graceful-exit.md +167 -0
  554. package/rihal/skills/core/rihal-party-mode/workflow.md +190 -0
  555. package/rihal/skills/core/rihal-review-adversarial-general/SKILL.md +55 -0
  556. package/rihal/skills/core/rihal-review-edge-case-hunter/SKILL.md +81 -0
  557. package/rihal/skills/core/rihal-shard-doc/SKILL.md +119 -0
  558. package/rihal/skills/core/rihal-shard-doc/rihal-shard-doc/SKILL.md +122 -0
  559. package/rihal/team.yaml +343 -0
  560. package/rihal/templates/UI-SPEC.md +127 -0
  561. package/rihal/templates/documentation-requirements.csv +11 -0
  562. package/rihal/templates/github/bug-template.md +53 -0
  563. package/rihal/templates/github/epic-template.md +57 -0
  564. package/rihal/templates/github/feature-template.md +55 -0
  565. package/rihal/templates/github/task-template.md +52 -0
  566. package/rihal/templates/milestone.md +147 -0
  567. package/rihal/templates/projects/api-backend/PROJECT.md +37 -0
  568. package/rihal/templates/projects/api-backend/REQUIREMENTS.md +38 -0
  569. package/rihal/templates/projects/api-backend/ROADMAP.md +92 -0
  570. package/rihal/templates/projects/api-backend/template.yaml +17 -0
  571. package/rihal/templates/projects/mobile-app/PROJECT.md +37 -0
  572. package/rihal/templates/projects/mobile-app/REQUIREMENTS.md +32 -0
  573. package/rihal/templates/projects/mobile-app/ROADMAP.md +93 -0
  574. package/rihal/templates/projects/mobile-app/template.yaml +17 -0
  575. package/rihal/templates/projects/saas-b2b/PROJECT.md +40 -0
  576. package/rihal/templates/projects/saas-b2b/REQUIREMENTS.md +38 -0
  577. package/rihal/templates/projects/saas-b2b/ROADMAP.md +95 -0
  578. package/rihal/templates/projects/saas-b2b/template.yaml +18 -0
  579. package/rihal/templates/settings-hooks.json +36 -0
  580. package/rihal/templates/sprint.md +70 -0
  581. package/rihal/workflows/add-phase.md +112 -0
  582. package/rihal/workflows/add-tests.md +351 -0
  583. package/rihal/workflows/add-todo.md +181 -0
  584. package/rihal/workflows/analyze-dependencies.md +138 -0
  585. package/rihal/workflows/audit-fix.md +190 -0
  586. package/rihal/workflows/audit-milestone.md +155 -0
  587. package/rihal/workflows/audit-uat.md +109 -0
  588. package/rihal/workflows/autonomous.md +992 -0
  589. package/rihal/workflows/brainstorm.md +203 -0
  590. package/rihal/workflows/chain.md +188 -0
  591. package/rihal/workflows/check-implementation-readiness.md +193 -0
  592. package/rihal/workflows/check-todos.md +177 -0
  593. package/rihal/workflows/cleanup.md +152 -0
  594. package/rihal/workflows/code-review-fix.md +529 -0
  595. package/rihal/workflows/code-review.md +566 -0
  596. package/rihal/workflows/complete-milestone.md +836 -0
  597. package/rihal/workflows/config.md +105 -0
  598. package/rihal/workflows/correct-course.md +190 -0
  599. package/rihal/workflows/council.md +565 -0
  600. package/rihal/workflows/create-epics-and-stories.md +373 -0
  601. package/rihal/workflows/create-story.md +297 -0
  602. package/rihal/workflows/dashboard.md +102 -0
  603. package/rihal/workflows/debug.md +256 -0
  604. package/rihal/workflows/decisions.md +107 -0
  605. package/rihal/workflows/dev-story.md +432 -0
  606. package/rihal/workflows/diff.md +74 -0
  607. package/rihal/workflows/discuss-phase-power.md +325 -0
  608. package/rihal/workflows/discuss-phase.md +1201 -0
  609. package/rihal/workflows/discuss.md +227 -0
  610. package/rihal/workflows/do.md +175 -0
  611. package/rihal/workflows/docs-update.md +261 -0
  612. package/rihal/workflows/document-project.md +180 -0
  613. package/rihal/workflows/enable-hooks.md +102 -0
  614. package/rihal/workflows/execute-sprint.md +514 -0
  615. package/rihal/workflows/execute.md +1478 -0
  616. package/rihal/workflows/explore.md +171 -0
  617. package/rihal/workflows/export-to-github.md +174 -0
  618. package/rihal/workflows/forensics.md +201 -0
  619. package/rihal/workflows/from-template.md +173 -0
  620. package/rihal/workflows/health.md +194 -0
  621. package/rihal/workflows/help.md +318 -0
  622. package/rihal/workflows/import.md +306 -0
  623. package/rihal/workflows/inbox.md +418 -0
  624. package/rihal/workflows/init.md +245 -0
  625. package/rihal/workflows/insert-phase.md +116 -0
  626. package/rihal/workflows/install.md +85 -0
  627. package/rihal/workflows/karpathy-audit.md +409 -0
  628. package/rihal/workflows/list-plans.md +146 -0
  629. package/rihal/workflows/list-workspaces.md +115 -0
  630. package/rihal/workflows/map-codebase.md +449 -0
  631. package/rihal/workflows/milestone-summary.md +206 -0
  632. package/rihal/workflows/new-milestone.md +616 -0
  633. package/rihal/workflows/new-project-research.md +262 -0
  634. package/rihal/workflows/new-project-roadmap.md +446 -0
  635. package/rihal/workflows/new-project.md +1503 -0
  636. package/rihal/workflows/new-workspace.md +167 -0
  637. package/rihal/workflows/next.md +162 -0
  638. package/rihal/workflows/note.md +156 -0
  639. package/rihal/workflows/notify-test.md +113 -0
  640. package/rihal/workflows/pause-work.md +243 -0
  641. package/rihal/workflows/plan-milestone-gaps.md +273 -0
  642. package/rihal/workflows/plan.md +1262 -0
  643. package/rihal/workflows/plant-seed.md +169 -0
  644. package/rihal/workflows/pr-branch.md +129 -0
  645. package/rihal/workflows/profile-user.md +162 -0
  646. package/rihal/workflows/progress.md +184 -0
  647. package/rihal/workflows/quick.md +105 -0
  648. package/rihal/workflows/remove-phase.md +155 -0
  649. package/rihal/workflows/remove-workspace.md +158 -0
  650. package/rihal/workflows/replay.md +160 -0
  651. package/rihal/workflows/rerun.md +77 -0
  652. package/rihal/workflows/research-phase.md +82 -0
  653. package/rihal/workflows/resume-work.md +326 -0
  654. package/rihal/workflows/review-adversarial.md +180 -0
  655. package/rihal/workflows/review-edge-case-hunter.md +214 -0
  656. package/rihal/workflows/review.md +281 -0
  657. package/rihal/workflows/scan.md +135 -0
  658. package/rihal/workflows/secure-phase.md +196 -0
  659. package/rihal/workflows/session-report.md +187 -0
  660. package/rihal/workflows/settings.md +185 -0
  661. package/rihal/workflows/ship.md +237 -0
  662. package/rihal/workflows/show.md +63 -0
  663. package/rihal/workflows/sprint-planning.md +166 -0
  664. package/rihal/workflows/sprint-status.md +124 -0
  665. package/rihal/workflows/stats.md +141 -0
  666. package/rihal/workflows/status.md +116 -0
  667. package/rihal/workflows/ui-phase.md +148 -0
  668. package/rihal/workflows/ui-review.md +130 -0
  669. package/rihal/workflows/undo.md +426 -0
  670. package/rihal/workflows/update.md +185 -0
  671. package/rihal/workflows/validate-phase.md +174 -0
  672. package/rihal/workflows/verify-phase.md +375 -0
  673. package/rihal/workflows/verify-work.md +717 -0
  674. package/rihal/workflows/why.md +130 -0
  675. package/rihal/workflows/workstream.md +197 -0
  676. package/server/dashboard.js +632 -0
@@ -0,0 +1,1478 @@
1
+ <purpose>
2
+ Execute all plans in a phase using wave-based parallel execution. Orchestrator stays lean — delegates plan execution to subagents.
3
+ </purpose>
4
+
5
+ <pre_flight>
6
+ **Mandatory before execution begins.** Run these checks first and surface
7
+ findings BEFORE any subagents are spawned. If any check fails, stop and
8
+ route back to the user.
9
+
10
+ 1. **Init state**: `node .rihal/bin/rihal-tools.cjs init execute-phase {N}`
11
+ 2. **Phase index**: list all plans via `state phase-plan-index {N}` — extract
12
+ plan count, wave count, autonomy flag per plan, files_modified overlaps
13
+ 3. **Anti-patterns**: check for `.continue-here.md` (paused state), STATE.md
14
+ error flag, existing VERIFICATION.md with FAIL items without overrides
15
+ 4. **Branch check**: confirm current git branch matches milestone's expected
16
+ branch (from config or roadmap)
17
+ 5. **Worktree config**: read `workflow.use_worktrees` — if true + parallelization
18
+ is true + no file overlaps, plans in a wave run parallel via worktrees
19
+ </pre_flight>
20
+
21
+ <insight_block>
22
+ After pre-flight, emit an insight block with the 2-3 most load-bearing
23
+ observations from phase inspection. Format exactly:
24
+
25
+ ```
26
+ ★ Insight ─────────────────────────────────────
27
+ - {observation 1: key scope reality}
28
+ - {observation 2: forced-sequential / overlap / checkpoint flags}
29
+ - {observation 3: autonomous-false plans needing human presence}
30
+ ─────────────────────────────────────────────────
31
+ ```
32
+
33
+ Keep to 3 bullets. Name specific files and plan IDs. No generic advice.
34
+ </insight_block>
35
+
36
+ <execution_plan>
37
+ After insight block, render a table of waves × plans:
38
+
39
+ ```
40
+ Execution Plan
41
+
42
+ Phase {NN}: {phase_name} — {N} plans across {M} waves{, building {one-line outcome}}.
43
+
44
+ ┌──────┬───────┬───────────────┬──────────────────────────────────────────────┐
45
+ │ Wave │ Plan │ Autonomy │ What it builds │
46
+ ├──────┼───────┼───────────────┼──────────────────────────────────────────────┤
47
+ │ 1 │ NN-01 │ 🛑 checkpoint │ {one-line what it builds} │
48
+ │ 1 │ NN-02 │ auto │ {one-line what it builds} │
49
+ │ 2 │ NN-03 │ auto │ {one-line what it builds} │
50
+ └──────┴───────┴───────────────┴──────────────────────────────────────────────┘
51
+ ```
52
+
53
+ Below the table, flag any wave forced to sequential (file overlaps) and
54
+ why. One sentence reality check about scope size (file count, token cost,
55
+ wall-clock expectation).
56
+ </execution_plan>
57
+
58
+ <three_options>
59
+ After execution plan, offer three modes via AskUserQuestion. Each option
60
+ names the tradeoff explicitly:
61
+
62
+ **A) Autonomous run** — Spawn subagent per plan in sequence/parallel per
63
+ wave rules. Checkpoints still pause for user. Fastest wall-clock.
64
+ Highest token cost. Least visibility mid-plan.
65
+
66
+ **B) Interactive mode** (`--interactive`) — Execute plans inline in the
67
+ current context (no subagents). Pair-programming style. Lower token
68
+ cost. Catch mistakes early. Best for design-heavy or novel work.
69
+
70
+ **C) Wave-only** (`--wave N`) — Run just one wave now, review, then run
71
+ later waves in a separate session. Good for staged rollout / review
72
+ gates.
73
+
74
+ Include a recommendation line: "My recommendation: {letter} because {reason
75
+ in one clause}." Then ask which option to proceed with — do NOT silently
76
+ pick one.
77
+ </three_options>
78
+
79
+ <output_format>
80
+ Open with banner:
81
+
82
+ ```
83
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
84
+ RIHAL ► EXECUTING PHASE {NN}
85
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
86
+ ```
87
+
88
+ Use TaskCreate at start, one entry per wave:
89
+ - TaskCreate: "Wave 1: {N} plan(s) in parallel"
90
+ - TaskCreate: "Wave 2: {N} plan(s) in parallel"
91
+ - TaskCreate: "Write phase SUMMARY.md"
92
+ - TaskCreate: "Run verifier gate"
93
+
94
+ Per-wave banner as each begins:
95
+ ```
96
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
97
+ RIHAL ► EXECUTING WAVE {N}
98
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
99
+
100
+ ◆ Spawning {N} rihal-executor agents in parallel...
101
+ ```
102
+
103
+ Per-agent completion:
104
+ ```
105
+ ✓ rihal-executor complete: {plan-id} → SUMMARY.md ({N} commits)
106
+ ```
107
+
108
+ Closure:
109
+ ```
110
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
111
+ RIHAL ► PHASE {NN} COMPLETE ✓
112
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
113
+ ```
114
+ End with Next Up block routing to /rihal:verify-work or /rihal:next.
115
+ </output_format>
116
+
117
+ <core_principle>
118
+ Orchestrator coordinates, not executes. Each subagent loads the full execute-sprint context. Orchestrator: discover plans → analyze deps → group waves → spawn agents → handle checkpoints → collect results.
119
+ </core_principle>
120
+
121
+ <runtime_compatibility>
122
+ **Subagent spawning is runtime-specific:**
123
+ - **Claude Code:** Uses `Task(subagent_type="rihal-executor", ...)` — blocks until complete, returns result
124
+ - **Copilot:** Subagent spawning does not reliably return completion signals. **Default to
125
+ sequential inline execution**: read and follow execute-sprint.md directly for each plan
126
+ instead of spawning parallel agents. Only attempt parallel spawning if the user
127
+ explicitly requests it — and in that case, rely on the spot-check fallback in step 3
128
+ to detect completion.
129
+ - **Other runtimes:** If `Task`/`task` tool is unavailable, use sequential inline execution as the
130
+ fallback. Check for tool availability at runtime rather than assuming based on runtime name.
131
+
132
+ **Fallback rule:** If a spawned agent completes its work (commits visible, SUMMARY.md exists) but
133
+ the orchestrator never receives the completion signal, treat it as successful based on spot-checks
134
+ and continue to the next wave/plan. Never block indefinitely waiting for a signal — always verify
135
+ via filesystem and git state.
136
+ </runtime_compatibility>
137
+
138
+ <required_reading>
139
+ @.rihal/references/output-format.md
140
+ Read STATE.md before any operation to load project context.
141
+
142
+ @.rihal/references/agent-contracts.md
143
+ @.rihal/references/context-budget.md
144
+ @.rihal/references/gates.md
145
+ </required_reading>
146
+
147
+ <available_agent_types>
148
+ These are the valid Rihal subagent types registered in .claude/agents/ (or equivalent for your runtime).
149
+ Always use the exact name from this list — do not fall back to 'general-purpose' or other built-in types:
150
+
151
+ - rihal-executor — Executes plan tasks, commits, creates SUMMARY.md
152
+ - rihal-verifier — Verifies phase completion, checks quality gates
153
+ - rihal-planner — Creates detailed plans from phase scope
154
+ - rihal-phase-researcher — Researches technical approaches for a phase
155
+ - rihal-sprint-checker — Reviews plan quality before execution
156
+ - rihal-debugger — Diagnoses and fixes issues
157
+ - rihal-codebase-mapper — Maps project structure and dependencies
158
+ - rihal-integration-checker — Checks cross-phase integration
159
+ - rihal-nyquist-auditor — Validates verification coverage
160
+ - rihal-ui-designer — Researches UI/UX approaches
161
+ - rihal-ui-auditor — Reviews UI implementation quality
162
+ - rihal-ui-auditor — Audits UI against design requirements
163
+ </available_agent_types>
164
+
165
+ <process>
166
+
167
+ <step name="parse_args" priority="first">
168
+ Parse `$ARGUMENTS` before loading any context:
169
+
170
+ - First positional token → `PHASE_ARG`
171
+ - Optional `--wave N` → `WAVE_FILTER`
172
+ - Optional `--gaps-only` keeps its current meaning
173
+
174
+ If `--wave` is absent, preserve the current behavior of executing all incomplete waves in the phase.
175
+ </step>
176
+
177
+ <step name="initialize" priority="first">
178
+ Load all context in one call:
179
+
180
+ ```bash
181
+ INIT=$(node ".rihal/bin/rihal-tools.cjs" init execute "${PHASE_ARG}")
182
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
183
+ AGENT_SKILLS=$(node ".rihal/bin/rihal-tools.cjs" agent-skills rihal-executor 2>/dev/null)
184
+ ```
185
+
186
+ Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`, `response_language`.
187
+
188
+ **If `response_language` is set:** Include `response_language: {value}` in all spawned subagent prompts so any user-facing output stays in the configured language.
189
+
190
+ Read worktree config:
191
+
192
+ ```bash
193
+ USE_WORKTREES=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow.use_worktrees 2>/dev/null || echo "true")
194
+ ```
195
+
196
+ When `USE_WORKTREES` is `false`, all executor agents run without `isolation="worktree"` — they execute sequentially on the main working tree instead of in parallel worktrees.
197
+
198
+ Read context window size for adaptive prompt enrichment:
199
+
200
+ ```bash
201
+ CONTEXT_WINDOW=$(node ".rihal/bin/rihal-tools.cjs" config-get context_window 2>/dev/null || echo "200000")
202
+ ```
203
+
204
+ When `CONTEXT_WINDOW >= 500000` (1M-class models), subagent prompts include richer context:
205
+ - Executor agents receive prior wave SUMMARY.md files and the phase CONTEXT.md/RESEARCH.md
206
+ - Verifier agents receive all SPRINT.md, SUMMARY.md, CONTEXT.md files plus REQUIREMENTS.md
207
+ - This enables cross-phase awareness and history-aware verification
208
+
209
+ **If `phase_found` is false:** Error — phase directory not found.
210
+ **If `plan_count` is 0:** Error — no plans found in phase.
211
+ **If `state_exists` is false but `.planning/` exists:** Offer reconstruct or continue.
212
+
213
+ When `parallelization` is false, plans within a wave execute sequentially.
214
+
215
+ **Runtime detection for Copilot:**
216
+ Check if the current runtime is Copilot by testing for the `@rihal-executor` agent pattern
217
+ or absence of the `Task()` subagent API. If running under Copilot, force sequential inline
218
+ execution regardless of the `parallelization` setting — Copilot's subagent completion
219
+ signals are unreliable (see `<runtime_compatibility>`). Set `COPILOT_SEQUENTIAL=true`
220
+ internally and skip the `execute_waves` step in favor of `check_interactive_mode`'s
221
+ inline path for each plan.
222
+
223
+ **REQUIRED — Sync chain flag with intent.** If user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This prevents stale `_auto_chain_active: true` from causing unwanted auto-advance. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference). You MUST execute this bash block before any config reads:
224
+ ```bash
225
+ # REQUIRED: prevents stale auto-chain from previous --auto runs
226
+ if [[ ! "$ARGUMENTS" =~ --auto ]]; then
227
+ node ".rihal/bin/rihal-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
228
+ fi
229
+ ```
230
+ </step>
231
+
232
+ <step name="create_phase_snapshot" priority="first">
233
+ **Create a pre-execution git tag so `/rihal:undo --phase NN --to-snapshot` can restore to this exact state.**
234
+
235
+ Only runs when inside a git repository with a valid HEAD (skip silently for fresh/empty repos).
236
+
237
+ ```bash
238
+ if git rev-parse --verify HEAD >/dev/null 2>&1; then
239
+ SNAPSHOT_TAG="rihal/snapshot/phase-${phase_number}"
240
+ if git rev-parse --verify "refs/tags/${SNAPSHOT_TAG}" >/dev/null 2>&1; then
241
+ PREV_SHA=$(git rev-parse --short "${SNAPSHOT_TAG}")
242
+ git tag -d "${SNAPSHOT_TAG}" >/dev/null 2>&1
243
+ echo "Replaced prior snapshot (was at ${PREV_SHA})"
244
+ fi
245
+ git tag -a "${SNAPSHOT_TAG}" -m "Pre-execution snapshot for phase ${phase_number}" HEAD 2>/dev/null \
246
+ && echo "✓ Snapshot: ${SNAPSHOT_TAG} @ $(git rev-parse --short HEAD)" \
247
+ || echo "⚠ Could not create snapshot tag (non-fatal — undo --to-snapshot will be unavailable for this phase)"
248
+ fi
249
+ ```
250
+
251
+ Tags are local-only by default (never auto-pushed), honoring the repo's push policy.
252
+ </step>
253
+
254
+ <step name="check_blocking_antipatterns" priority="first">
255
+ **MANDATORY — Check for blocking anti-patterns before any other work.**
256
+
257
+ Look for a `.continue-here.md` in the current phase directory:
258
+
259
+ ```bash
260
+ ls ${phase_dir}/.continue-here.md 2>/dev/null || true
261
+ ```
262
+
263
+ If `.continue-here.md` exists, parse its "Critical Anti-Patterns" table for rows with `severity` = `blocking`.
264
+
265
+ **If one or more `blocking` anti-patterns are found:**
266
+
267
+ This step cannot be skipped. Before proceeding to `check_interactive_mode` or any other step, the agent must demonstrate understanding of each blocking anti-pattern by answering all three questions for each one:
268
+
269
+ 1. **What is this anti-pattern?** — Describe it in your own words, not by quoting the handoff.
270
+ 2. **How did it manifest?** — Explain the specific failure that caused it to be recorded.
271
+ 3. **What structural mechanism (not acknowledgment) prevents it?** — Name the concrete step, checklist item, or enforcement mechanism that stops recurrence.
272
+
273
+ Write these answers inline before continuing. If a blocking anti-pattern cannot be answered from the context in `.continue-here.md`, stop and ask the user for clarification.
274
+
275
+ **If no `.continue-here.md` exists, or no `blocking` rows are found:** Proceed directly to `check_interactive_mode`.
276
+ </step>
277
+
278
+ <step name="check_interactive_mode">
279
+ **Parse `--interactive` flag from $ARGUMENTS.**
280
+
281
+ **If `--interactive` flag present:** Switch to interactive execution mode.
282
+
283
+ Interactive mode executes plans sequentially **inline** (no subagent spawning) with user
284
+ checkpoints between tasks. The user can review, modify, or redirect work at any point.
285
+
286
+ **Interactive execution flow:**
287
+
288
+ 1. Load plan inventory as normal (discover_and_group_plans)
289
+ 2. For each plan (sequentially, ignoring wave grouping):
290
+
291
+ a. **Present the plan to the user:**
292
+ ```
293
+ ## Plan {plan_id}: {plan_name}
294
+
295
+ Objective: {from plan file}
296
+ Tasks: {task_count}
297
+
298
+ Options:
299
+ - Execute (proceed with all tasks)
300
+ - Review first (show task breakdown before starting)
301
+ - Skip (move to next plan)
302
+ - Stop (end execution, save progress)
303
+ ```
304
+
305
+ b. **If "Review first":** Read and display the full plan file. Ask again: Execute, Modify, Skip.
306
+
307
+ c. **If "Execute":** Read and follow `.rihal/workflows/execute-sprint.md` **inline**
308
+ (do NOT spawn a subagent). Execute tasks one at a time.
309
+
310
+ d. **After each task:** Pause briefly. If the user intervenes (types anything), stop and address
311
+ their feedback before continuing. Otherwise proceed to next task.
312
+
313
+ e. **After plan complete:** Show results, commit, create SUMMARY.md, then present next plan.
314
+
315
+ 3. After all plans: proceed to verification (same as normal mode).
316
+
317
+ **Benefits of interactive mode:**
318
+ - No subagent overhead — dramatically lower token usage
319
+ - User catches mistakes early — saves costly verification cycles
320
+ - Maintains Rihal's planning/tracking structure
321
+ - Best for: small phases, bug fixes, verification gaps, learning Rihal
322
+
323
+ **Skip to handle_branching step** (interactive plans execute inline after grouping).
324
+ </step>
325
+
326
+ <step name="handle_branching">
327
+ Check `branching_strategy` from init:
328
+
329
+ **"none":** Skip, continue on current branch.
330
+
331
+ **"phase" or "milestone":** Use pre-computed `branch_name` from init:
332
+ ```bash
333
+ git checkout -b "$BRANCH_NAME" 2>/dev/null || git checkout "$BRANCH_NAME"
334
+ ```
335
+
336
+ All subsequent commits go to this branch. User handles merging.
337
+ </step>
338
+
339
+ <step name="validate_phase">
340
+ From init JSON: `phase_dir`, `plan_count`, `incomplete_count`.
341
+
342
+ Report: "Found {plan_count} plans in {phase_dir} ({incomplete_count} incomplete)"
343
+
344
+ **Update STATE.md for phase start:**
345
+ ```bash
346
+ node ".rihal/bin/rihal-tools.cjs" state begin-phase --phase "${PHASE_NUMBER}" --name "${PHASE_NAME}" --plans "${PLAN_COUNT}"
347
+ ```
348
+ This updates Status, Last Activity, Current focus, Current Position, and plan counts in STATE.md so frontmatter and body text reflect the active phase immediately.
349
+ </step>
350
+
351
+ <step name="discover_and_group_plans">
352
+ Load plan inventory with wave grouping in one call:
353
+
354
+ ```bash
355
+ PLAN_INDEX=$(node ".rihal/bin/rihal-tools.cjs" phase-plan-index "${PHASE_NUMBER}")
356
+ ```
357
+
358
+ Parse JSON for: `phase`, `plans[]` (each with `id`, `wave`, `autonomous`, `objective`, `files_modified`, `task_count`, `has_summary`), `waves` (map of wave number → plan IDs), `incomplete`, `has_checkpoints`.
359
+
360
+ **Filtering:** Skip plans where `has_summary: true`. If `--gaps-only`: also skip non-gap_closure plans. If `WAVE_FILTER` is set: also skip plans whose `wave` does not equal `WAVE_FILTER`.
361
+
362
+ **Wave safety check:** If `WAVE_FILTER` is set and there are still incomplete plans in any lower wave that match the current execution mode, STOP and tell the user to finish earlier waves first. Do not let Wave 2+ execute while prerequisite earlier-wave plans remain incomplete.
363
+
364
+ If all filtered: "No matching incomplete plans" → exit.
365
+
366
+ Report:
367
+ ```
368
+ ## Execution Plan
369
+
370
+ **Phase {X}: {Name}** — {total_plans} matching plans across {wave_count} wave(s)
371
+
372
+ {If WAVE_FILTER is set: `Wave filter active: executing only Wave {WAVE_FILTER}`.}
373
+
374
+ | Wave | Plans | What it builds |
375
+ |------|-------|----------------|
376
+ | 1 | 01-01, 01-02 | {from plan objectives, 3-8 words} |
377
+ | 2 | 01-03 | ... |
378
+ ```
379
+ </step>
380
+
381
+ <step name="execute_waves">
382
+ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`, sequential if `false`.
383
+
384
+ **For each wave:**
385
+
386
+ 1. **Intra-wave files_modified overlap check (BEFORE spawning):**
387
+
388
+ Before spawning any agents for this wave, inspect the `files_modified` list of all plans
389
+ in the wave. Check every pair of plans in the wave — if any two plans share even one file
390
+ in their `files_modified` lists, those plans have an implicit dependency and MUST NOT run
391
+ in parallel.
392
+
393
+ **Detection algorithm (pseudocode):**
394
+ ```
395
+ seen_files = {}
396
+ overlapping_plans = []
397
+ for each plan in wave_plans:
398
+ for each file in plan.files_modified:
399
+ if file in seen_files:
400
+ overlapping_plans.add(plan, seen_files[file]) # both plans overlap on this file
401
+ else:
402
+ seen_files[file] = plan
403
+ ```
404
+
405
+ **If overlap is detected:**
406
+ - Warn the user:
407
+ ```
408
+ ⚠ Intra-wave files_modified overlap detected in Wave {N}:
409
+ Plan {A} and Plan {B} both modify {file}
410
+ Running these plans sequentially to avoid parallel worktree conflicts.
411
+ ```
412
+ - Override `PARALLELIZATION` to `false` for this wave only — run all plans in the wave
413
+ sequentially regardless of the global parallelization setting.
414
+ - This is a safety net for plans that were incorrectly assigned to the same wave.
415
+ The planner should have caught this; flag it as a planning defect so the user can
416
+ replan the phase if desired.
417
+
418
+ **If no overlap:** proceed normally (parallel if `PARALLELIZATION=true`).
419
+
420
+ 2. **Describe what's being built (BEFORE spawning):**
421
+
422
+ Read each plan's `<objective>`. Extract what's being built and why.
423
+
424
+ ```
425
+ ---
426
+ ## Wave {N}
427
+
428
+ **{Plan ID}: {Plan Name}**
429
+ {2-3 sentences: what this builds, technical approach, why it matters}
430
+
431
+ Spawning {count} agent(s)...
432
+ ---
433
+ ```
434
+
435
+ - Bad: "Executing terrain generation plan"
436
+ - Good: "Procedural terrain generator using Perlin noise — creates height maps, biome zones, and collision meshes. Required before vehicle physics can interact with ground."
437
+
438
+ 3. **Spawn executor agents:**
439
+
440
+ Pass paths only — executors read files themselves with their fresh context window.
441
+ For 200k models, this keeps orchestrator context lean (~10-15%).
442
+ For 1M+ models (Opus 4.6, Sonnet 4.6), richer context can be passed directly.
443
+
444
+ **Worktree mode** (`USE_WORKTREES` is not `false`):
445
+
446
+ Before spawning, capture the current HEAD:
447
+ ```bash
448
+ EXPECTED_BASE=$(git rev-parse HEAD)
449
+ ```
450
+
451
+ **Sequential dispatch for parallel execution (waves with 2+ agents):**
452
+ When spawning multiple agents in a wave, dispatch each `Task()` call **one at a time
453
+ with `run_in_background: true`** — do NOT send all Task calls in a single message.
454
+ `git worktree add` acquires an exclusive lock on `.git/config.lock`, so simultaneous
455
+ calls race for this lock and fail. Sequential dispatch ensures each worktree finishes
456
+ creation before the next begins (the round-trip latency of each tool call provides
457
+ natural spacing), while all agents still **run in parallel** once created.
458
+
459
+ ```
460
+ # CORRECT: dispatch one Task() per message, each with run_in_background: true
461
+ # → worktrees created sequentially, agents execute in parallel
462
+ #
463
+ # WRONG: multiple Task() calls in a single message
464
+ # → simultaneous git worktree add → .git/config.lock contention → failures
465
+ ```
466
+
467
+ ```
468
+ Task(
469
+ subagent_type="rihal-executor",
470
+ description="Execute plan {plan_number} of phase {phase_number}",
471
+ model="{executor_model}",
472
+ isolation="worktree",
473
+ prompt="
474
+ <objective>
475
+ Execute plan {plan_number} of phase {phase_number}-{phase_name}.
476
+ Commit each task atomically. Create SUMMARY.md.
477
+ Do NOT update STATE.md or ROADMAP.md — the orchestrator owns those writes after all worktree agents in the wave complete.
478
+ </objective>
479
+
480
+ <worktree_branch_check>
481
+ FIRST ACTION before any other work: verify this worktree's branch is based on the correct commit.
482
+
483
+ Run:
484
+ ```bash
485
+ ACTUAL_BASE=$(git merge-base HEAD {EXPECTED_BASE})
486
+ CURRENT_HEAD=$(git rev-parse HEAD)
487
+ ```
488
+
489
+ If `ACTUAL_BASE` != `{EXPECTED_BASE}` (i.e. the worktree branch was created from an older
490
+ base such as `main` instead of the feature branch HEAD), rebase onto the correct base:
491
+ ```bash
492
+ git rebase --onto {EXPECTED_BASE} $(git rev-parse --abbrev-ref HEAD~1 2>/dev/null || git rev-parse HEAD^) HEAD 2>/dev/null || true
493
+ # If rebase fails or is a no-op, reset the branch to start from the correct base:
494
+ git reset --soft {EXPECTED_BASE}
495
+ ```
496
+
497
+ If `ACTUAL_BASE` == `{EXPECTED_BASE}`: the branch base is correct, proceed immediately.
498
+
499
+ This check fixes a known issue on Windows where `EnterWorktree` creates branches from
500
+ `main` instead of the current feature branch HEAD.
501
+ </worktree_branch_check>
502
+
503
+ <parallel_execution>
504
+ You are running as a PARALLEL executor agent. Use --no-verify on all git
505
+ commits to avoid pre-commit hook contention with other agents. The
506
+ orchestrator validates hooks once after all agents complete.
507
+ For rihal-tools commits: add --no-verify flag.
508
+ For direct git commits: use git commit --no-verify -m "..."
509
+ </parallel_execution>
510
+
511
+ <execution_context>
512
+ @.rihal/workflows/execute-sprint.md
513
+ @.rihal/templates/summary.md
514
+ @.rihal/references/checkpoints.md
515
+ @.rihal/references/tdd.md
516
+ </execution_context>
517
+
518
+ <files_to_read>
519
+ Read these files at execution start using the Read tool:
520
+ - {phase_dir}/{plan_file} (Plan)
521
+ - .planning/PROJECT.md (Project context — core value, requirements, evolution rules)
522
+ - .planning/STATE.md (State)
523
+ - .planning/config.json (Config, if exists)
524
+ ${CONTEXT_WINDOW >= 500000 ? `
525
+ - ${phase_dir}/*-CONTEXT.md (User decisions from discuss-phase — honors locked choices)
526
+ - ${phase_dir}/*-RESEARCH.md (Technical research — pitfalls and patterns to follow)
527
+ - ${prior_wave_summaries} (SUMMARY.md files from earlier waves in this phase — what was already built)
528
+ ` : ''}
529
+ - ./CLAUDE.md (Project instructions, if exists — follow project-specific guidelines and coding conventions)
530
+ - .claude/skills/ or .agents/skills/ (Project skills, if either exists — list skills, read SKILL.md for each, follow relevant rules during implementation)
531
+ </files_to_read>
532
+
533
+ ${AGENT_SKILLS}
534
+
535
+ <mcp_tools>
536
+ If CLAUDE.md or project instructions reference MCP tools (e.g. jCodeMunch, context7,
537
+ or other MCP servers), prefer those tools over Grep/Glob for code navigation when available.
538
+ MCP tools often save significant tokens by providing structured code indexes.
539
+ Check tool availability first — if MCP tools are not accessible, fall back to Grep/Glob.
540
+ </mcp_tools>
541
+
542
+ <success_criteria>
543
+ - [ ] All tasks executed
544
+ - [ ] Each task committed individually
545
+ - [ ] SUMMARY.md created in plan directory
546
+ </success_criteria>
547
+ "
548
+ )
549
+ ```
550
+
551
+ **Sequential mode** (`USE_WORKTREES` is `false`):
552
+
553
+ Omit `isolation="worktree"` from the Task call. Replace the `<parallel_execution>` block with:
554
+
555
+ ```
556
+ <sequential_execution>
557
+ You are running as a SEQUENTIAL executor agent on the main working tree.
558
+ Use normal git commits (with hooks). Do NOT use --no-verify.
559
+ </sequential_execution>
560
+ ```
561
+
562
+ The sequential mode Task prompt uses the same structure as worktree mode but with these differences in success_criteria — since there is only one agent writing at a time, there are no shared-file conflicts:
563
+
564
+ ```
565
+ <success_criteria>
566
+ - [ ] All tasks executed
567
+ - [ ] Each task committed individually
568
+ - [ ] SUMMARY.md created in plan directory
569
+ - [ ] STATE.md updated with position and decisions
570
+ - [ ] ROADMAP.md updated with plan progress (via `roadmap update-plan-progress`)
571
+ </success_criteria>
572
+ ```
573
+
574
+ When worktrees are disabled, execute plans **one at a time within each wave** (sequential) regardless of the `PARALLELIZATION` setting — multiple agents writing to the same working tree concurrently would cause conflicts.
575
+
576
+ 4. **Wait for all agents in wave to complete.**
577
+
578
+ **Completion signal fallback (Copilot and runtimes where Task() may not return):**
579
+
580
+ If a spawned agent does not return a completion signal but appears to have finished
581
+ its work, do NOT block indefinitely. Instead, verify completion via spot-checks:
582
+
583
+ ```bash
584
+ # For each plan in this wave, check if the executor finished:
585
+ SUMMARY_EXISTS=$(test -f "{phase_dir}/{plan_number}-{plan_padded}-SUMMARY.md" && echo "true" || echo "false")
586
+ COMMITS_FOUND=$(git log --oneline --all --grep="{phase_number}-{plan_padded}" --since="1 hour ago" | head -1)
587
+ ```
588
+
589
+ **If SUMMARY.md exists AND commits are found:** The agent completed successfully —
590
+ treat as done and proceed to step 5. Log: `"✓ {Plan ID} completed (verified via spot-check — completion signal not received)"`
591
+
592
+ **If SUMMARY.md does NOT exist after a reasonable wait:** The agent may still be
593
+ running or may have failed silently. Check `git log --oneline -5` for recent
594
+ activity. If commits are still appearing, wait longer. If no activity, report
595
+ the plan as failed and route to the failure handler in step 6.
596
+
597
+ **This fallback applies automatically to all runtimes.** Claude Code's Task() normally
598
+ returns synchronously, but the fallback ensures resilience if it doesn't.
599
+
600
+ 5. **Post-wave hook validation (parallel mode only):**
601
+
602
+ When agents committed with `--no-verify`, run pre-commit hooks once after the wave:
603
+ ```bash
604
+ # Run project's pre-commit hooks on the current state
605
+ git diff --cached --quiet || git stash # stash any unstaged changes
606
+ git hook run pre-commit 2>&1 || echo "⚠ Pre-commit hooks failed — review before continuing"
607
+ ```
608
+ If hooks fail: report the failure and ask "Fix hook issues now?" or "Continue to next wave?"
609
+
610
+ 5.5. **Worktree cleanup (when `isolation="worktree"` was used):**
611
+
612
+ When executor agents ran in worktree isolation, their commits land on temporary branches in separate working trees. After the wave completes, merge these changes back and clean up:
613
+
614
+ ```bash
615
+ # List worktrees created by this wave's agents
616
+ WORKTREES=$(git worktree list --porcelain | grep "^worktree " | grep -v "$(pwd)$" | sed 's/^worktree //')
617
+
618
+ for WT in $WORKTREES; do
619
+ # Get the branch name for this worktree
620
+ WT_BRANCH=$(git -C "$WT" rev-parse --abbrev-ref HEAD 2>/dev/null)
621
+ if [ -n "$WT_BRANCH" ] && [ "$WT_BRANCH" != "HEAD" ]; then
622
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
623
+
624
+ # --- Orchestrator file protection (#1756) ---
625
+ # Snapshot orchestrator-owned files BEFORE merge. If the worktree
626
+ # branch outlived a milestone transition, its versions of STATE.md
627
+ # and ROADMAP.md are stale. Main always wins for these files.
628
+ STATE_BACKUP=$(mktemp)
629
+ ROADMAP_BACKUP=$(mktemp)
630
+ git show HEAD:.planning/STATE.md > "$STATE_BACKUP" 2>/dev/null || true
631
+ git show HEAD:.planning/ROADMAP.md > "$ROADMAP_BACKUP" 2>/dev/null || true
632
+
633
+ # Snapshot list of files on main BEFORE merge to detect resurrections
634
+ PRE_MERGE_FILES=$(git ls-files .planning/)
635
+
636
+ # Merge the worktree branch into the current branch
637
+ git merge "$WT_BRANCH" --no-edit -m "chore: merge executor worktree ($WT_BRANCH)" 2>&1 || {
638
+ echo "⚠ Merge conflict from worktree $WT_BRANCH — resolve manually"
639
+ rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
640
+ continue
641
+ }
642
+
643
+ # Restore orchestrator-owned files (main always wins)
644
+ if [ -s "$STATE_BACKUP" ]; then
645
+ cp "$STATE_BACKUP" .planning/STATE.md
646
+ fi
647
+ if [ -s "$ROADMAP_BACKUP" ]; then
648
+ cp "$ROADMAP_BACKUP" .planning/ROADMAP.md
649
+ fi
650
+ rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
651
+
652
+ # Detect files deleted on main but re-added by worktree merge
653
+ # (e.g., archived phase directories that were intentionally removed)
654
+ DELETED_FILES=$(git diff --diff-filter=A --name-only HEAD~1 -- .planning/ 2>/dev/null || true)
655
+ for RESURRECTED in $DELETED_FILES; do
656
+ # Check if this file was NOT in main's pre-merge tree
657
+ if ! echo "$PRE_MERGE_FILES" | grep -qxF "$RESURRECTED"; then
658
+ git rm -f "$RESURRECTED" 2>/dev/null || true
659
+ fi
660
+ done
661
+
662
+ # Amend merge commit with restored files if any changed
663
+ if ! git diff --quiet .planning/STATE.md .planning/ROADMAP.md 2>/dev/null || \
664
+ [ -n "$DELETED_FILES" ]; then
665
+ # Only amend the commit with .planning/ files if commit_docs is enabled (#1783)
666
+ COMMIT_DOCS=$(node ".rihal/bin/rihal-tools.cjs" config-get commit_docs 2>/dev/null || echo "true")
667
+ if [ "$COMMIT_DOCS" != "false" ]; then
668
+ git add .planning/STATE.md .planning/ROADMAP.md 2>/dev/null || true
669
+ git commit --amend --no-edit 2>/dev/null || true
670
+ fi
671
+ fi
672
+
673
+ # Remove the worktree
674
+ git worktree remove "$WT" --force 2>/dev/null || true
675
+
676
+ # Delete the temporary branch
677
+ git branch -D "$WT_BRANCH" 2>/dev/null || true
678
+ fi
679
+ done
680
+ ```
681
+
682
+ **If `workflow.use_worktrees` is `false`:** Agents ran on the main working tree — skip this step entirely.
683
+
684
+ **If no worktrees found:** Skip silently — agents may have been spawned without worktree isolation.
685
+
686
+ 5.6. **Post-wave shared artifact update (worktree mode only):**
687
+
688
+ When executor agents ran with `isolation="worktree"`, they skipped STATE.md and ROADMAP.md updates to avoid last-merge-wins overwrites. The orchestrator is the single writer for these files. After worktrees are merged back, update shared artifacts once:
689
+
690
+ ```bash
691
+ # Update ROADMAP.md for each completed plan in this wave
692
+ for PLAN_ID in ${WAVE_PLAN_IDS}; do
693
+ node ".rihal/bin/rihal-tools.cjs" roadmap update-plan-progress "${PHASE_NUMBER}" "${PLAN_ID}" completed
694
+ done
695
+
696
+ ```
697
+
698
+ Where `WAVE_PLAN_IDS` is the space-separated list of plan IDs that completed in this wave.
699
+
700
+ **If `workflow.use_worktrees` is `false`:** Sequential agents already updated STATE.md and ROADMAP.md themselves — skip this step.
701
+
702
+ 6. **Report completion — spot-check claims first:**
703
+
704
+ For each SUMMARY.md:
705
+ - Verify first 2 files from `key-files.created` exist on disk
706
+ - Check `git log --oneline --all --grep="{phase}-{plan}"` returns ≥1 commit
707
+ - Check for `## Self-Check: FAILED` marker
708
+
709
+ If ANY spot-check fails: report which plan failed, route to failure handler — ask "Retry plan?" or "Continue with remaining waves?"
710
+
711
+ If pass:
712
+ ```
713
+ ---
714
+ ## Wave {N} Complete
715
+
716
+ **{Plan ID}: {Plan Name}**
717
+ {What was built — from SUMMARY.md}
718
+ {Notable deviations, if any}
719
+
720
+ {If more waves: what this enables for next wave}
721
+ ---
722
+ ```
723
+
724
+ - Bad: "Wave 2 complete. Proceeding to Wave 3."
725
+ - Good: "Terrain system complete — 3 biome types, height-based texturing, physics collision meshes. Vehicle physics (Wave 3) can now reference ground surfaces."
726
+
727
+ 7. **Handle failures:**
728
+
729
+ **Known Claude Code bug (classifyHandoffIfNeeded):** If an agent reports "failed" with error containing `classifyHandoffIfNeeded is not defined`, this is a Claude Code runtime bug — not a Rihal or agent issue. The error fires in the completion handler AFTER all tool calls finish. In this case: run the same spot-checks as step 5 (SUMMARY.md exists, git commits present, no Self-Check: FAILED). If spot-checks PASS → treat as **successful**. If spot-checks FAIL → treat as real failure below.
730
+
731
+ For real failures: report which plan failed → ask "Continue?" or "Stop?" → if continue, dependent plans may also fail. If stop, partial completion report.
732
+
733
+ 7b. **Pre-wave dependency check (waves 2+ only):**
734
+
735
+ Before spawning wave N+1, for each plan in the upcoming wave:
736
+ ```bash
737
+ node ".rihal/bin/rihal-tools.cjs" verify key-links {phase_dir}/{plan}-SPRINT.md
738
+ ```
739
+
740
+ If any key-link from a PRIOR wave's artifact fails verification:
741
+
742
+ ## Cross-Plan Wiring Gap
743
+
744
+ | Plan | Link | From | Expected Pattern | Status |
745
+ |------|------|------|-----------------|--------|
746
+ | {plan} | {via} | {from} | {pattern} | NOT FOUND |
747
+
748
+ Wave {N} artifacts may not be properly wired. Options:
749
+ 1. Investigate and fix before continuing
750
+ 2. Continue (may cause cascading failures in wave {N+1})
751
+
752
+ Key-links referencing files in the CURRENT (upcoming) wave are skipped.
753
+
754
+ 8. **Execute checkpoint plans between waves** — see `<checkpoint_handling>`.
755
+
756
+ 9. **Proceed to next wave.**
757
+ </step>
758
+
759
+ <step name="checkpoint_handling">
760
+ Plans with `autonomous: false` require user interaction.
761
+
762
+ **Auto-mode checkpoint handling:**
763
+
764
+ Read auto-advance config (chain flag + user preference):
765
+ ```bash
766
+ AUTO_CHAIN=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
767
+ AUTO_CFG=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
768
+ ```
769
+
770
+ When executor returns a checkpoint AND (`AUTO_CHAIN` is `"true"` OR `AUTO_CFG` is `"true"`):
771
+ - **human-verify** → Auto-spawn continuation agent with `{user_response}` = `"approved"`. Log `⚡ Auto-approved checkpoint`.
772
+ - **decision** → Auto-spawn continuation agent with `{user_response}` = first option from checkpoint details. Log `⚡ Auto-selected: [option]`.
773
+ - **human-action** → Present to user (existing behavior below). Auth gates cannot be automated.
774
+
775
+ **Standard flow (not auto-mode, or human-action type):**
776
+
777
+ 1. Spawn agent for checkpoint plan
778
+ 2. Agent runs until checkpoint task or auth gate → returns structured state
779
+ 3. Agent return includes: completed tasks table, current task + blocker, checkpoint type/details, what's awaited
780
+ 4. **Present to user:**
781
+ ```
782
+ ## Checkpoint: [Type]
783
+
784
+ **Plan:** 03-03 Dashboard Layout
785
+ **Progress:** 2/3 tasks complete
786
+
787
+ [Checkpoint Details from agent return]
788
+ [Awaiting section from agent return]
789
+ ```
790
+ 5. User responds: "approved"/"done" | issue description | decision selection
791
+ 6. **Spawn continuation agent (NOT resume)** using continuation-prompt.md template:
792
+ - `{completed_tasks_table}`: From checkpoint return
793
+ - `{resume_task_number}` + `{resume_task_name}`: Current task
794
+ - `{user_response}`: What user provided
795
+ - `{resume_instructions}`: Based on checkpoint type
796
+ 7. Continuation agent verifies previous commits, continues from resume point
797
+ 8. Repeat until plan completes or user stops
798
+
799
+ **Why fresh agent, not resume:** Resume relies on internal serialization that breaks with parallel tool calls. Fresh agents with explicit state are more reliable.
800
+
801
+ **Checkpoints in parallel waves:** Agent pauses and returns while other parallel agents may complete. Present checkpoint, spawn continuation, wait for all before next wave.
802
+ </step>
803
+
804
+ <step name="aggregate_results">
805
+ After all waves:
806
+
807
+ ```markdown
808
+ ## Phase {X}: {Name} Execution Complete
809
+
810
+ **Waves:** {N} | **Plans:** {M}/{total} complete
811
+
812
+ | Wave | Plans | Status |
813
+ |------|-------|--------|
814
+ | 1 | plan-01, plan-02 | ✓ Complete |
815
+ | CP | plan-03 | ✓ Verified |
816
+ | 2 | plan-04 | ✓ Complete |
817
+
818
+ ### Plan Details
819
+ 1. **03-01**: [one-liner from SUMMARY.md]
820
+ 2. **03-02**: [one-liner from SUMMARY.md]
821
+
822
+ ### Issues Encountered
823
+ [Aggregate from SUMMARYs, or "None"]
824
+ ```
825
+
826
+ **Security gate check:**
827
+ ```bash
828
+ SECURITY_CFG=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
829
+ SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
830
+ ```
831
+
832
+ If `SECURITY_CFG` is `false`: skip.
833
+
834
+ If `SECURITY_CFG` is `true` AND `SECURITY_FILE` is empty (no SECURITY.md yet):
835
+ Include in the next-steps routing output:
836
+ ```
837
+ ⚠ Security enforcement enabled — run before advancing:
838
+ /rihal:secure-phase {PHASE} ${Rihal_WS}
839
+ ```
840
+
841
+ If `SECURITY_CFG` is `true` AND SECURITY.md exists: check frontmatter `threats_open`. If > 0:
842
+ ```
843
+ ⚠ Security gate: {threats_open} threats open
844
+ /rihal:secure-phase {PHASE} — resolve before advancing
845
+ ```
846
+ </step>
847
+
848
+ <step name="handle_partial_wave_execution">
849
+ If `WAVE_FILTER` was used, re-run plan discovery after execution:
850
+
851
+ ```bash
852
+ POST_PLAN_INDEX=$(node ".rihal/bin/rihal-tools.cjs" phase-plan-index "${PHASE_NUMBER}")
853
+ ```
854
+
855
+ Apply the same "incomplete" filtering rules as earlier:
856
+ - ignore plans with `has_summary: true`
857
+ - if `--gaps-only`, only consider `gap_closure: true` plans
858
+
859
+ **If incomplete plans still remain anywhere in the phase:**
860
+ - STOP here
861
+ - Do NOT run phase verification
862
+ - Do NOT mark the phase complete in ROADMAP/STATE
863
+ - Present:
864
+
865
+ ```markdown
866
+ ## Wave {WAVE_FILTER} Complete
867
+
868
+ Selected wave finished successfully. This phase still has incomplete plans, so phase-level verification and completion were intentionally skipped.
869
+
870
+ /rihal:execute {phase} ${Rihal_WS} # Continue remaining waves
871
+ /rihal:execute {phase} --wave {next} ${Rihal_WS} # Run the next wave explicitly
872
+ ```
873
+
874
+ **If no incomplete plans remain after the selected wave finishes:**
875
+ - continue with the normal phase-level verification and completion flow below
876
+ - this means the selected wave happened to be the last remaining work in the phase
877
+ </step>
878
+
879
+ <step name="code_review_gate" required="true">
880
+ **This step is REQUIRED and must not be skipped.** Spawn `rihal-code-reviewer` to review the phase's source changes. Acts as a BLOCKING gate before the verifier when critical or high findings are present.
881
+
882
+ **Config gate (default ON):**
883
+ ```bash
884
+ CODE_REVIEW_ENABLED=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow.code_review_enabled 2>/dev/null || echo "true")
885
+ ```
886
+
887
+ If `CODE_REVIEW_ENABLED` is `"false"`: display "Code review skipped (workflow.code_review_enabled=false)" and proceed to `close_parent_artifacts`.
888
+
889
+ **Resolve reviewer model:**
890
+ ```bash
891
+ REVIEWER_MODEL=$(node ".rihal/bin/rihal-tools.cjs" resolve-model code-reviewer 2>/dev/null | node -e "let d='';process.stdin.on('data',c=>d+=c).on('end',()=>{try{console.log(JSON.parse(d).model)}catch{console.log('')}})" || echo "")
892
+ REVIEWER_SKILLS=$(node ".rihal/bin/rihal-tools.cjs" agent-skills rihal-code-reviewer 2>/dev/null || echo "")
893
+ PADDED=$(printf "%02d" "${PHASE_NUMBER}")
894
+ REVIEW_FILE="${PHASE_DIR}/${PADDED}-REVIEW.md"
895
+ ```
896
+
897
+ **Spawn the reviewer agent:**
898
+ ```
899
+ Task(
900
+ description="Code review for phase {phase_number}",
901
+ prompt="Review the source code changes for phase {phase_number}.
902
+ Phase directory: {phase_dir}
903
+ Phase goal: {goal from ROADMAP.md}
904
+
905
+ Read all plan files and summaries in the phase directory, then review the source files actually modified (from SUMMARY.md `key-files.created`/`modified`). Classify each finding by severity: critical, high, medium, or low.
906
+
907
+ Write the review to: ${REVIEW_FILE}
908
+
909
+ The file MUST begin with YAML frontmatter including:
910
+ ---
911
+ status: clean | issues_found | skipped
912
+ phase: {phase_number}
913
+ critical: <count>
914
+ high: <count>
915
+ medium: <count>
916
+ low: <count>
917
+ generated: <ISO timestamp>
918
+ ---
919
+
920
+ Group findings by severity. For each finding include: file path, line reference, description, recommended fix.
921
+
922
+ ${REVIEWER_SKILLS}",
923
+ subagent_type="rihal-code-reviewer",
924
+ model="${REVIEWER_MODEL}"
925
+ )
926
+ ```
927
+
928
+ **Error handling:** If the Task invocation fails or throws, display "Code review encountered an error (non-blocking): {error}" and proceed to `close_parent_artifacts`. A broken reviewer must never permanently block execution.
929
+
930
+ **Parse severity counts:**
931
+ ```bash
932
+ if [[ -f "$REVIEW_FILE" ]]; then
933
+ REVIEW_STATUS=$(sed -n '/^---$/,/^---$/p' "$REVIEW_FILE" | grep "^status:" | head -1 | cut -d: -f2 | tr -d ' ')
934
+ CRITICAL_COUNT=$(sed -n '/^---$/,/^---$/p' "$REVIEW_FILE" | grep "^critical:" | head -1 | cut -d: -f2 | tr -d ' ')
935
+ HIGH_COUNT=$(sed -n '/^---$/,/^---$/p' "$REVIEW_FILE" | grep "^high:" | head -1 | cut -d: -f2 | tr -d ' ')
936
+ MEDIUM_COUNT=$(sed -n '/^---$/,/^---$/p' "$REVIEW_FILE" | grep "^medium:" | head -1 | cut -d: -f2 | tr -d ' ')
937
+ LOW_COUNT=$(sed -n '/^---$/,/^---$/p' "$REVIEW_FILE" | grep "^low:" | head -1 | cut -d: -f2 | tr -d ' ')
938
+ fi
939
+ ```
940
+
941
+ **Blocking gate on critical/high:**
942
+
943
+ If `CRITICAL_COUNT > 0` OR `HIGH_COUNT > 0`, present the block banner and use AskUserQuestion:
944
+
945
+ ```
946
+ ## ⛔ Code Review Gate: Blocking Findings
947
+
948
+ Phase {phase_number} code review found:
949
+ critical: ${CRITICAL_COUNT}
950
+ high: ${HIGH_COUNT}
951
+ medium: ${MEDIUM_COUNT}
952
+ low: ${LOW_COUNT}
953
+
954
+ Report: ${REVIEW_FILE}
955
+
956
+ Verifier is blocked until critical/high findings are resolved.
957
+ ```
958
+
959
+ AskUserQuestion with options:
960
+ 1. **"Run /rihal:code-review-fix first (recommended)"** — Stop. Print next command: `/rihal:code-review-fix ${PHASE_NUMBER} ${Rihal_WS}`. Do NOT spawn verifier.
961
+ 2. **"Proceed to verifier anyway (high findings unresolved)"** — Log override and continue to `close_parent_artifacts` → `regression_gate` → `verify_phase_goal`.
962
+ 3. **"Cancel execution"** — Stop. Report partial completion.
963
+
964
+ **Advisory line on medium/low only:**
965
+
966
+ If `CRITICAL_COUNT == 0` AND `HIGH_COUNT == 0` AND (`MEDIUM_COUNT > 0` OR `LOW_COUNT > 0`), display:
967
+ ```
968
+ ⚠ Code review found non-blocking findings (medium: ${MEDIUM_COUNT}, low: ${LOW_COUNT}).
969
+ Report: ${REVIEW_FILE}
970
+ Consider: /rihal:code-review-fix ${PHASE_NUMBER}
971
+ ```
972
+ Then continue to `close_parent_artifacts`.
973
+
974
+ **Clean review:** If `REVIEW_STATUS == "clean"` (or all counts are zero), display "✓ Code review clean" and continue.
975
+
976
+ Only when the gate is clean or the user overrides do we proceed to close_parent_artifacts → regression_gate → verify_phase_goal.
977
+ </step>
978
+
979
+ <step name="close_parent_artifacts">
980
+ **For decimal/polish phases only (X.Y pattern):** Close the feedback loop by resolving parent UAT and debug artifacts.
981
+
982
+ **Skip if** phase number has no decimal (e.g., `3`, `04`) — only applies to gap-closure phases like `4.1`, `03.1`.
983
+
984
+ **1. Detect decimal phase and derive parent:**
985
+ ```bash
986
+ # Check if phase_number contains a decimal
987
+ if [[ "$PHASE_NUMBER" == *.* ]]; then
988
+ PARENT_PHASE="${PHASE_NUMBER%%.*}"
989
+ fi
990
+ ```
991
+
992
+ **2. Find parent UAT file:**
993
+ ```bash
994
+ PARENT_INFO=$(node ".rihal/bin/rihal-tools.cjs" find-phase "${PARENT_PHASE}" --raw)
995
+ # Extract directory from PARENT_INFO JSON, then find UAT file in that directory
996
+ ```
997
+
998
+ **If no parent UAT found:** Skip this step (gap-closure may have been triggered by VERIFICATION.md instead).
999
+
1000
+ **3. Update UAT gap statuses:**
1001
+
1002
+ Read the parent UAT file's `## Gaps` section. For each gap entry with `status: failed`:
1003
+ - Update to `status: resolved`
1004
+
1005
+ **4. Update UAT frontmatter:**
1006
+
1007
+ If all gaps now have `status: resolved`:
1008
+ - Update frontmatter `status: diagnosed` → `status: resolved`
1009
+ - Update frontmatter `updated:` timestamp
1010
+
1011
+ **5. Resolve referenced debug sessions:**
1012
+
1013
+ For each gap that has a `debug_session:` field:
1014
+ - Read the debug session file
1015
+ - Update frontmatter `status:` → `resolved`
1016
+ - Update frontmatter `updated:` timestamp
1017
+ - Move to resolved directory:
1018
+ ```bash
1019
+ mkdir -p .planning/debug/resolved
1020
+ mv .planning/debug/{slug}.md .planning/debug/resolved/
1021
+ ```
1022
+
1023
+ **6. Commit updated artifacts:**
1024
+ ```bash
1025
+ node ".rihal/bin/rihal-tools.cjs" commit "docs(phase-${PARENT_PHASE}): resolve UAT gaps and debug sessions after ${PHASE_NUMBER} gap closure" --files .planning/phases/*${PARENT_PHASE}*/*-UAT.md .planning/debug/resolved/*.md
1026
+ ```
1027
+ </step>
1028
+
1029
+ <step name="regression_gate">
1030
+ Run prior phases' test suites to catch cross-phase regressions BEFORE verification.
1031
+
1032
+ **Skip if:** This is the first phase (no prior phases), or no prior VERIFICATION.md files exist.
1033
+
1034
+ **Step 1: Discover prior phases' test files**
1035
+ ```bash
1036
+ # Find all VERIFICATION.md files from prior phases in current milestone
1037
+ PRIOR_VERIFICATIONS=$(find .planning/phases/ -name "*-VERIFICATION.md" ! -path "*${PHASE_NUMBER}*" 2>/dev/null)
1038
+ ```
1039
+
1040
+ **Step 2: Extract test file lists from prior verifications**
1041
+
1042
+ For each VERIFICATION.md found, look for test file references:
1043
+ - Lines containing `test`, `spec`, or `__tests__` paths
1044
+ - The "Test Suite" or "Automated Checks" section
1045
+ - File patterns from `key-files.created` in corresponding SUMMARY.md files that match `*.test.*` or `*.spec.*`
1046
+
1047
+ Collect all unique test file paths into `REGRESSION_FILES`.
1048
+
1049
+ **Step 3: Run regression tests (if any found)**
1050
+
1051
+ ```bash
1052
+ # Detect test runner and run prior phase tests
1053
+ if [ -f "package.json" ]; then
1054
+ # Node.js — use project's test runner
1055
+ npx jest ${REGRESSION_FILES} --passWithNoTests --no-coverage -q 2>&1 || npx vitest run ${REGRESSION_FILES} 2>&1
1056
+ elif [ -f "Cargo.toml" ]; then
1057
+ cargo test 2>&1
1058
+ elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
1059
+ python -m pytest ${REGRESSION_FILES} -q --tb=short 2>&1
1060
+ fi
1061
+ ```
1062
+
1063
+ **Step 4: Report results**
1064
+
1065
+ If all tests pass:
1066
+ ```
1067
+ ✓ Regression gate: {N} prior-phase test files passed — no regressions detected
1068
+ ```
1069
+ → Proceed to verify_phase_goal
1070
+
1071
+ If any tests fail:
1072
+ ```
1073
+ ## ⚠ Cross-Phase Regression Detected
1074
+
1075
+ Phase {X} execution may have broken functionality from prior phases.
1076
+
1077
+ | Test File | Phase | Status | Detail |
1078
+ |-----------|-------|--------|--------|
1079
+ | {file} | {origin_phase} | FAILED | {first_failure_line} |
1080
+
1081
+ Options:
1082
+ 1. Fix regressions before verification (recommended)
1083
+ 2. Continue to verification anyway (regressions will compound)
1084
+ 3. Abort phase — roll back and re-plan
1085
+ ```
1086
+
1087
+ Use AskUserQuestion to present the options.
1088
+ </step>
1089
+
1090
+ <step name="schema_drift_gate">
1091
+ Post-execution schema drift detection. Catches false-positive verification where
1092
+ build/types pass because TypeScript types come from config, not the live database.
1093
+
1094
+ **Run after execution completes but BEFORE verification marks success.**
1095
+
1096
+ ```bash
1097
+ SCHEMA_DRIFT=$(node ".rihal/bin/rihal-tools.cjs" verify schema-drift "${PHASE_NUMBER}" 2>/dev/null)
1098
+ ```
1099
+
1100
+ Parse JSON result for: `drift_detected`, `blocking`, `schema_files`, `orms`, `unpushed_orms`, `message`.
1101
+
1102
+ **If `drift_detected` is false:** Skip to verify_phase_goal.
1103
+
1104
+ **If `drift_detected` is true AND `blocking` is true:**
1105
+
1106
+ Check for override:
1107
+ ```bash
1108
+ SKIP_SCHEMA=$(echo "${Rihal_SKIP_SCHEMA_CHECK:-false}")
1109
+ ```
1110
+
1111
+ **If `SKIP_SCHEMA` is `true`:**
1112
+
1113
+ Display:
1114
+ ```
1115
+ ⚠ Schema drift detected but Rihal_SKIP_SCHEMA_CHECK=true — bypassing gate.
1116
+
1117
+ Schema files changed: {schema_files}
1118
+ ORMs requiring push: {unpushed_orms}
1119
+
1120
+ Proceeding to verification (database may be out of sync).
1121
+ ```
1122
+ → Continue to verify_phase_goal.
1123
+
1124
+ **If `SKIP_SCHEMA` is not `true`:**
1125
+
1126
+ BLOCK verification. Display:
1127
+
1128
+ ```
1129
+ ## BLOCKED: Schema Drift Detected
1130
+
1131
+ Schema-relevant files changed during this phase but no database push command
1132
+ was executed. Build and type checks pass because TypeScript types come from
1133
+ config, not the live database — verification would produce a false positive.
1134
+
1135
+ Schema files changed: {schema_files}
1136
+ ORMs requiring push: {unpushed_orms}
1137
+
1138
+ Required push commands:
1139
+ {For each unpushed ORM, show the push command from the message}
1140
+
1141
+ Options:
1142
+ 1. Run push command now (recommended) — execute the push, then re-verify
1143
+ 2. Skip schema check (Rihal_SKIP_SCHEMA_CHECK=true) — bypass this gate
1144
+ 3. Abort — stop execution and investigate
1145
+ ```
1146
+
1147
+ If `TEXT_MODE` is true, present as a plain-text numbered list. Otherwise use AskUserQuestion.
1148
+
1149
+ **If user selects option 1:** Present the specific push command(s) to run. After user confirms execution, re-run the schema drift check. If it passes, continue to verify_phase_goal.
1150
+
1151
+ **If user selects option 2:** Set override and continue to verify_phase_goal.
1152
+
1153
+ **If user selects option 3:** Stop execution. Report partial completion.
1154
+ </step>
1155
+
1156
+ <step name="verify_phase_goal">
1157
+ Verify phase achieved its GOAL, not just completed tasks.
1158
+
1159
+ ```bash
1160
+ VERIFIER_SKILLS=$(node ".rihal/bin/rihal-tools.cjs" agent-skills rihal-verifier 2>/dev/null)
1161
+ ```
1162
+
1163
+ ```
1164
+ Task(
1165
+ description="Verify phase {phase_number} goal achievement",
1166
+ prompt="Verify phase {phase_number} goal achievement.
1167
+ Phase directory: {phase_dir}
1168
+ Phase goal: {goal from ROADMAP.md}
1169
+ Phase requirement IDs: {phase_req_ids}
1170
+ Check must_haves against actual codebase.
1171
+ Cross-reference requirement IDs from PLAN frontmatter against REQUIREMENTS.md — every ID MUST be accounted for.
1172
+ Create VERIFICATION.md.
1173
+
1174
+ <files_to_read>
1175
+ Read these files before verification:
1176
+ - {phase_dir}/*-SPRINT.md (All plans — understand intent, check must_haves)
1177
+ - {phase_dir}/*-SUMMARY.md (All summaries — cross-reference claimed vs actual)
1178
+ - .planning/REQUIREMENTS.md (Requirement traceability)
1179
+ ${CONTEXT_WINDOW >= 500000 ? `- {phase_dir}/*-CONTEXT.md (User decisions — verify they were honored)
1180
+ - {phase_dir}/*-RESEARCH.md (Known pitfalls — check for traps)
1181
+ - Prior VERIFICATION.md files from earlier phases (regression check)
1182
+ ` : ''}
1183
+ </files_to_read>
1184
+
1185
+ ${VERIFIER_SKILLS}",
1186
+ subagent_type="rihal-verifier",
1187
+ model="{verifier_model}"
1188
+ )
1189
+ ```
1190
+
1191
+ Read status:
1192
+ ```bash
1193
+ grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
1194
+ ```
1195
+
1196
+ | Status | Action |
1197
+ |--------|--------|
1198
+ | `passed` | → update_roadmap |
1199
+ | `human_needed` | Present items for human testing, get approval or feedback |
1200
+ | `gaps_found` | Present gap summary, offer `/rihal:plan {phase} --gaps ${Rihal_WS}` |
1201
+
1202
+ **If human_needed:**
1203
+
1204
+ **Step A: Persist human verification items as UAT file.**
1205
+
1206
+ Create `{phase_dir}/{phase_num}-HUMAN-UAT.md` using UAT template format:
1207
+
1208
+ ```markdown
1209
+ ---
1210
+ status: partial
1211
+ phase: {phase_num}-{phase_name}
1212
+ source: [{phase_num}-VERIFICATION.md]
1213
+ started: [now ISO]
1214
+ updated: [now ISO]
1215
+ ---
1216
+
1217
+ ## Current Test
1218
+
1219
+ [awaiting human testing]
1220
+
1221
+ ## Tests
1222
+
1223
+ {For each human_verification item from VERIFICATION.md:}
1224
+
1225
+ ### {N}. {item description}
1226
+ expected: {expected behavior from VERIFICATION.md}
1227
+ result: [pending]
1228
+
1229
+ ## Summary
1230
+
1231
+ total: {count}
1232
+ passed: 0
1233
+ issues: 0
1234
+ pending: {count}
1235
+ skipped: 0
1236
+ blocked: 0
1237
+
1238
+ ## Gaps
1239
+ ```
1240
+
1241
+ Commit the file:
1242
+ ```bash
1243
+ node ".rihal/bin/rihal-tools.cjs" commit "test({phase_num}): persist human verification items as UAT" --files "{phase_dir}/{phase_num}-HUMAN-UAT.md"
1244
+ ```
1245
+
1246
+ **Step B: Present to user:**
1247
+
1248
+ ```
1249
+ ## ✓ Phase {X}: {Name} — Human Verification Required
1250
+
1251
+ All automated checks passed. {N} items need human testing:
1252
+
1253
+ {From VERIFICATION.md human_verification section}
1254
+
1255
+ Items saved to `{phase_num}-HUMAN-UAT.md` — they will appear in `/rihal:progress` and `/rihal:audit-uat`.
1256
+
1257
+ "approved" → continue | Report issues → gap closure
1258
+ ```
1259
+
1260
+ **If user says "approved":** Proceed to `update_roadmap`. The HUMAN-UAT.md file persists with `status: partial` and will surface in future progress checks until the user runs `/rihal:verify-work` on it.
1261
+
1262
+ **If user reports issues:** Proceed to gap closure as currently implemented.
1263
+
1264
+ **If gaps_found:**
1265
+ ```
1266
+ ## ⚠ Phase {X}: {Name} — Gaps Found
1267
+
1268
+ **Score:** {N}/{M} must-haves verified
1269
+ **Report:** {phase_dir}/{phase_num}-VERIFICATION.md
1270
+
1271
+ ### What's Missing
1272
+ {Gap summaries from VERIFICATION.md}
1273
+
1274
+ ---
1275
+ ## ▶ Next Up
1276
+
1277
+ `/clear` then:
1278
+
1279
+ `/rihal:plan {X} --gaps ${Rihal_WS}`
1280
+
1281
+ Also: `cat {phase_dir}/{phase_num}-VERIFICATION.md` — full report
1282
+ Also: `/rihal:verify-work {X} ${Rihal_WS}` — manual testing first
1283
+ ```
1284
+
1285
+ Gap closure cycle: `/rihal:plan {X} --gaps ${Rihal_WS}` reads VERIFICATION.md → creates gap plans with `gap_closure: true` → user runs `/rihal:execute {X} --gaps-only ${Rihal_WS}` → verifier re-runs.
1286
+ </step>
1287
+
1288
+ <step name="update_roadmap">
1289
+ **Mark phase complete and update all tracking files:**
1290
+
1291
+ ```bash
1292
+ COMPLETION=$(node ".rihal/bin/rihal-tools.cjs" phase complete "${PHASE_NUMBER}")
1293
+ ```
1294
+
1295
+ The CLI handles:
1296
+ - Marking phase checkbox `[x]` with completion date
1297
+ - Updating Progress table (Status → Complete, date)
1298
+ - Updating plan count to final
1299
+ - Advancing STATE.md to next phase
1300
+ - Updating REQUIREMENTS.md traceability
1301
+ - Scanning for verification debt (returns `warnings` array)
1302
+
1303
+ Extract from result: `next_phase`, `next_phase_name`, `is_last_phase`, `warnings`, `has_warnings`.
1304
+
1305
+ **If has_warnings is true:**
1306
+ ```
1307
+ ## Phase {X} marked complete with {N} warnings:
1308
+
1309
+ {list each warning}
1310
+
1311
+ These items are tracked and will appear in `/rihal:progress` and `/rihal:audit-uat`.
1312
+ ```
1313
+
1314
+ ```bash
1315
+ node ".rihal/bin/rihal-tools.cjs" commit "docs(phase-{X}): complete phase execution" --files .planning/ROADMAP.md .planning/STATE.md .planning/REQUIREMENTS.md {phase_dir}/*-VERIFICATION.md
1316
+ ```
1317
+ </step>
1318
+
1319
+ <step name="auto_copy_learnings">
1320
+ **Auto-copy phase learnings to global store (when enabled).**
1321
+
1322
+ This step runs AFTER phase completion and SUMMARY.md is written. It copies any LEARNINGS.md
1323
+ entries from the completed phase to the global learnings store at `.rihal/knowledge/`.
1324
+
1325
+ **Check config gate:**
1326
+ ```bash
1327
+ GL_ENABLED=$(node ".rihal/bin/rihal-tools.cjs" config-get features.global_learnings --raw 2>/dev/null || echo "false")
1328
+ ```
1329
+
1330
+ **If `GL_ENABLED` is not `true`:** Skip this step entirely (feature disabled by default).
1331
+
1332
+ **If enabled:**
1333
+
1334
+ 1. Check if LEARNINGS.md exists in the phase directory (use the `phase_dir` value from init context)
1335
+ 2. If found, copy to global store:
1336
+ ```bash
1337
+ node ".rihal/bin/rihal-tools.cjs" learnings copy 2>/dev/null || echo "⚠ Learnings copy failed — continuing"
1338
+ ```
1339
+ Copy failure must NOT block phase completion.
1340
+ </step>
1341
+
1342
+ <step name="update_project_md">
1343
+ **Evolve PROJECT.md to reflect phase completion (prevents planning document drift — #956):**
1344
+
1345
+ PROJECT.md tracks validated requirements, decisions, and current state. Without this step,
1346
+ PROJECT.md falls behind silently over multiple phases.
1347
+
1348
+ 1. Read `.planning/PROJECT.md`
1349
+ 2. If the file exists and has a `## Validated Requirements` or `## Requirements` section:
1350
+ - Move any requirements validated by this phase from Active → Validated
1351
+ - Add a brief note: `Validated in Phase {X}: {Name}`
1352
+ 3. If the file has a `## Current State` or similar section:
1353
+ - Update it to reflect this phase's completion (e.g., "Phase {X} complete — {one-liner}")
1354
+ 4. Update the `Last updated:` footer to today's date
1355
+ 5. Commit the change:
1356
+
1357
+ ```bash
1358
+ node ".rihal/bin/rihal-tools.cjs" commit "docs(phase-{X}): evolve PROJECT.md after phase completion" --files .planning/PROJECT.md
1359
+ ```
1360
+
1361
+ **Skip this step if** `.planning/PROJECT.md` does not exist.
1362
+ </step>
1363
+
1364
+ <step name="notify_on_completion">
1365
+ **Post phase completion to configured webhooks (Slack / Discord / MS Teams).**
1366
+
1367
+ Silent no-op if no webhook URLs are in `.rihal/config.yaml`. Failures are reported but never block the workflow.
1368
+
1369
+ ```bash
1370
+ node ".rihal/bin/rihal-tools.cjs" notify send \
1371
+ --title "Phase ${phase_number} complete — ${phase_name}" \
1372
+ --body "$(basename "$PWD") · $(git rev-parse --short HEAD) · ${incomplete_count:-0} plan(s) remaining" \
1373
+ --event "execute-done" 2>/dev/null || true
1374
+ ```
1375
+
1376
+ Users configure webhooks by editing `.rihal/config.yaml`:
1377
+
1378
+ ```yaml
1379
+ slack_webhook_url: "https://hooks.slack.com/services/..."
1380
+ discord_webhook_url: "https://discord.com/api/webhooks/..."
1381
+ teams_webhook_url: "https://outlook.office.com/webhook/..."
1382
+ ```
1383
+
1384
+ Then verify with `/rihal:notify-test`.
1385
+ </step>
1386
+
1387
+ <step name="offer_next">
1388
+
1389
+ **Exception:** If `gaps_found`, the `verify_phase_goal` step already presents the gap-closure path (`/rihal:plan {X} --gaps`). No additional routing needed — skip auto-advance.
1390
+
1391
+ **No-transition check (spawned by auto-advance chain):**
1392
+
1393
+ Parse `--no-transition` flag from $ARGUMENTS.
1394
+
1395
+ **If `--no-transition` flag present:**
1396
+
1397
+ Execute-phase was spawned by plan's auto-advance. Do NOT run transition.md.
1398
+ After verification passes and roadmap is updated, return completion status to parent:
1399
+
1400
+ ```
1401
+ ## PHASE COMPLETE
1402
+
1403
+ Phase: ${PHASE_NUMBER} - ${PHASE_NAME}
1404
+ Plans: ${completed_count}/${total_count}
1405
+ Verification: {Passed | Gaps Found}
1406
+
1407
+ [Include aggregate_results output]
1408
+ ```
1409
+
1410
+ STOP. Do not proceed to auto-advance or transition.
1411
+
1412
+ **If `--no-transition` flag is NOT present:**
1413
+
1414
+ **Auto-advance detection:**
1415
+
1416
+ 1. Parse `--auto` flag from $ARGUMENTS
1417
+ 2. Read both the chain flag and user preference (chain flag already synced in init step):
1418
+ ```bash
1419
+ AUTO_CHAIN=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
1420
+ AUTO_CFG=$(node ".rihal/bin/rihal-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
1421
+ ```
1422
+
1423
+ **If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true (AND verification passed with no gaps):**
1424
+
1425
+ ```
1426
+ ╔══════════════════════════════════════════╗
1427
+ ║ AUTO-ADVANCING → TRANSITION ║
1428
+ ║ Phase {X} verified, continuing chain ║
1429
+ ╚══════════════════════════════════════════╝
1430
+ ```
1431
+
1432
+ Execute the transition workflow inline (do NOT use Task — orchestrator context is ~10-15%, transition needs phase completion data already in context):
1433
+
1434
+ Read and follow `.rihal/workflows/transition.md`, passing through the `--auto` flag so it propagates to the next phase invocation.
1435
+
1436
+ **If none of `--auto`, `AUTO_CHAIN`, or `AUTO_CFG` is true:**
1437
+
1438
+ **STOP. Do not auto-advance. Do not execute transition. Do not plan next phase. Present options to the user and wait.**
1439
+
1440
+ **IMPORTANT: There is NO `/rihal:transition` command. Never suggest it. The transition workflow is internal only.**
1441
+
1442
+ ```
1443
+ ## ✓ Phase {X}: {Name} Complete
1444
+
1445
+ /rihal:progress ${Rihal_WS} — see updated roadmap
1446
+ /rihal:discuss-phase {next} ${Rihal_WS} — discuss next phase before planning
1447
+ /rihal:plan {next} ${Rihal_WS} — plan next phase
1448
+ /rihal:execute {next} ${Rihal_WS} — execute next phase
1449
+ ```
1450
+
1451
+ Only suggest the commands listed above. Do not invent or hallucinate command names.
1452
+ </step>
1453
+
1454
+ </process>
1455
+
1456
+ <context_efficiency>
1457
+ Orchestrator: ~10-15% context for 200k windows, can use more for 1M+ windows.
1458
+ Subagents: fresh context each (200k-1M depending on model). No polling (Task blocks). No context bleed.
1459
+
1460
+ For 1M+ context models, consider:
1461
+ - Passing richer context (code snippets, dependency outputs) directly to executors instead of just file paths
1462
+ - Running small phases (≤3 plans, no dependencies) inline without subagent spawning overhead
1463
+ - Relaxing /clear recommendations — context rot onset is much further out with 5x window
1464
+ </context_efficiency>
1465
+
1466
+ <failure_handling>
1467
+ - **classifyHandoffIfNeeded false failure:** Agent reports "failed" but error is `classifyHandoffIfNeeded is not defined` → Claude Code bug, not Rihal. Spot-check (SUMMARY exists, commits present) → if pass, treat as success
1468
+ - **Agent fails mid-plan:** Missing SUMMARY.md → report, ask user how to proceed
1469
+ - **Dependency chain breaks:** Wave 1 fails → Wave 2 dependents likely fail → user chooses attempt or skip
1470
+ - **All agents in wave fail:** Systemic issue → stop, report for investigation
1471
+ - **Checkpoint unresolvable:** "Skip this plan?" or "Abort phase execution?" → record partial progress in STATE.md
1472
+ </failure_handling>
1473
+
1474
+ <resumption>
1475
+ Re-run `/rihal:execute {phase}` → discover_plans finds completed SUMMARYs → skips them → resumes from first incomplete plan → continues wave execution.
1476
+
1477
+ STATE.md tracks: last completed plan, current wave, pending checkpoints.
1478
+ </resumption>