snow-flow 8.32.13 → 8.32.14

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 CHANGED
@@ -804,6 +804,125 @@ Your process:
804
804
 
805
805
  ---
806
806
 
807
+ ## 🔗 PROACTIVE INFORMATION FETCHING
808
+
809
+ ### CRITICAL RULE: Always Fetch Instance URL First
810
+
811
+ **NEVER provide placeholder URLs. ALWAYS fetch the actual instance URL first.**
812
+
813
+ When you need to provide a ServiceNow URL to the user:
814
+ 1. **AUTOMATICALLY** call `snow_get_instance_info` FIRST (without asking)
815
+ 2. **THEN** construct the full URL using the actual instance URL
816
+ 3. **NEVER** use placeholders like `[je-instance].service-now.com` or `[your-instance]`
817
+
818
+ **Examples:**
819
+
820
+ ❌ **WRONG - Placeholder URL:**
821
+ ```
822
+ The URL is: https://[je-instance].service-now.com/sys_update_set.do?sys_id=123
823
+ ```
824
+
825
+ ✅ **CORRECT - Actual URL:**
826
+ ```javascript
827
+ // First, get instance info (do this automatically!)
828
+ const info = await snow_get_instance_info()
829
+ // Then provide the actual URL
830
+ const url = `${info.data.instance_url}/sys_update_set.do?sys_id=123`
831
+ ```
832
+
833
+ **This applies to ALL ServiceNow URLs:**
834
+ - Update Set URLs
835
+ - Record URLs
836
+ - Table URLs
837
+ - Widget URLs
838
+ - Any UI links
839
+
840
+ ### Proactive Tool Usage Patterns
841
+
842
+ **Don't wait for the user to ask - be proactive!**
843
+
844
+ #### Instance Information
845
+ - When discussing URLs → Automatically use `snow_get_instance_info`
846
+ - When checking configuration → Automatically use `snow_get_instance_info`
847
+ - When verifying connection → Automatically use `snow_get_instance_info`
848
+
849
+ #### Update Set Operations
850
+ - When user mentions "update set" → Automatically check current with `snow_update_set_current`
851
+ - When starting development → Automatically create update set if none active
852
+ - After creating artifacts → Automatically provide full URL with instance info
853
+
854
+ #### Error Handling
855
+ - When operations fail → Automatically check logs with `snow_get_logs`
856
+ - When connection fails → Automatically verify with `snow_get_instance_info`
857
+ - When scripts error → Automatically fetch execution logs
858
+
859
+ #### Post-Completion Actions
860
+ - After creating widgets → Automatically offer preview URL
861
+ - After deployments → Automatically verify success
862
+ - After queries → Automatically offer export options
863
+
864
+ ### Context Awareness
865
+
866
+ **Remember what you know from previous tool calls.**
867
+
868
+ - If you just created an update set, you know its sys_id → Don't ask for it
869
+ - If you just queried a record, you know its details → Use them
870
+ - If you checked instance info, you know the URL → Reuse it
871
+ - If user mentions "the widget" and you just created one, you know which one
872
+
873
+ **Anti-Pattern:**
874
+ ```
875
+ ❌ User: "Open the update set"
876
+ You: "Which update set do you want to open?"
877
+ (You just created one 2 messages ago!)
878
+ ```
879
+
880
+ **Correct Pattern:**
881
+ ```
882
+ ✅ User: "Open the update set"
883
+ You: "Opening the update set 'Feature: Dashboard' (sys_id: abc123) that we just created..."
884
+ [Automatically constructs full URL with instance info]
885
+ ```
886
+
887
+ ### Communication Style Guidelines
888
+
889
+ #### Be Action-Oriented, Not Question-Oriented
890
+ - ✅ "Let me fetch the instance URL and create that update set..."
891
+ - ❌ "Would you like me to create an update set? What should I call it?"
892
+
893
+ #### Show Results, Don't Describe Actions
894
+ - ✅ [Executes tool] "Created widget 'incident_dashboard' - here's the preview URL: https://dev123.service-now.com/sp?id=..."
895
+ - ❌ "You can create a widget using the snow_create_widget tool..."
896
+
897
+ #### Provide Complete Information
898
+ - ✅ "Here's the direct URL: https://dev351277.service-now.com/sys_update_set.do?sys_id=abc123"
899
+ - ❌ "Here's the URL: /sys_update_set.do?sys_id=abc123"
900
+
901
+ #### Smart Suggestions After Completion
902
+ After completing tasks, proactively suggest next steps:
903
+ - After creating widget → "Would you like me to preview it in your instance?"
904
+ - After querying data → "I can export this to CSV/JSON if you'd like"
905
+ - After finding errors → "Shall I help fix these issues?"
906
+ - After deployment → "Would you like me to verify the deployment succeeded?"
907
+
908
+ ### Common Mistakes to Avoid
909
+
910
+ **❌ DON'T:**
911
+ 1. Ask for information you can fetch yourself
912
+ 2. Provide incomplete or placeholder URLs
913
+ 3. Wait for permission to help (just do it!)
914
+ 4. Give generic errors ("something went wrong")
915
+ 5. Ask clarifying questions when you have context
916
+
917
+ **✅ DO:**
918
+ 1. Fetch information proactively
919
+ 2. Provide complete, clickable URLs
920
+ 3. Take initiative to help
921
+ 4. Provide specific, actionable information
922
+ 5. Use context from previous interactions
923
+
924
+ ---
925
+
807
926
  ## 🎓 FINAL MANDATE
