@vibecheckai/cli 3.5.0 → 3.5.2
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/registry.js +214 -237
- package/bin/runners/cli-utils.js +33 -2
- package/bin/runners/context/analyzer.js +52 -1
- package/bin/runners/context/generators/cursor.js +2 -49
- package/bin/runners/context/git-context.js +3 -1
- package/bin/runners/context/team-conventions.js +33 -7
- package/bin/runners/lib/analysis-core.js +25 -5
- package/bin/runners/lib/analyzers.js +431 -481
- package/bin/runners/lib/default-config.js +127 -0
- package/bin/runners/lib/doctor/modules/security.js +3 -1
- package/bin/runners/lib/engine/ast-cache.js +210 -0
- package/bin/runners/lib/engine/auth-extractor.js +211 -0
- package/bin/runners/lib/engine/billing-extractor.js +112 -0
- package/bin/runners/lib/engine/enforcement-extractor.js +100 -0
- package/bin/runners/lib/engine/env-extractor.js +207 -0
- package/bin/runners/lib/engine/express-extractor.js +208 -0
- package/bin/runners/lib/engine/extractors.js +849 -0
- package/bin/runners/lib/engine/index.js +207 -0
- package/bin/runners/lib/engine/repo-index.js +514 -0
- package/bin/runners/lib/engine/types.js +124 -0
- package/bin/runners/lib/engines/accessibility-engine.js +18 -218
- package/bin/runners/lib/engines/api-consistency-engine.js +30 -335
- package/bin/runners/lib/engines/cross-file-analysis-engine.js +27 -292
- package/bin/runners/lib/engines/empty-catch-engine.js +17 -127
- package/bin/runners/lib/engines/mock-data-engine.js +10 -53
- package/bin/runners/lib/engines/performance-issues-engine.js +36 -176
- package/bin/runners/lib/engines/security-vulnerabilities-engine.js +54 -382
- package/bin/runners/lib/engines/type-aware-engine.js +39 -263
- package/bin/runners/lib/engines/vibecheck-engines/index.js +13 -122
- package/bin/runners/lib/engines/vibecheck-engines/lib/ast-cache.js +164 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/code-quality-engine.js +291 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/console-logs-engine.js +83 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/dead-code-engine.js +198 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/deprecated-api-engine.js +275 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/empty-catch-engine.js +167 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/file-filter.js +217 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/hardcoded-secrets-engine.js +73 -373
- package/bin/runners/lib/engines/vibecheck-engines/lib/mock-data-engine.js +140 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/parallel-processor.js +164 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/performance-issues-engine.js +234 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/type-aware-engine.js +217 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/unsafe-regex-engine.js +78 -0
- package/bin/runners/lib/entitlements-v2.js +73 -97
- package/bin/runners/lib/error-handler.js +44 -3
- package/bin/runners/lib/error-messages.js +289 -0
- package/bin/runners/lib/evidence-pack.js +7 -1
- package/bin/runners/lib/finding-id.js +69 -0
- package/bin/runners/lib/finding-sorter.js +89 -0
- package/bin/runners/lib/html-proof-report.js +700 -350
- package/bin/runners/lib/missions/plan.js +6 -46
- package/bin/runners/lib/missions/templates.js +0 -232
- package/bin/runners/lib/next-action.js +560 -0
- package/bin/runners/lib/prerequisites.js +149 -0
- package/bin/runners/lib/route-detection.js +137 -68
- package/bin/runners/lib/scan-output.js +91 -76
- package/bin/runners/lib/scan-runner.js +135 -0
- package/bin/runners/lib/schemas/ajv-validator.js +464 -0
- package/bin/runners/lib/schemas/error-envelope.schema.json +105 -0
- package/bin/runners/lib/schemas/finding-v3.schema.json +151 -0
- package/bin/runners/lib/schemas/report-artifact.schema.json +120 -0
- package/bin/runners/lib/schemas/run-request.schema.json +108 -0
- package/bin/runners/lib/schemas/validator.js +27 -0
- package/bin/runners/lib/schemas/verdict.schema.json +140 -0
- package/bin/runners/lib/ship-output-enterprise.js +23 -23
- package/bin/runners/lib/ship-output.js +75 -31
- package/bin/runners/lib/terminal-ui.js +6 -113
- package/bin/runners/lib/truth.js +351 -10
- package/bin/runners/lib/unified-cli-output.js +430 -603
- package/bin/runners/lib/unified-output.js +13 -9
- package/bin/runners/runAIAgent.js +10 -5
- package/bin/runners/runAgent.js +0 -3
- package/bin/runners/runAllowlist.js +389 -0
- package/bin/runners/runApprove.js +0 -33
- package/bin/runners/runAuth.js +73 -45
- package/bin/runners/runCheckpoint.js +51 -11
- package/bin/runners/runClassify.js +85 -21
- package/bin/runners/runContext.js +0 -3
- package/bin/runners/runDoctor.js +41 -28
- package/bin/runners/runEvidencePack.js +362 -0
- package/bin/runners/runFirewall.js +0 -3
- package/bin/runners/runFirewallHook.js +0 -3
- package/bin/runners/runFix.js +66 -76
- package/bin/runners/runGuard.js +18 -411
- package/bin/runners/runInit.js +113 -30
- package/bin/runners/runLabs.js +424 -0
- package/bin/runners/runMcp.js +19 -25
- package/bin/runners/runPolish.js +64 -240
- package/bin/runners/runPromptFirewall.js +12 -5
- package/bin/runners/runProve.js +57 -22
- package/bin/runners/runQuickstart.js +531 -0
- package/bin/runners/runReality.js +59 -68
- package/bin/runners/runReport.js +38 -33
- package/bin/runners/runRuntime.js +8 -5
- package/bin/runners/runScan.js +1413 -190
- package/bin/runners/runShip.js +113 -719
- package/bin/runners/runTruth.js +0 -3
- package/bin/runners/runValidate.js +13 -9
- package/bin/runners/runWatch.js +23 -14
- package/bin/scan.js +6 -1
- package/bin/vibecheck.js +204 -185
- package/mcp-server/deprecation-middleware.js +282 -0
- package/mcp-server/handlers/index.ts +15 -0
- package/mcp-server/handlers/tool-handler.ts +554 -0
- package/mcp-server/index-v1.js +698 -0
- package/mcp-server/index.js +210 -238
- package/mcp-server/lib/cache-wrapper.cjs +383 -0
- package/mcp-server/lib/error-envelope.js +138 -0
- package/mcp-server/lib/executor.ts +499 -0
- package/mcp-server/lib/index.ts +19 -0
- package/mcp-server/lib/rate-limiter.js +166 -0
- package/mcp-server/lib/sandbox.test.ts +519 -0
- package/mcp-server/lib/sandbox.ts +395 -0
- package/mcp-server/lib/types.ts +267 -0
- package/mcp-server/package.json +12 -3
- package/mcp-server/registry/tool-registry.js +794 -0
- package/mcp-server/registry/tools.json +605 -0
- package/mcp-server/registry.test.ts +334 -0
- package/mcp-server/tests/tier-gating.test.js +297 -0
- package/mcp-server/tier-auth.js +378 -45
- package/mcp-server/tools-v3.js +353 -442
- package/mcp-server/tsconfig.json +37 -0
- package/mcp-server/vibecheck-2.0-tools.js +14 -1
- package/package.json +1 -1
- package/bin/runners/lib/agent-firewall/learning/learning-engine.js +0 -849
- package/bin/runners/lib/audit-logger.js +0 -532
- package/bin/runners/lib/authority/authorities/architecture.js +0 -364
- package/bin/runners/lib/authority/authorities/compliance.js +0 -341
- package/bin/runners/lib/authority/authorities/human.js +0 -343
- package/bin/runners/lib/authority/authorities/quality.js +0 -420
- package/bin/runners/lib/authority/authorities/security.js +0 -228
- package/bin/runners/lib/authority/index.js +0 -293
- package/bin/runners/lib/bundle/bundle-intelligence.js +0 -846
- package/bin/runners/lib/cli-charts.js +0 -368
- package/bin/runners/lib/cli-config-display.js +0 -405
- package/bin/runners/lib/cli-demo.js +0 -275
- package/bin/runners/lib/cli-errors.js +0 -438
- package/bin/runners/lib/cli-help-formatter.js +0 -439
- package/bin/runners/lib/cli-interactive-menu.js +0 -509
- package/bin/runners/lib/cli-prompts.js +0 -441
- package/bin/runners/lib/cli-scan-cards.js +0 -362
- package/bin/runners/lib/compliance-reporter.js +0 -710
- package/bin/runners/lib/conductor/index.js +0 -671
- package/bin/runners/lib/easy/README.md +0 -123
- package/bin/runners/lib/easy/index.js +0 -140
- package/bin/runners/lib/easy/interactive-wizard.js +0 -788
- package/bin/runners/lib/easy/one-click-firewall.js +0 -564
- package/bin/runners/lib/easy/zero-config-reality.js +0 -714
- package/bin/runners/lib/engines/async-patterns-engine.js +0 -444
- package/bin/runners/lib/engines/bundle-size-engine.js +0 -433
- package/bin/runners/lib/engines/confidence-scoring.js +0 -276
- package/bin/runners/lib/engines/context-detection.js +0 -264
- package/bin/runners/lib/engines/database-patterns-engine.js +0 -429
- package/bin/runners/lib/engines/duplicate-code-engine.js +0 -354
- package/bin/runners/lib/engines/env-variables-engine.js +0 -458
- package/bin/runners/lib/engines/error-handling-engine.js +0 -437
- package/bin/runners/lib/engines/false-positive-prevention.js +0 -630
- package/bin/runners/lib/engines/framework-adapters/index.js +0 -607
- package/bin/runners/lib/engines/framework-detection.js +0 -508
- package/bin/runners/lib/engines/import-order-engine.js +0 -429
- package/bin/runners/lib/engines/naming-conventions-engine.js +0 -544
- package/bin/runners/lib/engines/noise-reduction-engine.js +0 -452
- package/bin/runners/lib/engines/orchestrator.js +0 -334
- package/bin/runners/lib/engines/react-patterns-engine.js +0 -457
- package/bin/runners/lib/engines/vibecheck-engines/lib/ai-hallucination-engine.js +0 -806
- package/bin/runners/lib/engines/vibecheck-engines/lib/smart-fix-engine.js +0 -577
- package/bin/runners/lib/engines/vibecheck-engines/lib/vibe-score-engine.js +0 -543
- package/bin/runners/lib/engines/vibecheck-engines.js +0 -514
- package/bin/runners/lib/enhanced-features/index.js +0 -305
- package/bin/runners/lib/enhanced-output.js +0 -631
- package/bin/runners/lib/enterprise.js +0 -300
- package/bin/runners/lib/firewall/command-validator.js +0 -351
- package/bin/runners/lib/firewall/config.js +0 -341
- package/bin/runners/lib/firewall/content-validator.js +0 -519
- package/bin/runners/lib/firewall/index.js +0 -101
- package/bin/runners/lib/firewall/path-validator.js +0 -256
- package/bin/runners/lib/intelligence/cross-repo-intelligence.js +0 -817
- package/bin/runners/lib/mcp-utils.js +0 -425
- package/bin/runners/lib/output/index.js +0 -1022
- package/bin/runners/lib/policy-engine.js +0 -652
- package/bin/runners/lib/polish/autofix/accessibility-fixes.js +0 -333
- package/bin/runners/lib/polish/autofix/async-handlers.js +0 -273
- package/bin/runners/lib/polish/autofix/dead-code.js +0 -280
- package/bin/runners/lib/polish/autofix/imports-optimizer.js +0 -344
- package/bin/runners/lib/polish/autofix/index.js +0 -200
- package/bin/runners/lib/polish/autofix/remove-consoles.js +0 -209
- package/bin/runners/lib/polish/autofix/strengthen-types.js +0 -245
- package/bin/runners/lib/polish/backend-checks.js +0 -148
- package/bin/runners/lib/polish/documentation-checks.js +0 -111
- package/bin/runners/lib/polish/frontend-checks.js +0 -168
- package/bin/runners/lib/polish/index.js +0 -71
- package/bin/runners/lib/polish/infrastructure-checks.js +0 -131
- package/bin/runners/lib/polish/library-detection.js +0 -175
- package/bin/runners/lib/polish/performance-checks.js +0 -100
- package/bin/runners/lib/polish/security-checks.js +0 -148
- package/bin/runners/lib/polish/utils.js +0 -203
- package/bin/runners/lib/prompt-builder.js +0 -540
- package/bin/runners/lib/proof-certificate.js +0 -634
- package/bin/runners/lib/reality/accessibility-audit.js +0 -946
- package/bin/runners/lib/reality/api-contract-validator.js +0 -1012
- package/bin/runners/lib/reality/chaos-engineering.js +0 -1084
- package/bin/runners/lib/reality/performance-tracker.js +0 -1077
- package/bin/runners/lib/reality/scenario-generator.js +0 -1404
- package/bin/runners/lib/reality/visual-regression.js +0 -852
- package/bin/runners/lib/reality-profiler.js +0 -717
- package/bin/runners/lib/replay/flight-recorder-viewer.js +0 -1160
- package/bin/runners/lib/review/ai-code-review.js +0 -832
- package/bin/runners/lib/rules/custom-rule-engine.js +0 -985
- package/bin/runners/lib/sbom-generator.js +0 -641
- package/bin/runners/lib/scan-output-enhanced.js +0 -512
- package/bin/runners/lib/security/owasp-scanner.js +0 -939
- package/bin/runners/lib/validators/contract-validator.js +0 -283
- package/bin/runners/lib/validators/dead-export-detector.js +0 -279
- package/bin/runners/lib/validators/dep-audit.js +0 -245
- package/bin/runners/lib/validators/env-validator.js +0 -319
- package/bin/runners/lib/validators/index.js +0 -120
- package/bin/runners/lib/validators/license-checker.js +0 -252
- package/bin/runners/lib/validators/route-validator.js +0 -290
- package/bin/runners/runAuthority.js +0 -528
- package/bin/runners/runConductor.js +0 -772
- package/bin/runners/runContainer.js +0 -366
- package/bin/runners/runEasy.js +0 -410
- package/bin/runners/runIaC.js +0 -372
- package/bin/runners/runVibe.js +0 -791
- package/mcp-server/tools.js +0 -495
|
@@ -1,438 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI Errors - Unified error handling and display for Vibecheck CLI
|
|
3
|
-
*
|
|
4
|
-
* Provides:
|
|
5
|
-
* - Beautiful error messages
|
|
6
|
-
* - Error categories with icons
|
|
7
|
-
* - Stack trace formatting
|
|
8
|
-
* - Suggestions/fixes for common errors
|
|
9
|
-
* - Debug mode output
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
"use strict";
|
|
13
|
-
|
|
14
|
-
const {
|
|
15
|
-
ansi,
|
|
16
|
-
sym,
|
|
17
|
-
box,
|
|
18
|
-
padRight,
|
|
19
|
-
SUPPORTS_UNICODE,
|
|
20
|
-
formatDuration,
|
|
21
|
-
} = require("./unified-cli-output");
|
|
22
|
-
|
|
23
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
24
|
-
// ERROR CATEGORIES
|
|
25
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
26
|
-
|
|
27
|
-
const ERROR_TYPES = {
|
|
28
|
-
AUTH: {
|
|
29
|
-
code: 'AUTH',
|
|
30
|
-
icon: sym.lock,
|
|
31
|
-
color: ansi.yellow,
|
|
32
|
-
label: 'Authentication Error',
|
|
33
|
-
},
|
|
34
|
-
NETWORK: {
|
|
35
|
-
code: 'NETWORK',
|
|
36
|
-
icon: '🌐',
|
|
37
|
-
color: ansi.yellow,
|
|
38
|
-
label: 'Network Error',
|
|
39
|
-
},
|
|
40
|
-
CONFIG: {
|
|
41
|
-
code: 'CONFIG',
|
|
42
|
-
icon: sym.gear,
|
|
43
|
-
color: ansi.yellow,
|
|
44
|
-
label: 'Configuration Error',
|
|
45
|
-
},
|
|
46
|
-
PERMISSION: {
|
|
47
|
-
code: 'PERMISSION',
|
|
48
|
-
icon: sym.lock,
|
|
49
|
-
color: ansi.red,
|
|
50
|
-
label: 'Permission Error',
|
|
51
|
-
},
|
|
52
|
-
NOT_FOUND: {
|
|
53
|
-
code: 'NOT_FOUND',
|
|
54
|
-
icon: sym.search,
|
|
55
|
-
color: ansi.yellow,
|
|
56
|
-
label: 'Not Found',
|
|
57
|
-
},
|
|
58
|
-
VALIDATION: {
|
|
59
|
-
code: 'VALIDATION',
|
|
60
|
-
icon: sym.warning,
|
|
61
|
-
color: ansi.yellow,
|
|
62
|
-
label: 'Validation Error',
|
|
63
|
-
},
|
|
64
|
-
TIER: {
|
|
65
|
-
code: 'TIER',
|
|
66
|
-
icon: sym.star,
|
|
67
|
-
color: ansi.magenta,
|
|
68
|
-
label: 'Upgrade Required',
|
|
69
|
-
},
|
|
70
|
-
INTERNAL: {
|
|
71
|
-
code: 'INTERNAL',
|
|
72
|
-
icon: sym.cross,
|
|
73
|
-
color: ansi.red,
|
|
74
|
-
label: 'Internal Error',
|
|
75
|
-
},
|
|
76
|
-
TIMEOUT: {
|
|
77
|
-
code: 'TIMEOUT',
|
|
78
|
-
icon: sym.clock,
|
|
79
|
-
color: ansi.yellow,
|
|
80
|
-
label: 'Timeout Error',
|
|
81
|
-
},
|
|
82
|
-
SCAN: {
|
|
83
|
-
code: 'SCAN',
|
|
84
|
-
icon: sym.search,
|
|
85
|
-
color: ansi.red,
|
|
86
|
-
label: 'Scan Error',
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
91
|
-
// COMMON ERROR SUGGESTIONS
|
|
92
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
93
|
-
|
|
94
|
-
const ERROR_SUGGESTIONS = {
|
|
95
|
-
// Auth errors
|
|
96
|
-
'invalid api key': [
|
|
97
|
-
'Check that your API key is correct',
|
|
98
|
-
'Get a new key at: https://vibecheckai.dev/settings/keys',
|
|
99
|
-
'Run: vibecheck login',
|
|
100
|
-
],
|
|
101
|
-
'not authenticated': [
|
|
102
|
-
'Run: vibecheck login',
|
|
103
|
-
'Or set VIBECHECK_API_KEY environment variable',
|
|
104
|
-
],
|
|
105
|
-
'api key expired': [
|
|
106
|
-
'Your API key has expired',
|
|
107
|
-
'Get a new key at: https://vibecheckai.dev/settings/keys',
|
|
108
|
-
],
|
|
109
|
-
|
|
110
|
-
// Network errors
|
|
111
|
-
'enotfound': [
|
|
112
|
-
'Check your internet connection',
|
|
113
|
-
'Verify DNS settings',
|
|
114
|
-
'Try again in a few moments',
|
|
115
|
-
],
|
|
116
|
-
'etimedout': [
|
|
117
|
-
'Request timed out - server may be slow',
|
|
118
|
-
'Check your internet connection',
|
|
119
|
-
'Try again with: --timeout 60',
|
|
120
|
-
],
|
|
121
|
-
'econnrefused': [
|
|
122
|
-
'Could not connect to server',
|
|
123
|
-
'Check if the server is running',
|
|
124
|
-
'Verify the URL is correct',
|
|
125
|
-
],
|
|
126
|
-
|
|
127
|
-
// Config errors
|
|
128
|
-
'config not found': [
|
|
129
|
-
'Run: vibecheck init',
|
|
130
|
-
'Or create .vibecheckrc manually',
|
|
131
|
-
],
|
|
132
|
-
'invalid config': [
|
|
133
|
-
'Check your .vibecheckrc file for syntax errors',
|
|
134
|
-
'Run: vibecheck doctor --fix',
|
|
135
|
-
],
|
|
136
|
-
|
|
137
|
-
// Permission errors
|
|
138
|
-
'eacces': [
|
|
139
|
-
'Permission denied',
|
|
140
|
-
'Check file/folder permissions',
|
|
141
|
-
'Try running with appropriate permissions',
|
|
142
|
-
],
|
|
143
|
-
|
|
144
|
-
// Tier errors
|
|
145
|
-
'feature requires': [
|
|
146
|
-
'This feature requires a higher tier',
|
|
147
|
-
'Upgrade at: https://vibecheckai.dev/pricing',
|
|
148
|
-
],
|
|
149
|
-
'limit exceeded': [
|
|
150
|
-
'You have exceeded your plan limits',
|
|
151
|
-
'Upgrade for more capacity: https://vibecheckai.dev/pricing',
|
|
152
|
-
],
|
|
153
|
-
|
|
154
|
-
// Scan errors
|
|
155
|
-
'no files found': [
|
|
156
|
-
'No scannable files found in the project',
|
|
157
|
-
'Check that you are in the correct directory',
|
|
158
|
-
'Verify your .vibecheckignore patterns',
|
|
159
|
-
],
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
163
|
-
// ERROR CLASS
|
|
164
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
165
|
-
|
|
166
|
-
class CLIError extends Error {
|
|
167
|
-
constructor(message, options = {}) {
|
|
168
|
-
super(message);
|
|
169
|
-
this.name = 'CLIError';
|
|
170
|
-
this.type = options.type || ERROR_TYPES.INTERNAL;
|
|
171
|
-
this.code = options.code || this.type.code;
|
|
172
|
-
this.suggestions = options.suggestions || [];
|
|
173
|
-
this.details = options.details || null;
|
|
174
|
-
this.cause = options.cause || null;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
179
|
-
// ERROR DISPLAY
|
|
180
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Display a formatted error message
|
|
184
|
-
* @param {Error|CLIError|string} error
|
|
185
|
-
* @param {Object} options
|
|
186
|
-
*/
|
|
187
|
-
function displayError(error, options = {}) {
|
|
188
|
-
const { showStack = false, showSuggestions = true, json = false } = options;
|
|
189
|
-
|
|
190
|
-
// Handle string errors
|
|
191
|
-
if (typeof error === 'string') {
|
|
192
|
-
error = new CLIError(error);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Determine error type
|
|
196
|
-
const errorType = error.type || detectErrorType(error);
|
|
197
|
-
const config = errorType;
|
|
198
|
-
|
|
199
|
-
// Get suggestions
|
|
200
|
-
const suggestions = error.suggestions?.length > 0
|
|
201
|
-
? error.suggestions
|
|
202
|
-
: findSuggestions(error.message);
|
|
203
|
-
|
|
204
|
-
// JSON output
|
|
205
|
-
if (json) {
|
|
206
|
-
console.log(JSON.stringify({
|
|
207
|
-
success: false,
|
|
208
|
-
error: {
|
|
209
|
-
code: config.code,
|
|
210
|
-
message: error.message,
|
|
211
|
-
suggestions,
|
|
212
|
-
stack: showStack ? error.stack : undefined,
|
|
213
|
-
}
|
|
214
|
-
}, null, 2));
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Visual output
|
|
219
|
-
console.log();
|
|
220
|
-
console.log(` ${config.color}${config.icon}${ansi.reset} ${ansi.bold}${config.label}${ansi.reset}`);
|
|
221
|
-
console.log(` ${ansi.gray}${box.horizontal.repeat(60)}${ansi.reset}`);
|
|
222
|
-
console.log();
|
|
223
|
-
console.log(` ${error.message}`);
|
|
224
|
-
|
|
225
|
-
// Details
|
|
226
|
-
if (error.details) {
|
|
227
|
-
console.log();
|
|
228
|
-
console.log(` ${ansi.dim}Details:${ansi.reset}`);
|
|
229
|
-
if (typeof error.details === 'object') {
|
|
230
|
-
for (const [key, value] of Object.entries(error.details)) {
|
|
231
|
-
console.log(` ${ansi.gray}${key}:${ansi.reset} ${value}`);
|
|
232
|
-
}
|
|
233
|
-
} else {
|
|
234
|
-
console.log(` ${error.details}`);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Suggestions
|
|
239
|
-
if (showSuggestions && suggestions.length > 0) {
|
|
240
|
-
console.log();
|
|
241
|
-
console.log(` ${ansi.cyan}${sym.info}${ansi.reset} ${ansi.dim}Suggestions:${ansi.reset}`);
|
|
242
|
-
for (const suggestion of suggestions) {
|
|
243
|
-
console.log(` ${ansi.gray}${sym.arrow}${ansi.reset} ${suggestion}`);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// Stack trace (debug mode)
|
|
248
|
-
if (showStack && error.stack) {
|
|
249
|
-
console.log();
|
|
250
|
-
console.log(` ${ansi.dim}Stack trace:${ansi.reset}`);
|
|
251
|
-
const stackLines = error.stack.split('\n').slice(1, 6);
|
|
252
|
-
for (const line of stackLines) {
|
|
253
|
-
console.log(` ${ansi.gray}${line.trim()}${ansi.reset}`);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
console.log();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Detect error type from error object
|
|
262
|
-
* @param {Error} error
|
|
263
|
-
*/
|
|
264
|
-
function detectErrorType(error) {
|
|
265
|
-
const message = (error.message || '').toLowerCase();
|
|
266
|
-
const code = (error.code || '').toLowerCase();
|
|
267
|
-
|
|
268
|
-
// Auth errors
|
|
269
|
-
if (message.includes('auth') || message.includes('api key') || message.includes('unauthorized') || code === 'unauthorized') {
|
|
270
|
-
return ERROR_TYPES.AUTH;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Network errors
|
|
274
|
-
if (code === 'enotfound' || code === 'etimedout' || code === 'econnrefused' || code === 'econnreset' ||
|
|
275
|
-
message.includes('network') || message.includes('connection')) {
|
|
276
|
-
return ERROR_TYPES.NETWORK;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Config errors
|
|
280
|
-
if (message.includes('config') || message.includes('.vibecheckrc')) {
|
|
281
|
-
return ERROR_TYPES.CONFIG;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// Permission errors
|
|
285
|
-
if (code === 'eacces' || code === 'eperm' || message.includes('permission')) {
|
|
286
|
-
return ERROR_TYPES.PERMISSION;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// Not found
|
|
290
|
-
if (code === 'enoent' || message.includes('not found') || message.includes('does not exist')) {
|
|
291
|
-
return ERROR_TYPES.NOT_FOUND;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// Validation
|
|
295
|
-
if (message.includes('invalid') || message.includes('validation')) {
|
|
296
|
-
return ERROR_TYPES.VALIDATION;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// Tier/upgrade
|
|
300
|
-
if (message.includes('upgrade') || message.includes('tier') || message.includes('requires')) {
|
|
301
|
-
return ERROR_TYPES.TIER;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// Timeout
|
|
305
|
-
if (message.includes('timeout') || code === 'etimedout') {
|
|
306
|
-
return ERROR_TYPES.TIMEOUT;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
return ERROR_TYPES.INTERNAL;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Find suggestions based on error message
|
|
314
|
-
* @param {string} message
|
|
315
|
-
*/
|
|
316
|
-
function findSuggestions(message) {
|
|
317
|
-
const lower = (message || '').toLowerCase();
|
|
318
|
-
|
|
319
|
-
for (const [pattern, suggestions] of Object.entries(ERROR_SUGGESTIONS)) {
|
|
320
|
-
if (lower.includes(pattern)) {
|
|
321
|
-
return suggestions;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return [];
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
329
|
-
// ERROR BOUNDARY
|
|
330
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Wrap an async function with error handling
|
|
334
|
-
* @param {Function} fn - Async function to wrap
|
|
335
|
-
* @param {Object} options
|
|
336
|
-
*/
|
|
337
|
-
function withErrorHandler(fn, options = {}) {
|
|
338
|
-
return async (...args) => {
|
|
339
|
-
try {
|
|
340
|
-
return await fn(...args);
|
|
341
|
-
} catch (error) {
|
|
342
|
-
displayError(error, options);
|
|
343
|
-
|
|
344
|
-
// Return appropriate exit code
|
|
345
|
-
const errorType = error.type || detectErrorType(error);
|
|
346
|
-
switch (errorType.code) {
|
|
347
|
-
case 'AUTH': return 10;
|
|
348
|
-
case 'NETWORK': return 11;
|
|
349
|
-
case 'CONFIG': return 12;
|
|
350
|
-
case 'PERMISSION': return 13;
|
|
351
|
-
case 'NOT_FOUND': return 14;
|
|
352
|
-
case 'VALIDATION': return 15;
|
|
353
|
-
case 'TIER': return 16;
|
|
354
|
-
case 'TIMEOUT': return 17;
|
|
355
|
-
default: return 1;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
362
|
-
// WARNING DISPLAY
|
|
363
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Display a warning message
|
|
367
|
-
* @param {string} message
|
|
368
|
-
* @param {Object} options
|
|
369
|
-
*/
|
|
370
|
-
function displayWarning(message, options = {}) {
|
|
371
|
-
const { suggestions = [] } = options;
|
|
372
|
-
|
|
373
|
-
console.log(` ${ansi.yellow}${sym.warning}${ansi.reset} ${ansi.bold}Warning${ansi.reset}`);
|
|
374
|
-
console.log(` ${message}`);
|
|
375
|
-
|
|
376
|
-
if (suggestions.length > 0) {
|
|
377
|
-
console.log();
|
|
378
|
-
for (const suggestion of suggestions) {
|
|
379
|
-
console.log(` ${ansi.gray}${sym.arrow}${ansi.reset} ${suggestion}`);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
console.log();
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
386
|
-
// CRASH REPORT
|
|
387
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Display a crash report for unexpected errors
|
|
391
|
-
* @param {Error} error
|
|
392
|
-
*/
|
|
393
|
-
function displayCrashReport(error) {
|
|
394
|
-
console.log();
|
|
395
|
-
console.log(` ${ansi.red}${box.topLeft}${box.horizontal.repeat(66)}${box.topRight}${ansi.reset}`);
|
|
396
|
-
console.log(` ${ansi.red}${box.vertical}${ansi.reset} ${ansi.bold}${ansi.red}UNEXPECTED ERROR${ansi.reset}${' '.repeat(49)}${ansi.red}${box.vertical}${ansi.reset}`);
|
|
397
|
-
console.log(` ${ansi.red}${box.vertical}${box.horizontal.repeat(66)}${box.vertical}${ansi.reset}`);
|
|
398
|
-
console.log(` ${ansi.red}${box.vertical}${ansi.reset} ${ansi.red}${box.vertical}${ansi.reset}`);
|
|
399
|
-
console.log(` ${ansi.red}${box.vertical}${ansi.reset} An unexpected error occurred. This is likely a bug. ${ansi.red}${box.vertical}${ansi.reset}`);
|
|
400
|
-
console.log(` ${ansi.red}${box.vertical}${ansi.reset} ${ansi.red}${box.vertical}${ansi.reset}`);
|
|
401
|
-
console.log(` ${ansi.red}${box.vertical}${ansi.reset} ${ansi.dim}Error:${ansi.reset} ${padRight(error.message?.slice(0, 50) || 'Unknown', 52)} ${ansi.red}${box.vertical}${ansi.reset}`);
|
|
402
|
-
console.log(` ${ansi.red}${box.vertical}${ansi.reset} ${ansi.red}${box.vertical}${ansi.reset}`);
|
|
403
|
-
console.log(` ${ansi.red}${box.vertical}${ansi.reset} Please report this issue: ${ansi.red}${box.vertical}${ansi.reset}`);
|
|
404
|
-
console.log(` ${ansi.red}${box.vertical}${ansi.reset} ${ansi.cyan}https://github.com/vibecheckai/vibecheck/issues${ansi.reset} ${ansi.red}${box.vertical}${ansi.reset}`);
|
|
405
|
-
console.log(` ${ansi.red}${box.vertical}${ansi.reset} ${ansi.red}${box.vertical}${ansi.reset}`);
|
|
406
|
-
console.log(` ${ansi.red}${box.bottomLeft}${box.horizontal.repeat(66)}${box.bottomRight}${ansi.reset}`);
|
|
407
|
-
|
|
408
|
-
if (process.env.DEBUG || process.env.VIBECHECK_DEBUG) {
|
|
409
|
-
console.log();
|
|
410
|
-
console.log(` ${ansi.dim}Stack trace:${ansi.reset}`);
|
|
411
|
-
const stackLines = (error.stack || '').split('\n').slice(1, 10);
|
|
412
|
-
for (const line of stackLines) {
|
|
413
|
-
console.log(` ${ansi.gray}${line.trim()}${ansi.reset}`);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
console.log();
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
421
|
-
// EXPORTS
|
|
422
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
423
|
-
|
|
424
|
-
module.exports = {
|
|
425
|
-
// Error types
|
|
426
|
-
ERROR_TYPES,
|
|
427
|
-
CLIError,
|
|
428
|
-
|
|
429
|
-
// Display functions
|
|
430
|
-
displayError,
|
|
431
|
-
displayWarning,
|
|
432
|
-
displayCrashReport,
|
|
433
|
-
|
|
434
|
-
// Utilities
|
|
435
|
-
detectErrorType,
|
|
436
|
-
findSuggestions,
|
|
437
|
-
withErrorHandler,
|
|
438
|
-
};
|