bemadralphy 0.3.7 → 2.0.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 (78) hide show
  1. package/README.md +312 -381
  2. package/dist/ai/anthropic.d.ts +7 -0
  3. package/dist/ai/anthropic.js +38 -0
  4. package/dist/ai/anthropic.js.map +1 -0
  5. package/dist/ai/index.d.ts +3 -0
  6. package/dist/ai/index.js +52 -0
  7. package/dist/ai/index.js.map +1 -0
  8. package/dist/ai/ollama.d.ts +7 -0
  9. package/dist/ai/ollama.js +39 -0
  10. package/dist/ai/ollama.js.map +1 -0
  11. package/dist/ai/openai.d.ts +7 -0
  12. package/dist/ai/openai.js +37 -0
  13. package/dist/ai/openai.js.map +1 -0
  14. package/dist/ai/provider.d.ts +10 -0
  15. package/dist/ai/provider.js +14 -0
  16. package/dist/ai/provider.js.map +1 -0
  17. package/dist/beads/adapter.d.ts +3 -1
  18. package/dist/beads/adapter.js +17 -1
  19. package/dist/beads/adapter.js.map +1 -1
  20. package/dist/cli.js +82 -1
  21. package/dist/cli.js.map +1 -1
  22. package/dist/config.d.ts +9 -0
  23. package/dist/config.js.map +1 -1
  24. package/dist/engines/cli-adapter.js +42 -3
  25. package/dist/engines/cli-adapter.js.map +1 -1
  26. package/dist/engines/index.js +0 -2
  27. package/dist/engines/index.js.map +1 -1
  28. package/dist/engines/ralphy.d.ts +7 -1
  29. package/dist/engines/ralphy.js +5 -8
  30. package/dist/engines/ralphy.js.map +1 -1
  31. package/dist/execution/retry.d.ts +7 -0
  32. package/dist/execution/retry.js +56 -0
  33. package/dist/execution/retry.js.map +1 -0
  34. package/dist/index.d.ts +1 -1
  35. package/dist/index.js +1 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/orchestrator.d.ts +12 -0
  38. package/dist/orchestrator.js +94 -203
  39. package/dist/orchestrator.js.map +1 -1
  40. package/dist/phases/execute.js +53 -29
  41. package/dist/phases/execute.js.map +1 -1
  42. package/dist/phases/sync.js +11 -9
  43. package/dist/phases/sync.js.map +1 -1
  44. package/dist/phases/types.d.ts +8 -0
  45. package/dist/planning/index.js +61 -50
  46. package/dist/planning/index.js.map +1 -1
  47. package/dist/specs/archive.js +15 -7
  48. package/dist/specs/archive.js.map +1 -1
  49. package/dist/specs/delta.js +3 -4
  50. package/dist/specs/delta.js.map +1 -1
  51. package/dist/specs/generate.js +7 -4
  52. package/dist/specs/generate.js.map +1 -1
  53. package/dist/specs/index.d.ts +1 -0
  54. package/dist/specs/index.js +1 -0
  55. package/dist/specs/index.js.map +1 -1
  56. package/dist/specs/validate.d.ts +1 -0
  57. package/dist/specs/validate.js +92 -0
  58. package/dist/specs/validate.js.map +1 -0
  59. package/dist/state.d.ts +10 -0
  60. package/dist/state.js.map +1 -1
  61. package/dist/steering/index.js +16 -3
  62. package/dist/steering/index.js.map +1 -1
  63. package/dist/tasks/db.d.ts +3 -0
  64. package/dist/tasks/db.js +42 -0
  65. package/dist/tasks/db.js.map +1 -0
  66. package/dist/tasks/index.d.ts +2 -0
  67. package/dist/tasks/index.js +2 -0
  68. package/dist/tasks/index.js.map +1 -0
  69. package/dist/tasks/manager.d.ts +36 -0
  70. package/dist/tasks/manager.js +166 -0
  71. package/dist/tasks/manager.js.map +1 -0
  72. package/dist/templates/index.d.ts +4 -0
  73. package/dist/templates/index.js +37 -0
  74. package/dist/templates/index.js.map +1 -0
  75. package/dist/utils/exec.d.ts +9 -0
  76. package/dist/utils/exec.js +22 -1
  77. package/dist/utils/exec.js.map +1 -1
  78. package/package.json +5 -1
package/README.md CHANGED
@@ -1,207 +1,247 @@
1
1
  # BeMadRalphy
2
2
 
