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.
Files changed (80) hide show
  1. package/README.md +30 -0
  2. package/dist/commands/action.js +47 -20
  3. package/dist/commands/chat.d.ts +1 -1
  4. package/dist/commands/chat.js +325 -62
  5. package/dist/commands/config.js +2 -1
  6. package/dist/commands/daemon.d.ts +2 -5
  7. package/dist/commands/daemon.js +118 -49
  8. package/dist/commands/docker.js +110 -73
  9. package/dist/commands/fix-config.js +2 -1
  10. package/dist/commands/fix-prd.js +2 -2
  11. package/dist/commands/help.js +19 -3
  12. package/dist/commands/init.js +78 -17
  13. package/dist/commands/listen.js +116 -5
  14. package/dist/commands/logo.d.ts +5 -0
  15. package/dist/commands/logo.js +41 -0
  16. package/dist/commands/notify.js +1 -1
  17. package/dist/commands/once.js +19 -9
  18. package/dist/commands/prd.js +20 -2
  19. package/dist/commands/run.js +111 -27
  20. package/dist/commands/slack.d.ts +10 -0
  21. package/dist/commands/slack.js +333 -0
  22. package/dist/config/responder-presets.json +69 -0
  23. package/dist/index.js +6 -1
  24. package/dist/providers/discord.d.ts +82 -0
  25. package/dist/providers/discord.js +697 -0
  26. package/dist/providers/slack.d.ts +79 -0
  27. package/dist/providers/slack.js +715 -0
  28. package/dist/providers/telegram.d.ts +30 -0
  29. package/dist/providers/telegram.js +190 -7
  30. package/dist/responders/claude-code-responder.d.ts +48 -0
  31. package/dist/responders/claude-code-responder.js +203 -0
  32. package/dist/responders/cli-responder.d.ts +62 -0
  33. package/dist/responders/cli-responder.js +298 -0
  34. package/dist/responders/llm-responder.d.ts +135 -0
  35. package/dist/responders/llm-responder.js +582 -0
  36. package/dist/templates/macos-scripts.js +2 -4
  37. package/dist/templates/prompts.js +4 -2
  38. package/dist/tui/ConfigEditor.js +42 -5
  39. package/dist/tui/components/ArrayEditor.js +1 -1
  40. package/dist/tui/components/EditorPanel.js +10 -6
  41. package/dist/tui/components/HelpPanel.d.ts +1 -1
  42. package/dist/tui/components/HelpPanel.js +1 -1
  43. package/dist/tui/components/JsonSnippetEditor.js +8 -5
  44. package/dist/tui/components/KeyValueEditor.js +69 -5
  45. package/dist/tui/components/LLMProvidersEditor.d.ts +22 -0
  46. package/dist/tui/components/LLMProvidersEditor.js +357 -0
  47. package/dist/tui/components/ObjectEditor.js +1 -1
  48. package/dist/tui/components/Preview.js +1 -1
  49. package/dist/tui/components/RespondersEditor.d.ts +22 -0
  50. package/dist/tui/components/RespondersEditor.js +437 -0
  51. package/dist/tui/components/SectionNav.js +27 -3
  52. package/dist/tui/utils/presets.js +15 -2
  53. package/dist/utils/chat-client.d.ts +33 -4
  54. package/dist/utils/chat-client.js +20 -1
  55. package/dist/utils/config.d.ts +100 -1
  56. package/dist/utils/config.js +78 -1
  57. package/dist/utils/daemon-actions.d.ts +19 -0
  58. package/dist/utils/daemon-actions.js +111 -0
  59. package/dist/utils/daemon-client.d.ts +21 -0
  60. package/dist/utils/daemon-client.js +28 -1
  61. package/dist/utils/llm-client.d.ts +82 -0
  62. package/dist/utils/llm-client.js +185 -0
  63. package/dist/utils/message-queue.js +6 -6
  64. package/dist/utils/notification.d.ts +10 -2
  65. package/dist/utils/notification.js +111 -4
  66. package/dist/utils/prd-validator.js +60 -19
  67. package/dist/utils/prompt.js +22 -12
  68. package/dist/utils/responder-logger.d.ts +47 -0
  69. package/dist/utils/responder-logger.js +129 -0
  70. package/dist/utils/responder-presets.d.ts +92 -0
  71. package/dist/utils/responder-presets.js +156 -0
  72. package/dist/utils/responder.d.ts +88 -0
  73. package/dist/utils/responder.js +207 -0
  74. package/dist/utils/stream-json.js +6 -6
  75. package/docs/CHAT-CLIENTS.md +520 -0
  76. package/docs/CHAT-RESPONDERS.md +785 -0
  77. package/docs/DEVELOPMENT.md +25 -0
  78. package/docs/USEFUL_ACTIONS.md +815 -0
  79. package/docs/chat-architecture.md +251 -0
  80. package/package.json +14 -1
