snow-flow 8.38.0 → 8.38.2

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
@@ -420,17 +420,11 @@ program
420
420
  updateLearning: async () => { }
421
421
  };
422
422
  }
423
- // Start SnowCode multi-agent orchestration
423
+ // Start SnowCode with the objective
424
424
  try {
425
- // Generate the orchestration prompt
426
- const orchestrationPrompt = buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated, sessionId);
427
425
  if (options.verbose) {
428
- cliLogger.info('\n👑 Initializing multi-agent orchestration with SnowCode...');
429
- cliLogger.info('🎯 SnowCode will coordinate the following:');
430
- cliLogger.info(` - Analyze objective: "${objective}"`);
431
- cliLogger.info(` - Spawn ${taskAnalysis.estimatedAgentCount} specialized agents via Task() system`);
432
- cliLogger.info(` - Coordinate through shared memory (session: ${sessionId})`);
433
- cliLogger.info(` - Monitor progress and adapt strategy`);
426
+ cliLogger.info('\n🚀 Starting SnowCode...');
427
+ cliLogger.info(`📋 Objective: "${objective}"`);
434
428
  }
435
429
  // Check if intelligent features are enabled
436
430
  const hasIntelligentFeatures = options.autoPermissions || options.smartDiscovery ||
@@ -574,9 +568,10 @@ async function executeSnowCode(objective, options) {
574
568
  cliLogger.error('SnowCode CLI not found - install: npm install -g @groeimetai/snow-code');
575
569
  return false;
576
570
  }
577
- // Check for SnowCode config (.snow-code/snow-code.json)
578
- const snowcodeConfigPath = (0, path_1.join)(process.cwd(), '.snow-code', 'snow-code.json');
579
- if (!(0, fs_2.existsSync)(snowcodeConfigPath)) {
571
+ // Check for SnowCode config (.snow-code/config.json OR .snow-code/snow-code.json)
572
+ const snowcodeConfigPath = (0, path_1.join)(process.cwd(), '.snow-code', 'config.json');
573
+ const snowcodeConfigPathAlt = (0, path_1.join)(process.cwd(), '.snow-code', 'snow-code.json');
574
+ if (!(0, fs_2.existsSync)(snowcodeConfigPath) && !(0, fs_2.existsSync)(snowcodeConfigPathAlt)) {
580
575
  cliLogger.error('SnowCode config not found - run: snow-flow init');
581
576
  return false;
582
577
  }
@@ -675,594 +670,6 @@ async function executeSnowCode(objective, options) {
675
670
  return false;
676
671
  }
677
672
  }
