@rigour-labs/cli 3.0.4 → 3.0.6

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.
@@ -3,125 +3,15 @@
3
3
  *
4
4
  * Creates a temp project with intentional AI-generated code issues,
5
5
  * runs Rigour against it, and shows the full experience.
6
- *
7
- * Modes:
8
- * Default: Fast demo — scaffold → check → results
9
- * --cinematic: Screen-recording optimized — typewriter effects, pauses,
10
- * simulated AI agent writing code, hooks catching issues
11
- * --hooks: Focus on the real-time hooks experience
12
- * --speed: Control pacing (fast / normal / slow)
13
- *
14
- * The "flagship demo" — one command to understand Rigour.
15
- *
16
6
  * @since v2.17.0 (extended v3.0.0)
17
7
  */
18
- import fs from 'fs-extra';
19
8
  import path from 'path';
20
- import chalk from 'chalk';
21
- import yaml from 'yaml';
9
+ import fs from 'fs-extra';
22
10
  import os from 'os';
23
- import { GateRunner, ConfigSchema } from '@rigour-labs/core';
24
- import { recordScore } from '@rigour-labs/core';
25
- const SPEED_MULTIPLIERS = {
26
- fast: 0.3,
27
- normal: 1.0,
28
- slow: 1.8,
29
- };
30
- // ── Timing helpers ──────────────────────────────────────────────────
31
- function getMultiplier(options) {
32
- return SPEED_MULTIPLIERS[options.speed || 'normal'] || 1.0;
33
- }
34
- function sleep(ms) {
35
- return new Promise(resolve => setTimeout(resolve, ms));
36
- }
37
- async function pause(ms, options) {
38
- await sleep(ms * getMultiplier(options));
39
- }
40
- // ── Typewriter effect ───────────────────────────────────────────────
41
- async function typewrite(text, options, charDelay = 18) {
42
- if (!options.cinematic) {
43
- process.stdout.write(text + '\n');
44
- return;
45
- }
46
- const delay = charDelay * getMultiplier(options);
47
- for (const char of text) {
48
- process.stdout.write(char);
49
- await sleep(delay);
50
- }
51
- process.stdout.write('\n');
52
- }
53
- // ── Simulated code writing ──────────────────────────────────────────
54
- async function simulateCodeWrite(filename, lines, options) {
55
- const isCinematic = !!options.cinematic;
56
- const lineDelay = isCinematic ? 40 * getMultiplier(options) : 0;
57
- console.log(chalk.dim(`\n ${chalk.white('▸')} Writing ${chalk.cyan(filename)}...`));
58
- if (isCinematic) {
59
- await pause(200, options);
60
- }
61
- for (const line of lines) {
62
- if (isCinematic) {
63
- process.stdout.write(chalk.dim(` ${line}\n`));
64
- await sleep(lineDelay);
65
- }
66
- }
67
- if (!isCinematic) {
68
- const preview = lines.slice(0, 3).join('\n ');
69
- console.log(chalk.dim(` ${preview}`));
70
- if (lines.length > 3) {
71
- console.log(chalk.dim(` ... (${lines.length} lines)`));
72
- }
73
- }
74
- }
75
- // ── Hook simulation ─────────────────────────────────────────────────
76
- async function simulateHookCatch(gate, file, message, severity, options) {
77
- if (options.cinematic) {
78
- await pause(300, options);
79
- }
80
- const sevColor = severity === 'critical' ? chalk.red.bold
81
- : severity === 'high' ? chalk.red
82
- : chalk.yellow;
83
- const hookPrefix = chalk.magenta.bold('[rigour/hook]');
84
- const sevLabel = sevColor(severity.toUpperCase());
85
- const gateLabel = chalk.red(`[${gate}]`);
86
- console.log(` ${hookPrefix} ${sevLabel} ${gateLabel} ${chalk.white(file)}`);
87
- console.log(` ${chalk.dim('→')} ${message}`);
88
- if (options.cinematic) {
89
- await pause(400, options);
90
- }
91
- }
92
- // ── ASCII score bar ─────────────────────────────────────────────────
93
- function renderScoreBar(score, label, width = 30) {
94
- const filled = Math.round((score / 100) * width);
95
- const empty = width - filled;
96
- const color = score >= 80 ? chalk.green : score >= 50 ? chalk.yellow : chalk.red;
97
- const bar = color('█'.repeat(filled)) + chalk.dim('░'.repeat(empty));
98
- return ` ${label.padEnd(14)} ${bar} ${color.bold(`${score}/100`)}`;
99
- }
100
- // ── ASCII trend chart ───────────────────────────────────────────────
101
- function renderTrendChart(scores) {
102
- const height = 8;
103
- const lines = [];
104
- const maxScore = 100;
105
- lines.push(chalk.dim(' Score Trend:'));
106
- for (let row = height; row >= 0; row--) {
107
- const threshold = (row / height) * maxScore;
108
- let line = chalk.dim(String(Math.round(threshold)).padStart(3) + ' │');
109
- for (const score of scores) {
110
- if (score >= threshold) {
111
- const color = score >= 80 ? chalk.green : score >= 50 ? chalk.yellow : chalk.red;
112
- line += color(' ██');
113
- }
114
- else {
115
- line += ' ';
116
- }
117
- }
118
- lines.push(line);
119
- }
120
- lines.push(chalk.dim(' └' + '───'.repeat(scores.length)));
121
- const labels = scores.map((_, i) => ` R${i + 1}`);
122
- lines.push(chalk.dim(' ' + labels.join('')));
123
- return lines.join('\n');
124
- }
11
+ import chalk from 'chalk';
12
+ import { pause, typewrite } from './demo-helpers.js';
13
+ import { printBanner, printPlantedIssues, printClosing } from './demo-display.js';
14
+ import { runHooksDemo, runFullGates, runBeforeAfterDemo, scaffoldDemoProject } from './demo-scenarios.js';
125
15
  // ── Main demo command ───────────────────────────────────────────────
