@synchronized-studio/cmsassets-agent 0.1.1 → 0.1.3

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,9 @@ import {
9
9
  saveReport,
10
10
  scan,
11
11
  verify
12
- } from "./chunk-J6E3CMX6.js";
13
- import "./chunk-645ASJ55.js";
12
+ } from "./chunk-WDZHZ32V.js";
13
+ import "./chunk-Q6VYUIS7.js";
14
+ import "./chunk-E74TGIFQ.js";
14
15
  import "./chunk-QGM4M3NI.js";
15
16
 
16
17
  // src/cli.ts
@@ -67,6 +68,18 @@ function confirm(question) {
67
68
  });
68
69
  });
69
70
  }
71
+ function getOpenAiInstallCommand(packageManager) {
72
+ switch (packageManager) {
73
+ case "pnpm":
74
+ return "pnpm add openai";
75
+ case "yarn":
76
+ return "yarn add openai";
77
+ case "bun":
78
+ return "bun add openai";
79
+ default:
80
+ return "npm install openai";
81
+ }
82
+ }
70
83
  var initCommand = defineCommand({
71
84
  meta: {
72
85
  name: "init",
@@ -227,25 +240,43 @@ var initCommand = defineCommand({
227
240
  if (args["ai-verify"]) {
228
241
  const appliedPaths = applyReport.files.filter((f) => f.applied).map((f) => f.filePath);
229
242
  if (appliedPaths.length > 0) {
230
- consola2.log("");
231
- consola2.log(pc.bold(" CMS Assets Agent \u2014 AI Verification"));
232
- consola2.log(pc.dim(" \u2500".repeat(25)));
233
- consola2.log("");
234
- const { aiReviewAll } = await import("./aiReview-HZKRPSUV.js");
235
- aiReviewReport = await aiReviewAll(root, appliedPaths, plan, {
236
- model: args["ai-model"] ?? "gpt-4o",
237
- maxIterations: parseInt(args["ai-max-iterations"] ?? "3", 10)
238
- });
239
- consola2.log("");
240
- consola2.log(` ${pc.green("Passed:")} ${aiReviewReport.filesPassed} files`);
241
- if (aiReviewReport.filesFixed > 0) {
242
- consola2.log(` ${pc.blue("Fixed:")} ${aiReviewReport.filesFixed} files`);
243
+ const { checkAiVerifyReady } = await import("./openaiClient-YGAFYB3X.js");
244
+ let ready = await checkAiVerifyReady(root);
245
+ if (!ready.ok && ready.canInstallInProject) {
246
+ const openaiInstallCmd = getOpenAiInstallCommand(scanResult.packageManager);
247
+ consola2.info(`Installing openai in project: ${openaiInstallCmd}`);
248
+ try {
249
+ const { execSync } = await import("child_process");
250
+ execSync(openaiInstallCmd, { cwd: root, stdio: "inherit" });
251
+ ready = await checkAiVerifyReady(root);
252
+ } catch {
253
+ consola2.warn("Installing openai failed. AI verification skipped.");
254
+ ready = { ok: false };
255
+ }
243
256
  }
244
- if (aiReviewReport.filesFailed > 0) {
245
- consola2.log(` ${pc.red("Failed:")} ${aiReviewReport.filesFailed} files`);
257
+ if (!ready.ok) {
258
+ consola2.warn(` ${pc.yellow("AI Verification skipped:")} ${ready.reason}`);
259
+ } else {
260
+ consola2.log("");
261
+ consola2.log(pc.bold(" CMS Assets Agent \u2014 AI Verification"));
262
+ consola2.log(pc.dim(" \u2500".repeat(25)));
263
+ consola2.log("");
264
+ const { aiReviewAll } = await import("./aiReview-6WOTHK5N.js");
265
+ aiReviewReport = await aiReviewAll(root, appliedPaths, plan, {
266
+ model: args["ai-model"] ?? "gpt-4o",
267
+ maxIterations: parseInt(args["ai-max-iterations"] ?? "3", 10)
268
+ });
269
+ consola2.log("");
270
+ consola2.log(` ${pc.green("Passed:")} ${aiReviewReport.filesPassed} files`);
271
+ if (aiReviewReport.filesFixed > 0) {
272
+ consola2.log(` ${pc.blue("Fixed:")} ${aiReviewReport.filesFixed} files`);
273
+ }
274
+ if (aiReviewReport.filesFailed > 0) {
275
+ consola2.log(` ${pc.red("Failed:")} ${aiReviewReport.filesFailed} files`);
276
+ }
277
+ consola2.log(` ${pc.dim(`Tokens used: ${aiReviewReport.tokensUsed}`)}`);
278
+ consola2.log("");
246
279
  }
247
- consola2.log(` ${pc.dim(`Tokens used: ${aiReviewReport.tokensUsed}`)}`);
248
- consola2.log("");
249
280
  }
250
281
  }
251
282
  let scriptAdded = false;
@@ -282,6 +313,9 @@ var initCommand = defineCommand({
282
313
  if (scriptAdded) {
283
314
  consola2.log(` ${pc.dim("Re-run later with:")} ${pc.cyan("npm run cmsassets:transform")}`);
284
315
  }
316
+ if (!args["ai-verify"] && applied.length > 0) {
317
+ consola2.log(` ${pc.dim("Optional:")} Add ${pc.cyan("--ai-verify")} to have AI review patched files (requires OPENAI_API_KEY).`);
318
+ }
285
319
  consola2.log("");
286
320
  }
287
321
  });
@@ -640,28 +674,34 @@ var applyCommand = defineCommand4({
640
674
  if (args["ai-verify"]) {
641
675
  const appliedPaths = applyReport.files.filter((f) => f.applied).map((f) => f.filePath);
642
676
  if (appliedPaths.length > 0) {
643
- consola5.log("");
644
- consola5.log(pc4.bold(" CMS Assets Agent \u2014 AI Verification"));
645
- consola5.log(pc4.dim(" \u2500".repeat(25)));
646
- consola5.log("");
647
- const { aiReviewAll } = await import("./aiReview-HZKRPSUV.js");
648
- aiReviewReport = await aiReviewAll(root, appliedPaths, plan, {
649
- model: args["ai-model"] ?? "gpt-4o",
650
- maxIterations: parseInt(args["ai-max-iterations"] ?? "3", 10)
651
- });
652
- consola5.log("");
653
- consola5.log(` ${pc4.green("Passed:")} ${aiReviewReport.filesPassed} files`);
654
- if (aiReviewReport.filesFixed > 0) {
655
- consola5.log(` ${pc4.blue("Fixed:")} ${aiReviewReport.filesFixed} files`);
656
- }
657
- if (aiReviewReport.filesFailed > 0) {
658
- consola5.log(` ${pc4.red("Failed:")} ${aiReviewReport.filesFailed} files`);
659
- }
660
- consola5.log(` ${pc4.dim(`Tokens used: ${aiReviewReport.tokensUsed}`)}`);
661
- consola5.log("");
662
- if (aiReviewReport.filesFixed > 0 && gitOps.isGitRepo(root) && branchCreated) {
663
- gitOps.stageAll(root);
664
- gitOps.commit(root, "chore(cmsassets-agent): AI-verified fixes for missed transforms");
677
+ const { checkAiVerifyReady } = await import("./openaiClient-YGAFYB3X.js");
678
+ const ready = await checkAiVerifyReady(root);
679
+ if (!ready.ok) {
680
+ consola5.warn(` ${pc4.yellow("AI Verification skipped:")} ${ready.reason}`);
681
+ } else {
682
+ consola5.log("");
683
+ consola5.log(pc4.bold(" CMS Assets Agent \u2014 AI Verification"));
684
+ consola5.log(pc4.dim(" \u2500".repeat(25)));
685
+ consola5.log("");
686
+ const { aiReviewAll } = await import("./aiReview-6WOTHK5N.js");
687
+ aiReviewReport = await aiReviewAll(root, appliedPaths, plan, {
688
+ model: args["ai-model"] ?? "gpt-4o",
689
+ maxIterations: parseInt(args["ai-max-iterations"] ?? "3", 10)
690
+ });
691
+ consola5.log("");
692
+ consola5.log(` ${pc4.green("Passed:")} ${aiReviewReport.filesPassed} files`);
693
+ if (aiReviewReport.filesFixed > 0) {
694
+ consola5.log(` ${pc4.blue("Fixed:")} ${aiReviewReport.filesFixed} files`);
695
+ }
696
+ if (aiReviewReport.filesFailed > 0) {
697
+ consola5.log(` ${pc4.red("Failed:")} ${aiReviewReport.filesFailed} files`);
698
+ }
699
+ consola5.log(` ${pc4.dim(`Tokens used: ${aiReviewReport.tokensUsed}`)}`);
700
+ consola5.log("");
701
+ if (aiReviewReport.filesFixed > 0 && gitOps.isGitRepo(root) && branchCreated) {
702
+ gitOps.stageAll(root);
703
+ gitOps.commit(root, "chore(cmsassets-agent): AI-verified fixes for missed transforms");
704
+ }
665
705
  }
666
706
  }
667
707
  }
@@ -971,7 +1011,7 @@ var rollbackCommand = defineCommand7({
971
1011
  var main = defineCommand8({
972
1012
  meta: {
973
1013
  name: "cmsassets-agent",
974
- version: "0.1.1",
1014
+ version: "0.1.3",
975
1015
  description: "Auto-integrate @synchronized-studio/response-transformer into any JS/TS project."
976
1016
  },
977
1017
  subCommands: {
package/dist/index.js CHANGED
@@ -25,11 +25,12 @@ import {
25
25
  saveReport,
26
26
  scan,
27
27
  verify
28
- } from "./chunk-J6E3CMX6.js";
28
+ } from "./chunk-WDZHZ32V.js";
29
29
  import {
30
30
  aiReviewAll
31
- } from "./chunk-R6XRR66U.js";
32
- import "./chunk-645ASJ55.js";
31
+ } from "./chunk-OAWCNTAC.js";
32
+ import "./chunk-Q6VYUIS7.js";
33
+ import "./chunk-E74TGIFQ.js";
33
34
  import "./chunk-QGM4M3NI.js";
34
35
 
35
36
  // src/engine.ts
@@ -0,0 +1,11 @@
1
+ import {
2
+ chatCompletion,
3
+ checkAiVerifyReady,
4
+ isOpenAiError
5
+ } from "./chunk-E74TGIFQ.js";
6
+ import "./chunk-QGM4M3NI.js";
7
+ export {
8
+ chatCompletion,
9
+ checkAiVerifyReady,
10
+ isOpenAiError
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synchronized-studio/cmsassets-agent",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "CLI agent that auto-integrates @synchronized-studio/response-transformer into any JS/TS project.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",