808
927
 
809
928
  **Your mission** is to transform natural language user intent into concrete ServiceNow artifacts using the 410+ MCP tools available to you.
@@ -817,6 +936,10 @@ Your process:
817
936
  6. ✅ Manage context efficiently with lazy loading
818
937
  7. ✅ Follow the tool discovery decision tree
819
938
  8. ✅ Respect widget coherence (HTML ↔ Client ↔ Server)
939
+ 9. ✅ Always fetch instance URL before providing links (NO placeholders!)
940
+ 10. ✅ Be proactive - fetch information automatically
941
+ 11. ✅ Remember context - don't ask for info you already have
942
+ 12. ✅ Provide complete, clickable URLs with full instance info
820
943
 
821
944
  **Failure modes to avoid:**
822
945
  1. ❌ Skipping Update Set workflow
@@ -826,6 +949,10 @@ Your process:
826
949
  5. ❌ Using background scripts for development work
827
950
  6. ❌ Assuming instead of verifying
828
951
  7. ❌ Loading all tools instead of lazy loading
952
+ 8. ❌ Providing placeholder URLs like [your-instance].service-now.com
953
+ 9. ❌ Asking for information you can fetch automatically
954
+ 10. ❌ Forgetting context from previous tool calls
955
+ 11. ❌ Waiting for permission when you should take initiative
829
956
 
830
957
  **Remember:**
831
958
  - You are not documenting features - you are **building them**
@@ -2,7 +2,7 @@
2
2
  * Snow-Flow Health Monitoring API
3
3
  * Real-time system health and monitoring endpoints
4
4
  */
5
- declare const app: any;
5
+ declare const app: import("express-serve-static-core").Express;
6
6
  declare function start(): Promise<void>;
7
7
  export { app, start };
8
8
  //# sourceMappingURL=health-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"health-api.d.ts","sourceRoot":"","sources":["../../src/api/health-api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,QAAA,MAAM,GAAG,KAAY,CAAC;AAyQtB,iBAAe,KAAK,kBAanB;AAoCD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"health-api.d.ts","sourceRoot":"","sources":["../../src/api/health-api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,QAAA,MAAM,GAAG,6CAAY,CAAC;AAyQtB,iBAAe,KAAK,kBAanB;AAoCD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC"}
@@ -2,6 +2,6 @@
2
2
  * Snow-Flow Simple Health Monitoring API
3
3
  * Lightweight real-time system health endpoints
4
4
  */
5
- declare const app: any;
5
+ declare const app: import("express-serve-static-core").Express;
6
6
  export { app };
7
7
  //# sourceMappingURL=simple-health-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"simple-health-api.d.ts","sourceRoot":"","sources":["../../src/api/simple-health-api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,QAAA,MAAM,GAAG,KAAY,CAAC;AAkhBtB,OAAO,EAAE,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"simple-health-api.d.ts","sourceRoot":"","sources":["../../src/api/simple-health-api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,QAAA,MAAM,GAAG,6CAAY,CAAC;AAkhBtB,OAAO,EAAE,GAAG,EAAE,CAAC"}
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;GAEG;AAysGH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,KAAK,GAAE,OAAe,GACrB,OAAO,CAAC,IAAI,CAAC,CA+Sf"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;GAEG;AA2hGH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,KAAK,GAAE,OAAe,GACrB,OAAO,CAAC,IAAI,CAAC,CA+Sf"}
package/dist/cli.js CHANGED
@@ -57,6 +57,8 @@ const chalk_1 = __importDefault(require("chalk"));
57
57
  const prompts = __importStar(require("@clack/prompts"));
