snow-flow 1.3.7 → 1.3.9

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.js CHANGED
@@ -153,6 +153,7 @@ program
153
153
  (objective.toLowerCase().includes('flow') &&
154
154
  !objective.toLowerCase().includes('workflow') &&
155
155
  !objective.toLowerCase().includes('data flow'));
156
+ let xmlFlowResult = null;
156
157
  if (isFlowDesignerTask) {
157
158
  cliLogger.info('\nšŸ”§ Flow Designer Detected - Using XML-First Approach!');
158
159
  cliLogger.info('šŸ“‹ Creating production-ready ServiceNow flow XML...');
@@ -238,6 +239,7 @@ program
238
239
  // Generate XML
239
240
  cliLogger.info('šŸ—ļø Generating production XML...');
240
241
  const result = generateProductionFlowXML(flowDef);
242
+ xmlFlowResult = { ...result, flowDefinition: flowDef };
241
243
  cliLogger.info(`\nāœ… XML Generated Successfully!`);
242
244
  cliLogger.info(`šŸ“ File saved to: ${result.filePath}`);
243
245
  cliLogger.info(`šŸ“Š Flow structure:`);
@@ -267,8 +269,8 @@ program
267
269
  else {
268
270
  cliLogger.info('šŸ“‹ Use the import instructions above to deploy to ServiceNow');
269
271
  }
270
- cliLogger.info('\nšŸ’” Tip: For additional ServiceNow features beyond flows, run swarm again for widgets/scripts/etc.');
271
- return; // Exit early for Flow Designer flows
272
+ cliLogger.info('\nšŸ’” XML template generated. Now launching Queen Agent for intelligent flow development...');
273
+ // DO NOT RETURN HERE - Continue to Queen Agent orchestration!
272
274
  }
273
275
  catch (error) {
274
276
  cliLogger.error('āŒ XML flow generation failed:', error instanceof Error ? error.message : String(error));
@@ -278,7 +280,7 @@ program
278
280
  // Start real Claude Code orchestration
279
281
  try {
280
282
  // Generate the Queen Agent orchestration prompt
281
- const orchestrationPrompt = buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated, sessionId);
283
+ const orchestrationPrompt = buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated, sessionId, xmlFlowResult);
282
284
  cliLogger.info('\nšŸ‘‘ Initializing Queen Agent orchestration...');
283
285
  cliLogger.info('šŸŽÆ Queen Agent will coordinate the following:');
284
286
  cliLogger.info(` - Analyze objective: "${objective}"`);
@@ -342,22 +344,31 @@ program
342
344
  });
343
345
  }
344
346
  else {
345
- cliLogger.info('\nšŸ“‹ Claude Code manual execution required');
346
- cliLogger.info('\nšŸ‘‘ QUEEN AGENT ORCHESTRATION PROMPT:');
347
+ cliLogger.info('\nšŸš€ SNOW-FLOW ORCHESTRATION COMPLETE!');
348
+ cliLogger.info('šŸ¤– Now it\'s time for Claude Code agents to do the work...\n');
349
+ cliLogger.info('šŸ‘‘ QUEEN AGENT ORCHESTRATION PROMPT FOR CLAUDE CODE:');
347
350
  cliLogger.info('='.repeat(80));
348
351
  cliLogger.info(orchestrationPrompt);
349
352
  cliLogger.info('='.repeat(80));
350
- cliLogger.info('\nāœ… Queen Agent orchestration prompt generated!');
351
- cliLogger.info('šŸ“Š Next Steps:');
352
- cliLogger.info(' 1. Copy the above prompt and paste it into Claude Code');
353
- cliLogger.info(' 2. Queen Agent will analyze and spawn specialized agents');
354
- cliLogger.info(' 3. Agents will coordinate through shared memory');
355
- cliLogger.info(' 4. Monitor progress through TodoRead and Memory tools');
353
+ cliLogger.info('\nāœ… Snow-Flow has prepared the orchestration!');
354
+ cliLogger.info('šŸ“Š CRITICAL NEXT STEPS:');
355
+ cliLogger.info(' 1. Copy the ENTIRE prompt above');
356
+ cliLogger.info(' 2. Paste it into Claude Code (the AI assistant)');
357
+ cliLogger.info(' 3. Claude Code will spawn multiple specialized agents as workhorses');
358
+ cliLogger.info(' 4. These agents will implement your flow with all required logic');
359
+ cliLogger.info(' 5. Agents will enhance the basic XML template with real functionality');
360
+ cliLogger.info('\nšŸŽÆ Remember:');
361
+ cliLogger.info(' - Snow-Flow = Orchestrator (coordinates the work)');
362
+ cliLogger.info(' - Claude Code = Workhorses (implement the solution)');
363
+ if (xmlFlowResult) {
364
+ cliLogger.info(`\nšŸ“ XML template saved at: ${xmlFlowResult.filePath}`);
365
+ cliLogger.info(' āš ļø This is just a BASIC template - agents must enhance it!');
366
+ }
356
367
  if (isAuthenticated && options.autoDeploy) {
357
- cliLogger.info(' 5. Real artifacts will be created in ServiceNow');
368
+ cliLogger.info('\nšŸš€ Deployment Mode: Agents will create REAL artifacts in ServiceNow');
358
369
  }
359
370
  else {
360
- cliLogger.info(' 5. Planning mode - no real artifacts created');
371
+ cliLogger.info('\nšŸ“‹ Planning Mode: Analysis and recommendations only');
361
372
  }
362
373
  cliLogger.info(`\nšŸ’¾ Session ID for monitoring: ${sessionId}`);
363
374
  }
