snow-flow 1.3.30 ā 1.4.0
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/CLAUDE.md +12 -0
- package/README.md +153 -456
- package/dist/agents/base-agent.js +6 -7
- package/dist/agents/index.js +3 -4
- package/dist/agents/queen-agent.js +21 -7
- package/dist/api/natural-language-mapper.js +24 -21
- package/dist/cli/snow-flow-cli-integration.js +2 -1
- package/dist/cli.js +28 -1017
- package/dist/compliance/advanced-compliance-system.js +1 -1
- package/dist/documentation/self-documenting-system.js +10 -41
- package/dist/intelligence/auto-resolution-engine.js +1 -1
- package/dist/mcp/base-mcp-server.js +2 -2
- package/dist/mcp/http-transport-wrapper.js +2 -2
- package/dist/mcp/servicenow-deployment-mcp-refactored.js +1 -1
- package/dist/mcp/servicenow-deployment-mcp.js +16 -3
- package/dist/mcp/servicenow-flow-composer-mcp.js +20 -0
- package/dist/mcp/servicenow-intelligent-mcp-refactored.js +5 -5
- package/dist/mcp/servicenow-intelligent-mcp.js +11 -3
- package/dist/mcp/servicenow-operations-mcp-refactored.js +2 -2
- package/dist/mcp/servicenow-reporting-analytics-mcp-refactored.js +3 -1
- package/dist/mcp/servicenow-xml-flow-mcp.js +16 -9
- package/dist/mcp/shared/base-mcp-server.js +2 -2
- package/dist/memory/hierarchical-memory-system.js +0 -2
- package/dist/memory/memory-system.js +18 -81
- package/dist/memory/snow-flow-memory-patterns.js +41 -41
- package/dist/monitoring/enhanced-monitoring-system.js +6 -6
- package/dist/optimization/index.js +5 -3
- package/dist/orchestrator/flow-composer.js +101 -8
- package/dist/queen/agent-factory.js +8 -1
- package/dist/queen/mcp-execution-bridge.js +7 -0
- package/dist/queen/queen-memory-system.js +27 -1
- package/dist/queen/servicenow-queen.js +25 -17
- package/dist/snow-flow-system.js +36 -37
- package/dist/testing/integration-test-suite.js +31 -30
- package/dist/utils/complete-flow-xml-generator.js +52 -52
- package/dist/utils/servicenow-client.js +15 -8
- package/dist/utils/snow-oauth.js +17 -2
- package/dist/version.js +19 -1
- package/package.json +1 -1
- package/flow-update-sets/flow_build_automated_approval_flow_with_notifications_flow.xml +0 -203
- package/flow-update-sets/flow_create_approval_flow_for_equipment_requests_flow.xml +0 -206
- package/flow-update-sets/flow_create_equipment_approval_flow_with_manager_approv_flow.xml +0 -254
- package/flow-update-sets/iphone_15_pro_approval_flow.xml +0 -203
- package/flow-update-sets/test_iphone_approval_flow_flow.xml +0 -303
package/dist/cli.js
CHANGED
|
@@ -50,7 +50,6 @@ const fs_2 = require("fs");
|
|
|
50
50
|
const snow_oauth_js_1 = require("./utils/snow-oauth.js");
|
|
51
51
|
const servicenow_client_js_1 = require("./utils/servicenow-client.js");
|
|
52
52
|
const agent_detector_js_1 = require("./utils/agent-detector.js");
|
|
53
|
-
const servicenow_id_generator_js_1 = require("./utils/servicenow-id-generator.js");
|
|
54
53
|
const version_js_1 = require("./version.js");
|
|
55
54
|
const logger_js_1 = require("./utils/logger.js");
|
|
56
55
|
// Load environment variables
|
|
@@ -62,6 +61,29 @@ program
|
|
|
62
61
|
.name('snow-flow')
|
|
63
62
|
.description('ServiceNow Multi-Agent Development Framework')
|
|
64
63
|
.version(version_js_1.VERSION);
|
|
64
|
+
// Flow deprecation handler - check for flow-related commands
|
|
65
|
+
function checkFlowDeprecation(command, objective) {
|
|
66
|
+
const flowKeywords = ['flow', 'create-flow', 'xml-flow', 'flow-designer'];
|
|
67
|
+
const isFlowCommand = flowKeywords.some(keyword => command.includes(keyword));
|
|
68
|
+
const isFlowObjective = objective && objective.toLowerCase().includes('flow') &&
|
|
69
|
+
!objective.toLowerCase().includes('workflow') &&
|
|
70
|
+
!objective.toLowerCase().includes('data flow');
|
|
71
|
+
if (isFlowCommand || isFlowObjective) {
|
|
72
|
+
console.error('ā Flow creation has been removed from snow-flow v1.4.0+');
|
|
73
|
+
console.error('');
|
|
74
|
+
console.error('Please use ServiceNow Flow Designer directly:');
|
|
75
|
+
console.error('1. Log into your ServiceNow instance');
|
|
76
|
+
console.error('2. Navigate to: Flow Designer > Designer');
|
|
77
|
+
console.error('3. Create flows using the visual interface');
|
|
78
|
+
console.error('');
|
|
79
|
+
console.error('Snow-flow continues to support:');
|
|
80
|
+
console.error('- Widget development');
|
|
81
|
+
console.error('- Update Set management');
|
|
82
|
+
console.error('- Table/field discovery');
|
|
83
|
+
console.error('- General ServiceNow operations');
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
65
87
|
// Helper function to deploy XML to ServiceNow
|
|
66
88
|
async function deployXMLToServiceNow(xmlFile, options = {}) {
|
|
67
89
|
const oauth = new snow_oauth_js_1.ServiceNowOAuth();
|
|
@@ -250,6 +272,8 @@ program
|
|
|
250
272
|
.option('--no-autonomous-all', 'Disable all autonomous systems (overrides individual settings)')
|
|
251
273
|
.option('--verbose', 'Show detailed execution information')
|
|
252
274
|
.action(async (objective, options) => {
|
|
275
|
+
// Check for flow deprecation first
|
|
276
|
+
checkFlowDeprecation('swarm', objective);
|
|
253
277
|
// Always show essential info
|
|
254
278
|
cliLogger.info(`\nš Snow-Flow v${version_js_1.VERSION}`);
|
|
255
279
|
cliLogger.info(`š Objective: ${objective}`);
|
|
@@ -1203,12 +1227,7 @@ Your agents MUST use these MCP tools IN THIS ORDER:
|
|
|
1203
1227
|
- \`snow_catalog_item_search\` - Find catalog items with fuzzy matching
|
|
1204
1228
|
- \`snow_get_by_sysid\` - Direct sys_id lookup
|
|
1205
1229
|
|
|
1206
|
-
3. **
|
|
1207
|
-
- \`snow_create_flow\` - Create flows using XML-first approach with auto-deployment (RECOMMENDED)
|
|
1208
|
-
- \`snow_test_flow_with_mock\` - Test flows with mock data
|
|
1209
|
-
- \`snow_link_catalog_to_flow\` - Link catalog items to flows
|
|
1210
|
-
|
|
1211
|
-
4. **Update Set Management** (servicenow-update-set-mcp)
|
|
1230
|
+
3. **Update Set Management** (servicenow-update-set-mcp)
|
|
1212
1231
|
- \`snow_update_set_create\` - Create new update sets
|
|
1213
1232
|
- \`snow_update_set_add_artifact\` - Track artifacts
|
|
1214
1233
|
- \`snow_update_set_complete\` - Complete update sets
|
|
@@ -2054,8 +2073,6 @@ program
|
|
|
2054
2073
|
memory <action> Memory operations
|
|
2055
2074
|
auth <action> Authentication management
|
|
2056
2075
|
mcp <action> Manage ServiceNow MCP servers
|
|
2057
|
-
create-flow <instruction> Create flows using natural language
|
|
2058
|
-
xml-flow <instruction> Create flows using XML-first approach
|
|
2059
2076
|
deploy-xml <file> Deploy XML update set to ServiceNow
|
|
2060
2077
|
help Show this help
|
|
2061
2078
|
|
|
@@ -2066,8 +2083,6 @@ program
|
|
|
2066
2083
|
snow-flow mcp status # Check MCP server status
|
|
2067
2084
|
snow-flow swarm "create a widget for incident management"
|
|
2068
2085
|
snow-flow swarm "create approval flow" # š§ Auto-detects Flow Designer and uses XML!
|
|
2069
|
-
snow-flow create-flow "approval flow for hardware purchases over ā¬1000"
|
|
2070
|
-
snow-flow xml-flow "create iPhone approval flow" --table sc_request
|
|
2071
2086
|
snow-flow deploy-xml flow-update-sets/my_flow.xml # š Auto-import to ServiceNow!
|
|
2072
2087
|
snow-flow spawn widget-builder --name "IncidentWidget"
|
|
2073
2088
|
snow-flow monitor --duration 120
|
|
@@ -3779,7 +3794,6 @@ With concurrent execution and batch operations:
|
|
|
3779
3794
|
- **servicenow-deployment**: Widget, flow, and application deployment
|
|
3780
3795
|
- **servicenow-intelligent**: Smart search and artifact discovery
|
|
3781
3796
|
- **servicenow-operations**: Incident management and catalog operations
|
|
3782
|
-
- **servicenow-flow-composer**: Natural language flow creation
|
|
3783
3797
|
- **servicenow-platform-development**: Scripts, rules, and policies
|
|
3784
3798
|
|
|
3785
3799
|
### SPARC Modes
|
|
@@ -4030,7 +4044,6 @@ async function createMCPConfig(targetDir) {
|
|
|
4030
4044
|
const claudeSettings = {
|
|
4031
4045
|
"enabledMcpjsonServers": [
|
|
4032
4046
|
"servicenow-deployment",
|
|
4033
|
-
"servicenow-flow-composer",
|
|
4034
4047
|
"servicenow-update-set",
|
|
4035
4048
|
"servicenow-intelligent",
|
|
4036
4049
|
"servicenow-graph-memory",
|
|
@@ -4419,1010 +4432,6 @@ async function handleMCPDebug(options) {
|
|
|
4419
4432
|
console.log(' 3. Approve MCP servers when prompted by Claude Code');
|
|
4420
4433
|
console.log(' 4. Ensure .env file has valid ServiceNow credentials');
|
|
4421
4434
|
}
|
|
4422
|
-
// Create Flow command - intelligent flow composition
|
|
4423
|
-
program
|
|
4424
|
-
.command('create-flow <instruction>')
|
|
4425
|
-
.description('Create complex ServiceNow flows using natural language with automatic artifact orchestration')
|
|
4426
|
-
.option('--analyze-only', 'Only analyze the instruction without creating the flow')
|
|
4427
|
-
.option('--preview', 'Preview the flow structure before deployment')
|
|
4428
|
-
.option('--no-deploy', 'Create the flow but do not deploy it')
|
|
4429
|
-
.action(async (instruction, options) => {
|
|
4430
|
-
console.log(`\nš§ Snow-Flow Intelligent Flow Composer`);
|
|
4431
|
-
console.log(`š Instruction: ${instruction}`);
|
|
4432
|
-
console.log(`š Analyzing requirements and discovering artifacts...\n`);
|
|
4433
|
-
// Check authentication
|
|
4434
|
-
const oauth = new snow_oauth_js_1.ServiceNowOAuth();
|
|
4435
|
-
const isAuthenticated = await oauth.isAuthenticated();
|
|
4436
|
-
if (!isAuthenticated) {
|
|
4437
|
-
console.log('š ServiceNow connection: ā Not authenticated');
|
|
4438
|
-
console.log('š” Run "snow-flow auth login" to enable live ServiceNow integration');
|
|
4439
|
-
console.log('š Flow will be created as definition files\n');
|
|
4440
|
-
}
|
|
4441
|
-
else {
|
|
4442
|
-
console.log('š ServiceNow connection: ā
Authenticated');
|
|
4443
|
-
console.log('š Flow will be created and deployed directly to ServiceNow\n');
|
|
4444
|
-
}
|
|
4445
|
-
// Generate Claude Code prompt for flow composition
|
|
4446
|
-
const flowPrompt = `# Snow-Flow Intelligent Flow Composer
|
|
4447
|
-
|
|
4448
|
-
## Instruction
|
|
4449
|
-
${instruction}
|
|
4450
|
-
|
|
4451
|
-
## Task: Create Complex ServiceNow Flow with Multi-Artifact Orchestration
|
|
4452
|
-
|
|
4453
|
-
You are Snow-Flow's intelligent flow composer. Your task is to create a complex ServiceNow flow using natural language processing and automatic artifact orchestration.
|
|
4454
|
-
|
|
4455
|
-
## Process Steps
|
|
4456
|
-
|
|
4457
|
-
### 1. Analyze Flow Requirements
|
|
4458
|
-
Use the flow composition MCP tools to understand the instruction:
|
|
4459
|
-
- \`snow_analyze_flow_instruction\` - Parse and understand the natural language instruction
|
|
4460
|
-
- Identify required ServiceNow artifacts (script includes, business rules, tables, etc.)
|
|
4461
|
-
- Determine data flow and business logic requirements
|
|
4462
|
-
|
|
4463
|
-
### 2. Discover ServiceNow Artifacts
|
|
4464
|
-
Use intelligent artifact discovery:
|
|
4465
|
-
- \`snow_discover_flow_artifacts\` - Find existing ServiceNow artifacts that match requirements
|
|
4466
|
-
- Search for script includes, business rules, tables, and other components
|
|
4467
|
-
- Identify missing artifacts that need to be created
|
|
4468
|
-
|
|
4469
|
-
### 3. Preview Flow Structure
|
|
4470
|
-
Before deployment, preview the complete flow:
|
|
4471
|
-
- \`snow_preview_flow_structure\` - Show the complete flow structure
|
|
4472
|
-
- Display all activities, variables, and error handling
|
|
4473
|
-
- Show how discovered artifacts will be orchestrated
|
|
4474
|
-
|
|
4475
|
-
### 4. Create and Deploy Flow
|
|
4476
|
-
Create the complete flow with orchestration:
|
|
4477
|
-
- \`snow_create_complex_flow\` - Generate complete flow with all artifacts
|
|
4478
|
-
- Automatically create fallback artifacts if needed
|
|
4479
|
-
- Deploy to ServiceNow if authenticated
|
|
4480
|
-
|
|
4481
|
-
## Advanced Capabilities
|
|
4482
|
-
|
|
4483
|
-
### Multi-Artifact Orchestration
|
|
4484
|
-
The flow composer can automatically:
|
|
4485
|
-
- Find existing script includes for LLM translation
|
|
4486
|
-
- Discover business rules for data storage
|
|
4487
|
-
- Create tables for translated messages
|
|
4488
|
-
- Link all components in a cohesive flow
|
|
4489
|
-
|
|
4490
|
-
### Intelligent Fallback Creation
|
|
4491
|
-
If required artifacts are not found:
|
|
4492
|
-
- Creates basic LLM translation script includes
|
|
4493
|
-
- Generates data storage business rules
|
|
4494
|
-
- Creates database tables with proper schema
|
|
4495
|
-
- Ensures all components work together
|
|
4496
|
-
|
|
4497
|
-
### Natural Language Processing
|
|
4498
|
-
Understands complex instructions like:
|
|
4499
|
-
- "Create a flow using LLM localization to translate support desk messages to English"
|
|
4500
|
-
- "Build approval flow with email notifications after manager approval"
|
|
4501
|
-
- "Design incident escalation with automatic assignment based on priority"
|
|
4502
|
-
|
|
4503
|
-
## Available Flow Composition Tools
|
|
4504
|
-
|
|
4505
|
-
### Core Tools
|
|
4506
|
-
- \`snow_create_complex_flow\` - Main flow creation tool
|
|
4507
|
-
- \`snow_analyze_flow_instruction\` - Instruction analysis
|
|
4508
|
-
- \`snow_discover_flow_artifacts\` - Artifact discovery
|
|
4509
|
-
- \`snow_preview_flow_structure\` - Flow preview
|
|
4510
|
-
|
|
4511
|
-
### Configuration
|
|
4512
|
-
- Deploy immediately: ${!options.noDeploy}
|
|
4513
|
-
- Analysis only: ${options.analyzeOnly || false}
|
|
4514
|
-
- Preview mode: ${options.preview || false}
|
|
4515
|
-
- ServiceNow authenticated: ${isAuthenticated}
|
|
4516
|
-
|
|
4517
|
-
## Expected Output
|
|
4518
|
-
|
|
4519
|
-
The flow composer will:
|
|
4520
|
-
1. Parse your natural language instruction
|
|
4521
|
-
2. Identify all required ServiceNow artifacts
|
|
4522
|
-
3. Discover existing artifacts or create fallbacks
|
|
4523
|
-
4. Compose a complete flow with orchestration
|
|
4524
|
-
5. Deploy to ServiceNow (if authenticated)
|
|
4525
|
-
6. Provide direct links to created artifacts
|
|
4526
|
-
|
|
4527
|
-
## Instructions for Execution
|
|
4528
|
-
|
|
4529
|
-
${options.analyzeOnly ?
|
|
4530
|
-
'ANALYZE ONLY: Use snow_analyze_flow_instruction to analyze the instruction and show requirements.' :
|
|
4531
|
-
options.preview ?
|
|
4532
|
-
'PREVIEW MODE: Use snow_preview_flow_structure to show the complete flow structure before deployment.' :
|
|
4533
|
-
'FULL CREATION: Use snow_create_complex_flow to create and deploy the complete flow with orchestration.'}
|
|
4534
|
-
|
|
4535
|
-
Execute this intelligent flow composition using Snow-Flow's advanced orchestration capabilities.
|
|
4536
|
-
`;
|
|
4537
|
-
try {
|
|
4538
|
-
// Execute Claude Code with the flow composition prompt
|
|
4539
|
-
const success = await executeClaudeCode(flowPrompt);
|
|
4540
|
-
if (success) {
|
|
4541
|
-
console.log('\nā
Flow composition completed successfully!');
|
|
4542
|
-
if (isAuthenticated && !options.noDeploy) {
|
|
4543
|
-
console.log('š Flow deployed to ServiceNow with all artifacts');
|
|
4544
|
-
console.log('š Check your ServiceNow instance for the deployed flow');
|
|
4545
|
-
}
|
|
4546
|
-
else {
|
|
4547
|
-
console.log('š Flow structure created and analyzed');
|
|
4548
|
-
}
|
|
4549
|
-
}
|
|
4550
|
-
else {
|
|
4551
|
-
console.log('\nā ļø Claude Code execution failed. Flow composition prompt generated:');
|
|
4552
|
-
console.log('='.repeat(80));
|
|
4553
|
-
console.log(flowPrompt);
|
|
4554
|
-
console.log('='.repeat(80));
|
|
4555
|
-
console.log('\nš” Copy this prompt and run it in Claude Code for flow composition');
|
|
4556
|
-
}
|
|
4557
|
-
}
|
|
4558
|
-
catch (error) {
|
|
4559
|
-
console.error('ā Flow composition failed:', error instanceof Error ? error.message : String(error));
|
|
4560
|
-
}
|
|
4561
|
-
});
|
|
4562
|
-
// XML Flow command - Create flows using XML-first approach for maximum reliability
|
|
4563
|
-
program
|
|
4564
|
-
.command('xml-flow <instruction>')
|
|
4565
|
-
.description('šÆ Create ServiceNow flows using XML-first approach - MOST RELIABLE method!')
|
|
4566
|
-
.option('--name <name>', 'Flow name (auto-generated if not provided)')
|
|
4567
|
-
.option('--table <table>', 'Target table (e.g., incident, sc_request)')
|
|
4568
|
-
.option('--trigger <type>', 'Trigger type (record_created, record_updated, manual, scheduled)', 'record_created')
|
|
4569
|
-
.option('--output <path>', 'Output XML file path')
|
|
4570
|
-
.option('--import', 'Show import instructions after generation', true)
|
|
4571
|
-
.option('--no-import', 'Skip import instructions')
|
|
4572
|
-
.option('--test', 'Generate test flow with mock data')
|
|
4573
|
-
.option('--update-set <name>', 'Custom Update Set name')
|
|
4574
|
-
.action(async (instruction, options) => {
|
|
4575
|
-
console.log(`\nš§ XML-First Flow Generator v${version_js_1.VERSION}`);
|
|
4576
|
-
console.log('š Creating production-ready ServiceNow flow XML...\n');
|
|
4577
|
-
try {
|
|
4578
|
-
// Import IMPROVED XML flow generator (fixes "too small to work" issue!)
|
|
4579
|
-
const { generateImprovedFlowXML } = await Promise.resolve().then(() => __importStar(require('./utils/improved-flow-xml-generator.js')));
|
|
4580
|
-
// Parse instruction to determine activities
|
|
4581
|
-
const activities = [];
|
|
4582
|
-
// Check for common patterns in instruction
|
|
4583
|
-
const instructionLower = instruction.toLowerCase();
|
|
4584
|
-
if (instructionLower.includes('approval') || instructionLower.includes('approve')) {
|
|
4585
|
-
activities.push({
|
|
4586
|
-
name: 'Request Approval',
|
|
4587
|
-
type: 'approval',
|
|
4588
|
-
order: 100,
|
|
4589
|
-
inputs: {
|
|
4590
|
-
table: options.table || 'sc_request',
|
|
4591
|
-
record: '{{trigger.current.sys_id}}',
|
|
4592
|
-
approver: '{{trigger.current.requested_for.manager}}',
|
|
4593
|
-
approval_field: 'approval',
|
|
4594
|
-
message: `Please approve: {{trigger.current.number}}`
|
|
4595
|
-
},
|
|
4596
|
-
outputs: {
|
|
4597
|
-
state: 'string',
|
|
4598
|
-
approver_sys_id: 'string',
|
|
4599
|
-
comments: 'string'
|
|
4600
|
-
}
|
|
4601
|
-
});
|
|
4602
|
-
}
|
|
4603
|
-
if (instructionLower.includes('notification') || instructionLower.includes('email') || instructionLower.includes('notify')) {
|
|
4604
|
-
activities.push({
|
|
4605
|
-
name: 'Send Notification',
|
|
4606
|
-
type: 'notification',
|
|
4607
|
-
order: activities.length > 0 ? 200 : 100,
|
|
4608
|
-
inputs: {
|
|
4609
|
-
notification_id: (0, servicenow_id_generator_js_1.getNotificationTemplateSysId)('generic_notification'),
|
|
4610
|
-
recipients: '{{trigger.current.requested_for}}',
|
|
4611
|
-
values: {
|
|
4612
|
-
request_number: '{{trigger.current.number}}',
|
|
4613
|
-
status: 'Notification sent'
|
|
4614
|
-
}
|
|
4615
|
-
}
|
|
4616
|
-
});
|
|
4617
|
-
}
|
|
4618
|
-
// Build flow definition
|
|
4619
|
-
const flowDef = {
|
|
4620
|
-
name: options.name || `Flow_${instruction.substring(0, 30).replace(/[^a-zA-Z0-9]/g, '_')}`,
|
|
4621
|
-
description: instruction,
|
|
4622
|
-
table: options.table || 'incident',
|
|
4623
|
-
trigger_type: options.trigger,
|
|
4624
|
-
trigger_condition: '',
|
|
4625
|
-
activities: activities.length > 0 ? activities : null
|
|
4626
|
-
};
|
|
4627
|
-
// Add default activities if none specified
|
|
4628
|
-
if (!flowDef.activities || flowDef.activities.length === 0) {
|
|
4629
|
-
// Default activities if none specified
|
|
4630
|
-
console.log('ā ļø No specific activities detected, adding default workflow...');
|
|
4631
|
-
flowDef.activities = [
|
|
4632
|
-
{
|
|
4633
|
-
name: 'Log Flow Start',
|
|
4634
|
-
type: 'script',
|
|
4635
|
-
order: 100,
|
|
4636
|
-
inputs: {
|
|
4637
|
-
script: `gs.info('Flow started for: ' + current.number, 'XMLFlow');
|
|
4638
|
-
return { started: true };`
|
|
4639
|
-
},
|
|
4640
|
-
outputs: { started: 'boolean' }
|
|
4641
|
-
},
|
|
4642
|
-
{
|
|
4643
|
-
name: 'Send Notification',
|
|
4644
|
-
type: 'notification',
|
|
4645
|
-
order: 200,
|
|
4646
|
-
inputs: {
|
|
4647
|
-
notification_id: (0, servicenow_id_generator_js_1.getNotificationTemplateSysId)('generic_notification'),
|
|
4648
|
-
recipients: '{{trigger.current.opened_by}}',
|
|
4649
|
-
values: {
|
|
4650
|
-
record_number: '{{trigger.current.number}}',
|
|
4651
|
-
status: 'Flow triggered'
|
|
4652
|
-
}
|
|
4653
|
-
}
|
|
4654
|
-
}
|
|
4655
|
-
];
|
|
4656
|
-
}
|
|
4657
|
-
// Generate IMPROVED XML with enhanced structure
|
|
4658
|
-
console.log('\nšļø Generating IMPROVED production XML...');
|
|
4659
|
-
// Convert to improved flow definition
|
|
4660
|
-
const improvedFlowDef = {
|
|
4661
|
-
...flowDef,
|
|
4662
|
-
run_as: 'user',
|
|
4663
|
-
accessible_from: 'package_private',
|
|
4664
|
-
category: 'custom',
|
|
4665
|
-
tags: ['cli-generated'],
|
|
4666
|
-
activities: flowDef.activities.map((act) => ({
|
|
4667
|
-
...act,
|
|
4668
|
-
description: act.description || act.name
|
|
4669
|
-
}))
|
|
4670
|
-
};
|
|
4671
|
-
const result = generateImprovedFlowXML(improvedFlowDef);
|
|
4672
|
-
console.log(`\nā
IMPROVED XML Generated Successfully!`);
|
|
4673
|
-
console.log(`š File saved to: ${result.filePath}`);
|
|
4674
|
-
console.log(`š„ IMPROVEMENTS: Uses v2 tables, Base64+gzip encoding, complete label_cache!`);
|
|
4675
|
-
console.log(`š Flow structure:`);
|
|
4676
|
-
console.log(` - Name: ${flowDef.name}`);
|
|
4677
|
-
console.log(` - Table: ${flowDef.table}`);
|
|
4678
|
-
console.log(` - Trigger: ${flowDef.trigger_type}`);
|
|
4679
|
-
console.log(` - Activities: ${flowDef.activities.length}`);
|
|
4680
|
-
if (options.import) {
|
|
4681
|
-
console.log('\n' + '='.repeat(60));
|
|
4682
|
-
console.log(result.instructions);
|
|
4683
|
-
console.log('='.repeat(60));
|
|
4684
|
-
}
|
|
4685
|
-
console.log('\nšÆ Next Steps:');
|
|
4686
|
-
console.log('1. Import the XML file into ServiceNow');
|
|
4687
|
-
console.log('2. Preview the Update Set');
|
|
4688
|
-
console.log('3. Commit the Update Set');
|
|
4689
|
-
console.log('4. Open Flow Designer to see your flow!');
|
|
4690
|
-
// Helper function to map action types
|
|
4691
|
-
function mapActionType(type) {
|
|
4692
|
-
const typeMap = {
|
|
4693
|
-
'email': 'notification',
|
|
4694
|
-
'notify': 'notification',
|
|
4695
|
-
'approve': 'approval',
|
|
4696
|
-
'script': 'script',
|
|
4697
|
-
'create': 'create_record',
|
|
4698
|
-
'update': 'update_record',
|
|
4699
|
-
'rest': 'rest_step',
|
|
4700
|
-
'api': 'rest_step'
|
|
4701
|
-
};
|
|
4702
|
-
return typeMap[type.toLowerCase()] || 'script';
|
|
4703
|
-
}
|
|
4704
|
-
}
|
|
4705
|
-
catch (error) {
|
|
4706
|
-
console.error('ā XML flow generation failed:', error instanceof Error ? error.message : String(error));
|
|
4707
|
-
process.exit(1);
|
|
4708
|
-
}
|
|
4709
|
-
});
|
|
4710
|
-
// Parse command line arguments
|
|
4711
|
-
// Init command - initialize a new Snow-Flow project
|
|
4712
|
-
program
|
|
4713
|
-
.command('init')
|
|
4714
|
-
.description('Initialize a new Snow-Flow project')
|
|
4715
|
-
.option('--sparc', 'Initialize with full SPARC development environment')
|
|
4716
|
-
.option('--force', 'Force reinitialize if project already exists')
|
|
4717
|
-
.action(async (options) => {
|
|
4718
|
-
const targetDir = process.cwd();
|
|
4719
|
-
try {
|
|
4720
|
-
console.log('š Initializing Snow-Flow project...\n');
|
|
4721
|
-
// Check if project is already initialized
|
|
4722
|
-
const claudeDir = (0, path_1.join)(targetDir, '.claude');
|
|
4723
|
-
if (!options.force) {
|
|
4724
|
-
try {
|
|
4725
|
-
await fs_1.promises.access(claudeDir);
|
|
4726
|
-
console.log('ā Snow-Flow project already initialized. Use --force to reinitialize.');
|
|
4727
|
-
return;
|
|
4728
|
-
}
|
|
4729
|
-
catch {
|
|
4730
|
-
// Directory doesn't exist, continue with initialization
|
|
4731
|
-
}
|
|
4732
|
-
}
|
|
4733
|
-
// Phase 1: Create basic structure
|
|
4734
|
-
console.log('š Creating directory structure...');
|
|
4735
|
-
await createDirectoryStructure(targetDir);
|
|
4736
|
-
console.log('ā
Directory structure created\n');
|
|
4737
|
-
// Phase 2: Create configuration files
|
|
4738
|
-
console.log('āļø Creating configuration files...');
|
|
4739
|
-
await createBasicConfig(targetDir);
|
|
4740
|
-
console.log('ā
Configuration files created\n');
|
|
4741
|
-
// Phase 3: Create README files
|
|
4742
|
-
console.log('š Creating documentation...');
|
|
4743
|
-
await createReadmeFiles(targetDir);
|
|
4744
|
-
console.log('ā
Documentation created\n');
|
|
4745
|
-
if (options.sparc) {
|
|
4746
|
-
console.log('šÆ Creating SPARC environment...');
|
|
4747
|
-
await createSparcFiles(targetDir);
|
|
4748
|
-
console.log('ā
SPARC environment created');
|
|
4749
|
-
console.log('š Added swarm documentation:');
|
|
4750
|
-
console.log(' - swarm-patterns.md: Common swarm command examples');
|
|
4751
|
-
console.log(' - agent-types.md: Agent specializations guide');
|
|
4752
|
-
console.log(' - mcp-tools-quick-ref.md: MCP tools reference');
|
|
4753
|
-
console.log(' - examples/: Ready-to-run example scripts');
|
|
4754
|
-
console.log(' - memory/patterns/: Success patterns and templates\n');
|
|
4755
|
-
}
|
|
4756
|
-
// Phase 4: Create .env file
|
|
4757
|
-
console.log('š Creating environment configuration...');
|
|
4758
|
-
await createEnvFile(targetDir);
|
|
4759
|
-
console.log('ā
Environment file created\n');
|
|
4760
|
-
// Phase 4.5: Check for Neo4j and offer graph memory setup
|
|
4761
|
-
console.log('š§ Checking for Neo4j Graph Memory support...');
|
|
4762
|
-
const neo4jAvailable = await checkNeo4jAvailability();
|
|
4763
|
-
let enableGraphMemory = false;
|
|
4764
|
-
if (neo4jAvailable) {
|
|
4765
|
-
console.log('ā
Neo4j detected! Graph memory features available.');
|
|
4766
|
-
console.log('\nš Graph Memory provides:');
|
|
4767
|
-
console.log(' - Intelligent artifact relationship tracking');
|
|
4768
|
-
console.log(' - Impact analysis for changes');
|
|
4769
|
-
console.log(' - Dependency visualization');
|
|
4770
|
-
console.log(' - Pattern recognition across projects\n');
|
|
4771
|
-
const readline = require('readline');
|
|
4772
|
-
const rl = readline.createInterface({
|
|
4773
|
-
input: process.stdin,
|
|
4774
|
-
output: process.stdout
|
|
4775
|
-
});
|
|
4776
|
-
const answer = await new Promise((resolve) => {
|
|
4777
|
-
rl.question('Enable graph memory features? (Y/n): ', resolve);
|
|
4778
|
-
});
|
|
4779
|
-
rl.close();
|
|
4780
|
-
enableGraphMemory = answer.toLowerCase() !== 'n';
|
|
4781
|
-
if (enableGraphMemory) {
|
|
4782
|
-
console.log('ā
Graph memory enabled\n');
|
|
4783
|
-
// Add Neo4j config to .env
|
|
4784
|
-
await appendToEnvFile(targetDir, `
|
|
4785
|
-
# Neo4j Graph Memory Configuration
|
|
4786
|
-
NEO4J_URI=bolt://localhost:7687
|
|
4787
|
-
NEO4J_USER=neo4j
|
|
4788
|
-
NEO4J_PASSWORD=password
|
|
4789
|
-
`);
|
|
4790
|
-
}
|
|
4791
|
-
}
|
|
4792
|
-
else {
|
|
4793
|
-
console.log('ā¹ļø Neo4j not detected. Graph memory features will be disabled.');
|
|
4794
|
-
console.log(' To enable later: brew install neo4j && neo4j start\n');
|
|
4795
|
-
}
|
|
4796
|
-
// Phase 5: Create MCP configuration and Claude Code settings
|
|
4797
|
-
console.log('š MCP server configuration will be generated after build...');
|
|
4798
|
-
console.log('āļø Claude Code settings configured with:\n');
|
|
4799
|
-
console.log(' - No timeouts (unlimited execution time)');
|
|
4800
|
-
console.log(' - All batch tools enabled (TodoWrite, Task, Memory)');
|
|
4801
|
-
console.log(' - ServiceNow MCP server integration');
|
|
4802
|
-
console.log(' - Automation and parallel execution enabled');
|
|
4803
|
-
console.log(' - Extended output limits and thinking tokens\n');
|
|
4804
|
-
// Phase 6: Build project and start MCP servers
|
|
4805
|
-
console.log('š§ Setting up MCP servers...');
|
|
4806
|
-
// Check if we're running from npm global install or local dev
|
|
4807
|
-
const isGlobalInstall = __dirname.includes('node_modules') || !(0, fs_2.existsSync)((0, path_1.join)(targetDir, 'src'));
|
|
4808
|
-
let mcpConfig;
|
|
4809
|
-
try {
|
|
4810
|
-
if (!isGlobalInstall) {
|
|
4811
|
-
// Only build if we're in development mode with source files
|
|
4812
|
-
console.log('šļø Building project (compiling TypeScript)...');
|
|
4813
|
-
const { spawn } = require('child_process');
|
|
4814
|
-
const buildProcess = spawn('npm', ['run', 'build'], {
|
|
4815
|
-
cwd: targetDir,
|
|
4816
|
-
stdio: 'pipe'
|
|
4817
|
-
});
|
|
4818
|
-
await new Promise((resolve, reject) => {
|
|
4819
|
-
buildProcess.on('close', (code) => {
|
|
4820
|
-
if (code === 0) {
|
|
4821
|
-
resolve(undefined);
|
|
4822
|
-
}
|
|
4823
|
-
else {
|
|
4824
|
-
reject(new Error(`Build failed with code ${code}`));
|
|
4825
|
-
}
|
|
4826
|
-
});
|
|
4827
|
-
});
|
|
4828
|
-
console.log('ā
Project built successfully');
|
|
4829
|
-
}
|
|
4830
|
-
else {
|
|
4831
|
-
console.log('ā
Using pre-built MCP servers from npm package');
|
|
4832
|
-
}
|
|
4833
|
-
// Generate MCP configuration directly
|
|
4834
|
-
console.log('š§ Generating MCP configuration...');
|
|
4835
|
-
// Determine the correct path to MCP servers
|
|
4836
|
-
let mcpBasePath;
|
|
4837
|
-
if (isGlobalInstall) {
|
|
4838
|
-
// For global installs, find the global npm modules path
|
|
4839
|
-
const { execSync } = require('child_process');
|
|
4840
|
-
const globalRoot = execSync('npm root -g', { encoding: 'utf8' }).trim();
|
|
4841
|
-
mcpBasePath = (0, path_1.join)(globalRoot, 'snow-flow', 'dist', 'mcp');
|
|
4842
|
-
}
|
|
4843
|
-
else {
|
|
4844
|
-
// For local installs, use the current directory
|
|
4845
|
-
mcpBasePath = (0, path_1.join)(targetDir, 'dist', 'mcp');
|
|
4846
|
-
}
|
|
4847
|
-
// Read environment variables from .env if it exists
|
|
4848
|
-
const envPath = (0, path_1.join)(targetDir, '.env');
|
|
4849
|
-
let envVars = {};
|
|
4850
|
-
if ((0, fs_2.existsSync)(envPath)) {
|
|
4851
|
-
const envContent = await fs_1.promises.readFile(envPath, 'utf8');
|
|
4852
|
-
envContent.split('\n').forEach(line => {
|
|
4853
|
-
const [key, value] = line.split('=');
|
|
4854
|
-
if (key && value) {
|
|
4855
|
-
envVars[key.trim()] = value.trim();
|
|
4856
|
-
}
|
|
4857
|
-
});
|
|
4858
|
-
}
|
|
4859
|
-
// Generate .mcp.json with correct paths
|
|
4860
|
-
const mcpServers = {
|
|
4861
|
-
"servicenow-deployment": {
|
|
4862
|
-
command: "node",
|
|
4863
|
-
args: [(0, path_1.join)(mcpBasePath, "servicenow-deployment-mcp.js")],
|
|
4864
|
-
env: {
|
|
4865
|
-
SNOW_INSTANCE: envVars.SNOW_INSTANCE || "your-instance.service-now.com",
|
|
4866
|
-
SNOW_CLIENT_ID: envVars.SNOW_CLIENT_ID || "your-oauth-client-id",
|
|
4867
|
-
SNOW_CLIENT_SECRET: envVars.SNOW_CLIENT_SECRET || "your-oauth-client-secret"
|
|
4868
|
-
}
|
|
4869
|
-
},
|
|
4870
|
-
"servicenow-flow-composer": {
|
|
4871
|
-
command: "node",
|
|
4872
|
-
args: [(0, path_1.join)(mcpBasePath, "servicenow-flow-composer-mcp.js")],
|
|
4873
|
-
env: {
|
|
4874
|
-
SNOW_INSTANCE: envVars.SNOW_INSTANCE || "your-instance.service-now.com",
|
|
4875
|
-
SNOW_CLIENT_ID: envVars.SNOW_CLIENT_ID || "your-oauth-client-id",
|
|
4876
|
-
SNOW_CLIENT_SECRET: envVars.SNOW_CLIENT_SECRET || "your-oauth-client-secret"
|
|
4877
|
-
}
|
|
4878
|
-
},
|
|
4879
|
-
"servicenow-update-set": {
|
|
4880
|
-
command: "node",
|
|
4881
|
-
args: [(0, path_1.join)(mcpBasePath, "servicenow-update-set-mcp.js")],
|
|
4882
|
-
env: {
|
|
4883
|
-
SNOW_INSTANCE: envVars.SNOW_INSTANCE || "your-instance.service-now.com",
|
|
4884
|
-
SNOW_CLIENT_ID: envVars.SNOW_CLIENT_ID || "your-oauth-client-id",
|
|
4885
|
-
SNOW_CLIENT_SECRET: envVars.SNOW_CLIENT_SECRET || "your-oauth-client-secret"
|
|
4886
|
-
}
|
|
4887
|
-
},
|
|
4888
|
-
"servicenow-intelligent": {
|
|
4889
|
-
command: "node",
|
|
4890
|
-
args: [(0, path_1.join)(mcpBasePath, "servicenow-intelligent-mcp.js")],
|
|
4891
|
-
env: {
|
|
4892
|
-
SNOW_INSTANCE: envVars.SNOW_INSTANCE || "your-instance.service-now.com",
|
|
4893
|
-
SNOW_CLIENT_ID: envVars.SNOW_CLIENT_ID || "your-oauth-client-id",
|
|
4894
|
-
SNOW_CLIENT_SECRET: envVars.SNOW_CLIENT_SECRET || "your-oauth-client-secret"
|
|
4895
|
-
}
|
|
4896
|
-
}
|
|
4897
|
-
};
|
|
4898
|
-
// Only add graph memory if Neo4j is enabled
|
|
4899
|
-
if (enableGraphMemory) {
|
|
4900
|
-
mcpServers["servicenow-graph-memory"] = {
|
|
4901
|
-
command: "node",
|
|
4902
|
-
args: [(0, path_1.join)(mcpBasePath, "servicenow-graph-memory-mcp.js")],
|
|
4903
|
-
env: {
|
|
4904
|
-
NEO4J_URI: envVars.NEO4J_URI || "bolt://localhost:7687",
|
|
4905
|
-
NEO4J_USER: envVars.NEO4J_USER || "neo4j",
|
|
4906
|
-
NEO4J_PASSWORD: envVars.NEO4J_PASSWORD || "password",
|
|
4907
|
-
SNOW_INSTANCE: envVars.SNOW_INSTANCE || "your-instance.service-now.com",
|
|
4908
|
-
SNOW_CLIENT_ID: envVars.SNOW_CLIENT_ID || "your-oauth-client-id",
|
|
4909
|
-
SNOW_CLIENT_SECRET: envVars.SNOW_CLIENT_SECRET || "your-oauth-client-secret"
|
|
4910
|
-
}
|
|
4911
|
-
};
|
|
4912
|
-
}
|
|
4913
|
-
// Add remaining servers
|
|
4914
|
-
Object.assign(mcpServers, {
|
|
4915
|
-
"servicenow-operations": {
|
|
4916
|
-
command: "node",
|
|
4917
|
-
args: [(0, path_1.join)(mcpBasePath, "servicenow-operations-mcp.js")],
|
|
4918
|
-
env: {
|
|
4919
|
-
SNOW_INSTANCE: envVars.SNOW_INSTANCE || "your-instance.service-now.com",
|
|
4920
|
-
SNOW_CLIENT_ID: envVars.SNOW_CLIENT_ID || "your-oauth-client-id",
|
|
4921
|
-
SNOW_CLIENT_SECRET: envVars.SNOW_CLIENT_SECRET || "your-oauth-client-secret"
|
|
4922
|
-
}
|
|
4923
|
-
},
|
|
4924
|
-
"servicenow-platform-development": {
|
|
4925
|
-
command: "node",
|
|
4926
|
-
args: [(0, path_1.join)(mcpBasePath, "servicenow-platform-development-mcp.js")],
|
|
4927
|
-
env: {
|
|
4928
|
-
SNOW_INSTANCE: envVars.SNOW_INSTANCE || "your-instance.service-now.com",
|
|
4929
|
-
SNOW_CLIENT_ID: envVars.SNOW_CLIENT_ID || "your-oauth-client-id",
|
|
4930
|
-
SNOW_CLIENT_SECRET: envVars.SNOW_CLIENT_SECRET || "your-oauth-client-secret"
|
|
4931
|
-
}
|
|
4932
|
-
},
|
|
4933
|
-
"servicenow-integration": {
|
|
4934
|
-
command: "node",
|
|
4935
|
-
args: [(0, path_1.join)(mcpBasePath, "servicenow-integration-mcp.js")],
|
|
4936
|
-
env: {
|
|
4937
|
-
SNOW_INSTANCE: envVars.SNOW_INSTANCE || "your-instance.service-now.com",
|
|
4938
|
-
SNOW_CLIENT_ID: envVars.SNOW_CLIENT_ID || "your-oauth-client-id",
|
|
4939
|
-
SNOW_CLIENT_SECRET: envVars.SNOW_CLIENT_SECRET || "your-oauth-client-secret"
|
|
4940
|
-
}
|
|
4941
|
-
},
|
|
4942
|
-
"servicenow-automation": {
|
|
4943
|
-
command: "node",
|
|
4944
|
-
args: [(0, path_1.join)(mcpBasePath, "servicenow-automation-mcp.js")],
|
|
4945
|
-
env: {
|
|
4946
|
-
SNOW_INSTANCE: envVars.SNOW_INSTANCE || "your-instance.service-now.com",
|
|
4947
|
-
SNOW_CLIENT_ID: envVars.SNOW_CLIENT_ID || "your-oauth-client-id",
|
|
4948
|
-
SNOW_CLIENT_SECRET: envVars.SNOW_CLIENT_SECRET || "your-oauth-client-secret"
|
|
4949
|
-
}
|
|
4950
|
-
},
|
|
4951
|
-
"servicenow-security-compliance": {
|
|
4952
|
-
command: "node",
|
|
4953
|
-
args: [(0, path_1.join)(mcpBasePath, "servicenow-security-compliance-mcp.js")],
|
|
4954
|
-
env: {
|
|
4955
|
-
SNOW_INSTANCE: envVars.SNOW_INSTANCE || "your-instance.service-now.com",
|
|
4956
|
-
SNOW_CLIENT_ID: envVars.SNOW_CLIENT_ID || "your-oauth-client-id",
|
|
4957
|
-
SNOW_CLIENT_SECRET: envVars.SNOW_CLIENT_SECRET || "your-oauth-client-secret"
|
|
4958
|
-
}
|
|
4959
|
-
},
|
|
4960
|
-
"servicenow-reporting-analytics": {
|
|
4961
|
-
command: "node",
|
|
4962
|
-
args: [(0, path_1.join)(mcpBasePath, "servicenow-reporting-analytics-mcp.js")],
|
|
4963
|
-
env: {
|
|
4964
|
-
SNOW_INSTANCE: envVars.SNOW_INSTANCE || "your-instance.service-now.com",
|
|
4965
|
-
SNOW_CLIENT_ID: envVars.SNOW_CLIENT_ID || "your-oauth-client-id",
|
|
4966
|
-
SNOW_CLIENT_SECRET: envVars.SNOW_CLIENT_SECRET || "your-oauth-client-secret"
|
|
4967
|
-
}
|
|
4968
|
-
},
|
|
4969
|
-
"servicenow-memory": {
|
|
4970
|
-
command: "node",
|
|
4971
|
-
args: [(0, path_1.join)(mcpBasePath, "servicenow-memory-mcp.js")],
|
|
4972
|
-
env: {
|
|
4973
|
-
SNOW_INSTANCE: envVars.SNOW_INSTANCE || "your-instance.service-now.com",
|
|
4974
|
-
SNOW_CLIENT_ID: envVars.SNOW_CLIENT_ID || "your-oauth-client-id",
|
|
4975
|
-
SNOW_CLIENT_SECRET: envVars.SNOW_CLIENT_SECRET || "your-oauth-client-secret"
|
|
4976
|
-
}
|
|
4977
|
-
},
|
|
4978
|
-
"snow-flow": {
|
|
4979
|
-
command: "npx",
|
|
4980
|
-
args: ["claude-flow@alpha", "mcp"],
|
|
4981
|
-
env: {}
|
|
4982
|
-
},
|
|
4983
|
-
"ruv-swarm": {
|
|
4984
|
-
command: "npx",
|
|
4985
|
-
args: ["claude-flow@alpha", "swarm", "--mode", "mcp"],
|
|
4986
|
-
env: {}
|
|
4987
|
-
}
|
|
4988
|
-
});
|
|
4989
|
-
// Create the final mcpConfig
|
|
4990
|
-
mcpConfig = {
|
|
4991
|
-
mcpServers: mcpServers
|
|
4992
|
-
};
|
|
4993
|
-
// Now initialize and start MCP servers
|
|
4994
|
-
const { MCPServerManager } = await Promise.resolve().then(() => __importStar(require('./utils/mcp-server-manager.js')));
|
|
4995
|
-
const manager = new MCPServerManager();
|
|
4996
|
-
await manager.initialize();
|
|
4997
|
-
console.log('ā
MCP server manager initialized');
|
|
4998
|
-
console.log('š” Starting MCP servers...');
|
|
4999
|
-
await manager.startAllServers();
|
|
5000
|
-
const status = manager.getServerStatus();
|
|
5001
|
-
const running = status.filter(s => s.status === 'running').length;
|
|
5002
|
-
const total = status.length;
|
|
5003
|
-
if (running > 0) {
|
|
5004
|
-
console.log(`ā
Started ${running}/${total} MCP servers`);
|
|
5005
|
-
console.log('š MCP servers are now running and available in Claude Code!');
|
|
5006
|
-
}
|
|
5007
|
-
else {
|
|
5008
|
-
console.log('ā ļø MCP servers configured but failed to start');
|
|
5009
|
-
}
|
|
5010
|
-
// Write .mcp.json to project directory AFTER all initialization
|
|
5011
|
-
const mcpPath = (0, path_1.join)(targetDir, '.mcp.json');
|
|
5012
|
-
// Check if .mcp.json already exists (might have been copied)
|
|
5013
|
-
if ((0, fs_2.existsSync)(mcpPath)) {
|
|
5014
|
-
console.log('ā ļø Overwriting existing .mcp.json with correct paths...');
|
|
5015
|
-
}
|
|
5016
|
-
await fs_1.promises.writeFile(mcpPath, JSON.stringify(mcpConfig, null, 2));
|
|
5017
|
-
console.log('ā
MCP configuration generated with correct paths');
|
|
5018
|
-
console.log(`š¦ MCP servers location: ${mcpBasePath}`);
|
|
5019
|
-
// Phase 7: Create Claude Code settings with enabledMcpjsonServers
|
|
5020
|
-
let claudeSettingsCreated = false;
|
|
5021
|
-
try {
|
|
5022
|
-
// First try to copy from template if available (in npm package)
|
|
5023
|
-
const templatePath = (0, path_1.join)(__dirname, '..', '.claude.settings.template');
|
|
5024
|
-
const claudeSettingsPath = (0, path_1.join)(targetDir, '.claude/settings.json');
|
|
5025
|
-
if ((0, fs_2.existsSync)(templatePath)) {
|
|
5026
|
-
const templateContent = await fs_1.promises.readFile(templatePath, 'utf8');
|
|
5027
|
-
await fs_1.promises.writeFile(claudeSettingsPath, templateContent);
|
|
5028
|
-
console.log('ā
Claude Code settings.json created from template');
|
|
5029
|
-
claudeSettingsCreated = true;
|
|
5030
|
-
}
|
|
5031
|
-
}
|
|
5032
|
-
catch (error) {
|
|
5033
|
-
// Template not found, create from scratch
|
|
5034
|
-
}
|
|
5035
|
-
if (!claudeSettingsCreated) {
|
|
5036
|
-
// Create settings from scratch if template not found
|
|
5037
|
-
const claudeSettings = {
|
|
5038
|
-
"enabledMcpjsonServers": [
|
|
5039
|
-
"servicenow-deployment",
|
|
5040
|
-
"servicenow-flow-composer",
|
|
5041
|
-
"servicenow-update-set",
|
|
5042
|
-
"servicenow-intelligent",
|
|
5043
|
-
"servicenow-graph-memory",
|
|
5044
|
-
"servicenow-operations",
|
|
5045
|
-
"servicenow-platform-development",
|
|
5046
|
-
"servicenow-integration",
|
|
5047
|
-
"servicenow-automation",
|
|
5048
|
-
"servicenow-security-compliance",
|
|
5049
|
-
"servicenow-reporting-analytics",
|
|
5050
|
-
"snow-flow",
|
|
5051
|
-
"ruv-swarm"
|
|
5052
|
-
],
|
|
5053
|
-
"permissions": {
|
|
5054
|
-
"allow": [
|
|
5055
|
-
"Bash(*)",
|
|
5056
|
-
"Read(*)",
|
|
5057
|
-
"Write(*)",
|
|
5058
|
-
"Edit(*)",
|
|
5059
|
-
"MultiEdit(*)",
|
|
5060
|
-
"Glob(*)",
|
|
5061
|
-
"Grep(*)",
|
|
5062
|
-
"LS(*)",
|
|
5063
|
-
"TodoWrite",
|
|
5064
|
-
"Task(*)",
|
|
5065
|
-
"mcp__servicenow-*",
|
|
5066
|
-
"mcp__snow-flow__*"
|
|
5067
|
-
]
|
|
5068
|
-
},
|
|
5069
|
-
"env": {
|
|
5070
|
-
"BASH_DEFAULT_TIMEOUT_MS": "0",
|
|
5071
|
-
"BASH_MAX_TIMEOUT_MS": "0"
|
|
5072
|
-
}
|
|
5073
|
-
};
|
|
5074
|
-
const claudeSettingsPath = (0, path_1.join)(targetDir, '.claude/settings.json');
|
|
5075
|
-
await fs_1.promises.writeFile(claudeSettingsPath, JSON.stringify(claudeSettings, null, 2));
|
|
5076
|
-
console.log('ā
Claude Code settings.json created with MCP server enablement');
|
|
5077
|
-
}
|
|
5078
|
-
// Phase 7.5: Create .claude/mcp-config.json for additional MCP configuration
|
|
5079
|
-
try {
|
|
5080
|
-
const mcpConfigTemplate = (0, path_1.join)(__dirname, '..', '.claude.mcp-config.template');
|
|
5081
|
-
const mcpConfigPath = (0, path_1.join)(targetDir, '.claude/mcp-config.json');
|
|
5082
|
-
if ((0, fs_2.existsSync)(mcpConfigTemplate)) {
|
|
5083
|
-
// Read template and replace placeholders
|
|
5084
|
-
let mcpConfigContent = await fs_1.promises.readFile(mcpConfigTemplate, 'utf8');
|
|
5085
|
-
mcpConfigContent = mcpConfigContent.replace(/\${MCP_PATH}/g, mcpBasePath);
|
|
5086
|
-
await fs_1.promises.writeFile(mcpConfigPath, mcpConfigContent);
|
|
5087
|
-
console.log('ā
Created .claude/mcp-config.json for additional MCP configuration');
|
|
5088
|
-
}
|
|
5089
|
-
}
|
|
5090
|
-
catch (error) {
|
|
5091
|
-
// Not critical if this fails
|
|
5092
|
-
}
|
|
5093
|
-
// Phase 8: Claude Code will automatically load .mcp.json
|
|
5094
|
-
console.log('\nš” MCP servers configured for Claude Code');
|
|
5095
|
-
console.log('ā
Claude Code will automatically detect .mcp.json in this directory');
|
|
5096
|
-
console.log('\nš Debug Information:');
|
|
5097
|
-
console.log(` - .mcp.json location: ${mcpPath}`);
|
|
5098
|
-
console.log(` - .claude/settings.json location: ${(0, path_1.join)(targetDir, '.claude/settings.json')}`);
|
|
5099
|
-
console.log(` - MCP servers path: ${mcpBasePath}`);
|
|
5100
|
-
console.log('\nš” MCP servers configured for Claude Code');
|
|
5101
|
-
console.log('ā
MCP servers will be available when you run sparc or swarm commands');
|
|
5102
|
-
// Create activation scripts for manual use
|
|
5103
|
-
console.log('\nš Creating MCP activation scripts...');
|
|
5104
|
-
try {
|
|
5105
|
-
const isWindows = process.platform === 'win32';
|
|
5106
|
-
if (isWindows) {
|
|
5107
|
-
// Windows batch script
|
|
5108
|
-
const activationScript = `@echo off
|
|
5109
|
-
REM Snow-Flow MCP Activation Script
|
|
5110
|
-
echo š Starting Claude Code with MCP servers...
|
|
5111
|
-
echo š Working directory: ${targetDir}
|
|
5112
|
-
echo.
|
|
5113
|
-
|
|
5114
|
-
REM Change to project directory
|
|
5115
|
-
cd /d "${targetDir}"
|
|
5116
|
-
|
|
5117
|
-
REM Start Claude Code with MCP config
|
|
5118
|
-
claude --mcp-config .mcp.json .
|
|
5119
|
-
|
|
5120
|
-
echo.
|
|
5121
|
-
echo ā
Claude Code started with MCP servers!
|
|
5122
|
-
echo š” Check MCP servers with: /mcp in Claude Code
|
|
5123
|
-
`;
|
|
5124
|
-
const scriptPath = (0, path_1.join)(targetDir, 'activate-mcp.bat');
|
|
5125
|
-
await fs_1.promises.writeFile(scriptPath, activationScript);
|
|
5126
|
-
// Also create PowerShell script
|
|
5127
|
-
const psScript = `# Snow-Flow MCP Activation Script
|
|
5128
|
-
Write-Host "š Starting Claude Code with MCP servers..." -ForegroundColor Green
|
|
5129
|
-
Write-Host "š Working directory: ${targetDir}"
|
|
5130
|
-
Write-Host ""
|
|
5131
|
-
|
|
5132
|
-
# Change to project directory
|
|
5133
|
-
Set-Location "${targetDir}"
|
|
5134
|
-
|
|
5135
|
-
# Start Claude Code with MCP config
|
|
5136
|
-
& claude --mcp-config .mcp.json .
|
|
5137
|
-
|
|
5138
|
-
Write-Host ""
|
|
5139
|
-
Write-Host "ā
Claude Code started with MCP servers!" -ForegroundColor Green
|
|
5140
|
-
Write-Host "š” Check MCP servers with: /mcp in Claude Code" -ForegroundColor Yellow
|
|
5141
|
-
`;
|
|
5142
|
-
const psScriptPath = (0, path_1.join)(targetDir, 'activate-mcp.ps1');
|
|
5143
|
-
await fs_1.promises.writeFile(psScriptPath, psScript);
|
|
5144
|
-
console.log('ā
Created Windows activation scripts:');
|
|
5145
|
-
console.log(` - activate-mcp.bat`);
|
|
5146
|
-
console.log(` - activate-mcp.ps1`);
|
|
5147
|
-
}
|
|
5148
|
-
else {
|
|
5149
|
-
// Unix/Mac bash script
|
|
5150
|
-
const activationScript = `#!/bin/bash
|
|
5151
|
-
# Snow-Flow MCP Activation Script
|
|
5152
|
-
echo "š Starting Claude Code with MCP servers..."
|
|
5153
|
-
echo "š Working directory: ${targetDir}"
|
|
5154
|
-
echo ""
|
|
5155
|
-
|
|
5156
|
-
# Change to project directory
|
|
5157
|
-
cd "${targetDir}"
|
|
5158
|
-
|
|
5159
|
-
# Start Claude Code with MCP config
|
|
5160
|
-
claude --mcp-config .mcp.json .
|
|
5161
|
-
|
|
5162
|
-
echo ""
|
|
5163
|
-
echo "ā
Claude Code started with MCP servers!"
|
|
5164
|
-
echo "š” Check MCP servers with: /mcp in Claude Code"
|
|
5165
|
-
`;
|
|
5166
|
-
const scriptPath = (0, path_1.join)(targetDir, 'activate-mcp.sh');
|
|
5167
|
-
await fs_1.promises.writeFile(scriptPath, activationScript);
|
|
5168
|
-
await fs_1.promises.chmod(scriptPath, '755');
|
|
5169
|
-
console.log('ā
Created activation script: activate-mcp.sh');
|
|
5170
|
-
}
|
|
5171
|
-
console.log('\nš” To manually activate MCP servers in Claude Code:');
|
|
5172
|
-
if (isWindows) {
|
|
5173
|
-
console.log(' - Double-click activate-mcp.bat');
|
|
5174
|
-
console.log(' - Or run: .\\activate-mcp.ps1 (PowerShell)');
|
|
5175
|
-
}
|
|
5176
|
-
else {
|
|
5177
|
-
console.log(' - Run: ./activate-mcp.sh');
|
|
5178
|
-
}
|
|
5179
|
-
console.log(' - Or run: claude --mcp-config .mcp.json .');
|
|
5180
|
-
}
|
|
5181
|
-
catch (error) {
|
|
5182
|
-
console.log('ā ļø Could not create activation scripts');
|
|
5183
|
-
}
|
|
5184
|
-
console.log('\nš” MCP servers can also be activated automatically with:');
|
|
5185
|
-
console.log(' - snow-flow sparc "<task>" - Starts Claude Code with MCP for SPARC mode');
|
|
5186
|
-
console.log(' - snow-flow swarm "<objective>" - Starts Claude Code with MCP for swarm mode');
|
|
5187
|
-
// Phase 7 is now handled above with merged config approach
|
|
5188
|
-
/*
|
|
5189
|
-
try {
|
|
5190
|
-
await new Promise((resolve, reject) => {
|
|
5191
|
-
const registerProcess = spawn('claude', ['mcp', 'add', server.name, server.path], {
|
|
5192
|
-
cwd: targetDir,
|
|
5193
|
-
stdio: 'pipe'
|
|
5194
|
-
});
|
|
5195
|
-
|
|
5196
|
-
registerProcess.on('close', (code: number) => {
|
|
5197
|
-
if (code === 0) {
|
|
5198
|
-
registeredCount++;
|
|
5199
|
-
resolve(undefined);
|
|
5200
|
-
} else {
|
|
5201
|
-
reject(new Error(`Failed to register ${server.name}`));
|
|
5202
|
-
}
|
|
5203
|
-
});
|
|
5204
|
-
|
|
5205
|
-
registerProcess.on('error', reject);
|
|
5206
|
-
});
|
|
5207
|
-
} catch (error) {
|
|
5208
|
-
console.log(` ā ļø Failed to register ${server.name} with Claude Code`);
|
|
5209
|
-
}
|
|
5210
|
-
}
|
|
5211
|
-
|
|
5212
|
-
if (registeredCount > 0) {
|
|
5213
|
-
console.log(`ā
Registered ${registeredCount}/${mcpServers.length} MCP servers with Claude Code`);
|
|
5214
|
-
console.log('š MCP servers are now visible in Claude Code /mcp command!');
|
|
5215
|
-
} else {
|
|
5216
|
-
console.log('ā ļø MCP server registration failed - use manual registration:');
|
|
5217
|
-
console.log(` claude mcp add servicenow-deployment "${join(targetDir, 'dist/mcp/servicenow-deployment-mcp.js')}"`);
|
|
5218
|
-
console.log(` claude mcp add servicenow-flow-composer "${join(targetDir, 'dist/mcp/servicenow-flow-composer-mcp.js')}"`);
|
|
5219
|
-
console.log(` claude mcp add servicenow-update-set "${join(targetDir, 'dist/mcp/servicenow-update-set-mcp.js')}"`);
|
|
5220
|
-
console.log(` claude mcp add servicenow-intelligent "${join(targetDir, 'dist/mcp/servicenow-intelligent-mcp.js')}"`);
|
|
5221
|
-
console.log(` claude mcp add servicenow-graph-memory "${join(targetDir, 'dist/mcp/servicenow-graph-memory-mcp.js')}"`);
|
|
5222
|
-
console.log(` claude mcp add servicenow-operations "${join(targetDir, 'dist/mcp/servicenow-operations-mcp.js')}"`);
|
|
5223
|
-
console.log(` claude mcp add servicenow-platform-development "${join(targetDir, 'dist/mcp/servicenow-platform-development-mcp.js')}"`);
|
|
5224
|
-
console.log(` claude mcp add servicenow-integration "${join(targetDir, 'dist/mcp/servicenow-integration-mcp.js')}"`);
|
|
5225
|
-
console.log(` claude mcp add servicenow-automation "${join(targetDir, 'dist/mcp/servicenow-automation-mcp.js')}"`);
|
|
5226
|
-
console.log(` claude mcp add servicenow-security-compliance "${join(targetDir, 'dist/mcp/servicenow-security-compliance-mcp.js')}"`);
|
|
5227
|
-
console.log(` claude mcp add servicenow-reporting-analytics "${join(targetDir, 'dist/mcp/servicenow-reporting-analytics-mcp.js')}"`);
|
|
5228
|
-
}
|
|
5229
|
-
|
|
5230
|
-
} catch (error) {
|
|
5231
|
-
console.log('ā ļø Claude Code MCP registration failed - manual registration required:');
|
|
5232
|
-
console.log(` claude mcp add servicenow-deployment "${join(targetDir, 'dist/mcp/servicenow-deployment-mcp.js')}"`);
|
|
5233
|
-
console.log(` claude mcp add servicenow-flow-composer "${join(targetDir, 'dist/mcp/servicenow-flow-composer-mcp.js')}"`);
|
|
5234
|
-
console.log(` claude mcp add servicenow-update-set "${join(targetDir, 'dist/mcp/servicenow-update-set-mcp.js')}"`);
|
|
5235
|
-
console.log(` claude mcp add servicenow-intelligent "${join(targetDir, 'dist/mcp/servicenow-intelligent-mcp.js')}"`);
|
|
5236
|
-
console.log(` claude mcp add servicenow-graph-memory "${join(targetDir, 'dist/mcp/servicenow-graph-memory-mcp.js')}"`);
|
|
5237
|
-
console.log(` claude mcp add servicenow-operations "${join(targetDir, 'dist/mcp/servicenow-operations-mcp.js')}"`);
|
|
5238
|
-
console.log(` claude mcp add servicenow-platform-development "${join(targetDir, 'dist/mcp/servicenow-platform-development-mcp.js')}"`);
|
|
5239
|
-
console.log(` claude mcp add servicenow-integration "${join(targetDir, 'dist/mcp/servicenow-integration-mcp.js')}"`);
|
|
5240
|
-
console.log(` claude mcp add servicenow-automation "${join(targetDir, 'dist/mcp/servicenow-automation-mcp.js')}"`);
|
|
5241
|
-
console.log(` claude mcp add servicenow-security-compliance "${join(targetDir, 'dist/mcp/servicenow-security-compliance-mcp.js')}"`);
|
|
5242
|
-
console.log(` claude mcp add servicenow-reporting-analytics "${join(targetDir, 'dist/mcp/servicenow-reporting-analytics-mcp.js')}"`);
|
|
5243
|
-
}
|
|
5244
|
-
*/
|
|
5245
|
-
}
|
|
5246
|
-
catch (error) {
|
|
5247
|
-
if (!isGlobalInstall) {
|
|
5248
|
-
// Only show build errors in development mode
|
|
5249
|
-
console.log('ā ļø Build failed - MCP servers will need manual start:');
|
|
5250
|
-
console.log(' 1. Run: npm run build');
|
|
5251
|
-
console.log(' 2. Run: snow-flow mcp start');
|
|
5252
|
-
console.log(' 3. Register with Claude Code:');
|
|
5253
|
-
console.log(` claude mcp add servicenow-deployment "${(0, path_1.join)(targetDir, 'dist/mcp/servicenow-deployment-mcp.js')}"`);
|
|
5254
|
-
console.log(` claude mcp add servicenow-flow-composer "${(0, path_1.join)(targetDir, 'dist/mcp/servicenow-flow-composer-mcp.js')}"`);
|
|
5255
|
-
console.log(` claude mcp add servicenow-update-set "${(0, path_1.join)(targetDir, 'dist/mcp/servicenow-update-set-mcp.js')}"`);
|
|
5256
|
-
console.log(` claude mcp add servicenow-intelligent "${(0, path_1.join)(targetDir, 'dist/mcp/servicenow-intelligent-mcp.js')}"`);
|
|
5257
|
-
console.log(` claude mcp add servicenow-graph-memory "${(0, path_1.join)(targetDir, 'dist/mcp/servicenow-graph-memory-mcp.js')}"`);
|
|
5258
|
-
console.log(` claude mcp add servicenow-operations "${(0, path_1.join)(targetDir, 'dist/mcp/servicenow-operations-mcp.js')}"`);
|
|
5259
|
-
console.log(` claude mcp add servicenow-platform-development "${(0, path_1.join)(targetDir, 'dist/mcp/servicenow-platform-development-mcp.js')}"`);
|
|
5260
|
-
console.log(` claude mcp add servicenow-integration "${(0, path_1.join)(targetDir, 'dist/mcp/servicenow-integration-mcp.js')}"`);
|
|
5261
|
-
console.log(` claude mcp add servicenow-automation "${(0, path_1.join)(targetDir, 'dist/mcp/servicenow-automation-mcp.js')}"`);
|
|
5262
|
-
console.log(` claude mcp add servicenow-security-compliance "${(0, path_1.join)(targetDir, 'dist/mcp/servicenow-security-compliance-mcp.js')}"`);
|
|
5263
|
-
console.log(` claude mcp add servicenow-reporting-analytics "${(0, path_1.join)(targetDir, 'dist/mcp/servicenow-reporting-analytics-mcp.js')}"`);
|
|
5264
|
-
console.log(` Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
5265
|
-
}
|
|
5266
|
-
else {
|
|
5267
|
-
// In global install mode, just show a simpler message
|
|
5268
|
-
console.log('ā ļø MCP setup encountered an issue:');
|
|
5269
|
-
console.log(` ${error instanceof Error ? error.message : String(error)}`);
|
|
5270
|
-
console.log(' The project has been initialized successfully.');
|
|
5271
|
-
console.log(' You may need to configure MCP servers manually.');
|
|
5272
|
-
}
|
|
5273
|
-
}
|
|
5274
|
-
// Success message
|
|
5275
|
-
console.log('\nš Snow-Flow project initialized successfully!');
|
|
5276
|
-
console.log('');
|
|
5277
|
-
console.log('š Next steps:');
|
|
5278
|
-
console.log(' 1. Edit .env file with your ServiceNow OAuth credentials');
|
|
5279
|
-
console.log(' 2. Run: snow-flow auth login');
|
|
5280
|
-
console.log(' 3. Start your first swarm: snow-flow swarm "create a widget for incident management"');
|
|
5281
|
-
console.log('');
|
|
5282
|
-
console.log('š Documentation created:');
|
|
5283
|
-
console.log(' - QUICK_START.md: 5-minute getting started guide');
|
|
5284
|
-
console.log(' - CLAUDE.md: Complete development guide with MCP-FIRST workflow');
|
|
5285
|
-
console.log(' - .claude/commands/: Swarm patterns, agent types, MCP tools reference');
|
|
5286
|
-
console.log(' - examples/: Ready-to-run example scripts for common tasks');
|
|
5287
|
-
console.log('');
|
|
5288
|
-
console.log('ā
Project is ready to use!');
|
|
5289
|
-
console.log('');
|
|
5290
|
-
console.log('š§ MCP Servers:');
|
|
5291
|
-
console.log(' - ā
All 11 MCP servers have been built and configured');
|
|
5292
|
-
console.log(' - ā
.mcp.json generated with absolute paths and credentials');
|
|
5293
|
-
console.log(' - ā
Claude Code will automatically load servers from .mcp.json');
|
|
5294
|
-
console.log(' - ā¹ļø Start Claude Code in this directory to use MCP servers');
|
|
5295
|
-
console.log('');
|
|
5296
|
-
console.log('š” Available MCP Tools:');
|
|
5297
|
-
console.log(' - snow_deploy_widget - Deploy widgets directly');
|
|
5298
|
-
console.log(' - snow_create_complex_flow - Natural language flow creation');
|
|
5299
|
-
console.log(' - snow_update_set_create - Manage Update Sets');
|
|
5300
|
-
console.log(' - snow_find_artifact - Search with natural language');
|
|
5301
|
-
console.log(' - snow_graph_index_artifact - Neo4j graph memory');
|
|
5302
|
-
console.log(' - snow_create_ui_page - Platform development UI');
|
|
5303
|
-
console.log(' - snow_create_rest_message - Integration management');
|
|
5304
|
-
console.log(' - snow_create_scheduled_job - Process automation');
|
|
5305
|
-
console.log(' - snow_create_security_policy - Security & compliance');
|
|
5306
|
-
console.log(' - snow_create_report - Reporting & analytics');
|
|
5307
|
-
console.log('');
|
|
5308
|
-
console.log('š§ MCP Server Management:');
|
|
5309
|
-
console.log(' - Start servers: snow-flow mcp start');
|
|
5310
|
-
console.log(' - Check status: snow-flow mcp status');
|
|
5311
|
-
console.log(' - View logs: snow-flow mcp logs');
|
|
5312
|
-
console.log(' - Stop servers: snow-flow mcp stop');
|
|
5313
|
-
console.log('');
|
|
5314
|
-
console.log('š Documentation:');
|
|
5315
|
-
console.log(' - Environment config: .env (configure OAuth credentials here)');
|
|
5316
|
-
console.log(' - MCP configuration: .mcp.json (auto-generated)');
|
|
5317
|
-
console.log(' - Project structure: README.md');
|
|
5318
|
-
console.log(' - Memory system: .swarm/memory.db');
|
|
5319
|
-
console.log(' - MCP servers: .snow-flow/mcp-servers.json');
|
|
5320
|
-
if (options.sparc) {
|
|
5321
|
-
console.log(' - SPARC modes: .claude/commands/sparc/');
|
|
5322
|
-
console.log(' - Full guide: CLAUDE.md');
|
|
5323
|
-
}
|
|
5324
|
-
console.log('');
|
|
5325
|
-
console.log('š OAuth Setup Guide:');
|
|
5326
|
-
console.log(' 1. Open .env file in your editor');
|
|
5327
|
-
console.log(' 2. Follow the setup instructions in the file');
|
|
5328
|
-
console.log(' 3. Replace placeholder values with your ServiceNow credentials');
|
|
5329
|
-
console.log('');
|
|
5330
|
-
console.log('š Ready to build with Snow-Flow!');
|
|
5331
|
-
}
|
|
5332
|
-
catch (error) {
|
|
5333
|
-
console.error('ā Initialization failed:', error instanceof Error ? error.message : String(error));
|
|
5334
|
-
process.exit(1);
|
|
5335
|
-
}
|
|
5336
|
-
});
|
|
5337
|
-
// SPARC Command with Subcommands
|
|
5338
|
-
const sparc = program.command('sparc');
|
|
5339
|
-
sparc.description('SPARC development system - team and specialist modes');
|
|
5340
|
-
// SPARC Team Subcommand
|
|
5341
|
-
sparc
|
|
5342
|
-
.command('team <teamType> <task>')
|
|
5343
|
-
.description('Execute team-based SPARC development')
|
|
5344
|
-
.option('--parallel', 'Enable parallel execution')
|
|
5345
|
-
.option('--monitor', 'Real-time progress monitoring')
|
|
5346
|
-
.option('--shared-memory', 'Enable shared context between agents', true)
|
|
5347
|
-
.option('--no-shared-memory', 'Disable shared context')
|
|
5348
|
-
.option('--validation', 'Enable quality gates between handoffs', true)
|
|
5349
|
-
.option('--no-validation', 'Disable quality gates')
|
|
5350
|
-
.option('--dry-run', 'Preview team assembly without execution')
|
|
5351
|
-
.option('--max-agents <number>', 'Maximum number of agents', '5')
|
|
5352
|
-
.action(async (teamType, task, options) => {
|
|
5353
|
-
try {
|
|
5354
|
-
const { TeamSparcExecutor } = await Promise.resolve().then(() => __importStar(require('./sparc/team-sparc.js')));
|
|
5355
|
-
console.log(`\nš SPARC Team Mode: ${teamType.toUpperCase()}`);
|
|
5356
|
-
console.log(`š Task: ${task}\n`);
|
|
5357
|
-
const result = await TeamSparcExecutor.execute(teamType, task, {
|
|
5358
|
-
parallel: options.parallel,
|
|
5359
|
-
monitor: options.monitor,
|
|
5360
|
-
sharedMemory: options.sharedMemory,
|
|
5361
|
-
validation: options.validation,
|
|
5362
|
-
dryRun: options.dryRun,
|
|
5363
|
-
maxAgents: parseInt(options.maxAgents)
|
|
5364
|
-
});
|
|
5365
|
-
if (result.success) {
|
|
5366
|
-
console.log(`ā
Team execution completed successfully!`);
|
|
5367
|
-
console.log(`šÆ Coordinator: ${result.coordinator}`);
|
|
5368
|
-
console.log(`š„ Team: ${result.specialists.join(', ')}`);
|
|
5369
|
-
console.log(`š¦ Artifacts: ${result.artifacts.length}`);
|
|
5370
|
-
console.log(`ā±ļø Duration: ${result.executionTime}ms`);
|
|
5371
|
-
if (result.warnings && result.warnings.length > 0) {
|
|
5372
|
-
console.log(`ā ļø Warnings: ${result.warnings.length}`);
|
|
5373
|
-
result.warnings.forEach(warning => console.log(` - ${warning}`));
|
|
5374
|
-
}
|
|
5375
|
-
}
|
|
5376
|
-
else {
|
|
5377
|
-
console.error(`ā Team execution failed!`);
|
|
5378
|
-
if (result.errors) {
|
|
5379
|
-
result.errors.forEach(error => console.error(` - ${error}`));
|
|
5380
|
-
}
|
|
5381
|
-
process.exit(1);
|
|
5382
|
-
}
|
|
5383
|
-
}
|
|
5384
|
-
catch (error) {
|
|
5385
|
-
console.error('ā SPARC team execution failed:', error instanceof Error ? error.message : String(error));
|
|
5386
|
-
process.exit(1);
|
|
5387
|
-
}
|
|
5388
|
-
});
|
|
5389
|
-
// SPARC Specialist Subcommands
|
|
5390
|
-
const specialistTypes = ['frontend', 'backend', 'security', 'database', 'process', 'trigger', 'data', 'logic', 'interface', 'uiux', 'platform'];
|
|
5391
|
-
specialistTypes.forEach(specialistType => {
|
|
5392
|
-
sparc
|
|
5393
|
-
.command(`${specialistType} <task>`)
|
|
5394
|
-
.description(`Execute ${specialistType} specialist task`)
|
|
5395
|
-
.option('--dry-run', 'Preview execution without running')
|
|
5396
|
-
.option('--monitor', 'Real-time progress monitoring')
|
|
5397
|
-
.action(async (task, options) => {
|
|
5398
|
-
try {
|
|
5399
|
-
const { TeamSparcExecutor } = await Promise.resolve().then(() => __importStar(require('./sparc/team-sparc.js')));
|
|
5400
|
-
console.log(`\nšØāš» SPARC ${specialistType.toUpperCase()} Specialist`);
|
|
5401
|
-
console.log(`š Task: ${task}\n`);
|
|
5402
|
-
const result = await TeamSparcExecutor.executeSpecialist(specialistType, task, {
|
|
5403
|
-
dryRun: options.dryRun,
|
|
5404
|
-
monitor: options.monitor
|
|
5405
|
-
});
|
|
5406
|
-
if (result.success) {
|
|
5407
|
-
console.log(`ā
Specialist execution completed successfully!`);
|
|
5408
|
-
console.log(`šÆ Specialist: ${result.coordinator}`);
|
|
5409
|
-
console.log(`š¦ Artifacts: ${result.artifacts.length}`);
|
|
5410
|
-
console.log(`ā±ļø Duration: ${result.executionTime}ms`);
|
|
5411
|
-
}
|
|
5412
|
-
else {
|
|
5413
|
-
console.error(`ā Specialist execution failed!`);
|
|
5414
|
-
if (result.errors) {
|
|
5415
|
-
result.errors.forEach(error => console.error(` - ${error}`));
|
|
5416
|
-
}
|
|
5417
|
-
process.exit(1);
|
|
5418
|
-
}
|
|
5419
|
-
}
|
|
5420
|
-
catch (error) {
|
|
5421
|
-
console.error(`ā SPARC ${specialistType} execution failed:`, error instanceof Error ? error.message : String(error));
|
|
5422
|
-
process.exit(1);
|
|
5423
|
-
}
|
|
5424
|
-
});
|
|
5425
|
-
});
|
|
5426
4435
|
// SPARC Detailed Help Command
|
|
5427
4436
|
program
|
|
5428
4437
|
.command('sparc-help')
|
|
@@ -5454,6 +4463,8 @@ program
|
|
|
5454
4463
|
.option('--monitor', 'Show real-time hive-mind monitoring')
|
|
5455
4464
|
.option('--type <type>', 'Hint at task type (widget, flow, app, integration)')
|
|
5456
4465
|
.action(async (objective, options) => {
|
|
4466
|
+
// Check for flow deprecation first
|
|
4467
|
+
checkFlowDeprecation('queen', objective);
|
|
5457
4468
|
console.log(`\nš ServiceNow Queen Agent v${version_js_1.VERSION} - Hive-Mind Intelligence`);
|
|
5458
4469
|
console.log('š Elegant orchestration replacing complex team coordination\n');
|
|
5459
4470
|
try {
|