@hanzlaa/rcode 3.4.3 → 3.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/AGENTS.md +1 -1
  2. package/CONTRIBUTING.md +63 -1
  3. package/README.md +9 -4
  4. package/cli/generate-command-skills.cjs +5 -5
  5. package/cli/index.js +0 -0
  6. package/cli/install.js +128 -3
  7. package/cli/lib/manifest.cjs +1 -1
  8. package/cli/uninstall.js +8 -0
  9. package/dist/rcode.js +19 -1
  10. package/package.json +16 -17
  11. package/rihal/agents/rihal-ahmed.md +2 -1
  12. package/rihal/agents/rihal-code-fixer.md +46 -0
  13. package/rihal/agents/rihal-code-reviewer.md +46 -1
  14. package/rihal/agents/rihal-deviation-analyzer.md +1 -0
  15. package/rihal/agents/rihal-docs-auditor.md +106 -1
  16. package/rihal/agents/rihal-edge-case-hunter.md +47 -1
  17. package/rihal/agents/rihal-executor.md +1 -1
  18. package/rihal/agents/rihal-khalid.md +40 -1
  19. package/rihal/agents/rihal-layla.md +2 -1
  20. package/rihal/agents/rihal-nasser.md +2 -1
  21. package/rihal/agents/rihal-noor.md +3 -2
  22. package/rihal/agents/rihal-nyquist-auditor.md +1 -1
  23. package/rihal/agents/rihal-phase-researcher.md +46 -1
  24. package/rihal/agents/rihal-planner.md +1 -1
  25. package/rihal/agents/rihal-profiler.md +45 -2
  26. package/rihal/agents/rihal-project-researcher.md +47 -0
  27. package/rihal/agents/rihal-remediation-planner.md +45 -0
  28. package/rihal/agents/rihal-roadmapper.md +46 -0
  29. package/rihal/agents/rihal-security-adversary.md +46 -1
  30. package/rihal/agents/rihal-security-auditor.md +45 -1
  31. package/rihal/agents/rihal-ui-auditor.md +44 -1
  32. package/rihal/agents/rihal-ux-designer.md +41 -1
  33. package/rihal/agents/rihal-zahra.md +2 -1
  34. package/rihal/agents/rihal-zayd.md +2 -1
  35. package/rihal/bin/lib/config.cjs +13 -1
  36. package/rihal/bin/lib/council-panel.cjs +185 -23
  37. package/rihal/bin/lib/roadmap.cjs +27 -2
  38. package/rihal/bin/rihal-tools.cjs +1837 -99
  39. package/rihal/commands/audit.md +2 -2
  40. package/rihal/commands/capture.md +12 -0
  41. package/rihal/commands/diagnose-issues.md +18 -0
  42. package/rihal/commands/discuss-phase-power.md +18 -0
  43. package/rihal/commands/feature-drift.md +18 -0
  44. package/rihal/commands/karpathy-audit.md +18 -0
  45. package/rihal/commands/lens-audit.md +70 -0
  46. package/rihal/commands/new-project-research.md +18 -0
  47. package/rihal/commands/new-project-roadmap.md +18 -0
  48. package/rihal/commands/phase.md +11 -0
  49. package/rihal/references/continuation-format.md +3 -3
  50. package/rihal/references/output-format.md +79 -0
  51. package/rihal/references/revision-loop.md +1 -1
  52. package/rihal/references/verb-dictionary.md +85 -28
  53. package/rihal/skills/actions/1-analysis/rihal-prfaq/SKILL.md +1 -1
  54. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/SKILL.md +12 -2
  55. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/steps/step-04-final-validation.md +12 -0
  56. package/rihal/skills/actions/2-plan/rihal-create-prd/SKILL.md +12 -2
  57. package/rihal/skills/actions/2-plan/rihal-create-story/SKILL.md +12 -2
  58. package/rihal/skills/actions/4-implementation/rihal-browser-verify/SKILL.md +1 -1
  59. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/SKILL.md +1 -1
  60. package/rihal/skills/actions/4-implementation/rihal-ci/SKILL.md +1 -1
  61. package/rihal/skills/actions/4-implementation/rihal-code-review/SKILL.md +16 -4
  62. package/rihal/skills/actions/4-implementation/rihal-debug/SKILL.md +14 -1
  63. package/rihal/skills/actions/4-implementation/rihal-git-flow/SKILL.md +1 -1
  64. package/rihal/skills/actions/4-implementation/rihal-harden/SKILL.md +1 -1
  65. package/rihal/skills/actions/4-implementation/rihal-incremental/SKILL.md +1 -1
  66. package/rihal/skills/actions/4-implementation/rihal-migrate/SKILL.md +1 -1
  67. package/rihal/skills/actions/4-implementation/rihal-perf/SKILL.md +1 -1
  68. package/rihal/skills/actions/4-implementation/rihal-prove-it/SKILL.md +1 -1
  69. package/rihal/skills/actions/4-implementation/rihal-scaffold-project/steps/step-01-target.md +6 -0
  70. package/rihal/skills/actions/4-implementation/rihal-source-truth/SKILL.md +1 -1
  71. package/rihal/skills/actions/4-implementation/rihal-sprint-planning/SKILL.md +14 -3
  72. package/rihal/skills/actions/4-implementation/rihal-trim/SKILL.md +1 -1
  73. package/rihal/skills/agents/ahmed-hassani-director/SKILL.md +15 -1
  74. package/rihal/skills/agents/dalil-scout/SKILL.md +14 -2
  75. package/rihal/skills/agents/fatima-qa/SKILL.md +16 -1
  76. package/rihal/skills/agents/haitham-frontend/SKILL.md +13 -1
  77. package/rihal/skills/agents/hanzla-engineer/SKILL.md +13 -1
  78. package/rihal/skills/agents/hussain-pm/SKILL.md +16 -1
  79. package/rihal/skills/agents/hussain-sm/SKILL.md +14 -1
  80. package/rihal/skills/agents/layla-designer/SKILL.md +13 -1
  81. package/rihal/skills/agents/majlis-council/SKILL.md +16 -1
  82. package/rihal/skills/agents/mariam-marketing/SKILL.md +14 -1
  83. package/rihal/skills/agents/nasser-eng-manager/SKILL.md +16 -1
  84. package/rihal/skills/agents/noor-writer/SKILL.md +15 -1
  85. package/rihal/skills/agents/raees-orchestrator/SKILL.md +15 -1
  86. package/rihal/skills/agents/rihal-cross-platform-auditor/SKILL.md +162 -0
  87. package/rihal/skills/agents/rihal-dep-auditor/SKILL.md +151 -0
  88. package/rihal/skills/agents/rihal-deviation-analyzer/SKILL.md +78 -0
  89. package/rihal/skills/agents/rihal-i18n-auditor/SKILL.md +152 -0
  90. package/rihal/skills/agents/rihal-observability-auditor/SKILL.md +156 -0
  91. package/rihal/skills/agents/sadiq-analyst/SKILL.md +12 -2
  92. package/rihal/skills/agents/waleed-architect/SKILL.md +12 -2
  93. package/rihal/skills/agents/yousef-backend/SKILL.md +12 -2
  94. package/rihal/skills/agents/zahra-branding/SKILL.md +15 -1
  95. package/rihal/skills/agents/zayd-ml/SKILL.md +13 -1
  96. package/rihal/skills/core/rihal-advanced-elicitation/SKILL.md +2 -2
  97. package/rihal/skills/core/rihal-auth-audit/SKILL.md +1 -1
  98. package/rihal/skills/core/rihal-brainstorming/SKILL.md +13 -2
  99. package/rihal/skills/core/rihal-client-gate/SKILL.md +1 -1
  100. package/rihal/skills/core/rihal-clone-website/SKILL.md +11 -1
  101. package/rihal/skills/core/rihal-deploy-unify/SKILL.md +1 -1
  102. package/rihal/skills/core/rihal-distillator/SKILL.md +2 -2
  103. package/rihal/skills/core/rihal-editorial-review-prose/SKILL.md +1 -1
  104. package/rihal/skills/core/rihal-editorial-review-structure/SKILL.md +2 -2
  105. package/rihal/skills/core/rihal-help/SKILL.md +18 -1
  106. package/rihal/skills/core/rihal-incident-record/SKILL.md +1 -1
  107. package/rihal/skills/core/rihal-index-docs/SKILL.md +1 -1
  108. package/rihal/skills/core/rihal-memory-audit/SKILL.md +18 -1
  109. package/rihal/skills/core/rihal-memory-init/SKILL.md +13 -1
  110. package/rihal/skills/core/rihal-memory-update/SKILL.md +13 -1
  111. package/rihal/skills/core/rihal-mvp-graduate/SKILL.md +1 -1
  112. package/rihal/skills/core/rihal-ocr-consistency/SKILL.md +1 -1
  113. package/rihal/skills/core/rihal-rebrand/SKILL.md +1 -1
  114. package/rihal/skills/core/rihal-review-adversarial-general/SKILL.md +1 -1
  115. package/rihal/skills/core/rihal-review-edge-case-hunter/SKILL.md +17 -1
  116. package/rihal/skills/core/rihal-shard-doc/SKILL.md +1 -1
  117. package/rihal/skills/core/rihal-theme-system/SKILL.md +1 -1
  118. package/rihal/team.yaml +0 -7
  119. package/rihal/templates/RESEARCH.md +84 -0
  120. package/rihal/templates/VALIDATION.md +45 -0
  121. package/rihal/templates/memory/INDEX.md +1 -0
  122. package/rihal/templates/memory/project/design-system.md +128 -0
  123. package/rihal/templates/summary.md +33 -3
  124. package/rihal/workflows/add-tests.md +1 -1
  125. package/rihal/workflows/add-todo.md +6 -0
  126. package/rihal/workflows/analyze-dependencies.md +6 -0
  127. package/rihal/workflows/audit-fix.md +12 -0
  128. package/rihal/workflows/audit-milestone.md +2 -2
  129. package/rihal/workflows/audit.md +23 -14
  130. package/rihal/workflows/autonomous-smart-discuss.md +247 -0
  131. package/rihal/workflows/autonomous.md +54 -267
  132. package/rihal/workflows/capture.md +60 -0
  133. package/rihal/workflows/chain.md +1 -1
  134. package/rihal/workflows/code-review-fix.md +6 -3
  135. package/rihal/workflows/code-review.md +34 -10
  136. package/rihal/workflows/complete-milestone.md +17 -8
  137. package/rihal/workflows/correct-course.md +6 -0
  138. package/rihal/workflows/council.md +37 -23
  139. package/rihal/workflows/create-architecture.md +31 -0
  140. package/rihal/workflows/create-epics-and-stories.md +7 -1
  141. package/rihal/workflows/create-prd.md +25 -0
  142. package/rihal/workflows/dashboard.md +1 -1
  143. package/rihal/workflows/debug.md +8 -0
  144. package/rihal/workflows/decisions.md +1 -1
  145. package/rihal/workflows/diff.md +6 -0
  146. package/rihal/workflows/discuss-phase-discuss-areas.md +271 -0
  147. package/rihal/workflows/discuss-phase.md +27 -266
  148. package/rihal/workflows/do.md +51 -12
  149. package/rihal/workflows/docs-update.md +3 -0
  150. package/rihal/workflows/document-project.md +7 -1
  151. package/rihal/workflows/edit-prd.md +31 -0
  152. package/rihal/workflows/enable-hooks.md +1 -1
  153. package/rihal/workflows/execute-regression-gates.md +131 -0
  154. package/rihal/workflows/execute-sprint.md +31 -2
  155. package/rihal/workflows/execute-verify-phase-goal.md +136 -0
  156. package/rihal/workflows/execute-waves.md +404 -0
  157. package/rihal/workflows/execute.md +101 -642
  158. package/rihal/workflows/feature-drift.md +243 -0
  159. package/rihal/workflows/forensics.md +10 -2
  160. package/rihal/workflows/health.md +65 -16
  161. package/rihal/workflows/help.md +36 -9
  162. package/rihal/workflows/import.md +17 -3
  163. package/rihal/workflows/init.md +20 -10
  164. package/rihal/workflows/install.md +2 -10
  165. package/rihal/workflows/lens-audit.md +689 -0
  166. package/rihal/workflows/map-codebase.md +7 -1
  167. package/rihal/workflows/memory-audit.md +67 -5
  168. package/rihal/workflows/memory-distill.md +10 -0
  169. package/rihal/workflows/memory-init.md +4 -0
  170. package/rihal/workflows/memory-update.md +4 -0
  171. package/rihal/workflows/new-milestone.md +7 -1
  172. package/rihal/workflows/new-project-create-roadmap.md +176 -0
  173. package/rihal/workflows/new-project-define-requirements.md +160 -0
  174. package/rihal/workflows/new-project-research-decision.md +247 -0
  175. package/rihal/workflows/new-project.md +3 -557
  176. package/rihal/workflows/note.md +1 -1
  177. package/rihal/workflows/phase.md +54 -0
  178. package/rihal/workflows/plan-milestone-gaps.md +1 -1
  179. package/rihal/workflows/plan-prd-express.md +108 -0
  180. package/rihal/workflows/plan-research-validation.md +313 -0
  181. package/rihal/workflows/plan-spawn-planner.md +204 -0
  182. package/rihal/workflows/plan.md +91 -532
  183. package/rihal/workflows/plant-seed.md +1 -1
  184. package/rihal/workflows/pr-branch.md +1 -1
  185. package/rihal/workflows/profile-user.md +1 -1
  186. package/rihal/workflows/quick.md +3 -3
  187. package/rihal/workflows/remove-phase.md +6 -1
  188. package/rihal/workflows/remove-workspace.md +6 -0
  189. package/rihal/workflows/rerun.md +1 -1
  190. package/rihal/workflows/research-phase.md +4 -2
  191. package/rihal/workflows/resume-work.md +8 -3
  192. package/rihal/workflows/retrospective.md +31 -0
  193. package/rihal/workflows/review-adversarial.md +12 -0
  194. package/rihal/workflows/review.md +6 -0
  195. package/rihal/workflows/scaffold-project.md +31 -0
  196. package/rihal/workflows/scan.md +10 -0
  197. package/rihal/workflows/secure-phase.md +15 -2
  198. package/rihal/workflows/session-report.md +32 -7
  199. package/rihal/workflows/ship.md +7 -2
  200. package/rihal/workflows/show.md +6 -0
  201. package/rihal/workflows/sprint-status.md +4 -4
  202. package/rihal/workflows/status.md +2 -2
  203. package/rihal/workflows/ui-phase.md +1 -1
  204. package/rihal/workflows/undo.md +2 -3
  205. package/rihal/workflows/update.md +2 -2
  206. package/rihal/workflows/validate-phase.md +1 -1
  207. package/rihal/workflows/validate-prd.md +31 -0
  208. package/rihal/workflows/verify-phase.md +38 -5
  209. package/rihal/workflows/verify-work.md +25 -11
  210. package/rihal/workflows/workstream.md +20 -8
  211. package/server/lib/html/client.js +13 -63
  212. package/server/lib/html/shell.js +0 -1
  213. package/server/lib/scanner.js +33 -2
