vralphy 0.1.2 → 0.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.
@@ -0,0 +1,390 @@
1
+ # Ralph Methodology
2
+
3
+ The Ralph Playbook is an **autonomous AI development methodology** that enables AI agents to plan, implement, test, and deploy software with minimal human intervention.
4
+
5
+ ## Core Philosophy
6
+
7
+ **Humans define WHAT to build. AI determines HOW to build it.**
8
+
9
+ - Humans write specifications describing features and requirements
10
+ - AI analyzes the codebase, plans the implementation, writes code, runs tests, and commits changes
11
+ - The loop continues until all specifications are implemented or iteration limits are reached
12
+
13
+ ## Three Phases
14
+
15
+ ### 1. Specification Phase (`vralphy spec`)
16
+
17
+ **Purpose**: Capture requirements through interactive conversation
18
+
19
+ **How it works**:
20
+ 1. AI asks clarifying questions about the feature
21
+ 2. User provides answers and context
22
+ 3. AI generates a complete specification document
23
+ 4. Spec is saved to `specs/<topic>.md`
24
+
25
+ **Example**:
26
+ ```bash
27
+ vralphy spec user-authentication
28
+
29
+ # AI might ask:
30
+ # - What authentication methods? (password, OAuth, SSO)
31
+ # - Session management approach? (JWT, cookies, server-side)
32
+ # - Password requirements?
33
+ # - Two-factor authentication?
34
+
35
+ # Output: specs/user-authentication.md
36
+ ```
37
+
38
+ **Specification Format**:
39
+ ```markdown
40
+ # Feature Name
41
+
42
+ ## Overview
43
+ [Brief description]
44
+
45
+ ## Requirements
46
+ - [ ] Requirement 1
47
+ - [ ] Requirement 2
48
+
49
+ ## Acceptance Criteria
50
+ - [ ] Criterion 1
51
+ - [ ] Criterion 2
52
+
53
+ ## Edge Cases
54
+ [List edge cases]
55
+
56
+ ## Dependencies
57
+ [List dependencies]
58
+ ```
59
+
60
+ ### 2. Planning Phase (`vralphy plan`)
61
+
62
+ **Purpose**: Analyze codebase and create implementation plan
63
+
64
+ **How it works**:
65
+ 1. AI reads `.vralphy/AGENTS.md` to understand build/test commands
66
+ 2. AI studies all `specs/*.md` files using parallel subagents (up to 250)
67
+ 3. AI analyzes existing codebase using parallel subagents (up to 500)
68
+ 4. AI compares implementation against specifications
69
+ 5. AI creates/updates `IMPLEMENTATION_PLAN.md` with prioritized tasks
70
+ 6. **No code is written** - planning only
71
+
72
+ **Key Features**:
73
+ - **Parallel execution**: Uses hundreds of subagents for fast analysis
74
+ - **Incremental**: Updates existing plan rather than starting from scratch
75
+ - **Priority-based**: Tasks sorted by importance and dependencies
76
+ - **Gap analysis**: Identifies missing functionality, TODOs, placeholders
77
+
78
+ **Example**:
79
+ ```bash
80
+ vralphy plan 3 # Run 3 planning iterations
81
+
82
+ # AI will:
83
+ # 1. Read all specs
84
+ # 2. Scan codebase
85
+ # 3. Identify gaps
86
+ # 4. Update IMPLEMENTATION_PLAN.md
87
+ ```
88
+
89
+ **Output** (`IMPLEMENTATION_PLAN.md`):
90
+ ```markdown
91
+ # Implementation Plan
92
+
93
+ ## High Priority
94
+ - [ ] Implement user registration endpoint
95
+ - [ ] Add password hashing with bcrypt
96
+ - [ ] Create user database schema
97
+
98
+ ## Medium Priority
99
+ - [ ] Add email verification
100
+ - [ ] Implement password reset flow
101
+
102
+ ## Low Priority
103
+ - [ ] Add OAuth providers
104
+ ```
105
+
106
+ ### 3. Build Phase (`vralphy build`)
107
+
108
+ **Purpose**: Implement functionality autonomously
109
+
110
+ **How it works**:
111
+ 1. AI reads `.vralphy/AGENTS.md` for operational commands
112
+ 2. AI reads `IMPLEMENTATION_PLAN.md` to pick the highest priority task
113
+ 3. AI searches codebase to understand current state
114
+ 4. AI implements functionality using parallel subagents
115
+ 5. AI runs tests after changes
116
+ 6. AI updates `IMPLEMENTATION_PLAN.md` with findings
117
+ 7. AI commits changes with descriptive message
118
+ 8. Loop repeats until done or iteration limit reached
119
+
120
+ **Key Features**:
121
+ - **Autonomous**: Makes decisions without human input
122
+ - **Test-driven**: Runs tests after each change
123
+ - **Git integration**: Commits and pushes automatically
124
+ - **Self-documenting**: Updates `.vralphy/AGENTS.md` when learning new commands
125
+ - **Incremental progress**: Small, focused commits
126
+
127
+ **Example**:
128
+ ```bash
129
+ vralphy build 10 # Run 10 build iterations
130
+
131
+ # Each iteration:
132
+ # 1. Pick task from IMPLEMENTATION_PLAN.md
133
+ # 2. Search codebase
134
+ # 3. Write code
135
+ # 4. Run tests
136
+ # 5. If tests pass: commit + push
137
+ # 6. If tests fail: debug and retry
138
+ # 7. Update IMPLEMENTATION_PLAN.md
139
+ ```
140
+
141
+ ## The Loop
142
+
143
+ The Ralph methodology is designed to loop:
144
+
145
+ ```
146
+ ┌─────────────────────────────────────┐
147
+ │ 1. Human writes specifications │
148
+ │ (specs/*.md) │
149
+ └────────────┬────────────────────────┘
150
+
151
+
152
+ ┌─────────────────────────────────────┐
153
+ │ 2. AI analyzes and plans │
154
+ │ vralphy plan │
155
+ │ → Updates IMPLEMENTATION_PLAN.md │
156
+ └────────────┬────────────────────────┘
157
+
158
+
159
+ ┌─────────────────────────────────────┐
160
+ │ 3. AI implements and tests │
161
+ │ vralphy build │
162
+ │ → Writes code │
163
+ │ → Runs tests │
164
+ │ → Commits changes │
165
+ └────────────┬────────────────────────┘
166
+
167
+
168
+ ┌─────────────────────────────────────┐
169
+ │ 4. Check progress │
170
+ │ - All specs implemented? DONE │
171
+ │ - More work needed? Go to step 2 │
172
+ └─────────────────────────────────────┘
173
+ ```
174
+
175
+ ## Operational Context
176
+
177
+ **Problem**: AI agents need to know how to build, test, and run your project.
178
+
179
+ **Solution**: `.vralphy/AGENTS.md` - A lightweight operational guide (max 60 lines)
180
+
181
+ **Contents**:
182
+ - Build commands (e.g., `npm run build`)
183
+ - Test commands (e.g., `npm test`)
184
+ - Lint/typecheck commands
185
+ - Dev server commands
186
+ - Project-specific patterns
187
+
188
+ **AI-Generated**: When you run `vralphy init`, AI analyzes your project and generates this file automatically.
189
+
190
+ **Example** (`.vralphy/AGENTS.md`):
191
+ ```markdown
192
+ ## Build & Run
193
+ - Build: `npm run build`
194
+ - Dev: `npm run dev`
195
+
196
+ ## Validation
197
+ - Tests: `npm test`
198
+ - Typecheck: `tsc --noEmit`
199
+ - Lint: `npm run lint`
200
+
201
+ ## Tech Stack
202
+ - Node.js + TypeScript
203
+ - Vitest for testing
204
+ - ESLint for linting
205
+
206
+ ## Codebase Patterns
207
+ - Source files in src/
208
+ - Tests colocated with source (*.test.ts)
209
+ - Use named exports
210
+ ```
211
+
212
+ ## Parallel Execution
213
+
214
+ Ralph emphasizes **massive parallelism** for performance:
215
+
216
+ **Planning Phase**:
217
+ - 250 parallel subagents for reading specs
218
+ - 500 parallel subagents for searching codebase
219
+ - 1 reasoning agent (opus) for analysis
220
+
221
+ **Build Phase**:
222
+ - 500 parallel subagents for searches/reads
223
+ - 1 subagent for build/test (sequential)
224
+ - Reasoning agent (opus) for complex decisions
225
+
226
+ **Why?**: Reading files is IO-bound and can be parallelized. Building/testing must be sequential.
227
+
228
+ ## Design Principles
229
+
230
+ ### 1. Specification-Driven
231
+
232
+ Everything starts with specifications. AI doesn't guess what to build - it reads specs.
233
+
234
+ ### 2. Autonomous Operation
235
+
236
+ Once started, AI makes decisions independently:
237
+ - What to implement next
238
+ - How to implement it
239
+ - When tests pass (commit) or fail (debug)
240
+ - When to update documentation
241
+
242
+ ### 3. Incremental Progress
243
+
244
+ Small, focused changes:
245
+ - One feature/fix per commit
246
+ - Run tests after each change
247
+ - Update plan after each iteration
248
+ - Commit frequently
249
+
250
+ ### 4. Context is Precious
251
+
252
+ Keep operational docs lean:
253
+ - `.vralphy/AGENTS.md`: Max 60 lines
254
+ - Focus on commands, not explanations
255
+ - No changelogs or history
256
+ - Status updates go in `IMPLEMENTATION_PLAN.md`
257
+
258
+ ### 5. Non-Invasive
259
+
260
+ vralphy doesn't interfere with existing tools:
261
+ - `.vralphy/` directory for all vralphy files
262
+ - `.vralphy/AGENTS.md` for vralphy's operational guide
263
+ - Root `AGENTS.md` remains yours for Claude/OpenCode
264
+
265
+ ## Model Selection
266
+
267
+ Two-tier model system:
268
+
269
+ **Primary (Thinking)**:
270
+ - Model: opus (default)
271
+ - Purpose: Complex reasoning, orchestration, decisions
272
+ - Use: Planning, debugging, architecture
273
+
274
+ **Executor (Subagents)**:
275
+ - Model: sonnet (default)
276
+ - Purpose: Parallel tasks, file operations
277
+ - Use: Reading files, searching code, simple edits
278
+
279
+ **Why?**: Opus is expensive but smart. Sonnet is cheap and fast. Use each where appropriate.
280
+
281
+ ## Engine Abstraction
282
+
283
+ vralphy works with multiple AI engines:
284
+
285
+ | Engine | Provider | CLI Command |
286
+ |----------|-----------|-------------|
287
+ | claude | Anthropic | `claude` |
288
+ | opencode | OpenAI | `opencode` |
289
+ | codex | Custom | `codex` |
290
+
291
+ **Auto-detection**: vralphy detects available engines on startup.
292
+
293
+ **Flexibility**: Switch engines with `--engine` flag.
294
+
295
+ ## Lazy Loading
296
+
297
+ **Problem**: Loading all skills/agents into context wastes tokens.
298
+
299
+ **Solution**: Load on-demand when needed.
300
+
301
+ **How it works**:
302
+ 1. Agent encounters a task requiring domain knowledge
303
+ 2. Agent checks if a skill exists (e.g., `.claude/skills/react.md`)
304
+ 3. Agent loads only the relevant skill
305
+ 4. Agent uses knowledge to complete task
306
+
307
+ **Skill triggers**: Define when to load
308
+ ```markdown
309
+ ---
310
+ name: react-patterns
311
+ triggers:
312
+ - "React component"
313
+ - "useState"
314
+ - "useEffect"
315
+ ---
316
+ ```
317
+
318
+ ## Success Criteria
319
+
320
+ A Ralph loop is successful when:
321
+
322
+ 1. **All specs implemented**: Every requirement has passing tests
323
+ 2. **Clean codebase**: No TODOs, placeholders, or skipped tests
324
+ 3. **Tests passing**: All unit, integration, and e2e tests pass
325
+ 4. **Documented**: `.vralphy/AGENTS.md` reflects current state
326
+ 5. **Committed**: All changes committed to git with clear messages
327
+
328
+ ## Common Patterns
329
+
330
+ ### New Feature Flow
331
+
332
+ ```bash
333
+ # 1. Define what to build
334
+ vralphy spec new-feature
335
+
336
+ # 2. Plan how to build it
337
+ vralphy plan 2
338
+
339
+ # 3. Build it
340
+ vralphy build 20
341
+
342
+ # 4. Check progress
343
+ cat IMPLEMENTATION_PLAN.md
344
+ ```
345
+
346
+ ### Bug Fix Flow
347
+
348
+ ```bash
349
+ # 1. Add bug to IMPLEMENTATION_PLAN.md
350
+ echo "- [ ] Fix: Authentication fails for email with +" >> IMPLEMENTATION_PLAN.md
351
+
352
+ # 2. Let AI fix it
353
+ vralphy build 5
354
+ ```
355
+
356
+ ### Refactoring Flow
357
+
358
+ ```bash
359
+ # 1. Create refactoring spec
360
+ vralphy spec refactor-auth-module
361
+
362
+ # 2. Plan the refactoring
363
+ vralphy plan 3
364
+
365
+ # 3. Execute refactoring
366
+ vralphy build 15
367
+ ```
368
+
369
+ ## Anti-Patterns
370
+
371
+ **❌ Don't**: Write code manually during a Ralph loop
372
+ **✅ Do**: Let AI complete the current loop, then intervene
373
+
374
+ **❌ Don't**: Edit `.vralphy/AGENTS.md` with status updates
375
+ **✅ Do**: Keep it operational only; status goes in `IMPLEMENTATION_PLAN.md`
376
+
377
+ **❌ Don't**: Run `vralphy build` without planning first
378
+ **✅ Do**: Always run `vralphy plan` before `vralphy build`
379
+
380
+ **❌ Don't**: Write vague specs like "add authentication"
381
+ **✅ Do**: Use `vralphy spec` for interactive, detailed specs
382
+
383
+ **❌ Don't**: Set iteration counts too high (e.g., 1000)
384
+ **✅ Do**: Start small (5-10), verify, then increase
385
+
386
+ ## Further Reading
387
+
388
+ - [COMMANDS.md](./COMMANDS.md) - Complete command reference
389
+ - [WORKFLOWS.md](./WORKFLOWS.md) - Common workflows
390
+ - [DESIGN.md](./DESIGN.md) - Architecture and design decisions
package/docs/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # vralphy Documentation
2
+
3
+ **Version-specific documentation for the installed vralphy package**
4
+
5
+ This directory contains comprehensive documentation for vralphy, designed to help both humans and LLMs understand the tool, its methodology, and how to use it effectively.
6
+
7
+ ## What is vralphy?
8
+
9
+ vralphy is a CLI tool that implements the **Ralph Playbook** - an autonomous AI development methodology where AI agents plan, build, test, and commit code changes with minimal human intervention.
10
+
11
+ ## Quick Navigation
12
+
13
+ - **[METHODOLOGY.md](./METHODOLOGY.md)** - Deep dive into the Ralph methodology
14
+ - **[COMMANDS.md](./COMMANDS.md)** - Complete command reference with examples
15
+ - **[DESIGN.md](./DESIGN.md)** - Design principles and architecture
16
+ - **[WORKFLOWS.md](./WORKFLOWS.md)** - Common workflows and patterns
17
+ - **[EXAMPLES.md](./EXAMPLES.md)** - Real-world usage examples
18
+
19
+ ## Quick Start
20
+
21
+ ```bash
22
+ # Initialize vralphy in your project
23
+ vralphy init
24
+
25
+ # This creates:
26
+ # - .vralphy/AGENTS.md (operational guide for build/test commands)
27
+ # - .vralphy/prompts/ (customizable prompt templates)
28
+ # - specs/ (feature specifications directory)
29
+ # - IMPLEMENTATION_PLAN.md (task tracking)
30
+
31
+ # Create a specification
32
+ vralphy spec authentication
33
+
34
+ # Run planning phase
35
+ vralphy plan 3
36
+
37
+ # Run build phase
38
+ vralphy build 10
39
+ ```
40
+
41
+ ## Key Concepts
42
+
43
+ ### 1. Separation of Concerns
44
+
45
+ - **specs/** - What to build (requirements)
46
+ - **.vralphy/AGENTS.md** - How to build (commands)
47
+ - **IMPLEMENTATION_PLAN.md** - What's left to do (tasks)
48
+
49
+ ### 2. AI-Powered Operations
50
+
51
+ vralphy uses AI engines (claude/opencode/codex) to:
52
+ - Analyze your project structure
53
+ - Generate project-specific operational guides
54
+ - Plan implementation strategies
55
+ - Write and test code autonomously
56
+
57
+ ### 3. Non-Invasive Design
58
+
59
+ - `.vralphy/AGENTS.md` - vralphy's internal guide
60
+ - Root `AGENTS.md` - Your project's guide for other tools
61
+ - No collision with existing AI tooling
62
+
63
+ ## Engine Support
64
+
65
+ vralphy works with multiple AI engines:
66
+
67
+ - **Claude** (default) - Anthropic's Claude CLI
68
+ - **OpenCode** - OpenAI's code assistant
69
+ - **Codex** - Alternative AI engine
70
+
71
+ Engines are auto-detected. Install at least one:
72
+
73
+ ```bash
74
+ npm install -g @anthropic-ai/claude-code
75
+ ```
76
+
77
+ ## File Locations
78
+
79
+ After initialization, vralphy uses:
80
+
81
+ ```
82
+ .vralphy/
83
+ ├── AGENTS.md # Operational guide (build/test/run commands)
84
+ └── prompts/
85
+ ├── plan.md # Planning phase prompt template
86
+ ├── build.md # Build phase prompt template
87
+ └── spec.md # Spec creation prompt template
88
+ ```
89
+
90
+ ## Documentation Philosophy
91
+
92
+ This documentation is designed to be:
93
+
94
+ 1. **LLM-Friendly** - Easy for AI assistants to parse and understand
95
+ 2. **Complete** - Covers all features and concepts
96
+ 3. **Practical** - Includes real examples and workflows
97
+ 4. **Version-Specific** - Matches the installed vralphy version
98
+
99
+ ## Getting Help
100
+
101
+ - Read the detailed docs in this directory
102
+ - Run `vralphy <command> --help` for command-specific help
103
+ - Visit: https://github.com/vadimcomanescu/vralphy
104
+ - Report issues: https://github.com/vadimcomanescu/vralphy/issues
105
+
106
+ ## Next Steps
107
+
108
+ 1. Read [METHODOLOGY.md](./METHODOLOGY.md) to understand the Ralph approach
109
+ 2. Browse [COMMANDS.md](./COMMANDS.md) for complete command reference
110
+ 3. Check [WORKFLOWS.md](./WORKFLOWS.md) for common usage patterns