@hanzlaa/rcode 2.2.0 → 2.3.1

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 (72) hide show
  1. package/CONTRIBUTING.md +138 -0
  2. package/README.md +76 -17
  3. package/cli/install.js +312 -80
  4. package/cli/uninstall.js +8 -0
  5. package/dist/rcode.js +19777 -0
  6. package/package.json +17 -4
  7. package/rihal/DOCS-AUDIT.md +14 -0
  8. package/rihal/agents/rihal-code-reviewer.md +1 -1
  9. package/rihal/agents/rihal-codebase-mapper.md +1 -1
  10. package/rihal/agents/rihal-docs-auditor.md +1 -1
  11. package/rihal/agents/rihal-edge-case-hunter.md +1 -1
  12. package/rihal/agents/rihal-executor.md +1 -1
  13. package/rihal/agents/rihal-hussain-pm.md +1 -0
  14. package/rihal/agents/rihal-nyquist-auditor.md +1 -1
  15. package/rihal/agents/rihal-phase-researcher.md +1 -2
  16. package/rihal/agents/rihal-planner.md +1 -1
  17. package/rihal/agents/rihal-roadmapper.md +1 -0
  18. package/rihal/agents/rihal-security-adversary.md +1 -1
  19. package/rihal/agents/rihal-security-auditor.md +1 -1
  20. package/rihal/agents/rihal-sprint-checker.md +1 -1
  21. package/rihal/agents/rihal-verifier.md +1 -1
  22. package/rihal/bin/lib/roadmap.cjs +2 -3
  23. package/rihal/bin/rihal-tools.cjs +11 -31
  24. package/rihal/commands/audit.md +8 -0
  25. package/rihal/commands/checkpoint-preview.md +13 -0
  26. package/rihal/commands/config.md +4 -4
  27. package/rihal/commands/prfaq.md +15 -0
  28. package/rihal/commands/settings.md +2 -2
  29. package/rihal/references/agent-contracts.md +12 -0
  30. package/rihal/references/karpathy-guidelines-full.md +79 -0
  31. package/rihal/references/karpathy-guidelines.md +8 -76
  32. package/rihal/references/model-profile-resolution.md +8 -0
  33. package/rihal/references/phase-argument-parsing.md +11 -0
  34. package/rihal/references/revision-loop.md +11 -0
  35. package/rihal/references/universal-anti-patterns.md +15 -0
  36. package/rihal/skills/actions/1-analysis/rihal-prfaq/SKILL.md +10 -0
  37. package/rihal/skills/actions/2-plan/rihal-create-epics-and-stories/SKILL.md +3 -1
  38. package/rihal/skills/actions/2-plan/rihal-create-milestone/SKILL.md +3 -1
  39. package/rihal/skills/actions/2-plan/rihal-create-milestone/steps/step-10-complete.md +1 -1
  40. package/rihal/skills/actions/2-plan/rihal-create-prd/SKILL.md +13 -0
  41. package/rihal/skills/actions/2-plan/rihal-create-story/SKILL.md +4 -2
  42. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/SKILL.md +10 -0
  43. package/rihal/skills/actions/4-implementation/rihal-sprint-planning/SKILL.md +3 -1
  44. package/rihal/skills/agents/hussain-pm/SKILL.md +8 -0
  45. package/rihal/skills/agents/hussain-sm/SKILL.md +8 -0
  46. package/rihal/templates/UAT.md +29 -0
  47. package/rihal/templates/milestone.md +2 -0
  48. package/rihal/templates/sprint.md +11 -28
  49. package/rihal/templates/summary.md +30 -0
  50. package/rihal/templates/verification-report.md +28 -0
  51. package/rihal/workflows/audit-milestone.md +34 -2
  52. package/rihal/workflows/audit.md +172 -0
  53. package/rihal/workflows/autonomous.md +67 -0
  54. package/rihal/workflows/checkpoint-preview.md +7 -0
  55. package/rihal/workflows/council.md +3 -1
  56. package/rihal/workflows/debug.md +8 -1
  57. package/rihal/workflows/diagnose-issues.md +34 -0
  58. package/rihal/workflows/do.md +47 -3
  59. package/rihal/workflows/execute-sprint.md +11 -4
  60. package/rihal/workflows/execute.md +9 -3
  61. package/rihal/workflows/karpathy-audit.md +7 -14
  62. package/rihal/workflows/pause-work.md +7 -1
  63. package/rihal/workflows/prfaq.md +7 -0
  64. package/rihal/workflows/profile-user.md +2 -2
  65. package/rihal/workflows/settings.md +116 -118
  66. package/rihal/workflows/sprint-planning.md +39 -8
  67. package/rihal/workflows/status.md +5 -0
  68. package/rihal/workflows/ui-phase.md +3 -3
  69. package/rihal/workflows/update.md +80 -22
  70. package/rihal/workflows/validate-phase.md +7 -1
  71. package/rihal/agents/rihal-ui-designer.md +0 -6
  72. package/rihal/workflows/config.md +0 -105
