@hanzlaa/rcode 4.1.1 → 4.3.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 (105) 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 +29 -0
  6. package/cli/install.js +233 -15
  7. package/cli/lib/config.cjs +4 -2
  8. package/cli/lib/fsutil.cjs +13 -2
  9. package/cli/lib/homedir.cjs +21 -0
  10. package/cli/lib/schemas.cjs +6 -1
  11. package/cli/nuke.js +13 -8
  12. package/cli/postinstall.js +14 -4
  13. package/cli/rcode-slash-router.cjs +118 -0
  14. package/cli/uninstall.js +59 -1
  15. package/cli/update.js +10 -5
  16. package/cli/workflow.js +3 -1
  17. package/dist/rcode.js +241 -227
  18. package/package.json +1 -1
  19. package/rcode/bin/rcode-tools.cjs +15 -6
  20. package/rcode/commands/scaffold-project.md +2 -2
  21. package/rcode/skills/actions/2-plan/rcode-create-epics-and-stories/steps/step-04-final-validation.md +1 -1
  22. package/rcode/skills/actions/2-plan/rcode-create-milestone/steps/README.md +2 -2
  23. package/rcode/skills/actions/2-plan/rcode-create-milestone/steps/step-09-state-sync.md +1 -1
  24. package/rcode/skills/actions/4-implementation/rcode-code-review/steps/step-02-review.md +1 -1
  25. package/rcode/skills/actions/4-implementation/rcode-git-flow/SKILL.md +1 -1
  26. package/rcode/skills/actions/4-implementation/rcode-scaffold-project/SKILL.md +39 -12
  27. package/rcode/skills/actions/4-implementation/rcode-scaffold-project/steps/step-01-target.md +18 -3
  28. package/rcode/skills/actions/4-implementation/rcode-scaffold-project/steps/step-02-safety.md +27 -3
  29. package/rcode/skills/actions/4-implementation/rcode-scaffold-project/steps/step-03-brownfield.md +57 -0
  30. package/rcode/skills/actions/4-implementation/rcode-scaffold-project/steps/step-03-clone.md +4 -1
  31. package/rcode/skills/actions/4-implementation/rcode-scaffold-project/steps/step-04-post-setup.md +15 -1
  32. package/rcode/skills/actions/4-implementation/rcode-trim/SKILL.md +1 -1
  33. package/rcode/workflows/audit-milestone.md +1 -1
  34. package/rcode/workflows/discuss-phase.md +1 -1
  35. package/rcode/workflows/execute-milestone.md +1 -1
  36. package/rcode/workflows/execute-regression-gates.md +3 -0
  37. package/rcode/workflows/execute-sprint.md +27 -1
  38. package/rcode/workflows/execute-waves.md +6 -0
  39. package/rcode/workflows/execute.md +13 -3
  40. package/rcode/workflows/new-milestone.md +2 -2
  41. package/rcode/workflows/new-project.md +4 -0
  42. package/rcode/workflows/plan-research-validation.md +1 -1
  43. package/rcode/workflows/plan-spawn-planner.md +2 -2
  44. package/rcode/workflows/plan.md +34 -15
  45. package/rcode/workflows/review.md +2 -0
  46. package/rcode/workflows/scaffold-project.md +5 -1
  47. package/rcode/workflows/session-report.md +1 -1
  48. package/rcode/workflows/ship.md +39 -0
  49. package/rcode/workflows/sprint-planning.md +27 -0
  50. package/rcode/workflows/status.md +3 -3
  51. package/server/dashboard.js +26 -7
  52. package/server/lib/api.js +62 -4
  53. package/server/lib/html/client/agents-data.js +22 -18
  54. package/server/lib/html/client/app.js +3 -0
  55. package/server/lib/html/client/components/AgentCard.js +127 -0
  56. package/server/lib/html/client/components/App.js +104 -39
  57. package/server/lib/html/client/components/CommandPalette.js +133 -0
  58. package/server/lib/html/client/components/FileReader.js +116 -0
  59. package/server/lib/html/client/components/FilterChips.js +94 -0
  60. package/server/lib/html/client/components/NotifyCenter.js +117 -0
  61. package/server/lib/html/client/components/OrchPanel.js +80 -52
  62. package/server/lib/html/client/components/PhaseGraph.js +300 -0
  63. package/server/lib/html/client/components/RejectDialog.js +78 -0
  64. package/server/lib/html/client/components/RunnerPicker.js +190 -0
  65. package/server/lib/html/client/components/Sidebar.js +106 -61
  66. package/server/lib/html/client/components/StatusSummaryBar.js +76 -0
  67. package/server/lib/html/client/components/TaskPipeline.js +83 -0
  68. package/server/lib/html/client/components/Topbar.js +86 -39
  69. package/server/lib/html/client/components/dashboard/Blockers.js +57 -0
  70. package/server/lib/html/client/components/dashboard/CompletedTasks.js +47 -0
  71. package/server/lib/html/client/components/dashboard/CurrentPhase.js +107 -0
  72. package/server/lib/html/client/components/dashboard/InProgress.js +72 -0
  73. package/server/lib/html/client/components/dashboard/ProgressDonut.js +101 -0
  74. package/server/lib/html/client/components/dashboard/ProgressTimeline.js +101 -0
  75. package/server/lib/html/client/components/dashboard/ProjectHealth.js +80 -0
  76. package/server/lib/html/client/components/dashboard/RecentDecisions.js +57 -0
  77. package/server/lib/html/client/components/dashboard/Timeline.js +143 -0
  78. package/server/lib/html/client/components/shared.js +47 -11
  79. package/server/lib/html/client/filter-state.js +72 -0
  80. package/server/lib/html/client/icons-client.js +7 -0
  81. package/server/lib/html/client/notify.js +75 -0
  82. package/server/lib/html/client/orchestrator.js +168 -41
  83. package/server/lib/html/client/preact.js +13 -8
  84. package/server/lib/html/client/store.js +70 -6
  85. package/server/lib/html/client/util.js +78 -0
  86. package/server/lib/html/client/vendor/htm.js +1 -0
  87. package/server/lib/html/client/vendor/preact-hooks.js +2 -0
  88. package/server/lib/html/client/vendor/preact.js +2 -0
  89. package/server/lib/html/client/views/AgentsView.js +144 -51
  90. package/server/lib/html/client/views/FilesView.js +20 -103
  91. package/server/lib/html/client/views/KanbanView.js +40 -21
  92. package/server/lib/html/client/views/MemoryView.js +26 -9
  93. package/server/lib/html/client/views/MilestonesView.js +4 -4
  94. package/server/lib/html/client/views/OrchestrationView.js +154 -19
  95. package/server/lib/html/client/views/OverviewView.js +47 -239
  96. package/server/lib/html/client/views/PhasesView.js +50 -6
  97. package/server/lib/html/client/views/RoadmapView.js +6 -3
  98. package/server/lib/html/client/views/SprintsView.js +50 -6
  99. package/server/lib/html/client/views/TasksView.js +4 -3
  100. package/server/lib/html/client.js +21 -4
  101. package/server/lib/html/css.js +2761 -8
  102. package/server/lib/html/icons.js +7 -0
  103. package/server/lib/html/shell.js +10 -3
  104. package/server/lib/scanner.js +376 -39
  105. package/server/orchestrator.js +329 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzlaa/rcode",