package/README.md CHANGED
@@ -505,6 +505,36 @@ Features:
505
505
 
506
506
  See [docs/DOCKER.md](docs/DOCKER.md) for detailed Docker configuration, customization, and troubleshooting.
507
507
 
508
+ ## Chat Integration
509
+
510
+ Ralph can be controlled via chat platforms (Slack, Telegram, Discord) and includes intelligent chat responders powered by LLMs.
511
+
512
+ ### Chat Commands
513
+
514
+ Control Ralph remotely via chat:
515
+ - `/ralph run` - Start ralph automation
516
+ - `/ralph status` - Check PRD status
517
+ - `/ralph stop` - Stop running automation
518
+
519
+ ### Chat Responders
520
+
521
+ Responders handle messages and can answer questions about your codebase:
522
+
523
+ | Trigger | Type | Description |
524
+ |---------|------|-------------|
525
+ | `@qa` | LLM | Answer questions about the codebase |
526
+ | `@review` | LLM | Review code changes (supports `@review diff`, `@review last`) |
527
+ | `@code` | Claude Code | Make file modifications |
528
+ | `!lint` | CLI | Run custom commands |
529
+
530
+ **Features:**
531
+ - **Automatic file detection**: Mention file paths (e.g., `src/config.ts:42`) and they're automatically included in context
532
+ - **Git diff keywords**: Use `diff`, `staged`, `last`, `HEAD~N` to include git changes
533
+ - **Multi-turn conversations**: Continue discussions in Slack/Discord threads
534
+ - **Auto-notifications**: Results from `ralph run` are automatically sent to connected chat
535
+
536
+ See [docs/CHAT-CLIENTS.md](docs/CHAT-CLIENTS.md) for chat platform setup and [docs/CHAT-RESPONDERS.md](docs/CHAT-RESPONDERS.md) for responder configuration.
537
+
508
538
  ## How It Works
509
539
 
510
540
  1. **Read PRD**: Claude reads your requirements from `prd.json`
@@ -1,7 +1,8 @@
1
1
  import { spawn } from "child_process";
2
2
  import { existsSync } from "fs";
3
3
  import { loadConfig, isRunningInContainer } from "../utils/config.js";
