vralphy 0.8.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.
- package/README.md +512 -0
- package/bin/vralphy.js +3 -0
- package/dist/commands/build.d.ts +9 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +176 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/cleanup.d.ts +19 -0
- package/dist/commands/cleanup.d.ts.map +1 -0
- package/dist/commands/cleanup.js +159 -0
- package/dist/commands/cleanup.js.map +1 -0
- package/dist/commands/cleanup.test.d.ts +2 -0
- package/dist/commands/cleanup.test.d.ts.map +1 -0
- package/dist/commands/cleanup.test.js +389 -0
- package/dist/commands/cleanup.test.js.map +1 -0
- package/dist/commands/init.d.ts +13 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +120 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/plan.d.ts +9 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +147 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/spec.d.ts +9 -0
- package/dist/commands/spec.d.ts.map +1 -0
- package/dist/commands/spec.js +111 -0
- package/dist/commands/spec.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +251 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/agents.d.ts +32 -0
- package/dist/lib/agents.d.ts.map +1 -0
- package/dist/lib/agents.js +96 -0
- package/dist/lib/agents.js.map +1 -0
- package/dist/lib/config.d.ts +54 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +199 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/config.test.d.ts +2 -0
- package/dist/lib/config.test.d.ts.map +1 -0
- package/dist/lib/config.test.js +57 -0
- package/dist/lib/config.test.js.map +1 -0
- package/dist/lib/context.d.ts +29 -0
- package/dist/lib/context.d.ts.map +1 -0
- package/dist/lib/context.js +175 -0
- package/dist/lib/context.js.map +1 -0
- package/dist/lib/engines/base.d.ts +75 -0
- package/dist/lib/engines/base.d.ts.map +1 -0
- package/dist/lib/engines/base.js +62 -0
- package/dist/lib/engines/base.js.map +1 -0
- package/dist/lib/engines/base.test.d.ts +2 -0
- package/dist/lib/engines/base.test.d.ts.map +1 -0
- package/dist/lib/engines/base.test.js +28 -0
- package/dist/lib/engines/base.test.js.map +1 -0
- package/dist/lib/engines/claude.d.ts +12 -0
- package/dist/lib/engines/claude.d.ts.map +1 -0
- package/dist/lib/engines/claude.js +156 -0
- package/dist/lib/engines/claude.js.map +1 -0
- package/dist/lib/engines/codex.d.ts +28 -0
- package/dist/lib/engines/codex.d.ts.map +1 -0
- package/dist/lib/engines/codex.js +177 -0
- package/dist/lib/engines/codex.js.map +1 -0
- package/dist/lib/engines/index.d.ts +19 -0
- package/dist/lib/engines/index.d.ts.map +1 -0
- package/dist/lib/engines/index.js +40 -0
- package/dist/lib/engines/index.js.map +1 -0
- package/dist/lib/engines/opencode.d.ts +14 -0
- package/dist/lib/engines/opencode.d.ts.map +1 -0
- package/dist/lib/engines/opencode.js +127 -0
- package/dist/lib/engines/opencode.js.map +1 -0
- package/dist/lib/events/index.d.ts +6 -0
- package/dist/lib/events/index.d.ts.map +1 -0
- package/dist/lib/events/index.js +5 -0
- package/dist/lib/events/index.js.map +1 -0
- package/dist/lib/events/types.d.ts +93 -0
- package/dist/lib/events/types.d.ts.map +1 -0
- package/dist/lib/events/types.js +7 -0
- package/dist/lib/events/types.js.map +1 -0
- package/dist/lib/events/writer.d.ts +68 -0
- package/dist/lib/events/writer.d.ts.map +1 -0
- package/dist/lib/events/writer.js +178 -0
- package/dist/lib/events/writer.js.map +1 -0
- package/dist/lib/events.d.ts +33 -0
- package/dist/lib/events.d.ts.map +1 -0
- package/dist/lib/events.js +81 -0
- package/dist/lib/events.js.map +1 -0
- package/dist/lib/events.test.d.ts +2 -0
- package/dist/lib/events.test.d.ts.map +1 -0
- package/dist/lib/events.test.js +123 -0
- package/dist/lib/events.test.js.map +1 -0
- package/dist/lib/file-injection.d.ts +32 -0
- package/dist/lib/file-injection.d.ts.map +1 -0
- package/dist/lib/file-injection.js +138 -0
- package/dist/lib/file-injection.js.map +1 -0
- package/dist/lib/file-injection.test.d.ts +2 -0
- package/dist/lib/file-injection.test.d.ts.map +1 -0
- package/dist/lib/file-injection.test.js +508 -0
- package/dist/lib/file-injection.test.js.map +1 -0
- package/dist/lib/init.d.ts +27 -0
- package/dist/lib/init.d.ts.map +1 -0
- package/dist/lib/init.js +363 -0
- package/dist/lib/init.js.map +1 -0
- package/dist/lib/init.test.d.ts +2 -0
- package/dist/lib/init.test.d.ts.map +1 -0
- package/dist/lib/init.test.js +315 -0
- package/dist/lib/init.test.js.map +1 -0
- package/dist/lib/plan.d.ts +11 -0
- package/dist/lib/plan.d.ts.map +1 -0
- package/dist/lib/plan.js +22 -0
- package/dist/lib/plan.js.map +1 -0
- package/dist/lib/plan.test.d.ts +2 -0
- package/dist/lib/plan.test.d.ts.map +1 -0
- package/dist/lib/plan.test.js +70 -0
- package/dist/lib/plan.test.js.map +1 -0
- package/dist/lib/prompts/codex.d.ts +18 -0
- package/dist/lib/prompts/codex.d.ts.map +1 -0
- package/dist/lib/prompts/codex.js +82 -0
- package/dist/lib/prompts/codex.js.map +1 -0
- package/dist/lib/prompts/opencode.d.ts +16 -0
- package/dist/lib/prompts/opencode.d.ts.map +1 -0
- package/dist/lib/prompts/opencode.js +71 -0
- package/dist/lib/prompts/opencode.js.map +1 -0
- package/dist/lib/prompts.d.ts +57 -0
- package/dist/lib/prompts.d.ts.map +1 -0
- package/dist/lib/prompts.js +255 -0
- package/dist/lib/prompts.js.map +1 -0
- package/dist/lib/prompts.test.d.ts +2 -0
- package/dist/lib/prompts.test.d.ts.map +1 -0
- package/dist/lib/prompts.test.js +128 -0
- package/dist/lib/prompts.test.js.map +1 -0
- package/dist/lib/skills.d.ts +36 -0
- package/dist/lib/skills.d.ts.map +1 -0
- package/dist/lib/skills.js +132 -0
- package/dist/lib/skills.js.map +1 -0
- package/dist/lib/slack.d.ts +43 -0
- package/dist/lib/slack.d.ts.map +1 -0
- package/dist/lib/slack.js +130 -0
- package/dist/lib/slack.js.map +1 -0
- package/dist/lib/slack.test.d.ts +2 -0
- package/dist/lib/slack.test.d.ts.map +1 -0
- package/dist/lib/slack.test.js +74 -0
- package/dist/lib/slack.test.js.map +1 -0
- package/dist/lib/templates/injections.d.ts +18 -0
- package/dist/lib/templates/injections.d.ts.map +1 -0
- package/dist/lib/templates/injections.js +32 -0
- package/dist/lib/templates/injections.js.map +1 -0
- package/dist/lib/templates/readme.d.ts +6 -0
- package/dist/lib/templates/readme.d.ts.map +1 -0
- package/dist/lib/templates/readme.js +168 -0
- package/dist/lib/templates/readme.js.map +1 -0
- package/docs/COMMANDS.md +664 -0
- package/docs/DESIGN.md +537 -0
- package/docs/EXAMPLES.md +812 -0
- package/docs/METHODOLOGY.md +390 -0
- package/docs/README.md +110 -0
- package/docs/WORKFLOWS.md +808 -0
- package/llms.txt +104 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
# vralphy
|
|
2
|
+
|
|
3
|
+
CLI tool implementing the **Ralph Playbook** methodology with engine flexibility (Claude/OpenCode), model selection, and autonomous development loops.
|
|
4
|
+
|
|
5
|
+
## What is the Ralph Methodology?
|
|
6
|
+
|
|
7
|
+
Ralph is an **autonomous AI development methodology** where an AI agent:
|
|
8
|
+
|
|
9
|
+
1. **Plans** - Studies specs, analyzes codebase, creates implementation plans
|
|
10
|
+
2. **Builds** - Implements features using parallel subagents, runs tests, commits changes
|
|
11
|
+
3. **Loops** - Repeats until all tasks complete or iteration limit reached
|
|
12
|
+
|
|
13
|
+
The methodology emphasizes:
|
|
14
|
+
- **Parallel execution** - 500+ subagents for searches/reads, specialized agents for reasoning
|
|
15
|
+
- **Autonomous operation** - Agent makes decisions, runs tests, commits without human intervention
|
|
16
|
+
- **Specification-driven** - Work defined in `specs/*.md` files
|
|
17
|
+
- **Operational context** - Lightweight `AGENTS.md` keeps build/test commands accessible
|
|
18
|
+
- **Incremental progress** - `IMPLEMENTATION_PLAN.md` tracks remaining work across loops
|
|
19
|
+
|
|
20
|
+
## Comprehensive Documentation
|
|
21
|
+
|
|
22
|
+
vralphy includes **LLM-friendly documentation** in the `docs/` directory (bundled with the package):
|
|
23
|
+
|
|
24
|
+
- **[docs/README.md](./docs/README.md)** - Documentation overview
|
|
25
|
+
- **[docs/METHODOLOGY.md](./docs/METHODOLOGY.md)** - Deep dive into Ralph methodology
|
|
26
|
+
- **[docs/COMMANDS.md](./docs/COMMANDS.md)** - Complete command reference
|
|
27
|
+
- **[docs/DESIGN.md](./docs/DESIGN.md)** - Design principles and architecture
|
|
28
|
+
- **[docs/WORKFLOWS.md](./docs/WORKFLOWS.md)** - Common workflows and patterns
|
|
29
|
+
- **[docs/EXAMPLES.md](./docs/EXAMPLES.md)** - Real-world usage examples
|
|
30
|
+
|
|
31
|
+
### LLM Discovery Standard
|
|
32
|
+
|
|
33
|
+
vralphy includes an **[llms.txt](./llms.txt)** file following the [llms.txt standard](https://llmstxt.org/) for AI agent discovery. This markdown file provides a structured overview of vralphy's capabilities, making it easy for LLMs to understand and use the tool when working in projects.
|
|
34
|
+
|
|
35
|
+
This documentation is designed to help both humans and LLMs understand and use vralphy effectively.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install -g vralphy
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or use directly with npx:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx vralphy init
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
1. **Initialize a project:**
|
|
52
|
+
```bash
|
|
53
|
+
cd your-project
|
|
54
|
+
vralphy init
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This creates:
|
|
58
|
+
- `specs/` - Feature specifications directory
|
|
59
|
+
- `.vralphy/AGENTS.md` - **AI-generated** operational guide (build/test commands)
|
|
60
|
+
- `.vralphy/prompts/` - Prompt templates (plan.md, build.md, spec.md)
|
|
61
|
+
- `IMPLEMENTATION_PLAN.md` - Task tracking
|
|
62
|
+
|
|
63
|
+
**AI-Powered Init:** When an AI engine (claude/opencode/codex) is available, `vralphy init` uses AI to analyze your project and generate a smart, project-specific `.vralphy/AGENTS.md`. Falls back to template-based generation if no engine is found.
|
|
64
|
+
|
|
65
|
+
**Note:** The AGENTS.md in `.vralphy/` is vralphy's internal operational guide. It won't collide with your project's root AGENTS.md used by Claude/OpenCode/Codex.
|
|
66
|
+
|
|
67
|
+
2. **Create specifications:**
|
|
68
|
+
```bash
|
|
69
|
+
vralphy spec authentication
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Interactive conversation to define requirements, saves to `specs/authentication.md`
|
|
73
|
+
|
|
74
|
+
3. **Run planning phase:**
|
|
75
|
+
```bash
|
|
76
|
+
vralphy plan 3
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Agent analyzes specs and codebase, creates/updates `IMPLEMENTATION_PLAN.md`
|
|
80
|
+
|
|
81
|
+
4. **Run build phase:**
|
|
82
|
+
```bash
|
|
83
|
+
vralphy build 10
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Agent autonomously implements features, runs tests, commits changes
|
|
87
|
+
|
|
88
|
+
## Commands
|
|
89
|
+
|
|
90
|
+
### Core Commands
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
vralphy build [iterations] # Build mode (default: unlimited)
|
|
94
|
+
vralphy plan [iterations] # Plan mode
|
|
95
|
+
vralphy spec [topic] # Interactive spec creation
|
|
96
|
+
vralphy init # Initialize project (AI-powered)
|
|
97
|
+
vralphy cleanup # Remove vralphy from project
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Init Command Options
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
vralphy init # AI-powered init (default)
|
|
104
|
+
vralphy init --no-ai # Skip AI, use template fallback
|
|
105
|
+
vralphy init --approve # Review AGENTS.md before saving
|
|
106
|
+
vralphy init --engine codex # Use specific engine for AI generation
|
|
107
|
+
vralphy init --from /path/to/dir # Initialize from different directory
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Cleanup Command Options
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
vralphy cleanup # Remove vralphy files (prompts for confirmation)
|
|
114
|
+
vralphy cleanup --force # Skip confirmation prompt
|
|
115
|
+
vralphy cleanup --remove-specs # Also remove specs/ directory
|
|
116
|
+
vralphy cleanup --from /path # Clean up different directory
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**What gets removed**:
|
|
120
|
+
- `.vralphy/` - All vralphy configuration and prompts
|
|
121
|
+
- `IMPLEMENTATION_PLAN.md` - Task tracking file
|
|
122
|
+
- `specs/` - Only if `--remove-specs` flag is used (kept by default)
|
|
123
|
+
|
|
124
|
+
### Utility Commands
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
vralphy engines # List available engines (claude/opencode)
|
|
128
|
+
vralphy skills # List loaded skills
|
|
129
|
+
vralphy agents # List available agents
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Global Flags
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
--engine <engine> # claude, opencode, or codex (default: claude)
|
|
136
|
+
--planning-model <model> # Primary model: opus, sonnet, haiku (default: opus)
|
|
137
|
+
--executor-model <model> # Executor model for subagents (default: sonnet)
|
|
138
|
+
--reasoning-effort <level> # Reasoning effort (OpenCode/Codex: minimal/low/medium/high/xhigh/max)
|
|
139
|
+
--skills <path> # Skills directory (default: auto-detect)
|
|
140
|
+
--agents <path> # Agents directory (default: auto-detect)
|
|
141
|
+
--config <path> # Config file (default: .vralphy/config.json)
|
|
142
|
+
--verbose # Verbose output
|
|
143
|
+
--dry-run # Show what would execute without running
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Note**: The `--reasoning-effort` parameter works with OpenCode and Codex engines. Claude CLI does not support this parameter yet (feature pending).
|
|
147
|
+
|
|
148
|
+
## How It Works
|
|
149
|
+
|
|
150
|
+
### 1. Project Structure
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
your-project/
|
|
154
|
+
├── .vralphy/
|
|
155
|
+
│ ├── AGENTS.md # vralphy's operational guide (~60 lines max)
|
|
156
|
+
│ └── prompts/ # vralphy prompt templates
|
|
157
|
+
│ ├── plan.md
|
|
158
|
+
│ ├── build.md
|
|
159
|
+
│ └── spec.md
|
|
160
|
+
├── .claude/ # Claude engine's native location (if using Claude)
|
|
161
|
+
│ ├── skills/ # Skills loaded on-demand
|
|
162
|
+
│ └── agents/ # Agents spawned on-demand
|
|
163
|
+
├── specs/ # Feature specifications
|
|
164
|
+
│ ├── authentication.md
|
|
165
|
+
│ └── api-endpoints.md
|
|
166
|
+
├── AGENTS.md # (Optional) Your project's AGENTS.md for Claude/OpenCode
|
|
167
|
+
└── IMPLEMENTATION_PLAN.md # Current task list
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Key principle**: vralphy stores only its prompts in `.vralphy/`. Skills and agents come from the engine's native location (`.claude/`, `.opencode/`, etc.).
|
|
171
|
+
|
|
172
|
+
### 2. The Loop
|
|
173
|
+
|
|
174
|
+
**Planning Phase** (`vralphy plan`):
|
|
175
|
+
- Studies all `specs/*.md` files with parallel subagents
|
|
176
|
+
- Analyzes existing codebase
|
|
177
|
+
- Compares implementation against specs
|
|
178
|
+
- Creates/updates `IMPLEMENTATION_PLAN.md` with prioritized tasks
|
|
179
|
+
- **Does NOT write code**
|
|
180
|
+
|
|
181
|
+
**Build Phase** (`vralphy build`):
|
|
182
|
+
- Reads `IMPLEMENTATION_PLAN.md` and picks highest priority task
|
|
183
|
+
- Searches codebase to understand current state
|
|
184
|
+
- Implements functionality using parallel subagents
|
|
185
|
+
- Runs tests after changes
|
|
186
|
+
- Updates `IMPLEMENTATION_PLAN.md` with findings
|
|
187
|
+
- Commits and pushes changes
|
|
188
|
+
- Repeats until done or iteration limit reached
|
|
189
|
+
|
|
190
|
+
**Spec Phase** (`vralphy spec`):
|
|
191
|
+
- Interactive requirement gathering (Claude only)
|
|
192
|
+
- Agent asks clarifying questions using `AskUserQuestion`
|
|
193
|
+
- Generates comprehensive spec document
|
|
194
|
+
- Saves to `specs/<topic>.md`
|
|
195
|
+
|
|
196
|
+
### 3. Engine Abstraction
|
|
197
|
+
|
|
198
|
+
vralphy supports multiple AI engines:
|
|
199
|
+
|
|
200
|
+
**Claude Engine** (default):
|
|
201
|
+
```bash
|
|
202
|
+
vralphy --engine claude --planning-model opus build
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**OpenCode Engine**:
|
|
206
|
+
```bash
|
|
207
|
+
vralphy --engine opencode build
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Codex Engine**:
|
|
211
|
+
```bash
|
|
212
|
+
vralphy --engine codex build
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Engines auto-detected on startup. Install `claude`, `opencode`, or `codex` CLI tools.
|
|
216
|
+
|
|
217
|
+
### 4. Model Selection
|
|
218
|
+
|
|
219
|
+
Two-tier model system:
|
|
220
|
+
|
|
221
|
+
- **Primary (Thinking)**: Complex reasoning, orchestration (default: opus)
|
|
222
|
+
- **Executor (Subagents)**: Parallel tasks, file operations (default: sonnet)
|
|
223
|
+
|
|
224
|
+
#### Model Aliases by Engine
|
|
225
|
+
|
|
226
|
+
**Claude** (default):
|
|
227
|
+
- `opus` → claude-opus-4-5-20250514
|
|
228
|
+
- `sonnet` → claude-sonnet-4-20250514
|
|
229
|
+
- `haiku` → claude-haiku-3-5-20241022
|
|
230
|
+
|
|
231
|
+
**OpenCode** (OpenAI models):
|
|
232
|
+
- `gpt-4o` → gpt-4o
|
|
233
|
+
- `gpt-4` → gpt-4-turbo
|
|
234
|
+
- `o1` → o1 (reasoning model)
|
|
235
|
+
- `o1-mini` → o1-mini (reasoning model)
|
|
236
|
+
- `o1-preview` → o1-preview
|
|
237
|
+
|
|
238
|
+
**Codex** (DeepSeek models):
|
|
239
|
+
- `deepseek-chat` → deepseek-chat
|
|
240
|
+
- `deepseek-r1` → deepseek-r1 (reasoning model)
|
|
241
|
+
|
|
242
|
+
#### Using Reasoning Models
|
|
243
|
+
|
|
244
|
+
Some models have built-in reasoning capabilities (o1 series, DeepSeek R1). These can be used for complex planning:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Use o1 for planning with OpenCode
|
|
248
|
+
vralphy --engine opencode --planning-model o1 plan 3
|
|
249
|
+
|
|
250
|
+
# Use DeepSeek R1 for planning with Codex
|
|
251
|
+
vralphy --engine codex --planning-model deepseek-r1 plan 3
|
|
252
|
+
|
|
253
|
+
# Standard Claude for building
|
|
254
|
+
vralphy --engine claude --planning-model opus --executor-model sonnet build
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### Full Model IDs
|
|
258
|
+
|
|
259
|
+
You can also use full model IDs directly:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
vralphy --planning-model claude-opus-4-5-20250514 build
|
|
263
|
+
vralphy --planning-model gpt-4o build
|
|
264
|
+
vralphy --planning-model deepseek-r1 build
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### 5. Skills & Agents (Lazy Loading)
|
|
268
|
+
|
|
269
|
+
**Context is precious.** vralphy does NOT preload all skills/agents into prompts. Instead, the agent discovers and loads them on-demand from the engine's native locations:
|
|
270
|
+
|
|
271
|
+
| Engine | Skills Location | Agents Location |
|
|
272
|
+
|----------|---------------------|---------------------|
|
|
273
|
+
| Claude | `.claude/skills/` | `.claude/agents/` |
|
|
274
|
+
| OpenCode | `.opencode/skills/` | `.opencode/agents/` |
|
|
275
|
+
| Codex | `.codex/skills/` | `.codex/agents/` |
|
|
276
|
+
|
|
277
|
+
**When the agent loads a skill:**
|
|
278
|
+
- Current task requires domain-specific knowledge
|
|
279
|
+
- A spec explicitly references a framework with a matching skill
|
|
280
|
+
- After failing twice at something - checks if a skill could help
|
|
281
|
+
|
|
282
|
+
**When the agent spawns an agent:**
|
|
283
|
+
- Task requires deep focused expertise (security audit, architecture review)
|
|
284
|
+
- Needs a second opinion on a complex decision
|
|
285
|
+
- Parallel work that benefits from isolation
|
|
286
|
+
|
|
287
|
+
**Skill format** (`.claude/skills/react-patterns.md`):
|
|
288
|
+
```markdown
|
|
289
|
+
---
|
|
290
|
+
name: react-patterns
|
|
291
|
+
description: React best practices
|
|
292
|
+
triggers:
|
|
293
|
+
- "React component"
|
|
294
|
+
- "useState"
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
# React Patterns
|
|
298
|
+
[knowledge content]
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Agent format** (`.claude/agents/code-reviewer.md`):
|
|
302
|
+
```markdown
|
|
303
|
+
---
|
|
304
|
+
name: code-reviewer
|
|
305
|
+
description: Reviews code for bugs
|
|
306
|
+
model: sonnet
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
You are a code review specialist...
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
List what's available:
|
|
313
|
+
```bash
|
|
314
|
+
vralphy skills # Shows skills in engine-native location
|
|
315
|
+
vralphy agents # Shows agents in engine-native location
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Configuration
|
|
319
|
+
|
|
320
|
+
Three ways to configure (priority order):
|
|
321
|
+
|
|
322
|
+
### 1. CLI Flags
|
|
323
|
+
```bash
|
|
324
|
+
vralphy --engine claude --planning-model opus --executor-model sonnet build
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### 2. Environment Variables
|
|
328
|
+
```bash
|
|
329
|
+
export VRALPHY_ENGINE=claude
|
|
330
|
+
export VRALPHY_PLANNING_MODEL=opus
|
|
331
|
+
export VRALPHY_EXECUTOR_MODEL=sonnet
|
|
332
|
+
vralphy build
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### 3. Config File
|
|
336
|
+
```json
|
|
337
|
+
{
|
|
338
|
+
"engine": "claude",
|
|
339
|
+
"planningModel": "opus",
|
|
340
|
+
"executorModel": "sonnet",
|
|
341
|
+
"skillsDir": ".claude/skills",
|
|
342
|
+
"agentsDir": "agents"
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Save as `.vralphy/config.json` (preferred, non-invasive).
|
|
347
|
+
|
|
348
|
+
Legacy location `vralphy.config.json` in project root is still supported for backwards compatibility.
|
|
349
|
+
|
|
350
|
+
## Examples
|
|
351
|
+
|
|
352
|
+
### Example 1: New Feature
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
# Define the feature
|
|
356
|
+
vralphy spec user-authentication
|
|
357
|
+
|
|
358
|
+
# Plan implementation
|
|
359
|
+
vralphy plan 2
|
|
360
|
+
|
|
361
|
+
# Build it
|
|
362
|
+
vralphy build 20
|
|
363
|
+
|
|
364
|
+
# Check progress
|
|
365
|
+
cat IMPLEMENTATION_PLAN.md
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Example 2: Existing Project
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
# Initialize (detects package.json, extracts commands)
|
|
372
|
+
vralphy init
|
|
373
|
+
|
|
374
|
+
# Create specs for missing features
|
|
375
|
+
vralphy spec api-rate-limiting
|
|
376
|
+
vralphy spec error-handling
|
|
377
|
+
|
|
378
|
+
# Run planning
|
|
379
|
+
vralphy plan 5
|
|
380
|
+
|
|
381
|
+
# Execute build loop
|
|
382
|
+
vralphy build
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Example 3: Dry Run
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
# See what would execute without running
|
|
389
|
+
vralphy --dry-run build 1
|
|
390
|
+
|
|
391
|
+
# Shows the prompt that would be sent to the engine
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
## Why vralphy?
|
|
395
|
+
|
|
396
|
+
### Traditional Development
|
|
397
|
+
- Human writes spec → human codes → human tests → human debugs → repeat
|
|
398
|
+
|
|
399
|
+
### With Ralph + vralphy
|
|
400
|
+
- Human writes spec → vralphy plans → vralphy codes → vralphy tests → vralphy commits → repeat
|
|
401
|
+
|
|
402
|
+
You focus on **what to build** (specs), vralphy handles **how to build it**.
|
|
403
|
+
|
|
404
|
+
## Best Practices
|
|
405
|
+
|
|
406
|
+
### 1. Keep .vralphy/AGENTS.md Lean
|
|
407
|
+
- **Max ~60 lines**
|
|
408
|
+
- Only operational commands (build, test, lint)
|
|
409
|
+
- No verbose explanations or history
|
|
410
|
+
- Status updates belong in `IMPLEMENTATION_PLAN.md`
|
|
411
|
+
- This is vralphy's internal guide, separate from your project's root AGENTS.md
|
|
412
|
+
|
|
413
|
+
### 2. Write Clear Specs
|
|
414
|
+
- One feature per spec file
|
|
415
|
+
- Include acceptance criteria
|
|
416
|
+
- List edge cases
|
|
417
|
+
- Document dependencies
|
|
418
|
+
|
|
419
|
+
### 3. Start with Planning
|
|
420
|
+
- Always run `vralphy plan` before `vralphy build`
|
|
421
|
+
- Review `IMPLEMENTATION_PLAN.md` before executing
|
|
422
|
+
- Adjust iterations based on task complexity
|
|
423
|
+
|
|
424
|
+
### 4. Use Dry Run
|
|
425
|
+
- Test prompts with `--dry-run` first
|
|
426
|
+
- Verify model selection is appropriate
|
|
427
|
+
- Check that skills/agents load correctly
|
|
428
|
+
|
|
429
|
+
### 5. Iteration Management
|
|
430
|
+
- Start with small iteration counts (5-10)
|
|
431
|
+
- Monitor progress via commits
|
|
432
|
+
- Increase as you gain confidence
|
|
433
|
+
|
|
434
|
+
## Troubleshooting
|
|
435
|
+
|
|
436
|
+
### "Access token expired"
|
|
437
|
+
```bash
|
|
438
|
+
npm login
|
|
439
|
+
# or set token in ~/.npmrc:
|
|
440
|
+
echo "//registry.npmjs.org/:_authToken=npm_YOUR_TOKEN" > ~/.npmrc
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### "No engines found"
|
|
444
|
+
Install Claude or OpenCode CLI:
|
|
445
|
+
```bash
|
|
446
|
+
npm install -g @anthropic-ai/claude-code
|
|
447
|
+
# or
|
|
448
|
+
npm install -g opencode
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### "Skills not loading"
|
|
452
|
+
Check directory structure:
|
|
453
|
+
```bash
|
|
454
|
+
vralphy --verbose skills
|
|
455
|
+
# Shows search path and loaded skills
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### Model validation warnings
|
|
459
|
+
As of v0.7.1, vralphy uses advisory validation instead of blocking errors:
|
|
460
|
+
- **Warning shown**: Model not found in cache or cache unavailable
|
|
461
|
+
- **Execution continues**: Engine CLI validates the model
|
|
462
|
+
- **Autonomous-friendly**: Cache hiccups won't stop execution
|
|
463
|
+
- If the model is truly invalid, the engine will report the error
|
|
464
|
+
|
|
465
|
+
### Slow or busy models
|
|
466
|
+
As of v0.7.1, vralphy removes aggressive timeouts:
|
|
467
|
+
- **Patient execution**: No 60-second timeout on model responses
|
|
468
|
+
- **Better for autonomous**: System waits for slow/queued models
|
|
469
|
+
- **Engine-controlled**: Each engine manages its own timeout logic
|
|
470
|
+
- If something truly hangs, use Ctrl+C to interrupt
|
|
471
|
+
|
|
472
|
+
### Loop stuck
|
|
473
|
+
- Check `IMPLEMENTATION_PLAN.md` for circular tasks
|
|
474
|
+
- Review recent commits for issues
|
|
475
|
+
- Reduce iteration count and debug manually
|
|
476
|
+
|
|
477
|
+
## Development
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
git clone https://github.com/yourusername/vralphy.git
|
|
481
|
+
cd vralphy
|
|
482
|
+
npm install
|
|
483
|
+
npm run build
|
|
484
|
+
npm test
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
Run locally:
|
|
488
|
+
```bash
|
|
489
|
+
./bin/vralphy.js --help
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
## Contributing
|
|
493
|
+
|
|
494
|
+
vralphy was built **by Ralph** (autonomous AI) using its own methodology. Contributions should follow the same pattern:
|
|
495
|
+
|
|
496
|
+
1. Create spec in `specs/`
|
|
497
|
+
2. Run planning phase
|
|
498
|
+
3. Run build phase
|
|
499
|
+
4. Submit PR with generated code
|
|
500
|
+
|
|
501
|
+
## License
|
|
502
|
+
|
|
503
|
+
MIT
|
|
504
|
+
|
|
505
|
+
## Links
|
|
506
|
+
|
|
507
|
+
- [npm package](https://www.npmjs.com/package/vralphy)
|
|
508
|
+
- [Ralph Methodology](https://ralphloop.com) _(placeholder - add real link if exists)_
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
**Built with ❤️ by AI, for developers who want AI to do the heavy lifting.**
|
package/bin/vralphy.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VralphyConfig } from '../lib/config.js';
|
|
2
|
+
export interface BuildOptions {
|
|
3
|
+
iterations?: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Execute build mode
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildCommand(config: VralphyConfig, options: BuildOptions): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQjD,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAoL9F"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import { basename } from 'path';
|
|
3
|
+
import { getEngine } from '../lib/engines/index.js';
|
|
4
|
+
import { CodexEngine } from '../lib/engines/codex.js';
|
|
5
|
+
import { loadPrompt, interpolatePrompt, getDefaultBuildPrompt } from '../lib/prompts.js';
|
|
6
|
+
import { sendSlack, sessionStartMessage, iterationEndMessage, sessionEndMessage, iterationErrorMessage, planCompletedMessage } from '../lib/slack.js';
|
|
7
|
+
import { loadPlanSnapshot } from '../lib/plan.js';
|
|
8
|
+
import { initEventLogger, logEvent, generateSessionId } from '../lib/events.js';
|
|
9
|
+
/**
|
|
10
|
+
* Execute build mode
|
|
11
|
+
*/
|
|
12
|
+
export async function buildCommand(config, options) {
|
|
13
|
+
const engine = getEngine(config.engine);
|
|
14
|
+
if (!(await engine.isAvailable())) {
|
|
15
|
+
throw new Error(`Engine '${config.engine}' is not available. Please install it first.`);
|
|
16
|
+
}
|
|
17
|
+
// Configure Codex-specific settings if using Codex engine
|
|
18
|
+
if (config.engine === 'codex' && engine instanceof CodexEngine) {
|
|
19
|
+
engine.configure({
|
|
20
|
+
maxAgents: config.codex?.maxAgents,
|
|
21
|
+
workerTimeout: config.codex?.workerTimeout,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const maxIterations = options.iterations ?? 0;
|
|
25
|
+
let iteration = 0;
|
|
26
|
+
const project = basename(process.cwd());
|
|
27
|
+
const sessionId = generateSessionId();
|
|
28
|
+
initEventLogger(sessionId, project);
|
|
29
|
+
const webhookUrl = config.slackWebhook;
|
|
30
|
+
const sessionStart = Date.now();
|
|
31
|
+
console.log(`Starting build mode with ${config.engine} engine`);
|
|
32
|
+
console.log(`Planning Model: ${config.planningModel}, Executor Model: ${config.executorModel}`);
|
|
33
|
+
if (config.engine === 'codex') {
|
|
34
|
+
console.log(`Max agents: ${config.codex?.maxAgents ?? 8}, Worker timeout: ${config.codex?.workerTimeout ?? 300}s`);
|
|
35
|
+
}
|
|
36
|
+
console.log(`Max iterations: ${maxIterations || 'unlimited'}`);
|
|
37
|
+
// Snapshot initial plan state for completion detection
|
|
38
|
+
const initialPlan = await loadPlanSnapshot();
|
|
39
|
+
let planCompletionNotified = false;
|
|
40
|
+
if (initialPlan) {
|
|
41
|
+
console.log(`Plan: ${initialPlan.completedTasks}/${initialPlan.totalTasks} tasks complete`);
|
|
42
|
+
}
|
|
43
|
+
// Log and notify session start
|
|
44
|
+
logEvent({
|
|
45
|
+
type: 'session.start',
|
|
46
|
+
command: 'build',
|
|
47
|
+
engine: config.engine,
|
|
48
|
+
planningModel: config.planningModel,
|
|
49
|
+
executorModel: config.executorModel,
|
|
50
|
+
maxIterations,
|
|
51
|
+
planSnapshot: initialPlan ? {
|
|
52
|
+
totalTasks: initialPlan.totalTasks,
|
|
53
|
+
completedTasks: initialPlan.completedTasks,
|
|
54
|
+
} : undefined,
|
|
55
|
+
});
|
|
56
|
+
if (webhookUrl) {
|
|
57
|
+
sendSlack(webhookUrl, sessionStartMessage(project, 'build', maxIterations, config.engine, config.planningModel));
|
|
58
|
+
}
|
|
59
|
+
// Prompt locations in order of preference (engine-specific first)
|
|
60
|
+
const promptPaths = [
|
|
61
|
+
`.vralphy/prompts/${config.engine}/build.md`, // Engine-specific location
|
|
62
|
+
'.vralphy/prompts/build.md', // Generic new location
|
|
63
|
+
'PROMPT_build.md', // Legacy location (backwards compat)
|
|
64
|
+
];
|
|
65
|
+
let success = true;
|
|
66
|
+
try {
|
|
67
|
+
while (true) {
|
|
68
|
+
if (maxIterations > 0 && iteration >= maxIterations) {
|
|
69
|
+
console.log(`Reached max iterations (${maxIterations})`);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
const iterationStart = Date.now();
|
|
73
|
+
console.log(`\n=== Iteration ${iteration + 1} ===\n`);
|
|
74
|
+
let prompt;
|
|
75
|
+
const promptContext = {
|
|
76
|
+
planningModel: config.planningModel,
|
|
77
|
+
executorModel: config.executorModel,
|
|
78
|
+
engine: config.engine,
|
|
79
|
+
maxAgents: config.codex?.maxAgents,
|
|
80
|
+
workerTimeout: config.codex?.workerTimeout,
|
|
81
|
+
};
|
|
82
|
+
// Find first existing prompt file
|
|
83
|
+
const existingPromptPath = promptPaths.find(p => existsSync(p));
|
|
84
|
+
if (existingPromptPath) {
|
|
85
|
+
prompt = await loadPrompt(existingPromptPath, promptContext);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// Use engine-specific default prompt
|
|
89
|
+
const defaultPrompt = getDefaultBuildPrompt(config.engine);
|
|
90
|
+
prompt = interpolatePrompt(defaultPrompt, promptContext);
|
|
91
|
+
}
|
|
92
|
+
if (config.dryRun) {
|
|
93
|
+
console.log('--- DRY RUN: Would execute prompt ---');
|
|
94
|
+
console.log(prompt.slice(0, 500) + '...');
|
|
95
|
+
console.log('--- END DRY RUN ---');
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
// Engine handles output to terminal
|
|
100
|
+
for await (const chunk of engine.execute(prompt, {
|
|
101
|
+
planningModel: config.planningModel,
|
|
102
|
+
executorModel: config.executorModel,
|
|
103
|
+
headless: true,
|
|
104
|
+
skipPermissions: true,
|
|
105
|
+
verbose: config.verbose,
|
|
106
|
+
reasoningEffort: config.reasoningEffort,
|
|
107
|
+
})) {
|
|
108
|
+
if (chunk.type === 'error') {
|
|
109
|
+
console.error('Error:', chunk.error);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
const errorMsg = e instanceof Error ? e.message : String(e);
|
|
115
|
+
console.error('Execution failed:', e);
|
|
116
|
+
// Log and notify error
|
|
117
|
+
logEvent({
|
|
118
|
+
type: 'iteration.error',
|
|
119
|
+
iteration: iteration + 1,
|
|
120
|
+
maxIterations,
|
|
121
|
+
error: errorMsg,
|
|
122
|
+
});
|
|
123
|
+
if (webhookUrl) {
|
|
124
|
+
sendSlack(webhookUrl, iterationErrorMessage(project, iteration + 1, maxIterations, errorMsg));
|
|
125
|
+
}
|
|
126
|
+
success = false;
|
|
127
|
+
throw e;
|
|
128
|
+
}
|
|
129
|
+
iteration++;
|
|
130
|
+
// Log and notify iteration end
|
|
131
|
+
const iterationDuration = Date.now() - iterationStart;
|
|
132
|
+
logEvent({
|
|
133
|
+
type: 'iteration.end',
|
|
134
|
+
iteration,
|
|
135
|
+
maxIterations,
|
|
136
|
+
durationMs: iterationDuration,
|
|
137
|
+
});
|
|
138
|
+
if (webhookUrl) {
|
|
139
|
+
sendSlack(webhookUrl, iterationEndMessage(project, iteration, maxIterations, iterationDuration));
|
|
140
|
+
}
|
|
141
|
+
// Check for plan completion
|
|
142
|
+
if (initialPlan && initialPlan.incompleteTasks > 0 && !planCompletionNotified) {
|
|
143
|
+
const currentPlan = await loadPlanSnapshot();
|
|
144
|
+
if (currentPlan && currentPlan.incompleteTasks === 0) {
|
|
145
|
+
planCompletionNotified = true;
|
|
146
|
+
const duration = Date.now() - sessionStart;
|
|
147
|
+
console.log(`\n🎉 Plan completed! All ${currentPlan.totalTasks} tasks done.\n`);
|
|
148
|
+
logEvent({
|
|
149
|
+
type: 'plan.completed',
|
|
150
|
+
totalTasks: currentPlan.totalTasks,
|
|
151
|
+
iteration,
|
|
152
|
+
durationMs: duration,
|
|
153
|
+
});
|
|
154
|
+
if (webhookUrl) {
|
|
155
|
+
sendSlack(webhookUrl, planCompletedMessage(project, currentPlan.totalTasks, iteration, duration));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
// Log and notify session end
|
|
163
|
+
const totalDuration = Date.now() - sessionStart;
|
|
164
|
+
logEvent({
|
|
165
|
+
type: 'session.end',
|
|
166
|
+
success,
|
|
167
|
+
iterationsCompleted: iteration,
|
|
168
|
+
durationMs: totalDuration,
|
|
169
|
+
});
|
|
170
|
+
if (webhookUrl) {
|
|
171
|
+
sendSlack(webhookUrl, sessionEndMessage(project, iteration, totalDuration, success));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
console.log(`\nBuild complete after ${iteration} iteration(s)`);
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=build.js.map
|