workflow-agent-cli 2.20.1 → 2.21.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Workflow Agent Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,321 @@
1
+ // src/utils/check-runner.ts
2
+ import { execa } from "execa";
3
+ import chalk from "chalk";
4
+ var QUALITY_CHECKS = [
5
+ {
6
+ name: "typecheck",
7
+ displayName: "Type Check",
8
+ command: "pnpm",
9
+ args: ["typecheck"],
10
+ canAutoFix: false
11
+ // TypeScript errors need manual/LLM fix
12
+ },
13
+ {
14
+ name: "lint",
15
+ displayName: "Lint",
16
+ command: "pnpm",
17
+ args: ["lint"],
18
+ fixCommand: "pnpm",
19
+ fixArgs: ["lint", "--fix"],
20
+ canAutoFix: true
21
+ },
22
+ {
23
+ name: "format",
24
+ displayName: "Format",
25
+ command: "pnpm",
26
+ args: ["format", "--check"],
27
+ fixCommand: "pnpm",
28
+ fixArgs: ["format"],
29
+ canAutoFix: true
30
+ },
31
+ {
32
+ name: "test",
33
+ displayName: "Tests",
34
+ command: "pnpm",
35
+ args: ["test"],
36
+ canAutoFix: false
37
+ // Tests need manual/LLM fix
38
+ },
39
+ {
40
+ name: "build",
41
+ displayName: "Build",
42
+ command: "pnpm",
43
+ args: ["build"],
44
+ canAutoFix: false
45
+ // Build errors need manual/LLM fix
46
+ }
47
+ ];
48
+ async function runCheck(check, cwd) {
49
+ const startTime = Date.now();
50
+ try {
51
+ const result = await execa(check.command, check.args, {
52
+ cwd,
53
+ reject: false,
54
+ all: true
55
+ });
56
+ const duration = Date.now() - startTime;
57
+ if (result.exitCode === 0) {
58
+ return {
59
+ check,
60
+ success: true,
61
+ output: result.all || "",
62
+ duration
63
+ };
64
+ } else {
65
+ return {
66
+ check,
67
+ success: false,
68
+ output: result.all || "",
69
+ error: result.stderr || result.all || "Check failed",
70
+ duration
71
+ };
72
+ }
73
+ } catch (error) {
74
+ const duration = Date.now() - startTime;
75
+ const execaError = error;
76
+ return {
77
+ check,
78
+ success: false,
79
+ output: execaError.all?.toString() || execaError.message || "",
80
+ error: execaError.message,
81
+ duration
82
+ };
83
+ }
84
+ }
85
+ async function applyFix(check, cwd) {
86
+ if (!check.canAutoFix || !check.fixCommand) {
87
+ return { success: false, output: "Check does not support auto-fix" };
88
+ }
89
+ try {
90
+ const result = await execa(check.fixCommand, check.fixArgs || [], {
91
+ cwd,
92
+ reject: false,
93
+ all: true
94
+ });
95
+ return {
96
+ success: result.exitCode === 0,
97
+ output: result.all || ""
98
+ };
99
+ } catch (error) {
100
+ const execaError = error;
101
+ return {
102
+ success: false,
103
+ output: execaError.message
104
+ };
105
+ }
106
+ }
107
+ function formatFixCommand(check) {
108
+ if (!check.fixCommand) return "";
109
+ return `${check.fixCommand} ${(check.fixArgs || []).join(" ")}`;
110
+ }
111
+ async function runAllChecks(cwd, options = {}) {
112
+ const {
113
+ maxRetries = 10,
114
+ autoFix = true,
115
+ dryRun = false,
116
+ onProgress
117
+ } = options;
118
+ const log = (message, type = "info") => {
119
+ if (onProgress) {
120
+ onProgress(message, type);
121
+ } else {
122
+ switch (type) {
123
+ case "success":
124
+ console.log(chalk.green(message));
125
+ break;
126
+ case "error":
127
+ console.log(chalk.red(message));
128
+ break;
129
+ case "warning":
130
+ console.log(chalk.yellow(message));
131
+ break;
132
+ default:
133
+ console.log(message);
134
+ }
135
+ }
136
+ };
137
+ let attempt = 0;
138
+ let fixesApplied = 0;
139
+ const appliedFixes = [];
140
+ const pendingFixes = [];
141
+ while (attempt < maxRetries) {
142
+ attempt++;
143
+ log(`
144
+ ${"\u2501".repeat(50)}`, "info");
145
+ log(`\u{1F504} Validation Cycle ${attempt}/${maxRetries}`, "info");
146
+ log(`${"\u2501".repeat(50)}
147
+ `, "info");
148
+ const results = [];
149
+ let allPassed = true;
150
+ let fixAppliedThisCycle = false;
151
+ for (let i = 0; i < QUALITY_CHECKS.length; i++) {
152
+ const check = QUALITY_CHECKS[i];
153
+ const stepNum = i + 1;
154
+ const totalSteps = QUALITY_CHECKS.length;
155
+ log(`\u{1F4CB} Step ${stepNum}/${totalSteps}: ${check.displayName}...`, "info");
156
+ const result = await runCheck(check, cwd);
157
+ results.push(result);
158
+ if (result.success) {
159
+ log(`\u2705 ${check.displayName} passed (${result.duration}ms)`, "success");
160
+ } else {
161
+ allPassed = false;
162
+ log(`\u274C ${check.displayName} failed`, "error");
163
+ if (autoFix && check.canAutoFix && check.fixCommand) {
164
+ if (dryRun) {
165
+ log(
166
+ `\u{1F527} [DRY-RUN] Would run: ${formatFixCommand(check)}`,
167
+ "warning"
168
+ );
169
+ pendingFixes.push({ check, command: formatFixCommand(check) });
170
+ continue;
171
+ }
172
+ log(`\u{1F527} Attempting auto-fix for ${check.displayName}...`, "warning");
173
+ const fixResult = await applyFix(check, cwd);
174
+ if (fixResult.success) {
175
+ log(`\u2728 Auto-fix applied for ${check.displayName}`, "success");
176
+ fixesApplied++;
177
+ appliedFixes.push({
178
+ checkName: check.name,
179
+ displayName: check.displayName,
180
+ command: formatFixCommand(check),
181
+ timestamp: /* @__PURE__ */ new Date()
182
+ });
183
+ fixAppliedThisCycle = true;
184
+ log(
185
+ `
186
+ \u{1F504} Fix applied - restarting all checks to verify...`,
187
+ "warning"
188
+ );
189
+ break;
190
+ } else {
191
+ log(`\u26A0\uFE0F Auto-fix failed for ${check.displayName}`, "error");
192
+ log(` Manual intervention required`, "error");
193
+ if (result.error) {
194
+ const errorPreview = result.error.slice(0, 500);
195
+ log(`
196
+ ${chalk.dim(errorPreview)}`, "error");
197
+ if (result.error.length > 500) {
198
+ log(
199
+ chalk.dim(
200
+ `... (${result.error.length - 500} more characters)`
201
+ ),
202
+ "error"
203
+ );
204
+ }
205
+ }
206
+ return {
207
+ success: false,
208
+ results,
209
+ totalAttempts: attempt,
210
+ fixesApplied,
211
+ appliedFixes
212
+ };
213
+ }
214
+ } else {
215
+ if (check.canAutoFix) {
216
+ log(
217
+ `\u26A0\uFE0F ${check.displayName} can be fixed with: ${formatFixCommand(check)}`,
218
+ "warning"
219
+ );
220
+ } else {
221
+ log(`\u26A0\uFE0F ${check.displayName} requires manual fix`, "error");
222
+ }
223
+ if (result.error) {
224
+ const errorPreview = result.error.slice(0, 500);
225
+ log(`
226
+ ${chalk.dim(errorPreview)}`, "error");
227
+ if (result.error.length > 500) {
228
+ log(
229
+ chalk.dim(`... (${result.error.length - 500} more characters)`),
230
+ "error"
231
+ );
232
+ }
233
+ }
234
+ if (!dryRun) {
235
+ return {
236
+ success: false,
237
+ results,
238
+ totalAttempts: attempt,
239
+ fixesApplied,
240
+ appliedFixes
241
+ };
242
+ }
243
+ }
244
+ }
245
+ }
246
+ if (dryRun && pendingFixes.length > 0) {
247
+ log(`
248
+ ${"\u2501".repeat(50)}`, "info");
249
+ log(`\u{1F4CB} DRY-RUN SUMMARY`, "info");
250
+ log(`${"\u2501".repeat(50)}`, "info");
251
+ log(`
252
+ The following fixes would be applied:`, "warning");
253
+ for (const fix of pendingFixes) {
254
+ log(` \u2022 ${fix.check.displayName}: ${fix.command}`, "info");
255
+ }
256
+ log(`
257
+ Run without --dry-run to apply fixes.`, "info");
258
+ return {
259
+ success: false,
260
+ results,
261
+ totalAttempts: attempt,
262
+ fixesApplied: 0,
263
+ appliedFixes: [],
264
+ pendingFixes
265
+ };
266
+ }
267
+ if (allPassed) {
268
+ return {
269
+ success: true,
270
+ results,
271
+ totalAttempts: attempt,
272
+ fixesApplied,
273
+ appliedFixes
274
+ };
275
+ }
276
+ if (!fixAppliedThisCycle) {
277
+ return {
278
+ success: false,
279
+ results,
280
+ totalAttempts: attempt,
281
+ fixesApplied,
282
+ appliedFixes
283
+ };
284
+ }
285
+ }
286
+ log(`
287
+ \u274C Maximum retries (${maxRetries}) exceeded`, "error");
288
+ return {
289
+ success: false,
290
+ results: [],
291
+ totalAttempts: attempt,
292
+ fixesApplied,
293
+ appliedFixes
294
+ };
295
+ }
296
+ async function hasUncommittedChanges(cwd) {
297
+ try {
298
+ const result = await execa("git", ["status", "--porcelain"], { cwd });
299
+ return result.stdout.trim().length > 0;
300
+ } catch {
301
+ return false;
302
+ }
303
+ }
304
+ async function stageAllChanges(cwd) {
305
+ try {
306
+ await execa("git", ["add", "-A"], { cwd });
307
+ return true;
308
+ } catch {
309
+ return false;
310
+ }
311
+ }
312
+
313
+ export {
314
+ QUALITY_CHECKS,
315
+ runCheck,
316
+ applyFix,
317
+ runAllChecks,
318
+ hasUncommittedChanges,
319
+ stageAllChanges
320
+ };
321
+ //# sourceMappingURL=chunk-KVM6A42U.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/check-runner.ts"],"sourcesContent":["/**\n * Check Runner - Orchestrates quality checks with fix-and-revalidate pattern\n *\n * Pattern: Run check → If fails, fix → Re-run ALL checks from start\n * This ensures fixes don't introduce new issues in earlier checks.\n */\n\nimport { execa, type ExecaError } from \"execa\";\nimport chalk from \"chalk\";\n\nexport interface CheckDefinition {\n name: string;\n displayName: string;\n command: string;\n args: string[];\n fixCommand?: string;\n fixArgs?: string[];\n canAutoFix: boolean;\n}\n\nexport interface CheckResult {\n check: CheckDefinition;\n success: boolean;\n output: string;\n error?: string;\n duration: number;\n}\n\nexport interface AppliedFix {\n checkName: string;\n displayName: string;\n command: string;\n timestamp: Date;\n}\n\nexport interface RunAllChecksResult {\n success: boolean;\n results: CheckResult[];\n totalAttempts: number;\n fixesApplied: number;\n appliedFixes: AppliedFix[];\n pendingFixes?: Array<{ check: CheckDefinition; command: string }>;\n}\n\nexport type ProgressType = \"info\" | \"success\" | \"error\" | \"warning\";\n\nexport interface CheckRunnerOptions {\n maxRetries?: number;\n autoFix?: boolean;\n dryRun?: boolean;\n onProgress?: (message: string, type: ProgressType) => void;\n}\n\n/**\n * Standard quality checks in recommended order\n * Order: typecheck → lint → format → test → build\n * Type errors cascade, so we fix them first\n */\nexport const QUALITY_CHECKS: CheckDefinition[] = [\n {\n name: \"typecheck\",\n displayName: \"Type Check\",\n command: \"pnpm\",\n args: [\"typecheck\"],\n canAutoFix: false, // TypeScript errors need manual/LLM fix\n },\n {\n name: \"lint\",\n displayName: \"Lint\",\n command: \"pnpm\",\n args: [\"lint\"],\n fixCommand: \"pnpm\",\n fixArgs: [\"lint\", \"--fix\"],\n canAutoFix: true,\n },\n {\n name: \"format\",\n displayName: \"Format\",\n command: \"pnpm\",\n args: [\"format\", \"--check\"],\n fixCommand: \"pnpm\",\n fixArgs: [\"format\"],\n canAutoFix: true,\n },\n {\n name: \"test\",\n displayName: \"Tests\",\n command: \"pnpm\",\n args: [\"test\"],\n canAutoFix: false, // Tests need manual/LLM fix\n },\n {\n name: \"build\",\n displayName: \"Build\",\n command: \"pnpm\",\n args: [\"build\"],\n canAutoFix: false, // Build errors need manual/LLM fix\n },\n];\n\n/**\n * Run a single check\n */\nexport async function runCheck(\n check: CheckDefinition,\n cwd: string,\n): Promise<CheckResult> {\n const startTime = Date.now();\n\n try {\n const result = await execa(check.command, check.args, {\n cwd,\n reject: false,\n all: true,\n });\n\n const duration = Date.now() - startTime;\n\n if (result.exitCode === 0) {\n return {\n check,\n success: true,\n output: result.all || \"\",\n duration,\n };\n } else {\n return {\n check,\n success: false,\n output: result.all || \"\",\n error: result.stderr || result.all || \"Check failed\",\n duration,\n };\n }\n } catch (error) {\n const duration = Date.now() - startTime;\n const execaError = error as ExecaError;\n\n return {\n check,\n success: false,\n output: execaError.all?.toString() || execaError.message || \"\",\n error: execaError.message,\n duration,\n };\n }\n}\n\n/**\n * Apply fix for a check that supports auto-fix\n */\nexport async function applyFix(\n check: CheckDefinition,\n cwd: string,\n): Promise<{ success: boolean; output: string }> {\n if (!check.canAutoFix || !check.fixCommand) {\n return { success: false, output: \"Check does not support auto-fix\" };\n }\n\n try {\n const result = await execa(check.fixCommand, check.fixArgs || [], {\n cwd,\n reject: false,\n all: true,\n });\n\n return {\n success: result.exitCode === 0,\n output: result.all || \"\",\n };\n } catch (error) {\n const execaError = error as ExecaError;\n return {\n success: false,\n output: execaError.message,\n };\n }\n}\n\n/**\n * Format a fix command for display\n */\nfunction formatFixCommand(check: CheckDefinition): string {\n if (!check.fixCommand) return \"\";\n return `${check.fixCommand} ${(check.fixArgs || []).join(\" \")}`;\n}\n\n/**\n * Run all quality checks with fix-and-revalidate pattern\n *\n * When a check fails and can be auto-fixed:\n * 1. Apply the fix\n * 2. Re-run ALL checks from the beginning\n * 3. Repeat until all pass or max retries reached\n *\n * @param cwd - Working directory\n * @param options - Configuration options\n */\nexport async function runAllChecks(\n cwd: string,\n options: CheckRunnerOptions = {},\n): Promise<RunAllChecksResult> {\n const {\n maxRetries = 10,\n autoFix = true,\n dryRun = false,\n onProgress,\n } = options;\n\n const log = (message: string, type: ProgressType = \"info\") => {\n if (onProgress) {\n onProgress(message, type);\n } else {\n // Default console output with colors\n switch (type) {\n case \"success\":\n console.log(chalk.green(message));\n break;\n case \"error\":\n console.log(chalk.red(message));\n break;\n case \"warning\":\n console.log(chalk.yellow(message));\n break;\n default:\n console.log(message);\n }\n }\n };\n\n let attempt = 0;\n let fixesApplied = 0;\n const appliedFixes: AppliedFix[] = [];\n const pendingFixes: Array<{ check: CheckDefinition; command: string }> = [];\n\n while (attempt < maxRetries) {\n attempt++;\n\n log(`\\n${\"━\".repeat(50)}`, \"info\");\n log(`🔄 Validation Cycle ${attempt}/${maxRetries}`, \"info\");\n log(`${\"━\".repeat(50)}\\n`, \"info\");\n\n const results: CheckResult[] = [];\n let allPassed = true;\n let fixAppliedThisCycle = false;\n\n // Run each check in order\n for (let i = 0; i < QUALITY_CHECKS.length; i++) {\n const check = QUALITY_CHECKS[i];\n const stepNum = i + 1;\n const totalSteps = QUALITY_CHECKS.length;\n\n log(`📋 Step ${stepNum}/${totalSteps}: ${check.displayName}...`, \"info\");\n\n const result = await runCheck(check, cwd);\n results.push(result);\n\n if (result.success) {\n log(`✅ ${check.displayName} passed (${result.duration}ms)`, \"success\");\n } else {\n allPassed = false;\n log(`❌ ${check.displayName} failed`, \"error\");\n\n // Try to auto-fix if possible\n if (autoFix && check.canAutoFix && check.fixCommand) {\n if (dryRun) {\n // In dry-run mode, just record what would be fixed\n log(\n `🔧 [DRY-RUN] Would run: ${formatFixCommand(check)}`,\n \"warning\",\n );\n pendingFixes.push({ check, command: formatFixCommand(check) });\n\n // Continue to next check to show all issues\n continue;\n }\n\n log(`🔧 Attempting auto-fix for ${check.displayName}...`, \"warning\");\n\n const fixResult = await applyFix(check, cwd);\n\n if (fixResult.success) {\n log(`✨ Auto-fix applied for ${check.displayName}`, \"success\");\n fixesApplied++;\n appliedFixes.push({\n checkName: check.name,\n displayName: check.displayName,\n command: formatFixCommand(check),\n timestamp: new Date(),\n });\n fixAppliedThisCycle = true;\n\n // IMPORTANT: Re-run ALL checks from the beginning\n log(\n `\\n🔄 Fix applied - restarting all checks to verify...`,\n \"warning\",\n );\n break; // Exit the for loop to restart from the beginning\n } else {\n log(`⚠️ Auto-fix failed for ${check.displayName}`, \"error\");\n log(` Manual intervention required`, \"error\");\n\n // Show error details\n if (result.error) {\n const errorPreview = result.error.slice(0, 500);\n log(`\\n${chalk.dim(errorPreview)}`, \"error\");\n if (result.error.length > 500) {\n log(\n chalk.dim(\n `... (${result.error.length - 500} more characters)`,\n ),\n \"error\",\n );\n }\n }\n\n return {\n success: false,\n results,\n totalAttempts: attempt,\n fixesApplied,\n appliedFixes,\n };\n }\n } else {\n // Cannot auto-fix this check\n if (check.canAutoFix) {\n log(\n `⚠️ ${check.displayName} can be fixed with: ${formatFixCommand(check)}`,\n \"warning\",\n );\n } else {\n log(`⚠️ ${check.displayName} requires manual fix`, \"error\");\n }\n\n // Show error details\n if (result.error) {\n const errorPreview = result.error.slice(0, 500);\n log(`\\n${chalk.dim(errorPreview)}`, \"error\");\n if (result.error.length > 500) {\n log(\n chalk.dim(`... (${result.error.length - 500} more characters)`),\n \"error\",\n );\n }\n }\n\n if (!dryRun) {\n return {\n success: false,\n results,\n totalAttempts: attempt,\n fixesApplied,\n appliedFixes,\n };\n }\n }\n }\n }\n\n // Handle dry-run completion\n if (dryRun && pendingFixes.length > 0) {\n log(`\\n${\"━\".repeat(50)}`, \"info\");\n log(`📋 DRY-RUN SUMMARY`, \"info\");\n log(`${\"━\".repeat(50)}`, \"info\");\n log(`\\nThe following fixes would be applied:`, \"warning\");\n for (const fix of pendingFixes) {\n log(` • ${fix.check.displayName}: ${fix.command}`, \"info\");\n }\n log(`\\nRun without --dry-run to apply fixes.`, \"info\");\n\n return {\n success: false,\n results,\n totalAttempts: attempt,\n fixesApplied: 0,\n appliedFixes: [],\n pendingFixes,\n };\n }\n\n // If all checks passed, we're done!\n if (allPassed) {\n return {\n success: true,\n results,\n totalAttempts: attempt,\n fixesApplied,\n appliedFixes,\n };\n }\n\n // If no fix was applied this cycle but we still failed, we're stuck\n if (!fixAppliedThisCycle) {\n return {\n success: false,\n results,\n totalAttempts: attempt,\n fixesApplied,\n appliedFixes,\n };\n }\n\n // Otherwise, continue to next cycle (fix was applied, need to re-verify)\n }\n\n // Max retries exceeded\n log(`\\n❌ Maximum retries (${maxRetries}) exceeded`, \"error\");\n\n return {\n success: false,\n results: [],\n totalAttempts: attempt,\n fixesApplied,\n appliedFixes,\n };\n}\n\n/**\n * Check if there are uncommitted changes in git\n */\nexport async function hasUncommittedChanges(cwd: string): Promise<boolean> {\n try {\n const result = await execa(\"git\", [\"status\", \"--porcelain\"], { cwd });\n return result.stdout.trim().length > 0;\n } catch {\n return false;\n }\n}\n\n/**\n * Stage all changes in git\n */\nexport async function stageAllChanges(cwd: string): Promise<boolean> {\n try {\n await execa(\"git\", [\"add\", \"-A\"], { cwd });\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":";AAOA,SAAS,aAA8B;AACvC,OAAO,WAAW;AAkDX,IAAM,iBAAoC;AAAA,EAC/C;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,IACT,MAAM,CAAC,WAAW;AAAA,IAClB,YAAY;AAAA;AAAA,EACd;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,IACT,MAAM,CAAC,MAAM;AAAA,IACb,YAAY;AAAA,IACZ,SAAS,CAAC,QAAQ,OAAO;AAAA,IACzB,YAAY;AAAA,EACd;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,IACT,MAAM,CAAC,UAAU,SAAS;AAAA,IAC1B,YAAY;AAAA,IACZ,SAAS,CAAC,QAAQ;AAAA,IAClB,YAAY;AAAA,EACd;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,IACT,MAAM,CAAC,MAAM;AAAA,IACb,YAAY;AAAA;AAAA,EACd;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,IACT,MAA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c,CAAC;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAGA,QAAI,WAAW;AACb,aAAO;AAAA,QACL,SAAS;AAAA,QACT;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAGA,QAAI,CAAC,qBAAqB;AACxB,aAAO;AAAA,QACL,SAAS;AAAA,QACT;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EAGF;AAGA,MAAI;AAAA,0BAAwB,UAAU,cAAc,OAAO;AAE3D,SAAO;AAAA,IACL,SAAS;AAAA,IACT,SAAS,CAAC;AAAA,IACV,eAAe;AAAA,IACf;AAAA,IACA;AAAA,EACF;AACF;AAKA,eAAsB,sBAAsB,KAA+B;AACzE,MAAI;AACF,UAAM,SAAS,MAAM,MAAM,OAAO,CAAC,UAAU,aAAa,GAAG,EAAE,IAAI,CAAC;AACpE,WAAO,OAAO,OAAO,KAAK,EAAE,SAAS;AAAA,EACvC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAKA,eAAsB,gBAAgB,KAA+B;AACnE,MAAI;AACF,UAAM,MAAM,OAAO,CAAC,OAAO,IAAI,GAAG,EAAE,IAAI,CAAC;AACzC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,238 @@
1
+ import {
2
+ hasUncommittedChanges,
3
+ runAllChecks,
4
+ stageAllChanges
5
+ } from "./chunk-KVM6A42U.js";
6
+
7
+ // src/cli/commands/verify.ts
8
+ import chalk from "chalk";
9
+ import { execa } from "execa";
10
+ import {
11
+ PatternStore,
12
+ TelemetryCollector,
13
+ ContributorManager
14
+ } from "@hawkinside_out/workflow-improvement-tracker";
15
+ async function verifyCommand(options) {
16
+ const cwd = process.cwd();
17
+ const maxRetries = options.maxRetries ? parseInt(options.maxRetries, 10) : 10;
18
+ const autoFix = options.fix ?? false;
19
+ const shouldCommit = options.commit ?? false;
20
+ const dryRun = options.dryRun ?? false;
21
+ const learnFromFixes = options.learn ?? false;
22
+ console.log(chalk.bold.cyan("\n\u{1F50D} Workflow Agent Quality Verification\n"));
23
+ if (dryRun) {
24
+ console.log(chalk.yellow("\u{1F4CB} DRY-RUN MODE: No changes will be applied\n"));
25
+ }
26
+ console.log(chalk.dim(` Auto-fix: ${autoFix ? "enabled" : "disabled"}`));
27
+ console.log(chalk.dim(` Max retries: ${maxRetries}`));
28
+ console.log(chalk.dim(` Commit on success: ${shouldCommit ? "yes" : "no"}`));
29
+ console.log(chalk.dim(` Dry-run: ${dryRun ? "yes" : "no"}`));
30
+ console.log(
31
+ chalk.dim(` Learn from fixes: ${learnFromFixes ? "yes" : "no"}`)
32
+ );
33
+ const startTime = Date.now();
34
+ const result = await runAllChecks(cwd, {
35
+ maxRetries,
36
+ autoFix,
37
+ dryRun
38
+ });
39
+ const totalTime = ((Date.now() - startTime) / 1e3).toFixed(2);
40
+ console.log(`
41
+ ${"\u2501".repeat(50)}`);
42
+ if (result.success) {
43
+ console.log(chalk.bold.green("\n\u2705 ALL QUALITY CHECKS PASSED!\n"));
44
+ console.log(chalk.dim(` Total time: ${totalTime}s`));
45
+ console.log(chalk.dim(` Validation cycles: ${result.totalAttempts}`));
46
+ console.log(chalk.dim(` Fixes applied: ${result.fixesApplied}`));
47
+ if (learnFromFixes && result.fixesApplied > 0 && !dryRun) {
48
+ await recordSuccessfulFixes(cwd, result);
49
+ }
50
+ if (shouldCommit) {
51
+ const hasChanges = await hasUncommittedChanges(cwd);
52
+ if (hasChanges) {
53
+ console.log(chalk.cyan("\n\u{1F4E6} Staging and committing changes...\n"));
54
+ const staged = await stageAllChanges(cwd);
55
+ if (!staged) {
56
+ console.log(chalk.red("\u274C Failed to stage changes"));
57
+ process.exit(1);
58
+ }
59
+ try {
60
+ await execa(
61
+ "git",
62
+ ["commit", "-m", "chore: auto-fix quality issues"],
63
+ { cwd }
64
+ );
65
+ console.log(chalk.green("\u2705 Changes committed successfully"));
66
+ } catch (error) {
67
+ console.log(chalk.red("\u274C Failed to commit changes"));
68
+ console.log(chalk.dim(error.message));
69
+ process.exit(1);
70
+ }
71
+ } else {
72
+ console.log(chalk.dim("\n No changes to commit."));
73
+ }
74
+ }
75
+ console.log(chalk.cyan("\n\u{1F4A1} Next steps:\n"));
76
+ console.log(chalk.dim(" 1. git add ."));
77
+ console.log(
78
+ chalk.dim(' 2. git commit -m "<type>(<scope>): <description>"')
79
+ );
80
+ console.log(chalk.dim(" 3. git push origin <branch-name>"));
81
+ console.log("");
82
+ process.exit(0);
83
+ } else {
84
+ console.log(chalk.bold.red("\n\u274C QUALITY CHECKS FAILED\n"));
85
+ console.log(chalk.dim(` Total time: ${totalTime}s`));
86
+ console.log(chalk.dim(` Validation cycles: ${result.totalAttempts}`));
87
+ console.log(chalk.dim(` Fixes applied: ${result.fixesApplied}`));
88
+ if (result.pendingFixes && result.pendingFixes.length > 0) {
89
+ console.log(chalk.yellow("\n\u{1F4CB} Pending fixes (dry-run):"));
90
+ for (const fix of result.pendingFixes) {
91
+ console.log(chalk.dim(` \u2022 ${fix.check.displayName}: ${fix.command}`));
92
+ }
93
+ }
94
+ console.log(
95
+ chalk.yellow("\n\u26A0\uFE0F Please fix the errors above and run again.")
96
+ );
97
+ console.log(
98
+ chalk.dim(" Run with --fix to auto-fix lint and format issues.")
99
+ );
100
+ console.log("");
101
+ process.exit(1);
102
+ }
103
+ }
104
+ async function recordSuccessfulFixes(cwd, result) {
105
+ try {
106
+ const contributorManager = new ContributorManager(cwd);
107
+ const telemetryEnabled = await contributorManager.isTelemetryEnabled();
108
+ if (!telemetryEnabled) {
109
+ return;
110
+ }
111
+ const store = new PatternStore(cwd);
112
+ const telemetry = new TelemetryCollector(cwd);
113
+ let framework = "unknown";
114
+ let frameworkVersion = "0.0.0";
115
+ try {
116
+ const fs = await import("fs");
117
+ const path = await import("path");
118
+ const packageJsonPath = path.join(cwd, "package.json");
119
+ const packageJson = JSON.parse(
120
+ await fs.promises.readFile(packageJsonPath, "utf-8")
121
+ );
122
+ const deps = {
123
+ ...packageJson.dependencies,
124
+ ...packageJson.devDependencies
125
+ };
126
+ if (deps["next"]) {
127
+ framework = "next";
128
+ frameworkVersion = deps["next"].replace(/[\^~]/, "");
129
+ } else if (deps["react"]) {
130
+ framework = "react";
131
+ frameworkVersion = deps["react"].replace(/[\^~]/, "");
132
+ } else if (deps["vue"]) {
133
+ framework = "vue";
134
+ frameworkVersion = deps["vue"].replace(/[\^~]/, "");
135
+ } else if (deps["express"]) {
136
+ framework = "express";
137
+ frameworkVersion = deps["express"].replace(/[\^~]/, "");
138
+ }
139
+ } catch {
140
+ }
141
+ if (result.appliedFixes && result.appliedFixes.length > 0) {
142
+ console.log(
143
+ chalk.cyan("\n\u{1F4DA} Recording successful fixes for learning...\n")
144
+ );
145
+ for (const fix of result.appliedFixes) {
146
+ const patternName = `Auto-fix: ${fix.displayName}`;
147
+ const patternId = crypto.randomUUID();
148
+ const existingPatterns = await store.listFixPatterns({
149
+ tags: [{ category: "tool", name: fix.checkName }]
150
+ });
151
+ if (existingPatterns.success && existingPatterns.data && existingPatterns.data.length > 0) {
152
+ const existingPattern = existingPatterns.data[0];
153
+ await store.updateFixMetrics(existingPattern.id, true);
154
+ await telemetry.recordSuccess(
155
+ existingPattern.id,
156
+ "fix",
157
+ framework,
158
+ frameworkVersion
159
+ );
160
+ console.log(chalk.dim(` \u2713 Updated: ${existingPattern.name}`));
161
+ } else {
162
+ const now = (/* @__PURE__ */ new Date()).toISOString();
163
+ const newPattern = {
164
+ id: patternId,
165
+ name: patternName,
166
+ description: `Auto-fix pattern for ${fix.displayName} using command: ${fix.command}`,
167
+ category: "config",
168
+ tags: [
169
+ { category: "tool", name: fix.checkName },
170
+ { category: "framework", name: framework }
171
+ ],
172
+ trigger: {
173
+ errorPattern: fix.checkName,
174
+ errorMessage: `${fix.checkName} check failed`,
175
+ filePattern: "**/*"
176
+ },
177
+ solution: {
178
+ type: "command",
179
+ steps: [
180
+ {
181
+ order: 1,
182
+ action: "run",
183
+ target: fix.command,
184
+ description: `Run ${fix.command}`
185
+ }
186
+ ]
187
+ },
188
+ compatibility: {
189
+ framework,
190
+ frameworkVersion: `>=${frameworkVersion}`,
191
+ runtime: "node",
192
+ runtimeVersion: ">=18.0.0",
193
+ dependencies: []
194
+ },
195
+ metrics: {
196
+ applications: 1,
197
+ successes: 1,
198
+ failures: 0,
199
+ successRate: 100,
200
+ lastUsed: now,
201
+ lastSuccessful: now
202
+ },
203
+ source: "verify-fix",
204
+ isPrivate: true,
205
+ createdAt: now,
206
+ updatedAt: now
207
+ };
208
+ const saveResult = await store.saveFixPattern(newPattern);
209
+ if (saveResult.success) {
210
+ await telemetry.recordSuccess(
211
+ patternId,
212
+ "fix",
213
+ framework,
214
+ frameworkVersion
215
+ );
216
+ console.log(chalk.dim(` \u2713 Recorded: ${patternName}`));
217
+ }
218
+ }
219
+ }
220
+ console.log(
221
+ chalk.dim(`
222
+ Use 'workflow learn:list' to see recorded patterns.`)
223
+ );
224
+ }
225
+ } catch (error) {
226
+ console.log(
227
+ chalk.dim(
228
+ `
229
+ Note: Could not record learning patterns: ${error.message}`
230
+ )
231
+ );
232
+ }
233
+ }
234
+
235
+ export {
236
+ verifyCommand
237
+ };
238
+ //# sourceMappingURL=chunk-OMHCXETM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/commands/verify.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport {\n runAllChecks,\n hasUncommittedChanges,\n stageAllChanges,\n type RunAllChecksResult,\n} from \"../../utils/check-runner.js\";\nimport { execa } from \"execa\";\nimport {\n PatternStore,\n TelemetryCollector,\n ContributorManager,\n type FixPattern,\n} from \"@hawkinside_out/workflow-improvement-tracker\";\n\ninterface VerifyOptions {\n fix?: boolean;\n maxRetries?: string;\n commit?: boolean;\n dryRun?: boolean;\n learn?: boolean;\n}\n\n/**\n * Verify command - Run all quality checks with fix-and-revalidate pattern\n *\n * Pattern: Run check → If fails, fix → Re-run ALL checks from start\n * This ensures fixes don't introduce new issues in earlier checks.\n */\nexport async function verifyCommand(options: VerifyOptions) {\n const cwd = process.cwd();\n const maxRetries = options.maxRetries ? parseInt(options.maxRetries, 10) : 10;\n const autoFix = options.fix ?? false;\n const shouldCommit = options.commit ?? false;\n const dryRun = options.dryRun ?? false;\n const learnFromFixes = options.learn ?? false;\n\n console.log(chalk.bold.cyan(\"\\n🔍 Workflow Agent Quality Verification\\n\"));\n\n if (dryRun) {\n console.log(chalk.yellow(\"📋 DRY-RUN MODE: No changes will be applied\\n\"));\n }\n\n console.log(chalk.dim(` Auto-fix: ${autoFix ? \"enabled\" : \"disabled\"}`));\n console.log(chalk.dim(` Max retries: ${maxRetries}`));\n console.log(chalk.dim(` Commit on success: ${shouldCommit ? \"yes\" : \"no\"}`));\n console.log(chalk.dim(` Dry-run: ${dryRun ? \"yes\" : \"no\"}`));\n console.log(\n chalk.dim(` Learn from fixes: ${learnFromFixes ? \"yes\" : \"no\"}`),\n );\n\n const startTime = Date.now();\n\n const result = await runAllChecks(cwd, {\n maxRetries,\n autoFix,\n dryRun,\n });\n\n const totalTime = ((Date.now() - startTime) / 1000).toFixed(2);\n\n console.log(`\\n${\"━\".repeat(50)}`);\n\n if (result.success) {\n console.log(chalk.bold.green(\"\\n✅ ALL QUALITY CHECKS PASSED!\\n\"));\n console.log(chalk.dim(` Total time: ${totalTime}s`));\n console.log(chalk.dim(` Validation cycles: ${result.totalAttempts}`));\n console.log(chalk.dim(` Fixes applied: ${result.fixesApplied}`));\n\n // Auto-record successful fix patterns if learning is enabled\n if (learnFromFixes && result.fixesApplied > 0 && !dryRun) {\n await recordSuccessfulFixes(cwd, result);\n }\n\n // Handle commit if requested\n if (shouldCommit) {\n const hasChanges = await hasUncommittedChanges(cwd);\n\n if (hasChanges) {\n console.log(chalk.cyan(\"\\n📦 Staging and committing changes...\\n\"));\n\n const staged = await stageAllChanges(cwd);\n if (!staged) {\n console.log(chalk.red(\"❌ Failed to stage changes\"));\n process.exit(1);\n }\n\n try {\n await execa(\n \"git\",\n [\"commit\", \"-m\", \"chore: auto-fix quality issues\"],\n { cwd },\n );\n console.log(chalk.green(\"✅ Changes committed successfully\"));\n } catch (error) {\n console.log(chalk.red(\"❌ Failed to commit changes\"));\n console.log(chalk.dim((error as Error).message));\n process.exit(1);\n }\n } else {\n console.log(chalk.dim(\"\\n No changes to commit.\"));\n }\n }\n\n console.log(chalk.cyan(\"\\n💡 Next steps:\\n\"));\n console.log(chalk.dim(\" 1. git add .\"));\n console.log(\n chalk.dim(' 2. git commit -m \"<type>(<scope>): <description>\"'),\n );\n console.log(chalk.dim(\" 3. git push origin <branch-name>\"));\n console.log(\"\");\n\n process.exit(0);\n } else {\n console.log(chalk.bold.red(\"\\n❌ QUALITY CHECKS FAILED\\n\"));\n console.log(chalk.dim(` Total time: ${totalTime}s`));\n console.log(chalk.dim(` Validation cycles: ${result.totalAttempts}`));\n console.log(chalk.dim(` Fixes applied: ${result.fixesApplied}`));\n\n if (result.pendingFixes && result.pendingFixes.length > 0) {\n console.log(chalk.yellow(\"\\n📋 Pending fixes (dry-run):\"));\n for (const fix of result.pendingFixes) {\n console.log(chalk.dim(` • ${fix.check.displayName}: ${fix.command}`));\n }\n }\n\n console.log(\n chalk.yellow(\"\\n⚠️ Please fix the errors above and run again.\"),\n );\n console.log(\n chalk.dim(\" Run with --fix to auto-fix lint and format issues.\"),\n );\n console.log(\"\");\n\n process.exit(1);\n }\n}\n\n// ============================================\n// Auto-Record Learning Pattern\n// ============================================\n\n/**\n * Record successful fix patterns for learning\n * Called after verify succeeds with auto-fixes applied\n */\nasync function recordSuccessfulFixes(\n cwd: string,\n result: RunAllChecksResult,\n): Promise<void> {\n try {\n // Check if telemetry is enabled\n const contributorManager = new ContributorManager(cwd);\n const telemetryEnabled = await contributorManager.isTelemetryEnabled();\n\n if (!telemetryEnabled) {\n // Silently skip if telemetry is disabled\n return;\n }\n\n const store = new PatternStore(cwd);\n const telemetry = new TelemetryCollector(cwd);\n\n // Get package.json to determine framework\n let framework = \"unknown\";\n let frameworkVersion = \"0.0.0\";\n\n try {\n const fs = await import(\"node:fs\");\n const path = await import(\"node:path\");\n const packageJsonPath = path.join(cwd, \"package.json\");\n const packageJson = JSON.parse(\n await fs.promises.readFile(packageJsonPath, \"utf-8\"),\n );\n\n // Detect framework from dependencies\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n if (deps[\"next\"]) {\n framework = \"next\";\n frameworkVersion = deps[\"next\"].replace(/[\\^~]/, \"\");\n } else if (deps[\"react\"]) {\n framework = \"react\";\n frameworkVersion = deps[\"react\"].replace(/[\\^~]/, \"\");\n } else if (deps[\"vue\"]) {\n framework = \"vue\";\n frameworkVersion = deps[\"vue\"].replace(/[\\^~]/, \"\");\n } else if (deps[\"express\"]) {\n framework = \"express\";\n frameworkVersion = deps[\"express\"].replace(/[\\^~]/, \"\");\n }\n } catch {\n // Ignore package.json read errors\n }\n\n // Record telemetry for each fix applied\n if (result.appliedFixes && result.appliedFixes.length > 0) {\n console.log(\n chalk.cyan(\"\\n📚 Recording successful fixes for learning...\\n\"),\n );\n\n for (const fix of result.appliedFixes) {\n // Create or find existing pattern for this fix type\n const patternName = `Auto-fix: ${fix.displayName}`;\n const patternId = crypto.randomUUID();\n\n // Check if we already have a pattern for this fix type\n const existingPatterns = await store.listFixPatterns({\n tags: [{ category: \"tool\", name: fix.checkName }],\n });\n\n if (\n existingPatterns.success &&\n existingPatterns.data &&\n existingPatterns.data.length > 0\n ) {\n // Update metrics on existing pattern\n const existingPattern = existingPatterns.data[0];\n await store.updateFixMetrics(existingPattern.id, true);\n await telemetry.recordSuccess(\n existingPattern.id,\n \"fix\",\n framework,\n frameworkVersion,\n );\n console.log(chalk.dim(` ✓ Updated: ${existingPattern.name}`));\n } else {\n // Create new pattern\n const now = new Date().toISOString();\n const newPattern: FixPattern = {\n id: patternId,\n name: patternName,\n description: `Auto-fix pattern for ${fix.displayName} using command: ${fix.command}`,\n category: \"config\",\n tags: [\n { category: \"tool\", name: fix.checkName },\n { category: \"framework\", name: framework },\n ],\n trigger: {\n errorPattern: fix.checkName,\n errorMessage: `${fix.checkName} check failed`,\n filePattern: \"**/*\",\n },\n solution: {\n type: \"command\",\n steps: [\n {\n order: 1,\n action: \"run\",\n target: fix.command,\n description: `Run ${fix.command}`,\n },\n ],\n },\n compatibility: {\n framework,\n frameworkVersion: `>=${frameworkVersion}`,\n runtime: \"node\",\n runtimeVersion: \">=18.0.0\",\n dependencies: [],\n },\n metrics: {\n applications: 1,\n successes: 1,\n failures: 0,\n successRate: 100,\n lastUsed: now,\n lastSuccessful: now,\n },\n source: \"verify-fix\",\n isPrivate: true,\n createdAt: now,\n updatedAt: now,\n };\n\n const saveResult = await store.saveFixPattern(newPattern);\n if (saveResult.success) {\n await telemetry.recordSuccess(\n patternId,\n \"fix\",\n framework,\n frameworkVersion,\n );\n console.log(chalk.dim(` ✓ Recorded: ${patternName}`));\n }\n }\n }\n\n console.log(\n chalk.dim(`\\n Use 'workflow learn:list' to see recorded patterns.`),\n );\n }\n } catch (error) {\n // Don't fail the verify command if learning fails\n console.log(\n chalk.dim(\n `\\n Note: Could not record learning patterns: ${(error as Error).message}`,\n ),\n );\n }\n}\n"],"mappings":";;;;;;;AAAA,OAAO,WAAW;AAOlB,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAgBP,eAAsB,cAAc,SAAwB;AAC1D,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,aAAa,QAAQ,aAAa,SAAS,QAAQ,YAAY,EAAE,IAAI;AAC3E,QAAM,UAAU,QAAQ,OAAO;AAC/B,QAAM,eAAe,QAAQ,UAAU;AACvC,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,iBAAiB,QAAQ,SAAS;AAExC,UAAQ,IAAI,MAAM,KAAK,KAAK,mDAA4C,CAAC;AAEzE,MAAI,QAAQ;AACV,YAAQ,IAAI,MAAM,OAAO,sDAA+C,C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