@hanzlaa/rcode 4.1.0 → 4.1.2

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 (53) hide show
  1. package/AGENTS.md +1 -1
  2. package/CONTRIBUTING.md +3 -0
  3. package/README.md +3 -0
  4. package/cli/agent.js +3 -1
  5. package/cli/index.js +45 -0
  6. package/cli/install.js +59 -3
  7. package/cli/workflow.js +99 -0
  8. package/dist/rcode.js +215 -187
  9. package/package.json +1 -1
  10. package/rcode/bin/lib/config.cjs +3 -2
  11. package/rcode/bin/rcode-tools.cjs +23 -9
  12. package/rcode/commands/scaffold-project.md +2 -2
  13. package/rcode/skills/actions/2-plan/rcode-create-epics-and-stories/steps/step-04-final-validation.md +1 -1
  14. package/rcode/skills/actions/2-plan/rcode-create-milestone/steps/README.md +2 -2
  15. package/rcode/skills/actions/2-plan/rcode-create-milestone/steps/step-09-state-sync.md +1 -1
  16. package/rcode/skills/actions/3-solutioning/rcode-create-architecture/steps/step-01-init.md +1 -1
  17. package/rcode/skills/actions/3-solutioning/rcode-create-architecture/workflow.md +13 -1
  18. package/rcode/skills/actions/4-implementation/rcode-code-review/steps/step-02-review.md +1 -1
  19. package/rcode/skills/actions/4-implementation/rcode-git-flow/SKILL.md +1 -1
  20. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/SKILL.md +5 -1
  21. package/rcode/skills/actions/4-implementation/rcode-retrospective/workflow.md +61 -246
  22. package/rcode/skills/actions/4-implementation/rcode-scaffold-project/SKILL.md +39 -12
  23. package/rcode/skills/actions/4-implementation/rcode-scaffold-project/steps/step-01-target.md +18 -3
  24. package/rcode/skills/actions/4-implementation/rcode-scaffold-project/steps/step-02-safety.md +27 -3
  25. package/rcode/skills/actions/4-implementation/rcode-scaffold-project/steps/step-03-brownfield.md +57 -0
  26. package/rcode/skills/actions/4-implementation/rcode-scaffold-project/steps/step-03-clone.md +4 -1
  27. package/rcode/skills/actions/4-implementation/rcode-scaffold-project/steps/step-04-post-setup.md +15 -1
  28. package/rcode/skills/actions/4-implementation/rcode-trim/SKILL.md +1 -1
  29. package/rcode/workflows/audit-milestone.md +1 -1
  30. package/rcode/workflows/audit.md +3 -0
  31. package/rcode/workflows/brainstorm.md +1 -1
  32. package/rcode/workflows/council.md +8 -1
  33. package/rcode/workflows/create-architecture.md +5 -1
  34. package/rcode/workflows/create-prd.md +5 -1
  35. package/rcode/workflows/dashboard.md +5 -2
  36. package/rcode/workflows/discuss-phase.md +4 -16
  37. package/rcode/workflows/execute-milestone.md +1 -1
  38. package/rcode/workflows/execute-regression-gates.md +3 -0
  39. package/rcode/workflows/execute-sprint.md +30 -2
  40. package/rcode/workflows/execute-waves.md +6 -0
  41. package/rcode/workflows/execute.md +13 -3
  42. package/rcode/workflows/new-milestone.md +2 -2
  43. package/rcode/workflows/new-project.md +4 -0
  44. package/rcode/workflows/plan-research-validation.md +1 -1
  45. package/rcode/workflows/plan-spawn-planner.md +2 -2
  46. package/rcode/workflows/plan.md +34 -15
  47. package/rcode/workflows/retrospective.md +5 -1
  48. package/rcode/workflows/review.md +2 -0
  49. package/rcode/workflows/scaffold-project.md +5 -1
  50. package/rcode/workflows/session-report.md +1 -1
  51. package/rcode/workflows/ship.md +39 -0
  52. package/rcode/workflows/sprint-planning.md +36 -5
  53. package/rcode/workflows/status.md +3 -3
@@ -2,10 +2,12 @@
2
2
  name: rcode-scaffold-project
3
3
  internal: true
4
4
  description: >
5
- Scaffold a new project for rcode users using the official rcode template repo.
5
+ Scaffold a new project for rcode users using the official rcode template repo,
6
+ or initialize rcode in an existing project (brownfield / --here mode).
6
7
  Activates when the user says "scaffold project", "create project", "new project",
7
8
  "initialize project", "setup new project", "scaffold from template", "create from template",
8
- "rcode new project", or "start a new rcode project". Do NOT use for generating
9
+ "rcode new project", "start a new rcode project", "scaffold here", "use here",
10
+ "scaffold in this project", or "initialize rcode here". Do NOT use for generating
9
11
  project context files (use rcode-generate-project-context) or cloning websites
10
12
  (use rcode-clone-website).
11
13
  triggers:
@@ -18,6 +20,12 @@ triggers:
18
20
  - "create from template"
