@synchronized-studio/cmsassets-agent 0.3.9 → 0.4.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/dist/cli.js CHANGED
@@ -9,8 +9,8 @@ import {
9
9
  saveReport,
10
10
  scan,
11
11
  verify
12
- } from "./chunk-WXCGZDUK.js";
13
- import "./chunk-KYRW5D2O.js";
12
+ } from "./chunk-JZDGA2AR.js";
13
+ import "./chunk-MMNQQM5Y.js";
14
14
  import "./chunk-E74TGIFQ.js";
15
15
  import "./chunk-QGM4M3NI.js";
16
16
 
@@ -277,20 +277,10 @@ var initCommand = defineCommand({
277
277
  description: "Skip adding cmsassets:transform npm script",
278
278
  default: false
279
279
  },
280
- llm: {
281
- type: "boolean",
282
- description: "Enable LLM fallback for low-confidence patches when AST fails",
283
- default: false
284
- },
285
- "llm-all": {
286
- type: "boolean",
287
- description: "Try LLM for any failed AST patch. Requires --llm and OPENAI_API_KEY.",
288
- default: false
289
- },
290
- "llm-only": {
291
- type: "boolean",
292
- description: "Skip AST, use LLM for all patches (testing only). Requires OPENAI_API_KEY.",
293
- default: false
280
+ "patch-mode": {
281
+ type: "string",
282
+ description: "Patch strategy: ast | ai | hybrid",
283
+ default: "hybrid"
294
284
  },
295
285
  "ai-verify": {
296
286
  type: "boolean",
@@ -359,9 +349,7 @@ var initCommand = defineCommand({
359
349
  }
360
350
  const plan = createPlan(scanResult);
361
351
  if (args.slug) plan.env.placeholder = `https://${args.slug}.cmsassets.com`;
362
- if (args.llm || args["llm-only"]) plan.policies.allowLlmFallback = true;
363
- if (args["llm-all"]) plan.policies.llmFallbackForAll = true;
364
- if (args["llm-only"]) plan.policies.llmOnly = true;
352
+ if (args["patch-mode"]) plan.policies.patchMode = args["patch-mode"];
365
353
  if (args["dry-run"]) {
366
354
  consola3.log(pc.bold(" Dry Run \u2014 planned changes:"));
367
355
  consola3.log("");
@@ -389,9 +377,10 @@ var initCommand = defineCommand({
389
377
  consola3.warn("Package install failed. You can install it manually later.");
390
378
  }
391
379
  }
380
+ const patchMode = plan.policies.patchMode ?? "hybrid";
392
381
  const hasAiKey = !!process.env.OPENAI_API_KEY;
393
- let aiMode = args["ai-verify"] && hasAiKey;
394
- if (args["ai-verify"] && !hasAiKey) {
382
+ let aiMode = patchMode !== "ast" && hasAiKey;
383
+ if (patchMode !== "ast" && !hasAiKey) {
395
384
  consola3.log(` ${pc.yellow("No OPENAI_API_KEY")} \u2014 using mixed fallback (AST for high/medium, report-only for low)`);
396
385
  consola3.log("");
397
386
  } else if (aiMode) {
@@ -423,6 +412,7 @@ var initCommand = defineCommand({
423
412
  dryRun: false,
424
413
  includeTests: args["include-tests"],
425
414
  aiMode,
415
+ patchMode,
426
416
  aiModel: args["ai-model"] ?? "gpt-4o"
427
417
  });
428
418
  applyReport.installed = installed;
@@ -451,7 +441,7 @@ var initCommand = defineCommand({
451
441
  consola3.log(pc.bold(" CMS Assets Agent \u2014 AI Verification"));
452
442
  consola3.log(pc.dim(" \u2500".repeat(25)));
453
443
  consola3.log("");
454
- const { aiReviewAll } = await import("./aiReview-SSCUOREV.js");
444
+ const { aiReviewAll } = await import("./aiReview-7WRCOL7S.js");
455
445
  aiReviewReport = await aiReviewAll(root, appliedPaths, plan, {
456
446
  model: args["ai-model"] ?? "gpt-4o",
457
447
  maxIterations: parseInt(args["ai-max-iterations"] ?? "3", 10)
@@ -761,20 +751,10 @@ var applyCommand = defineCommand4({
761
751
  type: "string",
762
752
  description: "GitHub token for PR creation"
763
753
  },
764
- llm: {
765
- type: "boolean",
766
- description: "Enable LLM fallback for low-confidence patches when AST fails",
767
- default: false
768
- },
769
- "llm-all": {
770
- type: "boolean",
771
- description: "Try LLM for any failed AST patch (for testing). Requires --llm and OPENAI_API_KEY.",
772
- default: false
773
- },
774
- "llm-only": {
775
- type: "boolean",
776
- description: "Skip AST, use LLM for all patches (testing only). Requires --llm and OPENAI_API_KEY.",
777
- default: false
754
+ "patch-mode": {
755
+ type: "string",
756
+ description: "Patch strategy: ast | ai | hybrid",
757
+ default: "hybrid"
778
758
  },
779
759
  "ai-verify": {
780
760
  type: "boolean",
@@ -824,9 +804,7 @@ var applyCommand = defineCommand4({
824
804
  plan = generatePlan(root, args);
825
805
  }
826
806
  }
827
- if (args.llm || args["llm-only"]) plan.policies.allowLlmFallback = true;
828
- if (args["llm-all"]) plan.policies.llmFallbackForAll = true;
829
- if (args["llm-only"]) plan.policies.llmOnly = true;
807
+ if (args["patch-mode"]) plan.policies.patchMode = args["patch-mode"];
830
808
  if (args["max-files"]) plan.policies.maxFilesAutoApply = parseInt(args["max-files"], 10);
831
809
  if (args.force) plan.policies.maxFilesAutoApply = Number.MAX_SAFE_INTEGER;
832
810
  if (args["dry-run"]) {
@@ -865,11 +843,29 @@ var applyCommand = defineCommand4({
865
843
  consola6.warn("Package install failed. You can install it manually later.");
866
844
  }
867
845
  }
846
+ const patchMode = plan.policies.patchMode ?? "hybrid";
847
+ let aiMode = patchMode !== "ast";
848
+ if (aiMode) {
849
+ if (!process.env.OPENAI_API_KEY) {
850
+ consola6.warn("OPENAI_API_KEY is not set. Falling back to AST mode.");
851
+ aiMode = false;
852
+ } else {
853
+ const { checkAiVerifyReady } = await import("./openaiClient-YGAFYB3X.js");
854
+ const ready = await checkAiVerifyReady(root);
855
+ if (!ready.ok) {
856
+ consola6.warn(`AI mode unavailable: ${ready.reason}. Falling back to AST mode.`);
857
+ aiMode = false;
858
+ }
859
+ }
860
+ }
868
861
  consola6.info("Applying patches...");
869
862
  const applyReport = await applyPlan(plan, {
870
863
  dryRun: false,
871
864
  includeTests: args["include-tests"],
872
- maxFiles: args.force ? Number.MAX_SAFE_INTEGER : args["max-files"] ? parseInt(args["max-files"], 10) : void 0
865
+ maxFiles: args.force ? Number.MAX_SAFE_INTEGER : args["max-files"] ? parseInt(args["max-files"], 10) : void 0,
866
+ aiMode,
867
+ patchMode,
868
+ aiModel: args["ai-model"] ?? "gpt-4o"
873
869
  });
874
870
  applyReport.installed = installed;
875
871
  if (gitOps.isGitRepo(root) && branchCreated) {
@@ -897,7 +893,7 @@ var applyCommand = defineCommand4({
897
893
  consola6.log(pc4.bold(" CMS Assets Agent \u2014 AI Verification"));
898
894
  consola6.log(pc4.dim(" \u2500".repeat(25)));
899
895
  consola6.log("");
900
- const { aiReviewAll } = await import("./aiReview-SSCUOREV.js");
896
+ const { aiReviewAll } = await import("./aiReview-7WRCOL7S.js");
901
897
  aiReviewReport = await aiReviewAll(root, appliedPaths, plan, {
902
898
  model: args["ai-model"] ?? "gpt-4o",
903
899
  maxIterations: parseInt(args["ai-max-iterations"] ?? "3", 10)
@@ -1031,7 +1027,8 @@ var verifyCommand = defineCommand5({
1031
1027
  consola7.log("");
1032
1028
  const report = verify(root, {
1033
1029
  profile: args.profile,
1034
- framework: scanResult.framework.name
1030
+ framework: scanResult.framework.name,
1031
+ packageManager: scanResult.packageManager
1035
1032
  });
1036
1033
  consola7.log("");
1037
1034
  const pass = pc5.green("PASS");
@@ -1181,7 +1178,12 @@ var rollbackCommand = defineCommand7({
1181
1178
  },
1182
1179
  commit: {
1183
1180
  type: "string",
1184
- description: "Specific commit hash to rollback to (otherwise finds last agent commit)"
1181
+ description: "Specific commit hash to revert (otherwise finds last agent commit)"
1182
+ },
1183
+ "force-hard-reset": {
1184
+ type: "boolean",
1185
+ description: "Use destructive git reset --hard to target commit (dangerous).",
1186
+ default: false
1185
1187
  }
1186
1188
  },
1187
1189
  async run({ args }) {
@@ -1195,24 +1197,28 @@ var rollbackCommand = defineCommand7({
1195
1197
  consola9.log(pc7.dim(" \u2500".repeat(25)));
1196
1198
  consola9.log("");
1197
1199
  let targetCommit = null;
1200
+ let agentCommit = null;
1198
1201
  if (args.commit) {
1199
1202
  targetCommit = args.commit;
1200
1203
  } else {
1201
- const agentCommit = gitOps.getLastCommitByAgent(root);
1204
+ agentCommit = gitOps.getLastCommitByAgent(root);
1202
1205
  if (!agentCommit) {
1203
1206
  consola9.error("No agent commit found in git history.");
1204
1207
  process.exit(1);
1205
1208
  }
1206
- targetCommit = gitOps.getCommitBefore(root, agentCommit);
1207
- if (!targetCommit) {
1208
- consola9.error("Cannot find parent commit for rollback.");
1209
- process.exit(1);
1210
- }
1209
+ targetCommit = agentCommit;
1211
1210
  }
1212
- consola9.info(`Rolling back to commit: ${targetCommit}`);
1213
- const success = gitOps.rollbackToCommit(root, targetCommit);
1211
+ const forceHardReset = args["force-hard-reset"] === true;
1212
+ consola9.info(
1213
+ forceHardReset ? `Hard resetting to commit: ${targetCommit}` : `Reverting commit: ${targetCommit}`
1214
+ );
1215
+ const success = forceHardReset ? gitOps.hardResetToCommit(root, targetCommit) : gitOps.revertCommit(root, targetCommit);
1214
1216
  if (success) {
1215
- consola9.success(`Rollback complete. HEAD is now at ${targetCommit}`);
1217
+ if (forceHardReset) {
1218
+ consola9.success(`Rollback complete. HEAD is now at ${targetCommit}`);
1219
+ } else {
1220
+ consola9.success(`Rollback complete. Reverted ${targetCommit}`);
1221
+ }
1216
1222
  } else {
1217
1223
  consola9.error("Rollback failed. Check your git state manually.");
1218
1224
  process.exit(1);
@@ -1225,7 +1231,7 @@ var rollbackCommand = defineCommand7({
1225
1231
  var main = defineCommand8({
1226
1232
  meta: {
1227
1233
  name: "cmsassets-agent",
1228
- version: "0.3.0",
1234
+ version: "0.4.0",
1229
1235
  description: "Auto-integrate @synchronized-studio/response-transformer into any JS/TS project."
1230
1236
  },
1231
1237
  subCommands: {