@rigour-labs/cli 4.2.3 → 4.3.1

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/cli.js CHANGED
@@ -14,6 +14,7 @@ import { demoCommand } from './commands/demo.js';
14
14
  import { hooksInitCommand, hooksCheckCommand } from './commands/hooks.js';
15
15
  import { settingsShowCommand, settingsSetKeyCommand, settingsRemoveKeyCommand, settingsSetCommand, settingsGetCommand, settingsResetCommand, settingsPathCommand } from './commands/settings.js';
16
16
  import { doctorCommand } from './commands/doctor.js';
17
+ import { brainCommand } from './commands/brain.js';
17
18
  import { checkForUpdates } from './utils/version.js';
18
19
  import { getCliVersion } from './utils/cli-version.js';
19
20
  import chalk from 'chalk';
@@ -21,6 +22,7 @@ const CLI_VERSION = getCliVersion();
21
22
  const program = new Command();
22
23
  program.addCommand(indexCommand);
23
24
  program.addCommand(studioCommand);
25
+ program.addCommand(brainCommand);
24
26
  program
25
27
  .name('rigour')
26
28
  .description('šŸ›”ļø Rigour: The Quality Gate Loop for AI-Assisted Engineering')
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare const brainCommand: Command;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Brain Command — inspect, compact, and reset the local project memory.
3
+ * Storage lives at ~/.rigour/rigour.db (SQLite, WAL mode).
4
+ */
5
+ import chalk from 'chalk';
6
+ import { Command } from 'commander';
7
+ export const brainCommand = new Command('brain')
8
+ .description('Manage Rigour Brain — local project memory (SQLite)')
9
+ .addHelpText('after', `
10
+ Examples:
11
+ $ rigour brain # Show memory status
12
+ $ rigour brain --compact # Prune old data, reclaim disk
13
+ $ rigour brain --compact --retain 30 # Keep only last 30 days
14
+ $ rigour brain --reset # Wipe all memory and start fresh
15
+ `)
16
+ .option('--compact', 'Prune old findings, weak patterns, and reclaim disk space')
17
+ .option('--retain <days>', 'Days of findings to keep during compact (default: 90)', '90')
18
+ .option('--reset', 'Delete the entire database and start fresh')
19
+ .action(async (options) => {
20
+ const core = await import('@rigour-labs/core');
21
+ if (options.reset) {
22
+ await handleReset(core);
23
+ return;
24
+ }
25
+ if (options.compact) {
26
+ await handleCompact(core, parseInt(options.retain, 10));
27
+ return;
28
+ }
29
+ await handleStatus(core);
30
+ });
31
+ /** Show brain status: DB size, scan count, patterns, hard rules. */
32
+ async function handleStatus(core) {
33
+ const sizeBytes = core.getDatabaseSize();
34
+ if (sizeBytes === 0) {
35
+ console.log(chalk.yellow('No Rigour Brain database found.'));
36
+ console.log(chalk.dim('Run `rigour scan` or `rigour check` to start building local memory.'));
37
+ return;
38
+ }
39
+ console.log(chalk.bold.cyan('\n🧠 Rigour Brain — Local Memory Status\n'));
40
+ console.log(chalk.dim(` Database: ~/.rigour/rigour.db`));
41
+ console.log(chalk.dim(` Size: ${formatBytes(sizeBytes)}\n`));
42
+ const cwd = process.cwd();
43
+ const stats = core.getProjectStats(cwd);
44
+ if (!stats) {
45
+ console.log(chalk.yellow(' SQLite not available (better-sqlite3 not installed).'));
46
+ console.log(chalk.dim(' Run: npm install better-sqlite3'));
47
+ return;
48
+ }
49
+ if (stats.totalScans === 0) {
50
+ console.log(chalk.dim(' No scans recorded for this project yet.'));
51
+ console.log(chalk.dim(' Run `rigour scan` to start learning.\n'));
52
+ return;
53
+ }
54
+ console.log(` Scans recorded: ${chalk.green(stats.totalScans)}`);
55
+ console.log(` Learned patterns: ${chalk.green(stats.learnedPatterns)}`);
56
+ console.log(` Hard rules (≄0.9): ${chalk.green(stats.hardRules)}`);
57
+ if (stats.topPatterns.length > 0) {
58
+ console.log(chalk.bold('\n Top Patterns:'));
59
+ for (const p of stats.topPatterns) {
60
+ const bar = strengthBar(p.strength);
61
+ console.log(` ${bar} ${p.name} ${chalk.dim(`(seen ${p.timesSeen}x)`)}`);
62
+ }
63
+ }
64
+ console.log('');
65
+ }
66
+ /** Compact: prune old findings, weak patterns, VACUUM. */
67
+ async function handleCompact(core, retainDays) {
68
+ console.log(chalk.bold.cyan(`\n🧠 Compacting Rigour Brain (retain ${retainDays} days)...\n`));
69
+ const result = core.compactDatabase(retainDays);
70
+ console.log(` Findings pruned: ${chalk.yellow(result.pruned)}`);
71
+ console.log(` Patterns removed: ${chalk.yellow(result.patternsDecayed)}`);
72
+ console.log(` Size before: ${formatBytes(result.sizeBefore)}`);
73
+ console.log(` Size after: ${chalk.green(formatBytes(result.sizeAfter))}`);
74
+ const saved = result.sizeBefore - result.sizeAfter;
75
+ if (saved > 0) {
76
+ console.log(` Space saved: ${chalk.green(formatBytes(saved))}`);
77
+ }
78
+ console.log('');
79
+ }
80
+ /** Reset: delete the entire database. */
81
+ async function handleReset(core) {
82
+ const sizeBytes = core.getDatabaseSize();
83
+ if (sizeBytes === 0) {
84
+ console.log(chalk.yellow('No Rigour Brain database found. Nothing to reset.'));
85
+ return;
86
+ }
87
+ console.log(chalk.bold.red(`\nāš ļø Resetting Rigour Brain`));
88
+ console.log(chalk.dim(` This will delete all scan history, patterns, and learned rules.`));
89
+ console.log(chalk.dim(` Database size: ${formatBytes(sizeBytes)}\n`));
90
+ core.resetDatabase();
91
+ console.log(chalk.green(' āœ“ Brain reset complete. All memory cleared.\n'));
92
+ }
93
+ /** Format bytes as human-readable string. */
94
+ function formatBytes(bytes) {
95
+ if (bytes === 0)
96
+ return '0 B';
97
+ const units = ['B', 'KB', 'MB', 'GB'];
98
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
99
+ return `${(bytes / Math.pow(1024, i)).toFixed(1)} ${units[i]}`;
100
+ }
101
+ /** Visual strength bar for patterns. */
102
+ function strengthBar(strength) {
103
+ const filled = Math.round(strength * 10);
104
+ const bar = 'ā–ˆ'.repeat(filled) + 'ā–‘'.repeat(10 - filled);
105
+ const color = strength >= 0.9 ? chalk.green : strength >= 0.7 ? chalk.yellow : chalk.dim;
106
+ return color(`[${bar}]`);
107
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rigour-labs/cli",
3
- "version": "4.2.3",
3
+ "version": "4.3.1",
4
4
  "description": "CLI quality gates for AI-generated code. Forces AI agents (Claude, Cursor, Copilot) to meet strict engineering standards with PASS/FAIL enforcement.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://rigour.run",
@@ -44,7 +44,7 @@
44
44
  "inquirer": "9.2.16",
45
45
  "ora": "^8.0.1",
46
46
  "yaml": "^2.8.2",
47
- "@rigour-labs/core": "4.2.3"
47
+ "@rigour-labs/core": "4.3.1"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/fs-extra": "^11.0.4",