19
21
  - "rcode new project"
20
22
  - "start a new rcode project"
23
+ - "scaffold here"
24
+ - "scaffold --here"
25
+ - "use current directory"
26
+ - "scaffold in this project"
27
+ - "initialize rcode here"
28
+ - "add rcode to existing project"
21
29
  user-invocable: true
22
30
  ---
23
31
  @.rcode/references/karpathy-guidelines.md
@@ -30,14 +38,21 @@ user-invocable: true
30
38
 
31
39
  ## Overview
32
40
 
33
- This skill bootstraps a new rcode project by cloning the official rcode template
34
- repository (`https://github.com/rcode-om/template`) into a target directory.
41
+ This skill operates in two modes:
35
42
 
36
- It always clones fresh from GitHub nothing is stored locally — so if the template
37
- is updated, the next scaffold automatically picks up the latest version.
43
+ **Greenfield mode (default):** Bootstraps a new rcode project by cloning the
44
+ official rcode template (`https://github.com/rcode-om/template`) into a target
45
+ directory. Always clones fresh from GitHub.
46
+
47
+ **Brownfield mode (`--here`):** Initializes rcode in an *existing* project
48
+ without cloning the template. Use this when your codebase already exists and
49
+ you just want to add rcode structure to it. Invoke as:
50
+ `/rcode-scaffold-project --here` or just say "scaffold here" / "add rcode to
51
+ this existing project".
38
52
 
39
53
  The workflow enforces safety: it never overwrites an existing non-empty directory
40
- without explicit user consent.
54
+ without explicit user consent (greenfield), and never modifies existing project
55
+ files in brownfield mode.
41
56
 
42
57
  ## On Activation
43
58
 
@@ -53,9 +68,10 @@ Then proceed to `./steps/step-01-target.md`.
53
68
 
54
69
  | # | Stage | Purpose | File |
55
70
  |---|-------|---------|------|
56
- | 1 | Target Directory | Get + validate destination path | `steps/step-01-target.md` |
57
- | 2 | Safety Check | Verify folder is empty or get new path | `steps/step-02-safety.md` |
58
- | 3 | Clone | Clone template repo fresh from GitHub | `steps/step-03-clone.md` |
71
+ | 1 | Target Directory | Get + validate destination path; detect `--here` flag | `steps/step-01-target.md` |
72
+ | 2 | Safety Check | Verify folder is empty or get new path (greenfield); brownfield consent (brownfield) | `steps/step-02-safety.md` |
73
+ | 3a | Clone | Clone template repo fresh from GitHub *(greenfield only)* | `steps/step-03-clone.md` |
74
+ | 3b | Brownfield Init | Overlay rcode structure into existing project *(brownfield only)* | `steps/step-03-brownfield.md` |
59
75
  | 4 | Post-Setup | Rename, init git, suggest next steps | `steps/step-04-post-setup.md` |
60
76
 
61
77
  ## Design Decisions
@@ -63,6 +79,7 @@ Then proceed to `./steps/step-01-target.md`.
63
79
  - **Always clone fresh** — never cache template locally. Template updates are free.
64
80
  - **No local template copy** — single source of truth is `https://github.com/rcode-om/template`.
65
81
  - **Safety first** — never touch a non-empty directory without user approval.
82
+ - **Brownfield never overwrites** — in `--here` mode, existing files are never modified.
66
83
  - **Minimal assumptions** — ask before acting on any ambiguity.
67
84
 
68
85
  ## Output Format
@@ -86,6 +103,16 @@ Then proceed to `./steps/step-01-target.md`.
86
103
  **Input:** "scaffold project"
87
104
  **Expected:** Ask for project name before proceeding.
88
105
 
106
+ ### Happy Path — Brownfield (--here)
107
+ **Input:** "/rcode-scaffold-project --here" or "add rcode to this existing project"
108
+ **Expected:** Detect brownfield mode, use current directory, ask for consent, overlay
109
+ `.rcode/` structure only, never touch existing files, summarize what was added.
110
+
111
+ ### Edge Case — Brownfield, .rcode already exists
112
+ **Input:** `--here` flag but `.rcode/` already present in current dir
113
+ **Expected:** "rcode is already initialized here. Run `/rcode-init` to reconfigure."
114
+
89
115
  ### Negative Test
90
- **Input:** "scaffold my existing repo" (existing non-empty dir provided)
91
- **Expected:** Safety check triggers. Never overwrites. Offers alternatives.
116
+ **Input:** "scaffold my existing repo" (existing non-empty dir provided, no --here flag)
117
+ **Expected:** Safety check triggers. Never overwrites. Offers alternatives including
118
+ "Use `--here` mode to add rcode to this existing project instead".
@@ -1,14 +1,29 @@
1
1
  # Step 1: Target Directory
2
2
 
3
3
  ## Goal
4
- Determine the target directory for the new project.
4
+ Determine the target directory and mode (greenfield or brownfield).
5
5
 