@@ -21,6 +21,19 @@ Follow the instructions in ./workflow.md.
21
21
  - Every section has explicit owner and deadline
22
22
  - Do NOT include: vague verbs ("optimize"), unquantified metrics, or requirements without owners
23
23
 
24
+ ## Fast-path detection
25
+
26
+ If `$ARGUMENTS` or the opening message contains ALL FOUR of these fields, skip the discovery interview and go straight to drafting:
27
+
28
+ | Field | Signal words |
29
+ |-------|-------------|
30
+ | Product / feature name | explicit name or noun |
31
+ | Problem statement | "problem is", "users can't", "currently X fails" |
32
+ | Target user | "for X users", "persona is", "audience is" |
33
+ | Scope signal | "must have", "v1 only", "just need", "MVP" |
34
+
35
+ When fast-pathing: confirm detected fields in one line ("Got it — building {name} for {user} to solve {problem}. Starting PRD draft."), then generate without asking further questions. If any of the four are absent, run the normal interview.
36
+
24
37
  ## Examples
25
38
 
26
39
  ### Happy Path
@@ -15,10 +15,12 @@ Follow the instructions in ./workflow.md.
15
15
  ## Output Format
16
16
 
17
17
  - Story file at .rihal/phases/{phase}/stories/story-{id}.md
18
- - Fixed sections: Goal | Context | Tasks (checklist) | Acceptance Criteria | Dependencies | File List (empty) | Dev Agent Record (empty)
18
+ - Fixed sections: Goal | Assumptions | Context | Tasks (checklist) | Acceptance Criteria | Dependencies | File List (empty) | Dev Agent Record (empty)
19
19
  - Each task is ≤4 hours, in execution order
20
- - Acceptance criteria in Given/When/Then
20
+ - Acceptance criteria in Given/When/Then — no criterion is valid unless a test can be written against it
21
+ - `## Assumptions` block is mandatory: list every assumption that, if wrong, would change the story scope
21
22
  - Do NOT include implementation details in the story — those emerge during dev
23
+ - If AC cannot be stated in Given/When/Then, stop and ask the user to clarify before generating the story
22
24
 
23
25
  ## Examples
24
26
 
@@ -3,6 +3,16 @@ name: rihal-checkpoint-preview
3
3
  description: 'LLM-assisted human-in-the-loop review. Make sense of a change, focus attention where it matters, test. Use when the user says "checkpoint", "human review", or "walk me through this change".'
4
4
  ---
5
5
 
6
+ ## Do NOT use this skill for
7
+
8
+ - **Automated code review without a human** — use `/rihal:karpathy-audit` or a code-reviewer agent directly.
9
+ - **Approving a deploy or merge** — this skill explains a change; it does not authorize git push, deploys, or PR merges.
10
+ - **Bug investigation** from scratch — use `/rihal:debug` or the diagnose-issues workflow.
11
+ - **Architecture review of an undelivered design** — this skill reviews delivered code/diffs, not specs.
12
+ - **Sprint retros or milestone closure** — use `rihal-retrospective` or `rihal-complete-milestone`.
13
+
14
+ If the user has not produced a diff or change to review, ask them to do so first instead of invoking this skill.
15
+
6
16
  ## Workflow
7
17
 
8
18
 
@@ -15,10 +15,12 @@ Follow the instructions in ./workflow.md.
15
15
  ## Output Format
16
16
 
17
17
  - Output: .rihal/phases/{phase}/sprint-{N}.md
18
- - Fixed structure: Sprint Goal (one sentence) | Duration | Stories (with owners) | Capacity Used/Available | Risks | Definition of Done
18
+ - Fixed structure: Sprint Goal (one sentence) | Assumptions | Duration | Stories (with owners) | Capacity Used/Available | Risks | Definition of Done
19
19
  - Stories ranked by priority from epics.md
20
20
  - Leave 20% capacity buffer
21
21
  - Do NOT commit to stories without explicit owners
22
+ - Sprint Goal must be one verifiable sentence — if it cannot be verified at sprint end without interpretation, rewrite it
23
+ - `Assumptions` block required: list capacity assumptions, any known blockers assumed absent, any dependencies assumed resolved
22
24
 
23
25
  ## Examples
24
26
 
