projecta-rrr 1.19.1 → 1.20.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 (37) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/commands/rrr/execute-phase.md +5 -1
  3. package/commands/rrr/next.md +301 -0
  4. package/commands/rrr/pause-work.md +26 -0
  5. package/commands/rrr/ship.md +336 -0
  6. package/package.json +1 -1
  7. package/rrr/lib/__tests__/frontmatter.test.js +334 -0
  8. package/rrr/lib/__tests__/handoff.test.js +373 -0
  9. package/rrr/lib/__tests__/node-repair-integration.test.js +384 -0
  10. package/rrr/lib/__tests__/node-repair.test.js +543 -0
  11. package/rrr/lib/__tests__/regression-gate-integration.test.js +312 -0
  12. package/rrr/lib/__tests__/regression-gate.test.js +359 -0
  13. package/rrr/lib/__tests__/stub-detector.test.js +333 -0
  14. package/rrr/lib/budget-caps.js +357 -0
  15. package/rrr/lib/frontmatter.js +420 -0
  16. package/rrr/lib/handoff.js +202 -0
  17. package/rrr/lib/load-skills.js +5 -84
  18. package/rrr/lib/node-repair-integration.js +290 -0
  19. package/rrr/lib/node-repair.js +452 -0
  20. package/rrr/lib/pipeline.js +804 -0
  21. package/rrr/lib/regression-gate.js +377 -0
  22. package/rrr/lib/stub-detector.js +499 -0
  23. package/rrr/references/verification-patterns.md +25 -0
  24. package/rrr/scripts/state-compact.js +54 -1
  25. package/rrr/templates/continue-here.md +3 -0
  26. package/rrr/templates/phase-prompt.md +41 -0
  27. package/rrr/templates/state.md +90 -131
  28. package/rrr/templates/verification-report.md +121 -45
  29. package/rrr/workflows/execute-phase.md +202 -1
  30. package/rrr/workflows/execute-plan.md +78 -0
  31. package/rrr/workflows/resume-project.md +57 -8
  32. package/rrr/workflows/transition.md +20 -0
  33. package/rrr/workflows/verify-phase.md +256 -74
  34. package/scripts/build-project-context.js +1 -22
  35. package/scripts/handoff-preflight.js +2 -49
  36. package/scripts/refresh-scope-cache.js +1 -49
  37. package/scripts/verify-milestone.js +1 -45
package/CHANGELOG.md CHANGED
@@ -4,6 +4,31 @@ All notable changes to RRR will be documented in this file.
4
4
 
5
5
  Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
+ ## [1.20.0] - 2026-03-22
8
+
9
+ ### Added
10
+
11
+ - **YAML Frontmatter STATE.md** - Machine-readable state with `schema_version: 2`, consolidated `frontmatter.js` module replacing 4+ duplicate parsers across codebase
12
+ - **Structured HANDOFF.json** - Machine-readable pause/resume alongside `.continue-here.md` with priority chain (HANDOFF.json > .continue-here.md > STATE.md)
13
+ - **Stub Detection** - Tree-sitter context-aware analysis detecting TODO/FIXME/empty implementations per-plan during execution (`stub-detector.js`)
14
+ - **Two-Stage Verification** - Stage 1 correctness check (including stubs), Stage 2 quality review (non-blocking advisory by default, configurable to blocking)
15
+ - **`/rrr:next` Command** - Auto-routing with 8-state routing table and `--dry-run` preview mode
16
+ - **`/rrr:ship` Command** - PR creation via `gh` CLI with planning artifacts as description, graceful fallback to `SHIP-READY.md`
17
+ - **Cross-Phase Regression Gate** - Runs prior phases' test suites before new phase execution with affected-files filter, caching, and `--skip-regression` escape hatch
18
+ - **PLAN.md `test_command:` Schema** - Per-plan test discovery via frontmatter field
19
+ - **Auto-Advance Pipeline** - `--auto` flag on `/rrr:execute-phase` chains discuss→plan→execute with triple budget caps (per-step, per-pipeline, wall-clock) and `.planning/.stop-auto` stop-file
20
+ - **Node Repair** - Retry→decompose→prune→escalate recovery chain with max depth 1, Pushpa error classification integration, git rollback before repair, HANDOFF.json checkpointing
21
+
22
+ ### Changed
23
+
24
+ - All STATE.md consumers now use `frontmatter.js` with dual-read (YAML first, regex fallback)
25
+ - `pause-work.md` now writes HANDOFF.json alongside `.continue-here.md`
26
+ - `pipeline.js` delegates to `frontmatter.js` instead of local parser
27
+ - `verify-phase.md` restructured into two-stage workflow
28
+ - `execute-plan.md` includes per-plan stub scan and node repair on task failure
29
+ - `execute-phase.md` includes regression gate (blocking) and auto-advance pipeline
30
+ - `transition.md` includes advisory regression check
31
+
7
32
  ## [1.19.1] - 2026-02-11
