@rigstate/cli 0.7.25 → 0.7.26
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 +22 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/daemon/core.ts +28 -11
- package/.rigstate/daemon.state.json +0 -8
package/package.json
CHANGED
package/src/daemon/core.ts
CHANGED
|
@@ -160,6 +160,8 @@ export class GuardianDaemon extends EventEmitter {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
private violationsMap = new Map<string, any[]>();
|
|
164
|
+
|
|
163
165
|
private async runIntegrityCheck(filePath: string) {
|
|
164
166
|
if (!this.guardianMonitor) return;
|
|
165
167
|
|
|
@@ -170,25 +172,37 @@ export class GuardianDaemon extends EventEmitter {
|
|
|
170
172
|
if (result.violations.length > 0) {
|
|
171
173
|
this.handleViolations(filePath, result.violations);
|
|
172
174
|
} else {
|
|
173
|
-
// Success -
|
|
174
|
-
|
|
175
|
+
// Success - clear violations for this file
|
|
176
|
+
if (this.violationsMap.has(filePath)) {
|
|
177
|
+
this.violationsMap.delete(filePath);
|
|
178
|
+
this.updateViolationReport(); // Update the aggregate report
|
|
179
|
+
}
|
|
175
180
|
}
|
|
176
181
|
}
|
|
177
182
|
|
|
178
|
-
private async updateViolationReport(violations
|
|
183
|
+
private async updateViolationReport(violations?: any[]) {
|
|
184
|
+
// If violations arg is passed (from handleViolations), update the map first
|
|
185
|
+
// But usually handleViolations calls this without args to just refresh
|
|
186
|
+
|
|
179
187
|
const reportPath = path.join(process.cwd(), '.rigstate', 'ACTIVE_VIOLATIONS.md');
|
|
188
|
+
const allViolations = Array.from(this.violationsMap.entries());
|
|
189
|
+
const totalCount = allViolations.reduce((acc, [, v]) => acc + v.length, 0);
|
|
180
190
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
content += `*Last check: ${new Date().toLocaleString()}*\n\n`;
|
|
191
|
+
let content = `# 🛡️ Guardian Status: ${totalCount > 0 ? '⚠️ ATTENTION' : '✅ PASS'}\n\n`;
|
|
192
|
+
content += `*Last check: ${new Date().toLocaleString()}*\n`;
|
|
193
|
+
content += `*Files with issues: ${allViolations.length}*\n\n`;
|
|
185
194
|
|
|
186
|
-
if (
|
|
195
|
+
if (totalCount === 0) {
|
|
187
196
|
content += "All systems within architectural limits. Frank is satisfied. 🤫\n";
|
|
188
197
|
} else {
|
|
189
198
|
content += "### 🚨 Active Violations\n\n";
|
|
190
|
-
for (const
|
|
191
|
-
|
|
199
|
+
for (const [file, fileViolations] of allViolations) {
|
|
200
|
+
const relPath = path.relative(process.cwd(), file);
|
|
201
|
+
content += `#### 📄 ${relPath}\n`;
|
|
202
|
+
for (const v of fileViolations) {
|
|
203
|
+
content += `- **[${v.severity.toUpperCase()}]**: ${v.message}\n`;
|
|
204
|
+
}
|
|
205
|
+
content += '\n';
|
|
192
206
|
}
|
|
193
207
|
content += "\n---\n*Rigstate Daemon is watching. Fix violations to clear this report.*";
|
|
194
208
|
}
|
|
@@ -202,7 +216,10 @@ export class GuardianDaemon extends EventEmitter {
|
|
|
202
216
|
this.state.violationsFound += violations.length;
|
|
203
217
|
this.emit('violation', { file: filePath, violations });
|
|
204
218
|
|
|
205
|
-
|
|
219
|
+
// Update state map
|
|
220
|
+
this.violationsMap.set(filePath, violations);
|
|
221
|
+
|
|
222
|
+
this.updateViolationReport(); // Push to IDE dashboard
|
|
206
223
|
|
|
207
224
|
for (const v of violations) {
|
|
208
225
|
const level = v.severity === 'critical' ? 'error' : v.severity === 'warning' ? 'warn' : 'info';
|