ralphie 1.0.0 → 1.1.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.
@@ -254,7 +254,7 @@ npx bundlephobia <package>
254
254
 
255
255
  ### Required Reading
256
256
  Before starting work in a Ralphie loop:
257
- - **Always read:** `SPEC.md` - Project requirements and task list
257
+ - **Always read:** Active spec in `specs/active/` - Project requirements and task list
258
258
  - **Read if needed:** `STATE.txt` - Check if unsure what's already done
259
259
  - **Read if needed:** `.ai/ralphie/index.md` - Last 3-5 commits for context
260
260
 
@@ -322,7 +322,7 @@ You: Any specific dotfiles it must support, or auto-discover from home directory
322
322
  [Generate SPEC after gathering sufficient detail]
323
323
  ```
324
324
 
325
- **Important:** When starting a new project, replace the existing SPEC.md entirely. Each SPEC represents one project or feature set.
325
+ **Important:** When starting a new project, create a new spec in `specs/active/`. Each spec represents one project or feature set.
326
326
 
327
327
  ### Writing SPECs
328
328
 
@@ -1,11 +1,11 @@
1
1
  # Using Ralphie
2
2
 
3
- Ralphie is an autonomous AI coding loop. You write a SPEC, Ralphie works through it task by task.
3
+ Ralphie is an autonomous AI coding loop. You write a spec, Ralphie works through it task by task.
4
4
 
5
5
  ## Quick Start
6
6
 
7
- 1. **Create a SPEC.md** with your project requirements and tasks
8
- 2. **Run Ralphie**: `ralphie run` or `ralphie run -n 5` for multiple iterations
7
+ 1. **Create a spec** in `specs/active/` with your project requirements
8
+ 2. **Run Ralphie**: `ralphie run` or `ralphie run --all` to complete all tasks
9
9
 
10
10
  ## Project Structure
11
11
 
@@ -14,87 +14,115 @@ Ralphie expects this structure:
14
14
  ```
15
15
  your-project/
16
16
  ├── .claude/
17
- │ └── ralphie.md # Coding standards (auto-created)
18
- ├── .ai/ralphie/
19
- │ ├── plan.md # Current task plan (Ralphie writes this)
20
- │ └── index.md # Commit history (Ralphie appends here)
21
- ├── SPEC.md # YOUR requirements (you write this)
22
- ├── STATE.txt # Progress log (Ralphie updates this)
23
- └── src/ # Your code
17
+ │ └── ralphie.md # Coding standards (auto-created)
18
+ ├── specs/
19
+ │ ├── active/ # Current specs (you write here)
20
+ └── my-feature.md
21
+ │ └── completed/ # Archived specs (auto-moved)
22
+ ├── STATE.txt # Progress log (Ralphie updates this)
23
+ └── src/ # Your code
24
24
  ```
25
25
 
26
- ## Writing a SPEC
26
+ ## Writing a Spec (V2 Format)
27
27
 
28
- Your SPEC.md should have checkboxes for tasks. **Each checkbox = one Ralphie iteration**, so batch related work together.
28
+ Specs use task IDs and status tracking:
29
29
 
30
30
  ```markdown