@@ -5,6 +5,7 @@ Analyze freeform text from the user and route to the most appropriate Rihal comm
5
5
  <required_reading>
6
6
  @.rihal/references/output-format.md
7
7
  @.rihal/references/verb-dictionary.md
8
+ @.rihal/references/dispatch-banner.md
8
9
  Read all files referenced by the invoking prompt's execution_context before starting.
9
10
  </required_reading>
10
11
 
@@ -137,7 +138,7 @@ Apply this guard BEFORE the routing table below:
137
138
  | Intent contains... | AND state shows... | Then re-route to... | Why |
138
139
  |--------------------|---------------------|----------------------|-----|
139
140
  | "draft phases", "all phases", "build all phases", "groom phases", "auto mode" + "phases" | `HAS_PRD=false` | `/rihal-create-prd` first | Phases need a PRD foundation. Without one, the autonomous flow hallucinates requirements. |
140
- | "execute phase", "build phase N", "run phase N" | `HAS_PHASES=false` OR PLAN.md missing for phase N | `/rihal-plan N` first (or `/rihal-create-prd` if no PRD) | Can't execute what hasn't been planned. |
141
+ | "execute phase", "build phase N", "run phase N" | `HAS_PHASES=false` OR SPRINT.md missing for phase N | `/rihal-plan N` first (or `/rihal-create-prd` if no PRD) | Can't execute what hasn't been planned. |
141
142
  | "sprint planning", "plan the sprint" | `HAS_EPICS=false` | `/rihal-create-epics-and-stories` first | Sprints draw stories from epics. No epics = no stories to schedule. |
