workflow-agent-cli 2.23.0 → 2.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +15 -15
  2. package/dist/{auto-fix-7WAESKYO.js → auto-fix-WGRYEFLJ.js} +2 -2
  3. package/dist/{chunk-IWFUJ2DS.js → chunk-DWHIY7R4.js} +20 -9
  4. package/dist/chunk-DWHIY7R4.js.map +1 -0
  5. package/dist/{chunk-D36IFZUZ.js → chunk-EHRI6BI6.js} +15 -4
  6. package/dist/chunk-EHRI6BI6.js.map +1 -0
  7. package/dist/{chunk-M6RHIUSM.js → chunk-K42R54II.js} +147 -54
  8. package/dist/chunk-K42R54II.js.map +1 -0
  9. package/dist/{chunk-XGS2VFBP.js → chunk-MBRMT5ZG.js} +865 -18
  10. package/dist/chunk-MBRMT5ZG.js.map +1 -0
  11. package/dist/{chunk-YELUGXOM.js → chunk-NPJJZHJG.js} +1 -1
  12. package/dist/chunk-NPJJZHJG.js.map +1 -0
  13. package/dist/{chunk-UWJ2ZGEI.js → chunk-OH6TK27N.js} +3 -3
  14. package/dist/{chunk-ZLDJ2OGO.js → chunk-WK7D2AVV.js} +11 -3
  15. package/dist/{chunk-ZLDJ2OGO.js.map → chunk-WK7D2AVV.js.map} +1 -1
  16. package/dist/cli/index.js +771 -285
  17. package/dist/cli/index.js.map +1 -1
  18. package/dist/config/index.js +2 -2
  19. package/dist/index.d.ts +87 -56
  20. package/dist/index.js +26 -10
  21. package/dist/scripts/postinstall.js +1 -1
  22. package/dist/scripts/postinstall.js.map +1 -1
  23. package/dist/sync-HHQM3GKR.js +7 -0
  24. package/dist/validators/index.js +1 -1
  25. package/dist/verify-PA7R6FBJ.js +8 -0
  26. package/package.json +2 -2
  27. package/dist/chunk-3ADL5QDN.js +0 -396
  28. package/dist/chunk-3ADL5QDN.js.map +0 -1
  29. package/dist/chunk-D36IFZUZ.js.map +0 -1
  30. package/dist/chunk-IWFUJ2DS.js.map +0 -1
  31. package/dist/chunk-M6RHIUSM.js.map +0 -1
  32. package/dist/chunk-XGS2VFBP.js.map +0 -1
  33. package/dist/chunk-YELUGXOM.js.map +0 -1
  34. package/dist/sync-6T5TD4QS.js +0 -7
  35. package/dist/verify-TX6LFMI6.js +0 -8
  36. /package/dist/{auto-fix-7WAESKYO.js.map → auto-fix-WGRYEFLJ.js.map} +0 -0
  37. /package/dist/{chunk-UWJ2ZGEI.js.map → chunk-OH6TK27N.js.map} +0 -0
  38. /package/dist/{sync-6T5TD4QS.js.map → sync-HHQM3GKR.js.map} +0 -0
  39. /package/dist/{verify-TX6LFMI6.js.map → verify-PA7R6FBJ.js.map} +0 -0
@@ -130,26 +130,86 @@ async function hasSimpleGitHooksConfig(projectPath) {
130
130
  }
131
131
  }