31
- # My Project
32
-
33
- ## Overview
34
- Brief description of what you're building.
35
-
36
- ## Phase 1: Setup
37
- - [ ] Initialize project with TypeScript, testing, and linting
38
- - [ ] Set up database models and migrations
39
- - User model with email, password hash, timestamps
40
- - Post model with title, body, author reference
41
- - Comment model with body, author, post reference
42
-
43
- ## Phase 2: Core Features
44
- - [ ] Implement authentication system
45
- - POST /auth/register - create user with hashed password
46
- - POST /auth/login - validate credentials, return JWT
47
- - POST /auth/logout - invalidate token
48
- - Middleware for protected routes
49
- - Tests for all auth flows
50
-
51
- - [ ] Build posts API with full CRUD
52
- - GET/POST/PUT/DELETE endpoints
53
- - Authorization (only author can edit/delete)
54
- - Pagination for list endpoint
55
- - Tests for all operations
31
+ # My Feature
32
+
33
+ Goal: Brief description of what you're building.
34
+
35
+ ## Context
36
+
37
+ Background information for the AI implementing this spec.
38
+
39
+ ## Tasks
40
+
41
+ ### T001: Initialize project with TypeScript and testing
42
+ - Status: pending
43
+ - Size: M
44
+
45
+ **Deliverables:**
46
+ - TypeScript configuration with strict mode
47
+ - Vitest setup with coverage
48
+ - Basic project structure
49
+
50
+ **Verify:** `npm run type-check && npm test`
51
+
52
+ ---
53
+
54
+ ### T002: Set up database models
55
+ - Status: pending
56
+ - Size: M
57
+
58
+ **Deliverables:**
59
+ - User model with email, password hash, timestamps
60
+ - Post model with title, body, author reference
61
+ - Migration scripts
62
+
63
+ **Verify:** `npm run migrate && npm test`
64
+
65
+ ---
66
+
67
+ ### T003: Implement authentication system
68
+ - Status: pending
69
+ - Size: L
70
+
71
+ **Deliverables:**
72
+ - POST /auth/register endpoint
73
+ - POST /auth/login endpoint with JWT
74
+ - Auth middleware for protected routes
75
+ - Tests for all auth flows
76
+
77
+ **Verify:** `npm test -- auth`
78
+
79
+ ---
80
+
81
+ ## Acceptance Criteria
82
+
83
+ - WHEN user registers, THEN account is created with hashed password
84
+ - WHEN user logs in with valid credentials, THEN JWT is returned
56
85
  ```
57
86
 
58
87
  ### Task Design Principles
59
88
 
60
- **One checkbox = one iteration.** Sub-bullets are implementation details, not separate tasks.
89
+ **One task = one logical unit of work.** Deliverables are implementation details.
61
90
 
62
- | Pattern | Iterations | Throughput |
63
- |---------|------------|------------|
64
- | `- [ ] Create db.ts`<br>`- [ ] Create redis.ts`<br>`- [ ] Create queue.ts` | 3 | Low |
65
- | `- [ ] Create data layer (db.ts, redis.ts, queue.ts)` | 1 | High |
91
+ | Size | Points | Description |
92
+ |------|--------|-------------|
93
+ | S | 1 | Single file, < 50 lines |
94
+ | M | 2 | Multiple files, 50-200 lines |
95
+ | L | 4 | Complex feature, 200+ lines |
66
96
 
67
97
  **Batching heuristics:**
68
- - Same verb? Batch them. ("Create X, Create Y" "Create X and Y")
69
- - Same feature? Batch them. (model + API + tests = one task)
70
- - Files that import each other? Batch them.
71
- - Sweet spot: 3-7 files or ~200-500 lines per task
72
-
73
- **Include with each task:**
74
- - Implementation AND tests
75
- - Related files that depend on each other
76
- - All sub-components of a feature
98
+ - Same feature? One task. (model + API + tests = T001)
99
+ - Files that import each other? One task.
100
+ - Sweet spot: 3-7 files per task
77
101
 
78
102
  ## Commands
79
103
 
80
104
  ```bash
81
105
  ralphie run # Run one iteration
106
+ ralphie run --all # Run until spec complete
82
107
  ralphie run -n 5 # Run 5 iterations
