@hanzlaa/rcode 4.12.1 → 4.14.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 (63) hide show
  1. package/AGENTS.md +1 -1
  2. package/CLAUDE.md +1 -1
  3. package/CONTRIBUTING.md +1 -0
  4. package/cli/doctor.js +40 -5
  5. package/cli/install.js +6 -1
  6. package/dist/rcode.js +87 -87
  7. package/package.json +1 -1
  8. package/rcode/agents/rcode-hussain-pm.md +37 -3
  9. package/rcode/agents/rcode-orchestrator.md +91 -0
  10. package/rcode/agents/rcode-project-researcher.md +19 -1
  11. package/rcode/agents/rules/executor/correctness-hazard-scan.md +98 -0
  12. package/rcode/agents/rules/executor/execution-flow.md +8 -0
  13. package/rcode/agents/rules/executor/self-check.md +8 -0
  14. package/rcode/agents/rules/orchestrator/contract.md +76 -0
  15. package/rcode/agents/rules/sprint-checker/dimensions.md +38 -0
  16. package/rcode/agents/rules/verifier/reachability-check.md +45 -2
  17. package/rcode/bin/lib/progress.cjs +41 -13
  18. package/rcode/bin/lib/roadmap.cjs +62 -22
  19. package/rcode/bin/lib/state-digest.cjs +88 -0
  20. package/rcode/bin/rcode-hooks.cjs +192 -23
  21. package/rcode/bin/rcode-tools.cjs +278 -7
  22. package/rcode/references/REFERENCES_INDEX.md +3 -1
  23. package/rcode/references/agent-shared-rules.md +123 -0
  24. package/rcode/references/code-reviewer-playbook.md +5 -0
  25. package/rcode/references/executor-playbook.md +2 -0
  26. package/rcode/references/github-comment-style.md +57 -0
  27. package/rcode/references/persona-executor-mode.md +61 -0
  28. package/rcode/references/planner-playbook.md +11 -0
  29. package/rcode/references/questioning.md +100 -2
  30. package/rcode/references/response-style.md +21 -4
  31. package/rcode/references/roadmapper-playbook.md +14 -0
  32. package/rcode/references/verifier-playbook.md +26 -0
  33. package/rcode/skills/SKILLS_INDEX.md +1 -1
  34. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/references.md +7 -0
  35. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/rules/merge-strategy.md +19 -3
  36. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/templates/wave-prompt.md +3 -1
  37. package/rcode/skills/agents/{raees-orchestrator → orchestrator}/SKILL.md +1 -1
  38. package/rcode/team.yaml +20 -1
  39. package/rcode/workflows/audit-worktrees.md +15 -1
  40. package/rcode/workflows/execute-verify-phase-goal.md +58 -2
  41. package/rcode/workflows/execute.md +43 -8
  42. package/rcode/workflows/new-project-define-requirements.md +36 -0
  43. package/rcode/workflows/new-project-research-decision.md +61 -1
  44. package/rcode/workflows/new-project.md +95 -6
  45. package/rcode/workflows/plan-research-validation.md +8 -2
  46. package/rcode/workflows/plan-spawn-planner.md +32 -4
  47. package/rcode/workflows/plan.md +208 -18
  48. package/rcode/workflows/pr-branch.md +2 -0
  49. package/rcode/workflows/research-phase.md +12 -4
  50. package/rcode/workflows/resume-work.md +18 -0
  51. package/rcode/workflows/ship.md +4 -0
  52. package/rcode/workflows/verify-phase.md +40 -0
  53. package/server/dashboard.js +57 -17
  54. package/server/lib/html/client/components/OrchPanel.js +6 -2
  55. package/server/lib/html/client/components/XtermPanel.js +7 -2
  56. package/server/lib/html/client/orchestrator.js +58 -21
  57. package/server/lib/html/client/views/MemoryView.js +59 -3
  58. package/server/lib/html/css.js +40 -0
  59. package/server/lib/html/shell.js +10 -4
  60. package/server/lib/scanner.js +150 -3
  61. package/server/lib/view-only.js +32 -0
  62. package/server/orchestrator.js +63 -4
  63. /package/rcode/skills/agents/{raees-orchestrator → orchestrator}/references.md +0 -0
