@stackmemoryai/stackmemory 0.4.0 → 0.4.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/dist/cli/commands/ralph.js +122 -45
- package/dist/cli/commands/ralph.js.map +2 -2
- package/dist/features/tui/simple-monitor.js +112 -0
- package/dist/features/tui/simple-monitor.js.map +7 -0
- package/dist/features/tui/swarm-monitor.js +185 -29
- package/dist/features/tui/swarm-monitor.js.map +2 -2
- package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js +253 -24
- package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js.map +3 -3
- package/package.json +1 -1
- package/scripts/test-ralph-iteration-fix.ts +118 -0
- package/scripts/test-simple-ralph-state-sync.ts +178 -0
- package/scripts/test-tui-shortcuts.ts +66 -0
- package/scripts/validate-tui-shortcuts.ts +83 -0
|
@@ -9,8 +9,16 @@ import { ralphDebugger } from "../../integrations/ralph/visualization/ralph-debu
|
|
|
9
9
|
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
10
10
|
import { trace } from "../../core/trace/index.js";
|
|
11
11
|
function createRalphCommand() {
|
|
12
|
-
const ralph = new Command("ralph").description(
|
|
13
|
-
|
|
12
|
+
const ralph = new Command("ralph").description(
|
|
13
|
+
"Ralph Wiggum Loop integration with StackMemory"
|
|
14
|
+
);
|
|
15
|
+
ralph.command("init").description("Initialize a new Ralph Wiggum loop").argument("<task>", "Task description").option(
|
|
16
|
+
"-c, --criteria <criteria>",
|
|
17
|
+
"Completion criteria (comma separated)"
|
|
18
|
+
).option("--max-iterations <n>", "Maximum iterations", "50").option("--use-context", "Load relevant context from StackMemory").option(
|
|
19
|
+
"--learn-from-similar",
|
|
20
|
+
"Apply patterns from similar completed tasks"
|
|
21
|
+
).action(async (task, options) => {
|
|
14
22
|
return trace.command("ralph-init", { task, ...options }, async () => {
|
|
15
23
|
try {
|
|
16
24
|
console.log("\u{1F3AD} Initializing Ralph Wiggum loop...");
|
|
@@ -34,11 +42,17 @@ function createRalphCommand() {
|
|
|
34
42
|
enhancedTask = `${task}
|
|
35
43
|
|
|
36
44
|
${contextResponse.context}`;
|
|
37
|
-
console.log(
|
|
38
|
-
|
|
45
|
+
console.log(
|
|
46
|
+
`\u{1F4DA} Loaded context from ${contextResponse.sources.length} sources`
|
|
47
|
+
);
|
|
48
|
+
console.log(
|
|
49
|
+
`\u{1F3AF} Context tokens: ${contextResponse.metadata.totalTokens}`
|
|
50
|
+
);
|
|
39
51
|
}
|
|
40
52
|
} catch (error) {
|
|
41
|
-
console.log(
|
|
53
|
+
console.log(
|
|
54
|
+
`\u26A0\uFE0F Context loading failed: ${error.message}`
|
|
55
|
+
);
|
|
42
56
|
console.log("Proceeding without context...");
|
|
43
57
|
}
|
|
44
58
|
}
|
|
@@ -61,7 +75,9 @@ ${contextResponse.context}`;
|
|
|
61
75
|
return trace.command("ralph-run", options, async () => {
|
|
62
76
|
try {
|
|
63
77
|
if (!existsSync(".ralph")) {
|
|
64
|
-
console.error(
|
|
78
|
+
console.error(
|
|
79
|
+
'\u274C No Ralph loop found. Run "stackmemory ralph init" first.'
|
|
80
|
+
);
|
|
65
81
|
return;
|
|
66
82
|
}
|
|
67
83
|
console.log("\u{1F3AD} Starting Ralph Wiggum loop...");
|
|
@@ -85,13 +101,17 @@ ${contextResponse.context}`;
|
|
|
85
101
|
return;
|
|
86
102
|
}
|
|
87
103
|
const task = readFileSync(".ralph/task.md", "utf8");
|
|
88
|
-
const iteration = parseInt(
|
|
104
|
+
const iteration = parseInt(
|
|
105
|
+
readFileSync(".ralph/iteration.txt", "utf8") || "0"
|
|
106
|
+
);
|
|
89
107
|
const isComplete = existsSync(".ralph/work-complete.txt");
|
|
90
108
|
const feedback = existsSync(".ralph/feedback.txt") ? readFileSync(".ralph/feedback.txt", "utf8") : "";
|
|
91
109
|
console.log("\u{1F3AD} Ralph Loop Status:");
|
|
92
110
|
console.log(` Task: ${task.substring(0, 80)}...`);
|
|
93
111
|
console.log(` Iteration: ${iteration}`);
|
|
94
|
-
console.log(
|
|
112
|
+
console.log(
|
|
113
|
+
` Status: ${isComplete ? "\u2705 COMPLETE" : "\u{1F504} IN PROGRESS"}`
|
|
114
|
+
);
|
|
95
115
|
if (feedback) {
|
|
96
116
|
console.log(` Last feedback: ${feedback.substring(0, 100)}...`);
|
|
97
117
|
}
|
|
@@ -101,7 +121,9 @@ ${contextResponse.context}`;
|
|
|
101
121
|
progressLines.forEach((p) => {
|
|
102
122
|
const progress = p;
|
|
103
123
|
const status = progress.validation?.testsPass ? "\u2705" : "\u274C";
|
|
104
|
-
console.log(
|
|
124
|
+
console.log(
|
|
125
|
+
` ${progress.iteration}: ${status} ${progress.changes} changes, ${progress.errors} errors`
|
|
126
|
+
);
|
|
105
127
|
});
|
|
106
128
|
}
|
|
107
129
|
} catch (error) {
|
|
@@ -177,7 +199,9 @@ ${contextResponse.context}`;
|
|
|
177
199
|
console.log("\n\u{1F4C1} Ralph directory structure:");
|
|
178
200
|
const { execSync } = await import("child_process");
|
|
179
201
|
try {
|
|
180
|
-
const tree = execSync("find .ralph -type f | head -20", {
|
|
202
|
+
const tree = execSync("find .ralph -type f | head -20", {
|
|
203
|
+
encoding: "utf8"
|
|
204
|
+
});
|
|
181
205
|
console.log(tree);
|
|
182
206
|
} catch {
|
|
183
207
|
console.log(" (Unable to show directory tree)");
|
|
@@ -189,7 +213,11 @@ ${contextResponse.context}`;
|
|
|
189
213
|
}
|
|
190
214
|
});
|
|
191
215
|
});
|
|
192
|
-
ralph.command("swarm").description("Launch a swarm of specialized agents").argument("<project>", "Project description").option(
|
|
216
|
+
ralph.command("swarm").description("Launch a swarm of specialized agents").argument("<project>", "Project description").option(
|
|
217
|
+
"--agents <agents>",
|
|
218
|
+
"Comma-separated list of agent roles (architect,developer,tester,etc)",
|
|
219
|
+
"developer,tester"
|
|
220
|
+
).option("--max-agents <n>", "Maximum number of agents", "5").action(async (project, options) => {
|
|
193
221
|
return trace.command("ralph-swarm", { project, ...options }, async () => {
|
|
194
222
|
try {
|
|
195
223
|
console.log("\u{1F9BE} Launching Ralph swarm...");
|
|
@@ -200,12 +228,19 @@ ${contextResponse.context}`;
|
|
|
200
228
|
conflictResolution: "defer_to_expertise",
|
|
201
229
|
collaborationPreferences: []
|
|
202
230
|
}));
|
|
203
|
-
const swarmId = await swarmCoordinator.launchSwarm(
|
|
231
|
+
const swarmId = await swarmCoordinator.launchSwarm(
|
|
232
|
+
project,
|
|
233
|
+
agentSpecs
|
|
234
|
+
);
|
|
204
235
|
console.log(`\u2705 Swarm launched with ID: ${swarmId}`);
|
|
205
236
|
console.log(`\u{1F465} ${agentSpecs.length} agents working on: ${project}`);
|
|
206
237
|
console.log("\nNext steps:");
|
|
207
|
-
console.log(
|
|
208
|
-
|
|
238
|
+
console.log(
|
|
239
|
+
" stackmemory ralph swarm-status <swarmId> # Check progress"
|
|
240
|
+
);
|
|
241
|
+
console.log(
|
|
242
|
+
" stackmemory ralph swarm-stop <swarmId> # Stop swarm"
|
|
243
|
+
);
|
|
209
244
|
} catch (error) {
|
|
210
245
|
logger.error("Swarm launch failed", error);
|
|
211
246
|
console.error("\u274C Swarm launch failed:", error.message);
|
|
@@ -213,31 +248,45 @@ ${contextResponse.context}`;
|
|
|
213
248
|
});
|
|
214
249
|
});
|
|
215
250
|
ralph.command("orchestrate").description("Orchestrate multiple Ralph loops for complex tasks").argument("<description>", "Complex task description").option("--criteria <criteria>", "Success criteria (comma separated)").option("--max-loops <n>", "Maximum parallel loops", "3").option("--sequential", "Force sequential execution").action(async (description, options) => {
|
|
216
|
-
return trace.command(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
criteria,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
251
|
+
return trace.command(
|
|
252
|
+
"ralph-orchestrate",
|
|
253
|
+
{ description, ...options },
|
|
254
|
+
async () => {
|
|
255
|
+
try {
|
|
256
|
+
console.log("\u{1F3AD} Orchestrating complex task...");
|
|
257
|
+
await multiLoopOrchestrator.initialize();
|
|
258
|
+
const criteria = options.criteria ? options.criteria.split(",").map((c) => c.trim()) : [
|
|
259
|
+
"Task completed successfully",
|
|
260
|
+
"All components working",
|
|
261
|
+
"Tests pass"
|
|
262
|
+
];
|
|
263
|
+
const result = await multiLoopOrchestrator.orchestrateComplexTask(
|
|
264
|
+
description,
|
|
265
|
+
criteria,
|
|
266
|
+
{
|
|
267
|
+
maxLoops: parseInt(options.maxLoops),
|
|
268
|
+
forceSequential: options.sequential
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
console.log("\u2705 Orchestration completed!");
|
|
272
|
+
console.log(
|
|
273
|
+
`\u{1F4CA} Results: ${result.completedLoops.length} successful, ${result.failedLoops.length} failed`
|
|
274
|
+
);
|
|
275
|
+
console.log(
|
|
276
|
+
`\u23F1\uFE0F Total duration: ${Math.round(result.totalDuration / 1e3)}s`
|
|
277
|
+
);
|
|
278
|
+
if (result.insights.length > 0) {
|
|
279
|
+
console.log("\n\u{1F4A1} Insights:");
|
|
280
|
+
result.insights.forEach(
|
|
281
|
+
(insight) => console.log(` \u2022 ${insight}`)
|
|
282
|
+
);
|
|
227
283
|
}
|
|
228
|
-
)
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
console.log(`\u23F1\uFE0F Total duration: ${Math.round(result.totalDuration / 1e3)}s`);
|
|
232
|
-
if (result.insights.length > 0) {
|
|
233
|
-
console.log("\n\u{1F4A1} Insights:");
|
|
234
|
-
result.insights.forEach((insight) => console.log(` \u2022 ${insight}`));
|
|
284
|
+
} catch (error) {
|
|
285
|
+
logger.error("Orchestration failed", error);
|
|
286
|
+
console.error("\u274C Orchestration failed:", error.message);
|
|
235
287
|
}
|
|
236
|
-
} catch (error) {
|
|
237
|
-
logger.error("Orchestration failed", error);
|
|
238
|
-
console.error("\u274C Orchestration failed:", error.message);
|
|
239
288
|
}
|
|
240
|
-
|
|
289
|
+
);
|
|
241
290
|
});
|
|
242
291
|
ralph.command("learn").description("Learn patterns from completed loops").option("--task-type <type>", "Learn patterns for specific task type").action(async (options) => {
|
|
243
292
|
return trace.command("ralph-learn", options, async () => {
|
|
@@ -249,12 +298,17 @@ ${contextResponse.context}`;
|
|
|
249
298
|
if (patterns.length > 0) {
|
|
250
299
|
console.log("\n\u{1F4CA} Top patterns:");
|
|
251
300
|
patterns.slice(0, 5).forEach((pattern) => {
|
|
252
|
-
console.log(
|
|
301
|
+
console.log(
|
|
302
|
+
` \u2022 ${pattern.pattern} (${Math.round(pattern.confidence * 100)}% confidence)`
|
|
303
|
+
);
|
|
253
304
|
});
|
|
254
305
|
}
|
|
255
306
|
} catch (error) {
|
|
256
307
|
logger.error("Pattern learning failed", error);
|
|
257
|
-
console.error(
|
|
308
|
+
console.error(
|
|
309
|
+
"\u274C Pattern learning failed:",
|
|
310
|
+
error.message
|
|
311
|
+
);
|
|
258
312
|
}
|
|
259
313
|
});
|
|
260
314
|
});
|
|
@@ -262,13 +316,15 @@ ${contextResponse.context}`;
|
|
|
262
316
|
return trace.command("ralph-debug-enhanced", options, async () => {
|
|
263
317
|
try {
|
|
264
318
|
if (!existsSync(".ralph") && !options.loopId) {
|
|
265
|
-
console.log(
|
|
319
|
+
console.log(
|
|
320
|
+
"\u274C No Ralph loop found. Run a loop first or specify --loop-id"
|
|
321
|
+
);
|
|
266
322
|
return;
|
|
267
323
|
}
|
|
268
324
|
console.log("\u{1F50D} Starting enhanced debugging...");
|
|
269
325
|
await ralphDebugger.initialize();
|
|
270
326
|
const loopId = options.loopId || "current";
|
|
271
|
-
|
|
327
|
+
await ralphDebugger.startDebugSession(loopId, ".ralph");
|
|
272
328
|
if (options.generateReport) {
|
|
273
329
|
const report = await ralphDebugger.generateDebugReport(loopId);
|
|
274
330
|
console.log(`\u{1F4CB} Debug report generated: ${report.exportPath}`);
|
|
@@ -284,15 +340,36 @@ ${contextResponse.context}`;
|
|
|
284
340
|
}
|
|
285
341
|
});
|
|
286
342
|
});
|
|
287
|
-
ralph.command("tui").description("Launch TUI monitor for active swarms").option("--swarm-id <id>", "Monitor specific swarm ID").action(async (options) => {
|
|
343
|
+
ralph.command("tui").description("Launch TUI monitor for active swarms").option("--swarm-id <id>", "Monitor specific swarm ID").option("--simple", "Use simple text mode instead of full TUI").option("--force-tui", "Force full TUI even with compatibility issues").action(async (options) => {
|
|
288
344
|
try {
|
|
289
|
-
const
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
345
|
+
const isGhostty = process.env.TERM_PROGRAM === "ghostty" || process.env.TERM?.includes("ghostty");
|
|
346
|
+
const isBasicTerm = process.env.TERM === "dumb" || process.env.TERM === "unknown";
|
|
347
|
+
const hasCompatibilityIssues = isGhostty || isBasicTerm;
|
|
348
|
+
const useSimpleMode = options.simple || hasCompatibilityIssues && !options.forceTui;
|
|
349
|
+
if (useSimpleMode) {
|
|
350
|
+
console.log("\u{1F9BE} Starting Simple Swarm Monitor (Text Mode)");
|
|
351
|
+
if (hasCompatibilityIssues && !options.simple) {
|
|
352
|
+
console.log(
|
|
353
|
+
`\u26A0\uFE0F Detected ${isGhostty ? "Ghostty" : "basic"} terminal - using text mode for compatibility`
|
|
354
|
+
);
|
|
355
|
+
console.log(
|
|
356
|
+
" Use --force-tui to override, or --simple to explicitly use text mode"
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
const { SimpleSwarmMonitor } = await import("../../features/tui/simple-monitor.js");
|
|
360
|
+
const monitor = new SimpleSwarmMonitor();
|
|
361
|
+
monitor.start();
|
|
362
|
+
} else {
|
|
363
|
+
console.log("\u{1F9BE} Starting Full TUI Monitor");
|
|
364
|
+
const { SwarmTUI } = await import("../../features/tui/swarm-monitor.js");
|
|
365
|
+
const tui = new SwarmTUI();
|
|
366
|
+
await tui.initialize(void 0, options.swarmId);
|
|
367
|
+
tui.start();
|
|
368
|
+
}
|
|
293
369
|
} catch (error) {
|
|
294
370
|
logger.error("TUI launch failed", error);
|
|
295
371
|
console.error("\u274C TUI failed:", error.message);
|
|
372
|
+
console.log("\u{1F4A1} Try: stackmemory ralph tui --simple");
|
|
296
373
|
process.exit(1);
|
|
297
374
|
}
|
|
298
375
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/commands/ralph.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Ralph Wiggum Loop Commands\n * CLI interface for Ralph-StackMemory integration\n */\n\nimport { Command } from 'commander';\nimport { logger } from '../../core/monitoring/logger.js';\nimport { RalphLoop } from '../../../scripts/ralph-loop-implementation.js';\nimport { stackMemoryContextLoader } from '../../integrations/ralph/context/stackmemory-context-loader.js';\nimport { patternLearner } from '../../integrations/ralph/learning/pattern-learner.js';\nimport { multiLoopOrchestrator } from '../../integrations/ralph/orchestration/multi-loop-orchestrator.js';\nimport { swarmCoordinator } from '../../integrations/ralph/swarm/swarm-coordinator.js';\nimport { ralphDebugger } from '../../integrations/ralph/visualization/ralph-debugger.js';\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { trace } from '../../core/trace/index.js';\n\nexport function createRalphCommand(): Command {\n const ralph = new Command('ralph')\n .description('Ralph Wiggum Loop integration with StackMemory');\n\n // Initialize a new Ralph loop\n ralph\n .command('init')\n .description('Initialize a new Ralph Wiggum loop')\n .argument('<task>', 'Task description')\n .option('-c, --criteria <criteria>', 'Completion criteria (comma separated)')\n .option('--max-iterations <n>', 'Maximum iterations', '50')\n .option('--use-context', 'Load relevant context from StackMemory')\n .option('--learn-from-similar', 'Apply patterns from similar completed tasks')\n .action(async (task, options) => {\n return trace.command('ralph-init', { task, ...options }, async () => {\n try {\n console.log('\uD83C\uDFAD Initializing Ralph Wiggum loop...');\n \n // Use basic Ralph loop for now (StackMemory integration requires DB setup)\n const loop = new RalphLoop({\n baseDir: '.ralph',\n maxIterations: parseInt(options.maxIterations),\n verbose: true\n });\n\n // Parse criteria\n const criteria = options.criteria \n ? options.criteria.split(',').map((c: string) => `- ${c.trim()}`).join('\\n')\n : '- All tests pass\\n- Code works correctly\\n- No lint errors';\n\n // Load StackMemory context if requested\n let enhancedTask = task;\n \n if (options.useContext || options.learnFromSimilar) {\n try {\n await stackMemoryContextLoader.initialize();\n \n const contextResponse = await stackMemoryContextLoader.loadInitialContext({\n task,\n usePatterns: true,\n useSimilarTasks: options.learnFromSimilar,\n maxTokens: 3000\n });\n \n if (contextResponse.context) {\n enhancedTask = `${task}\\n\\n${contextResponse.context}`;\n console.log(`\uD83D\uDCDA Loaded context from ${contextResponse.sources.length} sources`);\n console.log(`\uD83C\uDFAF Context tokens: ${contextResponse.metadata.totalTokens}`);\n }\n } catch (error: unknown) {\n console.log(`\u26A0\uFE0F Context loading failed: ${(error as Error).message}`);\n console.log('Proceeding without context...');\n }\n }\n\n await loop.initialize(enhancedTask, criteria);\n \n console.log('\u2705 Ralph loop initialized!');\n console.log(`\uD83D\uDCCB Task: ${task}`);\n console.log(`\uD83C\uDFAF Max iterations: ${options.maxIterations}`);\n console.log(`\uD83D\uDCC1 Loop directory: .ralph/`);\n console.log('\\nNext steps:');\n console.log(' stackmemory ralph run # Start the loop');\n console.log(' stackmemory ralph status # Check status');\n\n } catch (error: unknown) {\n logger.error('Failed to initialize Ralph loop', error as Error);\n console.error('\u274C Initialization failed:', (error as Error).message);\n process.exit(1);\n }\n });\n });\n\n // Run the Ralph loop\n ralph\n .command('run')\n .description('Run the Ralph Wiggum loop')\n .option('--verbose', 'Verbose output')\n .option('--pause-on-error', 'Pause on validation errors')\n .action(async (options) => {\n return trace.command('ralph-run', options, async () => {\n try {\n if (!existsSync('.ralph')) {\n console.error('\u274C No Ralph loop found. Run \"stackmemory ralph init\" first.');\n return;\n }\n\n console.log('\uD83C\uDFAD Starting Ralph Wiggum loop...');\n \n const loop = new RalphLoop({\n baseDir: '.ralph',\n verbose: options.verbose\n });\n\n await loop.run();\n \n } catch (error: unknown) {\n logger.error('Failed to run Ralph loop', error as Error);\n console.error('\u274C Loop execution failed:', (error as Error).message);\n process.exit(1);\n }\n });\n });\n\n // Show loop status\n ralph\n .command('status')\n .description('Show current Ralph loop status')\n .option('--detailed', 'Show detailed iteration history')\n .action(async (options) => {\n return trace.command('ralph-status', options, async () => {\n try {\n if (!existsSync('.ralph')) {\n console.log('\u274C No Ralph loop found in current directory');\n return;\n }\n\n // Get basic status from files\n \n // Read status from files\n const task = readFileSync('.ralph/task.md', 'utf8');\n const iteration = parseInt(readFileSync('.ralph/iteration.txt', 'utf8') || '0');\n const isComplete = existsSync('.ralph/work-complete.txt');\n const feedback = existsSync('.ralph/feedback.txt') ? readFileSync('.ralph/feedback.txt', 'utf8') : '';\n \n console.log('\uD83C\uDFAD Ralph Loop Status:');\n console.log(` Task: ${task.substring(0, 80)}...`);\n console.log(` Iteration: ${iteration}`);\n console.log(` Status: ${isComplete ? '\u2705 COMPLETE' : '\uD83D\uDD04 IN PROGRESS'}`);\n \n if (feedback) {\n console.log(` Last feedback: ${feedback.substring(0, 100)}...`);\n }\n\n if (options.detailed && existsSync('.ralph/progress.jsonl')) {\n console.log('\\n\uD83D\uDCCA Iteration History:');\n const progressLines = readFileSync('.ralph/progress.jsonl', 'utf8')\n .split('\\n')\n .filter(Boolean)\n .map(line => JSON.parse(line));\n \n progressLines.forEach((p: any) => {\n const progress = p as { iteration: number; validation?: { testsPass: boolean }; changes: number; errors: number };\n const status = progress.validation?.testsPass ? '\u2705' : '\u274C';\n console.log(` ${progress.iteration}: ${status} ${progress.changes} changes, ${progress.errors} errors`);\n });\n }\n\n // TODO: Show StackMemory integration status when available\n\n } catch (error: unknown) {\n logger.error('Failed to get Ralph status', error as Error);\n console.error('\u274C Status check failed:', (error as Error).message);\n }\n });\n });\n\n // Resume a crashed or paused loop\n ralph\n .command('resume')\n .description('Resume a crashed or paused Ralph loop')\n .option('--from-stackmemory', 'Restore from StackMemory backup')\n .action(async (options) => {\n return trace.command('ralph-resume', options, async () => {\n try {\n console.log('\uD83D\uDD04 Resuming Ralph loop...');\n \n const loop = new RalphLoop({ baseDir: '.ralph', verbose: true });\n \n if (options.fromStackmemory) {\n console.log('\uD83D\uDCDA StackMemory restore feature coming soon...');\n }\n\n await loop.run(); // Resume by continuing the loop\n \n } catch (error: unknown) {\n logger.error('Failed to resume Ralph loop', error as Error);\n console.error('\u274C Resume failed:', (error as Error).message);\n process.exit(1);\n }\n });\n });\n\n // Stop the current loop\n ralph\n .command('stop')\n .description('Stop the current Ralph loop')\n .option('--save-progress', 'Save current progress to StackMemory')\n .action(async (options) => {\n return trace.command('ralph-stop', options, async () => {\n try {\n if (!existsSync('.ralph')) {\n console.log('\u274C No active Ralph loop found');\n return;\n }\n\n console.log('\uD83D\uDED1 Stopping Ralph loop...');\n \n if (options.saveProgress) {\n console.log('\uD83D\uDCBE StackMemory progress save feature coming soon...');\n }\n\n // Create stop signal file\n writeFileSync('.ralph/stop-signal.txt', new Date().toISOString());\n console.log('\u2705 Stop signal sent');\n \n } catch (error: unknown) {\n logger.error('Failed to stop Ralph loop', error as Error);\n console.error('\u274C Stop failed:', (error as Error).message);\n }\n });\n });\n\n // Clean up loop artifacts\n ralph\n .command('clean')\n .description('Clean up Ralph loop artifacts')\n .option('--keep-history', 'Keep iteration history')\n .action(async (options) => {\n return trace.command('ralph-clean', options, async () => {\n try {\n // Clean up Ralph directory\n if (!options.keepHistory && existsSync('.ralph/history')) {\n const { execSync } = await import('child_process');\n execSync('rm -rf .ralph/history');\n }\n \n // Remove working files but keep task definition\n if (existsSync('.ralph/work-complete.txt')) {\n const fs = await import('fs');\n fs.unlinkSync('.ralph/work-complete.txt');\n }\n \n console.log('\uD83E\uDDF9 Ralph loop artifacts cleaned');\n \n } catch (error: unknown) {\n logger.error('Failed to clean Ralph artifacts', error as Error);\n console.error('\u274C Cleanup failed:', (error as Error).message);\n }\n });\n });\n\n // Debug and diagnostics\n ralph\n .command('debug')\n .description('Debug Ralph loop state and diagnostics')\n .option('--reconcile', 'Force state reconciliation')\n .option('--validate-context', 'Validate context budget')\n .action(async (options) => {\n return trace.command('ralph-debug', options, async () => {\n try {\n console.log('\uD83D\uDD0D Ralph Loop Debug Information:');\n \n if (options.reconcile) {\n console.log('\uD83D\uDD27 State reconciliation feature coming soon...');\n }\n\n if (options.validateContext) {\n console.log('\uD83D\uDCCA Context validation feature coming soon...');\n }\n\n // Show file structure\n if (existsSync('.ralph')) {\n console.log('\\n\uD83D\uDCC1 Ralph directory structure:');\n const { execSync } = await import('child_process');\n try {\n const tree = execSync('find .ralph -type f | head -20', { encoding: 'utf8' });\n console.log(tree);\n } catch {\n console.log(' (Unable to show directory tree)');\n }\n }\n \n } catch (error: unknown) {\n logger.error('Ralph debug failed', error as Error);\n console.error('\u274C Debug failed:', (error as Error).message);\n }\n });\n });\n\n // Swarm coordination commands\n ralph\n .command('swarm')\n .description('Launch a swarm of specialized agents')\n .argument('<project>', 'Project description')\n .option('--agents <agents>', 'Comma-separated list of agent roles (architect,developer,tester,etc)', 'developer,tester')\n .option('--max-agents <n>', 'Maximum number of agents', '5')\n .action(async (project, options) => {\n return trace.command('ralph-swarm', { project, ...options }, async () => {\n try {\n console.log('\uD83E\uDDBE Launching Ralph swarm...');\n \n await swarmCoordinator.initialize();\n \n const agentRoles = options.agents.split(',').map((r: string) => r.trim());\n const agentSpecs = agentRoles.map((role: string) => ({\n role: role as any,\n conflictResolution: 'defer_to_expertise',\n collaborationPreferences: []\n }));\n \n const swarmId = await swarmCoordinator.launchSwarm(project, agentSpecs);\n \n console.log(`\u2705 Swarm launched with ID: ${swarmId}`);\n console.log(`\uD83D\uDC65 ${agentSpecs.length} agents working on: ${project}`);\n console.log('\\nNext steps:');\n console.log(' stackmemory ralph swarm-status <swarmId> # Check progress');\n console.log(' stackmemory ralph swarm-stop <swarmId> # Stop swarm');\n \n } catch (error: unknown) {\n logger.error('Swarm launch failed', error as Error);\n console.error('\u274C Swarm launch failed:', (error as Error).message);\n }\n });\n });\n\n // Multi-loop orchestration for complex tasks\n ralph\n .command('orchestrate')\n .description('Orchestrate multiple Ralph loops for complex tasks')\n .argument('<description>', 'Complex task description')\n .option('--criteria <criteria>', 'Success criteria (comma separated)')\n .option('--max-loops <n>', 'Maximum parallel loops', '3')\n .option('--sequential', 'Force sequential execution')\n .action(async (description, options) => {\n return trace.command('ralph-orchestrate', { description, ...options }, async () => {\n try {\n console.log('\uD83C\uDFAD Orchestrating complex task...');\n \n await multiLoopOrchestrator.initialize();\n \n const criteria = options.criteria ? \n options.criteria.split(',').map((c: string) => c.trim()) :\n ['Task completed successfully', 'All components working', 'Tests pass'];\n \n const result = await multiLoopOrchestrator.orchestrateComplexTask(\n description,\n criteria,\n {\n maxLoops: parseInt(options.maxLoops),\n forceSequential: options.sequential\n }\n );\n \n console.log('\u2705 Orchestration completed!');\n console.log(`\uD83D\uDCCA Results: ${result.completedLoops.length} successful, ${result.failedLoops.length} failed`);\n console.log(`\u23F1\uFE0F Total duration: ${Math.round(result.totalDuration / 1000)}s`);\n \n if (result.insights.length > 0) {\n console.log('\\n\uD83D\uDCA1 Insights:');\n result.insights.forEach(insight => console.log(` \u2022 ${insight}`));\n }\n \n } catch (error: unknown) {\n logger.error('Orchestration failed', error as Error);\n console.error('\u274C Orchestration failed:', (error as Error).message);\n }\n });\n });\n\n // Pattern learning command\n ralph\n .command('learn')\n .description('Learn patterns from completed loops')\n .option('--task-type <type>', 'Learn patterns for specific task type')\n .action(async (options) => {\n return trace.command('ralph-learn', options, async () => {\n try {\n console.log('\uD83E\uDDE0 Learning patterns from completed loops...');\n \n await patternLearner.initialize();\n \n const patterns = options.taskType ?\n await patternLearner.learnForTaskType(options.taskType) :\n await patternLearner.learnFromCompletedLoops();\n \n console.log(`\u2705 Learned ${patterns.length} patterns`);\n \n if (patterns.length > 0) {\n console.log('\\n\uD83D\uDCCA Top patterns:');\n patterns.slice(0, 5).forEach(pattern => {\n console.log(` \u2022 ${pattern.pattern} (${Math.round(pattern.confidence * 100)}% confidence)`);\n });\n }\n \n } catch (error: unknown) {\n logger.error('Pattern learning failed', error as Error);\n console.error('\u274C Pattern learning failed:', (error as Error).message);\n }\n });\n });\n\n // Enhanced debug command with visualization\n ralph\n .command('debug-enhanced')\n .description('Advanced debugging with visualization')\n .option('--loop-id <id>', 'Specific loop to debug')\n .option('--generate-report', 'Generate comprehensive debug report')\n .option('--timeline', 'Generate timeline visualization')\n .action(async (options) => {\n return trace.command('ralph-debug-enhanced', options, async () => {\n try {\n if (!existsSync('.ralph') && !options.loopId) {\n console.log('\u274C No Ralph loop found. Run a loop first or specify --loop-id');\n return;\n }\n \n console.log('\uD83D\uDD0D Starting enhanced debugging...');\n \n await ralphDebugger.initialize();\n \n const loopId = options.loopId || 'current';\n const debugSession = await ralphDebugger.startDebugSession(loopId, '.ralph');\n \n if (options.generateReport) {\n const report = await ralphDebugger.generateDebugReport(loopId);\n console.log(`\uD83D\uDCCB Debug report generated: ${report.exportPath}`);\n }\n \n if (options.timeline) {\n const timelinePath = await ralphDebugger.generateLoopTimeline(loopId);\n console.log(`\uD83D\uDCCA Timeline visualization: ${timelinePath}`);\n }\n \n console.log('\uD83D\uDD0D Debug analysis complete');\n \n } catch (error: unknown) {\n logger.error('Enhanced debugging failed', error as Error);\n console.error('\u274C Debug failed:', (error as Error).message);\n }\n });\n });\n\n // TUI command for real-time monitoring\n ralph\n .command('tui')\n .description('Launch TUI monitor for active swarms')\n .option('--swarm-id <id>', 'Monitor specific swarm ID')\n .action(async (options) => {\n try {\n const { SwarmTUI } = await import('../../features/tui/swarm-monitor.js');\n \n const tui = new SwarmTUI();\n \n // Initialize with optional swarm ID\n await tui.initialize(undefined, options.swarmId);\n tui.start();\n \n } catch (error: unknown) {\n logger.error('TUI launch failed', error as Error);\n console.error('\u274C TUI failed:', (error as Error).message);\n process.exit(1);\n }\n });\n\n return ralph;\n}\n\nexport default createRalphCommand;"],
|
|
5
|
-
"mappings": "AAKA,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAC9B,SAAS,YAAY,cAAc,qBAAqB;AACxD,SAAS,aAAa;AAEf,SAAS,qBAA8B;AAC5C,QAAM,QAAQ,IAAI,QAAQ,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * Ralph Wiggum Loop Commands\n * CLI interface for Ralph-StackMemory integration\n */\n\nimport { Command } from 'commander';\nimport { logger } from '../../core/monitoring/logger.js';\nimport { RalphLoop } from '../../../scripts/ralph-loop-implementation.js';\nimport { stackMemoryContextLoader } from '../../integrations/ralph/context/stackmemory-context-loader.js';\nimport { patternLearner } from '../../integrations/ralph/learning/pattern-learner.js';\nimport { multiLoopOrchestrator } from '../../integrations/ralph/orchestration/multi-loop-orchestrator.js';\nimport { swarmCoordinator } from '../../integrations/ralph/swarm/swarm-coordinator.js';\nimport { ralphDebugger } from '../../integrations/ralph/visualization/ralph-debugger.js';\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { trace } from '../../core/trace/index.js';\n\nexport function createRalphCommand(): Command {\n const ralph = new Command('ralph').description(\n 'Ralph Wiggum Loop integration with StackMemory'\n );\n\n // Initialize a new Ralph loop\n ralph\n .command('init')\n .description('Initialize a new Ralph Wiggum loop')\n .argument('<task>', 'Task description')\n .option(\n '-c, --criteria <criteria>',\n 'Completion criteria (comma separated)'\n )\n .option('--max-iterations <n>', 'Maximum iterations', '50')\n .option('--use-context', 'Load relevant context from StackMemory')\n .option(\n '--learn-from-similar',\n 'Apply patterns from similar completed tasks'\n )\n .action(async (task, options) => {\n return trace.command('ralph-init', { task, ...options }, async () => {\n try {\n console.log('\uD83C\uDFAD Initializing Ralph Wiggum loop...');\n\n // Use basic Ralph loop for now (StackMemory integration requires DB setup)\n const loop = new RalphLoop({\n baseDir: '.ralph',\n maxIterations: parseInt(options.maxIterations),\n verbose: true,\n });\n\n // Parse criteria\n const criteria = options.criteria\n ? options.criteria\n .split(',')\n .map((c: string) => `- ${c.trim()}`)\n .join('\\n')\n : '- All tests pass\\n- Code works correctly\\n- No lint errors';\n\n // Load StackMemory context if requested\n let enhancedTask = task;\n\n if (options.useContext || options.learnFromSimilar) {\n try {\n await stackMemoryContextLoader.initialize();\n\n const contextResponse =\n await stackMemoryContextLoader.loadInitialContext({\n task,\n usePatterns: true,\n useSimilarTasks: options.learnFromSimilar,\n maxTokens: 3000,\n });\n\n if (contextResponse.context) {\n enhancedTask = `${task}\\n\\n${contextResponse.context}`;\n console.log(\n `\uD83D\uDCDA Loaded context from ${contextResponse.sources.length} sources`\n );\n console.log(\n `\uD83C\uDFAF Context tokens: ${contextResponse.metadata.totalTokens}`\n );\n }\n } catch (error: unknown) {\n console.log(\n `\u26A0\uFE0F Context loading failed: ${(error as Error).message}`\n );\n console.log('Proceeding without context...');\n }\n }\n\n await loop.initialize(enhancedTask, criteria);\n\n console.log('\u2705 Ralph loop initialized!');\n console.log(`\uD83D\uDCCB Task: ${task}`);\n console.log(`\uD83C\uDFAF Max iterations: ${options.maxIterations}`);\n console.log(`\uD83D\uDCC1 Loop directory: .ralph/`);\n console.log('\\nNext steps:');\n console.log(' stackmemory ralph run # Start the loop');\n console.log(' stackmemory ralph status # Check status');\n } catch (error: unknown) {\n logger.error('Failed to initialize Ralph loop', error as Error);\n console.error('\u274C Initialization failed:', (error as Error).message);\n process.exit(1);\n }\n });\n });\n\n // Run the Ralph loop\n ralph\n .command('run')\n .description('Run the Ralph Wiggum loop')\n .option('--verbose', 'Verbose output')\n .option('--pause-on-error', 'Pause on validation errors')\n .action(async (options) => {\n return trace.command('ralph-run', options, async () => {\n try {\n if (!existsSync('.ralph')) {\n console.error(\n '\u274C No Ralph loop found. Run \"stackmemory ralph init\" first.'\n );\n return;\n }\n\n console.log('\uD83C\uDFAD Starting Ralph Wiggum loop...');\n\n const loop = new RalphLoop({\n baseDir: '.ralph',\n verbose: options.verbose,\n });\n\n await loop.run();\n } catch (error: unknown) {\n logger.error('Failed to run Ralph loop', error as Error);\n console.error('\u274C Loop execution failed:', (error as Error).message);\n process.exit(1);\n }\n });\n });\n\n // Show loop status\n ralph\n .command('status')\n .description('Show current Ralph loop status')\n .option('--detailed', 'Show detailed iteration history')\n .action(async (options) => {\n return trace.command('ralph-status', options, async () => {\n try {\n if (!existsSync('.ralph')) {\n console.log('\u274C No Ralph loop found in current directory');\n return;\n }\n\n // Get basic status from files\n\n // Read status from files\n const task = readFileSync('.ralph/task.md', 'utf8');\n const iteration = parseInt(\n readFileSync('.ralph/iteration.txt', 'utf8') || '0'\n );\n const isComplete = existsSync('.ralph/work-complete.txt');\n const feedback = existsSync('.ralph/feedback.txt')\n ? readFileSync('.ralph/feedback.txt', 'utf8')\n : '';\n\n console.log('\uD83C\uDFAD Ralph Loop Status:');\n console.log(` Task: ${task.substring(0, 80)}...`);\n console.log(` Iteration: ${iteration}`);\n console.log(\n ` Status: ${isComplete ? '\u2705 COMPLETE' : '\uD83D\uDD04 IN PROGRESS'}`\n );\n\n if (feedback) {\n console.log(` Last feedback: ${feedback.substring(0, 100)}...`);\n }\n\n if (options.detailed && existsSync('.ralph/progress.jsonl')) {\n console.log('\\n\uD83D\uDCCA Iteration History:');\n const progressLines = readFileSync('.ralph/progress.jsonl', 'utf8')\n .split('\\n')\n .filter(Boolean)\n .map((line) => JSON.parse(line));\n\n progressLines.forEach((p: any) => {\n const progress = p as {\n iteration: number;\n validation?: { testsPass: boolean };\n changes: number;\n errors: number;\n };\n const status = progress.validation?.testsPass ? '\u2705' : '\u274C';\n console.log(\n ` ${progress.iteration}: ${status} ${progress.changes} changes, ${progress.errors} errors`\n );\n });\n }\n\n // TODO: Show StackMemory integration status when available\n } catch (error: unknown) {\n logger.error('Failed to get Ralph status', error as Error);\n console.error('\u274C Status check failed:', (error as Error).message);\n }\n });\n });\n\n // Resume a crashed or paused loop\n ralph\n .command('resume')\n .description('Resume a crashed or paused Ralph loop')\n .option('--from-stackmemory', 'Restore from StackMemory backup')\n .action(async (options) => {\n return trace.command('ralph-resume', options, async () => {\n try {\n console.log('\uD83D\uDD04 Resuming Ralph loop...');\n\n const loop = new RalphLoop({ baseDir: '.ralph', verbose: true });\n\n if (options.fromStackmemory) {\n console.log('\uD83D\uDCDA StackMemory restore feature coming soon...');\n }\n\n await loop.run(); // Resume by continuing the loop\n } catch (error: unknown) {\n logger.error('Failed to resume Ralph loop', error as Error);\n console.error('\u274C Resume failed:', (error as Error).message);\n process.exit(1);\n }\n });\n });\n\n // Stop the current loop\n ralph\n .command('stop')\n .description('Stop the current Ralph loop')\n .option('--save-progress', 'Save current progress to StackMemory')\n .action(async (options) => {\n return trace.command('ralph-stop', options, async () => {\n try {\n if (!existsSync('.ralph')) {\n console.log('\u274C No active Ralph loop found');\n return;\n }\n\n console.log('\uD83D\uDED1 Stopping Ralph loop...');\n\n if (options.saveProgress) {\n console.log('\uD83D\uDCBE StackMemory progress save feature coming soon...');\n }\n\n // Create stop signal file\n writeFileSync('.ralph/stop-signal.txt', new Date().toISOString());\n console.log('\u2705 Stop signal sent');\n } catch (error: unknown) {\n logger.error('Failed to stop Ralph loop', error as Error);\n console.error('\u274C Stop failed:', (error as Error).message);\n }\n });\n });\n\n // Clean up loop artifacts\n ralph\n .command('clean')\n .description('Clean up Ralph loop artifacts')\n .option('--keep-history', 'Keep iteration history')\n .action(async (options) => {\n return trace.command('ralph-clean', options, async () => {\n try {\n // Clean up Ralph directory\n if (!options.keepHistory && existsSync('.ralph/history')) {\n const { execSync } = await import('child_process');\n execSync('rm -rf .ralph/history');\n }\n\n // Remove working files but keep task definition\n if (existsSync('.ralph/work-complete.txt')) {\n const fs = await import('fs');\n fs.unlinkSync('.ralph/work-complete.txt');\n }\n\n console.log('\uD83E\uDDF9 Ralph loop artifacts cleaned');\n } catch (error: unknown) {\n logger.error('Failed to clean Ralph artifacts', error as Error);\n console.error('\u274C Cleanup failed:', (error as Error).message);\n }\n });\n });\n\n // Debug and diagnostics\n ralph\n .command('debug')\n .description('Debug Ralph loop state and diagnostics')\n .option('--reconcile', 'Force state reconciliation')\n .option('--validate-context', 'Validate context budget')\n .action(async (options) => {\n return trace.command('ralph-debug', options, async () => {\n try {\n console.log('\uD83D\uDD0D Ralph Loop Debug Information:');\n\n if (options.reconcile) {\n console.log('\uD83D\uDD27 State reconciliation feature coming soon...');\n }\n\n if (options.validateContext) {\n console.log('\uD83D\uDCCA Context validation feature coming soon...');\n }\n\n // Show file structure\n if (existsSync('.ralph')) {\n console.log('\\n\uD83D\uDCC1 Ralph directory structure:');\n const { execSync } = await import('child_process');\n try {\n const tree = execSync('find .ralph -type f | head -20', {\n encoding: 'utf8',\n });\n console.log(tree);\n } catch {\n console.log(' (Unable to show directory tree)');\n }\n }\n } catch (error: unknown) {\n logger.error('Ralph debug failed', error as Error);\n console.error('\u274C Debug failed:', (error as Error).message);\n }\n });\n });\n\n // Swarm coordination commands\n ralph\n .command('swarm')\n .description('Launch a swarm of specialized agents')\n .argument('<project>', 'Project description')\n .option(\n '--agents <agents>',\n 'Comma-separated list of agent roles (architect,developer,tester,etc)',\n 'developer,tester'\n )\n .option('--max-agents <n>', 'Maximum number of agents', '5')\n .action(async (project, options) => {\n return trace.command('ralph-swarm', { project, ...options }, async () => {\n try {\n console.log('\uD83E\uDDBE Launching Ralph swarm...');\n\n await swarmCoordinator.initialize();\n\n const agentRoles = options.agents\n .split(',')\n .map((r: string) => r.trim());\n const agentSpecs = agentRoles.map((role: string) => ({\n role: role as any,\n conflictResolution: 'defer_to_expertise',\n collaborationPreferences: [],\n }));\n\n const swarmId = await swarmCoordinator.launchSwarm(\n project,\n agentSpecs\n );\n\n console.log(`\u2705 Swarm launched with ID: ${swarmId}`);\n console.log(`\uD83D\uDC65 ${agentSpecs.length} agents working on: ${project}`);\n console.log('\\nNext steps:');\n console.log(\n ' stackmemory ralph swarm-status <swarmId> # Check progress'\n );\n console.log(\n ' stackmemory ralph swarm-stop <swarmId> # Stop swarm'\n );\n } catch (error: unknown) {\n logger.error('Swarm launch failed', error as Error);\n console.error('\u274C Swarm launch failed:', (error as Error).message);\n }\n });\n });\n\n // Multi-loop orchestration for complex tasks\n ralph\n .command('orchestrate')\n .description('Orchestrate multiple Ralph loops for complex tasks')\n .argument('<description>', 'Complex task description')\n .option('--criteria <criteria>', 'Success criteria (comma separated)')\n .option('--max-loops <n>', 'Maximum parallel loops', '3')\n .option('--sequential', 'Force sequential execution')\n .action(async (description, options) => {\n return trace.command(\n 'ralph-orchestrate',\n { description, ...options },\n async () => {\n try {\n console.log('\uD83C\uDFAD Orchestrating complex task...');\n\n await multiLoopOrchestrator.initialize();\n\n const criteria = options.criteria\n ? options.criteria.split(',').map((c: string) => c.trim())\n : [\n 'Task completed successfully',\n 'All components working',\n 'Tests pass',\n ];\n\n const result = await multiLoopOrchestrator.orchestrateComplexTask(\n description,\n criteria,\n {\n maxLoops: parseInt(options.maxLoops),\n forceSequential: options.sequential,\n }\n );\n\n console.log('\u2705 Orchestration completed!');\n console.log(\n `\uD83D\uDCCA Results: ${result.completedLoops.length} successful, ${result.failedLoops.length} failed`\n );\n console.log(\n `\u23F1\uFE0F Total duration: ${Math.round(result.totalDuration / 1000)}s`\n );\n\n if (result.insights.length > 0) {\n console.log('\\n\uD83D\uDCA1 Insights:');\n result.insights.forEach((insight) =>\n console.log(` \u2022 ${insight}`)\n );\n }\n } catch (error: unknown) {\n logger.error('Orchestration failed', error as Error);\n console.error('\u274C Orchestration failed:', (error as Error).message);\n }\n }\n );\n });\n\n // Pattern learning command\n ralph\n .command('learn')\n .description('Learn patterns from completed loops')\n .option('--task-type <type>', 'Learn patterns for specific task type')\n .action(async (options) => {\n return trace.command('ralph-learn', options, async () => {\n try {\n console.log('\uD83E\uDDE0 Learning patterns from completed loops...');\n\n await patternLearner.initialize();\n\n const patterns = options.taskType\n ? await patternLearner.learnForTaskType(options.taskType)\n : await patternLearner.learnFromCompletedLoops();\n\n console.log(`\u2705 Learned ${patterns.length} patterns`);\n\n if (patterns.length > 0) {\n console.log('\\n\uD83D\uDCCA Top patterns:');\n patterns.slice(0, 5).forEach((pattern) => {\n console.log(\n ` \u2022 ${pattern.pattern} (${Math.round(pattern.confidence * 100)}% confidence)`\n );\n });\n }\n } catch (error: unknown) {\n logger.error('Pattern learning failed', error as Error);\n console.error(\n '\u274C Pattern learning failed:',\n (error as Error).message\n );\n }\n });\n });\n\n // Enhanced debug command with visualization\n ralph\n .command('debug-enhanced')\n .description('Advanced debugging with visualization')\n .option('--loop-id <id>', 'Specific loop to debug')\n .option('--generate-report', 'Generate comprehensive debug report')\n .option('--timeline', 'Generate timeline visualization')\n .action(async (options) => {\n return trace.command('ralph-debug-enhanced', options, async () => {\n try {\n if (!existsSync('.ralph') && !options.loopId) {\n console.log(\n '\u274C No Ralph loop found. Run a loop first or specify --loop-id'\n );\n return;\n }\n\n console.log('\uD83D\uDD0D Starting enhanced debugging...');\n\n await ralphDebugger.initialize();\n\n const loopId = options.loopId || 'current';\n await ralphDebugger.startDebugSession(loopId, '.ralph');\n\n if (options.generateReport) {\n const report = await ralphDebugger.generateDebugReport(loopId);\n console.log(`\uD83D\uDCCB Debug report generated: ${report.exportPath}`);\n }\n\n if (options.timeline) {\n const timelinePath =\n await ralphDebugger.generateLoopTimeline(loopId);\n console.log(`\uD83D\uDCCA Timeline visualization: ${timelinePath}`);\n }\n\n console.log('\uD83D\uDD0D Debug analysis complete');\n } catch (error: unknown) {\n logger.error('Enhanced debugging failed', error as Error);\n console.error('\u274C Debug failed:', (error as Error).message);\n }\n });\n });\n\n // TUI command for real-time monitoring\n ralph\n .command('tui')\n .description('Launch TUI monitor for active swarms')\n .option('--swarm-id <id>', 'Monitor specific swarm ID')\n .option('--simple', 'Use simple text mode instead of full TUI')\n .option('--force-tui', 'Force full TUI even with compatibility issues')\n .action(async (options) => {\n try {\n // Detect terminal compatibility\n const isGhostty =\n process.env.TERM_PROGRAM === 'ghostty' ||\n process.env.TERM?.includes('ghostty');\n const isBasicTerm =\n process.env.TERM === 'dumb' || process.env.TERM === 'unknown';\n const hasCompatibilityIssues = isGhostty || isBasicTerm;\n\n // Default behavior: use simple mode for problematic terminals unless forced\n const useSimpleMode =\n options.simple || (hasCompatibilityIssues && !options.forceTui);\n\n if (useSimpleMode) {\n console.log('\uD83E\uDDBE Starting Simple Swarm Monitor (Text Mode)');\n if (hasCompatibilityIssues && !options.simple) {\n console.log(\n `\u26A0\uFE0F Detected ${isGhostty ? 'Ghostty' : 'basic'} terminal - using text mode for compatibility`\n );\n console.log(\n ' Use --force-tui to override, or --simple to explicitly use text mode'\n );\n }\n\n const { SimpleSwarmMonitor } =\n await import('../../features/tui/simple-monitor.js');\n const monitor = new SimpleSwarmMonitor();\n monitor.start();\n } else {\n console.log('\uD83E\uDDBE Starting Full TUI Monitor');\n const { SwarmTUI } =\n await import('../../features/tui/swarm-monitor.js');\n\n const tui = new SwarmTUI();\n\n // Initialize with optional swarm ID\n await tui.initialize(undefined, options.swarmId);\n tui.start();\n }\n } catch (error: unknown) {\n logger.error('TUI launch failed', error as Error);\n console.error('\u274C TUI failed:', (error as Error).message);\n console.log('\uD83D\uDCA1 Try: stackmemory ralph tui --simple');\n process.exit(1);\n }\n });\n\n return ralph;\n}\n\nexport default createRalphCommand;\n"],
|
|
5
|
+
"mappings": "AAKA,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAC9B,SAAS,YAAY,cAAc,qBAAqB;AACxD,SAAS,aAAa;AAEf,SAAS,qBAA8B;AAC5C,QAAM,QAAQ,IAAI,QAAQ,OAAO,EAAE;AAAA,IACjC;AAAA,EACF;AAGA,QACG,QAAQ,MAAM,EACd,YAAY,oCAAoC,EAChD,SAAS,UAAU,kBAAkB,EACrC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,wBAAwB,sBAAsB,IAAI,EACzD,OAAO,iBAAiB,w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Q,IAAI,SAAS;AACtD,YAAM,yBAAyB,aAAa;AAG5C,YAAM,gBACJ,QAAQ,UAAW,0BAA0B,CAAC,QAAQ;AAExD,UAAI,eAAe;AACjB,gBAAQ,IAAI,qDAA8C;AAC1D,YAAI,0BAA0B,CAAC,QAAQ,QAAQ;AAC7C,kBAAQ;AAAA,YACN,0BAAgB,YAAY,YAAY,OAAO;AAAA,UACjD;AACA,kBAAQ;AAAA,YACN;AAAA,UACF;AAAA,QACF;AAEA,cAAM,EAAE,mBAAmB,IACzB,MAAM,OAAO,sCAAsC;AACrD,cAAM,UAAU,IAAI,mBAAmB;AACvC,gBAAQ,MAAM;AAAA,MAChB,OAAO;AACL,gBAAQ,IAAI,qCAA8B;AAC1C,cAAM,EAAE,SAAS,IACf,MAAM,OAAO,qCAAqC;AAEpD,cAAM,MAAM,IAAI,SAAS;AAGzB,cAAM,IAAI,WAAW,QAAW,QAAQ,OAAO;AAC/C,YAAI,MAAM;AAAA,MACZ;AAAA,IACF,SAAS,OAAgB;AACvB,aAAO,MAAM,qBAAqB,KAAc;AAChD,cAAQ,MAAM,sBAAkB,MAAgB,OAAO;AACvD,cAAQ,IAAI,+CAAwC;AACpD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AAEH,SAAO;AACT;AAEA,IAAO,gBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { SwarmRegistry } from "../../integrations/ralph/monitoring/swarm-registry.js";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
class SimpleSwarmMonitor {
|
|
4
|
+
refreshInterval = null;
|
|
5
|
+
/**
|
|
6
|
+
* Start simple text-based monitoring
|
|
7
|
+
*/
|
|
8
|
+
start() {
|
|
9
|
+
console.log("\u{1F9BE} Ralph Swarm Monitor (Text Mode)");
|
|
10
|
+
console.log("=====================================");
|
|
11
|
+
console.log("");
|
|
12
|
+
console.log("Press Ctrl+C to quit");
|
|
13
|
+
console.log("");
|
|
14
|
+
this.displayStatus();
|
|
15
|
+
this.refreshInterval = setInterval(() => {
|
|
16
|
+
this.displayStatus();
|
|
17
|
+
}, 5e3);
|
|
18
|
+
process.on("SIGINT", () => {
|
|
19
|
+
this.stop();
|
|
20
|
+
process.exit(0);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Stop monitoring
|
|
25
|
+
*/
|
|
26
|
+
stop() {
|
|
27
|
+
if (this.refreshInterval) {
|
|
28
|
+
clearInterval(this.refreshInterval);
|
|
29
|
+
}
|
|
30
|
+
console.log("\n\u{1F44B} Swarm monitoring stopped");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Display current status
|
|
34
|
+
*/
|
|
35
|
+
displayStatus() {
|
|
36
|
+
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
37
|
+
console.log(`
|
|
38
|
+
\u23F0 ${timestamp} - Swarm Status Update`);
|
|
39
|
+
console.log("\u2500".repeat(50));
|
|
40
|
+
try {
|
|
41
|
+
const registry = SwarmRegistry.getInstance();
|
|
42
|
+
const activeSwarms = registry.listActiveSwarms();
|
|
43
|
+
const stats = registry.getStatistics();
|
|
44
|
+
console.log(
|
|
45
|
+
`\u{1F4CA} Registry Stats: ${stats.activeSwarms} active, ${stats.totalSwarms} total`
|
|
46
|
+
);
|
|
47
|
+
if (activeSwarms.length > 0) {
|
|
48
|
+
console.log("\n\u{1F9BE} Active Swarms:");
|
|
49
|
+
for (const swarm of activeSwarms) {
|
|
50
|
+
const uptime = this.formatDuration(Date.now() - swarm.startTime);
|
|
51
|
+
console.log(
|
|
52
|
+
` \u2022 ${swarm.id.substring(0, 8)}: ${swarm.status} (${uptime})`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
console.log("\u274C No active swarms in registry");
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const ralphProcesses = execSync(
|
|
60
|
+
'ps aux | grep "ralph" | grep -v grep',
|
|
61
|
+
{ encoding: "utf8" }
|
|
62
|
+
);
|
|
63
|
+
if (ralphProcesses.trim()) {
|
|
64
|
+
console.log("\n\u{1F50D} External Ralph Processes:");
|
|
65
|
+
const processLines = ralphProcesses.split("\n").filter((line) => line.trim());
|
|
66
|
+
processLines.slice(0, 3).forEach((line) => {
|
|
67
|
+
const parts = line.split(/\s+/);
|
|
68
|
+
console.log(
|
|
69
|
+
` PID ${parts[1]}: ${parts.slice(10).join(" ").slice(0, 50)}...`
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
if (processLines.length > 3) {
|
|
73
|
+
console.log(` ... and ${processLines.length - 3} more processes`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} catch {
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const recentCommits = execSync(
|
|
80
|
+
'git log --oneline --since="1 hour ago" --pretty=format:"%h %an %s" | head -3',
|
|
81
|
+
{ encoding: "utf8", cwd: process.cwd() }
|
|
82
|
+
);
|
|
83
|
+
if (recentCommits.trim()) {
|
|
84
|
+
console.log("\n\u{1F4DD} Recent Commits:");
|
|
85
|
+
recentCommits.split("\n").filter((line) => line.trim()).forEach((line) => {
|
|
86
|
+
console.log(` ${line}`);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.log(`\u274C Status error: ${error.message}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Format duration string
|
|
97
|
+
*/
|
|
98
|
+
formatDuration(ms) {
|
|
99
|
+
const seconds = Math.floor(ms / 1e3);
|
|
100
|
+
const minutes = Math.floor(seconds / 60);
|
|
101
|
+
const hours = Math.floor(minutes / 60);
|
|
102
|
+
if (hours > 0) return `${hours}h ${minutes % 60}m`;
|
|
103
|
+
if (minutes > 0) return `${minutes}m ${seconds % 60}s`;
|
|
104
|
+
return `${seconds}s`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
var simple_monitor_default = SimpleSwarmMonitor;
|
|
108
|
+
export {
|
|
109
|
+
SimpleSwarmMonitor,
|
|
110
|
+
simple_monitor_default as default
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=simple-monitor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/features/tui/simple-monitor.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Simple text-based swarm monitor for terminal compatibility\n * Fallback for terminals that can't handle blessed TUI\n */\n\nimport { SwarmRegistry } from '../../integrations/ralph/monitoring/swarm-registry.js';\nimport { execSync } from 'child_process';\n// Simple monitor for terminal compatibility\n\nexport class SimpleSwarmMonitor {\n private refreshInterval: NodeJS.Timeout | null = null;\n\n /**\n * Start simple text-based monitoring\n */\n start(): void {\n console.log('\uD83E\uDDBE Ralph Swarm Monitor (Text Mode)');\n console.log('=====================================');\n console.log('');\n console.log('Press Ctrl+C to quit');\n console.log('');\n\n // Show initial status\n this.displayStatus();\n\n // Set up refresh interval\n this.refreshInterval = setInterval(() => {\n this.displayStatus();\n }, 5000);\n\n // Handle graceful shutdown\n process.on('SIGINT', () => {\n this.stop();\n process.exit(0);\n });\n }\n\n /**\n * Stop monitoring\n */\n stop(): void {\n if (this.refreshInterval) {\n clearInterval(this.refreshInterval);\n }\n console.log('\\n\uD83D\uDC4B Swarm monitoring stopped');\n }\n\n /**\n * Display current status\n */\n private displayStatus(): void {\n const timestamp = new Date().toLocaleTimeString();\n\n console.log(`\\n\u23F0 ${timestamp} - Swarm Status Update`);\n console.log('\u2500'.repeat(50));\n\n try {\n // Check registry\n const registry = SwarmRegistry.getInstance();\n const activeSwarms = registry.listActiveSwarms();\n const stats = registry.getStatistics();\n\n console.log(\n `\uD83D\uDCCA Registry Stats: ${stats.activeSwarms} active, ${stats.totalSwarms} total`\n );\n\n if (activeSwarms.length > 0) {\n console.log('\\n\uD83E\uDDBE Active Swarms:');\n for (const swarm of activeSwarms) {\n const uptime = this.formatDuration(Date.now() - swarm.startTime);\n console.log(\n ` \u2022 ${swarm.id.substring(0, 8)}: ${swarm.status} (${uptime})`\n );\n }\n } else {\n console.log('\u274C No active swarms in registry');\n }\n\n // Check for external processes\n try {\n const ralphProcesses = execSync(\n 'ps aux | grep \"ralph\" | grep -v grep',\n { encoding: 'utf8' }\n );\n if (ralphProcesses.trim()) {\n console.log('\\n\uD83D\uDD0D External Ralph Processes:');\n const processLines = ralphProcesses\n .split('\\n')\n .filter((line) => line.trim());\n processLines.slice(0, 3).forEach((line) => {\n const parts = line.split(/\\s+/);\n console.log(\n ` PID ${parts[1]}: ${parts.slice(10).join(' ').slice(0, 50)}...`\n );\n });\n if (processLines.length > 3) {\n console.log(` ... and ${processLines.length - 3} more processes`);\n }\n }\n } catch {\n // No external processes\n }\n\n // Show recent commits\n try {\n const recentCommits = execSync(\n 'git log --oneline --since=\"1 hour ago\" --pretty=format:\"%h %an %s\" | head -3',\n { encoding: 'utf8', cwd: process.cwd() }\n );\n\n if (recentCommits.trim()) {\n console.log('\\n\uD83D\uDCDD Recent Commits:');\n recentCommits\n .split('\\n')\n .filter((line) => line.trim())\n .forEach((line) => {\n console.log(` ${line}`);\n });\n }\n } catch {\n // No git or commits\n }\n } catch (error: unknown) {\n console.log(`\u274C Status error: ${(error as Error).message}`);\n }\n }\n\n /**\n * Format duration string\n */\n private formatDuration(ms: number): string {\n const seconds = Math.floor(ms / 1000);\n const minutes = Math.floor(seconds / 60);\n const hours = Math.floor(minutes / 60);\n\n if (hours > 0) return `${hours}h ${minutes % 60}m`;\n if (minutes > 0) return `${minutes}m ${seconds % 60}s`;\n return `${seconds}s`;\n }\n}\n\nexport default SimpleSwarmMonitor;\n"],
|
|
5
|
+
"mappings": "AAKA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AAGlB,MAAM,mBAAmB;AAAA,EACtB,kBAA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