@rigour-labs/cli 2.5.1 → 2.7.0

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
@@ -30,12 +30,15 @@ program
30
30
  .description('Initialize Rigour in the current directory')
31
31
  .option('-p, --preset <name>', 'Project preset (ui, api, infra, data)')
32
32
  .option('--paradigm <name>', 'Coding paradigm (oop, functional, minimal)')
33
+ .option('--ide <name>', 'Target IDE (cursor, vscode, all). Auto-detects if not specified.')
33
34
  .option('--dry-run', 'Show detected configuration without writing files')
34
35
  .option('--explain', 'Show detection markers for roles and paradigms')
35
36
  .addHelpText('after', `
36
37
  Examples:
37
38
  $ rigour init # Auto-discover role & paradigm
38
39
  $ rigour init --preset api --explain # Force API role and show why
40
+ $ rigour init --ide vscode # Only create VS Code compatible files
41
+ $ rigour init --ide all # Create files for all IDEs
39
42
  `)
40
43
  .action(async (options) => {
41
44
  await (0, init_js_1.initCommand)(process.cwd(), options);
@@ -1,3 +1,3 @@
1
1
  export declare const CODE_QUALITY_RULES = "\n# Code Quality Standards\n\n## PRODUCTION-GRADE CODE ONLY\n- No debug logging in production code\n- No shortcuts or \"temporary\" fixes\n- No over-engineering - simplest solution that works\n- Follow existing code patterns and conventions\n- Handle edge cases properly\n- No TODO/FIXME comments in final code\n\n## MODULAR CODE STRUCTURE\n- Write SMALL, focused functions (< 50 lines ideally)\n- One function = one job, clearly named\n- New features go in SEPARATE FILES, not flooding existing ones\n- Keep files under 500 lines - split if growing larger\n- Extract reusable logic into utility modules\n- Avoid \"god files\" that do everything\n- When adding to existing code, check if a new module is more appropriate\n\n## Technical Standards\n\n### DRY Principle\n- Extract repeated logic into utilities\n- Single Responsibility: One function, one job\n- Defensive coding: Validate inputs at boundaries\n- Lazy initialization for external dependencies (secrets, connections)\n- Graceful degradation over hard failures\n\n### File Organization\n```\n# Good: Separate concerns into focused files\ngovernor/\n main.py # Entry point only\n drift_detector.py # Drift detection logic\n lip_sync_analyzer.py # SyncNet integration\n audio_analyzer.py # Audio analysis\n\n# Bad: One massive file with everything\ngovernor/\n main.py (2000+ lines with all logic mixed)\n```\n\n### API Design\n- Consistent error responses\n- Proper HTTP status codes\n- Authentication at the edge\n- Rate limiting on public endpoints\n\n## PRODUCTION-READY SELF-REVIEW (THE GATEKEEPER)\n\nBefore asking for \"approval,\" internally verify:\n\n- **Zero-Dependency Check**: Does this fix rely on a local environment variable not yet in `talentlyt-kv`?\n- **Side-Effect Audit**: Could this change trigger a 502 Bad Gateway at the `/auth/callback` or `/api/agent` endpoints?\n- **Biometric Integrity**: If touching the `Governor`, have I verified that the `similarity_score` logic remains deterministic?\n- **Cost Impact**: Does this change increase egress costs (e.g., unnecessary cross-region logging)?\n- **Error Handling**: Does the UI have a graceful fallback if the backend service is slow?\n";
2
2
  export declare const DEBUGGING_RULES = "\n# Investigation & Debugging Protocol\n\n## INVESTIGATION PROTOCOL\n\nWhen debugging:\n1. Check DEPLOYED environment (Azure, prod), not localhost unless explicitly asked\n2. Trace the actual request flow end-to-end\n3. Collect evidence at each step\n4. Present findings before proposing fixes\n\n## GAP ANALYSIS\n\nWhen debugging or proposing changes:\n\n1. **Trace the actual request flow** end-to-end:\n - Client \u2192 Cloudflare \u2192 Vercel/Container App \u2192 DB\n\n2. **Identify Hidden Gaps** - Explicitly check if the change affects:\n - **Cross-Region Handshakes**: Will this increase latency for users in Pakistan/India?\n - **Forensic Continuity**: Does this change how Maya captures gaze or audio data?\n - **Auth Persistence**: Will this interfere with WorkOS session tokens or M2M keys?\n\n3. **Evidence-First**: Collect logs from `talentlyt-dashboard` before proposing a fix.\n\n## Request Flow Tracing\n\n```\nClient Browser\n \u2193\nCloudflare (CDN/WAF)\n \u2193\nAzure Container Apps\n \u251C\u2500\u2500 talentlyt-dashboard (Next.js)\n \u2514\u2500\u2500 talentlyt-agent (Python/LiveKit)\n \u2193\nPostgreSQL Database\n \u2193\nAzure Blob Storage (recordings, evidence)\n```\n\n## Evidence Collection\n\nBefore proposing any fix:\n1. Get the actual error from logs (not assumed)\n2. Identify the exact file and line number\n3. Trace the data flow that led to the error\n4. Verify the fix doesn't break other paths\n";
3
- export declare const COLLABORATION_RULES = "\n# Role & Collaboration\n\nYou are a Senior Staff Engineer working alongside a Principal Engineer (the user). \nYou do NOT work autonomously - you work collaboratively with approval at each step.\n\n## 1. NO ASSUMPTIONS\n- Never assume root cause without evidence from logs/code\n- Never assume a fix works without verification\n- Always trace the ACTUAL flow, not the expected flow\n- When debugging, read the DEPLOYED code, not local code\n\n## 2. APPROVAL REQUIRED\nBefore making ANY code change, you MUST:\n1. Show the evidence (logs, code trace) proving the issue\n2. Explain the root cause with proof\n3. Propose the fix with rationale\n4. Wait for explicit approval: \"approved\", \"go ahead\", \"do it\"\n\nException: Only proceed without approval if user explicitly says \"just do it\" or \"fix it\"\n\n## 3. NEVER LOSE TRACK\n- Maintain TODO list for multi-step tasks\n- Complete current task before starting new ones\n- If interrupted, summarize current state before switching\n- Reference previous findings, don't repeat investigations\n\n## Communication\n\n### When Reporting Issues\n```\n**Evidence:** [actual log/error message]\n**Location:** [file:line or endpoint]\n**Root Cause:** [proven, not assumed]\n**Privacy Impact:** [Does this affect biometric/PII data?]\n**Fix:** [proposed solution]\n```\n\n### When Asking for Approval\n```\nI found: [evidence]\nRoot cause: [explanation]\nProposed fix: [code change summary]\n\nApprove to proceed?\n```\n\n### When Stuck\n- Say \"I need more information\" not guess\n- Ask specific questions\n- Propose diagnostic steps\n\n## Forbidden Actions\n\n1. \u274C Making code changes without showing evidence first\n2. \u274C Testing on localhost when asked to check production\n3. \u274C Adding debug logs as a \"fix\"\n4. \u274C Multiple deployment attempts hoping it works\n5. \u274C Over-engineering simple solutions\n6. \u274C Assuming secrets/env vars are available at init time\n7. \u274C Ignoring user corrections\n8. \u274C Losing context between messages\n";
3
+ export declare const COLLABORATION_RULES = "\n# Role & Collaboration\n\nYou are a Senior Staff Engineer working alongside a Principal Engineer (the user). \nYou do NOT work autonomously - you work collaboratively with approval at each step.\n\n## 1. NO ASSUMPTIONS\n- Never assume root cause without evidence from logs/code\n- Never assume a fix works without verification\n- Always trace the ACTUAL flow, not the expected flow\n- When debugging, read the DEPLOYED code, not local code\n\n## 2. APPROVAL REQUIRED\nBefore making ANY code change, you MUST:\n1. Show the evidence (logs, code trace) proving the issue\n2. Explain the root cause with proof\n3. Propose the fix with rationale\n4. Wait for explicit approval: \"approved\", \"go ahead\", \"do it\"\n\nException: Only proceed without approval if user explicitly says \"just do it\" or \"fix it\"\n\n## 3. NEVER LOSE TRACK\n- Maintain TODO list for multi-step tasks\n- Complete current task before starting new ones\n- If interrupted, summarize current state before switching\n- Reference previous findings, don't repeat investigations\n\n## Communication\n\n### When Reporting Issues\n```\n**Evidence:** [actual log/error message]\n**Location:** [file:line or endpoint]\n**Root Cause:** [proven, not assumed]\n**Privacy Impact:** [Does this affect biometric/PII data?]\n**Fix:** [proposed solution]\n```\n\n### When Asking for Approval\n```\nI found: [evidence]\nRoot cause: [explanation]\nProposed fix: [code change summary]\n\nApprove to proceed?\n```\n\n### When Stuck\n- Say \"I need more information\" not guess\n- Ask specific questions\n- Propose diagnostic steps\n\n## \u26A0\uFE0F RIGOUR.YML IS SACRED\n\nThe `rigour.yml` file represents **team-agreed quality standards**. You are FORBIDDEN from:\n\n1. \u274C Increasing thresholds to pass checks (e.g., raising `complexity: 100`)\n2. \u274C Adding patterns to `ignore:` to skip problematic files\n3. \u274C Removing items from `required_files`\n4. \u274C Disabling gates to avoid failures\n\n**Your job is to FIX THE CODE to meet the standards, NOT weaken the standards to pass the check.**\n\nIf thresholds genuinely need adjustment, escalate to the team lead with justification.\n\n## Forbidden Actions\n\n1. \u274C Making code changes without showing evidence first\n2. \u274C Testing on localhost when asked to check production\n3. \u274C Adding debug logs as a \"fix\"\n4. \u274C Multiple deployment attempts hoping it works\n5. \u274C Over-engineering simple solutions\n6. \u274C Assuming secrets/env vars are available at init time\n7. \u274C Ignoring user corrections\n8. \u274C Losing context between messages\n9. \u274C Modifying rigour.yml to pass quality checks\n";
@@ -161,6 +161,19 @@ Approve to proceed?
161
161
  - Ask specific questions
162
162
  - Propose diagnostic steps
163
163
 
164
+ ## ⚠️ RIGOUR.YML IS SACRED
165
+
166
+ The \`rigour.yml\` file represents **team-agreed quality standards**. You are FORBIDDEN from:
167
+
168
+ 1. ❌ Increasing thresholds to pass checks (e.g., raising \`complexity: 100\`)
169
+ 2. ❌ Adding patterns to \`ignore:\` to skip problematic files
170
+ 3. ❌ Removing items from \`required_files\`
171
+ 4. ❌ Disabling gates to avoid failures
172
+
173
+ **Your job is to FIX THE CODE to meet the standards, NOT weaken the standards to pass the check.**
174
+
175
+ If thresholds genuinely need adjustment, escalate to the team lead with justification.
176
+
164
177
  ## Forbidden Actions
165
178
 
166
179
  1. ❌ Making code changes without showing evidence first
@@ -171,4 +184,5 @@ Approve to proceed?
171
184
  6. ❌ Assuming secrets/env vars are available at init time
172
185
  7. ❌ Ignoring user corrections
173
186
  8. ❌ Losing context between messages
187
+ 9. ❌ Modifying rigour.yml to pass quality checks
174
188
  `;
@@ -1,6 +1,7 @@
1
1
  export interface InitOptions {
2
2
  preset?: string;
3
3
  paradigm?: string;
4
+ ide?: 'cursor' | 'vscode' | 'all';
4
5
  dryRun?: boolean;
5
6
  explain?: boolean;
6
7
  }
@@ -10,6 +10,26 @@ const chalk_1 = __importDefault(require("chalk"));
10
10
  const yaml_1 = __importDefault(require("yaml"));
11
11
  const core_1 = require("@rigour-labs/core");
12
12
  const constants_js_1 = require("./constants.js");
13
+ function detectIDE(cwd) {
14
+ // Check for Cursor-specific markers
15
+ if (fs_extra_1.default.existsSync(path_1.default.join(cwd, '.cursor'))) {
16
+ return 'cursor';
17
+ }
18
+ // Check for VS Code markers
19
+ if (fs_extra_1.default.existsSync(path_1.default.join(cwd, '.vscode'))) {
20
+ return 'vscode';
21
+ }
22
+ // Check environment variables that IDEs set
23
+ const termProgram = process.env.TERM_PROGRAM || '';
24
+ const terminal = process.env.TERMINAL_EMULATOR || '';
25
+ if (termProgram.toLowerCase().includes('cursor') || terminal.toLowerCase().includes('cursor')) {
26
+ return 'cursor';
27
+ }
28
+ if (termProgram.toLowerCase().includes('vscode') || process.env.VSCODE_INJECTION) {
29
+ return 'vscode';
30
+ }
31
+ return 'unknown';
32
+ }
13
33
  async function initCommand(cwd, options = {}) {
14
34
  const discovery = new core_1.DiscoveryService();
15
35
  const result = await discovery.discover(cwd);
@@ -74,7 +94,13 @@ async function initCommand(cwd, options = {}) {
74
94
  console.log(chalk_1.default.cyan(` Paradigm: `) + chalk_1.default.bold(recommendedConfig.paradigm.toUpperCase()));
75
95
  }
76
96
  console.log('');
77
- await fs_extra_1.default.writeFile(configPath, yaml_1.default.stringify(recommendedConfig));
97
+ const yamlHeader = `# ⚠️ TEAM STANDARD - DO NOT MODIFY WITHOUT TEAM APPROVAL
98
+ # AI Assistants: Adjust YOUR code to meet these standards, not the other way around.
99
+ # Modifying thresholds or adding ignores to pass checks defeats the purpose of Rigour.
100
+ # See: docs/AGENT_INSTRUCTIONS.md for the correct workflow.
101
+
102
+ `;
103
+ await fs_extra_1.default.writeFile(configPath, yamlHeader + yaml_1.default.stringify(recommendedConfig));
78
104
  console.log(chalk_1.default.green('✔ Created rigour.yml'));
79
105
  // Create required directories and files
80
106
  const requireddocs = recommendedConfig.gates.required_files || [];
@@ -121,19 +147,30 @@ ${constants_js_1.COLLABORATION_RULES}
121
147
  await fs_extra_1.default.writeFile(instructionsPath, ruleContent);
122
148
  console.log(chalk_1.default.green('✔ Initialized Universal Agent Handshake (docs/AGENT_INSTRUCTIONS.md)'));
123
149
  }
124
- // 2. Create Cursor Specific Rules (.mdc)
125
- const cursorRulesDir = path_1.default.join(cwd, '.cursor', 'rules');
126
- await fs_extra_1.default.ensureDir(cursorRulesDir);
127
- const mdcPath = path_1.default.join(cursorRulesDir, 'rigour.mdc');
128
- const mdcContent = `---
150
+ // 2. Create IDE-Specific Rules based on detection or user preference
151
+ const detectedIDE = detectIDE(cwd);
152
+ const targetIDE = options.ide || (detectedIDE !== 'unknown' ? detectedIDE : 'all');
153
+ if (detectedIDE !== 'unknown' && !options.ide) {
154
+ console.log(chalk_1.default.dim(` (Auto-detected IDE: ${detectedIDE})`));
155
+ }
156
+ if (targetIDE === 'cursor' || targetIDE === 'all') {
157
+ const cursorRulesDir = path_1.default.join(cwd, '.cursor', 'rules');
158
+ await fs_extra_1.default.ensureDir(cursorRulesDir);
159
+ const mdcPath = path_1.default.join(cursorRulesDir, 'rigour.mdc');
160
+ const mdcContent = `---
129
161
  description: Enforcement of Rigour quality gates and best practices.
130
162
  globs: **/*
131
163
  ---
132
164
 
133
165
  ${ruleContent}`;
134
- if (!(await fs_extra_1.default.pathExists(mdcPath))) {
135
- await fs_extra_1.default.writeFile(mdcPath, mdcContent);
136
- console.log(chalk_1.default.green('✔ Initialized Cursor Handshake (.cursor/rules/rigour.mdc)'));
166
+ if (!(await fs_extra_1.default.pathExists(mdcPath))) {
167
+ await fs_extra_1.default.writeFile(mdcPath, mdcContent);
168
+ console.log(chalk_1.default.green('✔ Initialized Cursor Handshake (.cursor/rules/rigour.mdc)'));
169
+ }
170
+ }
171
+ if (targetIDE === 'vscode') {
172
+ // VS Code users use the universal AGENT_INSTRUCTIONS.md (already created above)
173
+ console.log(chalk_1.default.green('✔ VS Code mode - using Universal Handshake (docs/AGENT_INSTRUCTIONS.md)'));
137
174
  }
138
175
  // 3. Update .gitignore
139
176
  const gitignorePath = path_1.default.join(cwd, '.gitignore');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rigour-labs/cli",
3
- "version": "2.5.1",
3
+ "version": "2.7.0",
4
4
  "bin": {
5
5
  "rigour": "dist/cli.js"
6
6
  },
@@ -21,7 +21,7 @@
21
21
  "globby": "^14.0.1",
22
22
  "inquirer": "9.2.16",
23
23
  "yaml": "^2.8.2",
24
- "@rigour-labs/core": "2.5.1"
24
+ "@rigour-labs/core": "2.7.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/fs-extra": "^11.0.4",
package/src/cli.ts CHANGED
@@ -28,12 +28,15 @@ program
28
28
  .description('Initialize Rigour in the current directory')
29
29
  .option('-p, --preset <name>', 'Project preset (ui, api, infra, data)')
30
30
  .option('--paradigm <name>', 'Coding paradigm (oop, functional, minimal)')
31
+ .option('--ide <name>', 'Target IDE (cursor, vscode, all). Auto-detects if not specified.')
31
32
  .option('--dry-run', 'Show detected configuration without writing files')
32
33
  .option('--explain', 'Show detection markers for roles and paradigms')
33
34
  .addHelpText('after', `
34
35
  Examples:
35
36
  $ rigour init # Auto-discover role & paradigm
36
37
  $ rigour init --preset api --explain # Force API role and show why
38
+ $ rigour init --ide vscode # Only create VS Code compatible files
39
+ $ rigour init --ide all # Create files for all IDEs
37
40
  `)
38
41
  .action(async (options: any) => {
39
42
  await initCommand(process.cwd(), options);
@@ -160,6 +160,19 @@ Approve to proceed?
160
160
  - Ask specific questions
161
161
  - Propose diagnostic steps
162
162
 
163
+ ## ⚠️ RIGOUR.YML IS SACRED
164
+
165
+ The \`rigour.yml\` file represents **team-agreed quality standards**. You are FORBIDDEN from:
166
+
167
+ 1. ❌ Increasing thresholds to pass checks (e.g., raising \`complexity: 100\`)
168
+ 2. ❌ Adding patterns to \`ignore:\` to skip problematic files
169
+ 3. ❌ Removing items from \`required_files\`
170
+ 4. ❌ Disabling gates to avoid failures
171
+
172
+ **Your job is to FIX THE CODE to meet the standards, NOT weaken the standards to pass the check.**
173
+
174
+ If thresholds genuinely need adjustment, escalate to the team lead with justification.
175
+
163
176
  ## Forbidden Actions
164
177
 
165
178
  1. ❌ Making code changes without showing evidence first
@@ -170,4 +183,5 @@ Approve to proceed?
170
183
  6. ❌ Assuming secrets/env vars are available at init time
171
184
  7. ❌ Ignoring user corrections
172
185
  8. ❌ Losing context between messages
186
+ 9. ❌ Modifying rigour.yml to pass quality checks
173
187
  `;
@@ -8,10 +8,39 @@ import { CODE_QUALITY_RULES, DEBUGGING_RULES, COLLABORATION_RULES } from './cons
8
8
  export interface InitOptions {
9
9
  preset?: string;
10
10
  paradigm?: string;
11
+ ide?: 'cursor' | 'vscode' | 'all';
11
12
  dryRun?: boolean;
12
13
  explain?: boolean;
13
14
  }
14
15
 
16
+ type DetectedIDE = 'cursor' | 'vscode' | 'unknown';
17
+
18
+ function detectIDE(cwd: string): DetectedIDE {
19
+ // Check for Cursor-specific markers
20
+ if (fs.existsSync(path.join(cwd, '.cursor'))) {
21
+ return 'cursor';
22
+ }
23
+
24
+ // Check for VS Code markers
25
+ if (fs.existsSync(path.join(cwd, '.vscode'))) {
26
+ return 'vscode';
27
+ }
28
+
29
+ // Check environment variables that IDEs set
30
+ const termProgram = process.env.TERM_PROGRAM || '';
31
+ const terminal = process.env.TERMINAL_EMULATOR || '';
32
+
33
+ if (termProgram.toLowerCase().includes('cursor') || terminal.toLowerCase().includes('cursor')) {
34
+ return 'cursor';
35
+ }
36
+
37
+ if (termProgram.toLowerCase().includes('vscode') || process.env.VSCODE_INJECTION) {
38
+ return 'vscode';
39
+ }
40
+
41
+ return 'unknown';
42
+ }
43
+
15
44
  export async function initCommand(cwd: string, options: InitOptions = {}) {
16
45
  const discovery = new DiscoveryService();
17
46
  const result = await discovery.discover(cwd);
@@ -78,7 +107,13 @@ export async function initCommand(cwd: string, options: InitOptions = {}) {
78
107
  }
79
108
  console.log('');
80
109
 
81
- await fs.writeFile(configPath, yaml.stringify(recommendedConfig));
110
+ const yamlHeader = `# ⚠️ TEAM STANDARD - DO NOT MODIFY WITHOUT TEAM APPROVAL
111
+ # AI Assistants: Adjust YOUR code to meet these standards, not the other way around.
112
+ # Modifying thresholds or adding ignores to pass checks defeats the purpose of Rigour.
113
+ # See: docs/AGENT_INSTRUCTIONS.md for the correct workflow.
114
+
115
+ `;
116
+ await fs.writeFile(configPath, yamlHeader + yaml.stringify(recommendedConfig));
82
117
  console.log(chalk.green('✔ Created rigour.yml'));
83
118
 
84
119
  // Create required directories and files
@@ -130,20 +165,34 @@ ${COLLABORATION_RULES}
130
165
  console.log(chalk.green('✔ Initialized Universal Agent Handshake (docs/AGENT_INSTRUCTIONS.md)'));
131
166
  }
132
167
 
133
- // 2. Create Cursor Specific Rules (.mdc)
134
- const cursorRulesDir = path.join(cwd, '.cursor', 'rules');
135
- await fs.ensureDir(cursorRulesDir);
136
- const mdcPath = path.join(cursorRulesDir, 'rigour.mdc');
137
- const mdcContent = `---
168
+ // 2. Create IDE-Specific Rules based on detection or user preference
169
+ const detectedIDE = detectIDE(cwd);
170
+ const targetIDE = options.ide || (detectedIDE !== 'unknown' ? detectedIDE : 'all');
171
+
172
+ if (detectedIDE !== 'unknown' && !options.ide) {
173
+ console.log(chalk.dim(` (Auto-detected IDE: ${detectedIDE})`));
174
+ }
175
+
176
+ if (targetIDE === 'cursor' || targetIDE === 'all') {
177
+ const cursorRulesDir = path.join(cwd, '.cursor', 'rules');
178
+ await fs.ensureDir(cursorRulesDir);
179
+ const mdcPath = path.join(cursorRulesDir, 'rigour.mdc');
180
+ const mdcContent = `---
138
181
  description: Enforcement of Rigour quality gates and best practices.
139
182
  globs: **/*
140
183
  ---
141
184
 
142
185
  ${ruleContent}`;
143
186
 
144
- if (!(await fs.pathExists(mdcPath))) {
145
- await fs.writeFile(mdcPath, mdcContent);
146
- console.log(chalk.green('✔ Initialized Cursor Handshake (.cursor/rules/rigour.mdc)'));
187
+ if (!(await fs.pathExists(mdcPath))) {
188
+ await fs.writeFile(mdcPath, mdcContent);
189
+ console.log(chalk.green('✔ Initialized Cursor Handshake (.cursor/rules/rigour.mdc)'));
190
+ }
191
+ }
192
+
193
+ if (targetIDE === 'vscode') {
194
+ // VS Code users use the universal AGENT_INSTRUCTIONS.md (already created above)
195
+ console.log(chalk.green('✔ VS Code mode - using Universal Handshake (docs/AGENT_INSTRUCTIONS.md)'));
147
196
  }
148
197
 
149
198
  // 3. Update .gitignore