678
- // Helper function to build Queen Agent orchestration prompt
679
- // Helper function to build Queen Agent orchestration prompt - CLEANED UP VERSION
680
- function buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated = false, sessionId) {
681
- // Check if intelligent features are enabled
682
- const hasIntelligentFeatures = options.autoPermissions || options.smartDiscovery ||
683
- options.liveTesting || options.autoDeploy || options.autoRollback ||
684
- options.sharedMemory || options.progressMonitoring;
685
- const prompt = `# 👑 Snow-Flow Queen Agent Orchestration
686
-
687
- ## 🤖 Claude Agent SDK Integration
688
- **Snow-Flow v5.0+ is powered by @anthropic-ai/claude-agent-sdk@0.1.1**
689
-
690
- This session uses the official Anthropic Claude Agent SDK for:
691
- - **MCP Server Management**: 2 unified servers with 411 tools automatically managed
692
- - **Agent Lifecycle**: SDK handles agent spawning, coordination, and resource optimization
693
- - **Intelligent Routing**: Task-aware tool routing and context management
694
- - **Performance Optimization**: Automatic batching and parallel execution support
695
-
696
- **Available Tools:**
697
- - **ServiceNow Unified Server** (235+ tools): All ServiceNow operations
698
- - **Snow-Flow Orchestration Server** (176+ tools): Swarm coordination, neural networks, memory
699
-
700
- ## 🚨 CRITICAL: PREVENT INFINITE LOOPS - READ FIRST!
701
-
702
- **NEVER SPAWN DUPLICATE AGENTS!** This causes infinite loops that spam MCP servers and crash Codespaces!
703
-
704
- **❌ INFINITE LOOP PATTERN (PROHIBITED):**
705
- \`\`\`
706
- Task(\"UI Builder Tools Tester\", \"Test UI Builder tools\");
707
- Task(\"UI Builder Tools Tester\", \"Test UI Builder tools\"); // ← DUPLICATE AGENT TYPE!
708
- Task(\"Workspace Tools Tester\", \"Test workspace tools\");
709
- Task(\"Workspace Tools Tester\", \"Test workspace tools\"); // ← INFINITE LOOP!
710
- \`\`\`
711
-
712
- **✅ CORRECT PATTERN (REQUIRED):**
713
- \`\`\`
714
- Task(\"workspace-architect\", \"Create ONE UX workspace using snow_create_complete_workspace\");
715
- Task(\"ui-designer\", \"Design UI components AFTER workspace is created\");
716
- Task(\"validator\", \"Test AFTER both previous agents complete\");
717
- \`\`\`
718
-
719
- **GOLDEN RULES:**
720
- 1. **ONE agent per task type maximum**
721
- 2. **UNIQUE agent names** (not generic \"Tester\")
722
- 3. **SEQUENTIAL spawning** - wait for completion
723
- 4. **CHECK Memory** for existing agents first
724
-
725
- ## 🎯 Mission Brief
726
- You are the Queen Agent, master coordinator of the Snow-Flow hive-mind. Your mission is to orchestrate a swarm of specialized agents to complete the following ServiceNow development objective:
727
-
728
- **Objective**: ${objective}
729
- **Session ID**: ${sessionId}
730
-
731
- ## 🧠 Task Analysis Summary
732
- - **Task Type**: ${taskAnalysis.taskType}
733
- - **Complexity**: ${taskAnalysis.complexity}
734
- - **Primary Agent Required**: ${taskAnalysis.primaryAgent}
735
- - **Supporting Agents**: ${taskAnalysis.supportingAgents.join(', ')}
736
- - **Estimated Total Agents**: ${taskAnalysis.estimatedAgentCount}
737
- - **ServiceNow Artifacts**: ${taskAnalysis.serviceNowArtifacts.join(', ')}
738
-
739
- ## ⚡ CRITICAL: Task Intent Analysis
740
- **BEFORE PROCEEDING**, analyze the user's ACTUAL intent:
741
-
742
- 1. **Data Generation Request?** (e.g., "create 5000 incidents", "generate test data")
743
- → Focus on CREATING DATA, not building systems
744
- → Use simple scripts or bulk operations to generate the data
745
- → Skip complex architectures unless explicitly asked
746
-
747
- 2. **System Building Request?** (e.g., "build a widget", "create an ML system")
748
- → Follow full development workflow
749
- → Build proper architecture and components
750
-
751
- 3. **Simple Operation Request?** (e.g., "update field X", "delete records")
752
- → Execute the operation directly
753
- → Skip unnecessary complexity
754
-
755
- **For this objective**: Analyze if the user wants data generation, system building, or a simple operation.
756
-
757
- ## 📊 Table Discovery Intelligence
758
-
759
- The Queen Agent will automatically discover and validate table schemas based on the objective. This ensures agents use correct field names and table structures.
760
-
761
- **Table Detection Examples:**
762
- - "create widget for incident records" → Discovers: incident, sys_user, sys_user_group
763
- - "build catalog item for equipment requests" → Discovers: sc_cat_item, sc_category, u_equipment_request
764
- - "create UX workspace for IT support" → Discovers: sys_ux_experience, sys_ux_app_config, sys_ux_macroponent, sys_ux_page_registry, sys_ux_app_route
765
- - "portal showing catalog items" → Discovers: sc_cat_item, sc_category, sc_request
766
- - "dashboard with CMDB assets" → Discovers: cmdb_ci, cmdb_rel_ci, sys_user
767
- - "report on problem tickets" → Discovers: problem, incident, sys_user
768
-
769
- **Discovery Process:**
770
- 1. Extracts table names from objective (standard tables, u_ custom tables, explicit mentions)
771
- 2. Discovers actual table schemas with field names, types, and relationships
772
- 3. Stores schemas in memory for all agents to use
773
- 4. Agents MUST use exact field names from schemas (e.g., 'short_description' not 'desc')
774
-
775
- ## 👑 Your Queen Agent Responsibilities
776
-
777
- ## 🏗️ UX Workspace Creation Specific Instructions
778
- If the task involves UX WORKSPACE CREATION (e.g., "create workspace for IT support", "build agent workspace"):
779
-
780
- 1. **ALWAYS** use \`snow_create_complete_workspace\` for full 6-step workflow
781
- 2. **INDIVIDUAL STEPS** available if fine control needed:
782
- - Step 1: \`snow_create_ux_experience\` (sys_ux_experience)
783
- - Step 2: \`snow_create_ux_app_config\` (sys_ux_app_config)
784
- - Step 3: \`snow_create_ux_page_macroponent\` (sys_ux_macroponent)
785
- - Step 4: \`snow_create_ux_page_registry\` (sys_ux_page_registry)
786
- - Step 5: \`snow_create_ux_app_route\` (sys_ux_app_route)
787
- - Step 6: \`snow_update_ux_app_config_landing_page\` (landing page route)
788
- 3. **VERIFY ORDER**: Must follow exact sequence for functional workspaces
789
- 4. **STORE SYS_IDS**: Store all sys_ids in Memory for agents coordination
790
- 5. **TEST ACCESS**: Provide workspace URL: \`/now/experience/workspace/{route_name}\`
791
-
792
- ## 📊 Data Generation Specific Instructions
793
- If the task is identified as DATA GENERATION (e.g., "create 5000 incidents"):
794
-
795
- 1. **DO NOT** build complex export/import systems
796
- 2. **DO NOT** create APIs, UI Actions, or workflows
797
- 3. **DO** focus on:
798
- - Creating a simple script to generate the data
799
- - Using ServiceNow's REST API or direct table operations
800
- - Ensuring realistic data distribution for ML training
801
- - Adding variety in categories, priorities, descriptions, etc.
802
-
803
- **Example approach for "create 5000 incidents":**
804
- \`\`\`javascript
805
- // Simple batch creation script
806
- for (let i = 0; i < 5000; i += 100) {
807
- // Create 100 incidents at a time to avoid timeouts
808
- const batch = generateRealisticIncidentBatch(100);
809
- await createIncidentsBatch(batch);
810
- }
811
- \`\`\`
812
-
813
- ### 1. Initialize Memory & Session (Required First Step)
814
- **THIS MUST BE YOUR VERY FIRST ACTION:**
815
- \`\`\`javascript
816
- // Initialize swarm memory session using memory_usage MCP tool
817
- await memory_usage({
818
- action: 'store',
819
- key: "swarm_session_${sessionId}",
820
- value: JSON.stringify({
821
- objective: "${objective}",
822
- status: "initializing",
823
- started_at: new Date().toISOString(),
824
- task_analysis: ${JSON.stringify(taskAnalysis, null, 2)},
825
- configuration: {
826
- strategy: "${options.strategy}",
827
- mode: "${options.mode}",
828
- max_agents: ${parseInt(options.maxAgents)},
829
- authenticated: ${isAuthenticated}
830
- }
831
- })
832
- });
833
- \`\`\`
834
-
835
- ### 2. 🚨 MANDATORY: ServiceNow Auth & Update Set Setup
836
- **CRITICAL: These steps are REQUIRED for ALL development work:**
837
-
838
- \`\`\`javascript
839
- // Step 2.1: MANDATORY - Test ServiceNow authentication
840
- const authCheck = await snow_auth_diagnostics();
841
- if (!authCheck.success) {
842
- throw new Error("❌ CRITICAL: Authentication failed! Run: snow-flow auth login");
843
- }
844
-
845
- // Step 2.2: MANDATORY - Create Update Set for tracking ALL changes
846
- const updateSetName = "Snow-Flow: ${objective.substring(0, 50)}... - ${new Date().toISOString().split('T')[0]}";
847
- const updateSet = await snow_update_set_create({
848
- name: updateSetName,
849
- description: "Automated Snow-Flow development for: ${objective}\\n\\nSession: ${sessionId}\\nAll changes tracked automatically",
850
- auto_switch: true // 🚨 CRITICAL: Sets as current update set!
851
- });
852
-
853
- // Store Update Set info in memory for all agents using memory_usage MCP tool
854
- await memory_usage({
855
- action: 'store',
856
- key: "update_set_${sessionId}",
857
- value: JSON.stringify(updateSet)
858
- });
859
- await memory_usage({
860
- action: 'store',
861
- key: "current_update_set",
862
- value: updateSet.sys_id
863
- });
864
- \`\`\`
865
-
866
- **WHY THIS IS CRITICAL:**
867
- - ✅ All ServiceNow changes are automatically tracked
868
- - ✅ Enables deployment to other instances later
869
- - ✅ Provides rollback capabilities
870
- - ✅ Follows ServiceNow development best practices
871
- - ❌ **WITHOUT UPDATE SET: Changes are untracked and risky!**
872
-
873
- ### 3. Create Master Task List
874
- After completing setup steps, create task breakdown:
875
- \`\`\`javascript
876
- TodoWrite([
877
- {
878
- id: "setup_complete",
879
- content: "✅ Setup: Auth, Update Set, Memory initialized",
880
- status: "completed",
881
- priority: "high"
882
- },
883
- {
884
- id: "analyze_requirements",
885
- content: "Analyze user requirements: ${objective}",
886
- status: "in_progress",
887
- priority: "high"
888
- },
889
- {
890
- id: "spawn_agents",
891
- content: "Spawn ${taskAnalysis.estimatedAgentCount} specialized agents",
892
- status: "pending",
893
- priority: "high"
894
- },
895
- {
896
- id: "coordinate_development",
897
- content: "Coordinate agent activities for ${taskAnalysis.taskType}",
898
- status: "pending",
899
- priority: "high"
900
- },
901
- {
902
- id: "validate_solution",
903
- content: "Validate and test the complete solution",
904
- status: "pending",
905
- priority: "medium"
906
- }
907
- ]);
908
- \`\`\`
909
-
910
- ### 4. Agent Spawning Strategy - 🚨 ANTI-LOOP PROTECTION 🚨
911
-
912
- **CRITICAL: NO DUPLICATE AGENTS! ONLY SPAWN EACH AGENT TYPE ONCE!**
913
-
914
- **✅ CORRECT (Single Agents Only):**
915
- 1. **Initialize Swarm ONCE**: \`swarm_init({ topology: 'hierarchical', maxAgents: ${parseInt(options.maxAgents)} })\`
916
- 2. **Spawn ${taskAnalysis.estimatedAgentCount} DIFFERENT agents**:
917
- Spawn ONE agent of each required type based on the objective:
918
-
919
- **${taskAnalysis.taskType} requires these UNIQUE agents:**
920
- - **ONE researcher**: \`Task(\"researcher\", \"Research ServiceNow requirements for: ${objective}\")\`
921
- - **ONE ${taskAnalysis.primaryAgent}**: \`Task(\"${taskAnalysis.primaryAgent}\", \"Implement main solution for: ${objective}\")\`
922
- - **ONE tester**: \`Task(\"tester\", \"Test and validate solution for: ${objective}\")\`
923
-
924
- **🚨 CRITICAL ANTI-LOOP RULES:**
925
- - **NEVER spawn multiple agents of the same type**
926
- - **NEVER spawn \"UI Builder Tools Tester\" multiple times**
927
- - **NEVER spawn \"Workspace Tools Tester\" multiple times**
928
- - **WAIT for agent completion** before spawning related agents
929
- - **CHECK Memory** for existing agents before spawning new ones
930
-
931
- **❌ PROHIBITED PATTERNS:**
932
- \`\`\`
933
- // DON'T DO THIS - CAUSES INFINITE LOOPS:
934
- Task(\"UI Builder Tools Tester\", \"Test UI Builder tools\");
935
- Task(\"UI Builder Tools Tester\", \"Test UI Builder tools\"); // ← DUPLICATE!
936
- Task(\"UI Builder Tools Tester\", \"Test UI Builder tools\"); // ← INFINITE LOOP!
937
- \`\`\`
938
-
939
- **✅ CORRECT PATTERNS:**
940
- \`\`\`
941
- // DO THIS - SINGLE AGENTS WITH SPECIFIC TASKS:
942
- Task(\"ui-builder-specialist\", \"Create specific UI Builder page for incident management\");
943
- Task(\"workspace-architect\", \"Design UX workspace structure for IT support team\");
944
- Task(\"testing-specialist\", \"Validate workspace functionality and report results\");
945
- \`\`\`
946
-
947
- ### 5. Memory Coordination Pattern with Loop Detection
948
- All agents MUST use this memory coordination WITH loop prevention:
949
-
950
- \`\`\`javascript
951
- // STEP 1: Check if agent type already exists (PREVENT LOOPS!)
952
- const existingAgentsResult = await memory_usage({
953
- action: 'retrieve',
954
- key: 'active_agents'
955
- });
956
- const existingAgents = existingAgentsResult?.value ? JSON.parse(existingAgentsResult.value) : [];
957
- const agentType = 'ui-builder-specialist';
958
-
959
- if (existingAgents.includes(agentType)) {
960
- console.log('Agent type already active - SKIPPING to prevent infinite loop');
961
- return; // DON'T spawn duplicate agents!
962
- }
963
-
964
- // STEP 2: Register agent as active
965
- const agentId = \`agent_\${agentType}_\${sessionId}\`;
966
- existingAgents.push(agentType);
967
- await memory_usage({
968
- action: 'store',
969
- key: 'active_agents',
970
- value: JSON.stringify(existingAgents)
971
- });
972
-
973
- // STEP 3: Agent stores progress
974
- await memory_usage({
975
- action: 'store',
976
- key: \`\${agentId}_progress\`,
977
- value: JSON.stringify({
978
- agent_type: agentType,
979
- status: "working",
980
- current_task: "description of current work",
981
- completion_percentage: 45,
982
- spawned_at: new Date().toISOString(),
983
- last_update: new Date().toISOString()
984
- })
985
- });
986
-
987
- // Agent reads other agent's work when needed
988
- const primaryWorkResult = await memory_usage({
989
- action: 'retrieve',
990
- key: "agent_\${taskAnalysis.primaryAgent}_output"
991
- });
992
- const primaryWork = primaryWorkResult?.value ? JSON.parse(primaryWorkResult.value) : null;
993
-
994
- // Agent signals completion
995
- await memory_usage({
996
- action: 'store',
997
- key: \`\${agentId}_complete\`,
998
- value: JSON.stringify({
999
- completed_at: new Date().toISOString(),
1000
- outputs: { /* agent deliverables */ },
1001
- artifacts_created: [ /* list of created artifacts */ ]
1002
- })
1003
- });
1004
- \`\`\`
1005
-
1006
- ## 🧠 Intelligent Features Configuration
1007
- ${hasIntelligentFeatures ? `✅ **INTELLIGENT MODE ACTIVE** - The following features are enabled:
1008
-
1009
- - **🔐 Auto Permissions**: ${options.autoPermissions ? '✅ Will escalate permissions automatically' : '❌ Manual permission handling'}
1010
- - **🔍 Smart Discovery**: ${options.smartDiscovery ? '✅ Will discover and reuse existing artifacts' : '❌ Create all new artifacts'}
1011
- - **🧪 Live Testing**: ${options.liveTesting ? '✅ Will test in real ServiceNow instance' : '❌ Local testing only'}
1012
- - **🚀 Auto Deploy**: ${options.autoDeploy ? '⚠️ WILL DEPLOY TO SERVICENOW AUTOMATICALLY' : '✅ Planning mode - no deployment'}
1013
- - **🔄 Auto Rollback**: ${options.autoRollback ? '✅ Will rollback on any failures' : '❌ No automatic rollback'}
1014
- - **💾 Shared Memory**: ${options.sharedMemory ? '✅ Agents share context via Memory' : '❌ Isolated agent execution'}
1015
- - **📊 Progress Monitoring**: ${options.progressMonitoring ? '✅ Real-time progress tracking' : '❌ No progress monitoring'}
1016
- - **📝 Script Execution**: ${options.autoConfirm ? '⚠️ AUTO-CONFIRM - Background scripts execute without user confirmation' : options.autoConfirm === false ? '🔒 FORCE CONFIRM - Always ask for script confirmation' : '🤚 DEFAULT - Ask for confirmation on risky scripts'}` : '❌ **STANDARD MODE** - Use manual coordination patterns'}
1017
-
1018
- ## 🎯 ServiceNow Execution Strategy
1019
-
1020
- ### 🚀 MANDATORY: Live ServiceNow Development First!
1021
-
1022
- **CRITICAL RULE**: All agents MUST attempt to use ServiceNow MCP tools first, regardless of authentication status.
1023
-
1024
- ### 🚨 MANDATORY: ES5 JavaScript Only for ALL ServiceNow Scripts
1025
- **⚠️ SERVICENOW RHINO ENGINE = ES5 ONLY - NO MODERN SYNTAX!**
1026
-
1027
- **CRITICAL ES5 RULES:**
1028
- - NO const/let (use var)
1029
- - NO arrow functions (use function())
1030
- - NO template literals (use string concatenation)
1031
- - NO destructuring (use explicit property access)
1032
- - NO for...of loops (use traditional for loops)
1033
- - NO default parameters (use typeof checks)
1034
-
1035
- **🔥 If you use ES6+ syntax, the script WILL FAIL with SyntaxError!**
1036
- **See CLAUDE.md for complete ES5 examples and common mistake fixes.**
1037
-
1038
- ### 📝 Background Script Execution Settings
1039
- ${options.autoConfirm ? '⚠️ **AUTO-CONFIRM MODE ENABLED**: When calling snow_execute_background_script, ALWAYS add autoConfirm: true parameter to skip user confirmation.\n```javascript\nsnow_execute_background_script({\n script: "your ES5 script here",\n description: "Clear description",\n autoConfirm: true // ⚠️ User enabled auto-confirm mode\n})\n```' : options.autoConfirm === false ? '🔒 **FORCE CONFIRM MODE**: All background scripts will require user confirmation, even simple ones.' : '🤚 **DEFAULT MODE**: Background scripts will ask for user confirmation based on risk level.'}
1040
-
1041
- #### Current MCP Tools Available (Snow-Flow v3.3.4)
1042
- ${isAuthenticated ? '✅ Authentication detected - full deployment capabilities' : '⚠️ No authentication detected - MCP tools will provide specific instructions if auth needed'}
1043
-
1044
- Your agents MUST use these MCP tools IN THIS ORDER:
1045
-
1046
- 🚨 **MANDATORY PRE-FLIGHT CHECKS** (ALWAYS do first!):
1047
- 1. \`snow_auth_diagnostics\` - Test authentication and permissions
1048
- 2. \`snow_update_set_create\` - Create and activate update set for tracking
1049
- 3. If auth fails, STOP and provide instructions to run 'snow-flow auth login'
1050
- 4. If update set fails, STOP - development work is not safe without tracking
1051
-
1052
- 🎯 **Core Development Tools**:
1053
- 1. **Universal Query Tool**: \`snow_query_table\` - Works with ALL ServiceNow tables
1054
- - Count-only: \`{table: "incident", query: "state!=7"}\` → Memory efficient
1055
- - Specific fields: \`{table: "sc_request", fields: ["number", "state"]}\` → Only needed data
1056
- - Full content: \`{table: "change_request", include_content: true}\` → When all data needed
1057
-
1058
- 2. **Deployment Tools**:
1059
- - \`snow_deploy\` - Universal deployment for NEW artifacts (16+ types supported!)
1060
- - \`snow_update\` - Update EXISTING artifacts by name or sys_id
1061
-
1062
- 3. **Discovery Tools**:
1063
- - \`snow_discover_table_fields\` - Get exact field names and types
1064
- - \`snow_table_schema_discovery\` - Complete table structure
1065
-
1066
- 4. **Update Set Management**:
1067
- - \`snow_update_set_create\` - Create new update sets
1068
- - \`snow_update_set_add_comment\` - Track progress
1069
- - \`snow_update_set_retrieve\` - Get update set XML
1070
-
1071
- ## 🔧 NEW: Expanded Artifact Support (v3.3.4)
1072
-
1073
- Snow-Flow now supports **16+ different ServiceNow artifact types**:
1074
-
1075
- | Type | Table | Deploy | Update | Natural Language |
1076
- |------|-------|--------|---------|------------------|
1077
- | widget | sp_widget | ✅ | ✅ | ✅ |
1078
- | business_rule | sys_script | ✅ | ✅ | ✅ |
1079
- | script_include | sys_script_include | ✅ | ✅ | ✅ |
1080
- | ui_page | sys_ui_page | ✅ | ✅ | ✅ |
1081
- | client_script | sys_script_client | ✅ | ✅ | ✅ |
1082
- | ui_action | sys_ui_action | ✅ | ✅ | ✅ |
1083
- | ui_policy | sys_ui_policy | ✅ | ✅ | ✅ |
1084
- | acl | sys_security_acl | ✅ | ✅ | ✅ |
1085
- | table | sys_db_object | ✅ | ✅ | ✅ |
1086
- | field | sys_dictionary | ✅ | ✅ | ✅ |
1087
- | workflow | wf_workflow | ✅ | ✅ | ✅ |
1088
- | flow | sys_hub_flow | ✅ | ✅ | ✅ |
1089
- | notification | sysevent_email_action | ✅ | ✅ | ✅ |
1090
- | scheduled_job | sysauto_script | ✅ | ✅ | ✅ |
1091
-
1092
- **Usage Examples:**
1093
- \`\`\`javascript
1094
- // Deploy NEW artifacts
1095
- await snow_deploy({
1096
- type: 'business_rule',
1097
- name: 'Auto Assignment Rule',
1098
- table: 'incident',
1099
- when: 'before',
1100
- script: 'if (current.priority == "1") current.assigned_to = "admin";'
1101
- });
1102
-
1103
- // Update EXISTING artifacts (natural language supported!)
1104
- await snow_update({
1105
- type: 'ui_action',
1106
- identifier: 'close_incident',
1107
- instruction: 'Change label to "Close with Resolution" and add validation'
1108
- });
1109
- \`\`\`
1110
-
1111
- ${options.autoDeploy ? `
1112
- #### ⚠️ AUTO-DEPLOYMENT ACTIVE ⚠️
1113
- - Real artifacts will be created in ServiceNow
1114
- - All changes tracked in Update Sets
1115
- - Rollback available if needed
1116
- ` : `
1117
- #### 📋 Planning Mode Active
1118
- - No real artifacts will be created
1119
- - Analysis and recommendations only
1120
- - Use --auto-deploy to enable deployment
1121
- `}
1122
-
1123
- ${!isAuthenticated ? `### ❌ ServiceNow Integration Disabled
1124
-
1125
- #### Planning Mode (Auth Required)
1126
- When authentication is not available, agents will:
1127
- 1. Document the COMPLETE solution architecture
1128
- 2. Create detailed implementation guides
1129
- 3. Store all plans in Memory for future deployment
1130
- 4. Provide SPECIFIC instructions: "Run snow-flow auth login"
1131
-
1132
- ⚠️ IMPORTANT: This is a FALLBACK mode only!
1133
- Agents must ALWAYS try MCP tools first!` : ''}
1134
-
1135
- ## 👑 Queen Agent Coordination Instructions
1136
-
1137
- ### 6. Agent Coordination & Handoffs
1138
- Ensure smooth transitions between agents:
1139
-
1140
- \`\`\`javascript
1141
- // Primary agent signals readiness for support
1142
- await memory_usage({
1143
- action: 'store',
1144
- key: "agent_${taskAnalysis.primaryAgent}_ready_for_support",
1145
- value: JSON.stringify({
1146
- base_structure_complete: true,
1147
- ready_for: [${taskAnalysis.supportingAgents.map(a => `"${a}"`).join(', ')}],
1148
- timestamp: new Date().toISOString()
1149
- })
1150
- });
1151
-
1152
- // Supporting agents check readiness
1153
- const readinessResult = await memory_usage({
1154
- action: 'retrieve',
1155
- key: "agent_${taskAnalysis.primaryAgent}_ready_for_support"
1156
- });
1157
- const canProceed = readinessResult?.value ? JSON.parse(readinessResult.value) : {};
1158
- if (canProceed?.base_structure_complete) {
1159
- // Begin supporting work
1160
- }
1161
- \`\`\`
1162
-
1163
- ### 7. Final Validation and Completion
1164
- Once all agents complete their work:
1165
-
1166
- \`\`\`javascript
1167
- // Collect all agent outputs
1168
- const agentOutputs = {};
1169
- const agents = [${[taskAnalysis.primaryAgent, ...taskAnalysis.supportingAgents].map(a => `"${a}"`).join(', ')}];
1170
-
1171
- for (const agent of agents) {
1172
- const outputResult = await memory_usage({
1173
- action: 'retrieve',
1174
- key: \`agent_\${agent}_complete\`
1175
- });
1176
- if (outputResult?.value) {
1177
- agentOutputs[agent] = JSON.parse(outputResult.value);
1178
- }
1179
- }
1180
-
1181
- // Store final swarm results
1182
- await memory_usage({
1183
- action: 'store',
1184
- key: "swarm_session_${sessionId}_results",
1185
- value: JSON.stringify({
1186
- objective: "${objective}",
1187
- completed_at: new Date().toISOString(),
1188
- agent_outputs: agentOutputs,
1189
- artifacts_created: Object.values(agentOutputs)
1190
- .flatMap(output => output.artifacts_created || []),
1191
- success: true
1192
- })
1193
- });
1194
-
1195
- // Update final TodoWrite status
1196
- TodoWrite([
1197
- {
1198
- id: "swarm_completion",
1199
- content: "Swarm successfully completed: ${objective}",
1200
- status: "completed",
1201
- priority: "high"
1202
- }
1203
- ]);
1204
- \`\`\`
1205
-
1206
- ## 🎯 Success Criteria
1207
-
1208
- Your Queen Agent orchestration is successful when:
1209
- 1. ✅ All agents have been spawned and initialized
1210
- 2. ✅ Swarm session is tracked in Memory
1211
- 3. ✅ Agents are coordinating through shared Memory
1212
- 4. ✅ TodoWrite is being used for task tracking
1213
- 5. ✅ ${taskAnalysis.taskType} requirements are met
1214
- 6. ✅ All artifacts are created/deployed successfully
1215
-
1216
- ## 💡 Queen Agent Best Practices
1217
-
1218
- ### **Workflow Orchestration:**
1219
- 1. **NEVER parallel foundation work** - research, planning, architecture must be sequential
1220
- 2. **Foundation → Development → Validation** - strict phase progression
1221
- 3. **Parallel development only** after foundation complete
1222
- 4. **Use Memory to share foundation outputs** to development agents
1223
- 5. **Coordinate parallel agents** through shared Memory state
1224
-
1225
- ### **Agent Coordination:**
1226
- 1. **Sequential Agents**: researcher → planner → architect (must wait for each other)
1227
- 2. **Parallel Agents**: widget-developer + script-writer + ui-builder (can work simultaneously)
1228
- 3. **Foundation Dependencies**: All development agents depend on architecture completion
1229
- 4. **Shared Memory**: Store research findings, plans, architecture for all agents to access
1230
-
1231
- ### **Task Management:**
1232
- 1. **Update TodoWrite** with phase progression
1233
- 2. **Mark foundation complete** before starting development
1234
- 3. **Monitor parallel agent progress** and coordinate conflicts
1235
- 4. **Validate outputs** before marking complete
1236
- 5. **Store all decisions** in Memory for audit trail
1237
-
1238
- ### **Example Workflow:**
1239
- **Phase 1 (Sequential):** researcher → architect → planner
1240
- **Phase 2 (Parallel):** widget-dev + script-writer + ui-builder (use foundation outputs)
1241
- **Phase 3 (Parallel):** tester + reviewer + documenter (validate development outputs)
1242
-
1243
- ## 🚀 Begin Orchestration
1244
-
1245
- Now execute this Queen Agent orchestration plan:
1246
- 1. Initialize the swarm session in Memory
1247
- 2. Create the master task list with TodoWrite
1248
- 3. Spawn all required agents using Task
1249
- 4. Monitor progress and coordinate
1250
- 5. Validate and complete the objective
1251
-
1252
- Remember: You are the Queen Agent - the master coordinator. Your role is to ensure all agents work harmoniously to achieve the objective: "${objective}"
1253
-
1254
- ## 📊 Session Information
1255
- - **Session ID**: ${sessionId}
1256
- - **Snow-Flow Version**: v${version_js_1.VERSION}
1257
- - **Authentication**: ${isAuthenticated ? 'Active' : 'Required'}
1258
- - **Deployment Mode**: ${options.autoDeploy ? 'Live deployment enabled' : 'Planning mode'}
1259
- - **Estimated Agents**: ${taskAnalysis.estimatedAgentCount}
1260
- - **Primary Agent**: ${taskAnalysis.primaryAgent}
1261
-
1262
- 🎯 **Ready to begin orchestration!**
1263
- `;
1264
- return prompt;
1265
- }
1266
673
  // Helper function to analyze objectives using intelligent agent detection
1267
674
  function analyzeObjective(objective, userMaxAgents) {
1268
675
  return agent_detector_js_1.AgentDetector.analyzeTask(objective, userMaxAgents);
@@ -1740,10 +1147,10 @@ async function checkAndInstallSnowCode() {
1740
1147
  }
1741
1148
  async function createDirectoryStructure(targetDir, force = false) {
1742
1149
  // Minimal directory structure for snow-code
1743
- // Legacy directories (.claude, .swarm, .snow-flow, memory, coordination, servicenow, templates, scripts) removed
1150
+ // Legacy directories (.claude, .swarm, .snow-flow, memory, coordination, servicenow, templates, scripts, .snow-code/agent) removed
1151
+ // snow-code has its own built-in agent system, no need for custom agents from snow-flow
1744
1152
  const directories = [
1745
1153
  '.snow-code',
1746
- '.snow-code/agent',
1747
1154
  '.snow-code/command',
1748
1155
  '.snow-code/plugin'
1749
1156
  ];
@@ -2010,16 +1417,16 @@ async function verifyMCPServers(targetDir) {
2010
1417
  const path = require('path');
2011
1418
  const fs = require('fs').promises;
2012
1419
  try {
2013
- // Read SnowCode configuration - try snow-code.json first (primary), then config.json (fallback)
2014
- const snowCodeJsonPath = path.join(targetDir, '.snow-code', 'snow-code.json');
1420
+ // Read SnowCode configuration - try config.json first (primary), then snow-code.json (fallback for legacy)
2015
1421
  const configJsonPath = path.join(targetDir, '.snow-code', 'config.json');
1422
+ const snowCodeJsonPath = path.join(targetDir, '.snow-code', 'snow-code.json');
2016
1423
  let configContent;
2017
1424
  try {
2018
- configContent = await fs.readFile(snowCodeJsonPath, 'utf-8');
1425
+ configContent = await fs.readFile(configJsonPath, 'utf-8');
2019
1426
  }
2020
1427
  catch {
2021
- // Fallback to config.json if snow-code.json doesn't exist
2022
- configContent = await fs.readFile(configJsonPath, 'utf-8');
1428
+ // Fallback to snow-code.json for legacy projects
1429
+ configContent = await fs.readFile(snowCodeJsonPath, 'utf-8');
2023
1430
  }
2024
1431
  const config = JSON.parse(configContent);
2025
1432
  if (!config.mcp) {
@@ -2180,32 +1587,7 @@ async function copyCLAUDEmd(targetDir, force = false) {
2180
1587
  }
2181
1588
  // Setup .snow-code/ directory (directories already created by createDirectoryStructure)
2182
1589
  const snowcodeDir = (0, path_1.join)(targetDir, '.snow-code');
2183
- const agentsDir = (0, path_1.join)(snowcodeDir, 'agent');
2184
- // Copy agent files from .snow-code/agent/ in snow-flow package
2185
- const sourceAgentsDir = (0, path_1.join)(snowFlowRoot, '.snow-code', 'agent');
2186
- try {
2187
- const agentFiles = await fs_1.promises.readdir(sourceAgentsDir);
2188
- for (const file of agentFiles) {
2189
- if (file.endsWith('.md')) {
2190
- const sourceFile = (0, path_1.join)(sourceAgentsDir, file);
2191
- const targetFile = (0, path_1.join)(agentsDir, file);
2192
- try {
2193
- await fs_1.promises.access(targetFile);
2194
- if (force) {
2195
- const content = await fs_1.promises.readFile(sourceFile, 'utf-8');
2196
- await fs_1.promises.writeFile(targetFile, content);
2197
- }
2198
- }
2199
- catch {
2200
- const content = await fs_1.promises.readFile(sourceFile, 'utf-8');
2201
- await fs_1.promises.writeFile(targetFile, content);
2202
- }
2203
- }
2204
- }
2205
- }
2206
- catch (err) {
2207
- // Silently continue - agent files are optional
2208
- }
1590
+ // Agent files no longer copied - snow-code has its own built-in agent system
2209
1591
  // Create .snow-code/config.json from .mcp.json.template
2210
1592
  const envPath = (0, path_1.join)(targetDir, '.env');
2211
1593
  const envValues = {};
@@ -2365,7 +1747,7 @@ async function appendToEnvFile(targetDir, content) {
2365
1747
  }
2366
1748
  /**
2367
1749
  * Converts Claude Desktop MCP config format to SnowCode/OpenCode format
2368
- * Single source of truth: .mcp.json.template → both .mcp.json and .snow-code/snow-code.json
1750
+ * Single source of truth: .mcp.json.template → both .mcp.json and .snow-code/config.json
2369
1751
  */
2370
1752
  function convertToSnowCodeFormat(claudeConfig) {
2371
1753
  const snowcodeConfig = {
@@ -2994,7 +2376,7 @@ async function setupMCPConfig(targetDir, instanceUrl, clientId, clientSecret, fo
2994
2376
  prompts.log.message(` Servers: ${Object.keys(snowcodeConfig.mcp).join(', ')}`);
2995
2377
  // 🔥 ALSO write LOCAL config (takes priority!)
2996
2378
  const localSnowcodeDir = (0, path_1.join)(targetDir, '.snow-code');
2997
- const localSnowcodePath = (0, path_1.join)(localSnowcodeDir, 'snow-code.json');
2379
+ const localSnowcodePath = (0, path_1.join)(localSnowcodeDir, 'config.json');
2998
2380
  try {
2999
2381
  // Ensure local .snow-code directory exists
3000
2382
  await fs_1.promises.mkdir(localSnowcodeDir, { recursive: true });