@@ -111,6 +111,41 @@ Create `.planning/REQUIREMENTS.md` with:
111
111
 
112
112
  **REQ-ID format:** `[CATEGORY]-[NUMBER]` (AUTH-01, CONTENT-02)
113
113
 
114
+ **Every requirement carries its testable consequences.** This is the shape:
115
+
116
+ ```markdown
117
+ - [ ] **AUTH-01**: User can log in with email and password and stay logged in
118
+ across sessions.
119
+ - **Consequences (testable):**
120
+ - A valid credential pair returns a session cookie with a 30-day expiry
121
+ - An invalid password returns 401 and does not reveal whether the email exists
122
+ - A logged-in user reloading the page stays logged in
123
+ ```
124
+
125
+ **Why the consequences live here and not in the plan.** rcode's verifier derives
126
+ `must_haves` at verification time, long after the requirement was written — so it
127
+ is guessing at what "done" meant for a requirement someone else authored. That
128
+ guess is where verification quietly goes wrong: a phase passes because the
129
+ verifier's invented criterion was met, not the one the requirement intended.
130
+
131
+ Writing the consequences with the requirement moves that decision to the moment
132
+ the person actually knows the answer. The planner then copies them into
133
+ `must_haves.truths` instead of inventing them, and the verifier checks the
134
+ requirement's own criteria rather than its own reconstruction.
135
+
136
+ A requirement whose consequences you cannot state is a requirement you have not
137
+ finished writing. "Handle authentication properly" has no consequences because it
138
+ has no meaning — that is the signal to push for specificity, not to move on.
139
+
140
+ **Scope dial:** hobby/solo — one consequence per requirement is usually enough,
141
+ and it can be a sentence. Internal tool — the happy path plus the one failure
142
+ mode that matters. Launch — every condition a reviewer would ask about, including
143
+ the negative cases.
144
+
145
+ **Do not change the traceability table's shape.** `requirements mark-complete`
146
+ rewrites the status cell of a `| ID | ... | status |` row; consequences are nested
147
+ under the requirement in the list above, not added as table columns.
148
+
114
149
  **Requirement quality criteria:**
115
150
 
116
151
  Good requirements are:
@@ -119,6 +154,7 @@ Good requirements are:
119
154
  - **User-centric:** "User can X"
120
155
  - **Atomic:** One capability per requirement
121
156
  - **Independent:** Minimal dependencies on other requirements
157
+ - **Consequential:** you can name what must be true for it to be done
122
158
 
123
159
  Reject vague requirements. Push for specificity:
124
160
 
@@ -243,7 +243,67 @@ Display research complete banner and key findings:
243
243
  Files: `.planning/research/`