83
- ralphie run --help # See all options
108
+ ralphie status # Show progress
109
+ ralphie archive # Move completed spec to archive
110
+ ralphie --help # See all options
84
111
  ```
85
112
 
86
113
  ## The Loop
87
114
 
88
115
  Each iteration, Ralphie:
89
- 1. Reads SPEC.md to find the next incomplete task
90
- 2. Writes a plan to .ai/ralphie/plan.md
91
- 3. Implements the task with tests
116
+ 1. Reads spec from `specs/active/` to find pending tasks
117
+ 2. Implements the task with tests
118
+ 3. Updates task status to `passed` or `failed`
92
119
  4. Commits changes
93
- 5. Updates STATE.txt and .ai/ralphie/index.md
120
+ 5. Updates STATE.txt
94
121
 
95
122
  ## Tips
96
123
 
97
124
  - **Clean git state**: Ralphie requires no uncommitted changes before running
98
- - **One task per iteration**: Don't expect multiple checkboxes done at once
99
- - **Check STATE.txt**: See what's been done if you're unsure
100
- - **Edit SPEC anytime**: Add/remove/reorder tasks between runs
125
+ - **One task per iteration**: Tasks transition pending in_progress passed/failed
126
+ - **Check status**: Run `ralphie status` to see progress
127
+ - **Edit spec anytime**: Add/remove/reorder tasks between runs
128
+
File without changes
File without changes
@@ -0,0 +1,18 @@
1
+ # Lessons Learned
2
+
3
+ Cross-spec learnings that apply to future projects. Add entries as you discover patterns, pitfalls, and solutions.
4
+
5
+ ## Format
6
+
7
+ ```markdown
8
+ ### YYYY-MM-DD: Brief title
9
+ **Context:** What spec/task this came from
10
+ **Lesson:** What you learned
11
+ **Apply when:** When this lesson is relevant
12
+ ```
13
+
14
+ ---
15
+
16
+ ## Lessons
17
+
18
+ <!-- Add lessons below this line -->
@@ -0,0 +1,66 @@
1
+ # Bug Fix: Issue Title
2
+
3
+ Goal: Fix the bug where [describe the incorrect behavior].
4
+
5
+ ## Context
6
+
7
+ **Observed behavior:** What's happening now (the bug)
8
+ **Expected behavior:** What should happen instead
9
+ **Reproduction steps:** How to trigger the bug
10
+ **Affected areas:** Which parts of the system are impacted
11
+
12
+ ## Tasks
13
+
14
+ ### T001: Investigate root cause
15
+ - Status: pending
16
+ - Size: S
17
+
18
+ **Deliverables:**
19
+ - Identify the source of the bug
20
+ - Document findings in Notes section
21
+ - Determine fix approach
22
+
23
+ **Verify:** Root cause documented below
24
+
25
+ ---
26
+
27
+ ### T002: Implement fix
28
+ - Status: pending
29
+ - Size: M
30
+
31
+ **Deliverables:**
32
+ - Code change that fixes the bug
33
+ - No regressions in existing functionality
34
+ - Follows existing code patterns
35
+
36
+ **Verify:** `npm test` passes
37
+
38
+ ---
39
+
40
+ ### T003: Add regression test
41
+ - Status: pending
42
+ - Size: S
43
+
44
+ **Deliverables:**
45
+ - Test that fails without the fix
46
+ - Test that passes with the fix
47
+ - Test covers edge cases if applicable
48
+
49
+ **Verify:** `npm test -- bug-name` passes
50
+
51
+ ---
52
+
53
+ ## Acceptance Criteria
54
+
55
+ - WHEN reproducing the original bug steps, THEN correct behavior occurs
56
+ - WHEN running test suite, THEN all tests pass including new regression test
57
+
58
+ ## Notes
59
+
60
+ <!-- AI updates this section during implementation -->
61
+
62
+ ### Investigation Findings
63
+ <!-- Document root cause here -->
64
+
65
+ ### Fix Approach
66
+ <!-- Document chosen solution here -->
@@ -0,0 +1,56 @@
1
+ # Feature Name
2
+
3
+ Goal: One-sentence description of what this feature accomplishes.
4
+
5
+ ## Context
6
+
7
+ Background information for the agent implementing this spec:
8
+ - What problem does this solve?
9
+ - What existing code/patterns should it follow?
10
+ - Any constraints or requirements?
11
+
12
+ ## Tasks
13
+
14
+ ### T001: First task title
15
+ - Status: pending
16
+ - Size: S
17
+
18
+ **Deliverables:**
19
+ - What to build (WHAT, not HOW)
20
+ - Another deliverable
21
+
22
+ **Verify:** `npm test -- something`
23
+
24
+ ---
25
+
26
+ ### T002: Second task title
27
+ - Status: pending
28
+ - Size: M
29
+
30
+ **Deliverables:**
31
+ - Deliverable description
32
+ - Another deliverable
33
+
34
+ **Verify:** `curl localhost:3000/api` returns 200
35
+
36
+ ---
37
+
38
+ ### T003: Third task title
39
+ - Status: pending
40
+ - Size: S
41
+
42
+ **Deliverables:**
43
+ - Deliverable description
44
+
45
+ **Verify:** `npm run type-check` passes
46
+
47
+ ---
48
+
49
+ ## Acceptance Criteria
50
+
51
+ - WHEN user does X, THEN Y happens
52
+ - WHEN condition Z, THEN expected outcome
53
+
54
+ ## Notes
55
+
56
+ <!-- AI updates this section during implementation -->
@@ -0,0 +1,80 @@
1
+ # Refactor: Component/Module Name
2
+
3
+ Goal: Improve code quality of [target] without changing external behavior.
4
+
5
+ ## Context
6
+
7
+ **Why refactor:** What's wrong with the current code?
8
+ **Target scope:** Which files/modules are being refactored
9
+ **Constraints:** What must remain unchanged (APIs, behavior, etc.)
10
+
11
+ ## Tasks
12
+
13
+ ### T001: Audit current implementation
14
+ - Status: pending
15
+ - Size: S
16
+
17
+ **Deliverables:**
18
+ - Document current code structure
19
+ - Identify specific issues to address
20
+ - List files to modify
21
+
22
+ **Verify:** Audit documented in Notes section
23
+
24
+ ---
25
+
26
+ ### T002: Refactor core logic
27
+ - Status: pending
28
+ - Size: M
29
+
30
+ **Deliverables:**
31
+ - Improved code structure
32
+ - Better naming/organization
33
+ - Reduced complexity or duplication
34
+ - No behavior changes
35
+
36
+ **Verify:** `npm test` passes with same coverage
37
+
38
+ ---
39
+
40
+ ### T003: Update related code
41
+ - Status: pending
42
+ - Size: S
43
+
44
+ **Deliverables:**
45
+ - Update callers if signatures changed
46
+ - Update imports if files moved
47
+ - Update types if interfaces changed
48
+
49
+ **Verify:** `npm run type-check` passes
50
+
51
+ ---
52
+
53
+ ### T004: Verify no regressions
54
+ - Status: pending
55
+ - Size: S
56
+
57
+ **Deliverables:**
58
+ - All existing tests pass
59
+ - Manual verification of key flows
60
+ - Performance not degraded
61
+
62
+ **Verify:** `npm test && npm run type-check` passes
63
+
64
+ ---
65
+
66
+ ## Acceptance Criteria
67
+
68
+ - WHEN running test suite, THEN all tests pass
69
+ - WHEN comparing before/after behavior, THEN external behavior unchanged
70
+ - WHEN reviewing code, THEN identified issues are resolved
71
+
72
+ ## Notes
73
+
74
+ <!-- AI updates this section during implementation -->
75
+
76
+ ### Current Issues
77
+ <!-- List specific code smells/issues -->
78
+
79
+ ### Refactoring Approach
80
+ <!-- Document strategy -->
@@ -1,222 +0,0 @@
1
- ---
2
- name: create-spec
3
- description: Create a SPEC.md through structured interview and LLM review. Use this when starting a new project or feature.
4
- context: fork
5
- allowed-tools: Read, Write, Edit, AskUserQuestion, Task
6
- ---
7
-
8
- # Create SPEC Skill
9
-
10
- Create a well-structured SPEC.md through guided interview and quality review.
11
-
12
- ## Workflow
13
-
14
- ```
15
- Interview → Generate → Review → Finalize
16
- ```
17
-
18
- ## Step 1: Interview
19
-
20
- Use **AskUserQuestion** to gather requirements in batches. Don't generate the spec until you have enough context.
21
-
22
- ### Batch 1: Project Foundation
23
-
24
- ```typescript
25
- AskUserQuestion({
26
- questions: [
27
- {
28
- question: "What type of project is this?",
29
- header: "Type",
30
- multiSelect: false,
31
- options: [
32
- { label: "CLI tool", description: "Command-line application" },
33
- { label: "Web API", description: "REST/GraphQL backend" },
34
- { label: "Library", description: "Reusable package" },
35
- { label: "Full-stack", description: "Frontend + backend" }
36
- ]
37
- },
38
- {
39
- question: "What language/framework?",
40
- header: "Stack",
41
- multiSelect: false,
42
- options: [
43
- { label: "TypeScript/Node.js (Recommended)", description: "Modern JS with types" },
44
- { label: "Python", description: "Great for data, ML, scripting" },
45
- { label: "Go", description: "Fast, good for systems" },
46
- { label: "Rust", description: "Memory-safe systems" }
47
- ]
48
- }
49
- ]
50
- })
51
- ```
52
-
53
- ### Batch 2: Core Requirements
54
-
55
- Ask about:
56
- - Primary use case (what problem does it solve?)
57
- - Target users (who will use this?)
58
- - Core features (what must it do?)
59
- - External integrations (APIs, databases, services?)
60
-
61
- ### Batch 3: Quality & Constraints
62
-
63
- Ask about:
64
- - Testing expectations (unit only / unit+integration / full)
65
- - Auth requirements (none / basic / OAuth / custom)
66
- - Performance constraints (if any)
67
- - Timeline/priority (MVP vs full feature set)
68
-
69
- ### Interview Tips
70
-
71
- - Ask follow-up questions if answers are vague
72
- - Dig into edge cases: "What happens when X fails?"
73
- - Clarify scope: "Is Y a must-have or nice-to-have?"
74
- - Don't proceed until you understand the core requirements
75
-
76
- ## Step 2: Generate SPEC
77
-
78
- Write `SPEC.md` following these rules:
79
-
80
- ### Structure
81
-
82
- ```markdown
83
- # Project Name
84
-
85
- Brief description (1-2 sentences).
86
-
87
- ## Goal
88
- What this project achieves when complete.
89
-
90
- ## Tasks
91
-
92
- ### Phase 1: Foundation
93
- - [ ] Task description
94
- - Deliverable 1
95
- - Deliverable 2
96
-
97
- ### Phase 2: Core Features
98
- - [ ] Another task
99
- - Deliverable 1
100
- ```
101
-
102
- ### Task Rules
103
-
104
- **Each checkbox = one Ralphie iteration.** Batch related work.
105
-
106
- ```markdown
107
- # BAD - 4 iterations
108
- - [ ] Create UserModel.ts
109
- - [ ] Create UserService.ts
110
- - [ ] Create UserController.ts
111
- - [ ] Create user.test.ts
112
-
113
- # GOOD - 1 iteration
114
- - [ ] Create User module (Model, Service, Controller) with tests
115
- ```
116
-
117
- ### What SPECs Must NOT Include
118
-
119
- SPECs describe **requirements**, not solutions.
120
-
121
- **Never include:**
122
- - Code snippets or implementation examples
123
- - File:line references (e.g., `auth.ts:42`)
124
- - Shell commands (`npm install X`, `git log`)
125
- - Root cause analysis ("The bug is because...")
126
- - "Technical Notes" or "Fix Approach" sections
127
- - Implementation instructions
128
-
129
- **Sub-bullets are deliverables, not instructions:**
130
-
131
- ```markdown
132
- # BAD - prescribes HOW
133
- - [ ] Fix auth bug
134
- - Use `bcrypt.compare()` instead of `===`
135
- - Add try/catch at line 50
136
-
137
- # GOOD - describes WHAT
138
- - [ ] Fix auth bug
139
- - Password comparison should be timing-safe
140
- - Handle comparison errors gracefully
141
- ```
142
-
143
- ### Verification Steps
144
-
145
- Each task SHOULD include a **Verify:** section with concrete checks:
146
-
147
- ```markdown
148
- - [ ] Implement authentication system
149
- - POST /auth/register - create user with hashed password
150
- - POST /auth/login - validate credentials, return JWT
151
- - Tests for all auth flows
152
-
153
- **Verify:**
154
- - `curl -X POST localhost:3000/auth/register -d '{"email":"test@test.com","password":"test123"}'` → 201
155
- - `curl -X POST localhost:3000/auth/login -d '{"email":"test@test.com","password":"test123"}'` → returns JWT
156
- - `npm test` → all tests pass
157
- ```
158
-
159
- Good verification steps:
160
- - API calls with expected response codes
161
- - CLI commands with expected output
162
- - File existence checks (`ls dist/` → contains index.js)
163
- - Test commands (`npm test` → all pass)
164
-
165
- ## Step 3: Review with LLM
166
-
167
- After generating the spec, spawn a review agent to check for violations:
168
-
169
- ```typescript
170
- Task({
171
- subagent_type: 'general-purpose',
172
- description: 'Review SPEC.md',
173
- prompt: `Review SPEC.md for convention violations.
174
-
175
- Check for these anti-patterns:
176
- 1. Code snippets (any \`\`\` blocks with implementation code)
177
- 2. File:line references (e.g., setup.ts:150)
178
- 3. Shell commands in tasks (npm, git, docker, etc.)
179
- 4. "Technical Notes" or "Fix Approach" sections
180
- 5. Implementation instructions ("Use X to...", "Change line Y")
181
-
182
- For each violation found:
183
- - Quote the problematic line
184
- - Explain why it's a violation
185
- - Suggest a requirement-focused alternative
186
-
187
- Respond with:
188
- - PASS: No violations found
189
- - FAIL: List each violation with fix suggestion`
190
- })
191
- ```
192
-
193
- ### If Review Fails
194
-
195
- 1. Fix each violation the reviewer identified
196
- 2. Re-run the review
197
- 3. Only proceed when review passes
198
-
199
- ## Step 4: Finalize
200
-
201
- After review passes:
202
-
203
- 1. Confirm with user: "SPEC is ready. Review it or start first iteration?"
204
- 2. Wait for explicit approval
205
- 3. Do NOT auto-start implementation
206
-
207
- ```markdown
208
- ✓ SPEC.md created with X tasks across Y phases
209
- ✓ Passed convention review
210
-
211
- Ready to proceed? Say "start" to begin first iteration.
212
- ```
213
-
214
- ## Quick Reference
215
-
216
- | Do | Don't |
217
- |----|-------|
218
- | Describe outcomes | Prescribe implementation |
219
- | Use deliverable sub-bullets | Use instruction sub-bullets |
220
- | Batch related tasks | Split tiny tasks |
221
- | Keep it scannable | Add code examples |
222
- | Run LLM review | Skip validation |