58
58
  // Load MCP Persistent Guard for bulletproof server protection
59
59
  const mcp_persistent_guard_js_1 = require("./utils/mcp-persistent-guard.js");
60
+ // Automatic snow-code update utility
61
+ const auto_update_snow_code_js_1 = require("./utils/auto-update-snow-code.js");
60
62
  // Activate MCP guard ONLY for commands that actually use MCP servers
61
63
  // Explicitly exclude: init, version, help, auth, export, config commands
62
64
  const commandsNeedingMCP = ['swarm', 'status', 'monitor', 'mcp'];
@@ -254,6 +256,22 @@ program
254
256
  cliLogger.info(`\n🚀 Snow-Flow v${version_js_1.VERSION}`);
255
257
  console.log(chalk_1.default.blue(`📋 ${objective}`));
256
258
  }
259
+ // Ensure snow-code is up-to-date before starting swarm execution
260
+ try {
261
+ if (options.verbose) {
262
+ cliLogger.info('🔄 Checking for snow-code updates...');
263
+ }
264
+ const updateResult = await (0, auto_update_snow_code_js_1.autoUpdateSnowCode)(process.cwd(), options.verbose);
265
+ if (updateResult.success && options.verbose) {
266
+ cliLogger.info(`✓ Snow-code v${updateResult.mainPackageVersion || 'latest'} ready`);
267
+ }
268
+ // Silently continue if update fails - don't block swarm execution
269
+ }
270
+ catch (updateErr) {
271
+ if (options.verbose) {
272
+ cliLogger.debug('Snow-code update check failed (non-critical):', updateErr);
273
+ }
274
+ }
257
275
  // Only show detailed config in verbose mode
258
276
  if (options.verbose) {
259
277
  cliLogger.info(`⚙️ Strategy: ${options.strategy} | Mode: ${options.mode} | Max Agents: ${options.maxAgents}`);
@@ -541,177 +559,12 @@ function stopMCPServers() {
541
559
  // Ignore errors
542
560
  }
543
561
  }
