ralph-cli-sandboxed 0.4.0 → 0.4.2
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 +30 -0
- package/dist/commands/action.js +47 -20
- package/dist/commands/chat.d.ts +1 -1
- package/dist/commands/chat.js +325 -62
- package/dist/commands/config.js +2 -1
- package/dist/commands/daemon.d.ts +2 -5
- package/dist/commands/daemon.js +118 -49
- package/dist/commands/docker.js +110 -73
- package/dist/commands/fix-config.js +2 -1
- package/dist/commands/fix-prd.js +2 -2
- package/dist/commands/help.js +19 -3
- package/dist/commands/init.js +78 -17
- package/dist/commands/listen.js +116 -5
- package/dist/commands/logo.d.ts +5 -0
- package/dist/commands/logo.js +41 -0
- package/dist/commands/notify.js +1 -1
- package/dist/commands/once.js +19 -9
- package/dist/commands/prd.js +20 -2
- package/dist/commands/run.js +111 -27
- package/dist/commands/slack.d.ts +10 -0
- package/dist/commands/slack.js +333 -0
- package/dist/config/responder-presets.json +69 -0
- package/dist/index.js +6 -1
- package/dist/providers/discord.d.ts +82 -0
- package/dist/providers/discord.js +697 -0
- package/dist/providers/slack.d.ts +79 -0
- package/dist/providers/slack.js +715 -0
- package/dist/providers/telegram.d.ts +30 -0
- package/dist/providers/telegram.js +190 -7
- package/dist/responders/claude-code-responder.d.ts +48 -0
- package/dist/responders/claude-code-responder.js +203 -0
- package/dist/responders/cli-responder.d.ts +62 -0
- package/dist/responders/cli-responder.js +298 -0
- package/dist/responders/llm-responder.d.ts +135 -0
- package/dist/responders/llm-responder.js +582 -0
- package/dist/templates/macos-scripts.js +2 -4
- package/dist/templates/prompts.js +4 -2
- package/dist/tui/ConfigEditor.js +42 -5
- package/dist/tui/components/ArrayEditor.js +1 -1
- package/dist/tui/components/EditorPanel.js +10 -6
- package/dist/tui/components/HelpPanel.d.ts +1 -1
- package/dist/tui/components/HelpPanel.js +1 -1
- package/dist/tui/components/JsonSnippetEditor.js +8 -5
- package/dist/tui/components/KeyValueEditor.js +69 -5
- package/dist/tui/components/LLMProvidersEditor.d.ts +22 -0
- package/dist/tui/components/LLMProvidersEditor.js +357 -0
- package/dist/tui/components/ObjectEditor.js +1 -1
- package/dist/tui/components/Preview.js +1 -1
- package/dist/tui/components/RespondersEditor.d.ts +22 -0
- package/dist/tui/components/RespondersEditor.js +437 -0
- package/dist/tui/components/SectionNav.js +27 -3
- package/dist/tui/utils/presets.js +15 -2
- package/dist/utils/chat-client.d.ts +33 -4
- package/dist/utils/chat-client.js +20 -1
- package/dist/utils/config.d.ts +100 -1
- package/dist/utils/config.js +78 -1
- package/dist/utils/daemon-actions.d.ts +19 -0
- package/dist/utils/daemon-actions.js +111 -0
- package/dist/utils/daemon-client.d.ts +21 -0
- package/dist/utils/daemon-client.js +28 -1
- package/dist/utils/llm-client.d.ts +82 -0
- package/dist/utils/llm-client.js +185 -0
- package/dist/utils/message-queue.js +6 -6
- package/dist/utils/notification.d.ts +10 -2
- package/dist/utils/notification.js +111 -4
- package/dist/utils/prd-validator.js +60 -19
- package/dist/utils/prompt.js +22 -12
- package/dist/utils/responder-logger.d.ts +47 -0
- package/dist/utils/responder-logger.js +129 -0
- package/dist/utils/responder-presets.d.ts +92 -0
- package/dist/utils/responder-presets.js +156 -0
- package/dist/utils/responder.d.ts +88 -0
- package/dist/utils/responder.js +207 -0
- package/dist/utils/stream-json.js +6 -6
- package/docs/CHAT-CLIENTS.md +520 -0
- package/docs/CHAT-RESPONDERS.md +785 -0
- package/docs/DEVELOPMENT.md +25 -0
- package/docs/USEFUL_ACTIONS.md +815 -0
- package/docs/chat-architecture.md +251 -0
- package/package.json +14 -1
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
# Useful Ralph Actions
|
|
2
|
+
|
|
3
|
+
This document lists useful actions that can be executed via `ralph action <name>` and their configuration for `.ralph/config.json`.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Actions are predefined commands configured in `.ralph/config.json` that can be triggered from inside a Docker container to execute operations on the host machine. This is particularly useful for:
|
|
8
|
+
|
|
9
|
+
- Running host-only tools (Xcode, native compilers)
|
|
10
|
+
- Sending notifications
|
|
11
|
+
- Triggering deployments
|
|
12
|
+
- Logging and monitoring
|
|
13
|
+
- Integrating with external services
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
ralph action <name> [args...] # Execute an action
|
|
19
|
+
ralph action --list # List available actions
|
|
20
|
+
ralph action --help # Show help
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Built-in Actions
|
|
26
|
+
|
|
27
|
+
These actions are available by default without configuration:
|
|
28
|
+
|
|
29
|
+
| Action | Description | Requires Daemon | Availability |
|
|
30
|
+
|--------|-------------|-----------------|--------------|
|
|
31
|
+
| `ping` | Health check - responds with 'pong' | Yes | Always |
|
|
32
|
+
| `notify` | Send notification via configured provider | Yes | When `notifications.provider` is set |
|
|
33
|
+
| `telegram_notify` | Send notification via Telegram | Yes | When Telegram chat is configured |
|
|
34
|
+
| `slack_notify` | Send notification via Slack | Yes | When Slack chat is configured |
|
|
35
|
+
| `discord_notify` | Send notification via Discord | Yes | When Discord chat is configured |
|
|
36
|
+
| `chat_status` | Get PRD status as JSON | Yes | Always |
|
|
37
|
+
| `chat_add` | Add new task to PRD | Yes | Always |
|
|
38
|
+
|
|
39
|
+
> **Important**: All built-in actions require the daemon to be running (`ralph daemon start`). They use a message queue to communicate between the container and the host.
|
|
40
|
+
|
|
41
|
+
### Conditional Built-in Actions
|
|
42
|
+
|
|
43
|
+
Some built-in actions only appear when their corresponding provider is configured:
|
|
44
|
+
|
|
45
|
+
- **`notify`**: Requires `notifications.provider` to be set to `"ntfy"` or `"command"`
|
|
46
|
+
- **`telegram_notify`**: Requires `chat.telegram.botToken` to be set
|
|
47
|
+
- **`slack_notify`**: Requires `chat.slack.botToken`, `chat.slack.appToken`, and `chat.slack.signingSecret` to be set
|
|
48
|
+
- **`discord_notify`**: Requires `chat.discord.botToken` to be set
|
|
49
|
+
|
|
50
|
+
### Custom Actions vs Built-in Actions
|
|
51
|
+
|
|
52
|
+
When running `ralph action`:
|
|
53
|
+
|
|
54
|
+
- **Inside a container**: All actions (built-in and custom) are sent to the daemon via the message queue
|
|
55
|
+
- **Outside a container**:
|
|
56
|
+
- Built-in actions still use the message queue (daemon required)
|
|
57
|
+
- Custom actions execute directly on the host (no daemon required)
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Useful Custom Actions
|
|
62
|
+
|
|
63
|
+
### 1. Build & Test Actions
|
|
64
|
+
|
|
65
|
+
#### Run Build Script
|
|
66
|
+
Execute a custom build script on the host.
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"daemon": {
|
|
71
|
+
"actions": {
|
|
72
|
+
"build": {
|
|
73
|
+
"command": "./scripts/build.sh",
|
|
74
|
+
"description": "Build the project"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Run Tests with Coverage
|
|
82
|
+
Run tests and generate coverage reports.
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"daemon": {
|
|
87
|
+
"actions": {
|
|
88
|
+
"test_coverage": {
|
|
89
|
+
"command": "npm test -- --coverage",
|
|
90
|
+
"description": "Run tests with coverage report"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Type Check
|
|
98
|
+
Run TypeScript type checking.
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"daemon": {
|
|
103
|
+
"actions": {
|
|
104
|
+
"typecheck": {
|
|
105
|
+
"command": "npm run typecheck",
|
|
106
|
+
"description": "Run TypeScript type checker"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### Lint and Fix
|
|
114
|
+
Run linter with auto-fix.
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"daemon": {
|
|
119
|
+
"actions": {
|
|
120
|
+
"lint_fix": {
|
|
121
|
+
"command": "npm run lint -- --fix",
|
|
122
|
+
"description": "Run linter with auto-fix"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### 2. macOS/Swift Development
|
|
132
|
+
|
|
133
|
+
#### Generate Xcode Project
|
|
134
|
+
Generate Xcode project from Swift package.
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"daemon": {
|
|
139
|
+
"actions": {
|
|
140
|
+
"gen_xcode": {
|
|
141
|
+
"command": "./scripts/gen_xcode.sh",
|
|
142
|
+
"description": "Generate Xcode project from Swift package"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### Xcode Build
|
|
150
|
+
Build project using xcodebuild.
|
|
151
|
+
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"daemon": {
|
|
155
|
+
"actions": {
|
|
156
|
+
"xcode_build": {
|
|
157
|
+
"command": "xcodebuild -project MyApp.xcodeproj -scheme MyApp -configuration Debug build",
|
|
158
|
+
"description": "Build in Debug mode via Xcode"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### Xcode Test
|
|
166
|
+
Run tests via xcodebuild.
|
|
167
|
+
|
|
168
|
+
```json
|
|
169
|
+
{
|
|
170
|
+
"daemon": {
|
|
171
|
+
"actions": {
|
|
172
|
+
"xcode_test": {
|
|
173
|
+
"command": "xcodebuild -project MyApp.xcodeproj -scheme MyApp test",
|
|
174
|
+
"description": "Run tests via xcodebuild"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
#### Open in Xcode
|
|
182
|
+
Open project in Xcode.
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"daemon": {
|
|
187
|
+
"actions": {
|
|
188
|
+
"open_xcode": {
|
|
189
|
+
"command": "open *.xcodeproj",
|
|
190
|
+
"description": "Open project in Xcode"
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
### 3. Deployment Actions
|
|
200
|
+
|
|
201
|
+
#### Deploy to Staging
|
|
202
|
+
Deploy application to staging environment.
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"daemon": {
|
|
207
|
+
"actions": {
|
|
208
|
+
"deploy_staging": {
|
|
209
|
+
"command": "./scripts/deploy.sh --env staging",
|
|
210
|
+
"description": "Deploy to staging environment"
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### Deploy to Production
|
|
218
|
+
Deploy application to production (with confirmation).
|
|
219
|
+
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"daemon": {
|
|
223
|
+
"actions": {
|
|
224
|
+
"deploy_prod": {
|
|
225
|
+
"command": "./scripts/deploy.sh --env production --confirm",
|
|
226
|
+
"description": "Deploy to production environment"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### Fastlane Beta (iOS)
|
|
234
|
+
Deploy to TestFlight.
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"daemon": {
|
|
239
|
+
"actions": {
|
|
240
|
+
"fastlane_beta": {
|
|
241
|
+
"command": "cd scripts/fastlane && fastlane beta",
|
|
242
|
+
"description": "Deploy to TestFlight via Fastlane"
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### Fastlane Release (iOS)
|
|
250
|
+
Deploy to App Store.
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
{
|
|
254
|
+
"daemon": {
|
|
255
|
+
"actions": {
|
|
256
|
+
"fastlane_release": {
|
|
257
|
+
"command": "cd scripts/fastlane && fastlane release",
|
|
258
|
+
"description": "Deploy to App Store via Fastlane"
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
#### Docker Build and Push
|
|
266
|
+
Build and push Docker image.
|
|
267
|
+
|
|
268
|
+
```json
|
|
269
|
+
{
|
|
270
|
+
"daemon": {
|
|
271
|
+
"actions": {
|
|
272
|
+
"docker_push": {
|
|
273
|
+
"command": "docker build -t myapp:latest . && docker push myapp:latest",
|
|
274
|
+
"description": "Build and push Docker image"
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
### 4. Logging & Monitoring
|
|
284
|
+
|
|
285
|
+
#### Log Task Completion
|
|
286
|
+
Log completed tasks to a file.
|
|
287
|
+
|
|
288
|
+
```json
|
|
289
|
+
{
|
|
290
|
+
"daemon": {
|
|
291
|
+
"actions": {
|
|
292
|
+
"log_task": {
|
|
293
|
+
"command": "echo \"$(date '+%Y-%m-%d %H:%M:%S') - Task completed:\" >> log.txt && echo",
|
|
294
|
+
"description": "Log task completion to file"
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
#### Log Ralph Complete
|
|
302
|
+
Log when all PRD tasks are complete.
|
|
303
|
+
|
|
304
|
+
```json
|
|
305
|
+
{
|
|
306
|
+
"daemon": {
|
|
307
|
+
"actions": {
|
|
308
|
+
"log_complete": {
|
|
309
|
+
"command": "echo \"$(date '+%Y-%m-%d %H:%M:%S') - Ralph finished: All PRD tasks complete\" >> log.txt",
|
|
310
|
+
"description": "Log ralph completion to file"
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
#### Log with JSON Format
|
|
318
|
+
Log events in JSON format for parsing.
|
|
319
|
+
|
|
320
|
+
```json
|
|
321
|
+
{
|
|
322
|
+
"daemon": {
|
|
323
|
+
"actions": {
|
|
324
|
+
"log_json": {
|
|
325
|
+
"command": "echo '{\"timestamp\":\"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'\",\"event\":\"task_complete\",\"message\":\"'$RALPH_MESSAGE'\"}' >> events.jsonl",
|
|
326
|
+
"description": "Log events in JSON Lines format"
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
### 5. Git & Version Control
|
|
336
|
+
|
|
337
|
+
#### Git Status
|
|
338
|
+
Show git status.
|
|
339
|
+
|
|
340
|
+
```json
|
|
341
|
+
{
|
|
342
|
+
"daemon": {
|
|
343
|
+
"actions": {
|
|
344
|
+
"git_status": {
|
|
345
|
+
"command": "git status",
|
|
346
|
+
"description": "Show git repository status"
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
#### Git Diff
|
|
354
|
+
Show uncommitted changes.
|
|
355
|
+
|
|
356
|
+
```json
|
|
357
|
+
{
|
|
358
|
+
"daemon": {
|
|
359
|
+
"actions": {
|
|
360
|
+
"git_diff": {
|
|
361
|
+
"command": "git diff",
|
|
362
|
+
"description": "Show uncommitted changes"
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
#### Create Git Tag
|
|
370
|
+
Create a version tag.
|
|
371
|
+
|
|
372
|
+
```json
|
|
373
|
+
{
|
|
374
|
+
"daemon": {
|
|
375
|
+
"actions": {
|
|
376
|
+
"git_tag": {
|
|
377
|
+
"command": "git tag -a v$(date +%Y%m%d.%H%M%S) -m 'Auto-tagged by Ralph'",
|
|
378
|
+
"description": "Create timestamped git tag"
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
#### Push to Remote
|
|
386
|
+
Push changes to remote repository.
|
|
387
|
+
|
|
388
|
+
```json
|
|
389
|
+
{
|
|
390
|
+
"daemon": {
|
|
391
|
+
"actions": {
|
|
392
|
+
"git_push": {
|
|
393
|
+
"command": "git push origin HEAD",
|
|
394
|
+
"description": "Push current branch to origin"
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
### 6. Notification Actions
|
|
404
|
+
|
|
405
|
+
#### Desktop Notification (macOS)
|
|
406
|
+
Send macOS desktop notification.
|
|
407
|
+
|
|
408
|
+
```json
|
|
409
|
+
{
|
|
410
|
+
"daemon": {
|
|
411
|
+
"actions": {
|
|
412
|
+
"notify_macos": {
|
|
413
|
+
"command": "osascript -e 'display notification \"$RALPH_MESSAGE\" with title \"Ralph\"'",
|
|
414
|
+
"description": "Send macOS desktop notification"
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
#### Slack Notification
|
|
422
|
+
Send notification to Slack webhook.
|
|
423
|
+
|
|
424
|
+
```json
|
|
425
|
+
{
|
|
426
|
+
"daemon": {
|
|
427
|
+
"actions": {
|
|
428
|
+
"notify_slack": {
|
|
429
|
+
"command": "curl -X POST -H 'Content-type: application/json' --data '{\"text\":\"Ralph: Task completed\"}' $SLACK_WEBHOOK_URL",
|
|
430
|
+
"description": "Send Slack notification"
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
#### Discord Notification
|
|
438
|
+
Send notification to Discord webhook.
|
|
439
|
+
|
|
440
|
+
```json
|
|
441
|
+
{
|
|
442
|
+
"daemon": {
|
|
443
|
+
"actions": {
|
|
444
|
+
"notify_discord": {
|
|
445
|
+
"command": "curl -X POST -H 'Content-type: application/json' --data '{\"content\":\"Ralph: Task completed\"}' $DISCORD_WEBHOOK_URL",
|
|
446
|
+
"description": "Send Discord notification"
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
#### Play Sound (macOS)
|
|
454
|
+
Play a sound when task completes.
|
|
455
|
+
|
|
456
|
+
```json
|
|
457
|
+
{
|
|
458
|
+
"daemon": {
|
|
459
|
+
"actions": {
|
|
460
|
+
"play_sound": {
|
|
461
|
+
"command": "afplay /System/Library/Sounds/Glass.aiff",
|
|
462
|
+
"description": "Play completion sound"
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
### 7. Database Actions
|
|
472
|
+
|
|
473
|
+
#### Run Database Migrations
|
|
474
|
+
Run database migrations.
|
|
475
|
+
|
|
476
|
+
```json
|
|
477
|
+
{
|
|
478
|
+
"daemon": {
|
|
479
|
+
"actions": {
|
|
480
|
+
"db_migrate": {
|
|
481
|
+
"command": "npm run db:migrate",
|
|
482
|
+
"description": "Run database migrations"
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
#### Database Backup
|
|
490
|
+
Create database backup.
|
|
491
|
+
|
|
492
|
+
```json
|
|
493
|
+
{
|
|
494
|
+
"daemon": {
|
|
495
|
+
"actions": {
|
|
496
|
+
"db_backup": {
|
|
497
|
+
"command": "pg_dump -U $DB_USER $DB_NAME > backups/backup_$(date +%Y%m%d_%H%M%S).sql",
|
|
498
|
+
"description": "Create database backup"
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
#### Seed Database
|
|
506
|
+
Seed database with test data.
|
|
507
|
+
|
|
508
|
+
```json
|
|
509
|
+
{
|
|
510
|
+
"daemon": {
|
|
511
|
+
"actions": {
|
|
512
|
+
"db_seed": {
|
|
513
|
+
"command": "npm run db:seed",
|
|
514
|
+
"description": "Seed database with test data"
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
---
|
|
522
|
+
|
|
523
|
+
### 8. Environment & Utilities
|
|
524
|
+
|
|
525
|
+
#### Open Browser
|
|
526
|
+
Open URL in default browser.
|
|
527
|
+
|
|
528
|
+
```json
|
|
529
|
+
{
|
|
530
|
+
"daemon": {
|
|
531
|
+
"actions": {
|
|
532
|
+
"open_browser": {
|
|
533
|
+
"command": "open http://localhost:3000",
|
|
534
|
+
"description": "Open app in browser"
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
#### Clear Cache
|
|
542
|
+
Clear application cache.
|
|
543
|
+
|
|
544
|
+
```json
|
|
545
|
+
{
|
|
546
|
+
"daemon": {
|
|
547
|
+
"actions": {
|
|
548
|
+
"clear_cache": {
|
|
549
|
+
"command": "rm -rf .cache node_modules/.cache",
|
|
550
|
+
"description": "Clear application cache"
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
#### Kill Port
|
|
558
|
+
Kill process on a specific port.
|
|
559
|
+
|
|
560
|
+
```json
|
|
561
|
+
{
|
|
562
|
+
"daemon": {
|
|
563
|
+
"actions": {
|
|
564
|
+
"kill_port_3000": {
|
|
565
|
+
"command": "lsof -ti:3000 | xargs kill -9 2>/dev/null || true",
|
|
566
|
+
"description": "Kill process on port 3000"
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
#### Check System Resources
|
|
574
|
+
Display system resource usage.
|
|
575
|
+
|
|
576
|
+
```json
|
|
577
|
+
{
|
|
578
|
+
"daemon": {
|
|
579
|
+
"actions": {
|
|
580
|
+
"system_check": {
|
|
581
|
+
"command": "echo '=== Disk ===' && df -h . && echo '=== Memory ===' && free -h 2>/dev/null || vm_stat",
|
|
582
|
+
"description": "Check disk and memory usage"
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
---
|
|
590
|
+
|
|
591
|
+
## Event Configuration
|
|
592
|
+
|
|
593
|
+
Actions can be automatically triggered by Ralph events. Add an `events` section to your daemon config:
|
|
594
|
+
|
|
595
|
+
```json
|
|
596
|
+
{
|
|
597
|
+
"daemon": {
|
|
598
|
+
"actions": {
|
|
599
|
+
"log_task": {
|
|
600
|
+
"command": "echo \"$(date '+%Y-%m-%d %H:%M:%S') - Task: $RALPH_MESSAGE\" >> log.txt",
|
|
601
|
+
"description": "Log task completion"
|
|
602
|
+
},
|
|
603
|
+
"log_complete": {
|
|
604
|
+
"command": "echo \"$(date '+%Y-%m-%d %H:%M:%S') - All tasks complete\" >> log.txt",
|
|
605
|
+
"description": "Log ralph completion"
|
|
606
|
+
},
|
|
607
|
+
"play_sound": {
|
|
608
|
+
"command": "afplay /System/Library/Sounds/Glass.aiff",
|
|
609
|
+
"description": "Play completion sound"
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
"events": {
|
|
613
|
+
"task_complete": [
|
|
614
|
+
{
|
|
615
|
+
"action": "log_task",
|
|
616
|
+
"message": "{{task}}"
|
|
617
|
+
}
|
|
618
|
+
],
|
|
619
|
+
"ralph_complete": [
|
|
620
|
+
{
|
|
621
|
+
"action": "log_complete"
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
"action": "notify",
|
|
625
|
+
"message": "All tasks done!"
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
"action": "play_sound"
|
|
629
|
+
}
|
|
630
|
+
],
|
|
631
|
+
"error": [
|
|
632
|
+
{
|
|
633
|
+
"action": "notify",
|
|
634
|
+
"message": "Error occurred: {{error}}"
|
|
635
|
+
}
|
|
636
|
+
]
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
### Available Events
|
|
643
|
+
|
|
644
|
+
| Event | Description | Placeholders |
|
|
645
|
+
|-------|-------------|--------------|
|
|
646
|
+
| `task_complete` | After each task is marked as passing | `{{task}}` |
|
|
647
|
+
| `ralph_complete` | When all PRD tasks are complete | - |
|
|
648
|
+
| `iteration_complete` | After each `ralph once` iteration | - |
|
|
649
|
+
| `error` | When an error occurs | `{{error}}` |
|
|
650
|
+
|
|
651
|
+
---
|
|
652
|
+
|
|
653
|
+
## Complete Example Configuration
|
|
654
|
+
|
|
655
|
+
Here's a comprehensive config with multiple useful actions:
|
|
656
|
+
|
|
657
|
+
```json
|
|
658
|
+
{
|
|
659
|
+
"daemon": {
|
|
660
|
+
"actions": {
|
|
661
|
+
"build": {
|
|
662
|
+
"command": "npm run build",
|
|
663
|
+
"description": "Build the project"
|
|
664
|
+
},
|
|
665
|
+
"test": {
|
|
666
|
+
"command": "npm test",
|
|
667
|
+
"description": "Run tests"
|
|
668
|
+
},
|
|
669
|
+
"lint": {
|
|
670
|
+
"command": "npm run lint -- --fix",
|
|
671
|
+
"description": "Run linter with auto-fix"
|
|
672
|
+
},
|
|
673
|
+
"deploy_staging": {
|
|
674
|
+
"command": "./scripts/deploy.sh --env staging",
|
|
675
|
+
"description": "Deploy to staging"
|
|
676
|
+
},
|
|
677
|
+
"log_task": {
|
|
678
|
+
"command": "echo \"$(date '+%Y-%m-%d %H:%M:%S') - $RALPH_MESSAGE\" >> ralph.log",
|
|
679
|
+
"description": "Log task to file"
|
|
680
|
+
},
|
|
681
|
+
"notify_desktop": {
|
|
682
|
+
"command": "osascript -e 'display notification \"$RALPH_MESSAGE\" with title \"Ralph\"'",
|
|
683
|
+
"description": "Send desktop notification"
|
|
684
|
+
},
|
|
685
|
+
"open_browser": {
|
|
686
|
+
"command": "open http://localhost:3000",
|
|
687
|
+
"description": "Open app in browser"
|
|
688
|
+
},
|
|
689
|
+
"git_status": {
|
|
690
|
+
"command": "git status --short",
|
|
691
|
+
"description": "Show git status"
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
"events": {
|
|
695
|
+
"task_complete": [
|
|
696
|
+
{
|
|
697
|
+
"action": "log_task",
|
|
698
|
+
"message": "Completed: {{task}}"
|
|
699
|
+
}
|
|
700
|
+
],
|
|
701
|
+
"ralph_complete": [
|
|
702
|
+
{
|
|
703
|
+
"action": "notify",
|
|
704
|
+
"message": "All tasks complete!"
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
"action": "deploy_staging"
|
|
708
|
+
}
|
|
709
|
+
]
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
---
|
|
716
|
+
|
|
717
|
+
## Tips
|
|
718
|
+
|
|
719
|
+
1. **Use `$RALPH_MESSAGE`**: Actions receive arguments via the `RALPH_MESSAGE` environment variable.
|
|
720
|
+
|
|
721
|
+
2. **Chain commands**: Use `&&` to run multiple commands in sequence:
|
|
722
|
+
```json
|
|
723
|
+
"command": "npm run build && npm run test"
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
3. **Silent failures**: Use `|| true` to prevent action failures from stopping the workflow:
|
|
727
|
+
```json
|
|
728
|
+
"command": "some-command || true"
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
4. **Background processes**: Use `&` to run commands in the background:
|
|
732
|
+
```json
|
|
733
|
+
"command": "npm run dev &"
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
5. **Working directory**: Commands run from the project root directory on the host.
|
|
737
|
+
|
|
738
|
+
6. **Environment variables**: Host environment variables are available to actions.
|
|
739
|
+
|
|
740
|
+
---
|
|
741
|
+
|
|
742
|
+
## Troubleshooting
|
|
743
|
+
|
|
744
|
+
### Action Fails with "No response from daemon (timeout)"
|
|
745
|
+
|
|
746
|
+
The daemon is not running or not responding. Start it with:
|
|
747
|
+
|
|
748
|
+
```bash
|
|
749
|
+
ralph daemon start
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
Make sure to run the daemon on the **host machine**, not inside a container.
|
|
753
|
+
|
|
754
|
+
### Built-in Action Shows "Unknown action"
|
|
755
|
+
|
|
756
|
+
This happens when:
|
|
757
|
+
|
|
758
|
+
1. **The action's provider isn't configured**: For example, `telegram_notify` won't appear if Telegram isn't configured in `config.json`
|
|
759
|
+
2. **Using an outdated config**: Re-run `ralph init` or manually add the required configuration
|
|
760
|
+
|
|
761
|
+
Check available actions with:
|
|
762
|
+
|
|
763
|
+
```bash
|
|
764
|
+
ralph action --list
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
### Action Works on Host but Not in Container
|
|
768
|
+
|
|
769
|
+
Verify that:
|
|
770
|
+
|
|
771
|
+
1. The `.ralph` directory is mounted in the container (automatic with `ralph docker run`)
|
|
772
|
+
2. The daemon is running on the host
|
|
773
|
+
3. The messages file exists: `.ralph/messages.json`
|
|
774
|
+
|
|
775
|
+
### Custom Action Not Executing
|
|
776
|
+
|
|
777
|
+
1. Check that the action is defined in `daemon.actions` in `.ralph/config.json`
|
|
778
|
+
2. Verify the command path is correct and executable
|
|
779
|
+
3. Test the command manually on the host first
|
|
780
|
+
|
|
781
|
+
### Notifications Not Being Sent
|
|
782
|
+
|
|
783
|
+
For ntfy:
|
|
784
|
+
- Verify `notifications.provider` is set to `"ntfy"`
|
|
785
|
+
- Check that `notifications.ntfy.topic` is set
|
|
786
|
+
- Test manually: `curl -d "test" https://ntfy.sh/your-topic`
|
|
787
|
+
|
|
788
|
+
For Telegram:
|
|
789
|
+
- Verify `chat.telegram.botToken` is set
|
|
790
|
+
- Verify `chat.telegram.allowedChatIds` contains your chat ID
|
|
791
|
+
- Check the daemon logs for errors
|
|
792
|
+
|
|
793
|
+
### Actions Timing Out
|
|
794
|
+
|
|
795
|
+
Actions have a 60-second timeout by default. For long-running actions:
|
|
796
|
+
|
|
797
|
+
1. Consider running them in the background: `"command": "long-task.sh &"`
|
|
798
|
+
2. Or increase the timeout in the command itself
|
|
799
|
+
3. For very long tasks, trigger them asynchronously and poll for completion
|
|
800
|
+
|
|
801
|
+
### Debug Mode
|
|
802
|
+
|
|
803
|
+
Run actions with debug output:
|
|
804
|
+
|
|
805
|
+
```bash
|
|
806
|
+
ralph action --debug <name>
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
Or start the daemon in debug mode:
|
|
810
|
+
|
|
811
|
+
```bash
|
|
812
|
+
ralph daemon start --debug
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
This shows detailed message queue activity and can help identify where issues occur.
|