8
33
 
9
34
  ### Fixed
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: rrr:execute-phase
3
3
  description: Execute all plans in a phase with wave-based parallelization
4
- argument-hint: "<phase-number>"
4
+ argument-hint: "<phase-number> [--auto] [--dry-run] [--step-cap=30m] [--pipeline-cap=4h] [--wall-cap=6h]"
5
5
  allowed-tools:
6
6
  - Read
7
7
  - Write
@@ -20,6 +20,8 @@ Execute all plans in a phase using wave-based parallel execution.
20
20
  Orchestrator stays lean: discover plans, analyze dependencies, group into waves, spawn subagents, collect results. Each subagent loads the full execute-plan context and handles its own plan.
21
21
 
22
22
  Context budget: ~15% orchestrator, 100% fresh per subagent.
23
+
24
+ When `--auto` flag is passed, chains discuss-plan-execute automatically for the phase (and subsequent phases if applicable). Pipeline enforces triple budget caps and checks for `.planning/.stop-auto` stop-file before each step. Use `--dry-run` with `--auto` to preview the pipeline plan without executing.
23
25
  </objective>
24
26
 
25
27
  <execution_context>
@@ -34,6 +36,8 @@ Phase: $ARGUMENTS
34
36
 
35
37
  @.planning/ROADMAP.md
36
38
  @.planning/STATE.md
39
+ @rrr/lib/pipeline.js
40
+ @rrr/lib/budget-caps.js
37
41
  </context>
38
42
 
39
43
  <process>