142
143
  | "create stories", "epics" | `HAS_PRD=false` | `/rihal-create-prd` first | Epics decompose a milestone. Milestone needs PRD. |
143
144
  | "create milestones", "roadmap" | `HAS_PRD=false` | `/rihal-create-prd` first | Roadmap is derived from PRD success metrics. |
@@ -298,6 +299,8 @@ Evaluate `$QUESTION` against these routing rules. Apply the **first matching** r
298
299
  | A note, idea, or "remember to..." | `/rihal-note` | Capture for later |
299
300
  | Adding tests, "write tests", "test coverage" | `/rihal-add-tests` | Test generation |
300
301
  | Completing a milestone, shipping, releasing | `/rihal-complete-milestone` | Milestone lifecycle |
302
+ | Drift / out-of-date / "verify docs vs code" / "audit feature docs" / "fill out existing PRD/epics/stories" | `/rihal-feature-drift` | Detects PRD↔epics↔stories↔code drift; --fix patches trivial items |
303
+ | General audit / re-audit / extend / fill out / expand an existing artifact | `/rihal-audit` | Unified audit entry — picks artifact type and re-runs |
301
304
  | A specific, actionable, small task (add feature, fix typo, update config) | `/rihal-quick` | Self-contained, single executor |
302
305
  | Market/discovery/greenfield question (from classify) | `/rihal-council` | Needs multi-perspective discovery |