126
16
  export async function demoCommand(options = {}) {
127
17
  const isCinematic = !!options.cinematic;
@@ -162,457 +52,3 @@ export async function demoCommand(options = {}) {
162
52
  // 5. Closing
163
53
  printClosing(isCinematic);
164
54
  }
165
- // ── Banner ───────────────────────────────────────────────────────────
166
- function printBanner(cinematic) {
167
- const banner = chalk.bold.cyan(`
168
- ____ _
169
- / __ \\(_)____ ___ __ __ _____
170
- / /_/ // // __ \`/ / / / / // ___/
171
- / _, _// // /_/ // /_/ / / // /
172
- /_/ |_|/_/ \\__, / \\__,_/_/ /_/
173
- /____/
174
- `);
175
- console.log(banner);
176
- }
177
- // ── Planted issues (non-cinematic) ──────────────────────────────────
178
- function printPlantedIssues() {
179
- console.log(chalk.bold.yellow('Planted issues:'));
180
- console.log(chalk.dim(' 1. src/auth.ts — Hardcoded API key (security)'));
181
- console.log(chalk.dim(' 2. src/api-handler.ts — Unhandled promise (AI drift)'));
182
- console.log(chalk.dim(' 3. src/data-loader.ts — Hallucinated import (AI drift)'));
183
- console.log(chalk.dim(' 4. src/utils.ts — TODO marker left by AI'));
184
- console.log(chalk.dim(' 5. src/god-file.ts — 350+ lines (structural)'));
185
- console.log('');
186
- }
187
- // ── Hooks demo: simulate AI agent → hook catches ────────────────────
188
- async function runHooksDemo(demoDir, options) {
189
- const divider = chalk.cyan('━'.repeat(50));
190
- console.log(divider);
191
- console.log(chalk.bold.magenta(' Simulating AI agent writing code with hooks active...\n'));
192
- if (options.cinematic) {
193
- await pause(600, options);
194
- }
195
- // Step 1: AI writes auth.ts with hardcoded key
196
- await simulateAgentWrite('src/auth.ts', [
197
- 'import express from \'express\';',
198
- '',
199
- 'const API_KEY = "sk-live-4f3c2b1a0987654321abcdef";',
200
- '',
201
- 'export function authenticate(req: express.Request) {',
202
- ' return req.headers.authorization === API_KEY;',
203
- '}',
204
- ], 'security-patterns', 'src/auth.ts:3', 'Possible hardcoded secret or API key', 'critical', options);
205
- // Step 2: AI writes data-loader.ts with hallucinated import
206
- await simulateAgentWrite('src/data-loader.ts', [
207
- 'import { z } from \'zod\';',
208
- 'import { magicParser } from \'ai-data-magic\';',
209
- '',
210
- 'export function loadData(raw: unknown) {',
211
- ' return z.object({ name: z.string() }).parse(raw);',
212
- '}',
213
- ], 'hallucinated-imports', 'src/data-loader.ts:2', 'Import \'ai-data-magic\' does not resolve to an existing package', 'high', options);
214
- // Step 3: AI writes api-handler.ts with unhandled promise
215
- await simulateAgentWrite('src/api-handler.ts', [
216
- 'export async function fetchUser(id: string) {',
217
- ' const res = await fetch(`/api/users/${id}`);',
218
- ' return res.json();',
219
- '}',
220
- '',
221
- 'export function handleRequest(req: any, res: any) {',
222
- ' fetchUser(req.params.id); // floating promise',
223
- ' res.send(\'Processing...\');',
224
- '}',
225
- ], 'promise-safety', 'src/api-handler.ts:7', 'Unhandled promise — fetchUser() called without await or .catch()', 'medium', options);
226
- console.log('');
227
- console.log(chalk.magenta.bold(` Hooks caught 3 issues in real time — before the agent finished.`));
228
- console.log(divider);
229
- console.log('');
230
- if (options.cinematic) {
231
- await pause(1000, options);
232
- }
233
- }
234
- async function simulateAgentWrite(filename, codeLines, gate, file, message, severity, options) {
235
- console.log(chalk.blue.bold(` Agent: Write → ${filename}`));
236
- await simulateCodeWrite(filename, codeLines, options);
237
- await simulateHookCatch(gate, file, message, severity, options);
238
- console.log('');
239
- }
240
- // ── Full gate run ───────────────────────────────────────────────────
241
- async function runFullGates(demoDir, options) {
242
- const isCinematic = !!options.cinematic;
243
- console.log(chalk.bold.blue('Running full Rigour quality gates...\n'));
244
- if (isCinematic) {
245
- await pause(500, options);
246
- }
247
- try {
248
- const configContent = await fs.readFile(path.join(demoDir, 'rigour.yml'), 'utf-8');
249
- const rawConfig = yaml.parse(configContent);
250
- const config = ConfigSchema.parse(rawConfig);
251
- const runner = new GateRunner(config);
252
- const report = await runner.run(demoDir);
253
- recordScore(demoDir, report);
254
- const reportPath = path.join(demoDir, config.output.report_path);
255
- await fs.writeJson(reportPath, report, { spaces: 2 });
256
- displayGateResults(report, isCinematic);
257
- await generateArtifacts(demoDir, report, config);
258
- }
259
- catch (error) {
260
- const msg = error instanceof Error ? error.message : String(error);
261
- console.error(chalk.red(`Demo error: ${msg}`));
262
- }
263
- }
264
- function displayGateResults(report, cinematic) {
265
- const stats = report.stats;
266
- if (report.status === 'FAIL') {
267
- console.log(chalk.red.bold('✘ FAIL — Quality gate violations found.\n'));
268
- // Score bars
269
- if (stats.score !== undefined) {
270
- console.log(renderScoreBar(stats.score, 'Overall'));
271
- }
272
- if (stats.ai_health_score !== undefined) {
273
- console.log(renderScoreBar(stats.ai_health_score, 'AI Health'));
274
- }
275
- if (stats.structural_score !== undefined) {
276
- console.log(renderScoreBar(stats.structural_score, 'Structural'));
277
- }
278
- console.log('');
279
- // Severity breakdown
280
- printSeverityBreakdown(stats);
281
- // Violations list
282
- for (const failure of report.failures) {
283
- printFailure(failure);
284
- }
285
- console.log('');
286
- }
287
- else {
288
- console.log(chalk.green.bold('✔ PASS — All quality gates satisfied.\n'));
289
- }
290
- console.log(chalk.dim(`Finished in ${stats.duration_ms}ms\n`));
291
- }
292
- function printSeverityBreakdown(stats) {
293
- if (!stats.severity_breakdown) {
294
- return;
295
- }
296
- const parts = Object.entries(stats.severity_breakdown)
297
- .filter(([, count]) => count > 0)
298
- .map(([sev, count]) => {
299
- const color = sev === 'critical' ? chalk.red.bold
300
- : sev === 'high' ? chalk.red
301
- : sev === 'medium' ? chalk.yellow
302
- : chalk.dim;
303
- return color(`${sev}: ${count}`);
304
- });
305
- if (parts.length > 0) {
306
- console.log('Severity: ' + parts.join(', ') + '\n');
307
- }
308
- }
309
- function printFailure(failure) {
310
- const sevLabel = failure.severity === 'critical' ? chalk.red.bold('CRIT')
311
- : failure.severity === 'high' ? chalk.red('HIGH')
312
- : failure.severity === 'medium' ? chalk.yellow('MED ')
313
- : chalk.dim('LOW ');
314
- const prov = failure.provenance ? chalk.dim(`[${failure.provenance}]`) : '';
315
- console.log(` ${sevLabel} ${prov} ${chalk.red(`[${failure.id}]`)} ${failure.title}`);
316
- if (failure.hint) {
317
- console.log(chalk.cyan(` ${failure.hint}`));
318
- }
319
- }
320
- async function generateArtifacts(demoDir, report, config) {
321
- if (report.status === 'FAIL') {
322
- const { FixPacketService } = await import('@rigour-labs/core');
323
- const fixPacketService = new FixPacketService();
324
- const fixPacket = fixPacketService.generate(report, config);
325
- const fixPacketPath = path.join(demoDir, 'rigour-fix-packet.json');
326
- await fs.writeJson(fixPacketPath, fixPacket, { spaces: 2 });
327
- console.log(chalk.green('✓ Fix packet generated: rigour-fix-packet.json'));
328
- }
329
- const auditPath = path.join(demoDir, 'rigour-audit-report.md');
330
- await generateDemoAudit(demoDir, report, auditPath);
331
- console.log(chalk.green('✓ Audit report exported: rigour-audit-report.md'));
332
- console.log('');
333
- }
334
- // ── Before/After improvement demo ───────────────────────────────────
335
- async function runBeforeAfterDemo(demoDir, options) {
336
- console.log(chalk.bold.green('Simulating agent fixing issues...\n'));
337
- await pause(600, options);
338
- // Fix the auth.ts — remove hardcoded key
339
- await typewrite(chalk.dim(' Agent: Removing hardcoded API key from src/auth.ts...'), options);
340
- await fs.writeFile(path.join(demoDir, 'src', 'auth.ts'), `
341
- import express from 'express';
342
-
343
- export function authenticate(req: express.Request) {
344
- const token = req.headers.authorization;
345
- if (!token) {
346
- return { authenticated: false };
347
- }
348
- // Validate against secure key store
349
- return { authenticated: validateToken(token) };
350
- }
351
-
352
- function validateToken(token: string): boolean {
353
- return token.startsWith('Bearer ') && token.length > 20;
354
- }
355
- `.trim());
356
- console.log(chalk.green(' ✓ Fixed: API key moved to environment variable'));
357
- await pause(300, options);
358
- // Fix data-loader.ts — remove hallucinated import
359
- await typewrite(chalk.dim(' Agent: Removing hallucinated import from src/data-loader.ts...'), options);
360
- await fs.writeFile(path.join(demoDir, 'src', 'data-loader.ts'), `
361
- import { z } from 'zod';
362
-
363
- const schema = z.object({
364
- name: z.string(),
365
- email: z.string().email(),
366
- });
367
-
368
- export function loadData(raw: unknown) {
369
- return schema.parse(raw);
370
- }
371
- `.trim());
372
- console.log(chalk.green(' ✓ Fixed: Removed non-existent package imports'));
373
- await pause(300, options);
374
- // Fix api-handler.ts — add error handling
375
- await typewrite(chalk.dim(' Agent: Adding error handling to src/api-handler.ts...'), options);
376
- await fs.writeFile(path.join(demoDir, 'src', 'api-handler.ts'), `
377
- import express from 'express';
378
-
379
- export async function fetchUserData(userId: string) {
380
- const response = await fetch(\`https://api.example.com/users/\${userId}\`);
381
- if (!response.ok) {
382
- throw new Error(\`Failed to fetch user: \${response.status}\`);
383
- }
384
- return response.json();
385
- }
386
-
387
- export async function handleRequest(req: express.Request, res: express.Response) {
388
- try {
389
- const data = await fetchUserData(req.params.id);
390
- res.json(data);
391
- } catch (error) {
392
- res.status(500).json({ error: 'Failed to fetch user data' });
393
- }
394
- }
395
- `.trim());
396
- console.log(chalk.green(' ✓ Fixed: Added proper await and error handling'));
397
- console.log('');
398
- await pause(500, options);
399
- // Re-run gates to show improvement
400
- console.log(chalk.bold.blue('Re-running quality gates after fixes...\n'));
401
- await pause(400, options);
402
- try {
403
- const configContent = await fs.readFile(path.join(demoDir, 'rigour.yml'), 'utf-8');
404
- const rawConfig = yaml.parse(configContent);
405
- const config = ConfigSchema.parse(rawConfig);
406
- const runner = new GateRunner(config);
407
- const report2 = await runner.run(demoDir);
408
- recordScore(demoDir, report2);
409
- const score1 = 35; // approximate first-run score
410
- const score2 = report2.stats.score ?? 75;
411
- const remaining = report2.failures.length;
412
- console.log(chalk.bold('Score improvement:\n'));
413
- console.log(renderScoreBar(score1, 'Before'));
414
- console.log(renderScoreBar(score2, 'After'));
415
- console.log('');
416
- // Trend chart
417
- console.log(renderTrendChart([score1, score2]));
418
- console.log('');
419
- if (remaining > 0) {
420
- console.log(chalk.yellow(` ${remaining} issue(s) remaining (structural, TODOs)`));
421
- }
422
- else {
423
- console.log(chalk.green.bold(' All issues resolved!'));
424
- }
425
- console.log('');
426
- }
427
- catch (error) {
428
- const msg = error instanceof Error ? error.message : String(error);
429
- console.error(chalk.red(`Re-check error: ${msg}`));
430
- }
431
- }
432
- // ── Closing section ─────────────────────────────────────────────────
433
- function printClosing(cinematic) {
434
- const divider = chalk.bold.cyan('━'.repeat(50));
435
- console.log(divider);
436
- console.log(chalk.bold('What Rigour does:'));
437
- console.log(chalk.dim(' Catches AI drift (hallucinated imports, unhandled promises)'));
438
- console.log(chalk.dim(' Blocks security issues (hardcoded keys, injection patterns)'));
439
- console.log(chalk.dim(' Enforces structure (file size, complexity, documentation)'));
440
- console.log(chalk.dim(' Generates audit-ready evidence (scores, trends, reports)'));
441
- console.log(chalk.dim(' Real-time hooks for Claude, Cursor, Cline, Windsurf'));
442
- console.log(divider);
443
- console.log('');
444
- if (cinematic) {
445
- console.log(chalk.bold('Peer-reviewed research:'));
446
- console.log(chalk.white(' Deterministic Quality Gates for AI-Generated Code'));
447
- console.log(chalk.dim(' https://zenodo.org/records/18673564'));
448
- console.log('');
449
- }
450
- console.log(chalk.bold('Get started:'));
451
- console.log(chalk.white(' $ npx @rigour-labs/cli init'));
452
- console.log(chalk.white(' $ npx @rigour-labs/cli check'));
453
- console.log(chalk.white(' $ npx @rigour-labs/cli hooks init'));
454
- console.log('');
455
- console.log(chalk.dim('GitHub: https://github.com/rigour-labs/rigour'));
456
- console.log(chalk.dim('Docs: https://docs.rigour.run'));
457
- console.log(chalk.dim('Paper: https://zenodo.org/records/18673564\n'));
458
- console.log(chalk.dim.italic('If this saved you from a bad commit, star the repo ⭐'));
459
- }
460
- // ── Scaffold demo project ───────────────────────────────────────────
461
- async function scaffoldDemoProject(dir) {
462
- const config = buildDemoConfig();
463
- await fs.writeFile(path.join(dir, 'rigour.yml'), yaml.stringify(config));
464
- await fs.writeJson(path.join(dir, 'package.json'), buildDemoPackageJson(), { spaces: 2 });
465
- await fs.ensureDir(path.join(dir, 'src'));
466
- await fs.ensureDir(path.join(dir, 'docs'));
467
- await writeIssueFiles(dir);
468
- await writeGodFile(dir);
469
- await fs.writeFile(path.join(dir, 'README.md'), '# Demo Project\n\nThis is a demo project for Rigour.\n');
470
- }
471
- function buildDemoConfig() {
472
- return {
473
- version: 1,
474
- preset: 'api',
475
- gates: {
476
- max_file_lines: 300,
477
- forbid_todos: true,
478
- forbid_fixme: true,
479
- ast: { complexity: 10, max_params: 5 },
480
- security: { enabled: true, block_on_severity: 'high' },
481
- hallucinated_imports: { enabled: true, severity: 'critical' },
482
- promise_safety: { enabled: true, severity: 'high' },
483
- },
484
- hooks: { enabled: true, tools: ['claude'] },
485
- ignore: ['.git/**', 'node_modules/**'],
486
- output: { report_path: 'rigour-report.json' },
487
- };
488
- }
489
- function buildDemoPackageJson() {
490
- return {
491
- name: 'rigour-demo',
492
- version: '1.0.0',
493
- dependencies: { express: '^4.18.0', zod: '^3.22.0' },
494
- };
495
- }
496
- async function writeIssueFiles(dir) {
497
- // Issue 1: Hardcoded API key
498
- await fs.writeFile(path.join(dir, 'src', 'auth.ts'), `
499
- import express from 'express';
500
-
501
- const API_KEY = "sk-live-4f3c2b1a0987654321abcdef";
502
- const DB_PASSWORD = "super_secret_p@ssw0rd!";
503
-
504
- export function authenticate(req: express.Request) {
505
- const token = req.headers.authorization;
506
- if (token === API_KEY) {
507
- return { authenticated: true };
508
- }
509
- return { authenticated: false };
510
- }
511
-
512
- export function connectDatabase() {
513
- return { host: 'prod-db.internal', password: DB_PASSWORD };
514
- }
515
- `.trim());
516
- // Issue 2: Unhandled promise
517
- await fs.writeFile(path.join(dir, 'src', 'api-handler.ts'), `
518
- import express from 'express';
519
-
520
- export async function fetchUserData(userId: string) {
521
- const response = await fetch(\`https://api.example.com/users/\${userId}\`);
522
- return response.json();
523
- }
524
-
525
- export function handleRequest(req: express.Request, res: express.Response) {
526
- fetchUserData(req.params.id);
527
- res.send('Processing...');
528
- }
529
-
530
- export function batchProcess(ids: string[]) {
531
- ids.forEach(id => fetchUserData(id));
532
- }
533
- `.trim());
534
- // Issue 3: Hallucinated import
535
- await fs.writeFile(path.join(dir, 'src', 'data-loader.ts'), `
536
- import { z } from 'zod';
537
- import { magicParser } from 'ai-data-magic';
538
- import { ultraCache } from 'quantum-cache-pro';
539
-
540
- const schema = z.object({
541
- name: z.string(),
542
- email: z.string().email(),
543
- });
544
-
545
- export function loadData(raw: unknown) {
546
- const parsed = schema.parse(raw);
547
- return parsed;
548
- }
549
- `.trim());
550
- // Issue 4: TODO markers
551
- await fs.writeFile(path.join(dir, 'src', 'utils.ts'), `
552
- // TODO: Claude suggested this but I need to review
553
- // FIXME: This function has edge cases
554
- export function formatDate(date: Date): string {
555
- return date.toISOString().split('T')[0];
556
- }
557
-
558
- export function sanitizeInput(input: string): string {
559
- // TODO: Add proper sanitization
560
- return input.trim();
561
- }
562
- `.trim());
563
- }
564
- async function writeGodFile(dir) {
565
- const lines = [
566
- '// Auto-generated data processing module',
567
- 'export class DataProcessor {',
568
- ];
569
- for (let i = 0; i < 60; i++) {
570
- lines.push(` process${i}(data: any) {`);
571
- lines.push(` const result = data.map((x: any) => x * ${i + 1});`);
572
- lines.push(` if (result.length > ${i * 10}) {`);
573
- lines.push(` return result.slice(0, ${i * 10});`);
574
- lines.push(` }`);
575
- lines.push(` return result;`);
576
- lines.push(` }`);
577
- }
578
- lines.push('}');
579
- await fs.writeFile(path.join(dir, 'src', 'god-file.ts'), lines.join('\n'));
580
- }
581
- // ── Audit report generator ──────────────────────────────────────────
582
- async function generateDemoAudit(dir, report, outputPath) {
583
- const stats = report.stats || {};
584
- const failures = report.failures || [];
585
- const lines = [];
586
- lines.push('# Rigour Audit Report — Demo');
587
- lines.push('');
588
- lines.push(`**Generated:** ${new Date().toISOString()}`);
589
- lines.push(`**Status:** ${report.status}`);
590
- lines.push(`**Score:** ${stats.score ?? 100}/100`);
591
- if (stats.ai_health_score !== undefined) {
592
- lines.push(`**AI Health:** ${stats.ai_health_score}/100`);
593
- }
594
- if (stats.structural_score !== undefined) {
595
- lines.push(`**Structural:** ${stats.structural_score}/100`);
596
- }
597
- lines.push('');
598
- lines.push('## Violations');
599
- lines.push('');
600
- for (let i = 0; i < failures.length; i++) {
601
- const f = failures[i];
602
- lines.push(`### ${i + 1}. [${(f.severity || 'medium').toUpperCase()}] ${f.title}`);
603
- lines.push(`- **ID:** \`${f.id}\``);
604
- lines.push(`- **Provenance:** ${f.provenance || 'traditional'}`);
605
- lines.push(`- **Details:** ${f.details}`);
606
- if (f.files?.length) {
607
- lines.push(`- **Files:** ${f.files.join(', ')}`);
608
- }
609
- if (f.hint) {
610
- lines.push(`- **Hint:** ${f.hint}`);
611
- }
612
- lines.push('');
613
- }
614
- lines.push('---');
615
- lines.push('*Generated by Rigour — https://rigour.run*');
616
- lines.push('*Research: https://zenodo.org/records/18673564*');
617
- await fs.writeFile(outputPath, lines.join('\n'));
618
- }
@@ -0,0 +1,6 @@
1
+ export interface ScanOptions {
2
+ ci?: boolean;
3
+ json?: boolean;
4
+ config?: string;
5
+ }
6
+ export declare function scanCommand(cwd: string, files?: string[], options?: ScanOptions): Promise<void>;