132
132
  async function detectFramework(projectPath) {
133
+ const result = await detectAllPlatforms(projectPath);
134
+ return result.primary;
135
+ }
136
+ async function detectAllPlatforms(projectPath) {
137
+ const detected = [];
133
138
  try {
134
139
  const pkgPath = join2(projectPath, "package.json");
135
- if (!existsSync2(pkgPath)) return "unknown";
136
- const pkg = JSON.parse(await readFile2(pkgPath, "utf-8"));
137
- const deps = { ...pkg.dependencies, ...pkg.devDependencies };
138
- if (existsSync2(join2(projectPath, "shopify.theme.toml")) || existsSync2(join2(projectPath, "config/settings_schema.json")) || deps["@shopify/cli"] || deps["@shopify/theme"]) {
139
- return "shopify";
140
+ const hasPkgJson = existsSync2(pkgPath);
141
+ let deps = {};
142
+ let composerDeps = {};
143
+ if (hasPkgJson) {
144
+ const pkg = JSON.parse(await readFile2(pkgPath, "utf-8"));
145
+ deps = { ...pkg.dependencies, ...pkg.devDependencies };
146
+ }
147
+ const composerPath = join2(projectPath, "composer.json");
148
+ if (existsSync2(composerPath)) {
149
+ try {
150
+ const composer = JSON.parse(await readFile2(composerPath, "utf-8"));
151
+ composerDeps = { ...composer.require, ...composer["require-dev"] };
152
+ } catch {
153
+ }
154
+ }
155
+ if (deps["@shopify/hydrogen"] || deps["@shopify/remix-oxygen"] || existsSync2(join2(projectPath, "hydrogen.config.ts")) || existsSync2(join2(projectPath, "hydrogen.config.js"))) {
156
+ detected.push("shopify-hydrogen");
157
+ }
158
+ if (existsSync2(join2(projectPath, "shopify.theme.toml")) || existsSync2(join2(projectPath, "config/settings_schema.json")) || deps["@shopify/theme"] || await hasLiquidFiles(projectPath)) {
159
+ detected.push("shopify-theme");
160
+ }
161
+ const hasWooCommerce = Object.keys(composerDeps).some(
162
+ (dep) => dep.toLowerCase().includes("woocommerce")
163
+ ) || existsSync2(join2(projectPath, "wp-content/plugins/woocommerce"));
164
+ const isWordPress = existsSync2(join2(projectPath, "wp-content")) || existsSync2(join2(projectPath, "functions.php")) || await hasWordPressThemeHeader(projectPath) || Object.keys(composerDeps).some(
165
+ (dep) => dep.includes("wordpress") || dep.includes("johnpbloch/wordpress")
166
+ );
167
+ if (hasWooCommerce && isWordPress) {
168
+ detected.push("woocommerce");
169
+ } else if (isWordPress) {
170
+ detected.push("wordpress");
171
+ }
172
+ if (existsSync2(join2(projectPath, "app/etc/env.php")) || existsSync2(join2(projectPath, "bin/magento")) || Object.keys(composerDeps).some((dep) => dep.startsWith("magento/"))) {
173
+ detected.push("magento");
174
+ }
175
+ if (deps.next) detected.push("nextjs");
176
+ if (deps["@remix-run/react"] && !detected.includes("shopify-hydrogen")) {
177
+ detected.push("remix");
140
178
  }
141
- if (deps.next) return "nextjs";
142
- if (deps["@remix-run/react"]) return "remix";
143
- if (deps.nuxt) return "nuxt";
144
- if (deps.vue) return "vue";
145
- if (deps.svelte || deps["@sveltejs/kit"]) return "svelte";
146
- if (deps.react && !deps.next) return "react";
147
- if (deps.hono) return "hono";
148
- if (deps.express) return "express";
149
- if (deps["@types/node"] || pkg.type === "module") return "node";
150
- return "unknown";
179
+ if (deps.nuxt) detected.push("nuxt");
180
+ if (deps.vue && !deps.nuxt) detected.push("vue");
181
+ if (deps.svelte || deps["@sveltejs/kit"]) detected.push("svelte");
182
+ if (deps.react && !deps.next && !detected.includes("shopify-hydrogen")) {
183
+ detected.push("react");
184
+ }
185
+ if (deps.hono) detected.push("hono");
186
+ if (deps.express) detected.push("express");
187
+ if ((deps["@types/node"] || hasPkgJson && existsSync2(pkgPath)) && detected.length === 0) {
188
+ detected.push("node");
189
+ }
190
+ const primary = detected.length > 0 ? detected[0] : "unknown";
191
+ return { primary, detected };
151
192
  } catch {
152
- return "unknown";
193
+ return { primary: "unknown", detected: [] };
194
+ }
195
+ }
196
+ async function hasLiquidFiles(projectPath) {
197
+ try {
198
+ const { readdir } = await import("fs/promises");
199
+ const entries = await readdir(projectPath);
200
+ return entries.some((entry) => entry.endsWith(".liquid"));
201
+ } catch {
202
+ return false;
203
+ }
204
+ }
205
+ async function hasWordPressThemeHeader(projectPath) {
206
+ try {
207
+ const stylePath = join2(projectPath, "style.css");
208
+ if (!existsSync2(stylePath)) return false;
209
+ const content = await readFile2(stylePath, "utf-8");
210
+ return content.includes("Theme Name:");
211
+ } catch {
212
+ return false;
153
213
  }
154
214
  }
155
215
  async function generateSetupPlans(projectPath, packageManager, isTypeScript, framework, existing, scripts, isMonorepo2) {
@@ -1111,12 +1171,799 @@ async function readPrettierConfig(projectPath) {
1111
1171
  return {};
1112
1172
  }
1113
1173
 
1174
+ // src/utils/check-runner.ts
1175
+ import { execa as execa3 } from "execa";
1176
+ import chalk from "chalk";
1177
+ import { existsSync as existsSync3, readFileSync } from "fs";
1178
+ import { join as join3 } from "path";
1179
+ import * as p from "@clack/prompts";
1180
+ var QUALITY_CHECKS = [
1181
+ {
1182
+ name: "typecheck",
1183
+ displayName: "Type Check",
1184
+ command: "pnpm",
1185
+ args: ["typecheck"],
1186
+ canAutoFix: false,
1187
+ // TypeScript errors need manual/LLM fix
1188
+ requiredScript: "typecheck",
1189
+ fallbackCommand: ["tsc", "--noEmit"]
1190
+ },
1191
+ {
1192
+ name: "lint",
1193
+ displayName: "Lint",
1194
+ command: "pnpm",
1195
+ args: ["lint"],
1196
+ fixCommand: "pnpm",
1197
+ fixArgs: ["lint", "--fix"],
1198
+ canAutoFix: true,
1199
+ requiredScript: "lint"
1200
+ },
1201
+ {
1202
+ name: "format",
1203
+ displayName: "Format",
1204
+ command: "pnpm",
1205
+ args: ["format", "--check"],
1206
+ fixCommand: "pnpm",
1207
+ fixArgs: ["format"],
1208
+ canAutoFix: true,
1209
+ requiredScript: "format"
1210
+ },
1211
+ {
1212
+ name: "test",
1213
+ displayName: "Tests",
1214
+ command: "pnpm",
1215
+ args: ["test"],
1216
+ canAutoFix: false,
1217
+ // Tests need manual/LLM fix
1218
+ requiredScript: "test"
1219
+ },
1220
+ {
1221
+ name: "build",
1222
+ displayName: "Build",
1223
+ command: "pnpm",
1224
+ args: ["build"],
1225
+ canAutoFix: false,
1226
+ // Build errors need manual/LLM fix
1227
+ requiredScript: "build"
1228
+ }
1229
+ ];
1230
+ var PLATFORM_CLI_INSTALL = {
1231
+ "shopify-theme": {
1232
+ cli: "shopify",
1233
+ install: "npm install -g @shopify/cli @shopify/theme",
1234
+ requiresComposer: false,
1235
+ displayName: "Shopify Theme"
1236
+ },
1237
+ "shopify-hydrogen": {
1238
+ cli: "shopify",
1239
+ install: "npm install -g @shopify/cli",
1240
+ requiresComposer: false,
1241
+ displayName: "Shopify Hydrogen"
1242
+ },
1243
+ wordpress: {
1244
+ cli: "phpcs",
1245
+ install: "composer global require squizlabs/php_codesniffer wp-coding-standards/wpcs && phpcs --config-set installed_paths $(composer global config home)/vendor/wp-coding-standards/wpcs",
1246
+ requiresComposer: true,
1247
+ displayName: "WordPress"
1248
+ },
1249
+ magento: {
1250
+ cli: "phpcs",
1251
+ install: "composer global require squizlabs/php_codesniffer magento/magento-coding-standard && phpcs --config-set installed_paths $(composer global config home)/vendor/magento/magento-coding-standard",
1252
+ requiresComposer: true,
1253
+ displayName: "Magento"
1254
+ },
1255
+ woocommerce: {
1256
+ cli: "phpcs",
1257
+ install: "composer global require squizlabs/php_codesniffer automattic/woocommerce-sniffs && phpcs --config-set installed_paths $(composer global config home)/vendor/automattic/woocommerce-sniffs",
1258
+ requiresComposer: true,
1259
+ displayName: "WooCommerce"
1260
+ }
1261
+ };
1262
+ var PLATFORM_CHECKS = [
1263
+ {
1264
+ platform: "shopify-theme",
1265
+ name: "shopify-theme-check",
1266
+ displayName: "Shopify Theme Check",
1267
+ command: "shopify",
1268
+ args: ["theme", "check"],
1269
+ canAutoFix: false
1270
+ },
1271
+ {
1272
+ platform: "shopify-hydrogen",
1273
+ name: "shopify-hydrogen-check",
1274
+ displayName: "Shopify Hydrogen Check",
1275
+ command: "shopify",
1276
+ args: ["hydrogen", "check"],
1277
+ canAutoFix: false
1278
+ },
1279
+ {
1280
+ platform: "wordpress",
1281
+ name: "wordpress-phpcs",
1282
+ displayName: "WordPress Coding Standards",
1283
+ command: "phpcs",
1284
+ args: ["--standard=WordPress", "."],
1285
+ fixCommand: "phpcbf",
1286
+ fixArgs: ["--standard=WordPress", "."],
1287
+ canAutoFix: true
1288
+ },
1289
+ {
1290
+ platform: "magento",
1291
+ name: "magento-phpcs",
1292
+ displayName: "Magento Coding Standards",
1293
+ command: "phpcs",
1294
+ args: ["--standard=Magento2", "."],
1295
+ fixCommand: "phpcbf",
1296
+ fixArgs: ["--standard=Magento2", "."],
1297
+ canAutoFix: true
1298
+ },
1299
+ {
1300
+ platform: "woocommerce",
1301
+ name: "woocommerce-phpcs",
1302
+ displayName: "WooCommerce Coding Standards",
1303
+ command: "phpcs",
1304
+ args: ["--standard=WooCommerce-Core", "."],
1305
+ fixCommand: "phpcbf",
1306
+ fixArgs: ["--standard=WooCommerce-Core", "."],
1307
+ canAutoFix: true
1308
+ }
1309
+ ];
1310
+ function getAvailableScripts(cwd) {
1311
+ const packageJsonPath = join3(cwd, "package.json");
1312
+ if (!existsSync3(packageJsonPath)) {
1313
+ return /* @__PURE__ */ new Set();
1314
+ }
1315
+ try {
1316
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
1317
+ return new Set(Object.keys(packageJson.scripts || {}));
1318
+ } catch {
1319
+ return /* @__PURE__ */ new Set();
1320
+ }
1321
+ }
1322
+ async function commandExists(cmd) {
1323
+ try {
1324
+ await execa3("which", [cmd]);
1325
+ return true;
1326
+ } catch {
1327
+ return false;
1328
+ }
1329
+ }
1330
+ async function getApplicableChecks(cwd) {
1331
+ const availableScripts = getAvailableScripts(cwd);
1332
+ const applicableChecks = [];
1333
+ for (const check of QUALITY_CHECKS) {
1334
+ if (!check.requiredScript) {
1335
+ applicableChecks.push(check);
1336
+ continue;
1337
+ }
1338
+ if (availableScripts.has(check.requiredScript)) {
1339
+ applicableChecks.push(check);
1340
+ continue;
1341
+ }
1342
+ if (check.fallbackCommand && check.fallbackCommand.length > 0) {
1343
+ const fallbackCmd = check.fallbackCommand[0];
1344
+ if (await commandExists(fallbackCmd)) {
1345
+ applicableChecks.push({
1346
+ ...check,
1347
+ command: fallbackCmd,
1348
+ args: check.fallbackCommand.slice(1)
1349
+ });
1350
+ continue;
1351
+ }
1352
+ }
1353
+ }
1354
+ return applicableChecks;
1355
+ }
1356
+ async function ensureComposer() {
1357
+ const hasComposer = await commandExists("composer");
1358
+ if (!hasComposer) {
1359
+ console.log(chalk.red("\n\u274C Composer is required but not installed.\n"));
1360
+ console.log(chalk.yellow("Please install Composer for your platform:\n"));
1361
+ const platform = process.platform;
1362
+ if (platform === "darwin") {
1363
+ console.log(chalk.cyan(" macOS (Homebrew):"));
1364
+ console.log(chalk.dim(" brew install composer\n"));
1365
+ } else if (platform === "linux") {
1366
+ console.log(chalk.cyan(" Ubuntu/Debian:"));
1367
+ console.log(chalk.dim(" sudo apt install composer\n"));
1368
+ console.log(chalk.cyan(" Fedora/CentOS:"));
1369
+ console.log(chalk.dim(" sudo dnf install composer\n"));
1370
+ console.log(chalk.cyan(" Arch Linux:"));
1371
+ console.log(chalk.dim(" sudo pacman -S composer\n"));
1372
+ } else if (platform === "win32") {
1373
+ console.log(chalk.cyan(" Windows (Scoop):"));
1374
+ console.log(chalk.dim(" scoop install composer\n"));
1375
+ console.log(chalk.cyan(" Windows (Chocolatey):"));
1376
+ console.log(chalk.dim(" choco install composer\n"));
1377
+ }
1378
+ console.log(chalk.cyan(" Or download from:"));
1379
+ console.log(chalk.dim(" https://getcomposer.org/download/\n"));
1380
+ process.exit(1);
1381
+ }
1382
+ }
1383
+ async function promptPlatformChoice(detected) {
1384
+ const platformTypes = detected.filter(
1385
+ (d) => Object.keys(PLATFORM_CLI_INSTALL).includes(d)
1386
+ );
1387
+ if (platformTypes.length === 0) {
1388
+ return detected[0] || "unknown";
1389
+ }
1390
+ if (platformTypes.length === 1) {
1391
+ return platformTypes[0];
1392
+ }
1393
+ console.log(
1394
+ chalk.yellow("\n\u{1F50D} Multiple platforms detected in this project:\n")
1395
+ );
1396
+ const options = platformTypes.map((pt) => ({
1397
+ value: pt,
1398
+ label: PLATFORM_CLI_INSTALL[pt].displayName
1399
+ }));
1400
+ const choice = await p.select({
1401
+ message: "Which platform would you like to run checks for?",
1402
+ options
1403
+ });
1404
+ if (p.isCancel(choice)) {
1405
+ console.log(chalk.yellow("\n\u26A0\uFE0F Platform check cancelled."));
1406
+ process.exit(0);
1407
+ }
1408
+ return choice;
1409
+ }
1410
+ async function ensurePlatformCLI(platform) {
1411
+ const config = PLATFORM_CLI_INSTALL[platform];
1412
+ if (config.requiresComposer) {
1413
+ await ensureComposer();
1414
+ }
1415
+ const hasCLI = await commandExists(config.cli);
1416
+ if (!hasCLI) {
1417
+ console.log(
1418
+ chalk.yellow(
1419
+ `
1420
+ \u{1F4E6} ${config.displayName} CLI (${config.cli}) not found. Installing...
1421
+ `
1422
+ )
1423
+ );
1424
+ console.log(chalk.dim(` Running: ${config.install}
1425
+ `));
1426
+ try {
1427
+ await execa3("sh", ["-c", config.install], {
1428
+ stdio: "inherit"
1429
+ });
1430
+ const nowHasCLI = await commandExists(config.cli);
1431
+ if (!nowHasCLI) {
1432
+ console.log(
1433
+ chalk.red(
1434
+ `
1435
+ \u274C Failed to install ${config.cli}. Please install manually:
1436
+ `
1437
+ )
1438
+ );
1439
+ console.log(chalk.dim(` ${config.install}
1440
+ `));
1441
+ process.exit(1);
1442
+ }
1443
+ console.log(
1444
+ chalk.green(`
1445
+ \u2705 ${config.displayName} CLI installed successfully.
1446
+ `)
1447
+ );
1448
+ } catch (error) {
1449
+ console.log(chalk.red(`
1450
+ \u274C Failed to install ${config.cli}:
1451
+ `));
1452
+ console.log(chalk.dim(` ${error.message}
1453
+ `));
1454
+ console.log(chalk.yellow("Please install manually:\n"));
1455
+ console.log(chalk.dim(` ${config.install}
1456
+ `));
1457
+ process.exit(1);
1458
+ }
1459
+ }
1460
+ }
1461
+ async function getPlatformChecks(cwd) {
1462
+ const detection = await detectAllPlatforms(cwd);
1463
+ const platformsWithChecks = detection.detected.filter(
1464
+ (d) => Object.keys(PLATFORM_CLI_INSTALL).includes(d)
1465
+ );
1466
+ if (platformsWithChecks.length === 0) {
1467
+ return [];
1468
+ }
1469
+ let selectedPlatform;
1470
+ if (platformsWithChecks.length === 1) {
1471
+ selectedPlatform = platformsWithChecks[0];
1472
+ } else {
1473
+ const choice = await promptPlatformChoice(detection.detected);
1474
+ if (!Object.keys(PLATFORM_CLI_INSTALL).includes(choice)) {
1475
+ return [];
1476
+ }
1477
+ selectedPlatform = choice;
1478
+ }
1479
+ await ensurePlatformCLI(selectedPlatform);
1480
+ return PLATFORM_CHECKS.filter((check) => check.platform === selectedPlatform);
1481
+ }
1482
+ var SKIPPABLE_ERROR_PATTERNS = [
1483
+ {
1484
+ pattern: /No files matching the pattern .* were found/i,
1485
+ reason: "No files found matching the lint pattern"
1486
+ },
1487
+ {
1488
+ pattern: /No files matching .* were found/i,
1489
+ reason: "No files found matching the pattern"
1490
+ },
1491
+ {
1492
+ pattern: /No inputs were found in config file/i,
1493
+ reason: "No TypeScript files found"
1494
+ },
1495
+ {
1496
+ pattern: /No files matching the pattern .* are present/i,
1497
+ reason: "No files present matching the pattern"
1498
+ }
1499
+ ];
1500
+ function isSkippableError(output) {
1501
+ for (const { pattern, reason } of SKIPPABLE_ERROR_PATTERNS) {
1502
+ if (pattern.test(output)) {
1503
+ return reason;
1504
+ }
1505
+ }
1506
+ return void 0;
1507
+ }
1508
+ async function runCheck(check, cwd) {
1509
+ const startTime = Date.now();
1510
+ try {
1511
+ const result = await execa3(check.command, check.args, {
1512
+ cwd,
1513
+ reject: false,
1514
+ all: true
1515
+ });
1516
+ const duration = Date.now() - startTime;
1517
+ if (result.exitCode === 0) {
1518
+ return {
1519
+ check,
1520
+ success: true,
1521
+ output: result.all || "",
1522
+ duration
1523
+ };
1524
+ } else {
1525
+ const combinedOutput = result.all || result.stderr || "";
1526
+ const skipReason = isSkippableError(combinedOutput);
1527
+ if (skipReason) {
1528
+ return {
1529
+ check,
1530
+ success: true,
1531
+ // Treat as success since it's not a real failure
1532
+ output: result.all || "",
1533
+ duration,
1534
+ skipped: true,
1535
+ skipReason
1536
+ };
1537
+ }
1538
+ return {
1539
+ check,
1540
+ success: false,
1541
+ output: result.all || "",
1542
+ error: result.stderr || result.all || "Check failed",
1543
+ duration
1544
+ };
1545
+ }
1546
+ } catch (error) {
1547
+ const duration = Date.now() - startTime;
1548
+ const execaError = error;
1549
+ return {
1550
+ check,
1551
+ success: false,
1552
+ output: execaError.all?.toString() || execaError.message || "",
1553
+ error: execaError.message,
1554
+ duration
1555
+ };
1556
+ }
1557
+ }
1558
+ async function applyFix(check, cwd) {
1559
+ if (!check.canAutoFix || !check.fixCommand) {
1560
+ return { success: false, output: "Check does not support auto-fix" };
1561
+ }
1562
+ try {
1563
+ const result = await execa3(check.fixCommand, check.fixArgs || [], {
1564
+ cwd,
1565
+ reject: false,
1566
+ all: true
1567
+ });
1568
+ if (result.exitCode === 0) {
1569
+ return {
1570
+ success: true,
1571
+ output: result.all || ""
1572
+ };
1573
+ }
1574
+ const combinedOutput = result.all || result.stderr || "";
1575
+ const skipReason = isSkippableError(combinedOutput);
1576
+ if (skipReason) {
1577
+ return {
1578
+ success: true,
1579
+ // Treat as success since it's not a real failure
1580
+ output: result.all || "",
1581
+ skipped: true,
1582
+ skipReason
1583
+ };
1584
+ }
1585
+ return {
1586
+ success: false,
1587
+ output: result.all || ""
1588
+ };
1589
+ } catch (error) {
1590
+ const execaError = error;
1591
+ return {
1592
+ success: false,
1593
+ output: execaError.message
1594
+ };
1595
+ }
1596
+ }
1597
+ function formatFixCommand(check) {
1598
+ if (!check.fixCommand) return "";
1599
+ return `${check.fixCommand} ${(check.fixArgs || []).join(" ")}`;
1600
+ }
1601
+ async function runPlatformChecks(cwd, log, autoFix, dryRun) {
1602
+ const results = [];
1603
+ try {
1604
+ const platformChecks = await getPlatformChecks(cwd);
1605
+ if (platformChecks.length === 0) {
1606
+ return results;
1607
+ }
1608
+ log(`
1609
+ ${"\u2501".repeat(50)}`, "info");
1610
+ log(`\u{1F527} Platform-Specific Checks`, "info");
1611
+ log(`${"\u2501".repeat(50)}
1612
+ `, "info");
1613
+ for (let i = 0; i < platformChecks.length; i++) {
1614
+ const check = platformChecks[i];
1615
+ const stepNum = i + 1;
1616
+ const totalSteps = platformChecks.length;
1617
+ log(
1618
+ `\u{1F4CB} Platform ${stepNum}/${totalSteps}: ${check.displayName}...`,
1619
+ "info"
1620
+ );
1621
+ const result = await runCheck(check, cwd);
1622
+ results.push(result);
1623
+ if (result.success) {
1624
+ log(`\u2705 ${check.displayName} passed (${result.duration}ms)`, "success");
1625
+ } else {
1626
+ log(`\u274C ${check.displayName} failed`, "error");
1627
+ if (autoFix && check.canAutoFix && check.fixCommand) {
1628
+ if (dryRun) {
1629
+ log(
1630
+ `\u{1F527} [DRY-RUN] Would run: ${formatFixCommand(check)}`,
1631
+ "warning"
1632
+ );
1633
+ continue;
1634
+ }
1635
+ log(`\u{1F527} Attempting auto-fix for ${check.displayName}...`, "warning");
1636
+ const fixResult = await applyFix(check, cwd);
1637
+ if (fixResult.success) {
1638
+ log(`\u2728 Auto-fix applied for ${check.displayName}`, "success");
1639
+ const reResult = await runCheck(check, cwd);
1640
+ results[results.length - 1] = reResult;
1641
+ if (reResult.success) {
1642
+ log(`\u2705 ${check.displayName} now passes`, "success");
1643
+ } else {
1644
+ log(`\u26A0\uFE0F ${check.displayName} still failing after fix`, "error");
1645
+ }
1646
+ } else {
1647
+ log(`\u26A0\uFE0F Auto-fix failed for ${check.displayName}`, "error");
1648
+ }
1649
+ } else if (!check.canAutoFix) {
1650
+ log(`\u26A0\uFE0F ${check.displayName} requires manual fix`, "error");
1651
+ }
1652
+ if (result.error) {
1653
+ const errorPreview = result.error.slice(0, 500);
1654
+ log(`
1655
+ ${chalk.dim(errorPreview)}`, "error");
1656
+ if (result.error.length > 500) {
1657
+ log(
1658
+ chalk.dim(`... (${result.error.length - 500} more characters)`),
1659
+ "error"
1660
+ );
1661
+ }
1662
+ }
1663
+ }
1664
+ }
1665
+ } catch (error) {
1666
+ log(`
1667
+ \u26A0\uFE0F Platform check error: ${error.message}`, "warning");
1668
+ }
1669
+ return results;
1670
+ }
1671
+ async function runAllChecks(cwd, options = {}) {
1672
+ const {
1673
+ maxRetries = 10,
1674
+ autoFix = true,
1675
+ dryRun = false,
1676
+ onProgress,
1677
+ includePlatformChecks = true
1678
+ } = options;
1679
+ const log = (message, type = "info") => {
1680
+ if (onProgress) {
1681
+ onProgress(message, type);
1682
+ } else {
1683
+ switch (type) {
1684
+ case "success":
1685
+ console.log(chalk.green(message));
1686
+ break;
1687
+ case "error":
1688
+ console.log(chalk.red(message));
1689
+ break;
1690
+ case "warning":
1691
+ console.log(chalk.yellow(message));
1692
+ break;
1693
+ default:
1694
+ console.log(message);
1695
+ }
1696
+ }
1697
+ };
1698
+ let attempt = 0;
1699
+ let fixesApplied = 0;
1700
+ const appliedFixes = [];
1701
+ const pendingFixes = [];
1702
+ const applicableChecks = await getApplicableChecks(cwd);
1703
+ const skippedChecks = QUALITY_CHECKS.filter(
1704
+ (qc) => !applicableChecks.some((ac) => ac.name === qc.name)
1705
+ );
1706
+ if (skippedChecks.length > 0) {
1707
+ log(
1708
+ `
1709
+ \u23ED\uFE0F Skipping checks (scripts not found): ${skippedChecks.map((c) => c.displayName).join(", ")}`,
1710
+ "warning"
1711
+ );
1712
+ }
1713
+ if (applicableChecks.length === 0) {
1714
+ log(
1715
+ `
1716
+ \u26A0\uFE0F No applicable checks found. Add scripts to package.json: typecheck, lint, format, test, build`,
1717
+ "warning"
1718
+ );
1719
+ return {
1720
+ success: true,
1721
+ results: [],
1722
+ totalAttempts: 0,
1723
+ fixesApplied: 0,
1724
+ appliedFixes: []
1725
+ };
1726
+ }
1727
+ while (attempt < maxRetries) {
1728
+ attempt++;
1729
+ log(`
1730
+ ${"\u2501".repeat(50)}`, "info");
1731
+ log(`\u{1F504} Validation Cycle ${attempt}/${maxRetries}`, "info");
1732
+ log(`${"\u2501".repeat(50)}
1733
+ `, "info");
1734
+ const results = [];
1735
+ let allPassed = true;
1736
+ let fixAppliedThisCycle = false;
1737
+ for (let i = 0; i < applicableChecks.length; i++) {
1738
+ const check = applicableChecks[i];
1739
+ const stepNum = i + 1;
1740
+ const totalSteps = applicableChecks.length;
1741
+ log(`\u{1F4CB} Step ${stepNum}/${totalSteps}: ${check.displayName}...`, "info");
1742
+ const result = await runCheck(check, cwd);
1743
+ results.push(result);
1744
+ if (result.success) {
1745
+ if (result.skipped) {
1746
+ log(
1747
+ `\u23ED\uFE0F ${check.displayName} skipped: ${result.skipReason} (${result.duration}ms)`,
1748
+ "warning"
1749
+ );
1750
+ } else {
1751
+ log(
1752
+ `\u2705 ${check.displayName} passed (${result.duration}ms)`,
1753
+ "success"
1754
+ );
1755
+ }
1756
+ } else {
1757
+ allPassed = false;
1758
+ log(`\u274C ${check.displayName} failed`, "error");
1759
+ if (autoFix && check.canAutoFix && check.fixCommand) {
1760
+ if (dryRun) {
1761
+ log(
1762
+ `\u{1F527} [DRY-RUN] Would run: ${formatFixCommand(check)}`,
1763
+ "warning"
1764
+ );
1765
+ pendingFixes.push({ check, command: formatFixCommand(check) });
1766
+ continue;
1767
+ }
1768
+ log(`\u{1F527} Attempting auto-fix for ${check.displayName}...`, "warning");
1769
+ const fixResult = await applyFix(check, cwd);
1770
+ if (fixResult.success) {
1771
+ if (fixResult.skipped) {
1772
+ log(
1773
+ `\u23ED\uFE0F ${check.displayName} skipped: ${fixResult.skipReason}`,
1774
+ "warning"
1775
+ );
1776
+ results[results.length - 1] = {
1777
+ ...results[results.length - 1],
1778
+ success: true,
1779
+ skipped: true,
1780
+ skipReason: fixResult.skipReason
1781
+ };
1782
+ allPassed = true;
1783
+ continue;
1784
+ }
1785
+ log(`\u2728 Auto-fix applied for ${check.displayName}`, "success");
1786
+ fixesApplied++;
1787
+ appliedFixes.push({
1788
+ checkName: check.name,
1789
+ displayName: check.displayName,
1790
+ command: formatFixCommand(check),
1791
+ timestamp: /* @__PURE__ */ new Date()
1792
+ });
1793
+ fixAppliedThisCycle = true;
1794
+ log(
1795
+ `
1796
+ \u{1F504} Fix applied - restarting all checks to verify...`,
1797
+ "warning"
1798
+ );
1799
+ break;
1800
+ } else {
1801
+ log(`\u26A0\uFE0F Auto-fix failed for ${check.displayName}`, "error");
1802
+ log(` Manual intervention required`, "error");
1803
+ if (result.error) {
1804
+ const errorPreview = result.error.slice(0, 500);
1805
+ log(`
1806
+ ${chalk.dim(errorPreview)}`, "error");
1807
+ if (result.error.length > 500) {
1808
+ log(
1809
+ chalk.dim(
1810
+ `... (${result.error.length - 500} more characters)`
1811
+ ),
1812
+ "error"
1813
+ );
1814
+ }
1815
+ }
1816
+ return {
1817
+ success: false,
1818
+ results,
1819
+ totalAttempts: attempt,
1820
+ fixesApplied,
1821
+ appliedFixes
1822
+ };
1823
+ }
1824
+ } else {
1825
+ if (check.canAutoFix) {
1826
+ log(
1827
+ `\u26A0\uFE0F ${check.displayName} can be fixed with: ${formatFixCommand(check)}`,
1828
+ "warning"
1829
+ );
1830
+ } else {
1831
+ log(`\u26A0\uFE0F ${check.displayName} requires manual fix`, "error");
1832
+ }
1833
+ if (result.error) {
1834
+ const errorPreview = result.error.slice(0, 500);
1835
+ log(`
1836
+ ${chalk.dim(errorPreview)}`, "error");
1837
+ if (result.error.length > 500) {
1838
+ log(
1839
+ chalk.dim(`... (${result.error.length - 500} more characters)`),
1840
+ "error"
1841
+ );
1842
+ }
1843
+ }
1844
+ if (!dryRun) {
1845
+ return {
1846
+ success: false,
1847
+ results,
1848
+ totalAttempts: attempt,
1849
+ fixesApplied,
1850
+ appliedFixes
1851
+ };
1852
+ }
1853
+ }
1854
+ }
1855
+ }
1856
+ if (dryRun && pendingFixes.length > 0) {
1857
+ log(`
1858
+ ${"\u2501".repeat(50)}`, "info");
1859
+ log(`\u{1F4CB} DRY-RUN SUMMARY`, "info");
1860
+ log(`${"\u2501".repeat(50)}`, "info");
1861
+ log(`
1862
+ The following fixes would be applied:`, "warning");
1863
+ for (const fix of pendingFixes) {
1864
+ log(` \u2022 ${fix.check.displayName}: ${fix.command}`, "info");
1865
+ }
1866
+ log(`
1867
+ Run without --dry-run to apply fixes.`, "info");
1868
+ return {
1869
+ success: false,
1870
+ results,
1871
+ totalAttempts: attempt,
1872
+ fixesApplied: 0,
1873
+ appliedFixes: [],
1874
+ pendingFixes
1875
+ };
1876
+ }
1877
+ if (allPassed) {
1878
+ if (includePlatformChecks) {
1879
+ const platformCheckResults = await runPlatformChecks(
1880
+ cwd,
1881
+ log,
1882
+ autoFix,
1883
+ dryRun
1884
+ );
1885
+ if (platformCheckResults.length > 0) {
1886
+ const platformFailed = platformCheckResults.some((r) => !r.success);
1887
+ if (platformFailed) {
1888
+ return {
1889
+ success: false,
1890
+ results: [...results, ...platformCheckResults],
1891
+ totalAttempts: attempt,
1892
+ fixesApplied,
1893
+ appliedFixes
1894
+ };
1895
+ }
1896
+ results.push(...platformCheckResults);
1897
+ }
1898
+ }
1899
+ return {
1900
+ success: true,
1901
+ results,
1902
+ totalAttempts: attempt,
1903
+ fixesApplied,
1904
+ appliedFixes
1905
+ };
1906
+ }
1907
+ if (!fixAppliedThisCycle) {
1908
+ return {
1909
+ success: false,
1910
+ results,
1911
+ totalAttempts: attempt,
1912
+ fixesApplied,
1913
+ appliedFixes
1914
+ };
1915
+ }
1916
+ }
1917
+ log(`
1918
+ \u274C Maximum retries (${maxRetries}) exceeded`, "error");
1919
+ return {
1920
+ success: false,
1921
+ results: [],
1922
+ totalAttempts: attempt,
1923
+ fixesApplied,
1924
+ appliedFixes
1925
+ };
1926
+ }
1927
+ async function hasUncommittedChanges(cwd) {
1928
+ try {
1929
+ const result = await execa3("git", ["status", "--porcelain"], { cwd });
1930
+ return result.stdout.trim().length > 0;
1931
+ } catch {
1932
+ return false;
1933
+ }
1934
+ }
1935
+ async function stageAllChanges(cwd) {
1936
+ try {
1937
+ await execa3("git", ["add", "-A"], { cwd });
1938
+ return true;
1939
+ } catch {
1940
+ return false;
1941
+ }
1942
+ }
1943
+
1114
1944
  export {
1115
1945
  detectPackageManager,
1116
1946
  isMonorepo,
1117
1947
  analyzeProject,
1948
+ detectAllPlatforms,
1118
1949
  generateAuditReport,
1119
1950
  formatAuditReport,
1120
- runAllSetups
1951
+ runAllSetups,
1952
+ QUALITY_CHECKS,
1953
+ PLATFORM_CLI_INSTALL,
1954
+ PLATFORM_CHECKS,
1955
+ getAvailableScripts,
1956
+ getApplicableChecks,
1957
+ ensureComposer,
1958
+ promptPlatformChoice,
1959
+ ensurePlatformCLI,
1960
+ getPlatformChecks,
1961
+ SKIPPABLE_ERROR_PATTERNS,
1962
+ isSkippableError,
1963
+ runCheck,
1964
+ applyFix,
1965
+ runAllChecks,
1966
+ hasUncommittedChanges,
1967
+ stageAllChanges
1121
1968
  };
1122
- //# sourceMappingURL=chunk-XGS2VFBP.js.map
1969
+ //# sourceMappingURL=chunk-MBRMT5ZG.js.map