303
306
 
@@ -307,7 +310,20 @@ If no rule matches, fall back to the classifier:
307
310
  CLASSIFY=$(node ".rihal/bin/rihal-tools.cjs" classify-question "$QUESTION")
308
311
  ```
309
312
 
310
- Parse `type` from JSON — map codebase/team/release → `/rihal-discuss`; market/discovery/greenfield → `/rihal-council`. Default: `/rihal-discuss`.
313
+ Parse `type` from JSON — map codebase/team/release → `/rihal-discuss`; market/discovery/greenfield → `/rihal-council`; drift → `/rihal-feature-drift`. Default: `/rihal-discuss`.
314
+
315
+ **No-route exit (issue #458):** If neither the routing table nor the classifier yields a confident match, you MUST STOP. Print this disambiguation menu via AskUserQuestion and wait:
316
+
317
+ ```
318
+ I can't route this cleanly. Pick one:
319
+ 1. /rihal-add-phase — if it's a new phase
320
+ 2. /rihal-plan — if scope is clear, jump to plan
321
+ 3. /rihal-discuss-phase — if you want to think through it first
322
+ 4. /rihal-audit — if you want to extend an existing audit/plan
323
+ 5. Describe more specifically what you want
324
+ ```
325
+
326
+ Do NOT execute the work yourself. Do NOT run grep, find, Read, Bash, or Write to "investigate before routing." If you feel the urge to investigate, the dispatcher contract has already failed — STOP and ask.
311
327
 
312
328
  **Requires `.planning/` directory:** All routes except `/rihal-new-project`, `/rihal-map-codebase`, `/rihal-help`, `/rihal-discuss`, `/rihal-council`. If the project doesn't exist and the route requires it, suggest `/rihal-new-project` first.
313
329
 
@@ -341,15 +357,23 @@ Reason: {one-line why}
341
357
  </step>
342
358
 
343
359
  <step name="dispatch">
344
- **Invoke the chosen command.**
360
+ **Invoke the chosen command via the Skill tool — do NOT just print it as text.**
345
361
 
346
- If `AUTO_MODE` is true OR routing is unambiguous, invoke immediately:
362
+ CRITICAL: The dispatch step is an *action*, not a *display*. You must call the `Skill` tool with `skill: "rihal-{command}"` (and `args:` for any arguments). Printing the slash-command in a code block, in a banner, or in a "Dispatching..." message is NOT dispatch it is just text rendering, and the routed command will never run. Past failure: model emitted the dispatch banner three times in a row without ever invoking the Skill tool, then stalled.
347
363
 
348
- ```
349
- /rihal-{command} {arguments}
350
- ```
364
+ Canonical form: skills are namespaced with a hyphen, e.g. `rihal-discuss-phase`, `rihal-plan`, `rihal-status`. The colon form `rihal:discuss-phase` is NOT used in this project (avoided for cross-IDE compatibility) — do not display it to users or pass it to the Skill tool.
365
+
366
+ Rules:
367
+ - One Skill tool call per `/rihal-do` invocation. Never emit the same dispatch banner twice.
368
+ - Do NOT print `/rihal-{command}` inside a fenced code block as your "action" — that is display-only.
369
+ - The routing banner from the `display` step is the ONLY user-facing summary of the dispatch. After it, the very next thing you do is the Skill tool call.
370
+
371
+ If `AUTO_MODE` is true OR routing is unambiguous:
372
+ 1. Confirm the routing banner has been shown once (from the `display` step).
373
+ 2. Immediately call the Skill tool: `Skill(skill: "rihal-{command}", args: "{arguments}")`.
374
+ 3. Stop. The dispatched command handles everything from here.
351
375
 
352
- Otherwise show suggestion and ask via AskUserQuestion:
376
+ Otherwise (ambiguous, non-auto), use AskUserQuestion to confirm:
353
377
 
354
378
  ```
355
379
  Based on your request, I'd use: /rihal-{command} {arguments}
@@ -359,22 +383,37 @@ Based on your request, I'd use: /rihal-{command} {arguments}
359
383
  3. Cancel
