@rigour-labs/cli 2.6.0 → 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,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);
@@ -127,19 +147,30 @@ ${constants_js_1.COLLABORATION_RULES}
127
147
  await fs_extra_1.default.writeFile(instructionsPath, ruleContent);
128
148
  console.log(chalk_1.default.green('✔ Initialized Universal Agent Handshake (docs/AGENT_INSTRUCTIONS.md)'));
129
149
  }
130
- // 2. Create Cursor Specific Rules (.mdc)
131
- const cursorRulesDir = path_1.default.join(cwd, '.cursor', 'rules');
132
- await fs_extra_1.default.ensureDir(cursorRulesDir);
133
- const mdcPath = path_1.default.join(cursorRulesDir, 'rigour.mdc');
134
- 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 = `---
135
161
  description: Enforcement of Rigour quality gates and best practices.
136
162
  globs: **/*
137
163
  ---
138
164
 
139
165
  ${ruleContent}`;
140
- if (!(await fs_extra_1.default.pathExists(mdcPath))) {
141
- await fs_extra_1.default.writeFile(mdcPath, mdcContent);
142
- 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)'));
143
174
  }
144
175
  // 3. Update .gitignore
145
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.6.0",
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.6.0"
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);
@@ -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);
@@ -136,20 +165,34 @@ ${COLLABORATION_RULES}
136
165
  console.log(chalk.green('✔ Initialized Universal Agent Handshake (docs/AGENT_INSTRUCTIONS.md)'));
137
166
  }
138
167
 
139
- // 2. Create Cursor Specific Rules (.mdc)
140
- const cursorRulesDir = path.join(cwd, '.cursor', 'rules');
141
- await fs.ensureDir(cursorRulesDir);
142
- const mdcPath = path.join(cursorRulesDir, 'rigour.mdc');
143
- 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 = `---
144
181
  description: Enforcement of Rigour quality gates and best practices.
145
182
  globs: **/*
146
183
  ---
147
184
 
148
185
  ${ruleContent}`;
149
186
 
150
- if (!(await fs.pathExists(mdcPath))) {
151
- await fs.writeFile(mdcPath, mdcContent);
152
- 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)'));
153
196
  }
154
197
 
155
198
  // 3. Update .gitignore