3
- "version": "4.1.1",
3
+ "version": "4.3.0",
4
4
  "description": "rcode — the AI team that never forgets. Persistent memory, specialist agents, and slash commands for AI IDEs. Works in Claude Code, Cursor, Gemini, VS Code, and Antigravity.",
5
5
  "main": "cli/index.js",
6
6
  "bin": {
@@ -447,12 +447,19 @@ function cmdInit(workflowName, rawArgs) {
447
447
  } catch { /* parser failure shouldn't break init */ }
448
448
  }
449
449
 
450
- // Find phase directory on disk (matches both '6-name' and legacy '06-name').
450
+ // Find phase directory on disk (matches '1-name', '01-name', and '001-name' prefixes).
451
451
  let phaseDirEntry = null;
452
452
  if (fs.existsSync(phasesDir)) {
453
- const padded = String(phaseNum).padStart(2, '0');
453
+ const n = String(phaseNum);
454
+ const pad2 = n.padStart(2, '0');
455
+ const pad3 = n.padStart(3, '0');
454
456
  for (const entry of fs.readdirSync(phasesDir)) {
455
- if (entry === String(phaseNum) || entry.startsWith(`${phaseNum}-`) || entry.startsWith(`${padded}-`)) {
457
+ if (
458
+ entry === n ||
459
+ entry.startsWith(`${n}-`) ||
460
+ entry.startsWith(`${pad2}-`) ||
461
+ entry.startsWith(`${pad3}-`)
462
+ ) {
456
463
  phaseDirEntry = entry;
457
464
  break;
458
465
  }
@@ -463,10 +470,12 @@ function cmdInit(workflowName, rawArgs) {
463
470
  out.phase_number = String(phaseNum);
464
471
  // Issue #652 — no leading zeros in planning artifacts. The field name
465
472
  // 'padded_phase' is kept for workflow backward compat but the value is
466
- // now the canonical (unpadded) phase number. The resolver above still
467
- // accepts legacy '06-name' directories for older projects.
473
+ // now the canonical (unpadded) phase number (e.g. "6", not "06").
474
+ // Workflows MUST NOT rely on this being zero-padded; use phase_number instead.
475
+ // The resolver above still accepts legacy '06-name' / '006-name' dirs for older projects.
468
476
  out.padded_phase = String(phaseNum);
469
477
  out.phase_name = roadmapPhase ? roadmapPhase.name : null;
478
+ // Strip all leading-zero prefix digits so '001-name', '01-name', '1-name' → 'name'.
470
479
  out.phase_slug = phaseDirEntry ? phaseDirEntry.replace(/^\d+-/, '') : null;
471
480
  out.phase_dir = phaseDirEntry ? path.join(PLANNING_DIR, 'phases', phaseDirEntry) : null;
472
481
 
@@ -1367,7 +1376,7 @@ function cmdState(subArgs) {
1367
1376
  String(p.id) === String(flags.phase) ||
1368
1377
  p.name === flags.phase
1369
1378
  );
1370
- if (phaseIdx === -1) throw new Error(`Phase "${flags.phase}" not found in state`);
1379
+ if (phaseIdx === -1) throw new Error(`Phase "${flags.phase}" not found in state. If the phase exists in ROADMAP.md, run "rcode state sync" or "/rcode-update" to synchronize state first.`);
1371
1380
  const phase = state.phases[phaseIdx];
1372
1381
 
1373
1382
  // Derive phase number: prefer explicit .number, fallback to array position
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: rcode-scaffold-project
3
- description: "Scaffold a new project from the official rcode template repo."
4
- argument-hint: "[project-name]"
3
+ description: "Scaffold a new project from the official rcode template repo, or add rcode to an existing project with --here."
4
+ argument-hint: "[project-name | --here]"
5
5
  allowed-tools: Read, Write, Bash, Glob, Grep, AskUserQuestion
6
6
  ---
7
7
 
@@ -119,7 +119,7 @@ If all validations pass:
119
119
  - Ensure proper formatting
120
120
  - Save the final epics.md
121
121
 
122
- ### 7. State Sync (MANDATORY — closes #126)
122
+ ### 7. State Sync (MANDATORY)
123
123
 
124
124
  After saving `.planning/epics.md`, you MUST sync state so `.rcode/state.json` reflects the new epics. Without this, downstream workflows (`/rcode-status`, `/rcode-progress`, `/rcode-execute`) see a divergent picture.
125
125
 
@@ -4,8 +4,8 @@ This skill uses the same step-file architecture as `rcode-create-prd` and `rcode
4
4
 
5
5
  ## Status
6
6
 
7
- - All 10 step files are **implemented and production-ready** as of #134.
8
- - Scaffolded in #129; completed in #134; compliance re-verified in #137.
7
+ - All 10 step files are **implemented and production-ready**.
8
+ - Scaffolded, completed, and compliance-verified across multiple releases.
9
9
  - If a step is missing from this directory at runtime, re-install the package — do not fall back to inline generation.
10
10
 
11
11
  ## Expected Step Files (per workflow.md)
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## STEP GOAL
6
6
 
7
- Call the state-sync CLI so `.rcode/state.json` reflects every milestone and phase we just wrote to `ROADMAP.md`. This closes the drift loophole documented in issue #126 and enforced by `_shared/state-sync-rule.md`.
7
+ Call the state-sync CLI so `.rcode/state.json` reflects every milestone and phase we just wrote to `ROADMAP.md`. This closes the state-drift loophole enforced by `_shared/state-sync-rule.md`.
8
8
 
9
9
  ## MANDATORY RULES
10
10
 
@@ -17,7 +17,7 @@ failed_layers: '' # set at runtime: comma-separated list of layers that failed o
17
17
 
18
18
  2. Launch parallel subagents without conversation context. If subagents are not available, generate prompt files in `{implementation_artifacts}` — one per reviewer role below — and HALT. Ask the user to run each in a separate session (ideally a different LLM) and paste back the findings. When findings are pasted, resume from this point and proceed to step 3.
19
19
 
20
- **Subagent mapping** (issue #720): the three reviewer roles below map to actual agents shipped in `.claude/agents/`. The skill names that used to be referenced here (`rcode-review-adversarial-general`, `rcode-review-edge-case-hunter`) are skills, not subagents, and `Task(subagent_type=...)` cannot reach them. Use the agents listed.
20
+ **Subagent mapping:** the three reviewer roles below map to actual agents shipped in `.claude/agents/`. The skill names that used to be referenced here (`rcode-review-adversarial-general`, `rcode-review-edge-case-hunter`) are skills, not subagents, and `Task(subagent_type=...)` cannot reach them. Use the agents listed.
21
21
 
22
22
  - **Blind Hunter** — receives `{diff_output}` only. No spec, no context docs, no project access. Dispatch:
23
23
  `Task(subagent_type="rcode-security-adversary", model="{review_model}", prompt="<adversarial review of diff>")`. The security-adversary persona's cynical mindset is the right fit for an isolated diff-only review.
@@ -81,7 +81,7 @@ Do NOT include: force-pushes to main; commits with AI attribution; bundled commi
81
81
 
82
82
  ## Examples
83
83
 
84
- **Happy path** — Issue #387 (refresh README counts) → branch `docs/readme-counts` → 1 commit with subject `docs(readme): refresh agent/command/skill counts and add MIGRATIONS link` → push → PR with `Closes #387` → squash-merge.
84
+ **Happy path** — A tracked issue (refresh README counts) → branch `docs/readme-counts` → 1 commit with subject `docs(readme): refresh agent/command/skill counts and add MIGRATIONS link` → push → PR with `Closes` the tracked issue → squash-merge.
85
85
 
86
86
  **Edge case — conflict on team.yaml** — Two branches both edit team.yaml. Resolve by: pull both versions, manually merge agent entries (preserve unique IDs), run `node --test test/agents-registry.test.cjs`, commit.
87
87
 
@@ -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
@@ -875,7 +875,7 @@ Display banner:
875
875
  Context captured. Launching plan...
876
876
  ```
877
877
 
878
- 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):
879
879
  ```
880
880
  Skill(skill="rcode-plan", args="${PHASE} --auto ${RCODE_WS}")
881
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
  ```
@@ -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
 
@@ -295,6 +315,12 @@ If a commit is BLOCKED by a hook:
295
315
 
296
316
  After each task (verification passed, done criteria met), commit immediately.
297
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
+
298
324
  **1. Check:** `git status --short`
299
325
 
300
326
  **2. Stage individually** (NEVER `git add .` or `git add -A`):
@@ -350,7 +376,7 @@ If new untracked files appeared after running scripts or tools, decide for each:
350
376
  </task_commit>
351
377
 
352
378
  <post_step_revert_gate>
353
- ## Post-Step Revert Detection Gate (closes #737)
379
+ ## Post-Step Revert Detection Gate
354
380
 
355
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.
356
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