@rigstate/cli 0.7.22 → 0.7.24

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.22",
3
+ "version": "0.7.24",
4
4
  "description": "Rigstate CLI - Code audit, sync and supervision tool",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,12 +30,17 @@ export function createLinkCommand() {
30
30
 
31
31
  const manifestPath = path.join(process.cwd(), '.rigstate');
32
32
 
33
- const content = {
33
+ const content: any = {
34
34
  project_id: projectId,
35
- api_url: getApiUrl(),
36
35
  linked_at: new Date().toISOString()
37
36
  };
38
37
 
38
+ // Only store api_url locally if it's NOT the production default
39
+ const currentUrl = getApiUrl();
40
+ if (currentUrl !== 'https://app.rigstate.com') {
41
+ content.api_url = currentUrl;
42
+ }
43
+
39
44
  try {
40
45
  await fs.writeFile(manifestPath, JSON.stringify(content, null, 2), 'utf-8');
41
46
  console.log(chalk.green(`✔ Linked to project ID: ${projectId}`));
@@ -105,10 +110,6 @@ async function installHooks(cwd: string) {
105
110
  // Actually, let's just use the `hooks` command logic if possible, or a lightweight version
106
111
 
107
112
  try {
108
- const { installHooks: runInstall } = await import('./hooks.js');
109
- // We need to mock the command context or extract logic.
110
- // For simplicity/robustness in this iteration, let's just suggest it or verify
111
-
112
113
  // Simpler approach: Check if pre-commit exists
113
114
  const preCommitPath = path.join(cwd, '.git/hooks/pre-commit');
114
115
  try {
@@ -4,6 +4,7 @@ import { spawn } from 'child_process';
4
4
  import path from 'path';
5
5
  import fs from 'fs';
6
6
  import { fileURLToPath } from 'url';
7
+ import { getApiKey, getApiUrl } from '../utils/config.js';
7
8
 
8
9
  // ESM compatibility for __dirname
9
10
  const __filename = fileURLToPath(import.meta.url);
@@ -45,15 +46,29 @@ export function createMcpCommand() {
45
46
 
46
47
  console.log(chalk.dim(`Starting MCP server from: ${serverPath}`));
47
48
 
48
- // Map VIBE_API_KEY to RIGSTATE_API_KEY if needed (backwards compatibility)
49
- if (process.env.VIBE_API_KEY && !process.env.RIGSTATE_API_KEY) {
50
- process.env.RIGSTATE_API_KEY = process.env.VIBE_API_KEY;
49
+ // SMART INJECTION: Inject global config into MCP environment
50
+ const env = { ...process.env };
51
+
52
+ try {
53
+ const apiKey = getApiKey();
54
+ if (apiKey) {
55
+ env.RIGSTATE_API_KEY = apiKey;
56
+ // Also inject the URL for consistency
57
+ env.RIGSTATE_APP_URL = getApiUrl();
58
+ env.RIGSTATE_API_URL = getApiUrl();
59
+ }
60
+ } catch (e) {
61
+ // If not logged in, we carry on and let the MCP server show the final error
62
+ }
63
+
64
+ // Map VIBE_API_KEY if needed
65
+ if (env.VIBE_API_KEY && !env.RIGSTATE_API_KEY) {
66
+ env.RIGSTATE_API_KEY = env.VIBE_API_KEY;
51
67
  }
52
68
 
53
69
  // Spawn the MCP server as a child process
54
- // MCP uses stdio for communication, so we inherit it
55
70
  const worker = spawn('node', [serverPath], {
56
- env: process.env,
71
+ env,
57
72
  stdio: ['inherit', 'inherit', 'inherit']
58
73
  });
59
74
 
@@ -10,6 +10,7 @@
10
10
  import chalk from 'chalk';
11
11
  import ora from 'ora';
12
12
  import * as fs from 'fs/promises';
13
+ import path from 'path';
13
14
  import { EventEmitter } from 'events';
14
15
  import { createFileWatcher, type FileWatcherEvents } from './file-watcher.js';
15
16
  import { createHeuristicEngine } from './heuristic-engine.js';
@@ -85,6 +86,7 @@ export class GuardianDaemon extends EventEmitter {
85
86
  }
86
87
 
87
88
  this.printActive();
89
+ await this.updateViolationReport([]); // Initialize empty report
88
90
  this.emit('started', this.state);
89
91
  }
90
92
 
@@ -167,13 +169,41 @@ export class GuardianDaemon extends EventEmitter {
167
169
 
168
170
  if (result.violations.length > 0) {
169
171
  this.handleViolations(filePath, result.violations);
172
+ } else {
173
+ // Success - might need to clear previous violations for this file
174
+ await this.updateViolationReport([]);
170
175
  }
171
176
  }
172
177
 
178
+ private async updateViolationReport(violations: any[]) {
179
+ const reportPath = path.join(process.cwd(), '.rigstate', 'ACTIVE_VIOLATIONS.md');
180
+
181
+ // This is a simplified version. In a real build, we'd aggregate across all files.
182
+ // For now, let's show the most recent or active ones.
183
+ let content = `# 🛡️ Guardian Status: ${violations.length > 0 ? '⚠️ ATTENTION' : '✅ PASS'}\n\n`;
184
+ content += `*Last check: ${new Date().toLocaleString()}*\n\n`;
185
+
186
+ if (violations.length === 0) {
187
+ content += "All systems within architectural limits. Frank is satisfied. 🤫\n";
188
+ } else {
189
+ content += "### 🚨 Active Violations\n\n";
190
+ for (const v of violations) {
191
+ content += `- **[${v.severity.toUpperCase()}]**: ${v.message}\n`;
192
+ }
193
+ content += "\n---\n*Rigstate Daemon is watching. Fix violations to clear this report.*";
194
+ }
195
+
196
+ try {
197
+ await fs.writeFile(reportPath, content, 'utf-8');
198
+ } catch (e) { /* ignore */ }
199
+ }
200
+
173
201
  private handleViolations(filePath: string, violations: any[]) {
174
202
  this.state.violationsFound += violations.length;
175
203
  this.emit('violation', { file: filePath, violations });
176
204
 
205
+ this.updateViolationReport(violations); // Push to IDE dashboard
206
+
177
207
  for (const v of violations) {
178
208
  const level = v.severity === 'critical' ? 'error' : v.severity === 'warning' ? 'warn' : 'info';
179
209
  Logger[level as 'info'](`[${v.severity.toUpperCase()}] ${filePath}: ${v.message}`);
@@ -1 +0,0 @@
1
- 32037