@rigstate/cli 0.7.12 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rigstate/cli",
3
- "version": "0.7.12",
3
+ "version": "0.7.14",
4
4
  "description": "Rigstate CLI - Code audit, sync and supervision tool",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -69,7 +69,12 @@ export class GuardianDaemon extends EventEmitter {
69
69
 
70
70
  // 4. Setup Bridge
71
71
  if (this.config.bridgeEnabled) {
72
- await this.setupBridge();
72
+ try {
73
+ await this.setupBridge();
74
+ } catch (e: any) {
75
+ console.error(chalk.yellow(` ⚠️ Agent Bridge connection failed: ${e.message}`));
76
+ console.log(chalk.dim(' (Daemon will continue with local monitoring only)'));
77
+ }
73
78
  }
74
79
 
75
80
  this.printActive();
@@ -1,4 +1,6 @@
1
1
  import Conf from 'conf';
2
+ import axios from 'axios';
3
+ import chalk from 'chalk';
2
4
 
3
5
  interface RigstateConfig {
4
6
  apiKey?: string;
@@ -75,56 +77,35 @@ export function getApiUrl(): string {
75
77
  /**
76
78
  * Discovers the active local API URL (Async)
77
79
  * Scans ports 3000-3010 to find a responding Rigstate server.
80
+ * This is now SILENT and will not spam the console.
78
81
  */
79
82
  export async function discoverApiUrl(): Promise<string> {
80
83
  const configuredUrl = getApiUrl();
84
+ const ports = [3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010];
81
85
 
82
- // Dynamic import to avoid top-level await issues
83
- const { default: axios } = await import('axios');
84
- const { default: chalk } = await import('chalk');
85
-
86
- console.log(chalk.gray(`🔍 Discovering local Rigstate API URL... Configured: ${configuredUrl}`));
87
-
88
- // If not localhost, trust the config
86
+ // If not localhost, don't even bother scanning (saves time/noise)
89
87
  if (!configuredUrl.includes('localhost') && !configuredUrl.includes('127.0.0.1')) {
90
- console.log(chalk.gray(` Configured URL is not localhost, trusting: ${configuredUrl}`));
91
88
  return configuredUrl;
92
89
  }
93
90
 
94
- // Try to find the real port
95
- const ports = [3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010];
96
-
91
+ // Silent scan - check ports for a valid health endpoint
97
92
  for (const port of ports) {
98
93
  const url = `http://localhost:${port}`;
99
94
  try {
100
- console.log(chalk.gray(` Attempting to connect to ${url}/api/v1/system/health...`));
101
- // Try the health endpoint
102
- await axios.get(`${url}/api/v1/system/health`, { timeout: 800 });
103
-
104
- console.log(chalk.green(` ✅ Found Rigstate API at ${url}`));
105
- if (url !== configuredUrl) {
106
- console.log(chalk.gray(` Updating stored API URL from ${configuredUrl} to ${url}`));
107
- // Update config for next time
108
- setApiUrl(url);
109
- }
110
- return url;
111
- } catch (e: any) {
112
- // Check if it's a 404 on the health endpoint - if so, it might still be our server
113
- // But we prefer a positive match on health.
114
- if (axios.isAxiosError(e) && e.response && e.response.status === 404) {
115
- console.log(chalk.yellow(` ⚠️ ${url} responded with 404, but might still be a Rigstate server. Skipping for now.`));
116
- } else if (axios.isAxiosError(e) && e.code === 'ECONNABORTED') {
117
- console.log(chalk.gray(` Connection to ${url} timed out.`));
118
- } else if (axios.isAxiosError(e) && e.code === 'ECONNREFUSED') {
119
- console.log(chalk.gray(` Connection to ${url} refused.`));
120
- } else {
121
- console.log(chalk.gray(` Failed to connect to ${url}: ${e.message}`));
95
+ const res = await axios.get(`${url}/api/v1/system/health`, { timeout: 200 });
96
+ // If it responds with 'healthy', we found a Rigstate server!
97
+ if (res.data?.status === 'healthy') {
98
+ if (url !== configuredUrl) {
99
+ setApiUrl(url);
100
+ }
101
+ return url;
122
102
  }
123
- continue;
103
+ } catch (e) {
104
+ // Move to next port silently
124
105
  }
125
106
  }
126
107
 
127
- console.log(chalk.yellow(` ❌ No local Rigstate API found on scanned ports. Falling back to Rigstate Cloud.`));
108
+ // Default to Cloud if local Rigstate server is not found
128
109
  return 'https://app.rigstate.com';
129
110
  }
130
111