244
244
  ```
245
245
 
246
- **If "Skip research":** Continue to Step 7.
246
+ ## 6b. Stack confirmation gate HARD STOP
247
+
248
+ **The stack is never decided for the user. Not by research, not by a
249
+ recommendation, not by "the obvious choice for this domain."** Research produces
250
+ a *suggestion*; only the user turns it into a decision.
251
+
252
+ This gate runs whether research ran or was skipped. If research was skipped, ask
253
+ with no recommendation attached — you have no grounds for one.
254
+
255
+ ```
256
+ AskUserQuestion:
257
+ header: "Stack"
258
+ question: "Research suggests {STACK} because {the one reason that actually drove it}. Confirm?"
259
+ options:
260
+ - label: "Confirm {STACK}"
261
+ description: "{the trade-off the user is accepting, stated plainly}"
262
+ - label: "I'll choose the stack"
263
+ description: "Tell me what to build on and I'll record that instead."
264
+ - label: "Research more first"
265
+ description: "Compare against {the closest alternative} before deciding."
266
+ ```
267
+
268
+ **Nothing proceeds until the user answers.** Not requirements, not the roadmap,
269
+ not a single file. An unanswered question is not a confirmation, and neither is
270
+ silence, `--auto`, or `auto_advance`. **Auto mode does NOT bypass this gate** —
271
+ every other question in this workflow has an auto default; this one does not,
272
+ because a wrong stack is the most expensive thing in the project to reverse.
273
+
274
+ State the reason the suggestion exists, in one sentence, in the user's terms.
275
+ "Research recommends WordPress" is not a reason. "WordPress because a
276
+ non-technical client will update content themselves, with no dev retainer" is —
277
+ and stated that way the user can see immediately whether the premise is true.
278
+
279
+ Record the answer with `state add-decision`, including the premise it rests on:
280
+
281
+ ```bash
282
+ node ".rcode/bin/rcode-tools.cjs" state add-decision \
283
+ "Stack: {chosen}. Premise: {the one reason}. Confirmed by user {date}."
284
+ ```
285
+
286
+ ### The premise is part of the decision
287
+
288
+ **A stack decision is only valid while its premise holds.** Write the premise
289
+ into the decision, then re-open the decision the moment the premise changes.
290
+
291
+ Confirmed live: a site was scoped for a non-technical client, so research picked
292
+ WordPress and the roadmap locked it. The project later pivoted to a model with no
293
+ client at all — the maintainer was the technical owner. Every planning doc was
294
+ rewritten for the pivot and the stack stayed "Locked", because nothing in the
295
+ loop treats a locked decision as re-openable. A PHP theme got built and then
296
+ migrated wholesale to a static generator to undo it.
297
+
298
+ **On any pivot, re-run this gate** for every decision whose stated premise the
299
+ pivot invalidated. A decision whose reason has expired is not locked, it is
300
+ stale.
301
+
302
+ **If "Research more first":** run the comparison against the named alternative,
303
+ then return to this gate. Do not proceed past it.
304
+
305
+ **If "Skip research":** Continue to Step 6b — you still need the stack gate,
306
+ you just have no suggestion to offer.
247
307
 
248
308
 
249
309
  ## Next Up
@@ -475,7 +475,12 @@ Proceed to Step 4 (skip Steps 3 and 5).
475
475
 
476
476
  ## 3. Deep Questioning
477
477
 
478
- **If auto mode:** Skip (already handled in Step 2a). Extract project context from provided document instead and proceed to Step 4.
478
+ **If auto mode:** extract project context from the provided document instead of
479
+ asking. **You still owe the user the Mandatory decision set** — resolve each item
480
+ from the document where it answers one, and where it does not, list what you are
481
+ assuming before Step 4 writes PROJECT.md. Auto mode removes the conversation, not
482
+ the accountability. If the document leaves the maintainer or the stack unanswered,
483
+ stop and ask those two regardless of mode.
479
484
 
480
485
  **Display stage banner:**
481
486
 
@@ -491,6 +496,20 @@ Ask inline (freeform, NOT AskUserQuestion):
491
496
 
492
497
  "What do you want to build?"
493
498
 
499
+ **Then, before any deeper questioning, run two short probes from
500
+ `@.rcode/references/questioning.md` — in this order:**
501
+
502
+ 1. **Stakes calibration** — hobby/solo, internal tool, or launch? Scale every
503
+ artifact and gate below to the answer. Do not run the launch-grade pipeline on
504
+ a weekend project.
505
+ 2. **Working mode** — Fast path (batched questions, draft with `[ASSUMPTION]`
506
+ tags) or Coaching path (walk the decisions together)? **Ask it. Never infer it
507
+ from `auto_advance`, from how detailed their opening message was, or from your
508
+ own read of their hurry.** Only `--auto`/yolo picks Fast path without asking.
509
+
510
+ These two answers govern the rest of this workflow. Record them with
511
+ `state add-decision` so a later resume does not re-guess them.
512
+
494
513
  Wait for their response. This gives you the context needed to ask intelligent follow-up questions.
495
514
 
496
515
  **Research-before-questions mode:** Check if `workflow.research_before_questions` is enabled in `.rcode/config.yaml` (via `node .rcode/bin/rcode-tools.cjs config-get workflow.research_before_questions`). When enabled, before asking follow-up questions about a topic:
@@ -527,6 +546,11 @@ Mentally check the context checklist. If gaps remain, weave questions naturally.
527
546
 
528
547
  **Decision gate:**
529
548
 
549
+ **Before the decision gate, show your coverage.** State plainly which items of the
550
+ Mandatory decision set (`@.rcode/references/questioning.md`) the user actually
551
+ answered and which you are assuming, with each assumption spelled out in one line.
552
+ An assumption the user never saw is a decision you made for them.
553
+
530
554
  When you could write a clear PROJECT.md, use AskUserQuestion:
531
555
 
532
556
  - header: "Ready?"
@@ -601,16 +625,61 @@ Synthesize all context into `.planning/PROJECT.md`. If `.rcode/templates/project
601
625
  - [ ] {Requirement 2}
