@vibecheckai/cli 3.0.2 → 3.0.3

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.
Files changed (68) hide show
  1. package/package.json +9 -1
  2. package/bin/cli-hygiene.js +0 -241
  3. package/bin/guardrail.js +0 -834
  4. package/bin/runners/cli-utils.js +0 -1070
  5. package/bin/runners/context/ai-task-decomposer.js +0 -337
  6. package/bin/runners/context/analyzer.js +0 -462
  7. package/bin/runners/context/api-contracts.js +0 -427
  8. package/bin/runners/context/context-diff.js +0 -342
  9. package/bin/runners/context/context-pruner.js +0 -291
  10. package/bin/runners/context/dependency-graph.js +0 -414
  11. package/bin/runners/context/generators/claude.js +0 -107
  12. package/bin/runners/context/generators/codex.js +0 -108
  13. package/bin/runners/context/generators/copilot.js +0 -119
  14. package/bin/runners/context/generators/cursor.js +0 -514
  15. package/bin/runners/context/generators/mcp.js +0 -151
  16. package/bin/runners/context/generators/windsurf.js +0 -180
  17. package/bin/runners/context/git-context.js +0 -302
  18. package/bin/runners/context/index.js +0 -1042
  19. package/bin/runners/context/insights.js +0 -173
  20. package/bin/runners/context/mcp-server/generate-rules.js +0 -337
  21. package/bin/runners/context/mcp-server/index.js +0 -1176
  22. package/bin/runners/context/mcp-server/package.json +0 -24
  23. package/bin/runners/context/memory.js +0 -200
  24. package/bin/runners/context/monorepo.js +0 -215
  25. package/bin/runners/context/multi-repo-federation.js +0 -404
  26. package/bin/runners/context/patterns.js +0 -253
  27. package/bin/runners/context/proof-context.js +0 -972
  28. package/bin/runners/context/security-scanner.js +0 -303
  29. package/bin/runners/context/semantic-search.js +0 -350
  30. package/bin/runners/context/shared.js +0 -264
  31. package/bin/runners/context/team-conventions.js +0 -310
  32. package/bin/runners/lib/ai-bridge.js +0 -416
  33. package/bin/runners/lib/analysis-core.js +0 -271
  34. package/bin/runners/lib/analyzers.js +0 -541
  35. package/bin/runners/lib/audit-bridge.js +0 -391
  36. package/bin/runners/lib/auth-truth.js +0 -193
  37. package/bin/runners/lib/auth.js +0 -215
  38. package/bin/runners/lib/backup.js +0 -62
  39. package/bin/runners/lib/billing.js +0 -107
  40. package/bin/runners/lib/claims.js +0 -118
  41. package/bin/runners/lib/cli-ui.js +0 -540
  42. package/bin/runners/lib/compliance-bridge-new.js +0 -0
  43. package/bin/runners/lib/compliance-bridge.js +0 -165
  44. package/bin/runners/lib/contracts/auth-contract.js +0 -194
  45. package/bin/runners/lib/contracts/env-contract.js +0 -178
  46. package/bin/runners/lib/contracts/external-contract.js +0 -198
  47. package/bin/runners/lib/contracts/guard.js +0 -168
  48. package/bin/runners/lib/contracts/index.js +0 -89
  49. package/bin/runners/lib/contracts/plan-validator.js +0 -311
  50. package/bin/runners/lib/contracts/route-contract.js +0 -192
  51. package/bin/runners/lib/detect.js +0 -89
  52. package/bin/runners/lib/doctor/autofix.js +0 -254
  53. package/bin/runners/lib/doctor/index.js +0 -37
  54. package/bin/runners/lib/doctor/modules/dependencies.js +0 -325
  55. package/bin/runners/lib/doctor/modules/index.js +0 -46
  56. package/bin/runners/lib/doctor/modules/network.js +0 -250
  57. package/bin/runners/lib/doctor/modules/project.js +0 -312
  58. package/bin/runners/lib/doctor/modules/runtime.js +0 -224
  59. package/bin/runners/lib/doctor/modules/security.js +0 -348
  60. package/bin/runners/lib/doctor/modules/system.js +0 -213
  61. package/bin/runners/lib/doctor/modules/vibecheck.js +0 -394
  62. package/bin/runners/lib/doctor/reporter.js +0 -262
  63. package/bin/runners/lib/doctor/service.js +0 -262
  64. package/bin/runners/lib/doctor/types.js +0 -113
  65. package/bin/runners/lib/doctor/ui.js +0 -263
  66. package/bin/runners/lib/doctor-enhanced.js +0 -233
  67. package/bin/runners/lib/doctor-v2.js +0 -608
  68. package/bin/runners/lib/enforcement.js +0 -72