@@ -0,0 +1,301 @@
1
+ ---
2
+ name: rrr:next
3
+ description: Determine and execute the next action based on project state
4
+ argument-hint: "[--dry-run]"
5
+ allowed-tools:
6
+ - Read
7
+ - Bash
8
+ - Glob
9
+ - Grep
10
+ - SlashCommand
11
+ - AskUserQuestion
12
+ ---
13
+
14
+ <objective>
15
+ Determine the next action based on STATE.md and either execute it or show what would happen (--dry-run).
16
+
17
+ Single command that replaces the "read progress, decide, copy command, run command" workflow. This is the unit action that the auto-advance pipeline (Phase 70) will loop over.
18
+ </objective>
19
+
20
+ <execution_context>
21
+ @rrr/lib/phase-paths.md
22
+ @rrr/lib/state-schema.md
23
+ @rrr/lib/milestone-utils.md
24
+ </execution_context>
25
+
26
+ <context>
27
+ Arguments: $ARGUMENTS
28
+
29
+ @.planning/STATE.md
30
+ @.planning/ROADMAP.md
31
+ </context>
32
+
33
+ <process>
34
+
35
+ <step name="parse_arguments">
36
+ **Parse arguments:**
37
+
38
+ Check if `$ARGUMENTS` contains `--dry-run`:
39
+ - If yes: set `DRY_RUN=true`
40
+ - If no: set `DRY_RUN=false`
41
+ </step>
42
+
43
+ <step name="read_state">
44
+ **Read and parse STATE.md:**
45
+
46
+ Use Read tool to read `.planning/STATE.md`.
47
+
48
+ **If file not found (no .planning/ directory):**
49
+
50
+ ```
51
+ No RRR project found.
52
+
53
+ Expected: .planning/STATE.md
54
+
55
+ To start: /rrr:new-project
56
+ ```
57
+
58
+ Exit.
59
+
60
+ **Parse the Current Position section:**
61
+
62
+ Extract these fields from the `## Current Position` section:
63
+ - `Milestone:` value (e.g., "v1.20", "Between milestones")
64
+ - `Phase:` value (e.g., "66 of 71 (State Infrastructure)", "--")
65
+ - `Plan:` value (e.g., "4 of 4 in current phase", "--")
66
+ - `Status:` value (e.g., "Phase complete", "Executing", "Ready to plan")
67
+
68
+ **If Milestone field is missing:**
69
+
70
+ ```
71
+ STATE.md missing Milestone field. Run /rrr:complete-milestone or /rrr:new-milestone to fix.
72
+ ```
73
+
74
+ Exit.
75
+
76
+ Parse phase number from Phase field (e.g., "66" from "66 of 71 (State Infrastructure)").
77
+ Parse phase total from Phase field (e.g., "71" from "66 of 71 (State Infrastructure)").
78
+ Parse phase name from Phase field (e.g., "State Infrastructure" from "66 of 71 (State Infrastructure)").
79
+ </step>
80
+
81
+ <step name="check_between_milestones">
82
+ **Check for "Between milestones" state:**
83
+
84
+ If `Milestone` equals `Between milestones`:
85
+
86
+ 1. Check if `.planning/MILESTONE-CONTEXT.md` exists:
87
+
88
+ **On macOS/Linux:**
89
+ ```bash
90
+ ls .planning/MILESTONE-CONTEXT.md 2>/dev/null
91
+ ```
92
+
93
+ **On Windows:**
94
+ Use Read tool to check existence.
95
+
96
+ 2. Route based on context existence:
97
+
98
+ **If MILESTONE-CONTEXT.md exists:**
99
+ - Action: "Create milestone from gathered context"
100
+ - Command: `/rrr:new-milestone`
101
+
102
+ **If MILESTONE-CONTEXT.md does NOT exist:**
103
+ - Action: "Discuss next milestone"
104
+ - Command: `/rrr:discuss-milestone`
105
+
106
+ 3. Go to **output step** with determined action and command.
107
+ </step>
108
+
109
+ <step name="check_special_statuses">
110
+ **Check for special status values:**
111
+
112
+ These statuses have direct mappings regardless of file counts:
113
+
114
+ | Status | Action | Command |
115
+ |--------|--------|---------|
116
+ | `Defining requirements` | Define requirements | `/rrr:define-requirements` |
117
+ | `Planning roadmap` | Create roadmap | `/rrr:create-roadmap` |
118
+ | `Ready to discuss next milestone` | Discuss next milestone | `/rrr:discuss-milestone` |
119
+
120
+ If Status matches any of these, go to **output step** with the mapped action and command.
121
+ </step>
122
+
123
+ <step name="locate_phase">
124
+ **Locate current phase directory:**
125
+
126
+ Use `find_phase_dir()` from phase-paths library to locate the current phase:
127
+
128
+ ```bash
129
+ PHASE_NUM={parsed phase number}
130
+ PHASE_DIR=$(find_phase_dir "$PHASE_NUM")
131
+ if [ -z "$PHASE_DIR" ]; then
132
+ echo "Phase $PHASE_NUM directory not found"
133
+ fi
134
+ ```
135
+
136
+ If phase directory not found and Status is "Ready to plan":
137
+ - Action: "Plan phase {phase_num} ({phase_name})"
138
+ - Command: `/rrr:plan-phase {phase_num}`
139
+ - Go to **output step**.
140
+
141
+ If phase directory not found and Status is NOT "Ready to plan":
142
+ - Use AskUserQuestion to ask user what to do.
143
+ - Exit.
144
+ </step>
145
+
146
+ <step name="count_files">
147
+ **Count plan and summary files in phase directory:**
148
+
149
+ ```bash
150
+ PLAN_COUNT=$(ls -1 "${PHASE_DIR}"/*-PLAN.md 2>/dev/null | wc -l | tr -d ' ')
151
+ SUMMARY_COUNT=$(ls -1 "${PHASE_DIR}"/*-SUMMARY.md 2>/dev/null | wc -l | tr -d ' ')
152
+ ```
153
+
154
+ Also check for UAT gaps:
155
+
156
+ ```bash
157
+ UAT_GAPS=$(grep -l "status: diagnosed" "${PHASE_DIR}"/*-UAT.md 2>/dev/null | wc -l | tr -d ' ')
158
+ ```
159
+ </step>
160
+
161
+ <step name="route">
162
+ **Determine next action based on state and file counts:**
163
+
164
+ **Priority 1: UAT gaps exist (UAT_GAPS > 0)**
165
+
166
+ - Action: "Plan gap closure for phase {phase_num} UAT issues"
167
+ - Command: `/rrr:plan-phase {phase_num} --gaps`
168
+
169
+ **Priority 2: Status is "Ready to plan" or no PLAN.md files (PLAN_COUNT = 0)**
170
+
171
+ - Action: "Plan phase {phase_num} ({phase_name})"
172
+ - Command: `/rrr:plan-phase {phase_num}`
173
+
174
+ **Priority 3: Status is "Ready to execute" or "Executing" (unexecuted plans exist: SUMMARY_COUNT < PLAN_COUNT)**
175
+
176
+ - Action: "Execute phase {phase_num} ({phase_name})"
177
+ - Command: `/rrr:execute-phase {phase_num}`
178
+
179
+ **Priority 4: Phase complete (SUMMARY_COUNT = PLAN_COUNT AND PLAN_COUNT > 0)**
180
+
181
+ Read ROADMAP.md to determine if more phases remain in the milestone.
182
+
183
+ Parse the Phases section to find all phase numbers in the current milestone.
184
+ Identify the current phase number and the highest phase number.
185
+
186
+ **If current phase < highest phase (more phases remain):**
187
+
188
+ Find the next phase from ROADMAP.md:
189
+ - Read the `## Phases` section
190
+ - Find the phase entry AFTER the current one
191
+ - Extract next phase number and name
192
+
193
+ Before routing, update STATE.md:
194
+ - Phase: `{next_phase_num} of {phase_total} ({next_phase_name})`
195
+ - Plan: `Not started`
196
+ - Status: `Ready to plan`
197
+ - Last activity: `{today} -- Transitioned from Phase {current} to Phase {next}`
198
+
199
+ Then:
200
+ - Action: "Transition to Phase {next_phase_num} ({next_phase_name}) and plan it"
201
+ - Command: `/rrr:plan-phase {next_phase_num}`
202
+
203
+ **If current phase = highest phase (last phase in milestone):**
204
+
205
+ - Action: "Complete milestone (all phases done)"
206
+ - Command: `/rrr:complete-milestone`
207
+
208
+ **Priority 5: Ambiguous state**
209
+
210
+ If none of the above conditions match, use AskUserQuestion:
211
+
212
+ ```
213
+ Unable to determine next action automatically.
214
+
215
+ Current state:
216
+ - Milestone: {value}
217
+ - Phase: {value}
218
+ - Plan: {value}
219
+ - Status: {value}
220
+
221
+ What would you like to do?
222
+ ```
223
+
224
+ Provide options:
225
+ - "Run /rrr:progress for full status"
226
+ - "Plan current phase"
227
+ - "Execute current phase"
228
+
229
+ Exit after user responds.
230
+ </step>
231
+
232
+ <step name="output">
233
+ **Display result based on dry-run flag:**
234
+
235
+ **If DRY_RUN is true:**
236
+
237
+ ```
238
+ ## Dry Run
239
+
240
+ **Current state:**
241
+ - Milestone: {milestone}
242
+ - Phase: {phase}
243
+ - Plan: {plan}
244
+ - Status: {status}
245
+
246
+ **Next action:** {action description}
247
+ **Command:** `{command}`
248
+
249
+ Run `/rrr:next` (without --dry-run) to execute.
250
+ ```
251
+
252
+ Exit. Do NOT execute the command.
253
+
254
+ **If DRY_RUN is false:**
255
+
256
+ ```
257
+ ## Next: {action description}
258
+
259
+ Executing `{command}`...
260
+ ```
261
+
262
+ Then use SlashCommand to invoke the determined command:
263
+
264
+ ```
265
+ SlashCommand(command_name="{command_name}", command_args="{command_args}")
266
+ ```
267
+
268
+ Where:
269
+ - `command_name` is the full slash command name (e.g., "rrr:execute-phase")
270
+ - `command_args` is the arguments string (e.g., "68")
271
+
272
+ </step>
273
+
274
+ </process>
275
+
276
+ <edge_cases>
277
+ **Handle these edge cases gracefully:**
278
+
279
+ 1. **No .planning/ directory:** Show "No RRR project found" and suggest `/rrr:new-project`
280
+
281
+ 2. **STATE.md missing Milestone field:** Warn and suggest running `/rrr:complete-milestone` or `/rrr:new-milestone`
282
+
283
+ 3. **Phase directory not found:** If status says phase should exist but directory is missing, suggest planning it
284
+
285
+ 4. **Ambiguous state:** When automatic routing fails, use AskUserQuestion to present options
286
+
287
+ 5. **Phase complete but can't determine next phase:** Read ROADMAP.md for phase list; if ambiguous, ask user
288
+
289
+ 6. **All plans executed but status not updated:** Detect SUMMARY_COUNT = PLAN_COUNT even if Status still says "Executing" -- treat as phase complete
290
+ </edge_cases>
291
+
292
+ <success_criteria>
293
+ - [ ] Reads STATE.md and determines correct next action for every status value
294
+ - [ ] `--dry-run` shows what would happen without executing
295
+ - [ ] Normal mode executes the determined action via SlashCommand
296
+ - [ ] Routing covers all STATE.md status values from state-schema.md
297
+ - [ ] Between milestones state routes correctly (with/without MILESTONE-CONTEXT.md)
298
+ - [ ] Edge cases handled gracefully (no project, missing fields, ambiguous state)
299
+ - [ ] Command is lean -- no progress bars, no semantic search status, no audit runs
300
+ - [ ] Routing logic is self-contained (not delegating to progress.md)
301
+ </success_criteria>
@@ -89,9 +89,34 @@ Start with: [specific first action when resuming]
89
89
  Be specific enough for a fresh Claude to understand immediately.
