From b16210dfd7166d412b40f8c272018124bfb52502 Mon Sep 17 00:00:00 2001 From: rUv Date: Mon, 4 Aug 2025 14:49:34 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=96=20Checkpoint:=20Edit=20/workspaces?= =?UTF-8?q?/claude-code-flow/src/cli/simple-commands/automation.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/checkpoints/1754318776.json | 1 + .claude/checkpoints/1754318778.json | 1 + src/cli/simple-commands/automation.js | 179 ++++++++++++++++++++++++++ 3 files changed, 181 insertions(+) create mode 100644 .claude/checkpoints/1754318776.json create mode 100644 .claude/checkpoints/1754318778.json diff --git a/.claude/checkpoints/1754318776.json b/.claude/checkpoints/1754318776.json new file mode 100644 index 0000000000..c67df29892 --- /dev/null +++ b/.claude/checkpoints/1754318776.json @@ -0,0 +1 @@ +{"branch": "checkpoint/pre-edit-20250804-144616", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/automation.js", "timestamp": "2025-08-04T14:46:16Z", "type": "pre-edit", "original_branch": "alpha-85"} diff --git a/.claude/checkpoints/1754318778.json b/.claude/checkpoints/1754318778.json new file mode 100644 index 0000000000..6b87802bd3 --- /dev/null +++ b/.claude/checkpoints/1754318778.json @@ -0,0 +1 @@ +{"tag": "checkpoint-20250804-144618", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/automation.js", "timestamp": "2025-08-04T14:46:18Z", "type": "post-edit", "branch": "alpha-85", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 192 +++++++++++++++++++++++++++++++ .claude-flow/metrics/task-metrics.json | 6 +- .claude/checkpoints/1754318756.json | 1 + .claude/checkpoints/1754318758.json | 1 + claude-flow-wiki | 0 src/cli/simple-commands/automation.js | 9 ++ 7 files changed, 207 insertions(+), 4 deletions(-) "} diff --git a/src/cli/simple-commands/automation.js b/src/cli/simple-commands/automation.js index 6942ff6335..f3f7160038 100644 --- a/src/cli/simple-commands/automation.js +++ b/src/cli/simple-commands/automation.js @@ -254,6 +254,185 @@ async function workflowSelectCommand(subArgs, flags) { console.log(`\nšŸ“„ Workflow template saved for project: ${projectType}`); } +/** + * Execute a workflow from file - NEW IMPLEMENTATION + */ +async function runWorkflowCommand(subArgs, flags) { + const workflowFile = subArgs[1]; + const options = flags; + + if (!workflowFile) { + printError('Usage: automation run-workflow [options]'); + console.log('\nExample:'); + console.log(' claude-flow automation run-workflow workflow.json --claude --non-interactive'); + return; + } + + if (!existsSync(workflowFile)) { + printError(`Workflow file not found: ${workflowFile}`); + return; + } + + try { + console.log(`šŸ”„ Loading workflow: ${workflowFile}`); + + // Load workflow definition + const workflowData = await loadWorkflowFromFile(workflowFile); + + // Create executor with options + const executor = new WorkflowExecutor({ + enableClaude: options.claude || false, + nonInteractive: options['non-interactive'] || options.nonInteractive || false, + outputFormat: options['output-format'] || 'text', + maxConcurrency: parseInt(options['max-concurrency']) || 3, + timeout: parseInt(options.timeout) || 3600000, + logLevel: options.verbose ? 'debug' : 'info' + }); + + // Apply variable overrides if provided + const variables = {}; + if (options.variables) { + try { + Object.assign(variables, JSON.parse(options.variables)); + } catch (error) { + printWarning(`Invalid variables JSON: ${error.message}`); + } + } + + // Execute workflow + const result = await executor.executeWorkflow(workflowData, variables); + + if (options['output-format'] === 'json') { + console.log(JSON.stringify(result, null, 2)); + } + + printSuccess(`Workflow execution ${result.success ? 'completed' : 'failed'}`); + + if (!result.success && result.errors.length > 0) { + console.log('\nāŒ Errors encountered:'); + result.errors.forEach(error => { + console.log(` • ${error.type}: ${error.error}`); + }); + } + + } catch (error) { + printError(`Failed to execute workflow: ${error.message}`); + } +} + +/** + * Run MLE-STAR workflow - NEW FLAGSHIP COMMAND + */ +async function mleStarCommand(subArgs, flags) { + const options = flags; + + console.log(`🧠 MLE-STAR: Machine Learning Engineering via Search and Targeted Refinement`); + console.log(`šŸŽÆ This is the flagship automation workflow for ML engineering tasks`); + console.log(); + + try { + // Get the built-in MLE-STAR workflow + const workflowPath = getMLEStarWorkflowPath(); + + if (!existsSync(workflowPath)) { + printError('MLE-STAR workflow template not found'); + console.log('Please ensure the template is installed at:'); + console.log(workflowPath); + return; + } + + // Load MLE-STAR workflow + const workflowData = await loadWorkflowFromFile(workflowPath); + + console.log(`šŸ“‹ Workflow: ${workflowData.name}`); + console.log(`šŸ“„ Description: ${workflowData.description}`); + console.log(`šŸŽ“ Methodology: Search → Foundation → Refinement → Ensemble → Validation`); + console.log(`ā±ļø Expected Runtime: ${workflowData.metadata.expected_runtime}`); + console.log(); + + // Detect dataset if provided + const datasetPath = options.dataset || options.data || './data/dataset.csv'; + const targetColumn = options.target || 'target'; + + // Create executor with MLE-STAR optimized settings + const executor = new WorkflowExecutor({ + enableClaude: options.claude !== false, // Default to true for MLE-STAR + nonInteractive: options['non-interactive'] || options.nonInteractive || false, + outputFormat: options['output-format'] || 'text', + maxConcurrency: parseInt(options['max-agents']) || 6, + timeout: parseInt(options.timeout) || 14400000, // 4 hours for ML workflows + logLevel: options.verbose ? 'debug' : 'info' + }); + + // Prepare MLE-STAR specific variables + const variables = { + dataset_path: datasetPath, + target_column: targetColumn, + experiment_name: options.name || `mle-star-${Date.now()}`, + model_output_dir: options.output || './models/', + search_iterations: parseInt(options['search-iterations']) || 3, + refinement_iterations: parseInt(options['refinement-iterations']) || 5, + ...((options.variables && JSON.parse(options.variables)) || {}) + }; + + console.log(`šŸ“Š Configuration:`); + console.log(` Dataset: ${variables.dataset_path}`); + console.log(` Target: ${variables.target_column}`); + console.log(` Output: ${variables.model_output_dir}`); + console.log(` Claude Integration: ${executor.options.enableClaude ? 'Enabled' : 'Disabled'}`); + console.log(); + + if (!options.claude && !options['no-claude-warning']) { + printWarning('MLE-STAR works best with Claude integration. Add --claude flag for full automation.'); + console.log('Without Claude, this will simulate the workflow execution.'); + console.log(); + } + + // Execute MLE-STAR workflow + const result = await executor.executeWorkflow(workflowData, variables); + + if (result.success) { + console.log(); + printSuccess('šŸŽ‰ MLE-STAR workflow completed successfully!'); + console.log(`šŸ“Š Results: ${result.completedTasks}/${result.totalTasks} tasks completed`); + console.log(`ā±ļø Duration: ${executor.formatDuration(result.duration)}`); + console.log(`šŸ†” Execution ID: ${result.executionId}`); + + if (result.results && Object.keys(result.results).length > 0) { + console.log(`\nšŸ“ˆ Key Results:`); + Object.entries(result.results).forEach(([taskId, taskResult]) => { + if (taskResult.output?.status === 'completed') { + console.log(` āœ… ${taskId}: Completed successfully`); + } + }); + } + + console.log(`\nšŸ’” Next Steps:`); + console.log(` • Check models in: ${variables.model_output_dir}`); + console.log(` • Review experiment: ${variables.experiment_name}`); + console.log(` • Validate results with your test data`); + + } else { + printError('āŒ MLE-STAR workflow failed'); + console.log(`šŸ“Š Progress: ${result.completedTasks}/${result.totalTasks} tasks completed`); + + if (result.errors.length > 0) { + console.log('\nšŸ” Errors:'); + result.errors.forEach(error => { + console.log(` • ${error.type}: ${error.error}`); + }); + } + } + + if (options['output-format'] === 'json') { + console.log('\n' + JSON.stringify(result, null, 2)); + } + + } catch (error) { + printError(`MLE-STAR execution failed: ${error.message}`); + } +} + function showAutomationHelp() { console.log(` šŸ¤– Automation Commands - Intelligent Agent & Workflow Management