@@ -371,45 +382,75 @@ program
371
382
  });
372
383
  }
373
384
  });
374
- // Helper function to execute Claude Code directly (FALLBACK ONLY)
385
+ // Helper function to execute Claude Code directly
375
386
  async function executeClaudeCode(prompt) {
376
- return new Promise((resolve) => {
377
- cliLogger.info('šŸ” Checking for Claude Code availability...');
378
- // Try to find Claude Code binary
379
- const claudeCommands = ['claude', 'claude-code', 'npx claude-code'];
380
- let currentCommand = 0;
381
- const tryNextCommand = () => {
382
- if (currentCommand >= claudeCommands.length) {
383
- cliLogger.warn('āŒ Claude Code not found in PATH');
384
- resolve(false);
385
- return;
386
- }
387
- const command = claudeCommands[currentCommand];
388
- cliLogger.debug(`šŸ” Trying: ${command}`);
389
- const claudeArgs = [
390
- '--version'
391
- ];
392
- // Test if Claude Code is available
393
- const testProcess = (0, child_process_1.spawn)(command, claudeArgs, {
394
- stdio: ['ignore', 'pipe', 'pipe']
395
- });
396
- testProcess.on('close', (code) => {
387
+ cliLogger.info('šŸ¤– Preparing Claude Code agent orchestration...');
388
+ try {
389
+ // Check if Claude CLI is available
390
+ const { execSync } = require('child_process');
391
+ try {
392
+ execSync('which claude', { stdio: 'ignore' });
393
+ }
394
+ catch {
395
+ cliLogger.warn('āš ļø Claude Code CLI not found in PATH');
396
+ cliLogger.info('šŸ“‹ Please install Claude Desktop or copy the prompt manually');
397
+ return false;
398
+ }
399
+ // Check for MCP config
400
+ const mcpConfigPath = (0, path_1.join)(process.cwd(), '.mcp.json');
401
+ const hasMcpConfig = (0, fs_2.existsSync)(mcpConfigPath);
402
+ // Launch Claude Code with MCP config
403
+ const claudeArgs = hasMcpConfig
404
+ ? ['--mcp-config', '.mcp.json', '.']
405
+ : ['.'];
406
+ cliLogger.info('šŸš€ Launching Claude Code automatically...');
407
+ if (hasMcpConfig) {
408
+ cliLogger.info('šŸ”§ Starting Claude Code with ServiceNow MCP servers...');
409
+ }
410
+ // Start Claude Code process in interactive mode
411
+ const claudeProcess = (0, child_process_1.spawn)('claude', claudeArgs, {
412
+ stdio: ['pipe', 'inherit', 'inherit'],
413
+ shell: true,
414
+ env: { ...process.env }
415
+ });
416
+ // Send the prompt to Claude Code
417
+ cliLogger.info('šŸ“ Sending orchestration prompt to Claude Code...');
418
+ cliLogger.info('šŸš€ Claude Code interface opening...\n');
419
+ // Write prompt and close stdin to trigger execution
420
+ claudeProcess.stdin.write(prompt);
421
+ claudeProcess.stdin.end();
422
+ // Set up process monitoring
423
+ return new Promise((resolve) => {
424
+ claudeProcess.on('close', (code) => {
397
425
  if (code === 0) {
398
- cliLogger.info(`āœ… Found Claude Code: ${command}`);
399
- executeWithClaude(command, prompt, resolve);
426
+ cliLogger.info('\nāœ… Claude Code session completed successfully!');
427
+ resolve(true);
400
428
  }
401
429
  else {
402
- currentCommand++;
403
- tryNextCommand();
430
+ cliLogger.warn(`\nāš ļø Claude Code session ended with code: ${code}`);
431
+ resolve(false);
404
432
  }
405
433
  });
406
- testProcess.on('error', () => {
407
- currentCommand++;
408
- tryNextCommand();
434
+ claudeProcess.on('error', (error) => {
435
+ cliLogger.error(`āŒ Failed to start Claude Code: ${error.message}`);
436
+ resolve(false);
409
437
  });
410
- };
411
- tryNextCommand();
412
- });
438
+ // Set timeout (configurable via environment variable)
439
+ const timeoutMinutes = parseInt(process.env.SNOW_FLOW_TIMEOUT_MINUTES || '0');
440
+ if (timeoutMinutes > 0) {
441
+ setTimeout(() => {
442
+ cliLogger.warn(`ā±ļø Claude Code session timeout (${timeoutMinutes} minutes), terminating...`);
443
+ claudeProcess.kill('SIGTERM');
444
+ resolve(false);
445
+ }, timeoutMinutes * 60 * 1000);
446
+ }
447
+ });
448
+ }
449
+ catch (error) {
450
+ cliLogger.error('āŒ Error launching Claude Code:', error instanceof Error ? error.message : String(error));
451
+ cliLogger.info('šŸ“‹ Claude Code prompt generated - please copy and paste manually');
452
+ return false;
453
+ }
413
454
  }
414
455
  // Real-time monitoring dashboard for Claude Code process
415
456
  function startMonitoringDashboard(claudeProcess) {
@@ -519,7 +560,7 @@ async function executeWithClaude(claudeCommand, prompt, resolve) {
519
560
  });
520
561
  }
521
562
  // Helper function to build Queen Agent orchestration prompt
522
- function buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated = false, sessionId) {
563
+ function buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated = false, sessionId, xmlFlowResult = null) {
523
564
  // Check if intelligent features are enabled
524
565
  const hasIntelligentFeatures = options.autoPermissions || options.smartDiscovery ||
525
566
  options.liveTesting || options.autoDeploy || options.autoRollback ||
@@ -539,6 +580,23 @@ You are the Queen Agent, master coordinator of the Snow-Flow hive-mind. Your mis
539
580
  - **Supporting Agents**: ${taskAnalysis.supportingAgents.join(', ')}
540
581
  - **Estimated Total Agents**: ${taskAnalysis.estimatedAgentCount}
541
582
  - **ServiceNow Artifacts**: ${taskAnalysis.serviceNowArtifacts.join(', ')}
583
+
584
+ ${xmlFlowResult ? `## šŸ”§ Flow Designer XML Template Generated
585
+ An initial XML template has been created as a starting point:
586
+ - **File Path**: ${xmlFlowResult.filePath}
587
+ - **Flow Name**: ${xmlFlowResult.flowDefinition.name}
588
+ - **Table**: ${xmlFlowResult.flowDefinition.table}
589
+ - **Activities**: ${xmlFlowResult.flowDefinition.activities.length}
590
+
591
+ **IMPORTANT**: This is just a basic template! You must spawn Claude Code agents to:
592
+ 1. Analyze the detailed requirements from the objective
593
+ 2. Design the complete flow logic with all activities
594
+ 3. Add approval steps, notifications, conditions, etc.
595
+ 4. Test the flow implementation
596
+ 5. Deploy to ServiceNow
597
+
598
+ The XML template is saved but needs significant enhancement by your agents!
599
+ ` : ''}
542
600
  - **Recommended Team**: ${getTeamRecommendation(taskAnalysis.taskType)}
543
601
 
544
602
  ## šŸ“Š Table Discovery Intelligence
package/dist/version.js CHANGED
@@ -7,12 +7,24 @@ exports.VERSION_INFO = exports.VERSION = void 0;
7
7
  exports.getVersionString = getVersionString;
8
8
  exports.getLatestFeatures = getLatestFeatures;
9
9
  exports.isLatestVersion = isLatestVersion;
10
- exports.VERSION = '1.3.7';
10
+ exports.VERSION = '1.3.9';
11
11
  exports.VERSION_INFO = {
12
12
  version: exports.VERSION,
13
13
  name: 'Snow-Flow',
14
14
  description: 'ServiceNow Queen Agent - Hive-Mind Intelligence for ServiceNow Development',
15
15
  features: {
16
+ '1.3.9': [
17
+ 'šŸš€ CLAUDE CODE AUTO-LAUNCH: Restored automatic Claude Code launching',
18
+ 'šŸ¤– PROCESS SPAWNING: Claude CLI detection and proper process spawning',
19
+ 'šŸ“ PROMPT INJECTION: Automatic prompt sending to Claude Code via stdin',
20
+ 'šŸ”§ MCP INTEGRATION: Auto-loads MCP servers when .mcp.json exists'
21
+ ],
22
+ '1.3.8': [
23
+ 'šŸ¤– CLAUDE CODE FIX: Restored proper Claude Code agent spawning',
24
+ 'šŸš€ SWARM ORCHESTRATION: Snow-flow is orchestrator, Claude Code agents are workhorses',
25
+ 'šŸ”§ NO EARLY EXIT: Flow Designer tasks now continue to full agent orchestration',
26
+ 'šŸ“‹ CLEAR INSTRUCTIONS: Better messaging about Snow-flow vs Claude Code roles'
27
+ ],
16
28
  '1.3.7': [
17
29
  'šŸš€ RELEASE VERSION: Combined all fixes from 1.3.2-1.3.6 into stable release',
18
30
  'āœ… ZOD VALIDATION: Completely fixed all configuration schema issues',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "ServiceNow Queen Agent - Hive-Mind Intelligence for ServiceNow Development inspired by claude-flow. Transform complex workflows into elegant one-command orchestration.",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",