3
- **Be**(ads) + (B)**Mad** + **Ralphy** + [OpenSpec](https://github.com/Fission-AI/OpenSpec) four tools, one pipeline, zero gaps. **CLI-only.**
3
+ **Be**(ads) + (B)**Mad** + **Ralphy** + [OpenSpec](https://github.com/Fission-AI/OpenSpec) + [Superpowers](https://github.com/obra/superpowers) -- five parents, one self-contained CLI.
4
4
 
5
5
  BeMadRalphy is a product-delivery operating system for AI-assisted teams: methodology first, code generation second.
6
6
 
7
- > End-to-end automated coding: idea in planning task graph swarm-aware execution living specs deployment.
7
+ > End-to-end automated coding: idea in, planning, task graph, swarm-aware execution, living specs, deployment out.
8
8
 
9
9
  [![npm version](https://img.shields.io/npm/v/bemadralphy.svg)](https://www.npmjs.com/package/bemadralphy)
10
10
  [![npm downloads](https://img.shields.io/npm/dm/bemadralphy.svg)](https://www.npmjs.com/package/bemadralphy)
11
11
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
12
12
 
13
- ## Status
13
+ ---
14
+
15
+ ## Quick Links
16
+
17
+ - First local run: [docs/getting-started.md](docs/getting-started.md)
18
+ - Contributor setup: [docs/onboarding.md](docs/onboarding.md)
19
+ - Architecture deep dive: [docs/architecture.md](docs/architecture.md)
20
+ - Positioning and ICP: [docs/positioning.md](docs/positioning.md)
21
+
22
+ ---
23
+
24
+ ## What Is BeMadRalphy?
14
25
 
15
- BeMadRalphy runs end-to-end locally with real external CLI integrations.
26
+ BeMadRalphy v2 is a **self-contained CLI agent**. All planning, task management, specification lifecycle, and execution orchestration run internally -- no external parent CLIs required.
16
27
 
17
- Current implementation includes:
28
+ It absorbs the best ideas from five projects:
18
29
 
19
- - `idea.md`/`plan.md` intake with `.bemadralphy/intake.yaml` output
20
- - BMAD bootstrap (`bmad install`) and generated planning artifacts under `_bmad-output/`
21
- - Steering file generation (AGENTS.md, CLAUDE.md, Cursor/Windsurf/Cline/Kiro rules)
22
- - `tasks.md` generation plus Beads sync (`bd init`, `bd create`, `bd ready`, `bd close`, `bd update`)
23
- - Per-phase state persistence in `.bemadralphy/state.yaml`
24
- - Engine execution through explicit CLI contracts for all supported engines
25
- - OpenSpec lifecycle integration (`openspec init`, `openspec validate`, `openspec archive`)
30
+ | Parent | What BeMadRalphy absorbs |
31
+ | --- | --- |
32
+ | [BMAD-METHOD](https://github.com/bmad-code-org/BMAD-METHOD) | Planning prompts, workflow patterns, agent personas |
33
+ | [Beads](https://github.com/steveyegge/beads) | Task schema, dependency resolution, ready-queue algorithm |
34
+ | [Ralphy](https://github.com/michaelshimeles/ralphy) | Execution orchestration, retry logic, prompt construction |
35
+ | [OpenSpec](https://github.com/Fission-AI/OpenSpec) | Spec templates, validation rules, delta/archive lifecycle |
36
+ | [Superpowers](https://github.com/obra/superpowers) | TDD guardrails, two-stage review, anti-rationalization patterns |
37
+
38
+ The result is a single CLI that takes you from a rough idea to a deployed, documented, and tested codebase with minimal human intervention.
26
39
 
27
40
  ---
28
41
 
29
- ## Start Here
42
+ ## Prerequisites
43
+
44
+ - **Node.js 18+** (or Bun 1.0+)
45
+ - **Git**
46
+ - **At least one AI API key** (`ANTHROPIC_API_KEY` or `OPENAI_API_KEY`) for the planning phase
47
+ - **At least one coding agent CLI** on PATH (e.g., `claude`, `cursor`, `codex`, `kimi`, `gemini`, `ollama`)
48
+ - Optional: `gh` (GitHub CLI) for `--create-pr` support
49
+ - Optional: `ollama` for local model execution
30
50
 
31
- - First local run guide: [`docs/getting-started.md`](docs/getting-started.md)
32
- - Contributor/developer setup: [`docs/onboarding.md`](docs/onboarding.md)
33
- - Architecture and flow details: [`docs/architecture.md`](docs/architecture.md)
51
+ No external `bmad`, `bd`, `openspec`, or `ralphy` CLIs are required.
34
52
 
35
53
  ---
36
54
 
37
- ## What is BeMadRalphy?
55
+ ## Installation
38
56
 
39
- BeMadRalphy is a CLI orchestrator that merges:
57
+ ```bash
58
+ # npm (recommended)
59
+ npm install -g bemadralphy
40
60
 
41
- - **[BMAD-METHOD](https://github.com/bmad-code-org/BMAD-METHOD)** — Agile AI-driven planning (product briefs, PRDs, architecture, epics & stories)
42
- - **[Beads](https://github.com/steveyegge/beads)** — Git-backed graph issue tracker and persistent AI memory
43
- - **[Ralphy](https://github.com/michaelshimeles/ralphy)** — Autonomous AI coding loop with multi-engine support ([site](https://ralphy.goshen.fyi/))
44
- - **[OpenSpec](https://github.com/Fission-AI/OpenSpec)** — Living specifications and delta-based change tracking
61
+ # pnpm
62
+ pnpm add -g bemadralphy
45
63
 
46
- Into a single, seamless pipeline that takes you from a rough idea to a deployed, documented, and tested codebase — with minimal human intervention.
64
+ # bun
65
+ bun add -g bemadralphy
47
66
 
48
- ### Positioning and ICP
67
+ # yarn
68
+ yarn global add bemadralphy
49
69
 
50
- - Primary ICP: product teams of 2-10 engineers shipping continuously
51
- - Secondary ICPs: solo builders and agencies operating repeatable delivery workflows
52
- - Differentiation: not "write code faster," but "ship products systematically" via BMAD-driven intent-to-delivery
70
+ # or use the install script
71
+ curl -fsSL https://raw.githubusercontent.com/hxp-pxh/BeMadRalphy/main/install.sh | bash
72
+ ```
53
73
 
54
- For full positioning rationale and risk mitigation strategy, see [`docs/positioning.md`](docs/positioning.md).
74
+ Verify:
75
+
76
+ ```bash
77
+ bemadralphy --version
78
+ bemadralphy --help
79
+ ```
80
+
81
+ If your shell cannot find `bemadralphy` after global install:
82
+
83
+ ```bash
84
+ npx bemadralphy --help
85
+
86
+ # or add npm global bin to PATH
87
+ export PATH="$(npm config get prefix)/bin:$PATH"
88
+ ```
89
+
90
+ ### Docker
91
+
92
+ ```bash
93
+ docker pull ghcr.io/hxp-pxh/bemadralphy:latest
94
+ docker run -v $(pwd):/workspace ghcr.io/hxp-pxh/bemadralphy init
95
+ ```
55
96
 
56
97
  ---
57
98
 
58
- ## The 9-Phase Pipeline
99
+ ## Quick Start
100
+
101
+ ```bash
102
+ # 1. Create a new project directory
103
+ mkdir my-awesome-app && cd my-awesome-app
104
+
105
+ # 2. Initialize BeMadRalphy
106
+ npx bemadralphy init
107
+
108
+ # 3. Write your idea
109
+ echo "A todo app with real-time sync and offline support" > idea.md
110
+
111
+ # 4. Set an API key for planning
112
+ export ANTHROPIC_API_KEY=sk-ant-...
59
113
 
60
- ```mermaid
61
- flowchart TD
62
- subgraph explore [Phase 0: Explore]
63
- ExploreCmd[bemadralphy explore]
64
- ExploreReport[Exploration report]
65
- end
66
- subgraph intake [Phase 1: Idea Intake]
67
- IdeaMD[idea.md]
68
- DetectMode{Greenfield or brownfield?}
69
- IntakeYAML[intake.yaml]
70
- end
71
- subgraph planning [Phase 2: Planning]
72
- Brief[Product brief]
73
- PRD[PRD]
74
- Arch[Architecture]
75
- Stories[Epics and stories]
76
- end
77
- subgraph steer [Phase 3: Agent Steering]
78
- AllFiles[14+ steering files]
79
- end
80
- subgraph scaffold [Phase 4: Scaffolding]
81
- GitInit[git init + monorepo]
82
- PkgJson[package.json]
83
- end
84
- subgraph tasks [Phase 5: Task Sync]
85
- Beads[(Beads graph)]
86
- TasksMD[tasks.md]
87
- end
88
- subgraph exec [Phase 6: Execution]
89
- Detect{Swarm capable?}
90
- NativeSwarm[Native swarm]
91
- ProcessParallel[Process parallel]
92
- end
93
- subgraph verify [Phase 7: Verification]
94
- Completeness[Completeness]
95
- Correctness[Correctness]
96
- Coherence[Coherence]
97
- end
98
- subgraph post [Phase 8: Post-Execution]
99
- CodeReview[Code review]
100
- Docs[Documentation]
101
- Deploy[Deployment]
102
- end
103
- ExploreCmd --> ExploreReport --> IdeaMD
104
- IdeaMD --> DetectMode --> IntakeYAML
105
- IntakeYAML --> Brief --> PRD --> Arch --> Stories
106
- Stories --> AllFiles --> GitInit --> PkgJson
107
- PkgJson --> Beads --> TasksMD
108
- TasksMD --> Detect
109
- Detect -->|yes| NativeSwarm
110
- Detect -->|no| ProcessParallel
111
- NativeSwarm --> Completeness
112
- ProcessParallel --> Completeness
113
- Completeness --> Correctness --> Coherence
114
- Coherence --> CodeReview --> Docs --> Deploy
114
+ # 5. Run the full pipeline
115
+ npx bemadralphy run
116
+
117
+ # 6. Check environment readiness any time
118
+ npx bemadralphy doctor
115
119
  ```
116
120
 
117
- | Phase | What happens |
118
- | --------------------- | ---------------------------------------------------------------------------------------------------------------------- |
119
- | **0. Explore** | Optional. Investigate codebase (brownfield) or problem domain (greenfield) before committing to a plan. |
120
- | **1. Idea Intake** | Read `idea.md`, detect greenfield vs brownfield, classify project type, ask remaining questions, output `intake.yaml`. |
121
- | **2. Planning** | Greenfield: product brief PRD architecture → stories. Brownfield: proposal → spec deltas → design → tasks. |
122
- | **3. Agent Steering** | Generate 14+ steering files for every IDE/agent (Cursor, Claude, Copilot, Windsurf, Cline, Kiro, etc.). |
123
- | **4. Scaffolding** | `git init`, monorepo structure, `package.json`, `.gitignore`, `.env`, test/lint/CI configs. |
124
- | **5. Task Sync** | Convert stories to Beads issues (`bd create`, `bd dep add`). Generate `tasks.md`. Cost estimate. |
125
- | **6. Execution** | Swarm-aware Beads-driven loop. Native swarm for Claude/Kimi/Codex; process-level parallelism for others. |
126
- | **7. Verification** | Semantic check: completeness, correctness, coherence. Fix-up tasks fed back to Beads if needed. |
127
- | **8. Post-Execution** | Code review, full docs suite, living specs, deployment, release management, final summary. |
121
+ BeMadRalphy will:
122
+
123
+ 1. Parse your idea and detect greenfield vs. brownfield
124
+ 2. Generate a full PRD, architecture, and stories via direct AI calls
125
+ 3. Create steering files for every major AI agent/IDE
126
+ 4. Scaffold the project (git, configs, CI)
127
+ 5. Convert stories to dependency-aware tasks in an embedded SQLite database
128
+ 6. Execute tasks with retry logic and optional two-stage review
129
+ 7. Verify the implementation against living specs
130
+ 8. Generate documentation and deploy
128
131
 
129
132
  ---
130
133
 
131
- ## AI Engine Support
134
+ ## The 9-Phase Pipeline
132
135
 
133
- - `claude` (native swarm): `ralphy --claude --max-iterations 1 <task>`
134
- - `kimi` (native swarm): `kimi <task>`
135
- - `codex` (native swarm): `ralphy --codex --max-iterations 1 <task>`
136
- - `cursor`: `ralphy --cursor --max-iterations 1 <task>`
137
- - `opencode`: `ralphy --opencode --max-iterations 1 <task>`
138
- - `qwen`: `ralphy --qwen --max-iterations 1 <task>`
139
- - `copilot`: `ralphy --copilot --max-iterations 1 <task>`
140
- - `gemini`: `gemini <task>`
141
- - `ollama`: `ollama run <model> <task>` (default model via `OLLAMA_MODEL` or `llama3.2`)
142
- - `ralphy`: `ralphy --max-iterations 1 <task>`
136
+ ```text
137
+ Phase 0 Phase 1 Phase 2 Phase 3 Phase 4
138
+ Explore > Intake > Planning > Steering > Scaffold
139
+ |
140
+ Phase 8 Phase 7 Phase 6 Phase 5 v
141
+ Post < Verify < Execute < Task Sync <-----+
142
+ ```
143
+
144
+ | Phase | What happens |
145
+ | --- | --- |
146
+ | **0. Explore** | Optional. Investigate a codebase or problem domain before planning. |
147
+ | **1. Intake** | Read `idea.md`, detect greenfield/brownfield, classify project, output `intake.yaml`. |
148
+ | **2. Planning** | Direct AI calls generate product brief, PRD, architecture, and stories using embedded templates. |
149
+ | **3. Steering** | Generate 14+ steering files for every IDE and agent (Cursor, Claude, Copilot, Windsurf, Cline, Kiro, etc.). |
150
+ | **4. Scaffold** | `git init`, monorepo structure, `package.json`, lint/test/CI configs. |
151
+ | **5. Task Sync** | Convert stories to tasks in `.bemadralphy/tasks.db` (embedded SQLite) and generate `tasks.md`. |
152
+ | **6. Execute** | Swarm-aware execution using the internal ready queue, retry with exponential backoff, and optional two-stage review (spec compliance + code quality). |
153
+ | **7. Verify** | Semantic check: completeness, correctness, coherence. Fix-up tasks fed back if needed. |
154
+ | **8. Post** | Code review, full documentation suite, living specs, deployment, release management. |
143
155
 
144
156
  ---
145
157
 
146
- ## Autonomy Modes
158
+ ## AI Engine Support
159
+
160
+ BeMadRalphy delegates code execution to whichever coding agent CLI you have installed:
161
+
162
+ | Engine | Native swarm |
163
+ | --- | --- |
164
+ | `claude` (default) | Yes |
165
+ | `kimi` | Yes |
166
+ | `codex` | Yes |
167
+ | `cursor` | No |
168
+ | `opencode` | No |
169
+ | `qwen` | No |
170
+ | `copilot` | No |
171
+ | `gemini` | No |
172
+ | `ollama` | No |
147
173
 
148
- | Mode | Description |
149
- | ------------------------------------ | ------------------------------------------------------------------------------------------------ |
150
- | **Full Autonomous** (`--mode auto`) | Zero pauses after Q&A. Everything runs unattended. |
151
- | **Hybrid** (`--mode hybrid`) | Planning gates only (after brief, PRD, architecture, stories). Execution is autonomous. Default. |
152
- | **Supervised** (`--mode supervised`) | Planning gates + execution milestones (after scaffolding, each epic, before deployment). |
174
+ Planning model selection is independent: the planning phase uses the Anthropic, OpenAI, or Ollama API directly (configured via API keys or `--model`).
153
175
 
154
176
  ---
155
177
 
156
178
  ## CLI Commands
157
179
 
158
180
  ```bash
159
- # Initialize a new project
160
- npx bemadralphy init
161
-
162
- # Notes:
163
- # - Creates .bemadralphy/, openspec/, and _bmad-output/
164
- # - Initializes `bd` and `openspec`
165
- # - Fails fast if required CLIs are missing
181
+ # Initialize a project
182
+ bemadralphy init
166
183
 
167
184
  # Run the full pipeline
168
- npx bemadralphy run
169
-
170
- # Run with specific options
171
- npx bemadralphy run --mode auto --engine claude --max-parallel 5 --budget 50
185
+ bemadralphy run
186
+ bemadralphy run --mode auto --engine claude --max-parallel 5 --budget 50
172
187
 
173
- # Run with execution/audience profiles
174
- npx bemadralphy run --execution-profile safe --audience-profile product-team
188
+ # Run planning phases only (intake + planning + steering)
189
+ bemadralphy plan
190
+ bemadralphy plan --model claude-sonnet-4-20250514
175
191
 
176
- # Preview pipeline and estimated cost without execution
177
- npx bemadralphy run --dry-run --output json
192
+ # Run execution phases only (sync + execute)
193
+ bemadralphy execute --engine claude
178
194
 
179
- # Resume a failed/interrupted run
180
- npx bemadralphy run --resume
195
+ # Resume a failed or interrupted run
196
+ bemadralphy resume
197
+ bemadralphy resume --from execute
181
198
 
182
- # Replay a previous run from history
183
- npx bemadralphy replay <runId> --from-phase execute
199
+ # Preview pipeline and cost estimate without execution
200
+ bemadralphy run --dry-run --output json
184
201
 
185
202
  # Explore before planning (optional)
186
- npx bemadralphy explore "How should I structure authentication?"
203
+ bemadralphy explore "How should I structure authentication?"
187
204
 
188
205
  # Check pipeline status
189
- npx bemadralphy status
206
+ bemadralphy status
190
207
 
191
- # Show run history (human or JSON)
192
- npx bemadralphy history
193
- npx bemadralphy history --output json
208
+ # Show run history
209
+ bemadralphy history
210
+ bemadralphy history --output json
194
211
 
195
- # Check local dependency readiness
196
- npx bemadralphy doctor
197
- npx bemadralphy doctor --output json
212
+ # Replay a previous run
213
+ bemadralphy replay <runId> --from-phase execute
214
+
215
+ # Check environment readiness
216
+ bemadralphy doctor
217
+ bemadralphy doctor --output json
218
+
219
+ # Manage tasks
220
+ bemadralphy tasks list
221
+ bemadralphy tasks list --status open
222
+ bemadralphy tasks show <id>
223
+ bemadralphy tasks retry <id>
224
+
225
+ # Set persistent config
226
+ bemadralphy config set engine claude
227
+ bemadralphy config set mode auto
198
228
  ```
199
229
 
200
230
  ---
201
231
 
232
+ ## Autonomy Modes
233
+
234
+ | Mode | Description |
235
+ | --- | --- |
236
+ | **Full Autonomous** (`--mode auto`) | Zero pauses after intake Q&A. Everything runs unattended. |
237
+ | **Hybrid** (`--mode hybrid`) | Planning gates only (after brief, PRD, architecture, stories). Execution is autonomous. Default. |
238
+ | **Supervised** (`--mode supervised`) | Planning gates + execution milestones (after scaffolding, each epic, before deployment). |
239
+
240
+ ---
241
+
202
242
  ## The `idea.md` File
203
243
 
204
- BeMadRalphy starts with an `idea.md` file in your project root. It can be as simple or detailed as you want. The current scaffolding writes intake results to `.bemadralphy/intake.yaml`.
244
+ BeMadRalphy starts with an `idea.md` file in your project root. It can be as simple or as detailed as you want.
205
245
 
206
246
  ### Minimal example
207
247
 
@@ -237,84 +277,87 @@ Key features:
237
277
  - AI coach for personalized recommendations
238
278
  ```
239
279
 
240
- BeMadRalphy extracts what you've already decided and only asks about the rest.
280
+ BeMadRalphy extracts what you have already decided and only asks about the rest.
241
281
 
242
282
  ---
243
283
 
244
- ## Greenfield vs Brownfield
284
+ ## Greenfield vs. Brownfield
245
285
 
246
- | Mode | When | What happens |
247
- | -------------- | -------------------------- | ------------------------------------------------------------------------------------ |
248
- | **Greenfield** | No existing codebase | Full pipeline: idea PRD architecture stories build from scratch |
249
- | **Brownfield** | Existing codebase detected | Analyze codebase, generate proposal + spec deltas, skip scaffolding, execute changes |
286
+ | Mode | When | What happens |
287
+ | --- | --- | --- |
288
+ | **Greenfield** | No existing codebase | Full pipeline: idea, PRD, architecture, stories, build from scratch. |
289
+ | **Brownfield** | Existing codebase detected | Analyze codebase, generate proposal + spec deltas, skip scaffolding, execute changes. |
250
290
 
251
291
  Brownfield is auto-detected (looks for `package.json`, `src/`, etc.) or forced with `--brownfield`.
252
292
 
253
293
  ---
254
294
 
255
- ## Living Specs (OpenSpec-compatible)
295
+ ## Living Specs
256
296
 
257
297
  After the initial build, BeMadRalphy generates living specifications in `openspec/specs/`:
258
298
 
259
299
  ```text
260
300
  openspec/
261
- ├── specs/
262
- │ ├── auth/spec.md
263
- │ ├── workouts/spec.md
264
- │ └── goals/spec.md
265
- ├── changes/
266
- │ └── archive/
301
+ specs/
302
+ auth/spec.md
303
+ workouts/spec.md
304
+ goals/spec.md
305
+ changes/
306
+ archive/
267
307
  ```
268
308
 
269
- For subsequent brownfield changes, new requirements are expressed as **delta specs** (ADDED/MODIFIED/REMOVED) against the current specs. On completion, deltas merge into the main specs.
309
+ For subsequent brownfield changes, new requirements are expressed as **delta specs** (ADDED/MODIFIED/REMOVED) against the current specs. On completion, deltas merge into the main specs. All spec validation and archiving runs internally -- no external `openspec` CLI needed.
270
310
 
271
311
  ---
272
312
 
273
- ## Target Project Structure (after scaffolding)
313
+ ## Target Project Structure
314
+
315
+ After scaffolding, your project looks like:
274
316
 
275
317
  ```text
276
318
  your-project/
277
- ├── .bemadralphy/ # State, cost log, failures log, intake.yaml
278
- │ ├── state.yaml
279
- │ ├── cost.log
280
- │ └── failures.log
281
- ├── .beads/ # Beads task graph
282
- │ └── issues.jsonl
283
- ├── _bmad/ # BMAD playbooks (read-only)
284
- ├── _bmad-output/ # Planning artifacts
285
- │ ├── product-brief.md
286
- │ ├── prd.md
287
- │ ├── architecture.md
288
- │ └── stories/
289
- ├── openspec/ # Living specs
290
- │ └── specs/
291
- ├── docs/
292
- │ ├── adr/ # Architecture Decision Records
293
- │ ├── onboarding.md
294
- │ └── runbook.md
295
- ├── src/ # Your application code
296
- ├── tests/
297
- ├── .github/
298
- │ ├── workflows/
299
- │ ├── ISSUE_TEMPLATE/
300
- │ └── pull_request_template.md
301
- ├── AGENTS.md # Universal agent steering
302
- ├── CLAUDE.md # Claude-specific steering
303
- ├── .cursorrules # Cursor-specific steering
304
- ├── idea.md # Your original idea
305
- ├── .bemadralphy/intake.yaml # Processed intake
306
- ├── tasks.md # Human-readable task list
307
- ├── package.json
308
- └── README.md
319
+ .bemadralphy/ # Internal state
320
+ state.yaml # Pipeline state and checkpoints
321
+ tasks.db # SQLite task database
322
+ intake.yaml # Processed intake decisions
323
+ cost.log # Per-task cost tracking
324
+ failures.log # Phase failure log
325
+ runs.jsonl # Append-only run history
326
+ _bmad-output/ # Planning artifacts
327
+ product-brief.md
328
+ prd.md
329
+ architecture.md
330
+ stories/
331
+ openspec/ # Living specs
332
+ specs/
333
+ changes/
334
+ archive/
335
+ docs/
336
+ adr/ # Architecture Decision Records
337
+ onboarding.md
338
+ runbook.md
339
+ src/ # Your application code
340
+ tests/
341
+ .github/
342
+ workflows/
343
+ ISSUE_TEMPLATE/
344
+ pull_request_template.md
345
+ AGENTS.md # Universal agent steering
346
+ CLAUDE.md # Claude-specific steering
347
+ .cursorrules # Cursor-specific steering
348
+ idea.md # Your original idea
349
+ tasks.md # Human-readable task list
350
+ package.json
351
+ README.md
309
352
  ```
310
353
 
311
354
  ---
312
355
 
313
356
  ## Configuration
314
357
 
315
- ### `.bemadralphy/state.yaml`
358
+ ### State file (`.bemadralphy/state.yaml`)
316
359
 
317
- Tracks pipeline state for resumability and recovery:
360
+ Tracks pipeline state for resumability:
318
361
 
319
362
  ```yaml
320
363
  phase: execution
@@ -332,234 +375,121 @@ Resume and replay behavior:
332
375
 
333
376
  - `--resume` retries the failed phase when a run fails.
334
377
  - `--resume` starts at the next phase when the previous phase completed successfully.
335
- - completed runs clear `resumeFromPhase`, so a later `--resume` starts fresh instead of re-running `post`.
336
- - `replay <runId>` resolves from the latest run-history record for that `runId` (not the first row).
337
-
338
- Run/cost logs are append-only JSONL and use atomic append writes:
339
-
340
- - `.bemadralphy/runs.jsonl` (history)
341
- - `.bemadralphy/cost.log` (cost tracking)
342
- - `.bemadralphy/failures.log` (phase failures)
343
-
344
- ### Run defaults via config file
378
+ - Completed runs clear `resumeFromPhase`, so a later `--resume` starts fresh.
379
+ - `replay <runId>` resolves from the latest run-history record for that `runId`.
345
380
 
346
- You can define persistent defaults in either `.bemadralphyrc` (YAML/JSON) or `bemad.config.js`.
381
+ ### Persistent defaults via config file
347
382
 
348
- Example `.bemadralphyrc`:
383
+ Define defaults in `.bemadralphyrc` (YAML/JSON) or `bemad.config.js`:
349
384
 
350
385
  ```yaml
386
+ # .bemadralphyrc
351
387
  mode: hybrid
352
- engine: ollama
388
+ engine: claude
353
389
  maxParallel: 2
354
390
  executionProfile: balanced
355
391
  output: text
392
+ model: claude-sonnet-4-20250514
356
393
  plugins:
357
394
  - ./bemad.plugins/local-plugin.mjs
358
395
  ```
359
396
 
360
- Example `bemad.config.js`:
361
-
362
397
  ```js
398
+ // bemad.config.js
363
399
  export default {
364
400
  mode: 'hybrid',
365
- engine: 'ralphy',
401
+ engine: 'claude',
366
402
  output: 'json',
367
403
  };
368
404
  ```
369
405
 
370
406
  CLI flags always override config file values.
371
407
 
372
- ### Flags
373
-
374
- | Flag | Description |
375
- | --------------------------------- | --------------------------------------- |
376
- | `--mode auto\|hybrid\|supervised` | Autonomy mode |
377
- | `--engine <name>` | AI engine to use |
378
- | `--planning-engine <name>` | Override engine for planning phase only |
379
- | `--max-parallel N` | Max parallel tasks (default: 3) |
380
- | `--execution-profile <profile>` | Guardrails profile: `safe\|balanced\|fast` |
381
- | `--audience-profile <profile>` | ICP profile: `solo-dev\|agency-team\|product-team\|enterprise-team` |
382
- | `--budget N` | Cost cap in USD |
383
- | `--brownfield` | Force brownfield mode |
384
- | `--swarm native\|process\|off` | Override swarm detection |
385
- | `--create-pr` | Create PRs for each task |
386
- | `--dry-run` | Preflight plan + cost estimate only |
387
- | `--resume` | Resume from latest checkpoint |
388
- | `--from-phase <name>` | Start at a specific phase |
389
- | `--output text\|json` | Human-readable or structured output |
390
- | `--plugin <paths...>` | Load custom plugin modules |
408
+ ### Flags reference
409
+
410
+ | Flag | Description |
411
+ | --- | --- |
412
+ | `--mode auto\|hybrid\|supervised` | Autonomy mode |
413
+ | `--engine <name>` | AI engine for execution |
414
+ | `--planning-engine <name>` | Override engine for planning phase only |
415
+ | `--model <name>` | Model for direct AI planning calls |
416
+ | `--timeout <seconds>` | Task timeout hint |
417
+ | `--max-parallel N` | Max parallel tasks (default: 3) |
418
+ | `--execution-profile <profile>` | Guardrails: `safe\|balanced\|fast` |
419
+ | `--audience-profile <profile>` | ICP: `solo-dev\|agency-team\|product-team\|enterprise-team` |
420
+ | `--budget N` | Cost cap in USD |
421
+ | `--brownfield` | Force brownfield mode |
422
+ | `--swarm native\|process\|off` | Override swarm detection |
423
+ | `--create-pr` | Create PRs for each task |
424
+ | `--dry-run` | Preflight plan + cost estimate only |
425
+ | `--resume` | Resume from latest checkpoint |
426
+ | `--from-phase <name>` | Start at a specific phase |
427
+ | `--output text\|json` | Human-readable or structured output |
428
+ | `--plugin <paths...>` | Load custom plugin modules |
391
429
 
392
430
  ### Execution profiles
393
431
 
394
- - `safe`: single-lane execution defaults, process-mode bias, lowest coordination risk
395
- - `balanced` (default): controlled concurrency for day-to-day product work
396
- - `fast`: maximum requested concurrency for throughput-focused runs
432
+ - **safe**: Single-lane execution, process-mode bias, lowest coordination risk.
433
+ - **balanced** (default): Controlled concurrency for day-to-day product work.
434
+ - **fast**: Maximum requested concurrency for throughput-focused runs.
397
435
 
398
436
  ---
399
437
 
400
- ## Installation
401
-
402
- ### Quick Install (Recommended)
403
-
404
- ```bash
405
- # npm
406
- npm install -g bemadralphy
407
-
408
- # pnpm
409
- pnpm add -g bemadralphy
410
-
411
- # bun
412
- bun add -g bemadralphy
413
-
414
- # yarn
415
- yarn global add bemadralphy
416
-
417
- # or use the install script
418
- curl -fsSL https://raw.githubusercontent.com/hxp-pxh/BeMadRalphy/main/install.sh | bash
419
- ```
420
-
421
- Verify the install:
422
-
423
- ```bash
424
- bemadralphy --version
425
- bemadralphy --help
426
- ```
427
-
428
- If your shell cannot find `bemadralphy` right after global install:
429
-
430
- ```bash
431
- # still works without global PATH wiring
432
- npx bemadralphy --help
433
-
434
- # if you use a custom npm prefix, add its bin dir to PATH
435
- export PATH="$(npm config get prefix)/bin:$PATH"
436
- ```
437
-
438
- ### Docker
439
-
440
- ```bash
441
- # Pull from GitHub Container Registry
442
- docker pull ghcr.io/hxp-pxh/bemadralphy:latest
443
-
444
- # Run
445
- docker run -v $(pwd):/workspace ghcr.io/hxp-pxh/bemadralphy init
446
- ```
438
+ ## Internal Architecture (High-Level)
447
439
 
448
- For detailed first-run setup, see [`docs/getting-started.md`](docs/getting-started.md).
449
-
450
- ### Install required external CLIs
451
-
452
- ```bash
453
- # Ralphy
454
- sudo npm install -g ralphy-cli
455
-
456
- # BMAD
457
- sudo npm install -g bmad-method
458
-
459
- # Beads
460
- sudo npm install -g @beads/bd
461
-
462
- # OpenSpec
463
- sudo npm install -g @fission-ai/openspec
464
- ```
465
-
466
- Verify:
467
-
468
- ```bash
469
- ralphy --version
470
- bmad --version
471
- bd --version
472
- openspec --version
473
- ```
474
-
475
- ### Install BeMadRalphy dependencies
476
-
477
- ```bash
478
- npm install
479
- npm run build
480
- node dist/cli.js --help
440
+ ```text
441
+ idea.md
442
+ |
443
+ v
444
+ [ AI Provider ] -- Anthropic / OpenAI / Ollama
445
+ |
446
+ v
447
+ [ Planning Templates ] -- product-brief / PRD / architecture / stories
448
+ |
449
+ v
450
+ [ TaskManager ] -- embedded SQLite (.bemadralphy/tasks.db)
451
+ | dependency-aware ready queue (recursive CTE)
452
+ v
453
+ [ Engine Adapters ] -- claude / cursor / codex / kimi / gemini / ollama / ...
454
+ | rich prompt construction with project context
455
+ v
456
+ [ Retry + Review ] -- exponential backoff, error classification
457
+ | two-stage review (spec compliance + code quality)
458
+ v
459
+ [ Spec Engine ] -- internal validate / archive / delta merge
460
+ |
461
+ v
462
+ delivered project
481
463
  ```
482
464
 
483
- ### Prerequisites
465
+ For the full module-level walkthrough, see [docs/architecture.md](docs/architecture.md).
484
466
 
485
- - Node.js 18+ or Bun 1.0+
486
- - Git
487
- - Ralphy CLI (`ralphy`) for execution fallback and parallel orchestration
488
- - BMAD CLI (`bmad`)
489
- - Beads CLI (`bd`)
490
- - OpenSpec CLI (`openspec`)
491
- - Optional local engine: Ollama (`ollama`) when using `--engine ollama`
467
+ ---
492
468
 
493
469
  ## Fail-Fast Behavior
494
470
 
495
- `init` and `run` are strict by design for local-product reliability:
496
-
497
- - Missing required CLIs fail immediately with actionable errors.
498
- - Planning fails if BMAD command fails or required artifacts are missing.
499
- - Sync fails if stories cannot be parsed or Beads writes fail.
500
- - Execute fails for unknown/unavailable engines.
501
- - Verify/Post fail if OpenSpec commands fail.
502
-
503
- `init` is now soft for onboarding:
504
-
505
- - Always scaffolds `.bemadralphy/`, `openspec/`, `_bmad-output/`, and starter `idea.md`.
506
- - If `bd`, `bmad`, `openspec`, or `ralphy` are missing, it attempts `npm install -g` automatically.
507
- - If those CLIs already exist and npm is available, it checks for newer npm releases and upgrades to latest when needed.
508
- - If npm packages are installed globally but CLIs are not on PATH, it creates command shims in `~/.local/bin` when possible.
509
- - If auto-install/update fails, `init` still completes with warnings and reports actionable install hints.
510
- - Use `bemadralphy doctor` to check readiness before full pipeline runs.
471
+ BeMadRalphy is strict by design:
511
472
 
512
- Planning fallback behavior:
473
+ - **Init** scaffolds `.bemadralphy/`, `openspec/`, `_bmad-output/`, and starter `idea.md`. No external CLIs are auto-installed.
474
+ - **Doctor** checks Node, npm, API keys, SQLite access, and at least one coding agent CLI.
475
+ - **Planning** fails if AI provider calls fail and fallback generation cannot produce required artifacts.
476
+ - **Sync** fails if stories cannot be parsed or task creation fails.
477
+ - **Execute** fails for unknown or unavailable engines.
478
+ - **Verify** fails if internal spec validation detects issues.
513
479
 
514
- - If BMAD install/update enters an interactive prompt and cannot run unattended, BeMadRalphy generates minimal fallback planning artifacts so the pipeline can continue.
515
- - If BMAD exits successfully but still leaves missing/empty planning artifacts, the same fallback is generated.
516
- - Fallback files include explicit markers indicating BMAD automation needs to be rerun when non-interactive BMAD workflows are available.
517
-
518
- Typical recovery flow:
519
-
520
- ```bash
521
- # 1) Verify toolchain
522
- ralphy --version && bmad --version && bd --version && openspec --version
523
-
524
- # 2) Re-run setup and checks
525
- npm install
526
- npm run verify
527
- node dist/cli.js init
528
-
529
- # 3) Run pipeline
530
- node dist/cli.js run --mode auto --engine ralphy
531
- ```
532
-
533
- ---
534
-
535
- ## Quick Start
480
+ Recovery is straightforward:
536
481
 
537
482
  ```bash
538
- # 1. Create a new directory
539
- mkdir my-awesome-app && cd my-awesome-app
483
+ # Check environment
484
+ bemadralphy doctor
540
485
 
541
- # 2. Initialize BeMadRalphy
542
- npx bemadralphy init
543
-
544
- # 3. Write your idea
545
- echo "A todo app with real-time sync and offline support" > idea.md
486
+ # Fix the issue (API key, engine CLI, etc.)
487
+ export ANTHROPIC_API_KEY=sk-ant-...
546
488
 
547
- # 4. Run the pipeline
548
- npx bemadralphy run
489
+ # Re-run
490
+ bemadralphy run
549
491
  ```
550
492
 
551
- For full expected outputs and fail-fast troubleshooting, see [`docs/getting-started.md`](docs/getting-started.md).
552
-
553
- That's it. BeMadRalphy will:
554
-
555
- 1. Ask clarifying questions about your stack preferences
556
- 2. Generate a full PRD and architecture
557
- 3. Create all the steering files for your AI agents
558
- 4. Scaffold the project
559
- 5. Execute all tasks with tests
560
- 6. Verify the implementation
561
- 7. Generate documentation and deploy
562
-
563
493
  ---
564
494
 
565
495
  ## Contributing
@@ -568,7 +498,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on:
568
498
 
569
499
  - Fork/clone workflow
570
500
  - Branch naming conventions
571
- - Commit message format
501
+ - Commit message format (Conventional Commits)
572
502
  - PR process
573
503
  - Code standards
574
504
 
@@ -576,7 +506,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on:
576
506
 
577
507
  ## License
578
508
 
579
- [MIT](LICENSE) Copyright (c) 2026 hxp-pxh
509
+ [MIT](LICENSE) -- Copyright (c) 2026 hxp-pxh
580
510
 
581
511
  ---
582
512
 
@@ -584,7 +514,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on:
584
514
 
585
515
  BeMadRalphy builds on the shoulders of giants:
586
516
 
587
- - [BMAD-METHOD](https://github.com/bmad-code-org/BMAD-METHOD) The planning framework
588
- - [Beads](https://github.com/steveyegge/beads) The task graph and memory layer
589
- - [Ralphy](https://github.com/michaelshimeles/ralphy) The execution loop inspiration ([site](https://ralphy.goshen.fyi/))
590
- - [OpenSpec](https://github.com/Fission-AI/OpenSpec) The living spec model
517
+ - [BMAD-METHOD](https://github.com/bmad-code-org/BMAD-METHOD) -- The planning framework
518
+ - [Beads](https://github.com/steveyegge/beads) -- The task graph and dependency model
519
+ - [Ralphy](https://github.com/michaelshimeles/ralphy) -- The execution loop and retry patterns ([site](https://ralphy.goshen.fyi/))
520
+ - [OpenSpec](https://github.com/Fission-AI/OpenSpec) -- The living spec model
521
+ - [Superpowers](https://github.com/obra/superpowers) -- The TDD and review methodology