@@ -1,348 +0,0 @@
1
- /**
2
- * Security Diagnostics Module
3
- *
4
- * Checks for exposed secrets, gitignore configuration, and security best practices
5
- */
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
- const { SEVERITY, CATEGORY, FIX_TYPE } = require('../types');
10
-
11
- const MODULE_ID = 'security';
12
-
13
- const SECRET_PATTERNS = [
14
- { name: 'Stripe Live Key', pattern: /sk_live_[a-zA-Z0-9]{20,}/, critical: true },
15
- { name: 'Stripe Test Key', pattern: /sk_test_[a-zA-Z0-9]{20,}/, critical: false },
16
- { name: 'AWS Access Key', pattern: /AKIA[0-9A-Z]{16}/, critical: true },
17
- { name: 'GitHub Token', pattern: /ghp_[a-zA-Z0-9]{36}/, critical: true },
18
- { name: 'GitHub OAuth', pattern: /gho_[a-zA-Z0-9]{36}/, critical: true },
19
- { name: 'Private Key', pattern: /-----BEGIN (RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----/, critical: true },
20
- { name: 'Generic API Key', pattern: /api[_-]?key['"]?\s*[:=]\s*['"][a-zA-Z0-9]{20,}['"]/, critical: false },
21
- { name: 'Generic Secret', pattern: /secret['"]?\s*[:=]\s*['"][a-zA-Z0-9]{20,}['"]/, critical: false },
22
- { name: 'Database URL', pattern: /postgres(ql)?:\/\/[^:]+:[^@]+@/, critical: true },
23
- { name: 'MongoDB URL', pattern: /mongodb(\+srv)?:\/\/[^:]+:[^@]+@/, critical: true },
24
- ];
25
-
26
- const REQUIRED_GITIGNORE = [
27
- { pattern: '.env', name: '.env files' },
28
- { pattern: 'node_modules', name: 'node_modules' },
29
- { pattern: '.vibecheck', name: '.vibecheck output' },
30
- ];
31
-
32
- function createDiagnostics(projectPath) {
33
- return [
34
- {
35
- id: `${MODULE_ID}.env_file`,
36
- name: '.env File',
37
- category: CATEGORY.SECURITY,
38
- parallel: true,
39
- check: async () => {
40
- const envPath = path.join(projectPath, '.env');
41
- const envExamplePath = path.join(projectPath, '.env.example');
42
- const envLocalPath = path.join(projectPath, '.env.local');
43
-
44
- const hasEnv = fs.existsSync(envPath);
45
- const hasEnvExample = fs.existsSync(envExamplePath);
46
- const hasEnvLocal = fs.existsSync(envLocalPath);
47
-
48
- const metadata = { hasEnv, hasEnvExample, hasEnvLocal };
49
-
50
- if (!hasEnv && !hasEnvLocal) {
51
- return {
52
- severity: SEVERITY.INFO,
53
- message: 'No .env file found',
54
- detail: 'Create .env for local environment variables',
55
- metadata,
56
- fixes: [{
57
- type: FIX_TYPE.FILE_CREATE,
58
- description: 'Create .env from example',
59
- path: envPath,
60
- content: hasEnvExample
61
- ? fs.readFileSync(envExamplePath, 'utf8')
62
- : '# Environment variables\n',
63
- autoFixable: true,
64
- }],
65
- };
66
- }
67
-
68
- if (hasEnv && !hasEnvExample) {
69
- return {
70
- severity: SEVERITY.WARNING,
71
- message: '.env exists but no .env.example',
72
- detail: 'Create .env.example for team documentation',
73
- metadata,
74
- fixes: [{
75
- type: FIX_TYPE.COMMAND,
76
- description: 'Generate .env.example from .env',
77
- command: 'vibecheck ctx --env-template',
78
- autoFixable: false,
79
- }],
80
- };
81
- }
82
-
83
- return {
84
- severity: SEVERITY.PASS,
85
- message: hasEnvExample ? '.env + .env.example' : '.env configured',
86
- metadata,
87
- };
88
- },
89
- },
90
- {
91
- id: `${MODULE_ID}.gitignore`,
92
- name: '.gitignore',
93
- category: CATEGORY.SECURITY,
94
- parallel: true,
95
- check: async () => {
96
- const gitignorePath = path.join(projectPath, '.gitignore');
97
-
98
- if (!fs.existsSync(gitignorePath)) {
99
- return {
100
- severity: SEVERITY.WARNING,
101
- message: 'No .gitignore file',
102
- detail: 'Secrets and build artifacts may be committed to git',
103
- fixes: [{
104
- type: FIX_TYPE.FILE_CREATE,
105
- description: 'Create .gitignore with common patterns',
106
- path: gitignorePath,
107
- content: [
108
- '# Dependencies',
109
- 'node_modules/',
110
- '',
111
- '# Environment',
112
- '.env',
113
- '.env.local',
114
- '.env.*.local',
115
- '',
116
- '# Build',
117
- 'dist/',
118
- 'build/',
119
- '.next/',
120
- '',
121
- '# vibecheck',
122
- '.vibecheck/',
123
- '',
124
- '# IDE',
125
- '.idea/',
126
- '.vscode/',
127
- '*.swp',
128
- ].join('\n'),
129
- autoFixable: true,
130
- }],
131
- };
132
- }
133
-
134
- const content = fs.readFileSync(gitignorePath, 'utf8');
135
- const missing = REQUIRED_GITIGNORE.filter(r => !content.includes(r.pattern));
136
-
137
- const metadata = {
138
- missing: missing.map(m => m.pattern),
139
- lines: content.split('\n').length,
140
- };
141
-
142
- if (missing.length > 0) {
143
- return {
144
- severity: SEVERITY.WARNING,
145
- message: `Missing: ${missing.map(m => m.name).join(', ')}`,
146
- metadata,
147
- fixes: [{
148
- type: FIX_TYPE.FILE_EDIT,
149
- description: 'Add missing patterns to .gitignore',
150
- path: gitignorePath,
151
- content: content + '\n\n# Added by vibecheck doctor\n' +
152
- missing.map(m => m.pattern).join('\n') + '\n',
153
- autoFixable: true,
154
- }],
155
- };
156
- }
157
-
158
- return {
159
- severity: SEVERITY.PASS,
160
- message: 'Properly configured',
161
- metadata,
162
- };
163
- },
164
- },
165
- {
166
- id: `${MODULE_ID}.exposed_secrets`,
167
- name: 'Exposed Secrets',
168
- category: CATEGORY.SECURITY,
169
- parallel: false,
170
- check: async () => {
171
- const filesToCheck = [
172
- 'package.json',
173
- 'src/config.ts',
174
- 'src/config.js',
175
- 'config/index.ts',
176
- 'config/index.js',
177
- 'next.config.js',
178
- 'next.config.mjs',
179
- '.env.example',
180
- 'README.md',
181
- ];
182
-
183
- const findings = [];
184
-
185
- for (const file of filesToCheck) {
186
- const filePath = path.join(projectPath, file);
187
- if (!fs.existsSync(filePath)) continue;
188
-
189
- try {
190
- const content = fs.readFileSync(filePath, 'utf8');
191
-
192
- for (const sp of SECRET_PATTERNS) {
193
- if (sp.pattern.test(content)) {
194
- findings.push({
195
- file,
196
- secret: sp.name,
197
- critical: sp.critical,
198
- });
199
- }
200
- }
201
- } catch {
202
- // Skip unreadable files
203
- }
204
- }
205
-
206
- const metadata = { findings };
207
- const criticalFindings = findings.filter(f => f.critical);
208
-
209
- if (criticalFindings.length > 0) {
210
- return {
211
- severity: SEVERITY.CRITICAL,
212
- message: `${criticalFindings.length} critical secrets exposed`,
213
- detail: criticalFindings.map(f => `${f.secret} in ${f.file}`).join(', '),
214
- metadata,
215
- fixes: [{
216
- type: FIX_TYPE.MANUAL,
217
- description: 'Move secrets to .env and add to .gitignore',
218
- autoFixable: false,
219
- }],
220
- };
221
- }
222
-
223
- if (findings.length > 0) {
224
- return {
225
- severity: SEVERITY.WARNING,
226
- message: `${findings.length} potential secrets found`,
227
- detail: findings.map(f => `${f.secret} in ${f.file}`).join(', '),
228
- metadata,
229
- fixes: [{
230
- type: FIX_TYPE.MANUAL,
231
- description: 'Review and move secrets to .env',
232
- autoFixable: false,
233
- }],
234
- };
235
- }
236
-
237
- return {
238
- severity: SEVERITY.PASS,
239
- message: 'No exposed secrets detected',
240
- metadata,
241
- };
242
- },
243
- },
244
- {
245
- id: `${MODULE_ID}.env_in_git`,
246
- name: '.env in Git History',
247
- category: CATEGORY.SECURITY,
248
- parallel: true,
249
- check: async () => {
250
- const gitDir = path.join(projectPath, '.git');
251
- if (!fs.existsSync(gitDir)) {
252
- return {
253
- severity: SEVERITY.INFO,
254
- message: 'Not a git repository',
255
- };
256
- }
257
-
258
- try {
259
- const { execSync } = require('child_process');
260
- const result = execSync('git log --all --full-history -- .env 2>/dev/null | head -1', {
261
- cwd: projectPath,
262
- encoding: 'utf8',
263
- timeout: 10000,
264
- }).trim();
265
-
266
- if (result) {
267
- return {
268
- severity: SEVERITY.ERROR,
269
- message: '.env found in git history',
270
- detail: 'Secrets may be exposed in git commits',
271
- fixes: [
272
- {
273
- type: FIX_TYPE.LINK,
274
- description: 'Guide: Remove secrets from git history',
275
- url: 'https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository',
276
- },
277
- {
278
- type: FIX_TYPE.COMMAND,
279
- description: 'Remove .env from history (dangerous)',
280
- command: 'git filter-branch --force --index-filter "git rm --cached --ignore-unmatch .env" --prune-empty --tag-name-filter cat -- --all',
281
- dangerous: true,
282
- autoFixable: false,
283
- },
284
- ],
285
- };
286
- }
287
-
288
- return {
289
- severity: SEVERITY.PASS,
290
- message: 'No .env in git history',
291
- };
292
- } catch {
293
- return {
294
- severity: SEVERITY.INFO,
295
- message: 'Could not check git history',
296
- };
297
- }
298
- },
299
- },
300
- {
301
- id: `${MODULE_ID}.npmrc`,
302
- name: '.npmrc Security',
303
- category: CATEGORY.SECURITY,
304
- parallel: true,
305
- check: async () => {
306
- const npmrcPath = path.join(projectPath, '.npmrc');
307
-
308
- if (!fs.existsSync(npmrcPath)) {
309
- return {
310
- severity: SEVERITY.INFO,
311
- message: 'No .npmrc file',
312
- };
313
- }
314
-
315
- const content = fs.readFileSync(npmrcPath, 'utf8');
316
- const hasToken = content.includes('_authToken') || content.includes('//registry');
317
-
318
- if (hasToken) {
319
- const gitignorePath = path.join(projectPath, '.gitignore');
320
- const gitignoreContent = fs.existsSync(gitignorePath)
321
- ? fs.readFileSync(gitignorePath, 'utf8')
322
- : '';
323
-
324
- if (!gitignoreContent.includes('.npmrc')) {
325
- return {
326
- severity: SEVERITY.WARNING,
327
- message: '.npmrc contains tokens but not in .gitignore',
328
- fixes: [{
329
- type: FIX_TYPE.FILE_EDIT,
330
- description: 'Add .npmrc to .gitignore',
331
- path: gitignorePath,
332
- content: gitignoreContent + '\n.npmrc\n',
333
- autoFixable: true,
334
- }],
335
- };
336
- }
337
- }
338
-
339
- return {
340
- severity: SEVERITY.PASS,
341
- message: hasToken ? 'Contains tokens (gitignored)' : 'No sensitive data',
342
- };
343
- },
344
- },
345
- ];
346
- }
347
-
348
- module.exports = { MODULE_ID, createDiagnostics, SECRET_PATTERNS };
@@ -1,213 +0,0 @@
1
- /**
2
- * System Diagnostics Module
3
- *
4
- * Checks OS, memory, disk, CPU, and system resources
5
- */
6
-
7
- const os = require('os');
8
- const fs = require('fs');
9
- const path = require('path');
10
- const { SEVERITY, CATEGORY, FIX_TYPE } = require('../types');
11
-
12
- const MODULE_ID = 'system';
13
-
14
- function createDiagnostics(projectPath) {
15
- return [
16
- {
17
- id: `${MODULE_ID}.os`,
18
- name: 'Operating System',
19
- category: CATEGORY.SYSTEM,
20
- parallel: true,
21
- check: async () => {
22
- const platform = os.platform();
23
- const release = os.release();
24
- const arch = os.arch();
25
-
26
- const platformNames = {
27
- win32: 'Windows',
28
- darwin: 'macOS',
29
- linux: 'Linux',
30
- freebsd: 'FreeBSD',
31
- };
32
-
33
- return {
34
- severity: SEVERITY.PASS,
35
- message: `${platformNames[platform] || platform} ${release} (${arch})`,
36
- metadata: { platform, release, arch },
37
- };
38
- },
39
- },
40
- {
41
- id: `${MODULE_ID}.memory`,
42
- name: 'System Memory',
43
- category: CATEGORY.SYSTEM,
44
- parallel: true,
45
- check: async () => {
46
- const totalBytes = os.totalmem();
47
- const freeBytes = os.freemem();
48
- const totalGB = (totalBytes / 1024 / 1024 / 1024).toFixed(1);
49
- const freeGB = (freeBytes / 1024 / 1024 / 1024).toFixed(1);
50
- const usedPercent = Math.round((1 - freeBytes / totalBytes) * 100);
51
-
52
- const metadata = { totalBytes, freeBytes, totalGB, freeGB, usedPercent };
53
-
54
- if (freeBytes < 256 * 1024 * 1024) { // < 256MB
55
- return {
56
- severity: SEVERITY.ERROR,
57
- message: `Critically low memory: ${freeGB}GB free`,
58
- detail: 'vibecheck may fail or be extremely slow',
59
- metadata,
60
- fixes: [{
61
- type: FIX_TYPE.MANUAL,
62
- description: 'Close other applications to free memory',
63
- autoFixable: false,
64
- }],
65
- };
66
- }
67
-
68
- if (freeBytes < 512 * 1024 * 1024) { // < 512MB
69
- return {
70
- severity: SEVERITY.WARNING,
71
- message: `Low memory: ${freeGB}GB free of ${totalGB}GB`,
72
- metadata,
73
- fixes: [{
74
- type: FIX_TYPE.MANUAL,
75
- description: 'Close other applications to free memory',
76
- autoFixable: false,
77
- }],
78
- };
79
- }
80
-
81
- return {
82
- severity: SEVERITY.PASS,
83
- message: `${freeGB}GB free of ${totalGB}GB (${usedPercent}% used)`,
84
- metadata,
85
- };
86
- },
87
- },
88
- {
89
- id: `${MODULE_ID}.cpu`,
90
- name: 'CPU Information',
91
- category: CATEGORY.SYSTEM,
92
- parallel: true,
93
- check: async () => {
94
- const cpus = os.cpus();
95
- const cores = cpus.length;
96
- const model = cpus[0]?.model || 'Unknown';
97
- const loadAvg = os.loadavg();
98
-
99
- const metadata = { cores, model, loadAvg };
100
-
101
- // High load warning (load > cores * 2)
102
- if (loadAvg[0] > cores * 2) {
103
- return {
104
- severity: SEVERITY.WARNING,
105
- message: `High CPU load: ${loadAvg[0].toFixed(1)} (${cores} cores)`,
106
- detail: 'System is under heavy load',
107
- metadata,
108
- };
109
- }
110
-
111
- return {
112
- severity: SEVERITY.PASS,
113
- message: `${cores} cores, load: ${loadAvg[0].toFixed(2)}`,
114
- metadata,
115
- };
116
- },
117
- },
118
- {
119
- id: `${MODULE_ID}.disk_write`,
120
- name: 'Disk Write Access',
121
- category: CATEGORY.SYSTEM,
122
- parallel: false,
123
- check: async () => {
124
- const testDir = path.join(projectPath, '.vibecheck');
125
- const testFile = path.join(testDir, '.doctor-test');
126
-
127
- try {
128
- // Ensure directory exists
129
- if (!fs.existsSync(testDir)) {
130
- fs.mkdirSync(testDir, { recursive: true });
131
- }
132
-
133
- // Test write
134
- fs.writeFileSync(testFile, `test-${Date.now()}`);
135
- fs.unlinkSync(testFile);
136
-
137
- return {
138
- severity: SEVERITY.PASS,
139
- message: 'Write access OK',
140
- };
141
- } catch (err) {
142
- return {
143
- severity: SEVERITY.ERROR,
144
- message: 'Cannot write to project directory',
145
- detail: err.message,
146
- fixes: [
147
- {
148
- type: FIX_TYPE.COMMAND,
149
- description: 'Fix directory permissions',
150
- command: process.platform === 'win32'
151
- ? `icacls "${projectPath}" /grant "%USERNAME%":F /T`
152
- : `chmod -R u+w "${projectPath}"`,
153
- dangerous: true,
154
- autoFixable: false,
155
- },
156
- ],
157
- };
158
- }
159
- },
160
- },
161
- {
162
- id: `${MODULE_ID}.temp_dir`,
163
- name: 'Temp Directory',
164
- category: CATEGORY.SYSTEM,
165
- parallel: true,
166
- check: async () => {
167
- const tmpDir = os.tmpdir();
168
-
169
- try {
170
- const testFile = path.join(tmpDir, `.vibecheck-test-${Date.now()}`);
171
- fs.writeFileSync(testFile, 'test');
172
- fs.unlinkSync(testFile);
173
-
174
- return {
175
- severity: SEVERITY.PASS,
176
- message: `Writable: ${tmpDir}`,
177
- metadata: { tmpDir },
178
- };
179
- } catch (err) {
180
- return {
181
- severity: SEVERITY.WARNING,
182
- message: `Temp directory not writable: ${tmpDir}`,
183
- detail: err.message,
184
- metadata: { tmpDir },
185
- };
186
- }
187
- },
188
- },
189
- {
190
- id: `${MODULE_ID}.shell`,
191
- name: 'Shell Environment',
192
- category: CATEGORY.SYSTEM,
193
- parallel: true,
194
- check: async () => {
195
- const shell = process.env.SHELL || process.env.ComSpec || 'unknown';
196
- const term = process.env.TERM || process.env.WT_SESSION ? 'modern' : 'basic';
197
- const colorSupport = process.stdout.isTTY && (
198
- process.env.COLORTERM === 'truecolor' ||
199
- process.env.TERM_PROGRAM === 'vscode' ||
200
- process.env.WT_SESSION
201
- );
202
-
203
- return {
204
- severity: SEVERITY.PASS,
205
- message: `${path.basename(shell)} (${colorSupport ? 'color' : 'no-color'})`,
206
- metadata: { shell, term, colorSupport },
207
- };
208
- },
209
- },
210
- ];
211
- }
212
-
213
- module.exports = { MODULE_ID, createDiagnostics };