360
384
  ```
361
385
 
362
- If the chosen command expects a phase number and one wasn't provided in the text, extract it from context or ask via AskUserQuestion.
386
+ On "Yes" call Skill tool as above. On "Pick a different route" restart routing. On "Cancel" stop.
363
387
 
364
- After invoking the command, stop. The dispatched command handles everything from here.
388
+ If the chosen command expects a phase number and one wasn't provided in the text, extract it from context or ask via AskUserQuestion BEFORE the Skill call.
365
389
  </step>
366
390
 
367
391
  </process>
368
392
 
393
+ <guardrails>
394
+ **Hard prohibitions during /rihal-do execution (issue #458):**
395
+
396
+ - MUST NOT call Bash, Read, Grep, Glob, Write, or Edit tools. The dispatcher does not investigate, read code, or write files. Period.
397
+ - MUST NOT spawn Task / Agent / subagents. Dispatch is a Skill tool call to a routed command — nothing else.
398
+ - MUST NOT "do a quick check" before routing. If you feel the urge to grep or read a file to "figure out the right route," the dispatcher contract has already failed — STOP and use the no-route exit.
399
+ - The ONLY tools allowed inside /rihal-do are: AskUserQuestion (for disambiguation), Skill (for dispatch), and the one Bash call to the classifier (`classify-question`). Nothing else.
400
+ - If the user's input doesn't match any route and the classifier is ambiguous: invoke the no-route exit menu. Do not "be helpful" by executing the work yourself.
401
+
402
+ Why this is hard: do.md is a router. The moment it does work, two failure modes appear: (a) the work is duplicated when the user re-invokes the proper command, or (b) the work happens in the wrong context with the wrong subagent and produces inferior output. Both are worse than a 1-second routing prompt.
403
+ </guardrails>
404
+
369
405
  <success_criteria>
370
406
  - [ ] Input validated (not empty)
371
407
  - [ ] Intent matched to exactly one Rihal command
372
408
  - [ ] Ambiguity resolved via user question (if needed)
373
409
  - [ ] Scope-uncertainty signals steer to `/rihal-discuss-phase` over planning routes
374
410
  - [ ] Project existence checked for routes that require it
375
- - [ ] Routing decision displayed before dispatch
376
- - [ ] Command invoked with appropriate arguments
411
+ - [ ] Routing decision displayed before dispatch (exactly once)
412
+ - [ ] Command invoked via the Skill tool — NOT printed as text
413
+ - [ ] Dispatch banner not repeated (single emission only)
377
414
  - [ ] No work done directly — dispatcher only
415
+ - [ ] No Bash/Read/Grep/Write/Edit/Task tool calls during execution (only AskUserQuestion + Skill + classifier Bash)
416
+ - [ ] On no-route, exit cleanly with the disambiguation menu — never silently fall through to inline work
378
417
  </success_criteria>
379
418
  </content>
380
419
  </invoke>
@@ -49,6 +49,7 @@ fi
49
49
  Extract from project analysis:
50
50
  - `doc_writer_model` — model string from agent manifest (never hardcode a model name)
51
51
  - `commit_docs` — whether to commit generated files when done (read from `.planning/config.json` if exists)
52
+ - `response_language` — output language from `.rihal/config.yaml` (null = English); if set, include `Respond in {value}.` in all spawned subagent prompts
52
53
  - `existing_docs` — find all existing Markdown files with `find docs -name "*.md" 2>/dev/null`
53
54
  - `project_type` — detect from: `package.json`, `src/pages/api` or `pages/api`, `bin/` or `cli/`, `LICENSE`, `vercel.json` or `netlify.toml`, `lerna.json` or `pnpm-workspace.yaml`, `test/` or `__tests__/`
54
55
  - `doc_tooling` — detect from: `docusaurus.config.js`, `vitepress.config.js`, `mkdocs.yml`, `storybook.js`
@@ -156,6 +157,7 @@ For each doc in the queue, spawn a `rihal-noor` agent in parallel waves (up to 3
156
157
  ```
