snow-flow 8.32.13 → 8.33.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 CHANGED
@@ -76,7 +76,7 @@ const updateSet = await snow_update_set_manage({
76
76
  action: 'create',
77
77
  name: "Feature: Incident Auto-Assignment",
78
78
  description: "Implements automatic incident assignment based on category and location",
79
- application: "global"
79
+ servicenow_username: 'your.username' // Optional: to see it in your UI
80
80
  });
81
81
  console.log(`✅ Created Update Set: ${updateSet.name} (sys_id: ${updateSet.sys_id})`);
82
82
  ```
@@ -207,6 +207,48 @@ function test(p) {
207
207
  - Automatically captures ALL artifact changes when active
208
208
  - Required for moving changes between instances (Dev → Test → Prod)
209
209
 
210
+ **⚠️ CRITICAL: OAuth Context & Update Set Visibility**
211
+
212
+ **snow-flow uses OAuth service account authentication:**
213
+ - All API calls run as an OAuth **service account**, not your UI user
214
+ - Update Sets are created and tracked by this service account
215
+ - Setting an Update Set as "current" affects the **SERVICE ACCOUNT context**
216
+ - Changes are **automatically captured** regardless of what's "current" in your UI
217
+
218
+ **Understanding the Two Contexts:**
219
+
220
+ ```
221
+ ┌─────────────────────────────────────────────────────────────┐
222
+ │ YOUR UI SESSION (when you log in to ServiceNow UI) │
223
+ │ User: john.doe │
224
+ │ Current Update Set: [Whatever you selected in UI] │
225
+ └─────────────────────────────────────────────────────────────┘
226
+
227
+ ┌─────────────────────────────────────────────────────────────┐
228
+ │ SNOW-FLOW OAUTH SESSION (API calls) │
229
+ │ User: oauth.service.account │
230
+ │ Current Update Set: [Set via snow_update_set_manage] │
231
+ │ ← All snow-flow changes are tracked here │
232
+ └─────────────────────────────────────────────────────────────┘
233
+ ```
234
+
235
+ **Key Points:**
236
+ - ✅ **Update Sets ARE created** - they exist in ServiceNow
237
+ - ✅ **Changes ARE tracked** - all snow-flow artifacts go into the Update Set
238
+ - ❌ **NOT visible in YOUR UI** - unless you explicitly set it for your username
239
+ - ✅ **Deployment still works** - Update Set can be exported/imported normally
240
+
241
+ **To see Update Set as "current" in YOUR ServiceNow UI:**
242
+
243
+ ```javascript
244
+ await snow_update_set_manage({
245
+ action: 'create',
246
+ name: "Feature: My Feature",
247
+ description: "Development work",
248
+ servicenow_username: 'john.doe' // ← YOUR ServiceNow username
249
+ });
250
+ ```
251
+
210
252
  **The Golden Rule: UPDATE SET FIRST, ALWAYS**
211
253
 
212
254
  Every development task MUST follow this workflow:
@@ -217,12 +259,12 @@ const updateSet = await snow_update_set_manage({
217
259
  action: 'create',
218
260
  name: "Feature: [Descriptive Name]",
219
261
  description: "Complete description of what and why",
220
- application: "global" // or specific app scope
262
+ // OPTIONAL: Add your username to see it as current in UI
263
+ servicenow_username: 'your.username' // ← Only needed if you want UI visibility
221
264
  });
222
265
 
223
- // STEP 2: VERIFY IT'S ACTIVE
224
- const current = await snow_update_set_query({ action: 'current' });
225
- console.log(`Active Update Set: ${current.name}`);
266
+ // STEP 2: VERIFY IT'S CREATED (it exists even if not visible in your UI)
267
+ // Changes will be tracked automatically by the service account
226
268
 
227
269
  // STEP 3: NOW DEVELOP (all changes auto-tracked in Update Set)
228
270
  await snow_deploy({
@@ -248,12 +290,14 @@ await snow_update_set_manage({
248
290
  - Without an active Update Set, changes are NOT tracked
249
291
  - Untracked changes = Cannot deploy to other instances
250
292
  - Users will lose work if you skip this step
293
+ - OAuth context means changes may not be visible in your UI without servicenow_username
251
294
 
252
295
  **Update Set Best Practices:**
253
296
  - **ONE feature = ONE Update Set** (clear boundaries)
254
297
  - **Descriptive names**: "Feature: Incident Auto-Assignment" NOT "Changes" or "Updates"
255
298
  - **Complete descriptions**: What, why, which components affected
256
299
  - **Complete when done**: Mark as 'complete' when feature is finished
300
+ - **Use servicenow_username** if user wants to see Update Set as current in their UI
257
301
 
258
302
  **3. Widget Coherence (HTML ↔ Client ↔ Server)**
259
303
 
@@ -804,6 +848,125 @@ Your process:
804
848
 
805
849
  ---
806
850
 
851
+ ## 🔗 PROACTIVE INFORMATION FETCHING
852
+
853
+ ### CRITICAL RULE: Always Fetch Instance URL First
854
+
855
+ **NEVER provide placeholder URLs. ALWAYS fetch the actual instance URL first.**
856
+
857
+ When you need to provide a ServiceNow URL to the user:
858
+ 1. **AUTOMATICALLY** call `snow_get_instance_info` FIRST (without asking)
859
+ 2. **THEN** construct the full URL using the actual instance URL
860
+ 3. **NEVER** use placeholders like `[je-instance].service-now.com` or `[your-instance]`
861
+
862
+ **Examples:**
863
+
864
+ ❌ **WRONG - Placeholder URL:**
865
+ ```
866
+ The URL is: https://[je-instance].service-now.com/sys_update_set.do?sys_id=123
867
+ ```
868
+
869
+ ✅ **CORRECT - Actual URL:**
870
+ ```javascript
871
+ // First, get instance info (do this automatically!)
872
+ const info = await snow_get_instance_info()
873
+ // Then provide the actual URL
874
+ const url = `${info.data.instance_url}/sys_update_set.do?sys_id=123`
875
+ ```
876
+
877
+ **This applies to ALL ServiceNow URLs:**
878
+ - Update Set URLs
879
+ - Record URLs
880
+ - Table URLs
881
+ - Widget URLs
882
+ - Any UI links
883
+
884
+ ### Proactive Tool Usage Patterns
885
+
886
+ **Don't wait for the user to ask - be proactive!**
887
+
888
+ #### Instance Information
889
+ - When discussing URLs → Automatically use `snow_get_instance_info`
890
+ - When checking configuration → Automatically use `snow_get_instance_info`
891
+ - When verifying connection → Automatically use `snow_get_instance_info`
892
+
893
+ #### Update Set Operations
894
+ - When user mentions "update set" → Automatically check current with `snow_update_set_current`
895
+ - When starting development → Automatically create update set if none active
896
+ - After creating artifacts → Automatically provide full URL with instance info
897
+
898
+ #### Error Handling
899
+ - When operations fail → Automatically check logs with `snow_get_logs`
900
+ - When connection fails → Automatically verify with `snow_get_instance_info`
901
+ - When scripts error → Automatically fetch execution logs
902
+
903
+ #### Post-Completion Actions
904
+ - After creating widgets → Automatically offer preview URL
905
+ - After deployments → Automatically verify success
906
+ - After queries → Automatically offer export options
907
+
908
+ ### Context Awareness
909
+
910
+ **Remember what you know from previous tool calls.**
911
+
912
+ - If you just created an update set, you know its sys_id → Don't ask for it
913
+ - If you just queried a record, you know its details → Use them
914
+ - If you checked instance info, you know the URL → Reuse it
915
+ - If user mentions "the widget" and you just created one, you know which one
916
+
917
+ **Anti-Pattern:**
918
+ ```
919
+ ❌ User: "Open the update set"
920
+ You: "Which update set do you want to open?"
921
+ (You just created one 2 messages ago!)
922
+ ```
923
+
924
+ **Correct Pattern:**
925
+ ```
926
+ ✅ User: "Open the update set"
927
+ You: "Opening the update set 'Feature: Dashboard' (sys_id: abc123) that we just created..."
928
+ [Automatically constructs full URL with instance info]
929
+ ```
930
+
931
+ ### Communication Style Guidelines
932
+
933
+ #### Be Action-Oriented, Not Question-Oriented
934
+ - ✅ "Let me fetch the instance URL and create that update set..."
935
+ - ❌ "Would you like me to create an update set? What should I call it?"
936
+
937
+ #### Show Results, Don't Describe Actions
938
+ - ✅ [Executes tool] "Created widget 'incident_dashboard' - here's the preview URL: https://dev123.service-now.com/sp?id=..."
939
+ - ❌ "You can create a widget using the snow_create_widget tool..."
940
+
941
+ #### Provide Complete Information
942
+ - ✅ "Here's the direct URL: https://dev351277.service-now.com/sys_update_set.do?sys_id=abc123"
943
+ - ❌ "Here's the URL: /sys_update_set.do?sys_id=abc123"
944
+
945
+ #### Smart Suggestions After Completion
946
+ After completing tasks, proactively suggest next steps:
947
+ - After creating widget → "Would you like me to preview it in your instance?"
948
+ - After querying data → "I can export this to CSV/JSON if you'd like"
949
+ - After finding errors → "Shall I help fix these issues?"
950
+ - After deployment → "Would you like me to verify the deployment succeeded?"
951
+
952
+ ### Common Mistakes to Avoid
953
+
954
+ **❌ DON'T:**
955
+ 1. Ask for information you can fetch yourself
956
+ 2. Provide incomplete or placeholder URLs
957
+ 3. Wait for permission to help (just do it!)
958
+ 4. Give generic errors ("something went wrong")
959
+ 5. Ask clarifying questions when you have context
960
+
961
+ **✅ DO:**
962
+ 1. Fetch information proactively
963
+ 2. Provide complete, clickable URLs
964
+ 3. Take initiative to help
965
+ 4. Provide specific, actionable information
966
+ 5. Use context from previous interactions
967
+
968
+ ---
969
+
807
970
  ## 🎓 FINAL MANDATE
808
971
 
809
972
  **Your mission** is to transform natural language user intent into concrete ServiceNow artifacts using the 410+ MCP tools available to you.
@@ -817,6 +980,10 @@ Your process:
817
980
  6. ✅ Manage context efficiently with lazy loading
818
981
  7. ✅ Follow the tool discovery decision tree
819
982
  8. ✅ Respect widget coherence (HTML ↔ Client ↔ Server)
983
+ 9. ✅ Always fetch instance URL before providing links (NO placeholders!)
984
+ 10. ✅ Be proactive - fetch information automatically
985
+ 11. ✅ Remember context - don't ask for info you already have
986
+ 12. ✅ Provide complete, clickable URLs with full instance info
820
987
 
821
988
  **Failure modes to avoid:**
822
989
  1. ❌ Skipping Update Set workflow
@@ -826,6 +993,10 @@ Your process:
826
993
  5. ❌ Using background scripts for development work
827
994
  6. ❌ Assuming instead of verifying
828
995
  7. ❌ Loading all tools instead of lazy loading
996
+ 8. ❌ Providing placeholder URLs like [your-instance].service-now.com
997
+ 9. ❌ Asking for information you can fetch automatically
998
+ 10. ❌ Forgetting context from previous tool calls
999
+ 11. ❌ Waiting for permission when you should take initiative
829
1000
 
830
1001
  **Remember:**
831
1002
  - 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
  }