602
626
  - [ ] {Requirement 3}
603
627
 
604
- ### Out of Scope
628
+ ### Out of Scope (Non-Goals)
629
+
630
+ *What this project is NOT and will NOT do. This does outsized work downstream —
631
+ it is what prevents the "let me also add this nearby thing" failure at every
632
+ level: phase, sprint, task, and code. An unstated exclusion reappears later as a
633
+ gap; a stated one ends the argument before it starts.*
605
634
 
606
635
  - {Exclusion 1} — {why}
607
636
  - {Exclusion 2} — {why}
608
637
 
638
+ **Scope dial:** hobby/solo — the two or three things you keep being tempted by.
639
+ Internal tool — plus anything a stakeholder has already asked for and been told
640
+ no. Launch — plus the "we are not becoming X" statements about the product's
641
+ identity.
642
+
643
+ ## Glossary
644
+
645
+ *Every domain noun this project uses, defined once. Downstream agents and
646
+ documents use these terms verbatim — introducing a synonym anywhere is a
647
+ discipline violation, because two names for one thing is how a codebase ends up
648
+ with two implementations of it.*
649
+
650
+ - **{Term}** — {definition}. {relationship to other terms, cardinality if it matters}
651
+
652
+ **Scope dial:** hobby/solo — only terms that are genuinely ambiguous, often 2-3.
653
+ Internal tool — every domain noun. Launch — every domain noun plus the ones the
654
+ team argues about.
655
+
609
656
  ## Key Decisions
610
657
 
611
- | Decision | Rationale | Outcome |
612
- |----------|-----------|---------|
613
- | {Choice} | {Why} | — Pending |
658
+ | Decision | Premise (what makes it right) | Rationale | Outcome |
659
+ |----------|-------------------------------|-----------|---------|
660
+ | {Choice} | {the condition this rests on} | {Why} | — Pending |
661
+
662
+ *The **Premise** column is load-bearing. A decision is valid only while its
663
+ premise holds — when the project pivots, every decision whose premise the pivot
664
+ invalidated goes back to the user. A decision whose reason has expired is not
665
+ locked, it is stale.*
666
+
667
+ ## Assumptions Index
668
+
669
+ *Every `[ASSUMPTION]` tag in this document and in REQUIREMENTS.md, gathered here
670
+ for explicit confirmation. An assumption the user never saw is a decision nobody
671
+ made.*
672
+
673
+ | # | Assumption | Where | Status |
674
+ |---|-----------|-------|--------|
675
+ | A-1 | {what was inferred} | §{section} | unconfirmed |
676
+
677
+ **This table is walked with the user before the document is treated as settled.**
678
+ Each row ends as confirmed, corrected, or deferred with an owner. Auto mode does
679
+ not skip the walk; it defers it to the first interactive turn.
680
+
681
+ **Scope dial:** the table exists at every stakes level. Hobby/solo may resolve it
682
+ in one exchange; launch resolves it row by row.
614
683
 
615
684
  ## Constraints
616
685
 
@@ -628,19 +697,39 @@ This document evolves at phase transitions and milestone boundaries.
628
697
  1. Requirements invalidated? → Move to Out of Scope with reason
629
698
  2. Requirements validated? → Move to Validated with phase reference
630
699
  3. New requirements emerged? → Add to Active
631
- 4. Decisions to log? → Add to Key Decisions
700
+ 4. Decisions to log? → Add to Key Decisions, WITH its premise
632
701
  5. "What This Is" still accurate? → Update if drifted
702
+ 6. New domain nouns introduced? → Add to Glossary in the same pass
703
+ 7. Any `[ASSUMPTION]` resolved or added? → Update the Assumptions Index
704
+ 8. Did anything invalidate a recorded premise? → That decision reopens
633
705
 
634
706
  **After each milestone** (via `/rcode-complete-milestone`):
635
707
  1. Full review of all sections