@@ -16,6 +16,14 @@ description: >
16
16
 
17
17
  # Hussain (PM) — Product Manager
18
18
 
19
+ ## Planning Quality Rules (Karpathy-adapted)
20
+
21
+ Apply these as hard constraints when writing any PRD, story, epic, or scope definition:
22
+
23
+ - **P1 — Think first:** Every PRD section must declare load-bearing assumptions explicitly before stating requirements. If scope is ambiguous, ask — do not guess silently.
24
+ - **P2 — Simplicity:** Scope only what was asked. No speculative features, no "nice to have" requirements that weren't requested by the user or stakeholder.
25
+ - **P4 — Goal-driven:** Every requirement must have a testable acceptance criterion. "System should handle X" is not a criterion — "Given Y, when Z, then the system returns W" is.
26
+
19
27
  ## Overview
20
28
 
21
29
  This skill embodies Hussain (حسين) in his Product Manager hat. It drives PRD creation through user interviews and requirements discovery, cuts scope ruthlessly, and ships the smallest thing that validates the assumption. Hussain does not fill templates — he interrogates until the problem is crystal clear.
@@ -15,6 +15,14 @@ description: >
15
15
 
16
16
  # Hussain (SM) — Scrum Master
17
17
 
18
+ ## Sprint Quality Rules (Karpathy-adapted)
19
+
20
+ Apply these as hard constraints when preparing stories and planning sprints:
21
+
22
+ - **P1 — Think first:** Before committing stories to a sprint, surface capacity assumptions explicitly. Never assume velocity or team availability — ask.
23
+ - **P2 — Simplicity:** Each story must be independently deliverable. No story that bundles 2+ concerns. If a story needs a sub-story to make sense, split it.
24
+ - **P4 — Goal-driven:** Every story must have a Definition of Done that can be verified without talking to anyone. "Works correctly" is not a DoD — "all AC pass + no regression in test suite" is.
25
+
18
26
  ## Overview
19
27
 
20
28
  This skill embodies Hussain (حسين) in his Scrum Master hat. It prepares stories with full context for the dev agent, plans sprints, runs retros, reports status, and course-corrects when things go sideways. Every story that reaches Hanzla is dev-ready — no ambiguity allowed.
@@ -0,0 +1,29 @@
1
+ # UAT — {{phase_name}}
2
+
3
+ **Phase:** {{phase_id}}
4
+ **Generated:** {{date}}
5
+
6
+ ## How to use
7
+
8
+ For each scenario below, mark status: ✅ pass | ❌ fail | ⏸ skipped |
9
+ 🔍 needs-human. Add notes inline.
10
+
11
+ ## Scenarios
12
+
13
+ ### Scenario 1: {{golden path title}}
14
+
15
+ **Steps:**
16
+ 1. {{action}}
17
+ 2. {{action}}
18
+
19
+ **Expected:** {{outcome}}
20
+ **Status:** ⏸
21
+ **Notes:**
22
+
23
+ ### Scenario 2: {{edge case title}}
24
+
25
+ (Repeat as needed.)
26
+
27
+ ## Outstanding items
28
+
29
+ Items left as ⏸ or 🔍 carry forward to the next milestone audit.
@@ -1,5 +1,7 @@
1
1
  # Milestone Template
2
2
 
3
+ <!-- P2: Omit any section with nothing substantive. Empty sections are noise. Omit STATE.md blockers/workstreams if none active. Omit REQUIREMENTS.md out-of-scope if it doesn't constrain execution. -->
4
+
3
5
  Use this template when starting a new milestone with `/rihal:new-milestone`.
4
6
 
5
7
  ## ROADMAP.md
@@ -1,70 +1,53 @@
1
1
  # Sprint {sprint_id} — {sprint_goal}
2
2
 
3
+ <!-- P2: Omit Dependencies and Risks sections if empty. Omit Retrospective until sprint is complete. -->
4
+
3
5
  **Phase:** {phase_number} — {phase_name}
4
6
  **Status:** {status}
5
7
  **Velocity target:** {velocity_target} points
6
8
  **Started:** {started_at}
7
9
 
8
- ---
9
-
10
10
  ## Sprint Goal
11
11
 
12
12
  {sprint_goal}
13
13
 
14
- ---
15
-
16
14
  ## Stories
17
15
 
18
- | ID | Title | Points | Status | Acceptance |
19
- |----|-------|--------|--------|------------|
20
- | {story_id} | {title} | {points} | {status} | {acceptance} |
21
-
22
- ---
16
+ | ID | Title | Points | Status | Done when |
17
+ |----|-------|--------|--------|-----------|
18
+ | {story_id} | {title} | {points} | {status} | {verifiable_ac} |
23
19
 