90
90
  </step>
91
91
 
92
+ <step name="write_handoff_json">
93
+ **Write structured HANDOFF.json alongside .continue-here.md:**
94
+
95
+ ```bash
96
+ # Create HANDOFF.json in same phase directory for machine-readable resume
97
+ node -e "
98
+ const { writeHandoff } = require('$RRR_DIR/lib/handoff');
99
+ writeHandoff({
100
+ phase: '[XX-name]',
101
+ plan: '[current plan number]',
102
+ task: [current task number],
103
+ total_tasks: [total tasks],
104
+ status: '[in_progress|blocked]',
105
+ last_updated: new Date().toISOString(),
106
+ decisions: [/* key decisions from this session */],
107
+ blockers: [/* any blockers */],
108
+ next_action: '[specific first action when resuming]'
109
+ }, '[phase-dir-path]');
110
+ " 2>/dev/null || echo "HANDOFF.json write skipped (handoff.js not available)"
111
+ ```
112
+
113
+ This enables the Priority 1 resume path in `/rrr:resume-work` (HANDOFF.json > .continue-here.md > STATE.md).
114
+ </step>
115
+
92
116
  <step name="commit">
93
117
  ```bash
94
118
  git add .planning/milestones/**/phases/*/.continue-here.md
119
+ git add .planning/milestones/**/phases/*/HANDOFF.json 2>/dev/null
95
120
  git commit -m "wip: [phase-name] paused at task [X]/[Y]"
96
121
  ```
97
122
  </step>
@@ -116,6 +141,7 @@ To resume: /rrr:resume-work
116
141
 
117
142
  <success_criteria>
118
143
  - [ ] .continue-here.md created in correct phase directory
144
+ - [ ] HANDOFF.json created alongside .continue-here.md
119
145
  - [ ] All sections filled with specific content
120
146
  - [ ] Committed as WIP
121
147
  - [ ] User knows location and how to resume