6
- ## Rules
7
- - If the user already provided a project name or path when invoking the skill, use it.
6
+ ## Brownfield Detection (`--here` flag)
7
+
8
+ Check whether the user invoked with `--here`, said "scaffold here", "add rcode to
9
+ this project", "initialize rcode here", or any equivalent phrasing.
10
+
11
+ If **brownfield mode** is detected:
12
+ - Set `{brownfield_mode}` = `true`
13
+ - Set `{target_path}` = current working directory (`pwd`)
14
+ - Set `{project_name}` = basename of current directory
15
+ - Inform the user:
16
+ > "Brownfield mode — I'll add rcode to the current directory `{target_path}` without touching any existing files."
17
+ - Skip the name prompt and proceed directly to `step-02-safety.md`.
18
+
19
+ ## Greenfield Mode (default)
20
+
21
+ - If the user already provided a project name or path, use it.
8
22
  - If not, ask: **"What should the project be called? I'll create a folder with that name in the current directory."**
9
23
  - Accept either a bare name (`my-app`) or a full path (`/home/user/projects/my-app`).
10
24
  - If bare name: resolve to `{cwd}/{name}` where `{cwd}` is the directory the user is currently in.
11
25
  - Store resolved path as `{target_path}` and project name as `{project_name}`.
26
+ - Set `{brownfield_mode}` = `false`.
12
27
  - **Security:** Reject paths containing `..` traversal sequences before proceeding:
13
28
  ```bash
14
29
  case "{target_path}" in
@@ -3,7 +3,29 @@
3
3
  ## Goal
4
4
  Ensure the target directory is safe to scaffold into.
5
5
 
6
- ## Check: Does the directory exist?
6
+ ---
7
+
8
+ ## Brownfield Mode (`{brownfield_mode}` = true)
9
+
10
+ ### Case D — `.rcode/` already exists
11
+ - Check if `{target_path}/.rcode/` already exists.
12
+ - If yes: **STOP.**
13
+ > "rcode is already initialized in this directory. Run `/rcode-init` to reconfigure, or `/rcode-update` to update skills."
14
+ - Do not proceed further.
15
+
16
+ ### Case E — `.rcode/` does not exist (proceed with consent)
17
+ - Inform the user what will be created:
18
+ > "I'll add the following to `{target_path}` (existing files will NOT be touched):
19
+ > - `.rcode/` — rcode config and skills directory
20
+ > - `.rcode/config.json` — project config (name, language, etc.)
21
+ >
22
+ > Shall I proceed?"
23
+ - Wait for explicit confirmation before proceeding.
24
+ - On confirmation: proceed to `step-03-brownfield.md`.
25
+
26
+ ---
27
+
28
+ ## Greenfield Mode (`{brownfield_mode}` = false)
7
29
 
8
30
  ### Case A — Directory does not exist
9
31
  - Safe to proceed.
@@ -17,19 +39,21 @@ Ensure the target directory is safe to scaffold into.
17
39
 
18
40
  ### Case C — Directory exists and is NOT EMPTY
19
41
  - **STOP. Do not touch anything.**
20
- - Present the user with two options:
42
+ - Present the user with options:
21
43
 
22
44
  > "The folder `{target_path}` already has files in it. For safety I won't touch it.
23
45
  >
24
46
  > What would you like to do?
25
47
  > **A)** Create a new folder called `{project_name}-new` instead
26
48
  > **B)** Give me a different folder name
27
- > **C)** Empty the folder yourself first, then tell me when it's ready"
49
+ > **C)** Empty the folder yourself first, then tell me when it's ready
50
+ > **D)** Add rcode to this existing project instead (`--here` mode)"
28
51
 
29
52
  - Wait for user response. Do NOT proceed until user explicitly confirms.
30
53
  - If user chooses **A**: set `{target_path}` = `{cwd}/{project_name}-new`, proceed to step-03-clone.md.
31
54
  - If user chooses **B**: ask for new name, loop back to step-01-target.md logic.
32
55
  - If user chooses **C**: wait. When user says "ready" or "done", re-check the folder. Only proceed if it is now empty.
56
+ - If user chooses **D**: set `{brownfield_mode}` = `true`, proceed to Case E above (brownfield consent).
33
57
 
34
58
  ## Security Note
35
59
  **NEVER delete, move, or modify files in an existing directory.** The user must take that action themselves. This skill only creates new content.
@@ -0,0 +1,57 @@
1
+ # Step 3b: Brownfield Initialization
2
+
3
+ ## Goal
4
+ Add rcode structure to an existing project without cloning the template.
5
+ No existing files are ever modified.
6
+
7
+ ## What Gets Created
8
+
9
+ Only the following paths are written. If any already exist, skip and report:
10
+
11
+ ```
12
+ {target_path}/
13
+ └── .rcode/
14
+ └── config.json ← project config (name, language)
15
+ ```
16
+
17
+ ## Execution
18
+
19
+ ### 1. Create `.rcode/` directory
20
+ ```bash
21
+ mkdir -p "{target_path}/.rcode"
22
+ ```
23
+
24
+ ### 2. Write `.rcode/config.json`
25
+ Create with sensible defaults derived from the existing project:
26
+ ```json
27
+ {
28
+ "project_name": "{project_name}",
29
+ "communication_language": "English",
30
+ "created_at": "{iso_date}",
31
+ "mode": "brownfield"
32
+ }
33
+ ```
34
+ - Detect language preference from existing README or package.json if present.
35
+ - Set `{iso_date}` from the current date.
36
+
37
+ ### 3. Detect existing project metadata (offer, don't force)
38
+ - If `package.json` exists: read `name` field and offer to use it as `{project_name}` if different.
39
+ - If `README.md` exists: acknowledge it and skip creating a new one.
40
+
41
+ ## Progress Updates
42
+ Narrate each step:
43
+ - "Creating `.rcode/` directory..."
44
+ - "Writing `.rcode/config.json`..."
45
+ - "Done! Proceeding to post-setup..."
46
+
47
+ ## Error Handling
48
+
49
+ ### `.rcode/` creation fails (permissions)
50
+ - Report: "Couldn't create `.rcode/` — check directory permissions."
51
+ - Do NOT retry automatically.
52
+
53
+ ## Output
54
+ Confirm to the user:
55
+ > "rcode structure added to `{target_path}`. No existing files were modified."
56
+
57
+ Then proceed to `step-04-post-setup.md`.
@@ -1,4 +1,7 @@
1
- # Step 3: Clone Template
1
+ # Step 3a: Clone Template (Greenfield Only)
2
+
3
+ > **Brownfield mode:** If `{brownfield_mode}` is `true`, skip this step entirely
4
+ > and proceed to `step-03-brownfield.md` instead.
2
5
 
3
6
  ## Goal
4
7
  Clone the official rcode template repository fresh from GitHub into `{target_path}`.
@@ -18,8 +18,9 @@ Finalize the scaffolded project and guide the user on next steps.
18
18
  - Run only if user confirms.
19
19
 
20
20
  ### 3. Summary
21
- Print a clean summary:
21
+ Print a clean summary based on mode:
22
22
 
23
+ **Greenfield:**
23
24
  ```