24
20
  ## Capacity
25
21
 
26
22
  - **Velocity target:** {velocity_target} points
27
- - **Average velocity (last 3):** {avg_velocity} points
28
23
  - **Total committed:** {total_points} points
29
24
  - **Buffer:** {buffer_points} points ({buffer_pct}%)
30
25
 
31
- ---
32
-
26
+ <!-- Omit if no cross-story dependencies exist -->
33
27
  ## Dependencies
34
28
 
35
29
  | Story | Depends on | Status |
36
30
  |-------|-----------|--------|
37
- | | | |
38
-
39
- ---
40
31
 
32
+ <!-- Omit if no risks identified -->
41
33
  ## Risks
42
34
 
43
35
  | Risk | Impact | Mitigation |
44
36
  |------|--------|------------|
45
- | | | |
46
37
 
47
- ---
48
-
49
- ## Sprint Review Notes
50
-
51
- _Filled at sprint completion._
38
+ ## Sprint Review
52
39
 
40
+ <!-- Fill at sprint completion only — omit this section until then -->
53
41
  - Stories completed: {done_count}/{total_count}
54
42
  - Velocity actual: {velocity_actual} points
55
- - Carryover stories: {carryover}
56
-
57
- ---
43
+ - Carryover: {carryover}
58
44
 
59
45
  ## Retrospective
60
46
 
61
- _Filled at sprint completion._
62
-
47
+ <!-- Fill at sprint completion only — omit this section until then -->
63
48
  ### What went well
64
49
  -
65
-
66
50
  ### What didn't
67
51
  -
68
-
69
52
  ### Action items
70
53
  -