544
- // Helper function to auto-update SnowCode to latest version
545
- async function autoUpdateSnowCode(verbose = false) {
546
- try {
547
- const { execSync } = require('child_process');
548
- const { existsSync, readdirSync, rmSync } = require('fs');
549
- const { join, dirname } = require('path');
550
- if (verbose) {
551
- cliLogger.info('🔄 Checking for SnowCode updates...');
552
- }
553
- // Get current version
554
- const currentVersion = execSync('snow-code --version', { encoding: 'utf8' }).trim();
555
- // Get latest version from npm
556
- const latestVersion = execSync('npm view @groeimetai/snow-code version', { encoding: 'utf8' }).trim();
557
- // Helper to find node_modules in current and parent directories
558
- const findNodeModules = (startPath) => {
559
- const found = [];
560
- let currentPath = startPath;
561
- // Check up to 3 levels up
562
- for (let i = 0; i < 3; i++) {
563
- const nodeModulesPath = join(currentPath, 'node_modules', '@groeimetai');
564
- if (existsSync(nodeModulesPath)) {
565
- found.push(currentPath);
566
- }
567
- const parent = dirname(currentPath);
568
- if (parent === currentPath)
569
- break; // Reached root
570
- currentPath = parent;
571
- }
572
- return found;
573
- };
574
- // Helper to update local node_modules
575
- const updateLocalNodeModules = (projectRoot) => {
576
- const groeimetaiPath = join(projectRoot, 'node_modules', '@groeimetai');
577
- if (existsSync(groeimetaiPath)) {
578
- // Check main package version AND platform binaries
579
- const snowcodePackage = join(groeimetaiPath, 'snow-code', 'package.json');
580
- let needsUpdate = false;
581
- if (existsSync(snowcodePackage)) {
582
- const pkg = JSON.parse(require('fs').readFileSync(snowcodePackage, 'utf8'));
583
- if (pkg.version !== latestVersion) {
584
- needsUpdate = true;
585
- if (verbose) {
586
- cliLogger.info(`Main package outdated: ${pkg.version} → ${latestVersion}`);
587
- }
588
- }
589
- }
590
- else {
591
- needsUpdate = true;
592
- }
593
- // Also check platform binaries (snow-code-darwin-arm64, etc.)
594
- if (!needsUpdate) {
595
- try {
596
- const packages = readdirSync(groeimetaiPath);
597
- for (const pkg of packages) {
598
- if (pkg.startsWith('snow-code-')) {
599
- const pkgJsonPath = join(groeimetaiPath, pkg, 'package.json');
600
- if (existsSync(pkgJsonPath)) {
601
- const pkgJson = JSON.parse(require('fs').readFileSync(pkgJsonPath, 'utf8'));
602
- if (pkgJson.version !== latestVersion) {
603
- needsUpdate = true;
604
- if (verbose) {
605
- cliLogger.info(`Platform binary outdated: ${pkg}@${pkgJson.version} → ${latestVersion}`);
606
- }
607
- break;
608
- }
609
- }
610
- }
611
- }
612
- }
613
- catch (err) {
614
- if (verbose) {
615
- cliLogger.debug(`Error checking platform binaries: ${err}`);
616
- }
617
- }
618
- }
619
- if (needsUpdate) {
620
- if (verbose) {
621
- cliLogger.info(`📦 Updating SnowCode in ${projectRoot}...`);
622
- }
623
- // Remove old platform binaries to force reinstall
624
- try {
625
- const packages = readdirSync(groeimetaiPath);
626
- for (const pkg of packages) {
627
- if (pkg.startsWith('snow-code-') || pkg === 'snow-code') {
628
- const pkgPath = join(groeimetaiPath, pkg);
629
- cliLogger.debug(`Removing old package: ${pkg}`);
630
- rmSync(pkgPath, { recursive: true, force: true });
631
- }
632
- }
633
- }
634
- catch (err) {
635
- cliLogger.debug(`Cleanup error: ${err}`);
636
- }
637
- // Remove package-lock.json to ensure fresh install (avoid stale lockfile cache)
638
- const lockfilePath = join(projectRoot, 'package-lock.json');
639
- if (existsSync(lockfilePath)) {
640
- cliLogger.debug('Removing stale package-lock.json');
641
- rmSync(lockfilePath, { force: true });
642
- }
643
- // Install fresh version
644
- execSync('npm install @groeimetai/snow-code@latest', {
645
- stdio: 'inherit',
646
- cwd: projectRoot
647
- });
648
- // Restore executable permissions for platform binaries
649
- try {
650
- const packages = readdirSync(groeimetaiPath);
651
- for (const pkg of packages) {
652
- if (pkg.startsWith('snow-code-')) {
653
- const binPath = join(groeimetaiPath, pkg, 'bin');
654
- if (existsSync(binPath)) {
655
- const binaries = readdirSync(binPath);
656
- for (const binary of binaries) {
657
- const binaryPath = join(binPath, binary);
658
- try {
659
- execSync(`chmod +x "${binaryPath}"`, { stdio: 'ignore' });
660
- cliLogger.debug(`Set executable: ${pkg}/bin/${binary}`);
661
- }
662
- catch (err) {
663
- cliLogger.debug(`Chmod error for ${binary}: ${err}`);
664
- }
665
- }
666
- }
667
- }
668
- }
669
- }
670
- catch (err) {
671
- cliLogger.debug(`Error setting permissions: ${err}`);
672
- }
673
- cliLogger.info(`✅ Updated SnowCode in ${projectRoot}`);
674
- }
675
- }
676
- };
677
- if (currentVersion !== latestVersion) {
678
- cliLogger.info(`📦 Updating SnowCode: ${currentVersion} → ${latestVersion}`);
679
- // Update global version
680
- execSync('npm install -g @groeimetai/snow-code@latest', { stdio: 'inherit' });
681
- // Update all local node_modules
682
- const projectRoots = findNodeModules(process.cwd());
683
- cliLogger.info(`Found ${projectRoots.length} project(s) with node_modules`);
684
- for (const root of projectRoots) {
685
- updateLocalNodeModules(root);
686
- }
687
- cliLogger.info(`✅ SnowCode updated to ${latestVersion}`);
688
- }
689
- else {
690
- cliLogger.info(`✅ SnowCode is up-to-date (${currentVersion})`);
691
- // Even if global is up-to-date, check local node_modules
692
- const projectRoots = findNodeModules(process.cwd());
693
- cliLogger.debug(`Checking ${projectRoots.length} project(s) for local updates`);
694
- for (const root of projectRoots) {
695
- updateLocalNodeModules(root);
696
- }
697
- }
698
- }
699
- catch (error) {
700
- // Log error but don't block execution
701
- // Silently catch update errors - user can manually update with: npm install -g @groeimetai/snow-code@latest
702
- if (verbose) {
703
- cliLogger.warn(`⚠️ Auto-update check failed: ${error instanceof Error ? error.message : String(error)}`);
704
- cliLogger.debug(`Full error: ${error}`);
705
- cliLogger.info('💡 To manually update SnowCode: npm install -g @groeimetai/snow-code@latest');
706
- }
707
- }
708
- }
709
562
  // Helper function to execute SnowCode directly with the objective
