@vibecheckai/cli 3.1.0 → 3.1.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/bin/.generated +25 -25
- package/bin/dev/run-v2-torture.js +30 -30
- package/bin/registry.js +105 -105
- package/bin/runners/lib/__tests__/entitlements-v2.test.js +295 -295
- package/bin/runners/lib/analysis-core.js +271 -271
- package/bin/runners/lib/analyzers.js +579 -579
- package/bin/runners/lib/auth-truth.js +193 -193
- package/bin/runners/lib/backup.js +62 -62
- package/bin/runners/lib/billing.js +107 -107
- package/bin/runners/lib/claims.js +118 -118
- package/bin/runners/lib/cli-output.js +368 -368
- package/bin/runners/lib/cli-ui.js +540 -540
- package/bin/runners/lib/contracts/auth-contract.js +202 -202
- package/bin/runners/lib/contracts/env-contract.js +181 -181
- package/bin/runners/lib/contracts/external-contract.js +206 -206
- package/bin/runners/lib/contracts/guard.js +168 -168
- package/bin/runners/lib/contracts/index.js +89 -89
- package/bin/runners/lib/contracts/plan-validator.js +311 -311
- package/bin/runners/lib/contracts/route-contract.js +199 -199
- package/bin/runners/lib/contracts.js +804 -804
- package/bin/runners/lib/detect.js +89 -89
- package/bin/runners/lib/detectors-v2.js +703 -703
- package/bin/runners/lib/doctor/autofix.js +254 -254
- package/bin/runners/lib/doctor/index.js +37 -37
- package/bin/runners/lib/doctor/modules/dependencies.js +325 -325
- package/bin/runners/lib/doctor/modules/index.js +46 -46
- package/bin/runners/lib/doctor/modules/network.js +250 -250
- package/bin/runners/lib/doctor/modules/project.js +312 -312
- package/bin/runners/lib/doctor/modules/runtime.js +224 -224
- package/bin/runners/lib/doctor/modules/security.js +348 -348
- package/bin/runners/lib/doctor/modules/system.js +213 -213
- package/bin/runners/lib/doctor/modules/vibecheck.js +394 -394
- package/bin/runners/lib/doctor/reporter.js +262 -262
- package/bin/runners/lib/doctor/service.js +262 -262
- package/bin/runners/lib/doctor/types.js +113 -113
- package/bin/runners/lib/doctor/ui.js +263 -263
- package/bin/runners/lib/doctor-v2.js +608 -608
- package/bin/runners/lib/drift.js +425 -425
- package/bin/runners/lib/enforcement.js +72 -72
- package/bin/runners/lib/enterprise-detect.js +603 -603
- package/bin/runners/lib/enterprise-init.js +942 -942
- package/bin/runners/lib/entitlements-v2.js +490 -489
- package/bin/runners/lib/env-resolver.js +417 -417
- package/bin/runners/lib/env-template.js +66 -66
- package/bin/runners/lib/env.js +189 -189
- package/bin/runners/lib/extractors/client-calls.js +990 -990
- package/bin/runners/lib/extractors/fastify-route-dump.js +573 -573
- package/bin/runners/lib/extractors/fastify-routes.js +426 -426
- package/bin/runners/lib/extractors/index.js +363 -363
- package/bin/runners/lib/extractors/next-routes.js +524 -524
- package/bin/runners/lib/extractors/proof-graph.js +431 -431
- package/bin/runners/lib/extractors/route-matcher.js +451 -451
- package/bin/runners/lib/extractors/truthpack-v2.js +377 -377
- package/bin/runners/lib/extractors/ui-bindings.js +547 -547
- package/bin/runners/lib/findings-schema.js +281 -281
- package/bin/runners/lib/firewall-prompt.js +50 -50
- package/bin/runners/lib/graph/graph-builder.js +265 -265
- package/bin/runners/lib/graph/html-renderer.js +413 -413
- package/bin/runners/lib/graph/index.js +32 -32
- package/bin/runners/lib/graph/runtime-collector.js +215 -215
- package/bin/runners/lib/graph/static-extractor.js +518 -518
- package/bin/runners/lib/html-report.js +650 -650
- package/bin/runners/lib/init-wizard.js +308 -308
- package/bin/runners/lib/llm.js +75 -75
- package/bin/runners/lib/meter.js +61 -61
- package/bin/runners/lib/missions/evidence.js +126 -126
- package/bin/runners/lib/missions/plan.js +69 -69
- package/bin/runners/lib/missions/templates.js +192 -192
- package/bin/runners/lib/patch.js +40 -40
- package/bin/runners/lib/permissions/auth-model.js +213 -213
- package/bin/runners/lib/permissions/idor-prover.js +205 -205
- package/bin/runners/lib/permissions/index.js +45 -45
- package/bin/runners/lib/permissions/matrix-builder.js +198 -198
- package/bin/runners/lib/pkgjson.js +28 -28
- package/bin/runners/lib/policy.js +295 -295
- package/bin/runners/lib/preflight.js +142 -142
- package/bin/runners/lib/reality/correlation-detectors.js +359 -359
- package/bin/runners/lib/reality/index.js +318 -318
- package/bin/runners/lib/reality/request-hashing.js +416 -416
- package/bin/runners/lib/reality/request-mapper.js +453 -453
- package/bin/runners/lib/reality/safety-rails.js +463 -463
- package/bin/runners/lib/reality/semantic-snapshot.js +408 -408
- package/bin/runners/lib/reality/toast-detector.js +393 -393
- package/bin/runners/lib/reality-findings.js +84 -84
- package/bin/runners/lib/receipts.js +179 -179
- package/bin/runners/lib/redact.js +29 -29
- package/bin/runners/lib/replay/capsule-manager.js +154 -154
- package/bin/runners/lib/replay/index.js +263 -263
- package/bin/runners/lib/replay/player.js +348 -348
- package/bin/runners/lib/replay/recorder.js +331 -331
- package/bin/runners/lib/report-engine.js +447 -447
- package/bin/runners/lib/report-html.js +1499 -1499
- package/bin/runners/lib/report-templates.js +969 -969
- package/bin/runners/lib/report.js +135 -135
- package/bin/runners/lib/route-detection.js +1140 -1140
- package/bin/runners/lib/route-truth.js +477 -477
- package/bin/runners/lib/sandbox/index.js +59 -59
- package/bin/runners/lib/sandbox/proof-chain.js +399 -399
- package/bin/runners/lib/sandbox/sandbox-runner.js +205 -205
- package/bin/runners/lib/sandbox/worktree.js +174 -174
- package/bin/runners/lib/schema-validator.js +350 -350
- package/bin/runners/lib/schemas/contracts.schema.json +160 -160
- package/bin/runners/lib/schemas/finding.schema.json +100 -100
- package/bin/runners/lib/schemas/mission-pack.schema.json +206 -206
- package/bin/runners/lib/schemas/proof-graph.schema.json +176 -176
- package/bin/runners/lib/schemas/reality-report.schema.json +162 -162
- package/bin/runners/lib/schemas/share-pack.schema.json +180 -180
- package/bin/runners/lib/schemas/ship-report.schema.json +117 -117
- package/bin/runners/lib/schemas/truthpack-v2.schema.json +303 -303
- package/bin/runners/lib/schemas/validator.js +438 -438
- package/bin/runners/lib/score-history.js +282 -282
- package/bin/runners/lib/share-pack.js +239 -239
- package/bin/runners/lib/snippets.js +67 -67
- package/bin/runners/lib/truth.js +667 -667
- package/bin/runners/lib/upsell.js +510 -510
- package/bin/runners/lib/usage.js +153 -153
- package/bin/runners/lib/validate-patch.js +156 -156
- package/bin/runners/lib/verdict-engine.js +628 -628
- package/bin/runners/reality/engine.js +917 -917
- package/bin/runners/reality/flows.js +122 -122
- package/bin/runners/reality/report.js +378 -378
- package/bin/runners/reality/session.js +193 -193
- package/bin/runners/runAuth.js +51 -0
- package/bin/runners/runClaimVerifier.js +483 -483
- package/bin/runners/runContext.js +56 -56
- package/bin/runners/runContextCompiler.js +385 -385
- package/bin/runners/runCtx.js +674 -674
- package/bin/runners/runCtxDiff.js +301 -301
- package/bin/runners/runCtxGuard.js +176 -176
- package/bin/runners/runCtxSync.js +116 -116
- package/bin/runners/runGate.js +17 -17
- package/bin/runners/runGraph.js +454 -454
- package/bin/runners/runGuard.js +168 -168
- package/bin/runners/runInitGha.js +164 -164
- package/bin/runners/runInstall.js +277 -277
- package/bin/runners/runInteractive.js +388 -388
- package/bin/runners/runLabs.js +340 -340
- package/bin/runners/runMissionGenerator.js +282 -282
- package/bin/runners/runPR.js +255 -255
- package/bin/runners/runPermissions.js +304 -304
- package/bin/runners/runPreflight.js +580 -553
- package/bin/runners/runProve.js +1252 -1252
- package/bin/runners/runReality.js +1328 -1328
- package/bin/runners/runReplay.js +499 -499
- package/bin/runners/runReport.js +584 -584
- package/bin/runners/runShare.js +212 -212
- package/bin/runners/runStatus.js +138 -138
- package/bin/runners/runTruthpack.js +636 -636
- package/bin/runners/runVerify.js +272 -272
- package/bin/runners/runWatch.js +407 -407
- package/bin/vibecheck.js +2 -1
- package/mcp-server/consolidated-tools.js +804 -804
- package/mcp-server/package.json +1 -1
- package/mcp-server/tools/index.js +72 -72
- package/mcp-server/truth-context.js +581 -581
- package/mcp-server/truth-firewall-tools.js +1500 -1500
- package/package.json +1 -1
- package/bin/runners/runProof.zip +0 -0
|
@@ -1,308 +1,308 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Init Wizard — Beautiful Guided Setup
|
|
3
|
-
*
|
|
4
|
-
* Interactive setup wizard with:
|
|
5
|
-
* - Step-by-step configuration
|
|
6
|
-
* - Project type detection
|
|
7
|
-
* - Beautiful progress indicators
|
|
8
|
-
* - Smart defaults
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const fs = require('fs');
|
|
12
|
-
const path = require('path');
|
|
13
|
-
const readline = require('readline');
|
|
14
|
-
|
|
15
|
-
// Colors
|
|
16
|
-
const c = {
|
|
17
|
-
reset: '\x1b[0m',
|
|
18
|
-
bold: '\x1b[1m',
|
|
19
|
-
dim: '\x1b[2m',
|
|
20
|
-
red: '\x1b[31m',
|
|
21
|
-
green: '\x1b[32m',
|
|
22
|
-
yellow: '\x1b[33m',
|
|
23
|
-
blue: '\x1b[34m',
|
|
24
|
-
cyan: '\x1b[36m',
|
|
25
|
-
magenta: '\x1b[35m',
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// Project types with smart detection
|
|
29
|
-
const PROJECT_TYPES = {
|
|
30
|
-
nextjs: {
|
|
31
|
-
name: 'Next.js',
|
|
32
|
-
icon: '▲',
|
|
33
|
-
detect: (dir) => fs.existsSync(path.join(dir, 'next.config.js')) ||
|
|
34
|
-
fs.existsSync(path.join(dir, 'next.config.mjs')) ||
|
|
35
|
-
fs.existsSync(path.join(dir, 'next.config.ts')),
|
|
36
|
-
config: { framework: 'nextjs', checks: ['routes', 'auth', 'api', 'security'] },
|
|
37
|
-
},
|
|
38
|
-
react: {
|
|
39
|
-
name: 'React',
|
|
40
|
-
icon: '⚛️',
|
|
41
|
-
detect: (dir) => {
|
|
42
|
-
const pkg = loadPackageJson(dir);
|
|
43
|
-
return pkg?.dependencies?.react && !PROJECT_TYPES.nextjs.detect(dir);
|
|
44
|
-
},
|
|
45
|
-
config: { framework: 'react', checks: ['components', 'api', 'security'] },
|
|
46
|
-
},
|
|
47
|
-
fastify: {
|
|
48
|
-
name: 'Fastify',
|
|
49
|
-
icon: '⚡',
|
|
50
|
-
detect: (dir) => {
|
|
51
|
-
const pkg = loadPackageJson(dir);
|
|
52
|
-
return pkg?.dependencies?.fastify;
|
|
53
|
-
},
|
|
54
|
-
config: { framework: 'fastify', checks: ['routes', 'auth', 'api', 'security'] },
|
|
55
|
-
},
|
|
56
|
-
express: {
|
|
57
|
-
name: 'Express',
|
|
58
|
-
icon: '🚂',
|
|
59
|
-
detect: (dir) => {
|
|
60
|
-
const pkg = loadPackageJson(dir);
|
|
61
|
-
return pkg?.dependencies?.express;
|
|
62
|
-
},
|
|
63
|
-
config: { framework: 'express', checks: ['routes', 'auth', 'api', 'security'] },
|
|
64
|
-
},
|
|
65
|
-
node: {
|
|
66
|
-
name: 'Node.js',
|
|
67
|
-
icon: '🟢',
|
|
68
|
-
detect: (dir) => fs.existsSync(path.join(dir, 'package.json')),
|
|
69
|
-
config: { framework: 'node', checks: ['security', 'quality'] },
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
function loadPackageJson(dir) {
|
|
74
|
-
try {
|
|
75
|
-
return JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'));
|
|
76
|
-
} catch {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
class InitWizard {
|
|
82
|
-
constructor(projectPath, options = {}) {
|
|
83
|
-
this.projectPath = projectPath;
|
|
84
|
-
this.options = options;
|
|
85
|
-
this.answers = {};
|
|
86
|
-
this.detectedType = null;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async run() {
|
|
90
|
-
this.printHeader();
|
|
91
|
-
|
|
92
|
-
// Step 1: Detect project type
|
|
93
|
-
await this.detectProject();
|
|
94
|
-
|
|
95
|
-
// Step 2: Configure checks
|
|
96
|
-
await this.configureChecks();
|
|
97
|
-
|
|
98
|
-
// Step 3: Setup files
|
|
99
|
-
await this.setupFiles();
|
|
100
|
-
|
|
101
|
-
// Step 4: Print next steps
|
|
102
|
-
this.printNextSteps();
|
|
103
|
-
|
|
104
|
-
return 0;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
printHeader() {
|
|
108
|
-
console.log('');
|
|
109
|
-
console.log(`${c.cyan}╔══════════════════════════════════════════════════════════════════════╗${c.reset}`);
|
|
110
|
-
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
111
|
-
console.log(`${c.cyan}║${c.reset} ${c.bold}⚡ VIBECHECK SETUP WIZARD${c.reset} ${c.cyan}║${c.reset}`);
|
|
112
|
-
console.log(`${c.cyan}║${c.reset} ${c.dim}Configure your project for production readiness checks${c.reset} ${c.cyan}║${c.reset}`);
|
|
113
|
-
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
114
|
-
console.log(`${c.cyan}╚══════════════════════════════════════════════════════════════════════╝${c.reset}`);
|
|
115
|
-
console.log('');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async detectProject() {
|
|
119
|
-
console.log(`${c.cyan}┌─ Step 1: Project Detection ─────────────────────────────────────────┐${c.reset}`);
|
|
120
|
-
console.log(`${c.cyan}│${c.reset}`);
|
|
121
|
-
|
|
122
|
-
// Auto-detect project type
|
|
123
|
-
for (const [key, type] of Object.entries(PROJECT_TYPES)) {
|
|
124
|
-
if (type.detect(this.projectPath)) {
|
|
125
|
-
this.detectedType = { key, ...type };
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (this.detectedType) {
|
|
131
|
-
console.log(`${c.cyan}│${c.reset} ${c.green}✓${c.reset} Detected: ${c.bold}${this.detectedType.icon} ${this.detectedType.name}${c.reset}`);
|
|
132
|
-
} else {
|
|
133
|
-
console.log(`${c.cyan}│${c.reset} ${c.yellow}!${c.reset} Could not auto-detect project type`);
|
|
134
|
-
this.detectedType = { key: 'node', ...PROJECT_TYPES.node };
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Check for package.json
|
|
138
|
-
const pkg = loadPackageJson(this.projectPath);
|
|
139
|
-
if (pkg) {
|
|
140
|
-
console.log(`${c.cyan}│${c.reset} ${c.green}✓${c.reset} Package: ${c.bold}${pkg.name || 'unnamed'}${c.reset} v${pkg.version || '0.0.0'}`);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Check for existing config
|
|
144
|
-
const configPath = path.join(this.projectPath, '.vibecheckrc');
|
|
145
|
-
if (fs.existsSync(configPath)) {
|
|
146
|
-
console.log(`${c.cyan}│${c.reset} ${c.yellow}!${c.reset} Existing config found (will be updated)`);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
console.log(`${c.cyan}│${c.reset}`);
|
|
150
|
-
console.log(`${c.cyan}└──────────────────────────────────────────────────────────────────────┘${c.reset}`);
|
|
151
|
-
console.log('');
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async configureChecks() {
|
|
155
|
-
console.log(`${c.cyan}┌─ Step 2: Configuration ─────────────────────────────────────────────┐${c.reset}`);
|
|
156
|
-
console.log(`${c.cyan}│${c.reset}`);
|
|
157
|
-
|
|
158
|
-
// Use detected config as base
|
|
159
|
-
const config = this.detectedType?.config || PROJECT_TYPES.node.config;
|
|
160
|
-
|
|
161
|
-
console.log(`${c.cyan}│${c.reset} ${c.bold}Enabled checks:${c.reset}`);
|
|
162
|
-
|
|
163
|
-
const allChecks = [
|
|
164
|
-
{ id: 'routes', name: 'Route Integrity', desc: 'Dead links, orphan routes' },
|
|
165
|
-
{ id: 'auth', name: 'Authentication', desc: 'Auth coverage, ghost auth' },
|
|
166
|
-
{ id: 'api', name: 'API Verification', desc: 'Endpoint validation' },
|
|
167
|
-
{ id: 'security', name: 'Security', desc: 'Secrets, vulnerabilities' },
|
|
168
|
-
{ id: 'quality', name: 'Code Quality', desc: 'Mocks, placeholders' },
|
|
169
|
-
{ id: 'billing', name: 'Billing Gates', desc: 'Payment flow verification' },
|
|
170
|
-
];
|
|
171
|
-
|
|
172
|
-
for (const check of allChecks) {
|
|
173
|
-
const enabled = config.checks.includes(check.id);
|
|
174
|
-
const icon = enabled ? `${c.green}✓${c.reset}` : `${c.dim}○${c.reset}`;
|
|
175
|
-
const color = enabled ? '' : c.dim;
|
|
176
|
-
console.log(`${c.cyan}│${c.reset} ${icon} ${color}${check.name}${c.reset} ${c.dim}— ${check.desc}${c.reset}`);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
this.answers.config = {
|
|
180
|
-
version: '1.0.0',
|
|
181
|
-
framework: config.framework,
|
|
182
|
-
checks: config.checks,
|
|
183
|
-
output: '.vibecheck',
|
|
184
|
-
policy: {
|
|
185
|
-
strict: false,
|
|
186
|
-
allowlist: { domains: [], packages: [] },
|
|
187
|
-
ignore: { paths: ['node_modules', '__tests__', '*.test.*', '*.spec.*'] },
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
console.log(`${c.cyan}│${c.reset}`);
|
|
192
|
-
console.log(`${c.cyan}└──────────────────────────────────────────────────────────────────────┘${c.reset}`);
|
|
193
|
-
console.log('');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
async setupFiles() {
|
|
197
|
-
console.log(`${c.cyan}┌─ Step 3: Setup ─────────────────────────────────────────────────────┐${c.reset}`);
|
|
198
|
-
console.log(`${c.cyan}│${c.reset}`);
|
|
199
|
-
|
|
200
|
-
const tasks = [
|
|
201
|
-
{ name: 'Creating .vibecheckrc', fn: () => this.createConfig() },
|
|
202
|
-
{ name: 'Creating .vibecheck/ directory', fn: () => this.createOutputDir() },
|
|
203
|
-
{ name: 'Updating .gitignore', fn: () => this.updateGitignore() },
|
|
204
|
-
{ name: 'Creating schemas/', fn: () => this.createSchemas() },
|
|
205
|
-
];
|
|
206
|
-
|
|
207
|
-
for (const task of tasks) {
|
|
208
|
-
process.stdout.write(`${c.cyan}│${c.reset} ○ ${task.name}...`);
|
|
209
|
-
try {
|
|
210
|
-
const result = await task.fn();
|
|
211
|
-
process.stdout.write(`\r${c.cyan}│${c.reset} ${c.green}✓${c.reset} ${task.name} ${c.dim}${result || ''}${c.reset}\n`);
|
|
212
|
-
} catch (err) {
|
|
213
|
-
process.stdout.write(`\r${c.cyan}│${c.reset} ${c.red}✗${c.reset} ${task.name} ${c.red}${err.message}${c.reset}\n`);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
console.log(`${c.cyan}│${c.reset}`);
|
|
218
|
-
console.log(`${c.cyan}└──────────────────────────────────────────────────────────────────────┘${c.reset}`);
|
|
219
|
-
console.log('');
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
createConfig() {
|
|
223
|
-
const configPath = path.join(this.projectPath, '.vibecheckrc');
|
|
224
|
-
fs.writeFileSync(configPath, JSON.stringify(this.answers.config, null, 2));
|
|
225
|
-
return '';
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
createOutputDir() {
|
|
229
|
-
const outputDir = path.join(this.projectPath, '.vibecheck');
|
|
230
|
-
if (!fs.existsSync(outputDir)) {
|
|
231
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
232
|
-
}
|
|
233
|
-
return '';
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
updateGitignore() {
|
|
237
|
-
const gitignorePath = path.join(this.projectPath, '.gitignore');
|
|
238
|
-
const entry = '\n# vibecheck\n.vibecheck/\n';
|
|
239
|
-
|
|
240
|
-
if (fs.existsSync(gitignorePath)) {
|
|
241
|
-
const content = fs.readFileSync(gitignorePath, 'utf8');
|
|
242
|
-
if (!content.includes('.vibecheck/')) {
|
|
243
|
-
fs.appendFileSync(gitignorePath, entry);
|
|
244
|
-
return 'updated';
|
|
245
|
-
}
|
|
246
|
-
return 'already configured';
|
|
247
|
-
} else {
|
|
248
|
-
fs.writeFileSync(gitignorePath, entry.trim() + '\n');
|
|
249
|
-
return 'created';
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
createSchemas() {
|
|
254
|
-
const schemasDir = path.join(this.projectPath, '.vibecheck', 'schemas');
|
|
255
|
-
if (!fs.existsSync(schemasDir)) {
|
|
256
|
-
fs.mkdirSync(schemasDir, { recursive: true });
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// Create truthpack schema
|
|
260
|
-
const truthpackSchema = {
|
|
261
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
262
|
-
"$id": "https://vibecheck.dev/schemas/truthpack.json",
|
|
263
|
-
"title": "Vibecheck Truthpack",
|
|
264
|
-
"type": "object",
|
|
265
|
-
"properties": {
|
|
266
|
-
"version": { "type": "string" },
|
|
267
|
-
"generatedAt": { "type": "string", "format": "date-time" },
|
|
268
|
-
"routes": { "type": "object" },
|
|
269
|
-
"env": { "type": "object" },
|
|
270
|
-
"auth": { "type": "object" },
|
|
271
|
-
},
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
fs.writeFileSync(
|
|
275
|
-
path.join(schemasDir, 'truthpack.schema.json'),
|
|
276
|
-
JSON.stringify(truthpackSchema, null, 2)
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
return '';
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
printNextSteps() {
|
|
283
|
-
console.log(`${c.green}${c.bold}✓ Vibecheck initialized successfully!${c.reset}`);
|
|
284
|
-
console.log('');
|
|
285
|
-
console.log(`${c.cyan}╔══════════════════════════════════════════════════════════════════════╗${c.reset}`);
|
|
286
|
-
console.log(`${c.cyan}║${c.reset} ${c.bold}Next Steps${c.reset} ${c.cyan}║${c.reset}`);
|
|
287
|
-
console.log(`${c.cyan}╠══════════════════════════════════════════════════════════════════════╣${c.reset}`);
|
|
288
|
-
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
289
|
-
console.log(`${c.cyan}║${c.reset} ${c.bold}1.${c.reset} Run your first scan: ${c.cyan}║${c.reset}`);
|
|
290
|
-
console.log(`${c.cyan}║${c.reset} ${c.cyan}vibecheck ship${c.reset} ${c.cyan}║${c.reset}`);
|
|
291
|
-
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
292
|
-
console.log(`${c.cyan}║${c.reset} ${c.bold}2.${c.reset} Review the report: ${c.cyan}║${c.reset}`);
|
|
293
|
-
console.log(`${c.cyan}║${c.reset} ${c.dim}Open .vibecheck/report.html in your browser${c.reset} ${c.cyan}║${c.reset}`);
|
|
294
|
-
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
295
|
-
console.log(`${c.cyan}║${c.reset} ${c.bold}3.${c.reset} Fix issues and re-scan: ${c.cyan}║${c.reset}`);
|
|
296
|
-
console.log(`${c.cyan}║${c.reset} ${c.cyan}vibecheck ship --fix${c.reset} ${c.cyan}║${c.reset}`);
|
|
297
|
-
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
298
|
-
console.log(`${c.cyan}║${c.reset} ${c.bold}4.${c.reset} Generate a client report: ${c.cyan}║${c.reset}`);
|
|
299
|
-
console.log(`${c.cyan}║${c.reset} ${c.cyan}vibecheck report --type=executive${c.reset} ${c.cyan}║${c.reset}`);
|
|
300
|
-
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
301
|
-
console.log(`${c.cyan}╚══════════════════════════════════════════════════════════════════════╝${c.reset}`);
|
|
302
|
-
console.log('');
|
|
303
|
-
console.log(`${c.dim}Tip: Run ${c.cyan}vibecheck --help${c.dim} to see all available commands.${c.reset}`);
|
|
304
|
-
console.log('');
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
module.exports = { InitWizard };
|
|
1
|
+
/**
|
|
2
|
+
* Init Wizard — Beautiful Guided Setup
|
|
3
|
+
*
|
|
4
|
+
* Interactive setup wizard with:
|
|
5
|
+
* - Step-by-step configuration
|
|
6
|
+
* - Project type detection
|
|
7
|
+
* - Beautiful progress indicators
|
|
8
|
+
* - Smart defaults
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const readline = require('readline');
|
|
14
|
+
|
|
15
|
+
// Colors
|
|
16
|
+
const c = {
|
|
17
|
+
reset: '\x1b[0m',
|
|
18
|
+
bold: '\x1b[1m',
|
|
19
|
+
dim: '\x1b[2m',
|
|
20
|
+
red: '\x1b[31m',
|
|
21
|
+
green: '\x1b[32m',
|
|
22
|
+
yellow: '\x1b[33m',
|
|
23
|
+
blue: '\x1b[34m',
|
|
24
|
+
cyan: '\x1b[36m',
|
|
25
|
+
magenta: '\x1b[35m',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Project types with smart detection
|
|
29
|
+
const PROJECT_TYPES = {
|
|
30
|
+
nextjs: {
|
|
31
|
+
name: 'Next.js',
|
|
32
|
+
icon: '▲',
|
|
33
|
+
detect: (dir) => fs.existsSync(path.join(dir, 'next.config.js')) ||
|
|
34
|
+
fs.existsSync(path.join(dir, 'next.config.mjs')) ||
|
|
35
|
+
fs.existsSync(path.join(dir, 'next.config.ts')),
|
|
36
|
+
config: { framework: 'nextjs', checks: ['routes', 'auth', 'api', 'security'] },
|
|
37
|
+
},
|
|
38
|
+
react: {
|
|
39
|
+
name: 'React',
|
|
40
|
+
icon: '⚛️',
|
|
41
|
+
detect: (dir) => {
|
|
42
|
+
const pkg = loadPackageJson(dir);
|
|
43
|
+
return pkg?.dependencies?.react && !PROJECT_TYPES.nextjs.detect(dir);
|
|
44
|
+
},
|
|
45
|
+
config: { framework: 'react', checks: ['components', 'api', 'security'] },
|
|
46
|
+
},
|
|
47
|
+
fastify: {
|
|
48
|
+
name: 'Fastify',
|
|
49
|
+
icon: '⚡',
|
|
50
|
+
detect: (dir) => {
|
|
51
|
+
const pkg = loadPackageJson(dir);
|
|
52
|
+
return pkg?.dependencies?.fastify;
|
|
53
|
+
},
|
|
54
|
+
config: { framework: 'fastify', checks: ['routes', 'auth', 'api', 'security'] },
|
|
55
|
+
},
|
|
56
|
+
express: {
|
|
57
|
+
name: 'Express',
|
|
58
|
+
icon: '🚂',
|
|
59
|
+
detect: (dir) => {
|
|
60
|
+
const pkg = loadPackageJson(dir);
|
|
61
|
+
return pkg?.dependencies?.express;
|
|
62
|
+
},
|
|
63
|
+
config: { framework: 'express', checks: ['routes', 'auth', 'api', 'security'] },
|
|
64
|
+
},
|
|
65
|
+
node: {
|
|
66
|
+
name: 'Node.js',
|
|
67
|
+
icon: '🟢',
|
|
68
|
+
detect: (dir) => fs.existsSync(path.join(dir, 'package.json')),
|
|
69
|
+
config: { framework: 'node', checks: ['security', 'quality'] },
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
function loadPackageJson(dir) {
|
|
74
|
+
try {
|
|
75
|
+
return JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'));
|
|
76
|
+
} catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
class InitWizard {
|
|
82
|
+
constructor(projectPath, options = {}) {
|
|
83
|
+
this.projectPath = projectPath;
|
|
84
|
+
this.options = options;
|
|
85
|
+
this.answers = {};
|
|
86
|
+
this.detectedType = null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async run() {
|
|
90
|
+
this.printHeader();
|
|
91
|
+
|
|
92
|
+
// Step 1: Detect project type
|
|
93
|
+
await this.detectProject();
|
|
94
|
+
|
|
95
|
+
// Step 2: Configure checks
|
|
96
|
+
await this.configureChecks();
|
|
97
|
+
|
|
98
|
+
// Step 3: Setup files
|
|
99
|
+
await this.setupFiles();
|
|
100
|
+
|
|
101
|
+
// Step 4: Print next steps
|
|
102
|
+
this.printNextSteps();
|
|
103
|
+
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
printHeader() {
|
|
108
|
+
console.log('');
|
|
109
|
+
console.log(`${c.cyan}╔══════════════════════════════════════════════════════════════════════╗${c.reset}`);
|
|
110
|
+
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
111
|
+
console.log(`${c.cyan}║${c.reset} ${c.bold}⚡ VIBECHECK SETUP WIZARD${c.reset} ${c.cyan}║${c.reset}`);
|
|
112
|
+
console.log(`${c.cyan}║${c.reset} ${c.dim}Configure your project for production readiness checks${c.reset} ${c.cyan}║${c.reset}`);
|
|
113
|
+
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
114
|
+
console.log(`${c.cyan}╚══════════════════════════════════════════════════════════════════════╝${c.reset}`);
|
|
115
|
+
console.log('');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async detectProject() {
|
|
119
|
+
console.log(`${c.cyan}┌─ Step 1: Project Detection ─────────────────────────────────────────┐${c.reset}`);
|
|
120
|
+
console.log(`${c.cyan}│${c.reset}`);
|
|
121
|
+
|
|
122
|
+
// Auto-detect project type
|
|
123
|
+
for (const [key, type] of Object.entries(PROJECT_TYPES)) {
|
|
124
|
+
if (type.detect(this.projectPath)) {
|
|
125
|
+
this.detectedType = { key, ...type };
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (this.detectedType) {
|
|
131
|
+
console.log(`${c.cyan}│${c.reset} ${c.green}✓${c.reset} Detected: ${c.bold}${this.detectedType.icon} ${this.detectedType.name}${c.reset}`);
|
|
132
|
+
} else {
|
|
133
|
+
console.log(`${c.cyan}│${c.reset} ${c.yellow}!${c.reset} Could not auto-detect project type`);
|
|
134
|
+
this.detectedType = { key: 'node', ...PROJECT_TYPES.node };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Check for package.json
|
|
138
|
+
const pkg = loadPackageJson(this.projectPath);
|
|
139
|
+
if (pkg) {
|
|
140
|
+
console.log(`${c.cyan}│${c.reset} ${c.green}✓${c.reset} Package: ${c.bold}${pkg.name || 'unnamed'}${c.reset} v${pkg.version || '0.0.0'}`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Check for existing config
|
|
144
|
+
const configPath = path.join(this.projectPath, '.vibecheckrc');
|
|
145
|
+
if (fs.existsSync(configPath)) {
|
|
146
|
+
console.log(`${c.cyan}│${c.reset} ${c.yellow}!${c.reset} Existing config found (will be updated)`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
console.log(`${c.cyan}│${c.reset}`);
|
|
150
|
+
console.log(`${c.cyan}└──────────────────────────────────────────────────────────────────────┘${c.reset}`);
|
|
151
|
+
console.log('');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async configureChecks() {
|
|
155
|
+
console.log(`${c.cyan}┌─ Step 2: Configuration ─────────────────────────────────────────────┐${c.reset}`);
|
|
156
|
+
console.log(`${c.cyan}│${c.reset}`);
|
|
157
|
+
|
|
158
|
+
// Use detected config as base
|
|
159
|
+
const config = this.detectedType?.config || PROJECT_TYPES.node.config;
|
|
160
|
+
|
|
161
|
+
console.log(`${c.cyan}│${c.reset} ${c.bold}Enabled checks:${c.reset}`);
|
|
162
|
+
|
|
163
|
+
const allChecks = [
|
|
164
|
+
{ id: 'routes', name: 'Route Integrity', desc: 'Dead links, orphan routes' },
|
|
165
|
+
{ id: 'auth', name: 'Authentication', desc: 'Auth coverage, ghost auth' },
|
|
166
|
+
{ id: 'api', name: 'API Verification', desc: 'Endpoint validation' },
|
|
167
|
+
{ id: 'security', name: 'Security', desc: 'Secrets, vulnerabilities' },
|
|
168
|
+
{ id: 'quality', name: 'Code Quality', desc: 'Mocks, placeholders' },
|
|
169
|
+
{ id: 'billing', name: 'Billing Gates', desc: 'Payment flow verification' },
|
|
170
|
+
];
|
|
171
|
+
|
|
172
|
+
for (const check of allChecks) {
|
|
173
|
+
const enabled = config.checks.includes(check.id);
|
|
174
|
+
const icon = enabled ? `${c.green}✓${c.reset}` : `${c.dim}○${c.reset}`;
|
|
175
|
+
const color = enabled ? '' : c.dim;
|
|
176
|
+
console.log(`${c.cyan}│${c.reset} ${icon} ${color}${check.name}${c.reset} ${c.dim}— ${check.desc}${c.reset}`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
this.answers.config = {
|
|
180
|
+
version: '1.0.0',
|
|
181
|
+
framework: config.framework,
|
|
182
|
+
checks: config.checks,
|
|
183
|
+
output: '.vibecheck',
|
|
184
|
+
policy: {
|
|
185
|
+
strict: false,
|
|
186
|
+
allowlist: { domains: [], packages: [] },
|
|
187
|
+
ignore: { paths: ['node_modules', '__tests__', '*.test.*', '*.spec.*'] },
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
console.log(`${c.cyan}│${c.reset}`);
|
|
192
|
+
console.log(`${c.cyan}└──────────────────────────────────────────────────────────────────────┘${c.reset}`);
|
|
193
|
+
console.log('');
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async setupFiles() {
|
|
197
|
+
console.log(`${c.cyan}┌─ Step 3: Setup ─────────────────────────────────────────────────────┐${c.reset}`);
|
|
198
|
+
console.log(`${c.cyan}│${c.reset}`);
|
|
199
|
+
|
|
200
|
+
const tasks = [
|
|
201
|
+
{ name: 'Creating .vibecheckrc', fn: () => this.createConfig() },
|
|
202
|
+
{ name: 'Creating .vibecheck/ directory', fn: () => this.createOutputDir() },
|
|
203
|
+
{ name: 'Updating .gitignore', fn: () => this.updateGitignore() },
|
|
204
|
+
{ name: 'Creating schemas/', fn: () => this.createSchemas() },
|
|
205
|
+
];
|
|
206
|
+
|
|
207
|
+
for (const task of tasks) {
|
|
208
|
+
process.stdout.write(`${c.cyan}│${c.reset} ○ ${task.name}...`);
|
|
209
|
+
try {
|
|
210
|
+
const result = await task.fn();
|
|
211
|
+
process.stdout.write(`\r${c.cyan}│${c.reset} ${c.green}✓${c.reset} ${task.name} ${c.dim}${result || ''}${c.reset}\n`);
|
|
212
|
+
} catch (err) {
|
|
213
|
+
process.stdout.write(`\r${c.cyan}│${c.reset} ${c.red}✗${c.reset} ${task.name} ${c.red}${err.message}${c.reset}\n`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
console.log(`${c.cyan}│${c.reset}`);
|
|
218
|
+
console.log(`${c.cyan}└──────────────────────────────────────────────────────────────────────┘${c.reset}`);
|
|
219
|
+
console.log('');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
createConfig() {
|
|
223
|
+
const configPath = path.join(this.projectPath, '.vibecheckrc');
|
|
224
|
+
fs.writeFileSync(configPath, JSON.stringify(this.answers.config, null, 2));
|
|
225
|
+
return '';
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
createOutputDir() {
|
|
229
|
+
const outputDir = path.join(this.projectPath, '.vibecheck');
|
|
230
|
+
if (!fs.existsSync(outputDir)) {
|
|
231
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
232
|
+
}
|
|
233
|
+
return '';
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
updateGitignore() {
|
|
237
|
+
const gitignorePath = path.join(this.projectPath, '.gitignore');
|
|
238
|
+
const entry = '\n# vibecheck\n.vibecheck/\n';
|
|
239
|
+
|
|
240
|
+
if (fs.existsSync(gitignorePath)) {
|
|
241
|
+
const content = fs.readFileSync(gitignorePath, 'utf8');
|
|
242
|
+
if (!content.includes('.vibecheck/')) {
|
|
243
|
+
fs.appendFileSync(gitignorePath, entry);
|
|
244
|
+
return 'updated';
|
|
245
|
+
}
|
|
246
|
+
return 'already configured';
|
|
247
|
+
} else {
|
|
248
|
+
fs.writeFileSync(gitignorePath, entry.trim() + '\n');
|
|
249
|
+
return 'created';
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
createSchemas() {
|
|
254
|
+
const schemasDir = path.join(this.projectPath, '.vibecheck', 'schemas');
|
|
255
|
+
if (!fs.existsSync(schemasDir)) {
|
|
256
|
+
fs.mkdirSync(schemasDir, { recursive: true });
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Create truthpack schema
|
|
260
|
+
const truthpackSchema = {
|
|
261
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
262
|
+
"$id": "https://vibecheck.dev/schemas/truthpack.json",
|
|
263
|
+
"title": "Vibecheck Truthpack",
|
|
264
|
+
"type": "object",
|
|
265
|
+
"properties": {
|
|
266
|
+
"version": { "type": "string" },
|
|
267
|
+
"generatedAt": { "type": "string", "format": "date-time" },
|
|
268
|
+
"routes": { "type": "object" },
|
|
269
|
+
"env": { "type": "object" },
|
|
270
|
+
"auth": { "type": "object" },
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
fs.writeFileSync(
|
|
275
|
+
path.join(schemasDir, 'truthpack.schema.json'),
|
|
276
|
+
JSON.stringify(truthpackSchema, null, 2)
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
return '';
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
printNextSteps() {
|
|
283
|
+
console.log(`${c.green}${c.bold}✓ Vibecheck initialized successfully!${c.reset}`);
|
|
284
|
+
console.log('');
|
|
285
|
+
console.log(`${c.cyan}╔══════════════════════════════════════════════════════════════════════╗${c.reset}`);
|
|
286
|
+
console.log(`${c.cyan}║${c.reset} ${c.bold}Next Steps${c.reset} ${c.cyan}║${c.reset}`);
|
|
287
|
+
console.log(`${c.cyan}╠══════════════════════════════════════════════════════════════════════╣${c.reset}`);
|
|
288
|
+
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
289
|
+
console.log(`${c.cyan}║${c.reset} ${c.bold}1.${c.reset} Run your first scan: ${c.cyan}║${c.reset}`);
|
|
290
|
+
console.log(`${c.cyan}║${c.reset} ${c.cyan}vibecheck ship${c.reset} ${c.cyan}║${c.reset}`);
|
|
291
|
+
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
292
|
+
console.log(`${c.cyan}║${c.reset} ${c.bold}2.${c.reset} Review the report: ${c.cyan}║${c.reset}`);
|
|
293
|
+
console.log(`${c.cyan}║${c.reset} ${c.dim}Open .vibecheck/report.html in your browser${c.reset} ${c.cyan}║${c.reset}`);
|
|
294
|
+
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
295
|
+
console.log(`${c.cyan}║${c.reset} ${c.bold}3.${c.reset} Fix issues and re-scan: ${c.cyan}║${c.reset}`);
|
|
296
|
+
console.log(`${c.cyan}║${c.reset} ${c.cyan}vibecheck ship --fix${c.reset} ${c.cyan}║${c.reset}`);
|
|
297
|
+
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
298
|
+
console.log(`${c.cyan}║${c.reset} ${c.bold}4.${c.reset} Generate a client report: ${c.cyan}║${c.reset}`);
|
|
299
|
+
console.log(`${c.cyan}║${c.reset} ${c.cyan}vibecheck report --type=executive${c.reset} ${c.cyan}║${c.reset}`);
|
|
300
|
+
console.log(`${c.cyan}║${c.reset} ${c.cyan}║${c.reset}`);
|
|
301
|
+
console.log(`${c.cyan}╚══════════════════════════════════════════════════════════════════════╝${c.reset}`);
|
|
302
|
+
console.log('');
|
|
303
|
+
console.log(`${c.dim}Tip: Run ${c.cyan}vibecheck --help${c.dim} to see all available commands.${c.reset}`);
|
|
304
|
+
console.log('');
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
module.exports = { InitWizard };
|