ralph-mcp 1.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.
- package/LICENSE +21 -0
- package/README.md +131 -0
- package/dist/db/client.d.ts +7 -0
- package/dist/db/client.js +55 -0
- package/dist/db/schema.d.ts +540 -0
- package/dist/db/schema.js +57 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +278 -0
- package/dist/store/state.d.ts +55 -0
- package/dist/store/state.js +205 -0
- package/dist/tools/get.d.ts +40 -0
- package/dist/tools/get.js +48 -0
- package/dist/tools/merge.d.ts +50 -0
- package/dist/tools/merge.js +384 -0
- package/dist/tools/set-agent-id.d.ts +18 -0
- package/dist/tools/set-agent-id.js +24 -0
- package/dist/tools/start.d.ts +42 -0
- package/dist/tools/start.js +96 -0
- package/dist/tools/status.d.ts +35 -0
- package/dist/tools/status.js +53 -0
- package/dist/tools/stop.d.ts +24 -0
- package/dist/tools/stop.js +52 -0
- package/dist/tools/update.d.ts +28 -0
- package/dist/tools/update.js +71 -0
- package/dist/utils/agent.d.ts +22 -0
- package/dist/utils/agent.js +110 -0
- package/dist/utils/merge-helpers.d.ts +48 -0
- package/dist/utils/merge-helpers.js +213 -0
- package/dist/utils/prd-parser.d.ts +22 -0
- package/dist/utils/prd-parser.js +137 -0
- package/dist/utils/worktree.d.ts +34 -0
- package/dist/utils/worktree.js +136 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 G0d2i11a
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Ralph MCP
|
|
2
|
+
|
|
3
|
+
MCP server for autonomous PRD execution with Claude Code. Git worktree isolation, progress tracking, auto-merge.
|
|
4
|
+
|
|
5
|
+
Based on [Geoffrey Huntley's Ralph pattern](https://ghuntley.com/ralph/).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **PRD Parsing** - Extracts User Stories from markdown PRD files
|
|
10
|
+
- **Git Worktree Isolation** - Each PRD runs in isolated worktree
|
|
11
|
+
- **Progress Tracking** - Real-time status via `ralph_status()`
|
|
12
|
+
- **Auto Merge** - One-click merge with conflict resolution
|
|
13
|
+
- **Notifications** - Windows Toast when PRD completes
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
### From npm
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g ralph-mcp
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### From source
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git clone https://github.com/G0d2i11a/ralph-mcp.git
|
|
27
|
+
cd ralph-mcp
|
|
28
|
+
npm install
|
|
29
|
+
npm run build
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
Add to `~/.claude/mcp.json`:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"ralph": {
|
|
40
|
+
"command": "npx",
|
|
41
|
+
"args": ["ralph-mcp"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or if installed from source:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"mcpServers": {
|
|
52
|
+
"ralph": {
|
|
53
|
+
"command": "node",
|
|
54
|
+
"args": ["/path/to/ralph-mcp/dist/index.js"]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Restart Claude Code to load.
|
|
61
|
+
|
|
62
|
+
## Tools
|
|
63
|
+
|
|
64
|
+
| Tool | Description |
|
|
65
|
+
|------|-------------|
|
|
66
|
+
| `ralph_start` | Start PRD execution (parse PRD, create worktree, return agent prompt) |
|
|
67
|
+
| `ralph_status` | View all PRD execution status |
|
|
68
|
+
| `ralph_get` | Get single PRD details |
|
|
69
|
+
| `ralph_update` | Update User Story status (called by agent) |
|
|
70
|
+
| `ralph_stop` | Stop execution |
|
|
71
|
+
| `ralph_merge` | Merge to main + cleanup worktree |
|
|
72
|
+
| `ralph_merge_queue` | Manage serial merge queue |
|
|
73
|
+
| `ralph_set_agent_id` | Record Task agent ID |
|
|
74
|
+
|
|
75
|
+
## Usage
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
// Start PRD execution
|
|
79
|
+
ralph_start({ prdPath: "tasks/prd-feature.md" })
|
|
80
|
+
|
|
81
|
+
// Check all status
|
|
82
|
+
ralph_status()
|
|
83
|
+
|
|
84
|
+
// Get single PRD details
|
|
85
|
+
ralph_get({ branch: "ralph/prd-feature" })
|
|
86
|
+
|
|
87
|
+
// Update US status (agent calls this after completing a story)
|
|
88
|
+
ralph_update({ branch: "ralph/prd-feature", storyId: "US-1", passes: true, notes: "..." })
|
|
89
|
+
|
|
90
|
+
// Merge completed PRD
|
|
91
|
+
ralph_merge({ branch: "ralph/prd-feature" })
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## PRD Format
|
|
95
|
+
|
|
96
|
+
Ralph parses markdown PRD files with User Stories:
|
|
97
|
+
|
|
98
|
+
```markdown
|
|
99
|
+
# Feature Name
|
|
100
|
+
|
|
101
|
+
## User Stories
|
|
102
|
+
|
|
103
|
+
### US-1: Story Title
|
|
104
|
+
|
|
105
|
+
**Acceptance Criteria:**
|
|
106
|
+
- [ ] Criterion 1
|
|
107
|
+
- [ ] Criterion 2
|
|
108
|
+
|
|
109
|
+
### US-2: Another Story
|
|
110
|
+
...
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Conflict Resolution
|
|
114
|
+
|
|
115
|
+
`ralph_merge` supports these strategies:
|
|
116
|
+
|
|
117
|
+
| Strategy | Behavior |
|
|
118
|
+
|----------|----------|
|
|
119
|
+
| `auto_theirs` | `git merge -X theirs`, prefer main |
|
|
120
|
+
| `auto_ours` | `git merge -X ours`, prefer branch |
|
|
121
|
+
| `notify` | Pause, notify user to resolve manually |
|
|
122
|
+
| `agent` | Launch merge subagent to resolve (default) |
|
|
123
|
+
|
|
124
|
+
## Data Storage
|
|
125
|
+
|
|
126
|
+
- State: `~/.ralph/state.json` (JSON file)
|
|
127
|
+
- Logs: `~/.ralph/logs/`
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
MIT
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Database from "better-sqlite3";
|
|
2
|
+
import * as schema from "./schema.js";
|
|
3
|
+
declare const RALPH_DATA_DIR: string;
|
|
4
|
+
export declare const db: import("drizzle-orm/better-sqlite3").BetterSQLite3Database<typeof schema> & {
|
|
5
|
+
$client: Database.Database;
|
|
6
|
+
};
|
|
7
|
+
export { RALPH_DATA_DIR };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Database from "better-sqlite3";
|
|
2
|
+
import { drizzle } from "drizzle-orm/better-sqlite3";
|
|
3
|
+
import { existsSync, mkdirSync } from "fs";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
import * as schema from "./schema.js";
|
|
7
|
+
const RALPH_DATA_DIR = process.env.RALPH_DATA_DIR?.replace("~", homedir()) ||
|
|
8
|
+
join(homedir(), ".ralph");
|
|
9
|
+
// Ensure data directory exists
|
|
10
|
+
if (!existsSync(RALPH_DATA_DIR)) {
|
|
11
|
+
mkdirSync(RALPH_DATA_DIR, { recursive: true });
|
|
12
|
+
}
|
|
13
|
+
const DB_PATH = join(RALPH_DATA_DIR, "state.db");
|
|
14
|
+
const sqlite = new Database(DB_PATH);
|
|
15
|
+
// Enable WAL mode for better concurrency
|
|
16
|
+
sqlite.pragma("journal_mode = WAL");
|
|
17
|
+
export const db = drizzle(sqlite, { schema });
|
|
18
|
+
// Initialize tables
|
|
19
|
+
sqlite.exec(`
|
|
20
|
+
CREATE TABLE IF NOT EXISTS executions (
|
|
21
|
+
id TEXT PRIMARY KEY,
|
|
22
|
+
project TEXT NOT NULL,
|
|
23
|
+
branch TEXT NOT NULL UNIQUE,
|
|
24
|
+
description TEXT NOT NULL,
|
|
25
|
+
prd_path TEXT NOT NULL,
|
|
26
|
+
project_root TEXT NOT NULL,
|
|
27
|
+
worktree_path TEXT,
|
|
28
|
+
status TEXT NOT NULL DEFAULT 'pending',
|
|
29
|
+
agent_task_id TEXT,
|
|
30
|
+
on_conflict TEXT DEFAULT 'agent',
|
|
31
|
+
created_at INTEGER NOT NULL,
|
|
32
|
+
updated_at INTEGER NOT NULL
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
CREATE TABLE IF NOT EXISTS user_stories (
|
|
36
|
+
id TEXT PRIMARY KEY,
|
|
37
|
+
execution_id TEXT NOT NULL REFERENCES executions(id) ON DELETE CASCADE,
|
|
38
|
+
story_id TEXT NOT NULL,
|
|
39
|
+
title TEXT NOT NULL,
|
|
40
|
+
description TEXT NOT NULL,
|
|
41
|
+
acceptance_criteria TEXT NOT NULL,
|
|
42
|
+
priority INTEGER NOT NULL,
|
|
43
|
+
passes INTEGER NOT NULL DEFAULT 0,
|
|
44
|
+
notes TEXT DEFAULT ''
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
CREATE TABLE IF NOT EXISTS merge_queue (
|
|
48
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
49
|
+
execution_id TEXT NOT NULL REFERENCES executions(id) ON DELETE CASCADE,
|
|
50
|
+
position INTEGER NOT NULL,
|
|
51
|
+
status TEXT NOT NULL DEFAULT 'pending',
|
|
52
|
+
created_at INTEGER NOT NULL
|
|
53
|
+
);
|
|
54
|
+
`);
|
|
55
|
+
export { RALPH_DATA_DIR };
|