710
563
  async function executeSnowCode(objective, options) {
711
564
  let mcpServerPIDs = [];
712
565
  try {
713
566
  // Auto-update SnowCode to latest version
714
- await autoUpdateSnowCode(options.verbose);
567
+ await (0, auto_update_snow_code_js_1.autoUpdateSnowCode)(process.cwd(), options.verbose);
715
568
  // Check if SnowCode CLI is available
716
569
  const { execSync } = require('child_process');
717
570
  try {
@@ -1682,41 +1535,28 @@ program
1682
1535
  await migrationUtil.migrate();
1683
1536
  s.stop('Migration complete');
1684
1537
  }
1685
- // Install/Update SnowCode (both global and local peer dependency)
1538
+ // Install/Update SnowCode with comprehensive auto-update utility
1686
1539
  const snowcodeSpinner = prompts.spinner();
1687
- snowcodeSpinner.start('Checking SnowCode installation');
1540
+ snowcodeSpinner.start('Updating snow-code to latest version');
1688
1541
  try {
1689
- const { execSync } = await Promise.resolve().then(() => __importStar(require('child_process')));
1690
- // Update GLOBAL snow-code first (used by snow-flow auth login)
1691
- snowcodeSpinner.message('Updating global @groeimetai/snow-code');
1692
- try {
1693
- execSync('npm install -g @groeimetai/snow-code@latest', {
1694
- stdio: 'ignore'
1695
- });
1696
- snowcodeSpinner.message('Global SnowCode updated to latest');
1697
- }
1698
- catch (globalErr) {
1699
- // Continue even if global update fails
1700
- }
1701
- // Update local peer dependency - ALWAYS use @latest to avoid cached old versions
1702
- snowcodeSpinner.message('Updating local @groeimetai/snow-code');
1703
- try {
1704
- // ALWAYS install @latest instead of peerDependency version
1705
- // This ensures users get the newest features/fixes, not a cached older version
1706
- execSync('npm install @groeimetai/snow-code@latest', {
1707
- stdio: 'ignore',
1708
- cwd: targetDir
1709
- });
1710
- snowcodeSpinner.message('Local SnowCode updated to latest');
1542
+ const updateResult = await (0, auto_update_snow_code_js_1.autoUpdateSnowCode)(targetDir, false);
1543
+ if (updateResult.success) {
1544
+ snowcodeSpinner.stop(`✓ Snow-code updated to v${updateResult.mainPackageVersion || 'latest'}`);
1545
+ if (updateResult.binaryPackagesUpdated > 0) {
1546
+ prompts.log.info(` Updated ${updateResult.binaryPackagesUpdated} platform-specific binaries`);
1547
+ }
1711
1548
  }
1712
- catch (localErr) {
1713
- // Continue even if local update fails
1549
+ else {
1550
+ snowcodeSpinner.stop('⚠️ Snow-code update completed with warnings');
1551
+ if (updateResult.errors.length > 0) {
1552
+ prompts.log.warn('Some updates failed - run manually if needed:');
1553
+ prompts.log.warn(' npm install -g @groeimetai/snow-code@latest');
1554
+ prompts.log.warn(' npm run update-deps');
1555
+ }
1714
1556
  }
1715
- // Verify installation
1716
- snowcodeSpinner.stop('SnowCode updated (global + local)');
1717
1557
  }
1718
1558
  catch (err) {
1719
- snowcodeSpinner.stop('Could not update SnowCode');
1559
+ snowcodeSpinner.stop('Could not update snow-code');
1720
1560
  prompts.log.warn('Run: npm install -g @groeimetai/snow-code@latest');
1721
1561
  prompts.log.warn('And: npm run update-deps');
1722
1562
  }