ralph-cli-sandboxed 0.2.9 → 0.3.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 CHANGED
@@ -45,6 +45,8 @@ ralph docker run
45
45
  | `ralph fix-prd [opts]` | Validate and recover corrupted PRD file |
46
46
  | `ralph prompt [opts]` | Display resolved prompt |
47
47
  | `ralph docker <sub>` | Manage Docker sandbox environment |
48
+ | `ralph daemon <sub>` | Manage host daemon for sandbox notifications |
49
+ | `ralph notify [msg]` | Send notification (from sandbox to host) |
48
50
  | `ralph help` | Show help message |
49
51
 
50
52
  > **Note:** `ralph prd <subcommand>` still works for compatibility (e.g., `ralph prd add`).
@@ -85,19 +87,51 @@ After running `ralph init`, you'll have:
85
87
 
86
88
  ### Notifications
87
89
 
88
- Ralph can send notifications when events occur during automation. Configure a notification command in `.ralph/config.json`:
90
+ Ralph can send notifications when events occur during automation. Configure notifications in `.ralph/config.json`:
91
+
92
+ #### Using ntfy (Recommended)
93
+
94
+ [ntfy](https://ntfy.sh/) is a simple HTTP-based pub-sub notification service. Ralph uses curl to send notifications, so **no ntfy CLI installation is required**:
95
+
96
+ ```json
97
+ {
98
+ "notifications": {
99
+ "provider": "ntfy",
100
+ "ntfy": {
101
+ "topic": "my-ralph-notifications",
102
+ "server": "https://ntfy.sh"
103
+ }
104
+ }
105
+ }
106
+ ```
107
+
108
+ | Field | Description |
109
+ |-------|-------------|
110
+ | `provider` | Set to `"ntfy"` for ntfy notifications |
111
+ | `ntfy.topic` | Your unique topic name (required) |
112
+ | `ntfy.server` | ntfy server URL (default: `https://ntfy.sh`) |
113
+
114
+ To receive notifications:
115
+ 1. Subscribe to your topic on your phone ([ntfy app](https://ntfy.sh/)) or browser (`https://ntfy.sh/your-topic`)
116
+ 2. Run `ralph docker run` - you'll get notifications on completion
117
+
118
+ #### Using a Custom Command
119
+
120
+ For other notification tools, use the `command` provider:
89
121
 
90
122
  ```json
91
123
  {
92
- "notifyCommand": "ntfy pub mytopic"
124
+ "notifications": {
125
+ "provider": "command",
126
+ "command": "notify-send Ralph"
127
+ }
93
128
  }
94
129
  ```
95
130
 
96
- The message is appended as the last argument to your command. Supported notification tools include:
131
+ The message is appended as the last argument to your command. Supported tools include:
97
132
 
98
133
  | Tool | Example Command | Description |
99
134
  |------|----------------|-------------|
100
- | [ntfy](https://ntfy.sh/) | `ntfy pub mytopic` | Push notifications to phone/desktop |
101
135
  | notify-send (Linux) | `notify-send Ralph` | Desktop notifications on Linux |
102
136
  | terminal-notifier (macOS) | `terminal-notifier -title Ralph -message` | Desktop notifications on macOS |
103
137
  | Custom script | `/path/to/notify.sh` | Your own notification script |
@@ -113,25 +147,75 @@ Ralph sends notifications for these events:
113
147
  | Run Stopped | "Ralph: Run stopped..." | `ralph run` stops due to no progress or max failures |
114
148
  | Error | "Ralph: An error occurred." | CLI fails repeatedly |
115
149
 
116
- #### Example: ntfy Setup
150
+ #### Sandbox-to-Host Notifications (Daemon)
117
151
 
118
- [ntfy](https://ntfy.sh/) is a simple HTTP-based pub-sub notification service:
152
+ When running in a Docker sandbox, notifications are sent via the ralph daemon which runs on the host. The sandbox communicates with the daemon through a shared message file (`.ralph/messages.json`).
119
153
 
120
154
  ```bash
121
- # 1. Install ntfy CLI
122
- pip install ntfy
155
+ # Terminal 1: Start daemon on host
156
+ ralph daemon start
123
157
 
124
- # 2. Subscribe to your topic on your phone (ntfy app) or browser
125
- # Visit: https://ntfy.sh/your-unique-topic
158
+ # Terminal 2: Run container
159
+ ralph docker run
160
+
161
+ # Inside container: Send notification manually
162
+ ralph notify "Hello from sandbox!"
163
+ ```
164
+
165
+ The daemon watches for messages and executes the configured notification command on the host. This file-based approach works on all platforms (macOS, Linux, Windows) and allows other tools to integrate with the message queue.
126
166
 
127
- # 3. Configure ralph
128
- # In .ralph/config.json:
167
+ #### Custom Daemon Actions
168
+
169
+ You can define custom actions that the sandbox can trigger. This example logs task completions and ralph finished events to a file:
170
+
171
+ ```json
129
172
  {
130
- "notifyCommand": "ntfy pub your-unique-topic"
173
+ "daemon": {
174
+ "actions": {
175
+ "log_task": {
176
+ "command": "echo \"$(date '+%Y-%m-%d %H:%M:%S') - Task completed:\" >> log.txt && echo",
177
+ "description": "Log task completion to file"
178
+ },
179
+ "log_complete": {
180
+ "command": "echo \"$(date '+%Y-%m-%d %H:%M:%S') - Ralph finished: All PRD tasks complete\" >> log.txt",
181
+ "description": "Log ralph completion to file"
182
+ }
183
+ },
184
+ "events": {
185
+ "task_complete": [
186
+ {
187
+ "action": "log_task",
188
+ "message": "{{task}}"
189
+ }
190
+ ],
191
+ "ralph_complete": [
192
+ {
193
+ "action": "log_complete"
194
+ },
195
+ {
196
+ "action": "notify",
197
+ "message": "All tasks done!"
198
+ }
199
+ ]
200
+ }
201
+ }
131
202
  }
203
+ ```
132
204
 
133
- # 4. Run ralph - you'll get notifications on completion
134
- ralph docker run
205
+ | Event | When Triggered |
206
+ |-------|----------------|
207
+ | `task_complete` | After each PRD task is marked as passing |
208
+ | `ralph_complete` | When all PRD tasks are complete |
209
+ | `iteration_complete` | After each `ralph once` iteration |
210
+ | `error` | When an error occurs |
211
+
212
+ The `{{task}}` placeholder is replaced with the task description. Events can trigger multiple actions - for example, `ralph_complete` above both logs to file and sends a notification.
213
+
214
+ Example `log.txt` output:
215
+ ```
216
+ 2024-01-15 14:23:01 - Task completed: Add user authentication
217
+ 2024-01-15 14:45:32 - Task completed: Implement JWT tokens
218
+ 2024-01-15 15:02:18 - Ralph finished: All PRD tasks complete
135
219
  ```
136
220
 
137
221
  ### Supported Languages
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Chat command for managing Telegram (and other) chat integrations.
3
+ * Allows ralph to receive commands and send notifications via chat services.
4
+ */
5
+ /**
6
+ * Main chat command handler.
7
+ */
8
+ export declare function chat(args: string[]): Promise<void>;