157
158
  Task(
158
159
  subagent_type="rihal-noor",
160
+ model="sonnet",
159
161
  prompt="
160
162
  Generate documentation for {doc_type}.
161
163
  Output path: {resolved_path}
@@ -178,6 +180,7 @@ For each generated doc:
178
180
  ```
179
181
  Task(
180
182
  subagent_type="rihal-docs-auditor",
183
+ model="sonnet",
181
184
  prompt="
182
185
  Verify this documentation file against the live codebase:
183
186
  Path: {resolved_path}
@@ -72,7 +72,7 @@ For each row in CSV, check if document exists and assess staleness:
72
72
  ```bash
73
73
  for doc in $(cut -d',' -f1 .rihal/documentation-requirements.csv | tail -n +2); do
74
74
  if [ -f "$doc" ]; then
75
- MTIME=$(stat -c %Y "$doc")
75
+ MTIME=$(stat -c %Y "$doc" 2>/dev/null || stat -f %m "$doc" 2>/dev/null)
76
76
  NOW=$(date +%s)
77
77
  AGE_DAYS=$(( ($NOW - $MTIME) / 86400 ))
78
78
  if [ $AGE_DAYS -gt 90 ]; then echo "STALE"; fi
@@ -178,3 +178,9 @@ If .rihal/DOCS-AUDIT.md exists, check for missing/stale docs:
178
178
  - If CSV malformed: use template
179
179
  - If audit agent fails: provide manual audit template
180
180
  - If state write fails: skip task filing, report audit only
181
+
182
+ ## ▶ Next Up
183
+
184
+ - **Documentation updated:** `/rihal-progress` — see current project state
185
+ - **Proceed to planning:** `/rihal-plan {phase}` — create executable plans
186
+ - **Review with council:** `/rihal-council {question}` — debate approach
@@ -0,0 +1,31 @@
1
+ # Workflow: rihal-edit-prd
2
+
3
+ <purpose>
4
+ Update an existing PRD with revisions or clarifications. Delegates to the rihal-edit-prd skill.
5
+ </purpose>
6
+
7
+ ## Execution
8
+
9
+ Locate and follow the installed skill:
10
+
11
+ ```bash
12
+ find .rihal/skills/actions -path "*rihal-edit-prd/workflow.md" 2>/dev/null | head -1
13
+ ```
14
+
15
+ Read and follow the workflow at that path. If the path is empty:
16
+
17
+ ```
18
+ Skill not installed — run: npx @hanzlaa/rcode install
19
+ ```
20
+
21
+ ## On Completion
22
+
23
+ /rihal-validate-prd — validate after edits
24
+ /rihal-plan — re-plan phases from the updated PRD
25
+ /rihal-create-prd — start fresh if edits are too extensive
26
+
27
+ ## ▶ Next Up
28
+
29
+ - **PRD updated:** `/rihal-validate-prd` — check completeness after changes
30
+ - **Ready to plan:** `/rihal-create-milestone` — build milestone roadmap from PRD
31
+ - **Review epics:** `/rihal-create-epics-and-stories` — update stories if scope changed
@@ -62,7 +62,7 @@ Verify that the hook binary exists and is executable:
62
62
  ```bash
63
63
  if [ ! -f .rihal/bin/rihal-hooks.cjs ]; then
64
64
  echo "⚠ Hook binary missing at .rihal/bin/rihal-hooks.cjs"
65
- echo " Run: node /tmp/rihal-src/cli/install-v2.js . --force --yes"
65
+ echo " Run: npx @hanzlaa/rcode install --force --yes"
66
66
  exit 1
67
67
  fi
68
68
  node .rihal/bin/rihal-hooks.cjs --help 2>&1 || true
@@ -0,0 +1,131 @@
1
+ <purpose>
2
+ Sub-steps of execute.md — regression_gate and schema_drift_gate. Runs post-execution regression checks and schema drift detection before advancing to verification.
3
+ </purpose>
4
+
5
+ <step name="regression_gate">
6
+ Run prior phases' test suites to catch cross-phase regressions BEFORE verification.
7
+
8
+ **Skip if:** This is the first phase (no prior phases), or no prior VERIFICATION.md files exist.
9
+
10
+ **Step 1: Discover prior phases' test files**
11
+ ```bash
12
+ # Find all VERIFICATION.md files from prior phases in current milestone
13
+ PRIOR_VERIFICATIONS=$(find .planning/phases/ -name "*-VERIFICATION.md" ! -path "*${PHASE_NUMBER}*" 2>/dev/null | sort | tail -5)
14
+ ```
15
+
16
+ **Step 2: Extract test file lists from prior verifications**
17
+
18
+ For each VERIFICATION.md found, look for test file references:
19
+ - Lines containing `test`, `spec`, or `__tests__` paths
20
+ - The "Test Suite" or "Automated Checks" section
21
+ - File patterns from `key-files.created` in corresponding SUMMARY.md files that match `*.test.*` or `*.spec.*`
22
+
23
+ Collect all unique test file paths into `REGRESSION_FILES`.
24
+
25
+ **Step 3: Run regression tests (if any found)**
26
+
27
+ ```bash
28
+ # Detect test runner and run prior phase tests
29
+ if [ -f "package.json" ]; then
30
+ # Node.js — use project's test runner
31
+ npx jest ${REGRESSION_FILES} --passWithNoTests --no-coverage -q 2>&1 || npx vitest run ${REGRESSION_FILES} 2>&1
32
+ elif [ -f "Cargo.toml" ]; then
33
+ cargo test 2>&1
34
+ elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
35
+ python -m pytest ${REGRESSION_FILES} -q --tb=short 2>&1
36
+ fi
37
+ ```
38
+
39
+ **Step 4: Report results**
40
+
41
+ If all tests pass:
42
+ ```
43
+ ✓ Regression gate: {N} prior-phase test files passed — no regressions detected
44
+ ```
45
+ → Proceed to verify_phase_goal
46
+
47
+ If any tests fail:
48
+ ```
49
+ ## ⚠ Cross-Phase Regression Detected
50
+
51
+ Phase {X} execution may have broken functionality from prior phases.
52
+
53
+ | Test File | Phase | Status | Detail |
54
+ |-----------|-------|--------|--------|
55
+ | {file} | {origin_phase} | FAILED | {first_failure_line} |
56
+
57
+ Options:
58
+ 1. Fix regressions before verification (recommended)
59
+ 2. Continue to verification anyway (regressions will compound)
60
+ 3. Abort phase — roll back and re-plan
61
+ ```
62
+
63
+ Use AskUserQuestion to present the options.
64
+ </step>
65
+
66
+ <step name="schema_drift_gate">
67
+ Post-execution schema drift detection. Catches false-positive verification where
68
+ build/types pass because TypeScript types come from config, not the live database.
69
+
70
+ **Run after execution completes but BEFORE verification marks success.**
71
+
72
+ ```bash
73
+ SCHEMA_DRIFT=$(node ".rihal/bin/rihal-tools.cjs" verify schema-drift "${PHASE_NUMBER}" 2>/dev/null)
74
+ ```
75
+
76
+ Parse JSON result for: `drift_detected`, `blocking`, `schema_files`, `orms`, `unpushed_orms`, `message`.
77
+
78
+ **If `drift_detected` is false:** Skip to verify_phase_goal.
79
+
80
+ **If `drift_detected` is true AND `blocking` is true:**
81
+
82
+ Check for override:
83
+ ```bash
84
+ SKIP_SCHEMA=$(echo "${Rihal_SKIP_SCHEMA_CHECK:-false}")
85
+ ```
86
+
87
+ **If `SKIP_SCHEMA` is `true`:**
88
+
89
+ Display:
90
+ ```
91
+ ⚠ Schema drift detected but Rihal_SKIP_SCHEMA_CHECK=true — bypassing gate.
92
+
93
+ Schema files changed: {schema_files}
94
+ ORMs requiring push: {unpushed_orms}
95
+
96
+ Proceeding to verification (database may be out of sync).
97
+ ```
98
+ → Continue to verify_phase_goal.
99
+
100
+ **If `SKIP_SCHEMA` is not `true`:**
101
+
102
+ BLOCK verification. Display:
103
+
104
+ ```
105
+ ## BLOCKED: Schema Drift Detected
106
+
107
+ Schema-relevant files changed during this phase but no database push command
108
+ was executed. Build and type checks pass because TypeScript types come from
109
+ config, not the live database — verification would produce a false positive.
110
+
111
+ Schema files changed: {schema_files}
112
+ ORMs requiring push: {unpushed_orms}
113
+
114
+ Required push commands:
115
+ {For each unpushed ORM, show the push command from the message}
116
+
117
+ Options:
118
+ 1. Run push command now (recommended) — execute the push, then re-verify
119
+ 2. Skip schema check (Rihal_SKIP_SCHEMA_CHECK=true) — bypass this gate
120
+ 3. Abort — stop execution and investigate
121
+ ```
122
+
123
+ If `TEXT_MODE` is true, present as a plain-text numbered list. Otherwise use AskUserQuestion.
124
+
125
+ **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.
126
+
127
+ **If user selects option 2:** Set override and continue to verify_phase_goal.
128
+
129
+ **If user selects option 3:** Stop execution. Report partial completion.
130
+ </step>
131
+
@@ -21,7 +21,7 @@ Valid Rihal subagent types (use exact names — do not fall back to 'general-pur
21
21
  Load execution context (paths only to minimize orchestrator context):
22
22
 
23
23
  ```bash
24
- INIT=$(node ".rihal/bin/rihal-tools.cjs" init execute-phase "${PHASE}")
24
+ INIT=$(node ".rihal/bin/rihal-tools.cjs" init execute "${PHASE}")
25
25
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
26
26
  ```
27
27
 
@@ -60,6 +60,23 @@ PLAN_START_EPOCH=$(date +%s)
60
60
  ```
61
61
  </step>
62
62
 
63
+ <step name="create_phase_snapshot">
64
+ Create a pre-execution git tag so `/rihal-undo --phase NN --to-snapshot` can restore to this exact state.
65
+ Only runs when inside a git repository (skip silently otherwise).
66
+
67
+ ```bash
68
+ if git rev-parse --verify HEAD >/dev/null 2>&1; then
69
+ SNAPSHOT_TAG="rihal/snapshot/phase-${PHASE_NUMBER}"
70
+ if git rev-parse --verify "refs/tags/${SNAPSHOT_TAG}" >/dev/null 2>&1; then
71
+ git tag -d "${SNAPSHOT_TAG}" >/dev/null 2>&1
72
+ fi
73
+ git tag -a "${SNAPSHOT_TAG}" -m "Pre-execution snapshot for phase ${PHASE_NUMBER}" HEAD 2>/dev/null \
74
+ && echo "✓ Snapshot: ${SNAPSHOT_TAG} @ $(git rev-parse --short HEAD)" \
75
+ || echo "⚠ Could not create snapshot tag (non-fatal)"
76
+ fi
77
+ ```
78
+ </step>
79
+
63
80
  <step name="parse_segments">
64
81
  ```bash
65
82
  grep -n "type=\"checkpoint" .planning/phases/XX-name/{phase}-{plan}-SPRINT.md
@@ -146,6 +163,11 @@ Deviations are normal — handle via rules below.
146
163
  - **MANDATORY read_first gate:** If the task has a `<read_first>` field, you MUST read every listed file BEFORE making any edits. This is not optional. Do not skip files because you "already know" what's in them — read them. The read_first files establish ground truth for the task.
147
164
  - `type="auto"`: if `tdd="true"` → TDD execution. Implement with deviation rules + auth gates. Verify done criteria. Commit (see task_commit). Track hash for Summary.
148
165
  - `type="checkpoint:*"`: STOP → checkpoint_protocol → wait for user → continue only after confirmation.
166
+ - **Task completion precedence (when signals conflict):**
167
+ 1. `<verify><automated>` — machine-executable shell commands. **Highest authority.** If these pass, the task is done. If these fail, the task is NOT done — regardless of what `<acceptance_criteria>` says.
168
+ 2. `<done>` — single observable sentence. Use as the human-readable confirmation once automated checks pass.
169
+ 3. `<acceptance_criteria>` — prose checklist. **Lowest authority.** Use as a guide during implementation, but automated results override prose judgments.
170
+ - If `<verify><automated>` is absent: fall back to `<done>`, then `<acceptance_criteria>`.
149
171
  - **MANDATORY acceptance_criteria check:** After completing each task, if it has `<acceptance_criteria>`, verify EVERY criterion before moving to the next task. Use grep, file reads, or CLI commands to confirm each criterion. If any criterion fails, fix the implementation before proceeding. Do not skip criteria or mark them as "will verify later".
150
172
  3. Run `<verification>` checks
151
173
  4. Confirm `<success_criteria>` met
@@ -400,6 +422,13 @@ One-liner SUBSTANTIVE: "JWT auth with refresh rotation using jose library" not "
400
422
 
401
423
  Include: duration, start/end times, task count, file count.
402
424
 
425
+ **Fill the knowledge-transfer sections (omit any with nothing substantive to say):**
426
+
427
+ - **Patterns Established** — Any new architectural/coding patterns introduced. Future plans should follow these. Example: "All service errors now wrap in ServiceError(code, message)". If none, omit.
428
+ - **Provides** — Specific functions, APIs, models, config keys, or contracts this plan exposes for future plans to build on. Be concrete: function names and file paths.
429
+ - **Requires** — What this plan consumed from prior phases. Helps trace dependency chains.
430
+ - **Affects** — Later phases or components that may need re-verification because of what changed here.
431
+
403
432
  Next: more plans → "Ready for {next-plan}" | last → "Phase complete, ready for next step".
404
433
  </step>
405
434
 
@@ -500,7 +529,7 @@ If `USER_SETUP_CREATED=true`: display `⚠️ USER SETUP REQUIRED` with path + e
500
529
 
501
530
  | Condition | Route | Action |
502
531
  |-----------|-------|--------|
503
- | summaries < plans | **A: More plans** | Find next PLAN without SUMMARY. Yolo: auto-continue. Interactive: show next plan, suggest `/rihal-execute-phase {phase}` + `/rihal-verify-work`. STOP here. |
532
+ | summaries < plans | **A: More plans** | Find next PLAN without SUMMARY. Yolo: auto-continue. Interactive: show next plan, suggest `/rihal-execute {phase}` + `/rihal-verify-work`. STOP here. |
504
533
  | summaries = plans, current < highest phase | **B: Phase done** | Show completion, suggest `/rihal-plan-phase {Z+1}` + `/rihal-verify-work {Z}` + `/rihal-discuss-phase {Z+1}` |
505
534
  | summaries = plans, current = highest phase | **C: Milestone done** | Show banner, suggest `/rihal-complete-milestone` + `/rihal-verify-work` + `/rihal-add-phase` |
506
535
 
@@ -0,0 +1,136 @@
1
+ <purpose>
2
+ Sub-step of execute.md — verify_phase_goal. Spawns rihal-verifier to confirm the phase achieved its GOAL, not just completed tasks. Creates VERIFICATION.md.
3
+ </purpose>
4
+
5
+ <step name="verify_phase_goal">
6
+ Verify phase achieved its GOAL, not just completed tasks.
7
+
8
+ ```bash
9
+ VERIFIER_SKILLS=$(node ".rihal/bin/rihal-tools.cjs" agent-skills rihal-verifier 2>/dev/null)
10
+ ```
11
+
12
+ ```
13
+ Task(
14
+ description="Verify phase {phase_number} goal achievement",
15
+ prompt="Verify phase {phase_number} goal achievement.
16
+ Phase directory: {phase_dir}
17
+ Phase goal: {goal from ROADMAP.md}
18
+ Phase requirement IDs: {phase_req_ids}
19
+ Check must_haves against actual codebase.
20
+ Cross-reference requirement IDs from PLAN frontmatter against REQUIREMENTS.md — every ID MUST be accounted for.
21
+ Create VERIFICATION.md.
22
+
23
+ <files_to_read>
24
+ Read these files before verification:
25
+ - {phase_dir}/*-SPRINT.md (All plans — understand intent, check must_haves)
26
+ - {phase_dir}/*-SUMMARY.md (All summaries — cross-reference claimed vs actual)
27
+ - .planning/REQUIREMENTS.md (Requirement traceability)
28
+ ${CONTEXT_WINDOW >= 500000 ? `- {phase_dir}/*-CONTEXT.md (User decisions — verify they were honored)
29
+ - {phase_dir}/*-RESEARCH.md (Known pitfalls — check for traps)
30
+ - Prior VERIFICATION.md files from earlier phases — most recent 5 phases only (regression check)
31
+ ` : ''}
32
+ </files_to_read>
33
+
34
+ ${VERIFIER_SKILLS}",
35
+ subagent_type="rihal-verifier",
36
+ model="sonnet",
37
+ model="{verifier_model}"
38
+ )
39
+ ```
40
+
41
+ Read status:
42
+ ```bash
43
+ grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
44
+ ```
45
+
46
+ | Status | Action |
47
+ |--------|--------|
48
+ | `passed` | → update_roadmap |
49
+ | `human_needed` | Present items for human testing, get approval or feedback |
50
+ | `gaps_found` | Present gap summary, offer `/rihal-plan {phase} --gaps ${Rihal_WS}` |
51
+
52
+ **If human_needed:**
53
+
54
+ **Step A: Persist human verification items as UAT file.**
55
+
56
+ Create `{phase_dir}/{phase_num}-HUMAN-UAT.md` using UAT template format:
57
+
58
+ ```markdown
59
+ ---
60
+ status: partial
61
+ phase: {phase_num}-{phase_name}
62
+ source: [{phase_num}-VERIFICATION.md]
63
+ started: [now ISO]
64
+ updated: [now ISO]
65
+ ---
66
+
67
+ ## Current Test
68
+
69
+ [awaiting human testing]
70
+
71
+ ## Tests
72
+
73
+ {For each human_verification item from VERIFICATION.md:}
74
+
75
+ ### {N}. {item description}
76
+ expected: {expected behavior from VERIFICATION.md}
77
+ result: [pending]
78
+
79
+ ## Summary
80
+
81
+ total: {count}
82
+ passed: 0
83
+ issues: 0
84
+ pending: {count}
85
+ skipped: 0
86
+ blocked: 0
87
+
88
+ ## Gaps
89
+ ```
90
+
91
+ Commit the file:
92
+ ```bash
93
+ node ".rihal/bin/rihal-tools.cjs" commit "test({phase_num}): persist human verification items as UAT" --files "{phase_dir}/{phase_num}-HUMAN-UAT.md"
94
+ ```
95
+
96
+ **Step B: Present to user:**
97
+
98
+ ```
99
+ ## ✓ Phase {X}: {Name} — Human Verification Required
100
+
101
+ All automated checks passed. {N} items need human testing:
102
+
103
+ {From VERIFICATION.md human_verification section}
104
+
105
+ Items saved to `{phase_num}-HUMAN-UAT.md` — they will appear in `/rihal-progress` and `/rihal-audit-uat`.
106
+
107
+ "approved" → continue | Report issues → gap closure
108
+ ```
109
+
110
+ **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.
111
+
112
+ **If user reports issues:** Proceed to gap closure as currently implemented.
113
+
114
+ **If gaps_found:**
115
+ ```
116
+ ## ⚠ Phase {X}: {Name} — Gaps Found
117
+
118
+ **Score:** {N}/{M} must-haves verified
119
+ **Report:** {phase_dir}/{phase_num}-VERIFICATION.md
120
+
121
+ ### What's Missing
122
+ {Gap summaries from VERIFICATION.md}
123
+
124
+ ---
125
+ ## ▶ Next Up
126
+
127
+ `/clear` then:
128
+
129
+ `/rihal-plan {X} --gaps ${Rihal_WS}`
130
+
131
+ Also: `cat {phase_dir}/{phase_num}-VERIFICATION.md` — full report
132
+ Also: `/rihal-verify-work {X} ${Rihal_WS}` — manual testing first
133
+ ```
134
+
135
+ 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.
136
+ </step>