636
708
  2. Core Value check — still the right priority?
637
709
  3. Audit Out of Scope — reasons still valid?
638
710
  4. Update Context with current state
711
+ 5. Assumptions Index — any row still `unconfirmed` after a whole milestone is a
712
+ finding, not a formality. Resolve or escalate it
713
+ 6. Key Decisions — check every premise still holds
639
714
 
640
715
  ---
641
716
  *Last updated: {date} after initialization*
642
717
  ```
643
718
 
719
+ **Scale every section to the stakes answer from Step 3.** The template is one
720
+ document that serves a weekend project and a launch; the scope dials on each
721
+ section say how. Running the launch-grade depth on a hobby project is its own
722
+ failure — the user abandons the process, not the project.
723
+
724
+ | Stakes | PROJECT.md target |
725
+ |---|---|
726
+ | Hobby / solo | About a page. Glossary only where terms are ambiguous |
727
+ | Internal tool | Two to four pages. Every section present, lightly filled |
728
+ | Launch | As long as the requirements and concerns need |
729
+
730
+ Never pad a section to look thorough, and never drop one silently — if a section
731
+ genuinely does not apply, say so in one line where it would have been.
732
+
644
733
  **For greenfield projects:** Initialize requirements as hypotheses (all Active).
645
734
 
646
735
  **For brownfield projects (codebase map exists):** Read `.planning/codebase/ARCHITECTURE.md` and `STACK.md`. Identify what the codebase already does — these become the initial Validated set.
@@ -70,10 +70,16 @@ Answer: "What do I need to know to PLAN this phase well?"
70
70
  <files_to_read>
71
71
  - {context_path} (USER DECISIONS from /rcode-discuss-phase)
72
72
  - {requirements_path} (Project requirements)
73
- - {state_path} (Project decisions and history)
74
73
  </files_to_read>
75
74
 
76
- ${AGENT_SKILLS_RESEARCHER}
75
+ <project_state_digest>
76
+ {state_digest as JSON — current phase, recent decisions, open blockers. Slim
77
+ extract of state.json (#948); do NOT separately Read .rcode/state.json — its
78
+ full history (all phases, all sprints) is not needed here and costs 10-20K+
79
+ tokens on a mature project.}
80
+ </project_state_digest>
81
+
82
+ {agent_skills.researcher}
77
83
 
78
84
  <additional_context>
79
85
  **Phase description:** {phase_description}
@@ -34,14 +34,20 @@ When `GAPS_MODE=true`, use the prompt below in place of the standard planner pro
34
34
 
35
35
  <files_to_read>
36
36
  - {VERIFICATION_FILE} (Authoritative verification report — source of truth for gaps)
37
- - {state_path} (Project State)
38
37
  - {roadmap_path} (Roadmap)
39
38
  - {requirements_path} (Requirements)
40
39
  - Existing plan files in this phase: {EXISTING_PLAN_FILES}
41
40
  - Existing summary files in this phase: {EXISTING_SUMMARY_FILES}
42
41
  </files_to_read>
43
42
 
44
- ${AGENT_SKILLS_PLANNER}
43
+ <project_state_digest>
44
+ {state_digest as JSON — current phase, recent decisions, open blockers. Slim
45
+ extract of state.json (#948); do NOT separately Read .rcode/state.json — its
46
+ full history (all phases, all sprints) is not needed here and costs 10-20K+
47
+ tokens on a mature project.}
48
+ </project_state_digest>
49
+
50
+ {agent_skills.planner}
45
51
 
46
52
  <gap_list>
47
53
  {Serialized GAP_LIST — for each gap include id, title, expected behavior, actual behavior, status (gap_found|partial), and source section.}
@@ -86,7 +92,6 @@ Default: `phase` (one SPRINT.md, up to 8 stories — see Scope-Driven Sizing in
86
92
  **Self-upgrade to `initiative` mid-decomposition** if, once you've read CONTEXT.md/ROADMAP.md and started breaking down the work, it splits into independent waves or work-streams (e.g. shared-primitive foundation → feature-local migrations → cleanup/tests) and total stories would exceed 8. When that happens, emit multiple SPRINT.md files (`{phase}-1-SPRINT.md`, `{phase}-2-SPRINT.md`, ...) in this same run instead of one oversized plan. Do not wait for rcode-sprint-checker's "scope exceeds context budget" rejection to force a resharding pass — that costs a full extra planner run. Decide the split now, while you're already looking at the file/story list.
87
93
 
88
94
  <files_to_read>
89
- - {state_path} (Project State)
90
95
  - {roadmap_path} (Roadmap)
91
96
  - {requirements_path} (Requirements)
92
97
  - {context_path} (USER DECISIONS from /rcode-discuss-phase — read `<decisions>` for locked choices AND `<code_context>` for existing code patterns, reusable assets, and architectural notes gathered during discuss-phase)
@@ -102,7 +107,14 @@ ${CONTEXT_WINDOW >= 500000 ? `
102
107
  ` : ''}
103
108
  </files_to_read>
104
109
 
105
- ${AGENT_SKILLS_PLANNER}
110
+ <project_state_digest>
111
+ {state_digest as JSON — current phase, recent decisions, open blockers. Slim
112
+ extract of state.json (#948); do NOT separately Read .rcode/state.json — its
113
+ full history (all phases, all sprints) is not needed here and costs 10-20K+
114
+ tokens on a mature project.}
115
+ </project_state_digest>
116
+
117
+ {agent_skills.planner}
106
118
 
107
119
  **Phase requirement IDs (every ID MUST appear in a plan's `requirements` field):** {phase_req_ids}
108
120
 
@@ -266,6 +278,21 @@ Every task MUST include these fields — they are NOT optional:
266
278
  4. **`<verify>`** — Shell commands that PROVE the `<done>` criteria are met. Run by executor after task completes and by verifier during post-execution check. The block MUST contain an `<automated>` child with the exact commands to run (Dimension 8 hard-blocks without it). Rules:
267
279
  - `<automated>` commands must exit 0 on success, non-zero on failure
268
280
  - Prefer `grep -q` for presence checks, `test -f` for file existence, project test runner for behavior
281
+ - **A task that adds or changes a guard test MUST prove the test fails on the
282
+ unfixed code first ("red first").** A guard test is any test whose job is to
283
+ make a class of mistake impossible: meta-tests, schema invariant tests,
284
+ forbidden-pattern scans, coverage/manifest tests, lint-rule tests. Write the
285
+ task so the `<action>` states the red step explicitly ("run the new test on
286
+ the current tree and record that it fails, then apply the fix") and the
287
+ `<verify><automated>` block asserts the green state. A guard test that has
288
+ never been observed red is indistinguishable from one that greps the wrong
289
+ path — that is exactly how a `route.ts`-only glob left every Server Action
290
+ unguarded for nine phases while CI stayed green the whole time.
291
+ - **Absence checks use `! grep -q PATTERN FILE`, never `grep -qv`.** `-v` inverts per-line
292
+ matching, so `grep -qv PATTERN FILE` exits 0 as soon as ANY line fails to match — i.e. it
293
+ passes on virtually every file, including one that contains the forbidden pattern. This is a
294
+ silently-always-green assertion, the worst possible verify command. Same for "file must not
295
+ exist": `! test -f path`.
269
296
  - Keep commands short and composable — one check per line
270
297
  - If test file doesn't exist yet (TDD tasks), write `<automated>MISSING</automated>` and add a Wave 0 task to create the test
271
298
  - Example structure:
@@ -323,6 +350,7 @@ Every task MUST include these fields — they are NOT optional:
323
350
  - [ ] Every task has `<files>` listing exact files this task will modify or create
324
351
  - [ ] Every task has `<evidence>` with grep/lines/creates codebase grounding per issue #649 — not a prose checklist tag (none exists in the real plan schema)
325
352
  - [ ] Every task has `<verify>` with an `<automated>` child containing at least one shell command (Dimension 8 blocker)
353
+ - [ ] Every guard-test task states its red-first step in `<action>` (Dimension 8 blocker)
326
354
  - [ ] Every task has `<done>` with a single observable acceptance sentence (Dimension 2 requirement)
327
355
  - [ ] Every `<action>` contains concrete values (no "align X with Y" without specifying what)
328
356
  - [ ] Tasks extending existing code have `<interfaces>` with relevant signatures