ralphblaster-agent 0.1.1
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 +294 -0
- package/bin/agent-dashboard.sh +168 -0
- package/bin/monitor-agent.sh +264 -0
- package/bin/ralphblaster.js +247 -0
- package/package.json +64 -0
- package/postinstall-colored.js +66 -0
- package/src/api-client.js +764 -0
- package/src/claude-plugin/.claude-plugin/plugin.json +9 -0
- package/src/claude-plugin/README.md +42 -0
- package/src/claude-plugin/skills/ralph/SKILL.md +259 -0
- package/src/commands/add-project.js +257 -0
- package/src/commands/init.js +79 -0
- package/src/config-file-manager.js +84 -0
- package/src/config.js +66 -0
- package/src/error-window.js +86 -0
- package/src/executor/claude-runner.js +716 -0
- package/src/executor/error-handler.js +65 -0
- package/src/executor/git-helper.js +196 -0
- package/src/executor/index.js +296 -0
- package/src/executor/job-handlers/clarifying-questions.js +213 -0
- package/src/executor/job-handlers/code-execution.js +145 -0
- package/src/executor/job-handlers/prd-generation.js +259 -0
- package/src/executor/path-helper.js +74 -0
- package/src/executor/prompt-validator.js +51 -0
- package/src/executor.js +4 -0
- package/src/index.js +342 -0
- package/src/logger.js +193 -0
- package/src/logging/README.md +93 -0
- package/src/logging/config.js +179 -0
- package/src/logging/destinations/README.md +290 -0
- package/src/logging/destinations/api-destination-unbatched.js +118 -0
- package/src/logging/destinations/api-destination.js +40 -0
- package/src/logging/destinations/base-destination.js +85 -0
- package/src/logging/destinations/batched-destination.js +198 -0
- package/src/logging/destinations/console-destination.js +172 -0
- package/src/logging/destinations/file-destination.js +208 -0
- package/src/logging/destinations/index.js +29 -0
- package/src/logging/destinations/progress-batch-destination-unbatched.js +92 -0
- package/src/logging/destinations/progress-batch-destination.js +41 -0
- package/src/logging/formatter.js +288 -0
- package/src/logging/log-manager.js +426 -0
- package/src/progress-throttle.js +101 -0
- package/src/system-monitor.js +64 -0
- package/src/utils/format.js +16 -0
- package/src/utils/log-file-helper.js +265 -0
- package/src/utils/progress-parser.js +250 -0
- package/src/worktree-manager.js +255 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Ralph Plugin for Claude Code
|
|
2
|
+
|
|
3
|
+
This plugin provides the `/ralph` skill for converting markdown PRDs into structured JSON format for the Ralph autonomous agent system.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
The `/ralph` skill:
|
|
8
|
+
- Converts Product Requirements Documents (PRDs) from markdown to JSON
|
|
9
|
+
- Structures features into appropriately-sized user stories
|
|
10
|
+
- Orders stories by dependency (database โ backend โ UI)
|
|
11
|
+
- Ensures acceptance criteria are verifiable
|
|
12
|
+
- Generates branch names in kebab-case format
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
This plugin is automatically installed when you install the `ralph blaster` npm package:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g ralphblaster
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The plugin will be installed to: `~/.claude/plugins/local/ralph/`
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Use the `/ralph` skill in Claude Code:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
claude /ralph < your-prd.md
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or pipe PRD content directly:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
cat prd.md | claude /ralph
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The skill will generate a `prd.json` file in the current directory.
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ralphblaster
|
|
3
|
+
description: "Convert PRDs to prd.json format for the RalphBlasterBlaster autonomous agent system. Use when you have an existing PRD and need to convert it to RalphBlasterBlaster's JSON format. Triggers on: convert this prd, turn this into ralphblaster format, create prd.json from this, ralphblaster json."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# RalphBlasterBlaster PRD Converter
|
|
7
|
+
|
|
8
|
+
Converts existing PRDs to the prd.json format that RalphBlasterBlaster uses for autonomous execution.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## The Job
|
|
13
|
+
|
|
14
|
+
Take a PRD (markdown file or text) and convert it to `prd.json` format.
|
|
15
|
+
|
|
16
|
+
**CRITICAL: You MUST use the Write tool to create the prd.json file.** The user will specify the exact file path where you should write the file. Do not just output the JSON - you must actually create the file using the Write tool.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Output Format
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"project": "[Project Name]",
|
|
25
|
+
"branchName": "ralphblaster/[feature-name-kebab-case]",
|
|
26
|
+
"description": "[Feature description from PRD title/intro]",
|
|
27
|
+
"userStories": [
|
|
28
|
+
{
|
|
29
|
+
"id": "US-001",
|
|
30
|
+
"title": "[Story title]",
|
|
31
|
+
"description": "As a [user], I want [feature] so that [benefit]",
|
|
32
|
+
"acceptanceCriteria": [
|
|
33
|
+
"Criterion 1",
|
|
34
|
+
"Criterion 2",
|
|
35
|
+
"Typecheck passes"
|
|
36
|
+
],
|
|
37
|
+
"priority": 1,
|
|
38
|
+
"passes": false,
|
|
39
|
+
"notes": ""
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Story Size: The Number One Rule
|
|
48
|
+
|
|
49
|
+
**Each story must be completable in ONE RalphBlaster iteration (one context window).**
|
|
50
|
+
|
|
51
|
+
RalphBlaster spawns a fresh Amp instance per iteration with no memory of previous work. If a story is too big, the LLM runs out of context before finishing and produces broken code.
|
|
52
|
+
|
|
53
|
+
### Right-sized stories:
|
|
54
|
+
- Add a database column and migration
|
|
55
|
+
- Add a UI component to an existing page
|
|
56
|
+
- Update a server action with new logic
|
|
57
|
+
- Add a filter dropdown to a list
|
|
58
|
+
|
|
59
|
+
### Too big (split these):
|
|
60
|
+
- "Build the entire dashboard" - Split into: schema, queries, UI components, filters
|
|
61
|
+
- "Add authentication" - Split into: schema, middleware, login UI, session handling
|
|
62
|
+
- "Refactor the API" - Split into one story per endpoint or pattern
|
|
63
|
+
|
|
64
|
+
**Rule of thumb:** If you cannot describe the change in 2-3 sentences, it is too big.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Story Ordering: Dependencies First
|
|
69
|
+
|
|
70
|
+
Stories execute in priority order. Earlier stories must not depend on later ones.
|
|
71
|
+
|
|
72
|
+
**Correct order:**
|
|
73
|
+
1. Schema/database changes (migrations)
|
|
74
|
+
2. Server actions / backend logic
|
|
75
|
+
3. UI components that use the backend
|
|
76
|
+
4. Dashboard/summary views that aggregate data
|
|
77
|
+
|
|
78
|
+
**Wrong order:**
|
|
79
|
+
1. UI component (depends on schema that does not exist yet)
|
|
80
|
+
2. Schema change
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Acceptance Criteria: Must Be Verifiable
|
|
85
|
+
|
|
86
|
+
Each criterion must be something RalphBlaster can CHECK, not something vague.
|
|
87
|
+
|
|
88
|
+
### Good criteria (verifiable):
|
|
89
|
+
- "Add `status` column to tasks table with default 'pending'"
|
|
90
|
+
- "Filter dropdown has options: All, Active, Completed"
|
|
91
|
+
- "Clicking delete shows confirmation dialog"
|
|
92
|
+
- "Typecheck passes"
|
|
93
|
+
- "Tests pass"
|
|
94
|
+
|
|
95
|
+
### Bad criteria (vague):
|
|
96
|
+
- "Works correctly"
|
|
97
|
+
- "User can do X easily"
|
|
98
|
+
- "Good UX"
|
|
99
|
+
- "Handles edge cases"
|
|
100
|
+
|
|
101
|
+
### Always include as final criterion:
|
|
102
|
+
```
|
|
103
|
+
"Typecheck passes"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
For stories with testable logic, also include:
|
|
107
|
+
```
|
|
108
|
+
"Tests pass"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### For stories that change UI, also include:
|
|
112
|
+
```
|
|
113
|
+
"Verify in browser using dev-browser skill"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Frontend stories are NOT complete until visually verified. RalphBlaster will use the dev-browser skill to navigate to the page, interact with the UI, and confirm changes work.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Conversion Rules
|
|
121
|
+
|
|
122
|
+
1. **Each user story becomes one JSON entry**
|
|
123
|
+
2. **IDs**: Sequential (US-001, US-002, etc.)
|
|
124
|
+
3. **Priority**: Based on dependency order, then document order
|
|
125
|
+
4. **All stories**: `passes: false` and empty `notes`
|
|
126
|
+
5. **branchName**: Derive from feature name, kebab-case, prefixed with `ralphblaster/`
|
|
127
|
+
6. **Always add**: "Typecheck passes" to every story's acceptance criteria
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Splitting Large PRDs
|
|
132
|
+
|
|
133
|
+
If a PRD has big features, split them:
|
|
134
|
+
|
|
135
|
+
**Original:**
|
|
136
|
+
> "Add user notification system"
|
|
137
|
+
|
|
138
|
+
**Split into:**
|
|
139
|
+
1. US-001: Add notifications table to database
|
|
140
|
+
2. US-002: Create notification service for sending notifications
|
|
141
|
+
3. US-003: Add notification bell icon to header
|
|
142
|
+
4. US-004: Create notification dropdown panel
|
|
143
|
+
5. US-005: Add mark-as-read functionality
|
|
144
|
+
6. US-006: Add notification preferences page
|
|
145
|
+
|
|
146
|
+
Each is one focused change that can be completed and verified independently.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Example
|
|
151
|
+
|
|
152
|
+
**Input PRD:**
|
|
153
|
+
```markdown
|
|
154
|
+
# Task Status Feature
|
|
155
|
+
|
|
156
|
+
Add ability to mark tasks with different statuses.
|
|
157
|
+
|
|
158
|
+
## Requirements
|
|
159
|
+
- Toggle between pending/in-progress/done on task list
|
|
160
|
+
- Filter list by status
|
|
161
|
+
- Show status badge on each task
|
|
162
|
+
- Persist status in database
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Output prd.json:**
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"project": "TaskApp",
|
|
169
|
+
"branchName": "ralphblaster/task-status",
|
|
170
|
+
"description": "Task Status Feature - Track task progress with status indicators",
|
|
171
|
+
"userStories": [
|
|
172
|
+
{
|
|
173
|
+
"id": "US-001",
|
|
174
|
+
"title": "Add status field to tasks table",
|
|
175
|
+
"description": "As a developer, I need to store task status in the database.",
|
|
176
|
+
"acceptanceCriteria": [
|
|
177
|
+
"Add status column: 'pending' | 'in_progress' | 'done' (default 'pending')",
|
|
178
|
+
"Generate and run migration successfully",
|
|
179
|
+
"Typecheck passes"
|
|
180
|
+
],
|
|
181
|
+
"priority": 1,
|
|
182
|
+
"passes": false,
|
|
183
|
+
"notes": ""
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"id": "US-002",
|
|
187
|
+
"title": "Display status badge on task cards",
|
|
188
|
+
"description": "As a user, I want to see task status at a glance.",
|
|
189
|
+
"acceptanceCriteria": [
|
|
190
|
+
"Each task card shows colored status badge",
|
|
191
|
+
"Badge colors: gray=pending, blue=in_progress, green=done",
|
|
192
|
+
"Typecheck passes",
|
|
193
|
+
"Verify in browser using dev-browser skill"
|
|
194
|
+
],
|
|
195
|
+
"priority": 2,
|
|
196
|
+
"passes": false,
|
|
197
|
+
"notes": ""
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"id": "US-003",
|
|
201
|
+
"title": "Add status toggle to task list rows",
|
|
202
|
+
"description": "As a user, I want to change task status directly from the list.",
|
|
203
|
+
"acceptanceCriteria": [
|
|
204
|
+
"Each row has status dropdown or toggle",
|
|
205
|
+
"Changing status saves immediately",
|
|
206
|
+
"UI updates without page refresh",
|
|
207
|
+
"Typecheck passes",
|
|
208
|
+
"Verify in browser using dev-browser skill"
|
|
209
|
+
],
|
|
210
|
+
"priority": 3,
|
|
211
|
+
"passes": false,
|
|
212
|
+
"notes": ""
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"id": "US-004",
|
|
216
|
+
"title": "Filter tasks by status",
|
|
217
|
+
"description": "As a user, I want to filter the list to see only certain statuses.",
|
|
218
|
+
"acceptanceCriteria": [
|
|
219
|
+
"Filter dropdown: All | Pending | In Progress | Done",
|
|
220
|
+
"Filter persists in URL params",
|
|
221
|
+
"Typecheck passes",
|
|
222
|
+
"Verify in browser using dev-browser skill"
|
|
223
|
+
],
|
|
224
|
+
"priority": 4,
|
|
225
|
+
"passes": false,
|
|
226
|
+
"notes": ""
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Archiving Previous Runs
|
|
235
|
+
|
|
236
|
+
**Before writing a new prd.json, check if there is an existing one from a different feature:**
|
|
237
|
+
|
|
238
|
+
1. Read the current `prd.json` if it exists
|
|
239
|
+
2. Check if `branchName` differs from the new feature's branch name
|
|
240
|
+
3. If different AND `progress.txt` has content beyond the header:
|
|
241
|
+
- Create archive folder: `archive/YYYY-MM-DD-feature-name/`
|
|
242
|
+
- Copy current `prd.json` and `progress.txt` to archive
|
|
243
|
+
- Reset `progress.txt` with fresh header
|
|
244
|
+
|
|
245
|
+
**The ralph.sh script handles this automatically** when you run it, but if you are manually updating prd.json between runs, archive first.
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Checklist Before Saving
|
|
250
|
+
|
|
251
|
+
Before writing prd.json, verify:
|
|
252
|
+
|
|
253
|
+
- [ ] **Previous run archived** (if prd.json exists with different branchName, archive it first)
|
|
254
|
+
- [ ] Each story is completable in one iteration (small enough)
|
|
255
|
+
- [ ] Stories are ordered by dependency (schema to backend to UI)
|
|
256
|
+
- [ ] Every story has "Typecheck passes" as criterion
|
|
257
|
+
- [ ] UI stories have "Verify in browser using dev-browser skill" as criterion
|
|
258
|
+
- [ ] Acceptance criteria are verifiable (not vague)
|
|
259
|
+
- [ ] No story depends on a later story
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const ApiClient = require('../api-client');
|
|
5
|
+
const logger = require('../logger');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* AddProject Command
|
|
9
|
+
* Registers the current directory as a RalphBlaster project via API
|
|
10
|
+
*/
|
|
11
|
+
class AddProjectCommand {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.cwd = process.cwd();
|
|
14
|
+
this.apiClient = new ApiClient();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Run the add-project command
|
|
19
|
+
*/
|
|
20
|
+
async run() {
|
|
21
|
+
try {
|
|
22
|
+
logger.info('Registering project with RalphBlaster...');
|
|
23
|
+
|
|
24
|
+
// Detect project name
|
|
25
|
+
const projectName = await this.detectProjectName();
|
|
26
|
+
logger.debug(`Detected project name: ${projectName}`);
|
|
27
|
+
|
|
28
|
+
// Create project via API
|
|
29
|
+
const project = await this.createProject(this.cwd, projectName);
|
|
30
|
+
|
|
31
|
+
// Display success message
|
|
32
|
+
this.displaySuccess(project);
|
|
33
|
+
|
|
34
|
+
process.exit(0);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
this.handleError(error);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Detect project name from various sources
|
|
43
|
+
* Priority: 1. Git remote, 2. package.json, 3. Directory name
|
|
44
|
+
*/
|
|
45
|
+
async detectProjectName() {
|
|
46
|
+
// Try git remote first
|
|
47
|
+
try {
|
|
48
|
+
const gitRemoteName = this.getGitRemoteName();
|
|
49
|
+
if (gitRemoteName) {
|
|
50
|
+
logger.debug('Using project name from Git remote');
|
|
51
|
+
return gitRemoteName;
|
|
52
|
+
}
|
|
53
|
+
} catch (error) {
|
|
54
|
+
logger.debug('Could not detect Git remote name:', error.message);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Try package.json
|
|
58
|
+
try {
|
|
59
|
+
const packageJsonName = this.getPackageJsonName();
|
|
60
|
+
if (packageJsonName) {
|
|
61
|
+
logger.debug('Using project name from package.json');
|
|
62
|
+
return packageJsonName;
|
|
63
|
+
}
|
|
64
|
+
} catch (error) {
|
|
65
|
+
logger.debug('Could not read package.json:', error.message);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Fallback to directory name
|
|
69
|
+
logger.debug('Using directory name as project name');
|
|
70
|
+
return this.getDirectoryName();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get project name from Git remote URL
|
|
75
|
+
* Example: https://github.com/user/repo.git -> "repo"
|
|
76
|
+
*/
|
|
77
|
+
getGitRemoteName() {
|
|
78
|
+
try {
|
|
79
|
+
const remote = execSync('git config --get remote.origin.url', {
|
|
80
|
+
cwd: this.cwd,
|
|
81
|
+
encoding: 'utf8',
|
|
82
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
83
|
+
}).trim();
|
|
84
|
+
|
|
85
|
+
if (!remote) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Extract repo name from URL
|
|
90
|
+
// Handles: https://github.com/user/repo.git, git@github.com:user/repo.git
|
|
91
|
+
const match = remote.match(/\/([^\/]+?)(\.git)?$/);
|
|
92
|
+
return match ? match[1] : null;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
// Git not initialized or no remote configured
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get project name from package.json
|
|
101
|
+
*/
|
|
102
|
+
getPackageJsonName() {
|
|
103
|
+
const packageJsonPath = path.join(this.cwd, 'package.json');
|
|
104
|
+
|
|
105
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
110
|
+
return packageJson.name || null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Get project name from directory name
|
|
115
|
+
*/
|
|
116
|
+
getDirectoryName() {
|
|
117
|
+
return path.basename(this.cwd);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Create project via API
|
|
122
|
+
*/
|
|
123
|
+
async createProject(systemPath, name) {
|
|
124
|
+
try {
|
|
125
|
+
logger.info(`Creating project: ${name}`);
|
|
126
|
+
|
|
127
|
+
const response = await this.apiClient.requestWithFallback('post', '/projects', {
|
|
128
|
+
system_path: systemPath,
|
|
129
|
+
name: name
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (response.data && response.data.success) {
|
|
133
|
+
return response.data.project;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
throw new Error('Unexpected response format from API');
|
|
137
|
+
} catch (error) {
|
|
138
|
+
// Re-throw with more context
|
|
139
|
+
if (error.response) {
|
|
140
|
+
const status = error.response.status;
|
|
141
|
+
const errorMessage = error.response.data?.error || error.message;
|
|
142
|
+
|
|
143
|
+
if (status === 401) {
|
|
144
|
+
throw new Error('Invalid API token. Please run "ralphblaster init" first.');
|
|
145
|
+
} else if (status === 403) {
|
|
146
|
+
throw new Error('API token lacks "rb_agent" permission. Please generate a new agent token.');
|
|
147
|
+
} else if (status === 422) {
|
|
148
|
+
throw new Error(`Validation error: ${errorMessage}`);
|
|
149
|
+
} else {
|
|
150
|
+
throw new Error(`API error (${status}): ${errorMessage}`);
|
|
151
|
+
}
|
|
152
|
+
} else if (error.request) {
|
|
153
|
+
throw new Error(`Could not connect to RalphBlaster API at ${this.apiClient.client.defaults.baseURL}`);
|
|
154
|
+
} else {
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Display success message
|
|
162
|
+
*/
|
|
163
|
+
displaySuccess(project) {
|
|
164
|
+
const iconEmoji = this.getIconEmoji(project.icon);
|
|
165
|
+
|
|
166
|
+
logger.info('Project registered successfully!', {
|
|
167
|
+
name: project.name,
|
|
168
|
+
path: project.system_path,
|
|
169
|
+
icon: iconEmoji,
|
|
170
|
+
color: this.formatColorName(project.color)
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
console.log('');
|
|
174
|
+
console.log('Next step:');
|
|
175
|
+
console.log(' Start the agent: ralphblaster');
|
|
176
|
+
console.log('');
|
|
177
|
+
console.log('The agent will poll for tasks assigned to this project.');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Convert icon name to emoji
|
|
182
|
+
*/
|
|
183
|
+
getIconEmoji(icon) {
|
|
184
|
+
// If it's already an emoji, return it
|
|
185
|
+
if (icon && icon.match(/[\u{1F300}-\u{1F9FF}]/u)) {
|
|
186
|
+
return icon;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Map Heroicon names to emojis
|
|
190
|
+
const iconMap = {
|
|
191
|
+
'folder': '๐',
|
|
192
|
+
'rocket': '๐',
|
|
193
|
+
'beaker': '๐งช',
|
|
194
|
+
'globe-alt': '๐',
|
|
195
|
+
'device-phone-mobile': '๐ฑ',
|
|
196
|
+
'chart-bar': '๐',
|
|
197
|
+
'code': '๐ป',
|
|
198
|
+
'academic-cap': '๐',
|
|
199
|
+
'light-bulb': '๐ก',
|
|
200
|
+
'megaphone': '๐ฃ',
|
|
201
|
+
'briefcase': '๐ผ',
|
|
202
|
+
'cube': '๐ฒ',
|
|
203
|
+
'puzzle-piece': '๐งฉ',
|
|
204
|
+
'sparkles': 'โจ',
|
|
205
|
+
'fire': '๐ฅ',
|
|
206
|
+
'star': 'โญ',
|
|
207
|
+
'heart': 'โค๏ธ',
|
|
208
|
+
'bolt': 'โก',
|
|
209
|
+
'shield': '๐ก๏ธ',
|
|
210
|
+
'cloud': 'โ๏ธ'
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return iconMap[icon] || '๐';
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Format color name for display
|
|
218
|
+
*/
|
|
219
|
+
formatColorName(color) {
|
|
220
|
+
if (!color) return 'Blue';
|
|
221
|
+
|
|
222
|
+
// If it's a hex color, return as-is
|
|
223
|
+
if (color.startsWith('#')) {
|
|
224
|
+
return color;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Convert snake_case to Title Case
|
|
228
|
+
return color
|
|
229
|
+
.split('_')
|
|
230
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
231
|
+
.join(' ');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Handle errors with helpful messages
|
|
236
|
+
*/
|
|
237
|
+
handleError(error) {
|
|
238
|
+
logger.error(`Failed to register project: ${error.message}`);
|
|
239
|
+
|
|
240
|
+
// Provide helpful guidance based on error type
|
|
241
|
+
if (error.message.includes('run "ralphblaster init"')) {
|
|
242
|
+
console.error('');
|
|
243
|
+
console.error('Please initialize RalphBlaster first:');
|
|
244
|
+
console.error(' ralphblaster init --token=your_token_here');
|
|
245
|
+
console.error('');
|
|
246
|
+
} else if (error.message.includes('Could not connect')) {
|
|
247
|
+
console.error('');
|
|
248
|
+
console.error('Please check:');
|
|
249
|
+
console.error(' 1. Your internet connection');
|
|
250
|
+
console.error(' 2. RalphBlaster API URL is correct');
|
|
251
|
+
console.error(' 3. No firewall is blocking the connection');
|
|
252
|
+
console.error('');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
module.exports = AddProjectCommand;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const ConfigFileManager = require('../config-file-manager');
|
|
2
|
+
const logger = require('../logger');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Init Command
|
|
6
|
+
* Saves RalphBlaster credentials to ~/.ralphblasterrc
|
|
7
|
+
*/
|
|
8
|
+
class InitCommand {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.configFileManager = new ConfigFileManager();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Run the init command
|
|
15
|
+
*/
|
|
16
|
+
async run() {
|
|
17
|
+
try {
|
|
18
|
+
logger.info('Initializing RalphBlaster credentials...');
|
|
19
|
+
|
|
20
|
+
// Get token from environment variable
|
|
21
|
+
const token = process.env.RALPHBLASTER_API_TOKEN;
|
|
22
|
+
if (!token) {
|
|
23
|
+
throw new Error('No API token provided. Please set RALPHBLASTER_API_TOKEN or pass --token=...');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Get API URL from environment or use default
|
|
27
|
+
const apiUrl = process.env.RALPHBLASTER_API_URL || 'https://hq.ralphblaster.com';
|
|
28
|
+
|
|
29
|
+
// Save credentials to ~/.ralphblasterrc
|
|
30
|
+
this.configFileManager.update({
|
|
31
|
+
apiToken: token,
|
|
32
|
+
apiUrl: apiUrl
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Display success message
|
|
36
|
+
this.displaySuccess(apiUrl);
|
|
37
|
+
|
|
38
|
+
process.exit(0);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
this.handleError(error);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Display success message
|
|
47
|
+
*/
|
|
48
|
+
displaySuccess(apiUrl) {
|
|
49
|
+
logger.info('Credentials saved successfully!');
|
|
50
|
+
logger.info(`API URL: ${apiUrl}`);
|
|
51
|
+
logger.info('Config saved to ~/.ralphblasterrc');
|
|
52
|
+
console.log('');
|
|
53
|
+
console.log('Next steps:');
|
|
54
|
+
console.log(' 1. cd into your project directory');
|
|
55
|
+
console.log(' 2. Run: ralphblaster add-project');
|
|
56
|
+
console.log(' 3. Then start the agent: ralphblaster');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Handle errors with helpful messages
|
|
61
|
+
*/
|
|
62
|
+
handleError(error) {
|
|
63
|
+
logger.error(`Failed to save credentials: ${error.message}`);
|
|
64
|
+
|
|
65
|
+
// Provide helpful guidance
|
|
66
|
+
if (error.message.includes('API token')) {
|
|
67
|
+
console.error('');
|
|
68
|
+
console.error('Please provide your API token:');
|
|
69
|
+
console.error(' ralphblaster init --token=your_token_here');
|
|
70
|
+
console.error('');
|
|
71
|
+
console.error('Or set environment variable:');
|
|
72
|
+
console.error(' export RALPHBLASTER_API_TOKEN="your_token_here"');
|
|
73
|
+
console.error(' ralphblaster init');
|
|
74
|
+
console.error('');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = InitCommand;
|