@rigstate/cli 0.7.23 → 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/dist/index.cjs +104 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +104 -76
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/daemon/core.ts +30 -0
package/package.json
CHANGED
package/src/daemon/core.ts
CHANGED
|
@@ -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}`);
|