@vibecheckai/cli 2.5.7 → 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/LICENSE +1 -1
- package/dist/bundles/vibecheck-core.js +20 -20
- package/dist/commands/secrets-allowlist.js +4 -4
- package/dist/commands/secrets-allowlist.js.map +1 -1
- package/dist/commands/ship-consolidated.js +193 -193
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/init/ci-generator.d.ts +2 -2
- package/dist/init/hooks-installer.d.ts +2 -2
- package/dist/init/index.d.ts +1 -1
- package/dist/init/index.d.ts.map +1 -1
- package/dist/init/index.js +2 -2
- package/dist/init/index.js.map +1 -1
- package/dist/init/templates.d.ts +6 -285
- package/dist/init/templates.d.ts.map +1 -1
- package/dist/init/templates.js +2 -3
- package/dist/init/templates.js.map +1 -1
- package/dist/runtime/json-output.d.ts +2 -2
- package/package.json +11 -3
- package/dist/bundles/guardrail-core.js +0 -25799
- package/dist/bundles/guardrail-security.js +0 -208687
- package/dist/bundles/guardrail-ship.js +0 -2318
- package/dist/commands/autopilot-decision.d.ts +0 -24
- package/dist/commands/autopilot-decision.d.ts.map +0 -1
- package/dist/commands/autopilot-decision.js +0 -304
- package/dist/commands/autopilot-decision.js.map +0 -1
- package/dist/commands/autopilot.d.ts +0 -33
- package/dist/commands/autopilot.d.ts.map +0 -1
- package/dist/commands/autopilot.js +0 -1539
- package/dist/commands/autopilot.js.map +0 -1
- package/dist/commands/context.d.ts +0 -8
- package/dist/commands/context.d.ts.map +0 -1
- package/dist/commands/context.js +0 -340
- package/dist/commands/context.js.map +0 -1
- package/dist/commands/debug.d.ts +0 -78
- package/dist/commands/debug.d.ts.map +0 -1
- package/dist/commands/debug.js +0 -381
- package/dist/commands/debug.js.map +0 -1
- package/dist/commands/preview.d.ts +0 -54
- package/dist/commands/preview.d.ts.map +0 -1
- package/dist/commands/preview.js +0 -352
- package/dist/commands/preview.js.map +0 -1
- package/dist/commands/quality/check.d.ts +0 -31
- package/dist/commands/quality/check.d.ts.map +0 -1
- package/dist/commands/quality/check.js +0 -242
- package/dist/commands/quality/check.js.map +0 -1
- package/dist/commands/quality/index.d.ts +0 -8
- package/dist/commands/quality/index.d.ts.map +0 -1
- package/dist/commands/quality/index.js +0 -14
- package/dist/commands/quality/index.js.map +0 -1
- package/dist/commands/quality/setup-quality.d.ts +0 -23
- package/dist/commands/quality/setup-quality.d.ts.map +0 -1
- package/dist/commands/quality/setup-quality.js +0 -452
- package/dist/commands/quality/setup-quality.js.map +0 -1
- package/dist/commands/quality/tidy.d.ts +0 -41
- package/dist/commands/quality/tidy.d.ts.map +0 -1
- package/dist/commands/quality/tidy.js +0 -466
- package/dist/commands/quality/tidy.js.map +0 -1
- package/dist/commands/quality/utils.d.ts +0 -73
- package/dist/commands/quality/utils.d.ts.map +0 -1
- package/dist/commands/quality/utils.js +0 -158
- package/dist/commands/quality/utils.js.map +0 -1
- package/dist/fix/analytics.d.ts +0 -121
- package/dist/fix/analytics.d.ts.map +0 -1
- package/dist/fix/analytics.js +0 -289
- package/dist/fix/analytics.js.map +0 -1
- package/dist/fix/audit.d.ts +0 -61
- package/dist/fix/audit.d.ts.map +0 -1
- package/dist/fix/audit.js +0 -149
- package/dist/fix/audit.js.map +0 -1
- package/dist/fix/config.d.ts +0 -78
- package/dist/fix/config.d.ts.map +0 -1
- package/dist/fix/config.js +0 -200
- package/dist/fix/config.js.map +0 -1
- package/dist/fix/impact.d.ts +0 -74
- package/dist/fix/impact.d.ts.map +0 -1
- package/dist/fix/impact.js +0 -281
- package/dist/fix/impact.js.map +0 -1
- package/dist/fix/learning.d.ts +0 -109
- package/dist/fix/learning.d.ts.map +0 -1
- package/dist/fix/learning.js +0 -296
- package/dist/fix/learning.js.map +0 -1
- package/dist/fix/metrics.d.ts +0 -106
- package/dist/fix/metrics.d.ts.map +0 -1
- package/dist/fix/metrics.js +0 -138
- package/dist/fix/metrics.js.map +0 -1
- package/dist/fix/parallel.d.ts +0 -69
- package/dist/fix/parallel.d.ts.map +0 -1
- package/dist/fix/parallel.js +0 -203
- package/dist/fix/parallel.js.map +0 -1
- package/dist/fix/report.d.ts +0 -40
- package/dist/fix/report.d.ts.map +0 -1
- package/dist/fix/report.js +0 -212
- package/dist/fix/report.js.map +0 -1
- package/dist/fix/strategy.d.ts +0 -53
- package/dist/fix/strategy.d.ts.map +0 -1
- package/dist/fix/strategy.js +0 -143
- package/dist/fix/strategy.js.map +0 -1
- package/dist/fix/templates.d.ts +0 -58
- package/dist/fix/templates.d.ts.map +0 -1
- package/dist/fix/templates.js +0 -259
- package/dist/fix/templates.js.map +0 -1
- package/dist/fix/testing.d.ts +0 -68
- package/dist/fix/testing.d.ts.map +0 -1
- package/dist/fix/testing.js +0 -245
- package/dist/fix/testing.js.map +0 -1
- package/dist/fix/validation.d.ts +0 -71
- package/dist/fix/validation.d.ts.map +0 -1
- package/dist/fix/validation.js +0 -267
- package/dist/fix/validation.js.map +0 -1
- package/dist/fix/visualization.d.ts +0 -73
- package/dist/fix/visualization.d.ts.map +0 -1
- package/dist/fix/visualization.js +0 -243
- package/dist/fix/visualization.js.map +0 -1
- package/dist/runtime/cli-errors.d.ts +0 -38
- package/dist/runtime/cli-errors.d.ts.map +0 -1
- package/dist/runtime/cli-errors.js +0 -354
- package/dist/runtime/cli-errors.js.map +0 -1
- package/dist/runtime/owner-mode.d.ts +0 -48
- package/dist/runtime/owner-mode.d.ts.map +0 -1
- package/dist/runtime/owner-mode.js +0 -284
- package/dist/runtime/owner-mode.js.map +0 -1
- package/dist/scanner/index.d.ts +0 -8
- package/dist/scanner/index.d.ts.map +0 -1
- package/dist/scanner/index.js +0 -15
- package/dist/scanner/index.js.map +0 -1
- package/dist/scanner/placeholder-detector.d.ts +0 -56
- package/dist/scanner/placeholder-detector.d.ts.map +0 -1
- package/dist/scanner/placeholder-detector.js +0 -220
- package/dist/scanner/placeholder-detector.js.map +0 -1
- package/dist/scanner/route-detector.d.ts +0 -100
- package/dist/scanner/route-detector.d.ts.map +0 -1
- package/dist/scanner/route-detector.js +0 -455
- package/dist/scanner/route-detector.js.map +0 -1
- package/dist/scanner/scoring.d.ts +0 -67
- package/dist/scanner/scoring.d.ts.map +0 -1
- package/dist/scanner/scoring.js +0 -284
- package/dist/scanner/scoring.js.map +0 -1
- package/dist/ship-baseline.d.ts +0 -56
- package/dist/ship-baseline.d.ts.map +0 -1
- package/dist/ship-baseline.js +0 -194
- package/dist/ship-baseline.js.map +0 -1
- package/dist/ship-config.d.ts +0 -91
- package/dist/ship-config.d.ts.map +0 -1
- package/dist/ship-config.js +0 -133
- package/dist/ship-config.js.map +0 -1
- package/dist/ship-data-loader.d.ts +0 -70
- package/dist/ship-data-loader.d.ts.map +0 -1
- package/dist/ship-data-loader.js +0 -301
- package/dist/ship-data-loader.js.map +0 -1
- package/dist/utils/ai-helpers.d.ts +0 -72
- package/dist/utils/ai-helpers.d.ts.map +0 -1
- package/dist/utils/ai-helpers.js +0 -339
- package/dist/utils/ai-helpers.js.map +0 -1
- package/dist/utils/validation.d.ts +0 -34
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -160
- package/dist/utils/validation.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"visualization.d.ts","sourceRoot":"","sources":["../../src/fix/visualization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAO,MAAM,UAAU,CAAC;AAIxC,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ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
|
6
|
-
* context lines, and interactive preview capabilities.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.DiffVisualizer = void 0;
|
|
10
|
-
const fs_1 = require("fs");
|
|
11
|
-
const path_1 = require("path");
|
|
12
|
-
class DiffVisualizer {
|
|
13
|
-
constructor(projectPath, contextLines = 3) {
|
|
14
|
-
this.projectPath = projectPath;
|
|
15
|
-
this.contextLines = contextLines;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Generate unified diff visualization
|
|
19
|
-
*/
|
|
20
|
-
visualize(packs) {
|
|
21
|
-
const filesMap = new Map();
|
|
22
|
-
let totalAdditions = 0;
|
|
23
|
-
let totalDeletions = 0;
|
|
24
|
-
// Group fixes by file
|
|
25
|
-
for (const pack of packs) {
|
|
26
|
-
for (const fix of pack.fixes) {
|
|
27
|
-
if (!filesMap.has(fix.file)) {
|
|
28
|
-
filesMap.set(fix.file, {
|
|
29
|
-
file: fix.file,
|
|
30
|
-
hunks: [],
|
|
31
|
-
summary: { additions: 0, deletions: 0, changes: 0 },
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
const fileDiff = filesMap.get(fix.file);
|
|
35
|
-
const hunk = this.createHunk(fix);
|
|
36
|
-
fileDiff.hunks.push(hunk);
|
|
37
|
-
fileDiff.summary.additions += hunk.changes.filter((c) => c.type === 'add').length;
|
|
38
|
-
fileDiff.summary.deletions += hunk.changes.filter((c) => c.type === 'delete').length;
|
|
39
|
-
fileDiff.summary.changes =
|
|
40
|
-
fileDiff.summary.additions + fileDiff.summary.deletions;
|
|
41
|
-
totalAdditions += fileDiff.summary.additions;
|
|
42
|
-
totalDeletions += fileDiff.summary.deletions;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
files: Array.from(filesMap.values()),
|
|
47
|
-
summary: {
|
|
48
|
-
totalFiles: filesMap.size,
|
|
49
|
-
totalAdditions,
|
|
50
|
-
totalDeletions,
|
|
51
|
-
totalChanges: totalAdditions + totalDeletions,
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Create a hunk for a single fix
|
|
57
|
-
*/
|
|
58
|
-
createHunk(fix) {
|
|
59
|
-
const filePath = (0, path_1.join)(this.projectPath, fix.file);
|
|
60
|
-
const fileContent = (0, fs_1.existsSync)(filePath)
|
|
61
|
-
? (0, fs_1.readFileSync)(filePath, 'utf-8').split('\n')
|
|
62
|
-
: [];
|
|
63
|
-
const changes = [];
|
|
64
|
-
// Get context lines before
|
|
65
|
-
const contextBefore = [];
|
|
66
|
-
for (let i = Math.max(0, fix.line - this.contextLines - 1); i < fix.line - 1; i++) {
|
|
67
|
-
contextBefore.push({
|
|
68
|
-
type: 'context',
|
|
69
|
-
line: fileContent[i] || '',
|
|
70
|
-
oldLineNumber: i + 1,
|
|
71
|
-
newLineNumber: i + 1,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
// Get the actual change
|
|
75
|
-
const oldLines = fix.oldCode.split('\n');
|
|
76
|
-
const newLines = fix.newCode.split('\n');
|
|
77
|
-
// Deletion
|
|
78
|
-
for (let i = 0; i < oldLines.length; i++) {
|
|
79
|
-
changes.push({
|
|
80
|
-
type: 'delete',
|
|
81
|
-
line: oldLines[i],
|
|
82
|
-
oldLineNumber: fix.line + i,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
// Addition
|
|
86
|
-
for (let i = 0; i < newLines.length; i++) {
|
|
87
|
-
changes.push({
|
|
88
|
-
type: 'add',
|
|
89
|
-
line: newLines[i],
|
|
90
|
-
newLineNumber: fix.line + i,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
// Get context lines after
|
|
94
|
-
const contextAfter = [];
|
|
95
|
-
const lastLine = fix.line + oldLines.length - 1;
|
|
96
|
-
for (let i = lastLine; i < Math.min(fileContent.length, lastLine + this.contextLines); i++) {
|
|
97
|
-
contextAfter.push({
|
|
98
|
-
type: 'context',
|
|
99
|
-
line: fileContent[i] || '',
|
|
100
|
-
oldLineNumber: i + 1,
|
|
101
|
-
newLineNumber: i + 1 + (newLines.length - oldLines.length),
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
const allChanges = [...contextBefore, ...changes, ...contextAfter];
|
|
105
|
-
return {
|
|
106
|
-
oldStart: fix.line,
|
|
107
|
-
oldLines: oldLines.length,
|
|
108
|
-
newStart: fix.line,
|
|
109
|
-
newLines: newLines.length,
|
|
110
|
-
context: [],
|
|
111
|
-
changes: allChanges,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Generate unified diff string (compatible with git diff)
|
|
116
|
-
*/
|
|
117
|
-
generateUnifiedDiff(packs) {
|
|
118
|
-
const visualization = this.visualize(packs);
|
|
119
|
-
const lines = [];
|
|
120
|
-
for (const file of visualization.files) {
|
|
121
|
-
lines.push(`--- a/${file.file}`);
|
|
122
|
-
lines.push(`+++ b/${file.file}`);
|
|
123
|
-
lines.push('@@');
|
|
124
|
-
for (const hunk of file.hunks) {
|
|
125
|
-
lines.push(`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`);
|
|
126
|
-
for (const change of hunk.changes) {
|
|
127
|
-
if (change.type === 'context') {
|
|
128
|
-
lines.push(` ${change.line}`);
|
|
129
|
-
}
|
|
130
|
-
else if (change.type === 'delete') {
|
|
131
|
-
lines.push(`-${change.line}`);
|
|
132
|
-
}
|
|
133
|
-
else if (change.type === 'add') {
|
|
134
|
-
lines.push(`+${change.line}`);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
lines.push('');
|
|
139
|
-
}
|
|
140
|
-
return lines.join('\n');
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Generate colored terminal output
|
|
144
|
-
*/
|
|
145
|
-
generateColoredDiff(packs) {
|
|
146
|
-
const visualization = this.visualize(packs);
|
|
147
|
-
const lines = [];
|
|
148
|
-
for (const file of visualization.files) {
|
|
149
|
-
lines.push(`\x1b[1m\x1b[36m${file.file}\x1b[0m`);
|
|
150
|
-
lines.push(` \x1b[2m+${file.summary.additions} -${file.summary.deletions}\x1b[0m`);
|
|
151
|
-
for (const hunk of file.hunks) {
|
|
152
|
-
for (const change of hunk.changes) {
|
|
153
|
-
if (change.type === 'context') {
|
|
154
|
-
lines.push(` \x1b[2m ${change.line}\x1b[0m`);
|
|
155
|
-
}
|
|
156
|
-
else if (change.type === 'delete') {
|
|
157
|
-
lines.push(` \x1b[31m-${change.line}\x1b[0m`);
|
|
158
|
-
}
|
|
159
|
-
else if (change.type === 'add') {
|
|
160
|
-
lines.push(` \x1b[32m+${change.line}\x1b[0m`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
lines.push('');
|
|
165
|
-
}
|
|
166
|
-
return lines.join('\n');
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Generate HTML diff
|
|
170
|
-
*/
|
|
171
|
-
generateHTMLDiff(packs) {
|
|
172
|
-
const visualization = this.visualize(packs);
|
|
173
|
-
const html = [
|
|
174
|
-
'<!DOCTYPE html>',
|
|
175
|
-
'<html><head><style>',
|
|
176
|
-
this.getHTMLStyles(),
|
|
177
|
-
'</style></head><body>',
|
|
178
|
-
'<div class="diff-container">',
|
|
179
|
-
];
|
|
180
|
-
for (const file of visualization.files) {
|
|
181
|
-
html.push(`<div class="file-header">${file.file}</div>`);
|
|
182
|
-
html.push(`<div class="file-summary">+${file.summary.additions} -${file.summary.deletions}</div>`);
|
|
183
|
-
html.push('<div class="hunk">');
|
|
184
|
-
for (const hunk of file.hunks) {
|
|
185
|
-
html.push(`<div class="hunk-header">@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@</div>`);
|
|
186
|
-
for (const change of hunk.changes) {
|
|
187
|
-
const className = `line-${change.type}`;
|
|
188
|
-
html.push(`<div class="${className}">`);
|
|
189
|
-
if (change.type === 'delete') {
|
|
190
|
-
html.push(`<span class="line-number">${change.oldLineNumber}</span>`);
|
|
191
|
-
html.push(`<span class="line-content">-${this.escapeHtml(change.line)}</span>`);
|
|
192
|
-
}
|
|
193
|
-
else if (change.type === 'add') {
|
|
194
|
-
html.push(`<span class="line-number">${change.newLineNumber}</span>`);
|
|
195
|
-
html.push(`<span class="line-content">+${this.escapeHtml(change.line)}</span>`);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
html.push(`<span class="line-number">${change.oldLineNumber}</span>`);
|
|
199
|
-
html.push(`<span class="line-content"> ${this.escapeHtml(change.line)}</span>`);
|
|
200
|
-
}
|
|
201
|
-
html.push('</div>');
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
html.push('</div></div>');
|
|
205
|
-
}
|
|
206
|
-
html.push('</div></body></html>');
|
|
207
|
-
return html.join('\n');
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Get HTML styles for diff
|
|
211
|
-
*/
|
|
212
|
-
getHTMLStyles() {
|
|
213
|
-
return `
|
|
214
|
-
body { font-family: monospace; font-size: 12px; margin: 0; padding: 20px; background: #1e1e1e; color: #d4d4d4; }
|
|
215
|
-
.diff-container { max-width: 1200px; margin: 0 auto; }
|
|
216
|
-
.file-header { background: #252526; padding: 10px; font-weight: bold; border-bottom: 1px solid #3e3e42; }
|
|
217
|
-
.file-summary { background: #252526; padding: 5px 10px; color: #858585; font-size: 11px; }
|
|
218
|
-
.hunk { margin-bottom: 20px; }
|
|
219
|
-
.hunk-header { background: #2d2d30; padding: 5px 10px; color: #858585; font-size: 11px; }
|
|
220
|
-
.line-context { background: #1e1e1e; }
|
|
221
|
-
.line-delete { background: #4b1818; }
|
|
222
|
-
.line-add { background: #373d29; }
|
|
223
|
-
.line-context, .line-delete, .line-add { display: flex; padding: 2px 0; }
|
|
224
|
-
.line-number { width: 60px; text-align: right; padding-right: 10px; color: #858585; user-select: none; }
|
|
225
|
-
.line-content { flex: 1; white-space: pre; }
|
|
226
|
-
`;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Escape HTML entities
|
|
230
|
-
*/
|
|
231
|
-
escapeHtml(text) {
|
|
232
|
-
const map = {
|
|
233
|
-
'&': '&',
|
|
234
|
-
'<': '<',
|
|
235
|
-
'>': '>',
|
|
236
|
-
'"': '"',
|
|
237
|
-
"'": ''',
|
|
238
|
-
};
|
|
239
|
-
return text.replace(/[&<>"']/g, (m) => map[m]);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
exports.DiffVisualizer = DiffVisualizer;
|
|
243
|
-
//# sourceMappingURL=visualization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"visualization.js","sourceRoot":"","sources":["../../src/fix/visualization.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,2BAA8C;AAC9C,+BAA4B;AAsC5B,MAAa,cAAc;IAIzB,YAAY,WAAmB,EAAE,eAAuB,CAAC;QACvD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,KAAgB;QACxB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;QAC7C,IAAI,cAAc,GAAG,CAAC,CAAC;QACvB,IAAI,cAAc,GAAG,CAAC,CAAC;QAEvB,sBAAsB;QACtB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC7B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC5B,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE;wBACrB,IAAI,EAAE,GAAG,CAAC,IAAI;wBACd,KAAK,EAAE,EAAE;wBACT,OAAO,EAAE,EA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oBACJ,CAAC;yBAAM,CAAC;wBACN,IAAI,CAAC,IAAI,CACP,6BAA6B,MAAM,CAAC,aAAa,SAAS,CAC3D,CAAC;wBACF,IAAI,CAAC,IAAI,CACP,+BAA+B,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CACrE,CAAC;oBACJ,CAAC;oBACD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED;;OAEG;IACK,aAAa;QACnB,OAAO;;;;;;;;;;;;;KAaN,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,IAAY;QAC7B,MAAM,GAAG,GAA2B;YAClC,GAAG,EAAE,OAAO;YACZ,GAAG,EAAE,MAAM;YACX,GAAG,EAAE,MAAM;YACX,GAAG,EAAE,QAAQ;YACb,GAAG,EAAE,QAAQ;SACd,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;CACF;AApSD,wCAoSC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared CLI error formatting utilities
|
|
3
|
-
* Provides user-friendly, actionable error messages with optional debug information
|
|
4
|
-
*/
|
|
5
|
-
export interface FormatCliErrorOptions {
|
|
6
|
-
debug?: boolean | string[] | Record<string, any>;
|
|
7
|
-
context?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface FormattedError {
|
|
10
|
-
exitCode: number;
|
|
11
|
-
message: string;
|
|
12
|
-
type: string;
|
|
13
|
-
}
|
|
14
|
-
interface ErrorClassification {
|
|
15
|
-
type: string;
|
|
16
|
-
headline: string;
|
|
17
|
-
whatHappened: string;
|
|
18
|
-
why: string[];
|
|
19
|
-
whatToDo: string[];
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Check if debug mode is enabled from argv or environment
|
|
23
|
-
*/
|
|
24
|
-
export declare function isDebugEnabled(argv?: boolean | string[] | Record<string, any>): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Redact secrets from text to prevent leaking API keys, tokens, etc.
|
|
27
|
-
*/
|
|
28
|
-
export declare function redactSecrets(text: string | null | undefined): string;
|
|
29
|
-
/**
|
|
30
|
-
* Determine error type and extract context
|
|
31
|
-
*/
|
|
32
|
-
declare function classifyError(err: Error | unknown): ErrorClassification;
|
|
33
|
-
/**
|
|
34
|
-
* Format a CLI error with user-friendly structure
|
|
35
|
-
*/
|
|
36
|
-
export declare function formatCliError(err: Error | unknown, options?: FormatCliErrorOptions): FormattedError;
|
|
37
|
-
export { classifyError };
|
|
38
|
-
//# sourceMappingURL=cli-errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli-errors.d.ts","sourceRoot":"","sources":["../../src/runtime/cli-errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAavF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAsDrE;AAUD;;GAEG;AACH,iBAAS,aAAa,CAAC,GAAG,EAAE,KAAK,GAAG,OAAO,GAAG,mBAAmB,CAwLhE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,KAAK,GAAG,OAAO,EAAE,OAAO,GAAE,qBAA0B,GAAG,cAAc,CAuGxG;AAGD,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Shared CLI error formatting utilities
|
|
4
|
-
* Provides user-friendly, actionable error messages with optional debug information
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.isDebugEnabled = isDebugEnabled;
|
|
8
|
-
exports.redactSecrets = redactSecrets;
|
|
9
|
-
exports.formatCliError = formatCliError;
|
|
10
|
-
exports.classifyError = classifyError;
|
|
11
|
-
const colors = {
|
|
12
|
-
reset: '\x1b[0m',
|
|
13
|
-
red: '\x1b[31m',
|
|
14
|
-
yellow: '\x1b[33m',
|
|
15
|
-
cyan: '\x1b[36m',
|
|
16
|
-
green: '\x1b[32m',
|
|
17
|
-
bold: '\x1b[1m',
|
|
18
|
-
dim: '\x1b[2m',
|
|
19
|
-
};
|
|
20
|
-
const c = {
|
|
21
|
-
red: (text) => `${colors.red}${text}${colors.reset}`,
|
|
22
|
-
yellow: (text) => `${colors.yellow}${text}${colors.reset}`,
|
|
23
|
-
cyan: (text) => `${colors.cyan}${text}${colors.reset}`,
|
|
24
|
-
green: (text) => `${colors.green}${text}${colors.reset}`,
|
|
25
|
-
bold: (text) => `${colors.bold}${text}${colors.reset}`,
|
|
26
|
-
dim: (text) => `${colors.dim}${text}${colors.reset}`,
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Check if debug mode is enabled from argv or environment
|
|
30
|
-
*/
|
|
31
|
-
function isDebugEnabled(argv) {
|
|
32
|
-
// Support both array (process.argv) and object (parsed args)
|
|
33
|
-
if (Array.isArray(argv)) {
|
|
34
|
-
return argv.includes('--debug');
|
|
35
|
-
}
|
|
36
|
-
if (argv && typeof argv === 'object' && !Array.isArray(argv)) {
|
|
37
|
-
return !!argv.debug || !!argv.verbose;
|
|
38
|
-
}
|
|
39
|
-
return !!(process.env.DEBUG ||
|
|
40
|
-
process.env.GUARDRAIL_DEBUG ||
|
|
41
|
-
process.argv.includes('--debug'));
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Redact secrets from text to prevent leaking API keys, tokens, etc.
|
|
45
|
-
*/
|
|
46
|
-
function redactSecrets(text) {
|
|
47
|
-
if (!text || typeof text !== 'string') {
|
|
48
|
-
return String(text || '');
|
|
49
|
-
}
|
|
50
|
-
let redacted = text;
|
|
51
|
-
// Redact API keys (apikey=, api_key=, apiKey=)
|
|
52
|
-
redacted = redacted.replace(/(?:apikey|api_key|apiKey)\s*=\s*([^\s"'&;]+)/gi, (match, key) => {
|
|
53
|
-
if (key.length > 8) {
|
|
54
|
-
return match.replace(key, key.substring(0, 4) + '***' + key.substring(key.length - 4));
|
|
55
|
-
}
|
|
56
|
-
return match.replace(key, '***');
|
|
57
|
-
});
|
|
58
|
-
// Redact tokens (token=, access_token=, bearer tokens)
|
|
59
|
-
redacted = redacted.replace(/(?:token|access_token|refresh_token)\s*=\s*([^\s"'&;]+)/gi, (match, token) => {
|
|
60
|
-
if (token.length > 8) {
|
|
61
|
-
return match.replace(token, token.substring(0, 4) + '***' + token.substring(token.length - 4));
|
|
62
|
-
}
|
|
63
|
-
return match.replace(token, '***');
|
|
64
|
-
});
|
|
65
|
-
// Redact Authorization headers (Authorization: Bearer, Authorization: Basic)
|
|
66
|
-
redacted = redacted.replace(/Authorization:\s*(?:Bearer|Basic)\s+([^\s"'&;]+)/gi, (match, auth) => {
|
|
67
|
-
if (auth.length > 8) {
|
|
68
|
-
return match.replace(auth, auth.substring(0, 4) + '***' + auth.substring(auth.length - 4));
|
|
69
|
-
}
|
|
70
|
-
return match.replace(auth, '***');
|
|
71
|
-
});
|
|
72
|
-
// Redact common secret patterns
|
|
73
|
-
const secretPatterns = [
|
|
74
|
-
/(?:password|pwd|passwd)\s*=\s*([^\s"'&;]+)/gi,
|
|
75
|
-
/(?:secret|secret_key)\s*=\s*([^\s"'&;]+)/gi,
|
|
76
|
-
/(?:private[_-]?key)\s*=\s*([^\s"'&;]+)/gi,
|
|
77
|
-
];
|
|
78
|
-
for (const pattern of secretPatterns) {
|
|
79
|
-
redacted = redacted.replace(pattern, (match, secret) => {
|
|
80
|
-
return match.replace(secret, '***REDACTED***');
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
return redacted;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Extract file path from error message
|
|
87
|
-
*/
|
|
88
|
-
function extractPathFromMessage(message) {
|
|
89
|
-
const pathMatch = message.match(/['"]([^'"]+)['"]/);
|
|
90
|
-
return pathMatch ? pathMatch[1] : null;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Determine error type and extract context
|
|
94
|
-
*/
|
|
95
|
-
function classifyError(err) {
|
|
96
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
97
|
-
const message = error.message || String(err);
|
|
98
|
-
const code = error.code || error.statusCode || error.name;
|
|
99
|
-
// API connection errors
|
|
100
|
-
if (code === 'ECONNREFUSED' ||
|
|
101
|
-
code === 'ECONNRESET' ||
|
|
102
|
-
code === 'ETIMEDOUT' ||
|
|
103
|
-
code === 'ENOTFOUND' ||
|
|
104
|
-
code === 'ENETUNREACH' ||
|
|
105
|
-
error.name === 'NetworkError' ||
|
|
106
|
-
message.includes('connect') ||
|
|
107
|
-
message.includes('network') ||
|
|
108
|
-
message.includes('timeout') ||
|
|
109
|
-
message.includes('ECONN')) {
|
|
110
|
-
return {
|
|
111
|
-
type: 'API_CONNECTION',
|
|
112
|
-
headline: 'Cannot connect to Guardrail API',
|
|
113
|
-
whatHappened: 'Failed to establish connection to the Guardrail service',
|
|
114
|
-
why: [
|
|
115
|
-
'Your internet connection may be down',
|
|
116
|
-
'The Guardrail service may be temporarily unavailable',
|
|
117
|
-
'A firewall or proxy may be blocking the connection',
|
|
118
|
-
],
|
|
119
|
-
whatToDo: [
|
|
120
|
-
'Check your internet connection',
|
|
121
|
-
'Verify the service status at https://status.getguardrail.io',
|
|
122
|
-
'Check firewall/proxy settings if behind a corporate network',
|
|
123
|
-
'Try again in a few moments',
|
|
124
|
-
],
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
// File not found errors
|
|
128
|
-
if (code === 'ENOENT' ||
|
|
129
|
-
message.includes('not found') ||
|
|
130
|
-
message.includes('Cannot find') ||
|
|
131
|
-
message.includes('does not exist')) {
|
|
132
|
-
const path = error.path || extractPathFromMessage(message);
|
|
133
|
-
return {
|
|
134
|
-
type: 'FILE_NOT_FOUND',
|
|
135
|
-
headline: 'File or directory not found',
|
|
136
|
-
whatHappened: `The requested file or directory could not be located${path ? `: ${path}` : ''}`,
|
|
137
|
-
why: [
|
|
138
|
-
'The file may have been moved or deleted',
|
|
139
|
-
'The path may be incorrect',
|
|
140
|
-
'You may not have the required files in your project',
|
|
141
|
-
],
|
|
142
|
-
whatToDo: [
|
|
143
|
-
`Verify the path is correct${path ? `: ${path}` : ''}`,
|
|
144
|
-
'Check if the file exists in your project',
|
|
145
|
-
'Ensure you are running the command from the correct directory',
|
|
146
|
-
],
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
// Permission errors
|
|
150
|
-
if (code === 'EACCES' ||
|
|
151
|
-
code === 'EPERM' ||
|
|
152
|
-
message.includes('permission') ||
|
|
153
|
-
message.includes('access denied') ||
|
|
154
|
-
message.includes('Permission denied')) {
|
|
155
|
-
return {
|
|
156
|
-
type: 'PERMISSION',
|
|
157
|
-
headline: 'Permission denied',
|
|
158
|
-
whatHappened: 'You do not have permission to perform this operation',
|
|
159
|
-
why: [
|
|
160
|
-
'The file or directory may be owned by another user',
|
|
161
|
-
'Your user account may not have the required privileges',
|
|
162
|
-
'The file system may have restricted access',
|
|
163
|
-
],
|
|
164
|
-
whatToDo: [
|
|
165
|
-
'Check file permissions: `ls -la` (Unix) or check Properties (Windows)',
|
|
166
|
-
'Run with appropriate user privileges',
|
|
167
|
-
'Contact your system administrator if needed',
|
|
168
|
-
],
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
// Configuration errors
|
|
172
|
-
if (code === 'EINVAL' ||
|
|
173
|
-
message.includes('invalid') ||
|
|
174
|
-
message.includes('configuration') ||
|
|
175
|
-
message.includes('config') ||
|
|
176
|
-
message.includes('missing') ||
|
|
177
|
-
error.name === 'ValidationError') {
|
|
178
|
-
return {
|
|
179
|
-
type: 'CONFIGURATION',
|
|
180
|
-
headline: 'Configuration error',
|
|
181
|
-
whatHappened: 'The configuration is invalid or missing required settings',
|
|
182
|
-
why: [
|
|
183
|
-
'Required configuration values may be missing',
|
|
184
|
-
'The configuration file may be malformed',
|
|
185
|
-
'Environment variables may not be set correctly',
|
|
186
|
-
],
|
|
187
|
-
whatToDo: [
|
|
188
|
-
'Check your .env file or configuration file',
|
|
189
|
-
'Verify all required environment variables are set',
|
|
190
|
-
'Run `guardrail login` if authentication is required',
|
|
191
|
-
'See documentation: https://docs.getguardrail.io',
|
|
192
|
-
],
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
// Authentication/Authorization errors
|
|
196
|
-
if (code === 401 ||
|
|
197
|
-
code === 'UNAUTHORIZED' ||
|
|
198
|
-
code === 403 ||
|
|
199
|
-
code === 'FORBIDDEN' ||
|
|
200
|
-
error.name === 'AuthenticationError' ||
|
|
201
|
-
message.includes('authentication') ||
|
|
202
|
-
message.includes('unauthorized') ||
|
|
203
|
-
message.includes('forbidden')) {
|
|
204
|
-
return {
|
|
205
|
-
type: 'AUTHENTICATION',
|
|
206
|
-
headline: code === 403 || code === 'FORBIDDEN' ? 'Access denied' : 'Authentication failed',
|
|
207
|
-
whatHappened: code === 403 || code === 'FORBIDDEN'
|
|
208
|
-
? 'You do not have permission to access this resource'
|
|
209
|
-
: 'Your authentication credentials are invalid or expired',
|
|
210
|
-
why: [
|
|
211
|
-
code === 403 || code === 'FORBIDDEN'
|
|
212
|
-
? 'Your account may not have the required permissions'
|
|
213
|
-
: 'Your API key may be missing, invalid, or expired',
|
|
214
|
-
'You may need to upgrade your plan for this feature',
|
|
215
|
-
],
|
|
216
|
-
whatToDo: [
|
|
217
|
-
code === 403 || code === 'FORBIDDEN'
|
|
218
|
-
? 'Check your account permissions and plan tier'
|
|
219
|
-
: 'Run `guardrail login` to authenticate',
|
|
220
|
-
'Verify your API key at https://getguardrail.io/settings/keys',
|
|
221
|
-
'Check if this feature requires a premium plan',
|
|
222
|
-
],
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
// Tier restriction errors
|
|
226
|
-
if (code === 'LIMIT_EXCEEDED' ||
|
|
227
|
-
code === 'FEATURE_NOT_AVAILABLE' ||
|
|
228
|
-
code === 'TIER_RESTRICTION' ||
|
|
229
|
-
message.includes('tier') ||
|
|
230
|
-
message.includes('upgrade') ||
|
|
231
|
-
message.includes('premium') ||
|
|
232
|
-
message.includes('limit')) {
|
|
233
|
-
return {
|
|
234
|
-
type: 'TIER_RESTRICTION',
|
|
235
|
-
headline: 'Feature not available on your plan',
|
|
236
|
-
whatHappened: 'This feature requires a higher tier subscription',
|
|
237
|
-
why: [
|
|
238
|
-
'Your current plan does not include this feature',
|
|
239
|
-
'You may have exceeded your usage limits',
|
|
240
|
-
],
|
|
241
|
-
whatToDo: [
|
|
242
|
-
'Visit https://getguardrail.io/pricing to upgrade',
|
|
243
|
-
'Check your usage limits: `guardrail status`',
|
|
244
|
-
'Contact support if you believe this is an error',
|
|
245
|
-
],
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
// Generic error
|
|
249
|
-
return {
|
|
250
|
-
type: 'UNKNOWN',
|
|
251
|
-
headline: 'An error occurred',
|
|
252
|
-
whatHappened: message || 'An unexpected error occurred',
|
|
253
|
-
why: ['An unexpected error occurred during execution'],
|
|
254
|
-
whatToDo: [
|
|
255
|
-
'Check the error message above for details',
|
|
256
|
-
'Run with --debug for more information',
|
|
257
|
-
'If the issue persists, contact support',
|
|
258
|
-
],
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Format a CLI error with user-friendly structure
|
|
263
|
-
*/
|
|
264
|
-
function formatCliError(err, options = {}) {
|
|
265
|
-
const { debug = false, context = '' } = options;
|
|
266
|
-
const debugMode = isDebugEnabled(debug !== false ? debug : process.argv);
|
|
267
|
-
const classification = classifyError(err);
|
|
268
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
269
|
-
// Build the error message
|
|
270
|
-
const lines = [];
|
|
271
|
-
// Headline
|
|
272
|
-
lines.push(c.red(c.bold(`✗ ${classification.headline}`)));
|
|
273
|
-
lines.push('');
|
|
274
|
-
// What happened
|
|
275
|
-
lines.push(c.bold('What happened:'));
|
|
276
|
-
lines.push(` ${classification.whatHappened}`);
|
|
277
|
-
if (context) {
|
|
278
|
-
lines.push(` ${c.dim(`Context: ${context}`)}`);
|
|
279
|
-
}
|
|
280
|
-
lines.push('');
|
|
281
|
-
// Why it happened
|
|
282
|
-
if (classification.why && classification.why.length > 0) {
|
|
283
|
-
lines.push(c.bold('Why it happened:'));
|
|
284
|
-
classification.why.forEach((reason) => {
|
|
285
|
-
lines.push(` • ${reason}`);
|
|
286
|
-
});
|
|
287
|
-
lines.push('');
|
|
288
|
-
}
|
|
289
|
-
// What to do next
|
|
290
|
-
if (classification.whatToDo && classification.whatToDo.length > 0) {
|
|
291
|
-
lines.push(c.bold('What to do next:'));
|
|
292
|
-
classification.whatToDo.slice(0, 3).forEach((action) => {
|
|
293
|
-
lines.push(` • ${action}`);
|
|
294
|
-
});
|
|
295
|
-
lines.push('');
|
|
296
|
-
}
|
|
297
|
-
// Debug information
|
|
298
|
-
if (debugMode) {
|
|
299
|
-
lines.push(c.dim('─'.repeat(60)));
|
|
300
|
-
lines.push(c.dim(c.bold('Debug Information:')));
|
|
301
|
-
lines.push('');
|
|
302
|
-
// Stack trace
|
|
303
|
-
if (error.stack) {
|
|
304
|
-
lines.push(c.dim('Stack trace:'));
|
|
305
|
-
const redactedStack = redactSecrets(error.stack);
|
|
306
|
-
lines.push(c.dim(redactedStack));
|
|
307
|
-
lines.push('');
|
|
308
|
-
}
|
|
309
|
-
// Raw error details
|
|
310
|
-
lines.push(c.dim('Error details:'));
|
|
311
|
-
const errorDetails = {
|
|
312
|
-
name: error.name,
|
|
313
|
-
code: error.code || error.statusCode,
|
|
314
|
-
message: error.message,
|
|
315
|
-
};
|
|
316
|
-
if (error.response) {
|
|
317
|
-
errorDetails.response = {
|
|
318
|
-
status: error.response.status,
|
|
319
|
-
statusText: error.response.statusText,
|
|
320
|
-
body: redactSecrets(typeof error.response.body === 'string'
|
|
321
|
-
? error.response.body
|
|
322
|
-
: JSON.stringify(error.response.body || {})),
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
if (error.body) {
|
|
326
|
-
errorDetails.body = redactSecrets(typeof error.body === 'string' ? error.body : JSON.stringify(error.body || {}));
|
|
327
|
-
}
|
|
328
|
-
const redactedDetails = redactSecrets(JSON.stringify(errorDetails, null, 2));
|
|
329
|
-
lines.push(c.dim(redactedDetails));
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
lines.push(c.dim('💡 Run with --debug for detailed error information'));
|
|
333
|
-
}
|
|
334
|
-
// Determine exit code based on error type
|
|
335
|
-
let exitCode = 1; // Default: verification failed
|
|
336
|
-
if (classification.type === 'FILE_NOT_FOUND' ||
|
|
337
|
-
classification.type === 'CONFIGURATION' ||
|
|
338
|
-
classification.type === 'PERMISSION' ||
|
|
339
|
-
classification.type === 'AUTHENTICATION') {
|
|
340
|
-
exitCode = 2; // User error
|
|
341
|
-
}
|
|
342
|
-
else if (classification.type === 'TIER_RESTRICTION') {
|
|
343
|
-
exitCode = 2; // User error (need to upgrade)
|
|
344
|
-
}
|
|
345
|
-
else if (classification.type === 'API_CONNECTION') {
|
|
346
|
-
exitCode = 1; // Verification failed (couldn't complete check)
|
|
347
|
-
}
|
|
348
|
-
return {
|
|
349
|
-
exitCode,
|
|
350
|
-
message: lines.join('\n'),
|
|
351
|
-
type: classification.type,
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
//# sourceMappingURL=cli-errors.js.map
|