24
25
  ✅ Project scaffolded successfully!
25
26
 
@@ -33,6 +34,19 @@ Next steps:
33
34
  pnpm dev ← to start development server
34
35
  ```
35
36
 
37
+ **Brownfield (`--here` mode):**
38
+ ```
39
+ ✅ rcode initialized in existing project!
40
+
41
+ 📁 Location: {target_path}
42
+ 🗂 Added: .rcode/config.json
43
+ 📝 Note: No existing files were modified.
44
+
45
+ Next steps:
46
+ /rcode-init ← configure rcode for this project
47
+ /rcode-new-project ← design project requirements & roadmap
48
+ ```
49
+
36
50
  ### 4. Suggest next rcode skills
37
51
  Offer relevant follow-up actions:
38
52
  > "What would you like to do next?
@@ -66,7 +66,7 @@ Do NOT include: changes that touch behaviour; "while I'm here, also..."; trimmin
66
66
 
67
67
  **Happy path** — A 220-line component with 4 unused props, 2 dead useState hooks, and 30 lines of commented-out exploration code → trim to 140 lines, behaviour unchanged, tests green.
68
68
 
69
- **Edge case — comment that earns its lines** — `// see issue #234 — Postgres pre-13 doesn't return rowCount on UPSERT, so we re-query`. Don't touch it. The comment captures a constraint that won't be obvious from the code alone.
69
+ **Edge case — comment that earns its lines** — `// see the upstream issue — Postgres pre-13 doesn't return rowCount on UPSERT, so we re-query`. Don't touch it. The comment captures a constraint that won't be obvious from the code alone.
70
70
 
71
71
  **Negative — "simplify by rewriting"** — User asks to "clean up" a working module. If the rewrite is bigger than the cuts, it's not trimming — it's a refactor. Refuse and route to `rcode-incremental` with a real task.
72
72
 
@@ -141,7 +141,7 @@ If `--report` flag set, also print the report to stdout. Otherwise, just save to
141
141
 
142
142
  ## On Error
143
143
 