4
- import { getMessagesPath, sendMessage, waitForResponse, } from "../utils/message-queue.js";
4
+ import { getMessagesPath, sendMessage, waitForResponse } from "../utils/message-queue.js";
5
+ import { getDefaultActions, getBuiltInActionNames } from "../utils/daemon-actions.js";
5
6
  /**
6
7
  * Execute an action from config.json - works both inside and outside containers.
7
8
  *
@@ -46,64 +47,88 @@ export async function action(args) {
46
47
  console.error("Failed to load config. Run 'ralph init' first.");
47
48
  process.exit(1);
48
49
  }
49
- // Get available actions from daemon config
50
- const daemonActions = config.daemon?.actions || {};
51
- const actionNames = Object.keys(daemonActions);
52
- // If --list or no action specified, show available actions
53
- if (showList || !actionName) {
50
+ // Get built-in actions and configured actions
51
+ const builtInActions = getDefaultActions(config);
52
+ const builtInNames = getBuiltInActionNames(config);
53
+ const configuredActions = config.daemon?.actions || {};
54
+ // Merge: configured actions override built-in ones
55
+ const allActions = { ...builtInActions, ...configuredActions };
56
+ const actionNames = Object.keys(allActions);
57
+ // If --list, no action specified, or "help" action, show available actions
58
+ if (showList || !actionName || actionName === "help") {
54
59
  if (actionNames.length === 0) {
55
- console.log("No actions configured.");
60
+ console.log("No actions available.");
56
61
  console.log("");
57
62
  console.log("Configure actions in .ralph/config.json:");
58
- console.log(' {');
63
+ console.log(" {");
59
64
  console.log(' "daemon": {');
60
65
  console.log(' "actions": {');
61
66
  console.log(' "build": {');
62
67
  console.log(' "command": "./scripts/build.sh",');
63
68
  console.log(' "description": "Build the project"');
64
- console.log(' }');
65
- console.log(' }');
66
- console.log(' }');
67
- console.log(' }');
69
+ console.log(" }");
70
+ console.log(" }");
71
+ console.log(" }");
72
+ console.log(" }");
68
73
  }
69
74
  else {
70
75
  console.log("Available actions:");
71
76
  console.log("");
72
- for (const [name, actionConfig] of Object.entries(daemonActions)) {
73
- const desc = actionConfig.description || actionConfig.command;
74
- console.log(` ${name.padEnd(20)} ${desc}`);
77
+ // Show built-in actions first
78
+ const builtInList = actionNames.filter((name) => builtInNames.has(name) && !configuredActions[name]);
79
+ const customList = actionNames.filter((name) => !builtInNames.has(name) || configuredActions[name]);
80
+ for (const name of builtInList) {
81
+ const action = allActions[name];
82
+ const desc = action.description || action.command;
83
+ console.log(` ${name.padEnd(20)} ${desc} [built-in]`);
84
+ }
85
+ for (const name of customList) {
86
+ const action = allActions[name];
87
+ const desc = action.description || action.command;
88
+ // Mark if this is a custom override of a built-in action
89
+ const overrideMarker = builtInNames.has(name) ? " [override]" : "";
90
+ console.log(` ${name.padEnd(20)} ${desc}${overrideMarker}`);
75
91
  }
76
92
  console.log("");
77
93
  console.log("Run an action: ralph action <name> [args...]");
94
+ console.log("");
95
+ console.log("Note: Built-in actions require the daemon to be running.");
78
96
  }
79
97
  return;
80
98
  }
81
99
  // Validate action exists
82
- if (!daemonActions[actionName]) {
100
+ if (!allActions[actionName]) {
83
101
  console.error(`Unknown action: ${actionName}`);
84
102
  console.error("");
85
103
  if (actionNames.length > 0) {
86
104
  console.error(`Available actions: ${actionNames.join(", ")}`);
87
105
  }
88
106
  else {
89
- console.error("No actions configured in .ralph/config.json");
107
+ console.error("No actions available");
90
108
  }
91
109
  process.exit(1);
92
110
  }
93
- const actionConfig = daemonActions[actionName];
111
+ const actionConfig = allActions[actionName];
112
+ const isBuiltIn = builtInNames.has(actionName) && !configuredActions[actionName];
94
113
  const inContainer = isRunningInContainer();
95
114
  if (debug) {
96
115
  console.log(`[action] Name: ${actionName}`);
97
116
  console.log(`[action] Args: ${actionArgs.join(" ") || "(none)"}`);
98
117
  console.log(`[action] Command: ${actionConfig.command}`);
99
118
  console.log(`[action] In container: ${inContainer}`);
119
+ console.log(`[action] Is built-in: ${isBuiltIn}`);
100
120
  }
101
121
  if (inContainer) {
102
122
  // Inside container - use file-based message queue to execute on host
103
123
  await executeViaQueue(actionName, actionArgs, debug);
104
124
  }
125
+ else if (isBuiltIn) {
126
+ // Outside container, built-in action - also use message queue (daemon handles special actions)
127
+ // Built-in actions like telegram_notify, slack_notify use special markers that only the daemon understands
128
+ await executeViaQueue(actionName, actionArgs, debug);
129
+ }
105
130
  else {
106
- // Outside container - execute directly
131
+ // Outside container, custom action - execute directly
107
132
  await executeDirectly(actionConfig.command, actionArgs, debug);
108
133
  }
109
134
  }
@@ -162,7 +187,7 @@ async function executeDirectly(command, args, debug) {
162
187
  // Build full command with arguments
163
188
  let fullCommand = command;
164
189
  if (args.length > 0) {
165
- fullCommand = `${command} ${args.map(a => `"${a.replace(/"/g, '\\"')}"`).join(" ")}`;
190
+ fullCommand = `${command} ${args.map((a) => `"${a.replace(/"/g, '\\"')}"`).join(" ")}`;
166
191
  }
167
192
  if (debug) {
168
193
  console.log(`[action] Executing: ${fullCommand}`);
@@ -207,6 +232,7 @@ ralph action - Execute host actions from config.json
207
232
  USAGE:
208
233
  ralph action [name] [args...] Execute an action
209
234
  ralph action --list List available actions
235
+ ralph action help List available actions
210
236
  ralph action --help Show this help
211
237
 
212
238
  OPTIONS:
@@ -250,6 +276,7 @@ CONFIGURATION:
250
276
  EXAMPLES:
251
277
  # List available actions
252
278
  ralph action --list
279
+ ralph action help
253
280
  ralph action
254
281
 
255
282
  # Execute an action
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Chat command for managing Telegram (and other) chat integrations.
2
+ * Chat command for managing Telegram, Slack, and other chat integrations.
3
3
  * Allows ralph to receive commands and send notifications via chat services.
4
4
  */
5
5
  /**