@stackmemoryai/stackmemory 0.3.21 → 0.3.24
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/linear-unified.js +2 -3
- package/dist/cli/commands/linear-unified.js.map +2 -2
- package/dist/cli/commands/ralph.js +294 -0
- package/dist/cli/commands/ralph.js.map +7 -0
- package/dist/cli/commands/tasks.js +1 -1
- package/dist/cli/commands/tasks.js.map +2 -2
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +2 -2
- package/dist/integrations/mcp/handlers/code-execution-handlers.js +262 -0
- package/dist/integrations/mcp/handlers/code-execution-handlers.js.map +7 -0
- package/dist/integrations/mcp/tool-definitions-code.js +121 -0
- package/dist/integrations/mcp/tool-definitions-code.js.map +7 -0
- package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js +586 -0
- package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js.map +7 -0
- package/dist/integrations/ralph/context/context-budget-manager.js +297 -0
- package/dist/integrations/ralph/context/context-budget-manager.js.map +7 -0
- package/dist/integrations/ralph/context/stackmemory-context-loader.js +356 -0
- package/dist/integrations/ralph/context/stackmemory-context-loader.js.map +7 -0
- package/dist/integrations/ralph/index.js +14 -0
- package/dist/integrations/ralph/index.js.map +7 -0
- package/dist/integrations/ralph/learning/pattern-learner.js +397 -0
- package/dist/integrations/ralph/learning/pattern-learner.js.map +7 -0
- package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js +444 -0
- package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js.map +7 -0
- package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js +459 -0
- package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js.map +7 -0
- package/dist/integrations/ralph/performance/performance-optimizer.js +354 -0
- package/dist/integrations/ralph/performance/performance-optimizer.js.map +7 -0
- package/dist/integrations/ralph/ralph-integration-demo.js +178 -0
- package/dist/integrations/ralph/ralph-integration-demo.js.map +7 -0
- package/dist/integrations/ralph/state/state-reconciler.js +400 -0
- package/dist/integrations/ralph/state/state-reconciler.js.map +7 -0
- package/dist/integrations/ralph/swarm/swarm-coordinator.js +487 -0
- package/dist/integrations/ralph/swarm/swarm-coordinator.js.map +7 -0
- package/dist/integrations/ralph/types.js +1 -0
- package/dist/integrations/ralph/types.js.map +7 -0
- package/dist/integrations/ralph/visualization/ralph-debugger.js +581 -0
- package/dist/integrations/ralph/visualization/ralph-debugger.js.map +7 -0
- package/dist/servers/railway/index.js +98 -92
- package/dist/servers/railway/index.js.map +3 -3
- package/package.json +1 -2
- package/scripts/claude-sm-autostart.js +1 -1
- package/scripts/clean-linear-backlog.js +2 -2
- package/scripts/debug-linear-update.js +1 -1
- package/scripts/debug-railway-build.js +87 -0
- package/scripts/delete-linear-tasks.js +2 -2
- package/scripts/deploy-ralph-swarm.sh +365 -0
- package/scripts/install-code-execution-hooks.sh +96 -0
- package/scripts/linear-task-review.js +1 -1
- package/scripts/ralph-integration-test.js +274 -0
- package/scripts/ralph-loop-implementation.js +404 -0
- package/scripts/swarm-monitor.js +509 -0
- package/scripts/sync-and-clean-tasks.js +1 -1
- package/scripts/sync-linear-graphql.js +3 -3
- package/scripts/sync-linear-tasks.js +1 -1
- package/scripts/test-code-execution.js +143 -0
- package/scripts/test-parallel-swarms.js +443 -0
- package/scripts/testing/ralph-cli-test.js +88 -0
- package/scripts/testing/ralph-integration-validation.js +727 -0
- package/scripts/testing/ralph-swarm-test-scenarios.js +613 -0
- package/scripts/update-linear-tasks-fixed.js +1 -1
- package/scripts/validate-railway-deployment.js +137 -0
- package/templates/claude-hooks/hook-config.json +59 -0
- package/templates/claude-hooks/pre-tool-use +189 -0
- package/dist/servers/railway/minimal.js +0 -91
- package/dist/servers/railway/minimal.js.map +0 -7
|
@@ -122,7 +122,7 @@ function registerUnifiedLinearCommands(parent) {
|
|
|
122
122
|
try {
|
|
123
123
|
const authManager = new LinearAuthManager(process.cwd());
|
|
124
124
|
const hasAuth = authManager.isConfigured();
|
|
125
|
-
if (!hasAuth && !process.env.LINEAR_API_KEY) {
|
|
125
|
+
if (!hasAuth && !process.env.STACKMEMORY_LINEAR_API_KEY && !process.env.LINEAR_API_KEY) {
|
|
126
126
|
console.log(chalk.yellow("\u26A0 Not connected to Linear"));
|
|
127
127
|
console.log('Run "stackmemory linear auth" to connect');
|
|
128
128
|
return;
|
|
@@ -248,9 +248,8 @@ function registerUnifiedLinearCommands(parent) {
|
|
|
248
248
|
});
|
|
249
249
|
linear.command("auth").description("Authenticate with Linear").option("--api-key <key>", "Use API key").option("--oauth", "Use OAuth flow").action(async (options) => {
|
|
250
250
|
try {
|
|
251
|
-
const authManager = new LinearAuthManager(process.cwd());
|
|
252
251
|
if (options.apiKey) {
|
|
253
|
-
process.env.
|
|
252
|
+
process.env.STACKMEMORY_LINEAR_API_KEY = options.apiKey;
|
|
254
253
|
console.log(chalk.green("\u2713 API key configured"));
|
|
255
254
|
const client = new LinearClient({ apiKey: options.apiKey });
|
|
256
255
|
const user = await client.getViewer();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/commands/linear-unified.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Unified Linear CLI Commands\n * Consolidates all Linear operations into a single, coherent interface\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport {\n UnifiedLinearSync,\n UnifiedSyncConfig,\n SyncStats,\n DEFAULT_UNIFIED_CONFIG,\n} from '../../integrations/linear/unified-sync.js';\nimport { LinearAuthManager } from '../../integrations/linear/auth.js';\nimport { LinearClient } from '../../integrations/linear/client.js';\nimport { LinearTaskManager } from '../../features/tasks/linear-task-manager.js';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync, readFileSync } from 'fs';\nimport { logger } from '../../core/monitoring/logger.js';\nimport Table from 'cli-table3';\nimport ora from 'ora';\n\nexport function registerUnifiedLinearCommands(parent: Command) {\n const linear = parent\n .command('linear')\n .description(\n 'Unified Linear integration with duplicate detection and task planning'\n );\n\n // Main sync command with all features\n linear\n .command('sync')\n .description(\n 'Intelligent sync with Linear (duplicate detection, bidirectional, task planning)'\n )\n .option(\n '-d, --direction <dir>',\n 'Sync direction: bidirectional, to_linear, from_linear',\n 'bidirectional'\n )\n .option('-t, --team <id>', 'Linear team ID')\n .option('--no-duplicates', 'Disable duplicate detection')\n .option(\n '--merge-strategy <strategy>',\n 'Duplicate handling: merge_content, skip, create_anyway',\n 'merge_content'\n )\n .option(\n '--conflict <resolution>',\n 'Conflict resolution: newest_wins, linear_wins, local_wins',\n 'newest_wins'\n )\n .option('--task-plan', 'Enable task planning integration')\n .option('--dry-run', 'Preview changes without syncing')\n .option('--daemon', 'Run as background daemon')\n .option('-i, --interval <minutes>', 'Auto-sync interval', '15')\n .option('--verbose', 'Show detailed sync progress')\n .action(async (options) => {\n const spinner = ora('Initializing Linear sync...').start();\n\n try {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n spinner.fail('StackMemory not initialized');\n console.log(chalk.yellow('Run \"stackmemory init\" first'));\n return;\n }\n\n // Initialize components\n const db = new Database(dbPath);\n const taskStore = new LinearTaskManager(projectRoot, db);\n const authManager = new LinearAuthManager(projectRoot);\n\n // Build config from options\n const config: Partial<UnifiedSyncConfig> = {\n direction: options.direction,\n defaultTeamId: options.team,\n duplicateDetection: options.duplicates !== false,\n mergeStrategy: options.mergeStrategy,\n conflictResolution: options.conflict,\n taskPlanningEnabled: options.taskPlan || false,\n };\n\n // Create unified sync instance\n const unifiedSync = new UnifiedLinearSync(\n taskStore,\n authManager,\n projectRoot,\n config\n );\n\n // Listen to events for progress\n if (options.verbose) {\n unifiedSync.on('sync:started', ({ config }) => {\n spinner.text = `Syncing (${config.direction})...`;\n });\n }\n\n // Initialize\n spinner.text = 'Authenticating with Linear...';\n await unifiedSync.initialize();\n\n if (options.dryRun) {\n spinner.info('Dry run mode - no changes will be made');\n // TODO: Implement dry run preview\n return;\n }\n\n if (options.daemon) {\n // Daemon mode\n spinner.succeed('Starting sync daemon');\n console.log(chalk.cyan(`Sync interval: ${options.interval} minutes`));\n console.log(chalk.gray('Press Ctrl+C to stop\\n'));\n\n // Initial sync\n const stats = await unifiedSync.sync();\n displaySyncStats(stats);\n\n // Schedule periodic syncs\n const interval = setInterval(\n async () => {\n console.log(\n chalk.yellow(\n `\\n[${new Date().toLocaleTimeString()}] Running scheduled sync...`\n )\n );\n try {\n const stats = await unifiedSync.sync();\n displaySyncStats(stats);\n } catch (error: unknown) {\n console.error(\n chalk.red('Sync failed:'),\n (error as Error).message\n );\n }\n },\n parseInt(options.interval) * 60 * 1000\n );\n\n // Handle graceful shutdown\n process.on('SIGINT', () => {\n console.log(chalk.yellow('\\nStopping sync daemon...'));\n clearInterval(interval);\n db.close();\n process.exit(0);\n });\n\n // Keep process alive\n process.stdin.resume();\n } else {\n // Single sync\n spinner.text = 'Syncing tasks...';\n const stats = await unifiedSync.sync();\n\n spinner.succeed('Sync completed');\n displaySyncStats(stats);\n\n // Show task plan if enabled\n if (options.taskPlan) {\n displayTaskPlan(projectRoot);\n }\n\n db.close();\n }\n } catch (error: unknown) {\n spinner.fail('Sync failed');\n console.error(chalk.red('Error:'), (error as Error).message);\n if (options.verbose) {\n console.error(error);\n }\n process.exit(1);\n }\n });\n\n // Quick status command\n linear\n .command('status')\n .description('Show Linear connection status and sync statistics')\n .action(async () => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n const hasAuth = authManager.isConfigured();\n\n if (!hasAuth && !process.env.LINEAR_API_KEY) {\n console.log(chalk.yellow('\u26A0 Not connected to Linear'));\n console.log('Run \"stackmemory linear auth\" to connect');\n return;\n }\n\n console.log(chalk.green('\u2713 Linear connection configured'));\n\n // Show last sync stats if available\n const statsFile = join(\n process.cwd(),\n '.stackmemory',\n 'sync-stats.json'\n );\n if (existsSync(statsFile)) {\n const stats = JSON.parse(readFileSync(statsFile, 'utf8'));\n console.log(chalk.cyan('\\nLast sync:'));\n console.log(` Time: ${new Date(stats.timestamp).toLocaleString()}`);\n console.log(` Duration: ${stats.duration}ms`);\n console.log(\n ` To Linear: ${stats.toLinear.created} created, ${stats.toLinear.updated} updated`\n );\n console.log(\n ` From Linear: ${stats.fromLinear.created} created, ${stats.fromLinear.updated} updated`\n );\n\n if (stats.toLinear.duplicatesMerged > 0) {\n console.log(\n chalk.green(\n ` Duplicates prevented: ${stats.toLinear.duplicatesMerged}`\n )\n );\n }\n }\n\n // Show task plan status\n const planFile = join(process.cwd(), '.stackmemory', 'task-plan.md');\n if (existsSync(planFile)) {\n console.log(chalk.cyan('\\n\u2713 Task planning enabled'));\n const reportFile = join(\n process.cwd(),\n '.stackmemory',\n 'task-report.md'\n );\n if (existsSync(reportFile)) {\n console.log(` Report: ${reportFile}`);\n }\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Status check failed:'),\n (error as Error).message\n );\n }\n });\n\n // Task planning command\n linear\n .command('plan')\n .description('View and manage task planning')\n .option('--generate', 'Generate task plan from current tasks')\n .option('--report', 'Show task report')\n .action(async (options) => {\n try {\n const projectRoot = process.cwd();\n\n if (options.generate) {\n console.log(chalk.yellow('Generating task plan...'));\n // Run sync with task planning enabled\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n const db = new Database(dbPath);\n const taskStore = new LinearTaskManager(projectRoot, db);\n const authManager = new LinearAuthManager(projectRoot);\n\n const unifiedSync = new UnifiedLinearSync(\n taskStore,\n authManager,\n projectRoot,\n {\n taskPlanningEnabled: true,\n autoCreateTaskPlan: true,\n }\n );\n\n await unifiedSync.initialize();\n await unifiedSync.sync();\n\n console.log(chalk.green('\u2713 Task plan generated'));\n db.close();\n }\n\n displayTaskPlan(projectRoot, options.report);\n } catch (error: unknown) {\n console.error(\n chalk.red('Plan generation failed:'),\n (error as Error).message\n );\n }\n });\n\n // Duplicate detection command\n linear\n .command('duplicates')\n .description('Check for and manage duplicate Linear issues')\n .option('--check <title>', 'Check if a title would create a duplicate')\n .option('--merge', 'Merge detected duplicates')\n .option('--list', 'List potential duplicates')\n .action(async (options) => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n const token = await authManager.getValidToken();\n\n if (!token) {\n console.log(chalk.red('Not authenticated with Linear'));\n return;\n }\n\n const client = new LinearClient({\n apiKey: token,\n useBearer: authManager.isOAuth(),\n });\n\n if (options.check) {\n // Import dynamically to avoid circular dependency\n const { LinearDuplicateDetector } =\n await import('../../integrations/linear/sync-enhanced.js');\n const detector = new LinearDuplicateDetector(client);\n\n console.log(\n chalk.yellow(`Checking for duplicates of: \"${options.check}\"`)\n );\n const result = await detector.checkForDuplicate(options.check);\n\n if (result.isDuplicate && result.existingIssue) {\n console.log(chalk.red('\u26A0 Duplicate detected!'));\n console.log(\n ` Issue: ${result.existingIssue.identifier} - ${result.existingIssue.title}`\n );\n console.log(\n ` Similarity: ${Math.round((result.similarity || 0) * 100)}%`\n );\n console.log(` URL: ${result.existingIssue.url}`);\n } else {\n console.log(chalk.green('\u2713 No duplicates found'));\n }\n } else if (options.list) {\n console.log(chalk.yellow('Scanning for potential duplicates...'));\n // TODO: Implement duplicate scanning\n console.log('Feature coming soon');\n } else {\n console.log('Specify --check, --merge, or --list');\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Duplicate check failed:'),\n (error as Error).message\n );\n }\n });\n\n // Auth command (simplified)\n linear\n .command('auth')\n .description('Authenticate with Linear')\n .option('--api-key <key>', 'Use API key')\n .option('--oauth', 'Use OAuth flow')\n .action(async (options) => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n\n if (options.apiKey) {\n // Simple API key setup\n process.env.LINEAR_API_KEY = options.apiKey;\n console.log(chalk.green('\u2713 API key configured'));\n\n // Test connection\n const client = new LinearClient({ apiKey: options.apiKey });\n const user = await client.getViewer();\n console.log(chalk.cyan(`Connected as: ${user.name} (${user.email})`));\n } else {\n console.log(chalk.cyan('Linear Authentication'));\n console.log('\\nOption 1: API Key (Recommended for automation)');\n console.log(' 1. Go to: https://linear.app/settings/api');\n console.log(' 2. Create a personal API key');\n console.log(' 3. Run: stackmemory linear auth --api-key YOUR_KEY');\n console.log('\\nOption 2: OAuth (For user-facing apps)');\n console.log(' Configure OAuth app and use linear-oauth-server');\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Authentication failed:'),\n (error as Error).message\n );\n }\n });\n}\n\n/**\n * Display sync statistics\n */\nfunction displaySyncStats(stats: SyncStats): void {\n const table = new Table({\n head: ['Direction', 'Created', 'Updated', 'Merged', 'Skipped'],\n style: { head: ['cyan'] },\n });\n\n table.push(\n [\n '\u2192 Linear',\n stats.toLinear.created,\n stats.toLinear.updated,\n stats.toLinear.duplicatesMerged,\n stats.toLinear.skipped,\n ],\n [\n '\u2190 Linear',\n stats.fromLinear.created,\n stats.fromLinear.updated,\n '-',\n stats.fromLinear.skipped,\n ]\n );\n\n console.log('\\n' + table.toString());\n\n if (stats.conflicts.length > 0) {\n console.log(chalk.yellow(`\\n\u26A0 Conflicts: ${stats.conflicts.length}`));\n stats.conflicts.slice(0, 5).forEach((c) => {\n console.log(` - ${c.reason}`);\n });\n }\n\n if (stats.errors.length > 0) {\n console.log(chalk.red(`\\n\u274C Errors: ${stats.errors.length}`));\n stats.errors.slice(0, 5).forEach((e: string) => {\n console.log(` - ${e.substring(0, 100)}`);\n });\n }\n\n console.log(chalk.gray(`\\nCompleted in ${stats.duration}ms`));\n}\n\n/**\n * Display task plan\n */\nfunction displayTaskPlan(projectRoot: string, showReport = false): void {\n const reportFile = join(projectRoot, '.stackmemory', 'task-report.md');\n const planFile = join(projectRoot, '.stackmemory', 'task-plan.json');\n\n if (showReport && existsSync(reportFile)) {\n const report = readFileSync(reportFile, 'utf8');\n console.log('\\n' + report);\n } else if (existsSync(planFile)) {\n const plan = JSON.parse(readFileSync(planFile, 'utf8'));\n\n console.log(chalk.cyan('\\n\uD83D\uDCCB Task Plan Overview'));\n console.log(\n `Last updated: ${new Date(plan.lastUpdated).toLocaleString()}\\n`\n );\n\n plan.phases.forEach((phase) => {\n console.log(chalk.yellow(`${phase.name} (${phase.tasks.length})`));\n console.log(chalk.gray(` ${phase.description}`));\n\n if (phase.tasks.length > 0) {\n phase.tasks.slice(0, 5).forEach((task) => {\n const status = task.linearId ? '\uD83D\uDD17' : ' ';\n console.log(` ${status} ${task.title}`);\n });\n\n if (phase.tasks.length > 5) {\n console.log(chalk.gray(` ...and ${phase.tasks.length - 5} more`));\n }\n }\n console.log();\n });\n } else {\n console.log(\n chalk.yellow('No task plan found. Run sync with --task-plan to generate.')\n );\n }\n}\n"],
|
|
5
|
-
"mappings": "AAMA,OAAO,WAAW;AAClB;AAAA,EACE;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * Unified Linear CLI Commands\n * Consolidates all Linear operations into a single, coherent interface\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport {\n UnifiedLinearSync,\n UnifiedSyncConfig,\n SyncStats,\n} from '../../integrations/linear/unified-sync.js';\nimport { LinearAuthManager } from '../../integrations/linear/auth.js';\nimport { LinearClient } from '../../integrations/linear/client.js';\nimport { LinearTaskManager } from '../../features/tasks/linear-task-manager.js';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync, readFileSync } from 'fs';\n// import { logger } from '../../core/monitoring/logger.js';\nimport Table from 'cli-table3';\nimport ora from 'ora';\n\nexport function registerUnifiedLinearCommands(parent: Command) {\n const linear = parent\n .command('linear')\n .description(\n 'Unified Linear integration with duplicate detection and task planning'\n );\n\n // Main sync command with all features\n linear\n .command('sync')\n .description(\n 'Intelligent sync with Linear (duplicate detection, bidirectional, task planning)'\n )\n .option(\n '-d, --direction <dir>',\n 'Sync direction: bidirectional, to_linear, from_linear',\n 'bidirectional'\n )\n .option('-t, --team <id>', 'Linear team ID')\n .option('--no-duplicates', 'Disable duplicate detection')\n .option(\n '--merge-strategy <strategy>',\n 'Duplicate handling: merge_content, skip, create_anyway',\n 'merge_content'\n )\n .option(\n '--conflict <resolution>',\n 'Conflict resolution: newest_wins, linear_wins, local_wins',\n 'newest_wins'\n )\n .option('--task-plan', 'Enable task planning integration')\n .option('--dry-run', 'Preview changes without syncing')\n .option('--daemon', 'Run as background daemon')\n .option('-i, --interval <minutes>', 'Auto-sync interval', '15')\n .option('--verbose', 'Show detailed sync progress')\n .action(async (options) => {\n const spinner = ora('Initializing Linear sync...').start();\n\n try {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n spinner.fail('StackMemory not initialized');\n console.log(chalk.yellow('Run \"stackmemory init\" first'));\n return;\n }\n\n // Initialize components\n const db = new Database(dbPath);\n const taskStore = new LinearTaskManager(projectRoot, db);\n const authManager = new LinearAuthManager(projectRoot);\n\n // Build config from options\n const config: Partial<UnifiedSyncConfig> = {\n direction: options.direction,\n defaultTeamId: options.team,\n duplicateDetection: options.duplicates !== false,\n mergeStrategy: options.mergeStrategy,\n conflictResolution: options.conflict,\n taskPlanningEnabled: options.taskPlan || false,\n };\n\n // Create unified sync instance\n const unifiedSync = new UnifiedLinearSync(\n taskStore,\n authManager,\n projectRoot,\n config\n );\n\n // Listen to events for progress\n if (options.verbose) {\n unifiedSync.on('sync:started', ({ config }) => {\n spinner.text = `Syncing (${config.direction})...`;\n });\n }\n\n // Initialize\n spinner.text = 'Authenticating with Linear...';\n await unifiedSync.initialize();\n\n if (options.dryRun) {\n spinner.info('Dry run mode - no changes will be made');\n // TODO: Implement dry run preview\n return;\n }\n\n if (options.daemon) {\n // Daemon mode\n spinner.succeed('Starting sync daemon');\n console.log(chalk.cyan(`Sync interval: ${options.interval} minutes`));\n console.log(chalk.gray('Press Ctrl+C to stop\\n'));\n\n // Initial sync\n const stats = await unifiedSync.sync();\n displaySyncStats(stats);\n\n // Schedule periodic syncs\n const interval = setInterval(\n async () => {\n console.log(\n chalk.yellow(\n `\\n[${new Date().toLocaleTimeString()}] Running scheduled sync...`\n )\n );\n try {\n const stats = await unifiedSync.sync();\n displaySyncStats(stats);\n } catch (error: unknown) {\n console.error(\n chalk.red('Sync failed:'),\n (error as Error).message\n );\n }\n },\n parseInt(options.interval) * 60 * 1000\n );\n\n // Handle graceful shutdown\n process.on('SIGINT', () => {\n console.log(chalk.yellow('\\nStopping sync daemon...'));\n clearInterval(interval);\n db.close();\n process.exit(0);\n });\n\n // Keep process alive\n process.stdin.resume();\n } else {\n // Single sync\n spinner.text = 'Syncing tasks...';\n const stats = await unifiedSync.sync();\n\n spinner.succeed('Sync completed');\n displaySyncStats(stats);\n\n // Show task plan if enabled\n if (options.taskPlan) {\n displayTaskPlan(projectRoot);\n }\n\n db.close();\n }\n } catch (error: unknown) {\n spinner.fail('Sync failed');\n console.error(chalk.red('Error:'), (error as Error).message);\n if (options.verbose) {\n console.error(error);\n }\n process.exit(1);\n }\n });\n\n // Quick status command\n linear\n .command('status')\n .description('Show Linear connection status and sync statistics')\n .action(async () => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n const hasAuth = authManager.isConfigured();\n\n if (!hasAuth && !process.env.STACKMEMORY_LINEAR_API_KEY && !process.env.LINEAR_API_KEY) {\n console.log(chalk.yellow('\u26A0 Not connected to Linear'));\n console.log('Run \"stackmemory linear auth\" to connect');\n return;\n }\n\n console.log(chalk.green('\u2713 Linear connection configured'));\n\n // Show last sync stats if available\n const statsFile = join(\n process.cwd(),\n '.stackmemory',\n 'sync-stats.json'\n );\n if (existsSync(statsFile)) {\n const stats = JSON.parse(readFileSync(statsFile, 'utf8'));\n console.log(chalk.cyan('\\nLast sync:'));\n console.log(` Time: ${new Date(stats.timestamp).toLocaleString()}`);\n console.log(` Duration: ${stats.duration}ms`);\n console.log(\n ` To Linear: ${stats.toLinear.created} created, ${stats.toLinear.updated} updated`\n );\n console.log(\n ` From Linear: ${stats.fromLinear.created} created, ${stats.fromLinear.updated} updated`\n );\n\n if (stats.toLinear.duplicatesMerged > 0) {\n console.log(\n chalk.green(\n ` Duplicates prevented: ${stats.toLinear.duplicatesMerged}`\n )\n );\n }\n }\n\n // Show task plan status\n const planFile = join(process.cwd(), '.stackmemory', 'task-plan.md');\n if (existsSync(planFile)) {\n console.log(chalk.cyan('\\n\u2713 Task planning enabled'));\n const reportFile = join(\n process.cwd(),\n '.stackmemory',\n 'task-report.md'\n );\n if (existsSync(reportFile)) {\n console.log(` Report: ${reportFile}`);\n }\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Status check failed:'),\n (error as Error).message\n );\n }\n });\n\n // Task planning command\n linear\n .command('plan')\n .description('View and manage task planning')\n .option('--generate', 'Generate task plan from current tasks')\n .option('--report', 'Show task report')\n .action(async (options) => {\n try {\n const projectRoot = process.cwd();\n\n if (options.generate) {\n console.log(chalk.yellow('Generating task plan...'));\n // Run sync with task planning enabled\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n const db = new Database(dbPath);\n const taskStore = new LinearTaskManager(projectRoot, db);\n const authManager = new LinearAuthManager(projectRoot);\n\n const unifiedSync = new UnifiedLinearSync(\n taskStore,\n authManager,\n projectRoot,\n {\n taskPlanningEnabled: true,\n autoCreateTaskPlan: true,\n }\n );\n\n await unifiedSync.initialize();\n await unifiedSync.sync();\n\n console.log(chalk.green('\u2713 Task plan generated'));\n db.close();\n }\n\n displayTaskPlan(projectRoot, options.report);\n } catch (error: unknown) {\n console.error(\n chalk.red('Plan generation failed:'),\n (error as Error).message\n );\n }\n });\n\n // Duplicate detection command\n linear\n .command('duplicates')\n .description('Check for and manage duplicate Linear issues')\n .option('--check <title>', 'Check if a title would create a duplicate')\n .option('--merge', 'Merge detected duplicates')\n .option('--list', 'List potential duplicates')\n .action(async (options) => {\n try {\n const authManager = new LinearAuthManager(process.cwd());\n const token = await authManager.getValidToken();\n\n if (!token) {\n console.log(chalk.red('Not authenticated with Linear'));\n return;\n }\n\n const client = new LinearClient({\n apiKey: token,\n useBearer: authManager.isOAuth(),\n });\n\n if (options.check) {\n // Import dynamically to avoid circular dependency\n const { LinearDuplicateDetector } =\n await import('../../integrations/linear/sync-enhanced.js');\n const detector = new LinearDuplicateDetector(client);\n\n console.log(\n chalk.yellow(`Checking for duplicates of: \"${options.check}\"`)\n );\n const result = await detector.checkForDuplicate(options.check);\n\n if (result.isDuplicate && result.existingIssue) {\n console.log(chalk.red('\u26A0 Duplicate detected!'));\n console.log(\n ` Issue: ${result.existingIssue.identifier} - ${result.existingIssue.title}`\n );\n console.log(\n ` Similarity: ${Math.round((result.similarity || 0) * 100)}%`\n );\n console.log(` URL: ${result.existingIssue.url}`);\n } else {\n console.log(chalk.green('\u2713 No duplicates found'));\n }\n } else if (options.list) {\n console.log(chalk.yellow('Scanning for potential duplicates...'));\n // TODO: Implement duplicate scanning\n console.log('Feature coming soon');\n } else {\n console.log('Specify --check, --merge, or --list');\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Duplicate check failed:'),\n (error as Error).message\n );\n }\n });\n\n // Auth command (simplified)\n linear\n .command('auth')\n .description('Authenticate with Linear')\n .option('--api-key <key>', 'Use API key')\n .option('--oauth', 'Use OAuth flow')\n .action(async (options) => {\n try {\n // const authManager = new LinearAuthManager(process.cwd());\n\n if (options.apiKey) {\n // Simple API key setup\n process.env.STACKMEMORY_LINEAR_API_KEY = options.apiKey;\n console.log(chalk.green('\u2713 API key configured'));\n\n // Test connection\n const client = new LinearClient({ apiKey: options.apiKey });\n const user = await client.getViewer();\n console.log(chalk.cyan(`Connected as: ${user.name} (${user.email})`));\n } else {\n console.log(chalk.cyan('Linear Authentication'));\n console.log('\\nOption 1: API Key (Recommended for automation)');\n console.log(' 1. Go to: https://linear.app/settings/api');\n console.log(' 2. Create a personal API key');\n console.log(' 3. Run: stackmemory linear auth --api-key YOUR_KEY');\n console.log('\\nOption 2: OAuth (For user-facing apps)');\n console.log(' Configure OAuth app and use linear-oauth-server');\n }\n } catch (error: unknown) {\n console.error(\n chalk.red('Authentication failed:'),\n (error as Error).message\n );\n }\n });\n}\n\n/**\n * Display sync statistics\n */\nfunction displaySyncStats(stats: SyncStats): void {\n const table = new Table({\n head: ['Direction', 'Created', 'Updated', 'Merged', 'Skipped'],\n style: { head: ['cyan'] },\n });\n\n table.push(\n [\n '\u2192 Linear',\n stats.toLinear.created,\n stats.toLinear.updated,\n stats.toLinear.duplicatesMerged,\n stats.toLinear.skipped,\n ],\n [\n '\u2190 Linear',\n stats.fromLinear.created,\n stats.fromLinear.updated,\n '-',\n stats.fromLinear.skipped,\n ]\n );\n\n console.log('\\n' + table.toString());\n\n if (stats.conflicts.length > 0) {\n console.log(chalk.yellow(`\\n\u26A0 Conflicts: ${stats.conflicts.length}`));\n stats.conflicts.slice(0, 5).forEach((c) => {\n console.log(` - ${c.reason}`);\n });\n }\n\n if (stats.errors.length > 0) {\n console.log(chalk.red(`\\n\u274C Errors: ${stats.errors.length}`));\n stats.errors.slice(0, 5).forEach((e: string) => {\n console.log(` - ${e.substring(0, 100)}`);\n });\n }\n\n console.log(chalk.gray(`\\nCompleted in ${stats.duration}ms`));\n}\n\n/**\n * Display task plan\n */\nfunction displayTaskPlan(projectRoot: string, showReport = false): void {\n const reportFile = join(projectRoot, '.stackmemory', 'task-report.md');\n const planFile = join(projectRoot, '.stackmemory', 'task-plan.json');\n\n if (showReport && existsSync(reportFile)) {\n const report = readFileSync(reportFile, 'utf8');\n console.log('\\n' + report);\n } else if (existsSync(planFile)) {\n const plan = JSON.parse(readFileSync(planFile, 'utf8'));\n\n console.log(chalk.cyan('\\n\uD83D\uDCCB Task Plan Overview'));\n console.log(\n `Last updated: ${new Date(plan.lastUpdated).toLocaleString()}\\n`\n );\n\n plan.phases.forEach((phase) => {\n console.log(chalk.yellow(`${phase.name} (${phase.tasks.length})`));\n console.log(chalk.gray(` ${phase.description}`));\n\n if (phase.tasks.length > 0) {\n phase.tasks.slice(0, 5).forEach((task) => {\n const status = task.linearId ? '\uD83D\uDD17' : ' ';\n console.log(` ${status} ${task.title}`);\n });\n\n if (phase.tasks.length > 5) {\n console.log(chalk.gray(` ...and ${phase.tasks.length - 5} more`));\n }\n }\n console.log();\n });\n } else {\n console.log(\n chalk.yellow('No task plan found. Run sync with --task-plan to generate.')\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "AAMA,OAAO,WAAW;AAClB;AAAA,EACE;AAAA,OAGK;AACP,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,OAAO,cAAc;AACrB,SAAS,YAAY;AACrB,SAAS,YAAY,oBAAoB;AAEzC,OAAO,WAAW;AAClB,OAAO,SAAS;AAET,SAAS,8BAA8B,QAAiB;AAC7D,QAAM,SAAS,OACZ,QAAQ,QAAQ,EAChB;AAAA,IACC;AAAA,EACF;AAGF,SACG,QAAQ,MAAM,EACd;AAAA,IACC;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC,OAAO,mBAAmB,gBAAgB,EAC1C,OAAO,mBAAmB,6BAA6B,EACvD;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC,OAAO,eAAe,kCAAkC,EACxD,OAAO,aAAa,iCAAiC,EACrD,OAAO,YAAY,0BAA0B,EAC7C,OAAO,4BAA4B,sBAAsB,IAAI,EAC7D,OAAO,aAAa,6BAA6B,EACjD,OAAO,OAAO,YAAY;AACzB,UAAM,UAAU,IAAI,6BAA6B,EAAE,MAAM;AAEzD,QAAI;AACF,YAAM,cAAc,QAAQ,IAAI;AAChC,YAAM,SAAS,KAAK,aAAa,gBAAgB,YAAY;AAE7D,UAAI,CAAC,WAAW,MAAM,GAAG;AACvB,gBAAQ,KAAK,6BAA6B;AAC1C,gBAAQ,IAAI,MAAM,OAAO,8BAA8B,CAAC;AACxD;AAAA,MACF;AAGA,YAAM,KAAK,IAAI,SAAS,MAAM;AAC9B,YAAM,YAAY,IAAI,kBAAkB,aAAa,EAAE;AACvD,YAAM,cAAc,IAAI,kBAAkB,WAAW;AAGrD,YA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
|
|
3
|
+
import { RalphLoop } from "../../../scripts/ralph-loop-implementation.js";
|
|
4
|
+
import { stackMemoryContextLoader } from "../../integrations/ralph/context/stackmemory-context-loader.js";
|
|
5
|
+
import { patternLearner } from "../../integrations/ralph/learning/pattern-learner.js";
|
|
6
|
+
import { multiLoopOrchestrator } from "../../integrations/ralph/orchestration/multi-loop-orchestrator.js";
|
|
7
|
+
import { swarmCoordinator } from "../../integrations/ralph/swarm/swarm-coordinator.js";
|
|
8
|
+
import { ralphDebugger } from "../../integrations/ralph/visualization/ralph-debugger.js";
|
|
9
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
10
|
+
import { trace } from "../../core/trace/index.js";
|
|
11
|
+
function createRalphCommand() {
|
|
12
|
+
const ralph = new Command("ralph").description("Ralph Wiggum Loop integration with StackMemory");
|
|
13
|
+
ralph.command("init").description("Initialize a new Ralph Wiggum loop").argument("<task>", "Task description").option("-c, --criteria <criteria>", "Completion criteria (comma separated)").option("--max-iterations <n>", "Maximum iterations", "50").option("--use-context", "Load relevant context from StackMemory").option("--learn-from-similar", "Apply patterns from similar completed tasks").action(async (task, options) => {
|
|
14
|
+
return trace.command("ralph-init", { task, ...options }, async () => {
|
|
15
|
+
try {
|
|
16
|
+
console.log("\u{1F3AD} Initializing Ralph Wiggum loop...");
|
|
17
|
+
const loop = new RalphLoop({
|
|
18
|
+
baseDir: ".ralph",
|
|
19
|
+
maxIterations: parseInt(options.maxIterations),
|
|
20
|
+
verbose: true
|
|
21
|
+
});
|
|
22
|
+
const criteria = options.criteria ? options.criteria.split(",").map((c) => `- ${c.trim()}`).join("\n") : "- All tests pass\n- Code works correctly\n- No lint errors";
|
|
23
|
+
let enhancedTask = task;
|
|
24
|
+
if (options.useContext || options.learnFromSimilar) {
|
|
25
|
+
try {
|
|
26
|
+
await stackMemoryContextLoader.initialize();
|
|
27
|
+
const contextResponse = await stackMemoryContextLoader.loadInitialContext({
|
|
28
|
+
task,
|
|
29
|
+
usePatterns: true,
|
|
30
|
+
useSimilarTasks: options.learnFromSimilar,
|
|
31
|
+
maxTokens: 3e3
|
|
32
|
+
});
|
|
33
|
+
if (contextResponse.context) {
|
|
34
|
+
enhancedTask = `${task}
|
|
35
|
+
|
|
36
|
+
${contextResponse.context}`;
|
|
37
|
+
console.log(`\u{1F4DA} Loaded context from ${contextResponse.sources.length} sources`);
|
|
38
|
+
console.log(`\u{1F3AF} Context tokens: ${contextResponse.metadata.totalTokens}`);
|
|
39
|
+
}
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.log(`\u26A0\uFE0F Context loading failed: ${error.message}`);
|
|
42
|
+
console.log("Proceeding without context...");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
await loop.initialize(enhancedTask, criteria);
|
|
46
|
+
console.log("\u2705 Ralph loop initialized!");
|
|
47
|
+
console.log(`\u{1F4CB} Task: ${task}`);
|
|
48
|
+
console.log(`\u{1F3AF} Max iterations: ${options.maxIterations}`);
|
|
49
|
+
console.log(`\u{1F4C1} Loop directory: .ralph/`);
|
|
50
|
+
console.log("\nNext steps:");
|
|
51
|
+
console.log(" stackmemory ralph run # Start the loop");
|
|
52
|
+
console.log(" stackmemory ralph status # Check status");
|
|
53
|
+
} catch (error) {
|
|
54
|
+
logger.error("Failed to initialize Ralph loop", error);
|
|
55
|
+
console.error("\u274C Initialization failed:", error.message);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
ralph.command("run").description("Run the Ralph Wiggum loop").option("--verbose", "Verbose output").option("--pause-on-error", "Pause on validation errors").action(async (options) => {
|
|
61
|
+
return trace.command("ralph-run", options, async () => {
|
|
62
|
+
try {
|
|
63
|
+
if (!existsSync(".ralph")) {
|
|
64
|
+
console.error('\u274C No Ralph loop found. Run "stackmemory ralph init" first.');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
console.log("\u{1F3AD} Starting Ralph Wiggum loop...");
|
|
68
|
+
const loop = new RalphLoop({
|
|
69
|
+
baseDir: ".ralph",
|
|
70
|
+
verbose: options.verbose
|
|
71
|
+
});
|
|
72
|
+
await loop.run();
|
|
73
|
+
} catch (error) {
|
|
74
|
+
logger.error("Failed to run Ralph loop", error);
|
|
75
|
+
console.error("\u274C Loop execution failed:", error.message);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
ralph.command("status").description("Show current Ralph loop status").option("--detailed", "Show detailed iteration history").action(async (options) => {
|
|
81
|
+
return trace.command("ralph-status", options, async () => {
|
|
82
|
+
try {
|
|
83
|
+
if (!existsSync(".ralph")) {
|
|
84
|
+
console.log("\u274C No Ralph loop found in current directory");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const task = readFileSync(".ralph/task.md", "utf8");
|
|
88
|
+
const iteration = parseInt(readFileSync(".ralph/iteration.txt", "utf8") || "0");
|
|
89
|
+
const isComplete = existsSync(".ralph/work-complete.txt");
|
|
90
|
+
const feedback = existsSync(".ralph/feedback.txt") ? readFileSync(".ralph/feedback.txt", "utf8") : "";
|
|
91
|
+
console.log("\u{1F3AD} Ralph Loop Status:");
|
|
92
|
+
console.log(` Task: ${task.substring(0, 80)}...`);
|
|
93
|
+
console.log(` Iteration: ${iteration}`);
|
|
94
|
+
console.log(` Status: ${isComplete ? "\u2705 COMPLETE" : "\u{1F504} IN PROGRESS"}`);
|
|
95
|
+
if (feedback) {
|
|
96
|
+
console.log(` Last feedback: ${feedback.substring(0, 100)}...`);
|
|
97
|
+
}
|
|
98
|
+
if (options.detailed && existsSync(".ralph/progress.jsonl")) {
|
|
99
|
+
console.log("\n\u{1F4CA} Iteration History:");
|
|
100
|
+
const progressLines = readFileSync(".ralph/progress.jsonl", "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line));
|
|
101
|
+
progressLines.forEach((p) => {
|
|
102
|
+
const progress = p;
|
|
103
|
+
const status = progress.validation?.testsPass ? "\u2705" : "\u274C";
|
|
104
|
+
console.log(` ${progress.iteration}: ${status} ${progress.changes} changes, ${progress.errors} errors`);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
} catch (error) {
|
|
108
|
+
logger.error("Failed to get Ralph status", error);
|
|
109
|
+
console.error("\u274C Status check failed:", error.message);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
ralph.command("resume").description("Resume a crashed or paused Ralph loop").option("--from-stackmemory", "Restore from StackMemory backup").action(async (options) => {
|
|
114
|
+
return trace.command("ralph-resume", options, async () => {
|
|
115
|
+
try {
|
|
116
|
+
console.log("\u{1F504} Resuming Ralph loop...");
|
|
117
|
+
const loop = new RalphLoop({ baseDir: ".ralph", verbose: true });
|
|
118
|
+
if (options.fromStackmemory) {
|
|
119
|
+
console.log("\u{1F4DA} StackMemory restore feature coming soon...");
|
|
120
|
+
}
|
|
121
|
+
await loop.run();
|
|
122
|
+
} catch (error) {
|
|
123
|
+
logger.error("Failed to resume Ralph loop", error);
|
|
124
|
+
console.error("\u274C Resume failed:", error.message);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
ralph.command("stop").description("Stop the current Ralph loop").option("--save-progress", "Save current progress to StackMemory").action(async (options) => {
|
|
130
|
+
return trace.command("ralph-stop", options, async () => {
|
|
131
|
+
try {
|
|
132
|
+
if (!existsSync(".ralph")) {
|
|
133
|
+
console.log("\u274C No active Ralph loop found");
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
console.log("\u{1F6D1} Stopping Ralph loop...");
|
|
137
|
+
if (options.saveProgress) {
|
|
138
|
+
console.log("\u{1F4BE} StackMemory progress save feature coming soon...");
|
|
139
|
+
}
|
|
140
|
+
writeFileSync(".ralph/stop-signal.txt", (/* @__PURE__ */ new Date()).toISOString());
|
|
141
|
+
console.log("\u2705 Stop signal sent");
|
|
142
|
+
} catch (error) {
|
|
143
|
+
logger.error("Failed to stop Ralph loop", error);
|
|
144
|
+
console.error("\u274C Stop failed:", error.message);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
ralph.command("clean").description("Clean up Ralph loop artifacts").option("--keep-history", "Keep iteration history").action(async (options) => {
|
|
149
|
+
return trace.command("ralph-clean", options, async () => {
|
|
150
|
+
try {
|
|
151
|
+
if (!options.keepHistory && existsSync(".ralph/history")) {
|
|
152
|
+
const { execSync } = await import("child_process");
|
|
153
|
+
execSync("rm -rf .ralph/history");
|
|
154
|
+
}
|
|
155
|
+
if (existsSync(".ralph/work-complete.txt")) {
|
|
156
|
+
const fs = await import("fs");
|
|
157
|
+
fs.unlinkSync(".ralph/work-complete.txt");
|
|
158
|
+
}
|
|
159
|
+
console.log("\u{1F9F9} Ralph loop artifacts cleaned");
|
|
160
|
+
} catch (error) {
|
|
161
|
+
logger.error("Failed to clean Ralph artifacts", error);
|
|
162
|
+
console.error("\u274C Cleanup failed:", error.message);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
ralph.command("debug").description("Debug Ralph loop state and diagnostics").option("--reconcile", "Force state reconciliation").option("--validate-context", "Validate context budget").action(async (options) => {
|
|
167
|
+
return trace.command("ralph-debug", options, async () => {
|
|
168
|
+
try {
|
|
169
|
+
console.log("\u{1F50D} Ralph Loop Debug Information:");
|
|
170
|
+
if (options.reconcile) {
|
|
171
|
+
console.log("\u{1F527} State reconciliation feature coming soon...");
|
|
172
|
+
}
|
|
173
|
+
if (options.validateContext) {
|
|
174
|
+
console.log("\u{1F4CA} Context validation feature coming soon...");
|
|
175
|
+
}
|
|
176
|
+
if (existsSync(".ralph")) {
|
|
177
|
+
console.log("\n\u{1F4C1} Ralph directory structure:");
|
|
178
|
+
const { execSync } = await import("child_process");
|
|
179
|
+
try {
|
|
180
|
+
const tree = execSync("find .ralph -type f | head -20", { encoding: "utf8" });
|
|
181
|
+
console.log(tree);
|
|
182
|
+
} catch {
|
|
183
|
+
console.log(" (Unable to show directory tree)");
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
} catch (error) {
|
|
187
|
+
logger.error("Ralph debug failed", error);
|
|
188
|
+
console.error("\u274C Debug failed:", error.message);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
ralph.command("swarm").description("Launch a swarm of specialized agents").argument("<project>", "Project description").option("--agents <agents>", "Comma-separated list of agent roles (architect,developer,tester,etc)", "developer,tester").option("--max-agents <n>", "Maximum number of agents", "5").action(async (project, options) => {
|
|
193
|
+
return trace.command("ralph-swarm", { project, ...options }, async () => {
|
|
194
|
+
try {
|
|
195
|
+
console.log("\u{1F9BE} Launching Ralph swarm...");
|
|
196
|
+
await swarmCoordinator.initialize();
|
|
197
|
+
const agentRoles = options.agents.split(",").map((r) => r.trim());
|
|
198
|
+
const agentSpecs = agentRoles.map((role) => ({
|
|
199
|
+
role,
|
|
200
|
+
conflictResolution: "defer_to_expertise",
|
|
201
|
+
collaborationPreferences: []
|
|
202
|
+
}));
|
|
203
|
+
const swarmId = await swarmCoordinator.launchSwarm(project, agentSpecs);
|
|
204
|
+
console.log(`\u2705 Swarm launched with ID: ${swarmId}`);
|
|
205
|
+
console.log(`\u{1F465} ${agentSpecs.length} agents working on: ${project}`);
|
|
206
|
+
console.log("\nNext steps:");
|
|
207
|
+
console.log(" stackmemory ralph swarm-status <swarmId> # Check progress");
|
|
208
|
+
console.log(" stackmemory ralph swarm-stop <swarmId> # Stop swarm");
|
|
209
|
+
} catch (error) {
|
|
210
|
+
logger.error("Swarm launch failed", error);
|
|
211
|
+
console.error("\u274C Swarm launch failed:", error.message);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
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("ralph-orchestrate", { description, ...options }, async () => {
|
|
217
|
+
try {
|
|
218
|
+
console.log("\u{1F3AD} Orchestrating complex task...");
|
|
219
|
+
await multiLoopOrchestrator.initialize();
|
|
220
|
+
const criteria = options.criteria ? options.criteria.split(",").map((c) => c.trim()) : ["Task completed successfully", "All components working", "Tests pass"];
|
|
221
|
+
const result = await multiLoopOrchestrator.orchestrateComplexTask(
|
|
222
|
+
description,
|
|
223
|
+
criteria,
|
|
224
|
+
{
|
|
225
|
+
maxLoops: parseInt(options.maxLoops),
|
|
226
|
+
forceSequential: options.sequential
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
console.log("\u2705 Orchestration completed!");
|
|
230
|
+
console.log(`\u{1F4CA} Results: ${result.completedLoops.length} successful, ${result.failedLoops.length} failed`);
|
|
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}`));
|
|
235
|
+
}
|
|
236
|
+
} catch (error) {
|
|
237
|
+
logger.error("Orchestration failed", error);
|
|
238
|
+
console.error("\u274C Orchestration failed:", error.message);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
ralph.command("learn").description("Learn patterns from completed loops").option("--task-type <type>", "Learn patterns for specific task type").action(async (options) => {
|
|
243
|
+
return trace.command("ralph-learn", options, async () => {
|
|
244
|
+
try {
|
|
245
|
+
console.log("\u{1F9E0} Learning patterns from completed loops...");
|
|
246
|
+
await patternLearner.initialize();
|
|
247
|
+
const patterns = options.taskType ? await patternLearner.learnForTaskType(options.taskType) : await patternLearner.learnFromCompletedLoops();
|
|
248
|
+
console.log(`\u2705 Learned ${patterns.length} patterns`);
|
|
249
|
+
if (patterns.length > 0) {
|
|
250
|
+
console.log("\n\u{1F4CA} Top patterns:");
|
|
251
|
+
patterns.slice(0, 5).forEach((pattern) => {
|
|
252
|
+
console.log(` \u2022 ${pattern.pattern} (${Math.round(pattern.confidence * 100)}% confidence)`);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
} catch (error) {
|
|
256
|
+
logger.error("Pattern learning failed", error);
|
|
257
|
+
console.error("\u274C Pattern learning failed:", error.message);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
ralph.command("debug-enhanced").description("Advanced debugging with visualization").option("--loop-id <id>", "Specific loop to debug").option("--generate-report", "Generate comprehensive debug report").option("--timeline", "Generate timeline visualization").action(async (options) => {
|
|
262
|
+
return trace.command("ralph-debug-enhanced", options, async () => {
|
|
263
|
+
try {
|
|
264
|
+
if (!existsSync(".ralph") && !options.loopId) {
|
|
265
|
+
console.log("\u274C No Ralph loop found. Run a loop first or specify --loop-id");
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
console.log("\u{1F50D} Starting enhanced debugging...");
|
|
269
|
+
await ralphDebugger.initialize();
|
|
270
|
+
const loopId = options.loopId || "current";
|
|
271
|
+
const debugSession = await ralphDebugger.startDebugSession(loopId, ".ralph");
|
|
272
|
+
if (options.generateReport) {
|
|
273
|
+
const report = await ralphDebugger.generateDebugReport(loopId);
|
|
274
|
+
console.log(`\u{1F4CB} Debug report generated: ${report.exportPath}`);
|
|
275
|
+
}
|
|
276
|
+
if (options.timeline) {
|
|
277
|
+
const timelinePath = await ralphDebugger.generateLoopTimeline(loopId);
|
|
278
|
+
console.log(`\u{1F4CA} Timeline visualization: ${timelinePath}`);
|
|
279
|
+
}
|
|
280
|
+
console.log("\u{1F50D} Debug analysis complete");
|
|
281
|
+
} catch (error) {
|
|
282
|
+
logger.error("Enhanced debugging failed", error);
|
|
283
|
+
console.error("\u274C Debug failed:", error.message);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
return ralph;
|
|
288
|
+
}
|
|
289
|
+
var ralph_default = createRalphCommand;
|
|
290
|
+
export {
|
|
291
|
+
createRalphCommand,
|
|
292
|
+
ralph_default as default
|
|
293
|
+
};
|
|
294
|
+
//# sourceMappingURL=ralph.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 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,EAC9B,YAAY,gDAAgD;AAG/D,QACG,QAAQ,MAAM,EACd,YAAY,oCAAoC,EAChD,SAAS,UAAU,kBAAkB,EACrC,OAAO,6BAA6B,uCAAuC,EAC3E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AO,cAAc,iCAAiC,EACtD,OAAO,OAAO,YAAY;AACzB,WAAO,MAAM,QAAQ,wBAAwB,SAAS,YAAY;AAChE,UAAI;AACF,YAAI,CAAC,WAAW,QAAQ,KAAK,CAAC,QAAQ,QAAQ;AAC5C,kBAAQ,IAAI,mEAA8D;AAC1E;AAAA,QACF;AAEA,gBAAQ,IAAI,0CAAmC;AAE/C,cAAM,cAAc,WAAW;AAE/B,cAAM,SAAS,QAAQ,UAAU;AACjC,cAAM,eAAe,MAAM,cAAc,kBAAkB,QAAQ,QAAQ;AAE3E,YAAI,QAAQ,gBAAgB;AAC1B,gBAAM,SAAS,MAAM,cAAc,oBAAoB,MAAM;AAC7D,kBAAQ,IAAI,qCAA8B,OAAO,UAAU,EAAE;AAAA,QAC/D;AAEA,YAAI,QAAQ,UAAU;AACpB,gBAAM,eAAe,MAAM,cAAc,qBAAqB,MAAM;AACpE,kBAAQ,IAAI,qCAA8B,YAAY,EAAE;AAAA,QAC1D;AAEA,gBAAQ,IAAI,mCAA4B;AAAA,MAE1C,SAAS,OAAgB;AACvB,eAAO,MAAM,6BAA6B,KAAc;AACxD,gBAAQ,MAAM,wBAAoB,MAAgB,OAAO;AAAA,MAC3D;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAEH,SAAO;AACT;AAEA,IAAO,gBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/commands/tasks.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Enhanced Task Commands for StackMemory CLI\n * Provides task management directly from command line\n */\n\nimport { Command } from 'commander';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync } from 'fs';\nimport {\n LinearTaskManager,\n TaskPriority,\n} from '../../features/tasks/linear-task-manager.js';\n\nfunction getTaskStore(projectRoot: string): LinearTaskManager | null {\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return null;\n }\n \n // Use project isolation for proper task management\n const config = {\n linearApiKey: process.env.LINEAR_API_KEY,\n autoSync: true,\n syncInterval: 15,\n };\n return new LinearTaskManager(config, undefined, projectRoot);\n}\n\nexport function createTaskCommands(): Command {\n const tasks = new Command('tasks')\n .alias('task')\n .description('Manage tasks from command line');\n\n // List tasks\n tasks\n .command('list')\n .alias('ls')\n .description('List tasks')\n .option(\n '-s, --status <status>',\n 'Filter by status (pending, in_progress, completed, blocked)'\n )\n .option(\n '-p, --priority <priority>',\n 'Filter by priority (urgent, high, medium, low)'\n )\n .option('-q, --query <text>', 'Search in title/description')\n .option('-l, --limit <n>', 'Limit results', '20')\n .option('-a, --all', 'Include completed tasks')\n .action(async (options) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n // Get all tasks from DB\n const db = new Database(\n join(projectRoot, '.stackmemory', 'context.db')\n );\n let query = 'SELECT * FROM task_cache WHERE 1=1';\n const params: any[] = [];\n\n if (!options.all && !options.status) {\n query += \" AND status NOT IN ('completed', 'cancelled')\";\n }\n\n if (options.status) {\n query += ' AND status = ?';\n params.push(options.status);\n }\n\n if (options.priority) {\n query += ' AND priority = ?';\n params.push(options.priority);\n }\n\n if (options.query) {\n query += ' AND (title LIKE ? OR description LIKE ?)';\n params.push(`%${options.query}%`, `%${options.query}%`);\n }\n\n query += ' ORDER BY priority ASC, created_at DESC LIMIT ?';\n params.push(parseInt(options.limit));\n\n const rows = db.prepare(query).all(...params) as any[];\n db.close();\n\n if (rows.length === 0) {\n console.log('\uD83D\uDCDD No tasks found');\n return;\n }\n\n console.log(`\\n\uD83D\uDCCB Tasks (${rows.length})\\n`);\n\n const priorityIcon: Record<string, string> = {\n urgent: '\uD83D\uDD34',\n high: '\uD83D\uDFE0',\n medium: '\uD83D\uDFE1',\n low: '\uD83D\uDFE2',\n };\n const statusIcon: Record<string, string> = {\n pending: '\u23F3',\n in_progress: '\uD83D\uDD04',\n completed: '\u2705',\n blocked: '\uD83D\uDEAB',\n cancelled: '\u274C',\n };\n\n rows.forEach((row) => {\n const pIcon = priorityIcon[row.priority] || '\u26AA';\n const sIcon = statusIcon[row.status] || '\u26AA';\n const id = row.id.slice(0, 10);\n console.log(`${sIcon} ${pIcon} [${id}] ${row.title}`);\n if (row.description) {\n const desc = row.description.split('\\n')[0].slice(0, 60);\n console.log(\n ` ${desc}${row.description.length > 60 ? '...' : ''}`\n );\n }\n });\n console.log('');\n } catch (error: unknown) {\n console.error('\u274C Failed to list tasks:', (error as Error).message);\n }\n });\n\n // Add task\n tasks\n .command('add <title>')\n .description('Add a new task')\n .option('-d, --description <text>', 'Task description')\n .option(\n '-p, --priority <priority>',\n 'Priority (urgent, high, medium, low)',\n 'medium'\n )\n .option('-t, --tags <tags>', 'Comma-separated tags')\n .action(async (title, options) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n const taskId = taskStore.createTask({\n title,\n description: options.description,\n priority: options.priority as TaskPriority,\n frameId: 'cli',\n tags: options.tags\n ? options.tags.split(',').map((t: string) => t.trim())\n : [],\n });\n\n console.log(`\u2705 Created task: ${taskId.slice(0, 10)}`);\n console.log(` Title: ${title}`);\n console.log(` Priority: ${options.priority}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to add task:', (error as Error).message);\n }\n });\n\n // Start task (set to in_progress)\n tasks\n .command('start <taskId>')\n .description('Start working on a task')\n .action(async (taskId) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n // Find task by partial ID\n const task = findTaskByPartialId(projectRoot, taskId);\n if (!task) {\n console.log(`\u274C Task not found: ${taskId}`);\n return;\n }\n\n taskStore.updateTaskStatus(task.id, 'in_progress', 'Started from CLI');\n console.log(`\uD83D\uDD04 Started: ${task.title}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to start task:', (error as Error).message);\n }\n });\n\n // Complete task\n tasks\n .command('done <taskId>')\n .alias('complete')\n .description('Mark task as completed')\n .action(async (taskId) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n const task = findTaskByPartialId(projectRoot, taskId);\n if (!task) {\n console.log(`\u274C Task not found: ${taskId}`);\n return;\n }\n\n taskStore.updateTaskStatus(task.id, 'completed', 'Completed from CLI');\n console.log(`\u2705 Completed: ${task.title}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to complete task:', (error as Error).message);\n }\n });\n\n // Show task details\n tasks\n .command('show <taskId>')\n .description('Show task details')\n .action(async (taskId) => {\n const projectRoot = process.cwd();\n\n try {\n const task = findTaskByPartialId(projectRoot, taskId);\n if (!task) {\n console.log(`\u274C Task not found: ${taskId}`);\n return;\n }\n\n console.log(`\\n\uD83D\uDCCB Task Details\\n`);\n console.log(`ID: ${task.id}`);\n console.log(`Title: ${task.title}`);\n console.log(`Status: ${task.status}`);\n console.log(`Priority: ${task.priority}`);\n console.log(\n `Created: ${new Date(task.created_at * 1000).toLocaleString()}`\n );\n if (task.completed_at) {\n console.log(\n `Completed: ${new Date(task.completed_at * 1000).toLocaleString()}`\n );\n }\n if (task.description) {\n console.log(`\\nDescription:\\n${task.description}`);\n }\n const tags = JSON.parse(task.tags || '[]');\n if (tags.length > 0) {\n console.log(`\\nTags: ${tags.join(', ')}`);\n }\n console.log('');\n } catch (error: unknown) {\n console.error('\u274C Failed to show task:', (error as Error).message);\n }\n });\n\n return tasks;\n}\n\nfunction findTaskByPartialId(\n projectRoot: string,\n partialId: string\n): any | null {\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n if (!existsSync(dbPath)) return null;\n\n const db = new Database(dbPath);\n\n // Try exact match first, then partial\n let row = db.prepare('SELECT * FROM task_cache WHERE id = ?').get(partialId);\n\n if (!row) {\n row = db\n .prepare('SELECT * FROM task_cache WHERE id LIKE ?')\n .get(`${partialId}%`);\n }\n\n // Also try matching Linear identifier in title\n if (!row && partialId.match(/^ENG-\\d+$/i)) {\n row = db\n .prepare('SELECT * FROM task_cache WHERE title LIKE ?')\n .get(`%[${partialId.toUpperCase()}]%`);\n }\n\n db.close();\n return row || null;\n}\n"],
|
|
5
|
-
"mappings": "AAKA,SAAS,eAAe;AACxB,OAAO,cAAc;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,OAEK;AAEP,SAAS,aAAa,aAA+C;AACnE,QAAM,SAAS,KAAK,aAAa,gBAAgB,YAAY;AAC7D,MAAI,CAAC,WAAW,MAAM,GAAG;AACvB,YAAQ;AAAA,MACN;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAGA,QAAM,SAAS;AAAA,IACb,cAAc,QAAQ,IAAI;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * Enhanced Task Commands for StackMemory CLI\n * Provides task management directly from command line\n */\n\nimport { Command } from 'commander';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync } from 'fs';\nimport {\n LinearTaskManager,\n TaskPriority,\n} from '../../features/tasks/linear-task-manager.js';\n\nfunction getTaskStore(projectRoot: string): LinearTaskManager | null {\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return null;\n }\n \n // Use project isolation for proper task management\n const config = {\n linearApiKey: process.env.STACKMEMORY_LINEAR_API_KEY || process.env.LINEAR_API_KEY,\n autoSync: true,\n syncInterval: 15,\n };\n return new LinearTaskManager(config, undefined, projectRoot);\n}\n\nexport function createTaskCommands(): Command {\n const tasks = new Command('tasks')\n .alias('task')\n .description('Manage tasks from command line');\n\n // List tasks\n tasks\n .command('list')\n .alias('ls')\n .description('List tasks')\n .option(\n '-s, --status <status>',\n 'Filter by status (pending, in_progress, completed, blocked)'\n )\n .option(\n '-p, --priority <priority>',\n 'Filter by priority (urgent, high, medium, low)'\n )\n .option('-q, --query <text>', 'Search in title/description')\n .option('-l, --limit <n>', 'Limit results', '20')\n .option('-a, --all', 'Include completed tasks')\n .action(async (options) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n // Get all tasks from DB\n const db = new Database(\n join(projectRoot, '.stackmemory', 'context.db')\n );\n let query = 'SELECT * FROM task_cache WHERE 1=1';\n const params: any[] = [];\n\n if (!options.all && !options.status) {\n query += \" AND status NOT IN ('completed', 'cancelled')\";\n }\n\n if (options.status) {\n query += ' AND status = ?';\n params.push(options.status);\n }\n\n if (options.priority) {\n query += ' AND priority = ?';\n params.push(options.priority);\n }\n\n if (options.query) {\n query += ' AND (title LIKE ? OR description LIKE ?)';\n params.push(`%${options.query}%`, `%${options.query}%`);\n }\n\n query += ' ORDER BY priority ASC, created_at DESC LIMIT ?';\n params.push(parseInt(options.limit));\n\n const rows = db.prepare(query).all(...params) as any[];\n db.close();\n\n if (rows.length === 0) {\n console.log('\uD83D\uDCDD No tasks found');\n return;\n }\n\n console.log(`\\n\uD83D\uDCCB Tasks (${rows.length})\\n`);\n\n const priorityIcon: Record<string, string> = {\n urgent: '\uD83D\uDD34',\n high: '\uD83D\uDFE0',\n medium: '\uD83D\uDFE1',\n low: '\uD83D\uDFE2',\n };\n const statusIcon: Record<string, string> = {\n pending: '\u23F3',\n in_progress: '\uD83D\uDD04',\n completed: '\u2705',\n blocked: '\uD83D\uDEAB',\n cancelled: '\u274C',\n };\n\n rows.forEach((row) => {\n const pIcon = priorityIcon[row.priority] || '\u26AA';\n const sIcon = statusIcon[row.status] || '\u26AA';\n const id = row.id.slice(0, 10);\n console.log(`${sIcon} ${pIcon} [${id}] ${row.title}`);\n if (row.description) {\n const desc = row.description.split('\\n')[0].slice(0, 60);\n console.log(\n ` ${desc}${row.description.length > 60 ? '...' : ''}`\n );\n }\n });\n console.log('');\n } catch (error: unknown) {\n console.error('\u274C Failed to list tasks:', (error as Error).message);\n }\n });\n\n // Add task\n tasks\n .command('add <title>')\n .description('Add a new task')\n .option('-d, --description <text>', 'Task description')\n .option(\n '-p, --priority <priority>',\n 'Priority (urgent, high, medium, low)',\n 'medium'\n )\n .option('-t, --tags <tags>', 'Comma-separated tags')\n .action(async (title, options) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n const taskId = taskStore.createTask({\n title,\n description: options.description,\n priority: options.priority as TaskPriority,\n frameId: 'cli',\n tags: options.tags\n ? options.tags.split(',').map((t: string) => t.trim())\n : [],\n });\n\n console.log(`\u2705 Created task: ${taskId.slice(0, 10)}`);\n console.log(` Title: ${title}`);\n console.log(` Priority: ${options.priority}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to add task:', (error as Error).message);\n }\n });\n\n // Start task (set to in_progress)\n tasks\n .command('start <taskId>')\n .description('Start working on a task')\n .action(async (taskId) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n // Find task by partial ID\n const task = findTaskByPartialId(projectRoot, taskId);\n if (!task) {\n console.log(`\u274C Task not found: ${taskId}`);\n return;\n }\n\n taskStore.updateTaskStatus(task.id, 'in_progress', 'Started from CLI');\n console.log(`\uD83D\uDD04 Started: ${task.title}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to start task:', (error as Error).message);\n }\n });\n\n // Complete task\n tasks\n .command('done <taskId>')\n .alias('complete')\n .description('Mark task as completed')\n .action(async (taskId) => {\n const projectRoot = process.cwd();\n const taskStore = getTaskStore(projectRoot);\n if (!taskStore) return;\n\n try {\n const task = findTaskByPartialId(projectRoot, taskId);\n if (!task) {\n console.log(`\u274C Task not found: ${taskId}`);\n return;\n }\n\n taskStore.updateTaskStatus(task.id, 'completed', 'Completed from CLI');\n console.log(`\u2705 Completed: ${task.title}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to complete task:', (error as Error).message);\n }\n });\n\n // Show task details\n tasks\n .command('show <taskId>')\n .description('Show task details')\n .action(async (taskId) => {\n const projectRoot = process.cwd();\n\n try {\n const task = findTaskByPartialId(projectRoot, taskId);\n if (!task) {\n console.log(`\u274C Task not found: ${taskId}`);\n return;\n }\n\n console.log(`\\n\uD83D\uDCCB Task Details\\n`);\n console.log(`ID: ${task.id}`);\n console.log(`Title: ${task.title}`);\n console.log(`Status: ${task.status}`);\n console.log(`Priority: ${task.priority}`);\n console.log(\n `Created: ${new Date(task.created_at * 1000).toLocaleString()}`\n );\n if (task.completed_at) {\n console.log(\n `Completed: ${new Date(task.completed_at * 1000).toLocaleString()}`\n );\n }\n if (task.description) {\n console.log(`\\nDescription:\\n${task.description}`);\n }\n const tags = JSON.parse(task.tags || '[]');\n if (tags.length > 0) {\n console.log(`\\nTags: ${tags.join(', ')}`);\n }\n console.log('');\n } catch (error: unknown) {\n console.error('\u274C Failed to show task:', (error as Error).message);\n }\n });\n\n return tasks;\n}\n\nfunction findTaskByPartialId(\n projectRoot: string,\n partialId: string\n): any | null {\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n if (!existsSync(dbPath)) return null;\n\n const db = new Database(dbPath);\n\n // Try exact match first, then partial\n let row = db.prepare('SELECT * FROM task_cache WHERE id = ?').get(partialId);\n\n if (!row) {\n row = db\n .prepare('SELECT * FROM task_cache WHERE id LIKE ?')\n .get(`${partialId}%`);\n }\n\n // Also try matching Linear identifier in title\n if (!row && partialId.match(/^ENG-\\d+$/i)) {\n row = db\n .prepare('SELECT * FROM task_cache WHERE title LIKE ?')\n .get(`%[${partialId.toUpperCase()}]%`);\n }\n\n db.close();\n return row || null;\n}\n"],
|
|
5
|
+
"mappings": "AAKA,SAAS,eAAe;AACxB,OAAO,cAAc;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,OAEK;AAEP,SAAS,aAAa,aAA+C;AACnE,QAAM,SAAS,KAAK,aAAa,gBAAgB,YAAY;AAC7D,MAA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AAI,EAAE;AAAA,IAChB,SAAS,OAAgB;AACvB,cAAQ,MAAM,+BAA2B,MAAgB,OAAO;AAAA,IAClE;AAAA,EACF,CAAC;AAEH,SAAO;AACT;AAEA,SAAS,oBACP,aACA,WACY;AACZ,QAAM,SAAS,KAAK,aAAa,gBAAgB,YAAY;AAC7D,MAAI,CAAC,WAAW,MAAM,EAAG,QAAO;AAEhC,QAAM,KAAK,IAAI,SAAS,MAAM;AAG9B,MAAI,MAAM,GAAG,QAAQ,uCAAuC,EAAE,IAAI,SAAS;AAE3E,MAAI,CAAC,KAAK;AACR,UAAM,GACH,QAAQ,0CAA0C,EAClD,IAAI,GAAG,SAAS,GAAG;AAAA,EACxB;AAGA,MAAI,CAAC,OAAO,UAAU,MAAM,YAAY,GAAG;AACzC,UAAM,GACH,QAAQ,6CAA6C,EACrD,IAAI,KAAK,UAAU,YAAY,CAAC,IAAI;AAAA,EACzC;AAEA,KAAG,MAAM;AACT,SAAO,OAAO;AAChB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cli/index.js
CHANGED
|
@@ -28,6 +28,7 @@ import clearCommand from "./commands/clear.js";
|
|
|
28
28
|
import createWorkflowCommand from "./commands/workflow.js";
|
|
29
29
|
import monitorCommand from "./commands/monitor.js";
|
|
30
30
|
import qualityCommand from "./commands/quality.js";
|
|
31
|
+
import createRalphCommand from "./commands/ralph.js";
|
|
31
32
|
import { registerLoginCommand } from "./commands/login.js";
|
|
32
33
|
import { registerSignupCommand } from "./commands/signup.js";
|
|
33
34
|
import { registerLogoutCommand, registerDbCommands } from "./commands/db.js";
|
|
@@ -329,6 +330,7 @@ program.addCommand(clearCommand);
|
|
|
329
330
|
program.addCommand(createWorkflowCommand());
|
|
330
331
|
program.addCommand(monitorCommand);
|
|
331
332
|
program.addCommand(qualityCommand);
|
|
333
|
+
program.addCommand(createRalphCommand());
|
|
332
334
|
program.command("dashboard").description("Display monitoring dashboard in terminal").option("-w, --watch", "Auto-refresh dashboard").option("-i, --interval <seconds>", "Refresh interval in seconds", "5").action(async (options) => {
|
|
333
335
|
const { dashboardCommand } = await import("./commands/dashboard.js");
|
|
334
336
|
await dashboardCommand.handler(options);
|