@vertaaux/cli 0.4.0 → 0.5.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/CHANGELOG.md +97 -0
- package/MIGRATION.md +239 -0
- package/README.md +34 -16
- package/dist/app/interactive-app.d.ts +101 -0
- package/dist/app/interactive-app.d.ts.map +1 -0
- package/dist/app/interactive-app.js +309 -0
- package/dist/app/layout/canvas.d.ts +23 -0
- package/dist/app/layout/canvas.d.ts.map +1 -0
- package/dist/app/layout/canvas.js +36 -0
- package/dist/app/layout/footer.d.ts +31 -0
- package/dist/app/layout/footer.d.ts.map +1 -0
- package/dist/app/layout/footer.js +41 -0
- package/dist/app/layout/header.d.ts +20 -0
- package/dist/app/layout/header.d.ts.map +1 -0
- package/dist/app/layout/header.js +27 -0
- package/dist/app/menu/categories.d.ts +20 -0
- package/dist/app/menu/categories.d.ts.map +1 -0
- package/dist/app/menu/categories.js +181 -0
- package/dist/app/menu/filter.d.ts +17 -0
- package/dist/app/menu/filter.d.ts.map +1 -0
- package/dist/app/menu/filter.js +33 -0
- package/dist/app/menu/menu-view.d.ts +35 -0
- package/dist/app/menu/menu-view.d.ts.map +1 -0
- package/dist/app/menu/menu-view.js +230 -0
- package/dist/app/menu/recent.d.ts +24 -0
- package/dist/app/menu/recent.d.ts.map +1 -0
- package/dist/app/menu/recent.js +49 -0
- package/dist/app/types.d.ts +43 -0
- package/dist/app/types.d.ts.map +1 -0
- package/dist/app/types.js +7 -0
- package/dist/app/views/command-runner.d.ts +36 -0
- package/dist/app/views/command-runner.d.ts.map +1 -0
- package/dist/app/views/command-runner.js +372 -0
- package/dist/app/views/help-overlay.d.ts +21 -0
- package/dist/app/views/help-overlay.d.ts.map +1 -0
- package/dist/app/views/help-overlay.js +45 -0
- package/dist/auth/ci-token.d.ts +8 -2
- package/dist/auth/ci-token.d.ts.map +1 -1
- package/dist/auth/ci-token.js +15 -30
- package/dist/auth/device-flow.d.ts +2 -1
- package/dist/auth/device-flow.d.ts.map +1 -1
- package/dist/auth/device-flow.js +13 -10
- package/dist/auth/token-store.d.ts.map +1 -1
- package/dist/auth/token-store.js +12 -2
- package/dist/baseline/diff.d.ts +2 -2
- package/dist/baseline/diff.d.ts.map +1 -1
- package/dist/baseline/diff.js +15 -34
- package/dist/commands/a11y.d.ts +9 -0
- package/dist/commands/a11y.d.ts.map +1 -0
- package/dist/commands/a11y.js +76 -0
- package/dist/commands/audit/artifacts.d.ts +27 -0
- package/dist/commands/audit/artifacts.d.ts.map +1 -0
- package/dist/commands/audit/artifacts.js +158 -0
- package/dist/commands/audit/ci-detection.d.ts +18 -0
- package/dist/commands/audit/ci-detection.d.ts.map +1 -0
- package/dist/commands/audit/ci-detection.js +71 -0
- package/dist/commands/audit/explain.d.ts +11 -0
- package/dist/commands/audit/explain.d.ts.map +1 -0
- package/dist/commands/audit/explain.js +45 -0
- package/dist/commands/audit/filters.d.ts +17 -0
- package/dist/commands/audit/filters.d.ts.map +1 -0
- package/dist/commands/audit/filters.js +40 -0
- package/dist/commands/audit/index.d.ts +18 -0
- package/dist/commands/audit/index.d.ts.map +1 -0
- package/dist/commands/audit/index.js +564 -0
- package/dist/commands/audit/output.d.ts +32 -0
- package/dist/commands/audit/output.d.ts.map +1 -0
- package/dist/commands/audit/output.js +130 -0
- package/dist/commands/audit/policy.d.ts +19 -0
- package/dist/commands/audit/policy.d.ts.map +1 -0
- package/dist/commands/audit/policy.js +102 -0
- package/dist/commands/audit/scoring.d.ts +23 -0
- package/dist/commands/audit/scoring.d.ts.map +1 -0
- package/dist/commands/audit/scoring.js +70 -0
- package/dist/commands/audit/types.d.ts +88 -0
- package/dist/commands/audit/types.d.ts.map +1 -0
- package/dist/commands/audit/types.js +8 -0
- package/dist/commands/audit.d.ts +2 -60
- package/dist/commands/audit.d.ts.map +1 -1
- package/dist/commands/audit.js +2 -1097
- package/dist/commands/baseline.d.ts +1 -0
- package/dist/commands/baseline.d.ts.map +1 -1
- package/dist/commands/baseline.js +205 -121
- package/dist/commands/comment.d.ts +22 -0
- package/dist/commands/comment.d.ts.map +1 -1
- package/dist/commands/comment.js +122 -58
- package/dist/commands/compare.d.ts +17 -0
- package/dist/commands/compare.d.ts.map +1 -1
- package/dist/commands/compare.js +287 -180
- package/dist/commands/diff.d.ts +5 -0
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +168 -141
- package/dist/commands/doc.d.ts +10 -0
- package/dist/commands/doc.d.ts.map +1 -1
- package/dist/commands/doc.js +134 -76
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +164 -17
- package/dist/commands/download.d.ts +10 -0
- package/dist/commands/download.d.ts.map +1 -1
- package/dist/commands/download.js +169 -112
- package/dist/commands/explain.d.ts +5 -0
- package/dist/commands/explain.d.ts.map +1 -1
- package/dist/commands/explain.js +241 -155
- package/dist/commands/fix-all.d.ts +25 -0
- package/dist/commands/fix-all.d.ts.map +1 -0
- package/dist/commands/fix-all.js +206 -0
- package/dist/commands/fix-plan.d.ts +9 -0
- package/dist/commands/fix-plan.d.ts.map +1 -1
- package/dist/commands/fix-plan.js +152 -89
- package/dist/commands/fix.d.ts +17 -0
- package/dist/commands/fix.d.ts.map +1 -0
- package/dist/commands/fix.js +111 -0
- package/dist/commands/init.d.ts +11 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +94 -42
- package/dist/commands/login.d.ts +18 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +263 -92
- package/dist/commands/patch-review.d.ts +11 -0
- package/dist/commands/patch-review.d.ts.map +1 -1
- package/dist/commands/patch-review.js +159 -97
- package/dist/commands/policy.d.ts +31 -0
- package/dist/commands/policy.d.ts.map +1 -1
- package/dist/commands/policy.js +269 -124
- package/dist/commands/release-notes.d.ts +10 -0
- package/dist/commands/release-notes.d.ts.map +1 -1
- package/dist/commands/release-notes.js +127 -73
- package/dist/commands/scan.d.ts +13 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +133 -0
- package/dist/commands/status.d.ts +9 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +81 -0
- package/dist/commands/suggest.d.ts +10 -0
- package/dist/commands/suggest.d.ts.map +1 -1
- package/dist/commands/suggest.js +153 -82
- package/dist/commands/triage.d.ts +35 -0
- package/dist/commands/triage.d.ts.map +1 -1
- package/dist/commands/triage.js +206 -81
- package/dist/commands/upload.d.ts +9 -0
- package/dist/commands/upload.d.ts.map +1 -1
- package/dist/commands/upload.js +140 -101
- package/dist/commands/verify.d.ts +13 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +118 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +125 -990
- package/dist/interactive/fix-wizard.d.ts +3 -0
- package/dist/interactive/fix-wizard.d.ts.map +1 -1
- package/dist/interactive/fix-wizard.js +130 -112
- package/dist/interactive/init-wizard.d.ts +3 -1
- package/dist/interactive/init-wizard.d.ts.map +1 -1
- package/dist/interactive/init-wizard.js +207 -138
- package/dist/interactive/prompts.d.ts +7 -3
- package/dist/interactive/prompts.d.ts.map +1 -1
- package/dist/interactive/prompts.js +44 -23
- package/dist/output/envelope.d.ts +2 -0
- package/dist/output/envelope.d.ts.map +1 -1
- package/dist/output/envelope.js +18 -2
- package/dist/output/factory.d.ts +2 -1
- package/dist/output/factory.d.ts.map +1 -1
- package/dist/output/html.d.ts +2 -1
- package/dist/output/html.d.ts.map +1 -1
- package/dist/output/html.js +3 -2
- package/dist/output/human.d.ts +2 -1
- package/dist/output/human.d.ts.map +1 -1
- package/dist/output/human.js +3 -2
- package/dist/output/json.d.ts +2 -1
- package/dist/output/json.d.ts.map +1 -1
- package/dist/output/junit.d.ts +2 -1
- package/dist/output/junit.d.ts.map +1 -1
- package/dist/output/sarif.d.ts +2 -1
- package/dist/output/sarif.d.ts.map +1 -1
- package/dist/types.d.ts +74 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/ui/banner.d.ts +34 -0
- package/dist/ui/banner.d.ts.map +1 -1
- package/dist/ui/banner.js +97 -5
- package/dist/ui/diagnostics.d.ts +9 -4
- package/dist/ui/diagnostics.d.ts.map +1 -1
- package/dist/ui/diagnostics.js +32 -82
- package/dist/ui/strings.d.ts +373 -0
- package/dist/ui/strings.d.ts.map +1 -0
- package/dist/ui/strings.js +499 -0
- package/dist/ui/table.d.ts +0 -2
- package/dist/ui/table.d.ts.map +1 -1
- package/dist/ui/table.js +3 -4
- package/dist/utils/api-client.d.ts +46 -0
- package/dist/utils/api-client.d.ts.map +1 -0
- package/dist/utils/api-client.js +170 -0
- package/dist/utils/client.d.ts +29 -18
- package/dist/utils/client.d.ts.map +1 -1
- package/dist/utils/client.js +102 -12
- package/dist/utils/formatters.d.ts +38 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/formatters.js +277 -0
- package/dist/utils/url-classify.d.ts.map +1 -1
- package/dist/utils/url-classify.js +24 -3
- package/node_modules/@vertaaux/tui/dist/index.cjs +713 -20
- package/node_modules/@vertaaux/tui/dist/index.cjs.map +1 -1
- package/node_modules/@vertaaux/tui/dist/index.d.cts +361 -4
- package/node_modules/@vertaaux/tui/dist/index.d.ts +361 -4
- package/node_modules/@vertaaux/tui/dist/index.js +689 -21
- package/node_modules/@vertaaux/tui/dist/index.js.map +1 -1
- package/package.json +13 -5
- package/dist/commands/client.d.ts +0 -14
- package/dist/commands/client.d.ts.map +0 -1
- package/dist/commands/client.js +0 -362
- package/dist/commands/drift.d.ts +0 -15
- package/dist/commands/drift.d.ts.map +0 -1
- package/dist/commands/drift.js +0 -309
- package/dist/commands/protect.d.ts +0 -16
- package/dist/commands/protect.d.ts.map +0 -1
- package/dist/commands/protect.js +0 -323
- package/dist/commands/report.d.ts +0 -15
- package/dist/commands/report.d.ts.map +0 -1
- package/dist/commands/report.js +0 -214
- package/dist/policy/sync.d.ts +0 -67
- package/dist/policy/sync.d.ts.map +0 -1
- package/dist/policy/sync.js +0 -147
package/dist/commands/suggest.js
CHANGED
|
@@ -10,28 +10,28 @@
|
|
|
10
10
|
* vertaa suggest "compare two pages"
|
|
11
11
|
* vertaa suggest "set up CI quality gate"
|
|
12
12
|
*/
|
|
13
|
-
import
|
|
13
|
+
import { bold, dim, colorize, boldColor, brand, severity as severityPalette, runSteps, createRenderer, renderWarning, renderError, isCI, isTTY } from "@vertaaux/tui";
|
|
14
14
|
import { ExitCode } from "../utils/exit-codes.js";
|
|
15
15
|
import { resolveApiBase, getApiKey, hasApiKey, apiRequest } from "../utils/client.js";
|
|
16
16
|
import { resolveConfig } from "../config/loader.js";
|
|
17
17
|
import { writeJsonOutput, writeOutput } from "../output/envelope.js";
|
|
18
18
|
import { resolveCommandFormat } from "../output/formats.js";
|
|
19
|
-
import { createSpinner, succeedSpinner, failSpinner } from "../ui/spinner.js";
|
|
20
19
|
import { findMatches } from "../prompts/command-catalog.js";
|
|
21
20
|
import { AI_TIMEOUT_MS } from "../utils/ai-error.js";
|
|
21
|
+
import { strings } from "../ui/strings.js";
|
|
22
22
|
/**
|
|
23
23
|
* Format suggestion for human-readable output.
|
|
24
24
|
*/
|
|
25
25
|
function formatSuggestHuman(results) {
|
|
26
26
|
const lines = [];
|
|
27
27
|
for (const result of results) {
|
|
28
|
-
lines.push(` ${
|
|
29
|
-
lines.push(` ${
|
|
28
|
+
lines.push(` ${boldColor("$", brand.cyan)} ${bold(result.command)}`);
|
|
29
|
+
lines.push(` ${dim(result.explanation)}`);
|
|
30
30
|
lines.push("");
|
|
31
31
|
}
|
|
32
32
|
if (results.length === 0) {
|
|
33
|
-
lines.push(
|
|
34
|
-
lines.push(
|
|
33
|
+
lines.push(colorize("No matching commands found.", severityPalette.warning));
|
|
34
|
+
lines.push(dim("Try: vertaa --help"));
|
|
35
35
|
}
|
|
36
36
|
return lines.join("\n");
|
|
37
37
|
}
|
|
@@ -48,6 +48,137 @@ function formatSuggestJson(results) {
|
|
|
48
48
|
})),
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
+
export async function handleSuggest(opts) {
|
|
52
|
+
const format = resolveCommandFormat("suggest", opts.format, opts.machine || false);
|
|
53
|
+
const config = { apiKey: opts.apiKey };
|
|
54
|
+
const intent = opts.intent;
|
|
55
|
+
// Resolve fail-fast mode: --strict > --continue-on-error > auto-detect
|
|
56
|
+
let failFast;
|
|
57
|
+
if (opts.strict && opts.continueOnError) {
|
|
58
|
+
writeOutput(renderWarning({ message: "--strict and --continue-on-error both set — --strict takes precedence" }));
|
|
59
|
+
failFast = true;
|
|
60
|
+
}
|
|
61
|
+
else if (opts.strict) {
|
|
62
|
+
failFast = true;
|
|
63
|
+
}
|
|
64
|
+
else if (opts.continueOnError) {
|
|
65
|
+
failFast = false;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
failFast = isCI() || !isTTY();
|
|
69
|
+
}
|
|
70
|
+
let results = [];
|
|
71
|
+
const renderer = createRenderer("auto");
|
|
72
|
+
const baseState = {
|
|
73
|
+
phase: "suggest",
|
|
74
|
+
phaseIndex: 1,
|
|
75
|
+
phaseTotal: 1,
|
|
76
|
+
url: "",
|
|
77
|
+
mode: "suggest",
|
|
78
|
+
progress: {},
|
|
79
|
+
totals: {},
|
|
80
|
+
issueCount: 0,
|
|
81
|
+
scorePreview: null,
|
|
82
|
+
verbose: false,
|
|
83
|
+
elapsed: 0,
|
|
84
|
+
};
|
|
85
|
+
const steps = [
|
|
86
|
+
{
|
|
87
|
+
id: "search",
|
|
88
|
+
actionText: strings.suggest.search.action,
|
|
89
|
+
summaryText: strings.suggest.search.done(0),
|
|
90
|
+
run: async () => {
|
|
91
|
+
// Step 1: Local fuzzy match against command catalog
|
|
92
|
+
const localMatches = findMatches(intent);
|
|
93
|
+
if (localMatches.length > 0 && localMatches[0].score >= 0.2) {
|
|
94
|
+
// Good local matches — use them
|
|
95
|
+
results = localMatches.map((m) => ({
|
|
96
|
+
command: m.entry.command,
|
|
97
|
+
explanation: m.entry.description,
|
|
98
|
+
source: "local",
|
|
99
|
+
confidence: Math.round(m.score * 100),
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
else if (hasApiKey(config)) {
|
|
103
|
+
// No strong local match — try API
|
|
104
|
+
const base = resolveApiBase(opts.base);
|
|
105
|
+
const apiKey = getApiKey(config.apiKey);
|
|
106
|
+
try {
|
|
107
|
+
const response = await Promise.race([
|
|
108
|
+
apiRequest(base, "/cli/ai/suggest", { method: "POST", body: { intent } }, apiKey),
|
|
109
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("LLM request timed out")), AI_TIMEOUT_MS)),
|
|
110
|
+
]);
|
|
111
|
+
if (response.data?.suggestions?.length) {
|
|
112
|
+
results = response.data.suggestions.map((s) => ({
|
|
113
|
+
command: s.command,
|
|
114
|
+
explanation: s.explanation,
|
|
115
|
+
source: "api",
|
|
116
|
+
confidence: 80,
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
results = localMatches.map((m) => ({
|
|
121
|
+
command: m.entry.command,
|
|
122
|
+
explanation: m.entry.description,
|
|
123
|
+
source: "local",
|
|
124
|
+
confidence: Math.round(m.score * 100),
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// API failed — suggest degrades gracefully to local catalog
|
|
130
|
+
writeOutput(strings.suggest.errors.apiUnavailable + "\n");
|
|
131
|
+
results = localMatches.map((m) => ({
|
|
132
|
+
command: m.entry.command,
|
|
133
|
+
explanation: m.entry.description,
|
|
134
|
+
source: "local",
|
|
135
|
+
confidence: Math.round(m.score * 100),
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// No API key — use partial local matches
|
|
141
|
+
results = localMatches.map((m) => ({
|
|
142
|
+
command: m.entry.command,
|
|
143
|
+
explanation: m.entry.description,
|
|
144
|
+
source: "local",
|
|
145
|
+
confidence: Math.round(m.score * 100),
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
];
|
|
151
|
+
const { success, states } = await runSteps(steps, {
|
|
152
|
+
failFast,
|
|
153
|
+
onStateChange: (stepStates) => {
|
|
154
|
+
renderer.update({ ...baseState, stepStates });
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
renderer.finish({
|
|
158
|
+
url: "",
|
|
159
|
+
mode: "suggest",
|
|
160
|
+
overallScore: success ? 100 : 0,
|
|
161
|
+
scores: {},
|
|
162
|
+
issueCount: 0,
|
|
163
|
+
passed: success,
|
|
164
|
+
elapsed: 0,
|
|
165
|
+
});
|
|
166
|
+
if (!success) {
|
|
167
|
+
const failedStep = states.find((s) => s.status === "failed");
|
|
168
|
+
process.stderr.write(renderError({
|
|
169
|
+
message: strings.suggest.errors.searchFailed(failedStep?.failReason ?? "unknown error"),
|
|
170
|
+
suggestion: "vertaa --help",
|
|
171
|
+
}) + "\n");
|
|
172
|
+
process.exit(ExitCode.ERROR);
|
|
173
|
+
}
|
|
174
|
+
// Output
|
|
175
|
+
if (format === "json") {
|
|
176
|
+
writeJsonOutput(formatSuggestJson(results), "suggest");
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
writeOutput(formatSuggestHuman(results));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
51
182
|
/**
|
|
52
183
|
* Register the suggest command with the Commander program.
|
|
53
184
|
*/
|
|
@@ -56,6 +187,8 @@ export function registerSuggestCommand(program) {
|
|
|
56
187
|
.command("suggest <intent...>")
|
|
57
188
|
.description("Convert natural language to exact CLI command(s)")
|
|
58
189
|
.option("-f, --format <format>", "Output format: json | human")
|
|
190
|
+
.option("--strict", "Fail immediately on first step error")
|
|
191
|
+
.option("--continue-on-error", "Continue on step errors even in CI")
|
|
59
192
|
.addHelpText("after", `
|
|
60
193
|
Examples:
|
|
61
194
|
vertaa suggest "check accessibility"
|
|
@@ -68,84 +201,22 @@ Examples:
|
|
|
68
201
|
const globalOpts = command.optsWithGlobals();
|
|
69
202
|
const config = await resolveConfig(globalOpts.config);
|
|
70
203
|
const machineMode = globalOpts.machine || false;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
explanation: m.entry.description,
|
|
81
|
-
source: "local",
|
|
82
|
-
confidence: Math.round(m.score * 100),
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
else if (hasApiKey(config)) {
|
|
86
|
-
// No strong local match — try API
|
|
87
|
-
const spinner = createSpinner("Thinking...");
|
|
88
|
-
try {
|
|
89
|
-
const base = resolveApiBase(globalOpts.base);
|
|
90
|
-
const apiKey = getApiKey(config.apiKey);
|
|
91
|
-
const response = await Promise.race([
|
|
92
|
-
apiRequest(base, "/cli/ai/suggest", {
|
|
93
|
-
method: "POST",
|
|
94
|
-
body: { intent },
|
|
95
|
-
}, apiKey),
|
|
96
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error("LLM request timed out")), AI_TIMEOUT_MS)),
|
|
97
|
-
]);
|
|
98
|
-
succeedSpinner(spinner, "Done");
|
|
99
|
-
if (response.data?.suggestions?.length) {
|
|
100
|
-
results = response.data.suggestions.map((s) => ({
|
|
101
|
-
command: s.command,
|
|
102
|
-
explanation: s.explanation,
|
|
103
|
-
source: "api",
|
|
104
|
-
confidence: 80,
|
|
105
|
-
}));
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
// API returned nothing — fall back to partial local matches
|
|
109
|
-
results = localMatches.map((m) => ({
|
|
110
|
-
command: m.entry.command,
|
|
111
|
-
explanation: m.entry.description,
|
|
112
|
-
source: "local",
|
|
113
|
-
confidence: Math.round(m.score * 100),
|
|
114
|
-
}));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
// Suggest degrades gracefully — fall back to local catalog
|
|
119
|
-
// instead of hard exit via handleAiCommandError
|
|
120
|
-
failSpinner(spinner, "API unavailable — using local catalog");
|
|
121
|
-
// API failed — use whatever local matches we have
|
|
122
|
-
results = localMatches.map((m) => ({
|
|
123
|
-
command: m.entry.command,
|
|
124
|
-
explanation: m.entry.description,
|
|
125
|
-
source: "local",
|
|
126
|
-
confidence: Math.round(m.score * 100),
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
// No API key — use partial local matches
|
|
132
|
-
results = localMatches.map((m) => ({
|
|
133
|
-
command: m.entry.command,
|
|
134
|
-
explanation: m.entry.description,
|
|
135
|
-
source: "local",
|
|
136
|
-
confidence: Math.round(m.score * 100),
|
|
137
|
-
}));
|
|
138
|
-
}
|
|
139
|
-
// Output
|
|
140
|
-
if (format === "json") {
|
|
141
|
-
writeJsonOutput(formatSuggestJson(results), "suggest");
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
writeOutput(formatSuggestHuman(results));
|
|
145
|
-
}
|
|
204
|
+
await handleSuggest({
|
|
205
|
+
intent: intentParts.join(" "),
|
|
206
|
+
format: options.format,
|
|
207
|
+
strict: options.strict,
|
|
208
|
+
continueOnError: options.continueOnError,
|
|
209
|
+
machine: machineMode,
|
|
210
|
+
base: globalOpts.base,
|
|
211
|
+
apiKey: config.apiKey,
|
|
212
|
+
});
|
|
146
213
|
}
|
|
147
214
|
catch (error) {
|
|
148
|
-
|
|
215
|
+
process.stderr.write(renderError({
|
|
216
|
+
message: error instanceof Error ? error.message : String(error),
|
|
217
|
+
suggestion: "vertaa --help",
|
|
218
|
+
exitCode: ExitCode.ERROR,
|
|
219
|
+
}) + "\n");
|
|
149
220
|
process.exit(ExitCode.ERROR);
|
|
150
221
|
}
|
|
151
222
|
});
|
|
@@ -13,5 +13,40 @@
|
|
|
13
13
|
* vertaa triage --file audit.json --verbose
|
|
14
14
|
*/
|
|
15
15
|
import { Command } from "commander";
|
|
16
|
+
import { type ViewportItem } from "@vertaaux/tui";
|
|
17
|
+
interface TriageItem {
|
|
18
|
+
id: string | null;
|
|
19
|
+
title: string;
|
|
20
|
+
reason: string;
|
|
21
|
+
effort: "trivial" | "small" | "medium" | "large";
|
|
22
|
+
}
|
|
23
|
+
interface TriageApiResponse {
|
|
24
|
+
data: {
|
|
25
|
+
p0_critical: TriageItem[];
|
|
26
|
+
p1_important: TriageItem[];
|
|
27
|
+
p2_nice_to_have: TriageItem[];
|
|
28
|
+
quick_wins: string[];
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Flatten triage p0/p1/p2 buckets into a ViewportItem array.
|
|
33
|
+
*
|
|
34
|
+
* Order: p0_critical → p1_important → p2_nice_to_have (preserves API order within buckets).
|
|
35
|
+
* Severity mapping: p0 → "critical", p1 → "warning", p2 → "moderate".
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildViewportItems(data: TriageApiResponse["data"]): ViewportItem[];
|
|
38
|
+
export interface TriageCommandOptions {
|
|
39
|
+
job?: string;
|
|
40
|
+
file?: string;
|
|
41
|
+
format?: string;
|
|
42
|
+
strict?: boolean;
|
|
43
|
+
continueOnError?: boolean;
|
|
44
|
+
machine?: boolean;
|
|
45
|
+
verbose?: boolean;
|
|
46
|
+
base?: string;
|
|
47
|
+
apiKey?: string;
|
|
48
|
+
}
|
|
49
|
+
export declare function handleTriage(opts: TriageCommandOptions): Promise<void>;
|
|
16
50
|
export declare function registerTriageCommand(program: Command): void;
|
|
51
|
+
export {};
|
|
17
52
|
//# sourceMappingURL=triage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triage.d.ts","sourceRoot":"","sources":["../../src/commands/triage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"triage.d.ts","sourceRoot":"","sources":["../../src/commands/triage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAwK,KAAK,YAAY,EAAqC,MAAM,eAAe,CAAC;AAc3P,UAAU,UAAU;IAClB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CAClD;AAED,UAAU,iBAAiB;IACzB,IAAI,EAAE;QACJ,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,YAAY,EAAE,UAAU,EAAE,CAAC;QAC3B,eAAe,EAAE,UAAU,EAAE,CAAC;QAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;CACH;AA0HD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,GAAG,YAAY,EAAE,CAkClF;AAMD,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwJ5E;AAMD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+C5D"}
|