144
- If no SUMMARY.md files found, **do not dead-halt** (closes #234). Probe
144
+ If no SUMMARY.md files found, **do not dead-halt**. Probe
145
145
  for executed-phase signals and offer recovery options:
146
146
 
147
147
  ```bash
@@ -18,6 +18,7 @@ If `$ARGUMENTS` contains `--help` or `-h`:
18
18
 
19
19
  ```
20
20
  /rcode-audit # interactive — asks what to audit
21
+ /rcode-audit --auto # non-interactive — auto-picks best target from project state
21
22
  /rcode-audit plans [--report] # → audit-plans (structural + status + deps check)
22
23
  /rcode-audit phase [<NN>] # → /rcode-verify-phase
23
24
  /rcode-audit milestone [--strict] # → /rcode-audit-milestone (with synth fallback)
@@ -49,6 +50,8 @@ DISCUSS=$($TOOL config-get workflow.discuss_mode 2>/dev/null || echo "adaptive")
49
50
  ```
50
51
 
51
52
  Parse `$ARGUMENTS`:
53
+ - If `--auto` flag is present: strip it from args and force `MODE=yolo` for this invocation
54
+ (allows non-interactive runs without permanently changing the project config).
52
55
  - First word ∈ {plans, phase, milestone, uat, code, fix, work, lens, worktrees} → set `$TARGET`, drop it from args, jump to Step 4.
53
56
  - Empty or unrecognised → continue to Step 2.
54
57
 
@@ -40,7 +40,7 @@ AskUserQuestion(
40
40
 
41
41
  ## Step 2 — Load brainstorming methods
42
42
 
43
- Read `rcode/references/brain-methods.csv` and parse it.
43
+ Read `.rcode/references/brain-methods.csv` and parse it.
44
44
 
45
45
  If `--method` was specified:
46
46
  - Validate the method exists in the CSV
@@ -29,9 +29,10 @@ Closure: `rcode ► COUNCIL COMPLETE ✓` + Next Up with decision options.
29
29
 
30
30
  <required_reading>
31
31
  @.rcode/references/auto-init-guard.md
32
- @.rcode/references/output-format.md
33
32
  @.rcode/references/council-protocol.md
34
33
  </required_reading>
34
+ <!-- output-format.md removed: council is self-contained via <output_format> above.
35
+ General banner/todo/spawn patterns are defined inline — no 398-line load needed. -->
35
36
 
36
37
  <process>
37
38
  ## Step 0 — Usage check
@@ -101,6 +102,12 @@ list from INIT_JSON so new agents added to team.yaml are automatically available
101
102
  Do not invoke `general-purpose` or any agent type not present in
102
103
  `installed_agents`. If the scorer surfaces an unknown agent, drop it
103
104
  from the panel silently.
105
+
106
+ **Post-install agent namespace fallback:** If a `Task(subagent_type="rcode-{id}")` call
107
+ fails with "Agent type not found", the runtime has not yet registered the new agent files
108
+ (requires IDE/window reload). In that case retry with `subagent_type="rihal-{id}"` — the
109
+ `rihal-*` agents are content-identical to `rcode-*` (pre-rebrand names). If neither works,
110
+ skip that panelist and log `[council] agent rcode-{id} not available — reload IDE to register`.
104
111
  </available_agent_types>
105
112
 
106
113
  ## Step 1 — Observe
@@ -9,7 +9,11 @@ Write an Architecture Decision Record (ADR) or system design document. Delegates
9
9
  Locate and follow the installed skill:
10
10
 
11
11
  ```bash
12
- find .rcode/skills/actions -path "*rcode-create-architecture/workflow.md" 2>/dev/null | head -1
12
+ if [ -f .rcode/skills/rcode-create-architecture/workflow.md ]; then
13
+ printf '%s\n' ".rcode/skills/rcode-create-architecture/workflow.md"
14
+ else
15
+ find .rcode/skills/actions -path "*rcode-create-architecture/workflow.md" 2>/dev/null | head -1
16
+ fi
13
17
  ```
14
18
 
15
19
  Read and follow the workflow at that path. If the path is empty:
@@ -9,7 +9,11 @@ Create a Product Requirements Document from scratch through guided facilitation.
9
9
  Locate and follow the installed skill:
10
10
 
11
11
  ```bash
12
- find .rcode/skills/actions -path "*rcode-create-prd/workflow.md" 2>/dev/null | head -1
12
+ if [ -f .rcode/skills/rcode-create-prd/workflow.md ]; then
13
+ printf '%s\n' ".rcode/skills/rcode-create-prd/workflow.md"
14
+ else
15
+ find .rcode/skills/actions -path "*rcode-create-prd/workflow.md" 2>/dev/null | head -1
16
+ fi
13
17
  ```
14
18
 
15
19
  Read and follow the workflow at that path. If the path is empty:
@@ -33,8 +33,11 @@ if [ -f ./server/dashboard.js ]; then
33
33
  # 2. Installed package copy inside project
34
34
  elif [ -f ./.rcode/lib/server/dashboard.js ]; then
35
35
  DASHBOARD="./.rcode/lib/server/dashboard.js"
36
+ # 3. Local npm dependency install
37
+ elif [ -f ./node_modules/@hanzlaa/rcode/server/dashboard.js ]; then
38
+ DASHBOARD="./node_modules/@hanzlaa/rcode/server/dashboard.js"
36
39
  else
37
- # 3. Global installs — check npm, pnpm, and yarn roots
40
+ # 4. Global installs — check npm, pnpm, and yarn roots
38
41
  for ROOT in "$(npm root -g 2>/dev/null)" "$(pnpm root -g 2>/dev/null)" "$(yarn global dir 2>/dev/null)/node_modules"; do
39
42
  [ -z "$ROOT" ] && continue
40
43
  if [ -f "$ROOT/@hanzlaa/rcode/server/dashboard.js" ]; then
@@ -42,7 +45,7 @@ else
42
45
  break
43
46
  fi
44
47
  done
45
- # 4. Last resort — resolve via the rcode/rcode binary symlink
48
+ # 5. Last resort — resolve via the rcode/rcode binary symlink
46
49
  if [ -z "$DASHBOARD" ]; then
47
50
  for BIN in rcode; do
48
51
  BIN_PATH="$(command -v $BIN 2>/dev/null)" || continue
@@ -39,21 +39,9 @@ Only include domain-probes.md when `HAS_PRODUCT_SIGNALS` is 0.
39
39
  </downstream_awareness>
40
40
 
41
41
  <philosophy>
42
- **User = founder/visionary. Claude = builder.**
43
-
44
- The user knows:
45
- - How they imagine it working
46
- - What it should look/feel like
47
- - What's essential vs nice-to-have
48
- - Specific behaviors or references they have in mind
49
-
50
- The user doesn't know (and shouldn't be asked):
51
- - Codebase patterns (researcher reads the code)
52
- - Technical risks (researcher identifies these)
53
- - Implementation approach (planner figures this out)
54
- - Success metrics (inferred from the work)
55
-
56
- Ask about vision and implementation choices. Capture decisions for downstream agents.
42
+ User = visionary (knows what, not how). Claude = builder (asks about choices, not implementation).
43
+ Ask about vision and decisions. Capture for downstream agents. Never ask about codebase patterns,
44
+ technical risks, or architecture — those are research/planner territory.
57
45
  </philosophy>
58
46
 
59
47
  <scope_guardrail>
@@ -887,7 +875,7 @@ Display banner:
887
875
  Context captured. Launching plan...
888
876
  ```
889
877
 
890
- Launch plan using the Skill tool to avoid nested Task sessions (which cause runtime freezes due to deep agent nesting — see #686):
878
+ Launch plan using the Skill tool to avoid nested Task sessions (which cause runtime freezes due to deep agent nesting):
891
879
  ```
892
880
  Skill(skill="rcode-plan", args="${PHASE} --auto ${RCODE_WS}")
893
881
  ```
@@ -1,5 +1,5 @@
1
1
  <purpose>
2
- Execute all phases in the current milestone in dependency order, with verify gates between waves. Closes #738.
2
+ Execute all phases in the current milestone in dependency order, with verify gates between waves.
3
3
  Reads the ROADMAP.md to determine phase ordering, executes each phase via /rcode-execute, runs /rcode-verify-phase after each, and surfaces blockers before advancing.
4
4
  </purpose>
5
5
 
@@ -32,6 +32,9 @@ if [ -f "package.json" ]; then
32
32
  elif [ -f "Cargo.toml" ]; then
33
33
  cargo test 2>&1
34
34
  elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
35
+ # Python prerequisites: ensure Python 3.10+ is active (python --version).
36
+ # Install dependencies (pip install -r requirements.txt or uv sync).
37
+ # Activate your venv if applicable before running tests.
35
38
  python -m pytest ${REGRESSION_FILES} -q --tb=short 2>&1
36
39
  fi
37
40
  ```
@@ -4,7 +4,7 @@ Execute a phase prompt (SPRINT.md) and create the outcome summary (SUMMARY.md).
4
4
 
5
5
  <required_reading>
6
6
  Read STATE.md before any operation to load project context.
7
- Read config.json for planning behavior settings.
7
+ Read config.yaml for planning behavior settings.
8
8
 
9
9
  @.rcode/references/git-integration.md
10
10
  @.rcode/references/karpathy-guidelines.md
@@ -17,6 +17,26 @@ Valid rcode subagent types (use exact names — do not fall back to 'general-pur
17
17
 
18
18
  <process>
19
19
 
20
+ <preflight name="dependency_check">
21
+ **Check for uninstalled dependencies:** If a `package.json` exists in the project root but `node_modules/` is absent or empty, emit a WARNING and stop:
22
+
23
+ ```
24
+ ⚠ WARNING: package.json found but node_modules/ is missing or empty.
25
+ Run: pnpm install (or npm install if pnpm is not available)
26
+ Then re-run the sprint. Proceeding without installed dependencies will cause task failures.
27
+ ```
28
+
29
+ Do NOT auto-run the install. Emit the message and let the user decide.
30
+
31
+ ```bash
32
+ if [ -f package.json ] && [ ! -d node_modules ] || [ -f package.json ] && [ -z "$(ls -A node_modules 2>/dev/null)" ]; then
33
+ echo "⚠ WARNING: package.json found but node_modules/ is missing or empty."
34
+ echo " Run: pnpm install (or npm install if pnpm is not available)"
35
+ echo " Then re-run the sprint."
36
+ fi
37
+ ```
38
+ </preflight>
39
+
20
40
  <step name="init_context" priority="first">
21
41
  Load execution context (paths only to minimize orchestrator context):
22
42
 
@@ -104,6 +124,8 @@ grep -n "type=\"checkpoint" .planning/phases/XX-name/{phase}-{plan}-SPRINT.md
104
124
 
105
125
  **Pattern A:** init_agent_tracking → capture `EXPECTED_BASE=$(git rev-parse HEAD)` → spawn Task(subagent_type="rcode-executor", model=executor_model) with prompt: execute plan at [path], autonomous, all tasks + SUMMARY + commit, follow deviation/auth rules, report: plan name, tasks, SUMMARY path, commit hash → track agent_id → wait → update tracking → report. **Include `isolation="worktree"` only if `workflow.use_worktrees` is not `false`** (read via `config-get workflow.use_worktrees`). **When using `isolation="worktree"`, include a `<worktree_branch_check>` block in the prompt** instructing the executor to run `git merge-base HEAD {EXPECTED_BASE}` and, if the result differs from `{EXPECTED_BASE}`, reset the branch base with `git reset --soft {EXPECTED_BASE}` before starting work. This corrects a known issue on Windows where `EnterWorktree` creates branches from `main` instead of the feature branch HEAD.
106
126
 
127
+ **Post-install namespace fallback:** If `Task(subagent_type="rcode-executor")` fails with "Agent type not found", the runtime has not yet registered the agent (requires IDE reload after install). Retry with `subagent_type="rihal-executor"`. If that also fails, fall back to Pattern C (execute in main context) and log `[execute-sprint] rcode-executor not available — reload IDE or executing in main context`.
128
+
107
129
  **Pattern B:** Execute segment-by-segment. Autonomous segments: spawn subagent for assigned tasks only (no SUMMARY/commit). Checkpoints: main context. After all segments: aggregate, create SUMMARY, commit. See segment_execution.
108
130
 
109
131
  **Pattern C:** Execute in main using standard flow (step name="execute").
@@ -293,6 +315,12 @@ If a commit is BLOCKED by a hook:
293
315
 
294
316
  After each task (verification passed, done criteria met), commit immediately.
295
317
 
318
+ **Preflight — verify git repo exists:**
319
+ ```bash
320
+ git rev-parse --git-dir
321
+ ```
322
+ If this fails, stop and emit: `No git repository found. Run git init first, then re-run this workflow.`
323
+
296
324
  **1. Check:** `git status --short`
297
325
 
298
326
  **2. Stage individually** (NEVER `git add .` or `git add -A`):
@@ -348,7 +376,7 @@ If new untracked files appeared after running scripts or tools, decide for each:
348
376
  </task_commit>
349
377
 
350
378
  <post_step_revert_gate>
351
- ## Post-Step Revert Detection Gate (closes #737)
379
+ ## Post-Step Revert Detection Gate
352
380
 
353
381
  After committing each task, run a diff check to detect accidental reverts. This catches the class of bug where a task's implementation unknowingly undoes work from a previous task or wave.
354
382
 
@@ -26,6 +26,12 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
26
26
  seen_files[file] = plan
27
27
  ```
28
28
 
29
+ **Pseudocode quality checklist — apply before implementing any algorithm derived above:**
30
+ - No bare `except Exception` — catch specific exceptions
31
+ - No mutation of a collection while iterating over it
32
+ - Guard against file overwrites (check if path exists before writing)
33
+ - Validate inputs before processing
34
+
29
35
  **If overlap is detected:**
30
36
  - Warn the user:
31
37
  ```
@@ -7,12 +7,22 @@ Execute all plans in a phase using wave-based parallel execution. Orchestrator s
7
7
  findings BEFORE any subagents are spawned. If any check fails, stop and
8
8
  route back to the user.
9
9
 
10
+ 0. **Project-status preflight:**
11
+ ```bash
12
+ PROJECT_STATUS=$(node .rcode/bin/rcode-tools.cjs project-status 2>/dev/null || echo uninitialized)
13
+ ```
14
+ If `PROJECT_STATUS` is `uninstalled`, `uninitialized`, or `stub`:
15
+ ```
16
+ Project not initialized. Run /rcode-init first (or /rcode-new-project for a greenfield project), then return here.
17
+ ```
18
+ Stop. Do not proceed until `project-status` returns `real`.
19
+
10
20
  1. **Init state**: `node .rcode/bin/rcode-tools.cjs init execute {N}`
11
21
  2. **Phase index**: list all plans via `phase-plan-index {N}` — extract
12
22
  plan count, wave count, autonomy flag per plan, files_modified overlaps
13
23
  3. **Anti-patterns**: check for `.continue-here.md` (paused state), STATE.md
14
24
  error flag, existing VERIFICATION.md with FAIL items without overrides
15
- 4. **Branch check** (issue #659): confirm current git branch is appropriate
25
+ 4. **Branch check**: confirm current git branch is appropriate
16
26
  for the work. Two checks, both blocking:
17
27
 
18
28
  a. **Not on main/master without consent**: if `git branch --show-current`
@@ -773,7 +783,7 @@ node ".rcode/bin/rcode-tools.cjs" commit "docs(phase-${PARENT_PHASE}): resolve U
773
783
 
774
784
 
775
785
  <step name="uat_gate" priority="blocker">
776
- **UAT gate (added in v3.1.0 after #443 / #448):**
786
+ **UAT gate:**
777
787
 
778
788
  Before marking the phase complete, verify a passing VERIFICATION.md exists for this phase. Without it, the phase advances to `status: executed` (work done, awaiting verification) — not `status: complete`.
779
789
 
@@ -822,7 +832,7 @@ fi
822
832
 
823
833
  **Only when `VERIFICATION_STATUS` is `pass`** — proceed to `update_roadmap` below.
824
834
 
825
- The previous behaviour (printing "Next Up: /rcode-verify-work" without state-gating) caused phases to reach `status: complete` without any human-verified UAT — see #443 for the failure mode.
835
+ The previous behaviour (printing "Next Up: /rcode-verify-work" without state-gating) caused phases to reach `status: complete` without any human-verified UAT.
826
836
  </step>
827
837
 
828
838
  <step name="update_roadmap">
@@ -22,12 +22,12 @@ Valid rcode subagent types (use exact names — do not fall back to 'general-pur
22
22
  Parse `$ARGUMENTS` before anything else:
23
23
  - `--reset-phase-numbers` flag → restart roadmap phase numbering at `1`
24
24
  - `--dry-run` flag → show what would be written, do not commit
25
- - `--from-draft <path>` flag → use an existing MILESTONE-CONTEXT.md or ROADMAP draft as the milestone definition (closes #740). When present, set `DRAFT_FILE=<path>` and `FROM_DRAFT_MODE=true`.
25
+ - `--from-draft <path>` flag → use an existing MILESTONE-CONTEXT.md or ROADMAP draft as the milestone definition. When present, set `DRAFT_FILE=<path>` and `FROM_DRAFT_MODE=true`.
26
26
  - Remaining text → milestone name (optional)
27
27
 
28
28
  If `--from-draft` is absent, continue phase numbering from the previous milestone.
29
29
 
30
- **From-draft mode (closes #740):**
30
+ **From-draft mode:**
31
31
 
32
32
  When `FROM_DRAFT_MODE=true`:
33
33
  1. Read the draft file at `DRAFT_FILE`. Accept any markdown file — MILESTONE-CONTEXT.md, a scratch doc, or a ROADMAP partial.
@@ -881,6 +881,10 @@ Present completion summary:
881
881
  **[N] phases** | **[X] requirements** | Ready to build ✓
882
882
  ```
883
883
 
884
+ > **Verify before planning:**
885
+ > (a) `.planning/ROADMAP.md` contains real `## Phase N` headings — open it and add them if the file is still a stub.
886
+ > (b) Run `npx rcode state sync --from-disk` to populate `.rcode/state.json` with the phases array so downstream commands (`/rcode-plan`, `/rcode-execute-sprint`, etc.) can read the phase list.
887
+
884
888
  **If auto mode:**
885
889
 
886
890
  ```
@@ -8,7 +8,7 @@ Sub-steps of plan.md — Steps 5 through 5.7. Handles research, validation archi
8
8
 
9
9
  **If `has_research` is true (from init) AND no `--research` flag:** Use existing, skip to step 6.
10
10
 
11
- **If RESEARCH.md missing AND `has_context` is true AND no `--research` flag:** Skip research silently and proceed to step 6. CONTEXT.md already captures the user's design decisions — re-researching adds tokens without new signal. Display: `Research skipped — CONTEXT.md found (use --research to force)`. This closes #588.
11
+ **If RESEARCH.md missing AND `has_context` is true AND no `--research` flag:** Skip research silently and proceed to step 6. CONTEXT.md already captures the user's design decisions — re-researching adds tokens without new signal. Display: `Research skipped — CONTEXT.md found (use --research to force)`.
12
12
 
13
13
  **If RESEARCH.md missing OR `--research` flag:**
14
14
 
@@ -3,8 +3,8 @@ Sub-step of plan.md — Step 8 Spawn rcode-planner Agent. Spawns rcode-planner w
3
3
  </purpose>
4
4
 
5
5
  <filename_convention>
6
- Issue #657 — every SPRINT.md, including the first plan in a phase, uses the
7
- sequence-numbered form `{phase}-{plan}-SPRINT.md` (no leading zeros per #652).
6
+ Every SPRINT.md, including the first plan in a phase, uses the
7
+ sequence-numbered form `{phase}-{plan}-SPRINT.md` (no leading zeros).
8
8
  Examples: `8-1-SPRINT.md`, `8-2-SPRINT.md`. Do NOT emit a bare `{phase}-SPRINT.md`
9
9
  or `{phase}-PLAN.md` for the first plan — that creates an inconsistent series
10
10
  when a second plan is added later. The plan-number computation in plan.md uses