@@ -0,0 +1,30 @@
1
+ # Phase Summary — {{phase_name}}
2
+
3
+ <!-- P2: Omit any section that has nothing substantive to say. An empty section is worse than no section. -->
4
+
5
+ **Phase ID:** {{phase_id}}
6
+ **Closed:** {{closed_at}}
7
+ **Plan:** PLAN.md
8
+
9
+ ## Outcomes
10
+
11
+ - {{what was built, in user-visible terms}}
12
+
13
+ ## Decisions Made
14
+
15
+ <!-- Omit if no decisions were made that aren't already in PLAN.md -->
16
+ - {{key choices and their rationale}}
17
+
18
+ ## Deviations from Plan
19
+
20
+ <!-- Omit if execution matched the plan exactly -->
21
+ - {{anything that diverged from PLAN.md and why}}
22
+
23
+ ## Issues Encountered
24
+
25
+ <!-- Omit if no tasks were pruned, escalated, or skipped -->
26
+ - {{tasks pruned, escalated, or skipped}}
27
+
28
+ ## Hand-off
29
+
30
+ Next phase: {{next phase id and goal}}
@@ -0,0 +1,28 @@
1
+ # Verification Report — {{phase_name}}
2
+
3
+ **Phase:** {{phase_id}}
4
+ **Verified:** {{date}}
5
+ **Verifier:** rihal-verifier
6
+
7
+ ## Goal-backward check
8
+
9
+ **Original goal:** {{phase goal from PLAN.md}}
10
+
11
+ **Met?** ✅ / ◐ partial / ❌ not met
12
+
13
+ **Evidence:**
14
+ - {{file:line or test name proving the goal is met}}
15
+
16
+ ## Per-task verification
17
+
18
+ | # | Task | Status | Evidence |
19
+ |---|------|--------|----------|
20
+ | 1 | {{task}} | ✅ | {{evidence}} |
21
+
22
+ ## Gaps
23
+
24
+ - {{what wasn't delivered + why}}
25
+
26
+ ## Recommendation
27
+
28
+ - proceed / revise / block
@@ -140,13 +140,45 @@ If `--report` flag set, also print the report to stdout. Otherwise, just save to
140
140
 
141
141
  ## On Error
142
142
 
143
- If no SUMMARY.md files found:
143
+ If no SUMMARY.md files found, **do not dead-halt** (closes #234). Probe
144
+ for executed-phase signals and offer recovery options:
144
145
 
146
+ ```bash
147
+ PLANS=$(find "$MILESTONE_DIR" -name PLAN.md 2>/dev/null | wc -l)
148
+ GIT_FEAT=$(git log --oneline --grep='^feat' 2>/dev/null | wc -l)
149
+ APPS=$(ls -d apps packages src 2>/dev/null | wc -l)
145
150
  ```
146
- ⚠ No phase summaries found. Have phases been executed?
151
+
152
+ If `PLANS > 0` AND (`GIT_FEAT > 0` OR `APPS > 0`):
153
+
154
+ ```
155
+ ⚠ {PLANS} phases planned, 0 SUMMARY.md, {GIT_FEAT} feat commits, code present.
156
+ Phases were executed but never formally closed.
157
+
158
+ Options:
159
+ 1. Synthesize SUMMARY.md per phase from PLAN.md + git log [recommended]
160
+ (groups commits by phase tag like "feat(03-1):", writes a
161
+ first-pass SUMMARY.md the user can edit)
162
+ 2. Run /rihal:verify-phase NN per phase (manual close path)
163
+ 3. Continue audit anyway (only assesses what is documented — likely
164
+ reports 0% goal coverage)
165
+ 0. Cancel
166
+ ```
167
+
168
+ In `mode: yolo` (read via `node .rihal/bin/rihal-tools.cjs config-get
169
+ mode`), auto-pick option 1. In guided mode, ask. STOP after the user
170
+ picks 0 or 2; resume audit at Step 4 after option 1 completes.
171
+
172
+ If `PLANS == 0`:
173
+
174
+ ```
175
+ ⚠ No phase summaries and no plans found. Have phases been executed?
147
176
  Check: {MILESTONE_DIR}/phases/
177
+ Start one: /rihal:plan
148
178
  ```
149
179
 
180
+ STOP.
181
+
150
182
  If ROADMAP missing:
151
183
 
152
184
  ```
@@ -0,0 +1,172 @@
1
+ # Workflow: rihal:audit
2
+
3
+ <purpose>
4
+ Single entry point for every kind of audit. Asks the user *what* to audit
5
+ and dispatches to the right sub-workflow. Closes #234 — replaces the prior
6
+ state where users had to know about six separate audit/verify commands by
7
+ name (`audit-milestone`, `audit-uat`, `audit-fix`, `karpathy-audit`,
8
+ `verify-phase`, `verify-work`).
9
+
10
+ Honours `.rihal/config.yaml`: in `mode: yolo`, the router skips the menu
11
+ and auto-picks the most-relevant target based on project state. In
12
+ `mode: guided` (default), it asks.
13
+ </purpose>
14
+
15
+ ## Step 0 — Usage check
16
+
17
+ If `$ARGUMENTS` contains `--help` or `-h`:
18
+
19
+ ```
20
+ /rihal:audit # interactive — asks what to audit
21
+ /rihal:audit phase [<NN>] # → /rihal:verify-phase
22
+ /rihal:audit milestone [--strict] # → /rihal:audit-milestone (with synth fallback)
23
+ /rihal:audit uat # → /rihal:audit-uat
24
+ /rihal:audit code [--scope=...] # → /rihal:karpathy-audit
25
+ /rihal:audit fix # → /rihal:audit-fix
26
+ /rihal:audit work # → /rihal:verify-work
27
+ ```
28
+
29
+ **Examples:**
30
+ ```
31
+ /rihal:audit
32
+ /rihal:audit milestone --strict
33
+ /rihal:audit phase 03
34
+ ```
35
+
36
+ ## Step 1 — Resolve mode + arguments
37
+
38
+ ```bash
39
+ TOOL="node .rihal/bin/rihal-tools.cjs"
40
+ MODE=$($TOOL config-get mode 2>/dev/null || echo "guided")
41
+ DISCUSS=$($TOOL config-get workflow.discuss_mode 2>/dev/null || echo "adaptive")
42
+ ```
43
+
44
+ Parse `$ARGUMENTS`:
45
+ - First word ∈ {phase, milestone, uat, code, fix, work} → set `$TARGET`, drop it from args, jump to Step 4.
46
+ - Empty or unrecognised → continue to Step 2.
47
+
48
+ ## Step 2 — Detect project state
49
+
50
+ Probe what's audit-able right now:
51
+
52
+ ```bash
53
+ ROADMAP=$([ -f .planning/ROADMAP.md ] && echo yes || echo no)
54
+ PHASES=$(ls -d .planning/phases/*/ 2>/dev/null | wc -l)
55
+ PLANS=$(find .planning/phases -name PLAN.md 2>/dev/null | wc -l)
56
+ SUMMARIES=$(find .planning/phases -name SUMMARY.md 2>/dev/null | wc -l)
57
+ UAT_FILES=$(find .planning -name 'UAT*.md' 2>/dev/null | wc -l)
58
+ ON_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
59
+ DIRTY=$([ -n "$(git status --porcelain 2>/dev/null)" ] && echo yes || echo no)
60
+ ```
61
+
62
+ Use these to decide which menu options are *relevant* and which to mark
63
+ as `(no data — skip)`.
64
+
65
+ ## Step 3 — Ask user (guided mode only)
66
+
67
+ If `$MODE` is `yolo`, skip this step and pick the most relevant target
68
+ automatically (priority: `work` if dirty branch, else `phase` if PLANS>0
69
+ and SUMMARIES<PLANS, else `milestone` if SUMMARIES>0, else `code`).
70
+
71
+ Otherwise call AskUserQuestion:
72
+
73
+ ```
74
+ Question:
75
+ What do you want to audit?
76
+
77
+ Options:
78
+ 1. phase — verify a single phase against its PLAN ({PLANS} plans)
79
+ 2. milestone — cross-phase milestone goal coverage ({SUMMARIES} summaries)
80
+ 3. uat — outstanding UAT / verification items ({UAT_FILES} files)
81
+ 4. code-quality — Karpathy 4-principle code review (current diff)
82
+ 5. auto-fix — audit then auto-fix findings (uses #1–4 output)
83
+ 6. work — verify current branch / WIP ({ON_BRANCH}, dirty={DIRTY})
84
+ 0. cancel
85
+ ```
86
+
87
+ Set `$TARGET` from the user's choice.
88
+
89
+ ## Step 4 — Pre-flight per target
90
+
91
+ Each target has a precondition. Fail loudly with the fix step *before*
92
+ dispatching, so the user doesn't get a surprise halt deep inside the
93
+ sub-workflow.
94
+
95
+ | target | precondition | failure message |
96
+ |---|---|---|
97
+ | phase | at least one `.planning/phases/*/PLAN.md` | `No PLAN.md found. Run /rihal:plan first.` |
98
+ | milestone | ROADMAP.md exists | `No ROADMAP.md. Run /rihal:new-milestone first.` |
99
+ | uat | at least one UAT*.md exists | `No UAT files yet. Run /rihal:execute on a phase first.` |
100
+ | code | git repo with at least one commit | `Empty repo — nothing to audit yet.` |
101
+ | fix | a prior audit report exists OR a prior `--report` artefact | `No audit findings yet. Run /rihal:audit first.` |
102
+ | work | inside a git worktree | `Not in a git repo.` |
103
+
104
+ For `milestone` specifically, check the **graceful-degrade** condition
105
+ (closes #234 audit-milestone halt):
106
+
107
+ ```bash
108
+ if [ "$TARGET" = "milestone" ] && [ "$SUMMARIES" -eq 0 ] && [ "$PLANS" -gt 0 ]; then
109
+ # Phases planned but no formal closes — offer to synthesize.
110
+ GIT_FEAT_COMMITS=$(git log --oneline --grep='^feat' 2>/dev/null | wc -l)
111
+ echo "⚠ $PLANS phases planned, 0 SUMMARY.md, $GIT_FEAT_COMMITS feat commits."
112
+ echo " Phases were executed but never formally closed."
113
+ # Offer (yolo: auto-pick 1; guided: ask):
114
+ # 1. Synthesize SUMMARY.md per phase from PLAN.md + git log [recommended]
115
+ # 2. Run /rihal:verify-phase per phase (manual close)
116
+ # 3. Continue audit anyway (will only assess what's documented)
117
+ # 0. Cancel
118
+ fi
119
+ ```
120
+
121
+ In `mode: yolo`, auto-pick option 1: group `git log --oneline` output by
122
+ phase tag (e.g. commits matching `^feat\(0?(\d+)`) and write a first-pass
123
+ `SUMMARY.md` per phase under `.planning/phases/<phase>/SUMMARY.md`
124
+ containing the goal (from PLAN.md), the commit list, and a `# TODO:
125
+ expand outcomes` marker. The user can then refine before re-running the
126
+ audit.
127
+
128
+ A native `phase synthesize-summaries` CLI subcommand is tracked separately
129
+ (see #234 follow-ups) — until it lands, the LLM performs the synthesis
130
+ inline using `git log` + `Read PLAN.md` + `Write SUMMARY.md`.
131
+
132
+ ## Step 5 — Dispatch
133
+
134
+ Run the target's slash command, forwarding remaining args:
135
+
136
+ | target | dispatch |
137
+ |---|---|
138
+ | phase | `/rihal:verify-phase $REST_ARGS` |
139
+ | milestone | `/rihal:audit-milestone $REST_ARGS` |
140
+ | uat | `/rihal:audit-uat $REST_ARGS` |
141
+ | code | `/rihal:karpathy-audit $REST_ARGS` |
142
+ | fix | `/rihal:audit-fix $REST_ARGS` |
143
+ | work | `/rihal:verify-work $REST_ARGS` |
144
+
145
+ ## Step 6 — Closing summary
146
+
147
+ After the sub-workflow returns:
148
+
149
+ ```
150
+ RIHAL ► AUDIT ({TARGET}) ✓
151
+
152
+ Report: {report_path or "(stdout only)"}
153
+ Findings: {count}
154
+
155
+ Next:
156
+ /rihal:audit fix — auto-fix findings classified as auto-fixable
157
+ /rihal:audit code — drill into code-quality issues
158
+ /rihal:settings show — review which audit gates are enabled
159
+ ```
160
+
161
+ ## Success Criteria
162
+
163
+ - [ ] `/rihal:audit` (no args) presents menu in guided mode, auto-picks in yolo
164
+ - [ ] `/rihal:audit milestone` short-circuits the menu
165
+ - [ ] When SUMMARY.md absent but PLAN.md present, milestone offers synthesize/verify/skip — does not dead-halt
166
+ - [ ] Sub-workflow's closing report is surfaced unchanged
167
+
168
+ ## On Error
169
+
170
+ - **Sub-workflow not installed** (slash file missing): `Audit subroute '/rihal:{target}' not found. Run: npx @hanzlaa/rcode install .`
171
+ - **Precondition failed**: print the message from Step 4's table, suggest the unblocking command, STOP.
172
+ - **`.rihal/config.yaml` missing**: treat as `mode: guided`, continue.
@@ -4,16 +4,83 @@ Drive milestone phases autonomously — all remaining phases, a range via `--fro
4
4
 
5
5
  </purpose>
6
6
 
7
+ <critical_rules priority="absolute">
8
+
9
+ These rules apply throughout autonomous execution. Violations broke the
10
+ interpos audit (issue #221) — DO NOT regress.
11
+
12
+ 1. **NEVER modify `.rihal/config.yaml`.** Specifically: never write
13
+ `mode: yolo`, never call `rihal-tools config-set mode`, never `sed`
14
+ the file. The user's mode preference is sacred. Autonomous behavior
15
+ is governed by the workflow's own internal flags + the `--auto`
16
+ invocation flag, NOT by mutating persistent config.
17
+
18
+ 2. **NEVER skip the methodology chain on greenfield projects.** Before
19
+ the phase loop runs, the prerequisite check (next step) MUST verify:
20
+ - `.planning/prd.md` exists (else halt → /rihal:create-prd)
21
+ - ROADMAP.md has milestone structure (else halt → /rihal:create-milestone)
22
+ - `.planning/epics.md` exists (else halt → /rihal:create-epics-and-stories)
23
+ See issue #219 + #229.
24
+
25
+ 3. **NEVER write SPRINT.md directly.** Sprint creation MUST go through
26
+ the `rihal-sprint-planning` skill so the capacity gate (#127) fires.
27
+ If autonomous needs a sprint, invoke the skill — don't shortcut.
28
+
29
+ 4. **ALWAYS call `state sync --from-disk` after writing any
30
+ .planning/ artifact.** Otherwise state.json drifts and downstream
31
+ workflows lie. See `_shared/state-sync-rule.md` (#198).
32
+
33
+ 5. **ALWAYS record decisions via `rihal-tools state add-decision`.**
34
+ Never write decision prose to STATE.md. See #224.
35
+
36
+ </critical_rules>
37
+
7
38
  <required_reading>
8
39
 
9
40
  @.rihal/references/output-format.md
10
41
  @.rihal/references/workstream-flag.md
11
42
  @.rihal/references/output-realism.md
43
+ @.rihal/skills/_shared/no-autonomous-bypass.md
44
+ @.rihal/skills/_shared/state-sync-rule.md
12
45
 
13
46
  Read all files referenced by the invoking prompt's execution_context before starting.
14
47
 
15
48
  </required_reading>
16
49
 
50
+ <step name="prerequisite_check" priority="before-everything">
51
+
52
+ ## 0. Prerequisite check (greenfield guard)
53
+
54
+ Before any phase work, verify the methodology chain has run:
55
+
56
+ ```bash
57
+ HAS_PRD=$([ -f .planning/prd.md ] && echo true || echo false)
58
+ HAS_ROADMAP_MILESTONES=$(grep -qE "^## Milestone\s+M[0-9]+" .planning/ROADMAP.md 2>/dev/null && echo true || echo false)
59
+ HAS_EPICS=$([ -f .planning/epics.md ] && echo true || echo false)
60
+ SKIP_FLAG=$(echo "$ARGUMENTS" | grep -qE "\-\-skip-prerequisites" && echo true || echo false)
61
+ ```
62
+
63
+ If `SKIP_FLAG=false` AND any prerequisite is missing, HALT with a clear message:
64
+
65
+ ```
66
+ ⚠ Cannot run autonomous: missing prerequisite — {what}.
67
+
68
+ The autonomous flow assumes a project that has already gone through:
69
+ 1. /rihal:create-prd → produces .planning/prd.md
70
+ 2. /rihal:create-milestone → produces ROADMAP.md with M1..Mn
71
+ 3. /rihal:create-epics-and-stories → produces .planning/epics.md
72
+ 4. THEN /rihal:autonomous ← you are here
73
+
74
+ Suggested first step: /rihal:{first-missing-command}
75
+
76
+ If you genuinely want to skip these (rare — usually inverted methodology),
77
+ re-invoke with: /rihal:autonomous --skip-prerequisites
78
+ ```
79
+
80
+ If `SKIP_FLAG=true`: print a warning that downstream workflows may produce low-quality output without upstream artifacts, then proceed.
81
+
82
+ </step>
83
+
17
84
  <output_format>
18
85
 
19
86
  Open with banner:
@@ -0,0 +1,7 @@
1
+ # Workflow: rihal:checkpoint-preview
2
+
3
+ <purpose>
4
+ Human-in-the-loop change review. Make sense of a diff, focus attention where it matters, and walk through testing. Delegates to the rihal-checkpoint-preview skill for the full review protocol.
5
+ </purpose>
6
+
7
+ @.rihal/skills/rihal-checkpoint-preview/SKILL.md
@@ -404,7 +404,9 @@ Rules for compact mode:
404
404
  - Round 2 deltas: ≤ 15 words each. "Held position" is a valid delta.
405
405
  - No section headers beyond the four above. No numbered story breakdowns. No tables from panelists verbatim.
406
406
 
407
- ### Verbose mode (`--verbose` flag)
407
+ ### Verbose mode (`--verbose` flag or `output.verbose: true` in config)
408
+
409
+ Activated by: `--verbose` in `$ARGUMENTS` OR `$(node .rihal/bin/rihal-tools.cjs config-get output.verbose)` equals `"true"`.
408
410
 
409
411
  Print Round 1 (and Round 2 if ran) verbatim in panel order. Do NOT summarize.
410
412
 
@@ -118,8 +118,15 @@ Task(
118
118
  )
119
119
  ```
120
120
 
121
- **Never pass `isolation="worktree"` without explicit user consent.** Worktree isolation creates a git worktree, which is a write operation the user may not want. If you believe isolation is genuinely needed (e.g., the debug agent may edit files), ask first via AskUserQuestion:
121
+ **Never pass `isolation="worktree"` without explicit user consent.** Worktree isolation creates a git worktree, which is a write operation the user may not want. If you believe isolation is genuinely needed (e.g., the debug agent may edit files):
122
122
 
123
+ ```bash
124
+ CONFIG_MODE=$(node .rihal/bin/rihal-tools.cjs config-get mode 2>/dev/null || echo "guided")
125
+ ```
126
+
127
+ **If `CONFIG_MODE == "yolo"`:** Skip isolation — default to no worktree, proceed immediately.
128
+
129
+ Otherwise ask via AskUserQuestion:
123
130
  ```
124
131
  Spawn the debug agent with git worktree isolation?
125
132
  - Safer: agent edits stay isolated until you merge
@@ -0,0 +1,34 @@
1
+ # Workflow: rihal:diagnose-issues
2
+
3
+ <purpose>
4
+ Reusable diagnosis subroutine called from /rihal:verify-work when
5
+ verification fails. Walks symptom → hypothesis → evidence → minimal
6
+ repro and returns a structured finding. Not a top-level command.
7
+ </purpose>
8
+
9
+ ## Step 1 — Symptom capture
10
+
11
+ Record:
12
+ - failing assertion / log line / wrong output
13
+ - file:line where divergence first appears
14
+ - last commit before symptom appeared (`git log -S<token>`)
15
+
16
+ ## Step 2 — Hypotheses
17
+
18
+ List 2–3 plausible causes. For each:
19
+ - a one-line predicted mechanism
20
+ - the cheapest test that would falsify it
21
+
22
+ ## Step 3 — Evidence
23
+
24
+ Run the falsifying tests in cheapest-first order. Stop at the first
25
+ hypothesis that matches all evidence.
26
+
27
+ ## Step 4 — Minimal repro
28
+
29
+ Reduce to the smallest input that still triggers the bug. Save under
30
+ `.planning/diagnostics/<slug>.md`.
31
+
32
+ ## Step 5 — Hand-off
33
+
34
+ Return JSON: `{ root_cause, repro_path, suggested_fix }` to the caller.