@synchronized-studio/cmsassets-agent 0.1.2 → 0.2.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,9 @@ import {
9
9
  saveReport,
10
10
  scan,
11
11
  verify
12
- } from "./chunk-J6E3CMX6.js";
13
- import "./chunk-645ASJ55.js";
12
+ } from "./chunk-YZRA5AHC.js";
13
+ import "./chunk-OJVHNQQN.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",
@@ -166,6 +179,15 @@ var initCommand = defineCommand({
166
179
  consola2.log("");
167
180
  if (scanResult.injectionPoints.length === 0) {
168
181
  consola2.warn(" No injection points found. Nothing to do.");
182
+ consola2.log("");
183
+ consola2.log(
184
+ ` ${pc.dim("Tip:")} Run from your project root. The agent looks for fetch/useFetch/loaders that return CMS data.`
185
+ );
186
+ consola2.log(
187
+ ` ${pc.dim("If you already ran init here, all detected points may already be patched.")}`
188
+ );
189
+ consola2.log(` ${pc.dim("Run")} ${pc.cyan("npx @synchronized-studio/cmsassets-agent scan")} ${pc.dim("to see framework/CMS detection.")}`);
190
+ consola2.log("");
169
191
  return;
170
192
  }
171
193
  consola2.log(` ${pc.bold("Injection points:")} ${scanResult.injectionPoints.length} found`);
@@ -227,25 +249,43 @@ var initCommand = defineCommand({
227
249
  if (args["ai-verify"]) {
228
250
  const appliedPaths = applyReport.files.filter((f) => f.applied).map((f) => f.filePath);
229
251
  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`);
252
+ const { checkAiVerifyReady } = await import("./openaiClient-YGAFYB3X.js");
253
+ let ready = await checkAiVerifyReady(root);
254
+ if (!ready.ok && ready.canInstallInProject) {
255
+ const openaiInstallCmd = getOpenAiInstallCommand(scanResult.packageManager);
256
+ consola2.info(`Installing openai in project: ${openaiInstallCmd}`);
257
+ try {
258
+ const { execSync } = await import("child_process");
259
+ execSync(openaiInstallCmd, { cwd: root, stdio: "inherit" });
260
+ ready = await checkAiVerifyReady(root);
261
+ } catch {
262
+ consola2.warn("Installing openai failed. AI verification skipped.");
263
+ ready = { ok: false };
264
+ }
243
265
  }
244
- if (aiReviewReport.filesFailed > 0) {
245
- consola2.log(` ${pc.red("Failed:")} ${aiReviewReport.filesFailed} files`);
266
+ if (!ready.ok) {
267
+ consola2.warn(` ${pc.yellow("AI Verification skipped:")} ${ready.reason}`);
268
+ } else {
269
+ consola2.log("");
270
+ consola2.log(pc.bold(" CMS Assets Agent \u2014 AI Verification"));
271
+ consola2.log(pc.dim(" \u2500".repeat(25)));
272
+ consola2.log("");
273
+ const { aiReviewAll } = await import("./aiReview-2CEFN6ZS.js");
274
+ aiReviewReport = await aiReviewAll(root, appliedPaths, plan, {
275
+ model: args["ai-model"] ?? "gpt-4o",
276
+ maxIterations: parseInt(args["ai-max-iterations"] ?? "3", 10)
277
+ });
278
+ consola2.log("");
279
+ consola2.log(` ${pc.green("Passed:")} ${aiReviewReport.filesPassed} files`);
280
+ if (aiReviewReport.filesFixed > 0) {
281
+ consola2.log(` ${pc.blue("Fixed:")} ${aiReviewReport.filesFixed} files`);
282
+ }
283
+ if (aiReviewReport.filesFailed > 0) {
284
+ consola2.log(` ${pc.red("Failed:")} ${aiReviewReport.filesFailed} files`);
285
+ }
286
+ consola2.log(` ${pc.dim(`Tokens used: ${aiReviewReport.tokensUsed}`)}`);
287
+ consola2.log("");
246
288
  }
247
- consola2.log(` ${pc.dim(`Tokens used: ${aiReviewReport.tokensUsed}`)}`);
248
- consola2.log("");
249
289
  }
250
290
  }
251
291
  let scriptAdded = false;
@@ -643,28 +683,34 @@ var applyCommand = defineCommand4({
643
683
  if (args["ai-verify"]) {
644
684
  const appliedPaths = applyReport.files.filter((f) => f.applied).map((f) => f.filePath);
645
685
  if (appliedPaths.length > 0) {
646
- consola5.log("");
647
- consola5.log(pc4.bold(" CMS Assets Agent \u2014 AI Verification"));
648
- consola5.log(pc4.dim(" \u2500".repeat(25)));
649
- consola5.log("");
650
- const { aiReviewAll } = await import("./aiReview-HZKRPSUV.js");
651
- aiReviewReport = await aiReviewAll(root, appliedPaths, plan, {
652
- model: args["ai-model"] ?? "gpt-4o",
653
- maxIterations: parseInt(args["ai-max-iterations"] ?? "3", 10)
654
- });
655
- consola5.log("");
656
- consola5.log(` ${pc4.green("Passed:")} ${aiReviewReport.filesPassed} files`);
657
- if (aiReviewReport.filesFixed > 0) {
658
- consola5.log(` ${pc4.blue("Fixed:")} ${aiReviewReport.filesFixed} files`);
659
- }
660
- if (aiReviewReport.filesFailed > 0) {
661
- consola5.log(` ${pc4.red("Failed:")} ${aiReviewReport.filesFailed} files`);
662
- }
663
- consola5.log(` ${pc4.dim(`Tokens used: ${aiReviewReport.tokensUsed}`)}`);
664
- consola5.log("");
665
- if (aiReviewReport.filesFixed > 0 && gitOps.isGitRepo(root) && branchCreated) {
666
- gitOps.stageAll(root);
667
- gitOps.commit(root, "chore(cmsassets-agent): AI-verified fixes for missed transforms");
686
+ const { checkAiVerifyReady } = await import("./openaiClient-YGAFYB3X.js");
687
+ const ready = await checkAiVerifyReady(root);
688
+ if (!ready.ok) {
689
+ consola5.warn(` ${pc4.yellow("AI Verification skipped:")} ${ready.reason}`);
690
+ } else {
691
+ consola5.log("");
692
+ consola5.log(pc4.bold(" CMS Assets Agent \u2014 AI Verification"));
693
+ consola5.log(pc4.dim(" \u2500".repeat(25)));
694
+ consola5.log("");
695
+ const { aiReviewAll } = await import("./aiReview-2CEFN6ZS.js");
696
+ aiReviewReport = await aiReviewAll(root, appliedPaths, plan, {
697
+ model: args["ai-model"] ?? "gpt-4o",
698
+ maxIterations: parseInt(args["ai-max-iterations"] ?? "3", 10)
699
+ });
700
+ consola5.log("");
701
+ consola5.log(` ${pc4.green("Passed:")} ${aiReviewReport.filesPassed} files`);
702
+ if (aiReviewReport.filesFixed > 0) {
703
+ consola5.log(` ${pc4.blue("Fixed:")} ${aiReviewReport.filesFixed} files`);
704
+ }
705
+ if (aiReviewReport.filesFailed > 0) {
706
+ consola5.log(` ${pc4.red("Failed:")} ${aiReviewReport.filesFailed} files`);
707
+ }
708
+ consola5.log(` ${pc4.dim(`Tokens used: ${aiReviewReport.tokensUsed}`)}`);
709
+ consola5.log("");
710
+ if (aiReviewReport.filesFixed > 0 && gitOps.isGitRepo(root) && branchCreated) {
711
+ gitOps.stageAll(root);
712
+ gitOps.commit(root, "chore(cmsassets-agent): AI-verified fixes for missed transforms");
713
+ }
668
714
  }
669
715
  }
670
716
  }
@@ -974,7 +1020,7 @@ var rollbackCommand = defineCommand7({
974
1020
  var main = defineCommand8({
975
1021
  meta: {
976
1022
  name: "cmsassets-agent",
977
- version: "0.1.2",
1023
+ version: "0.1.3",
978
1024
  description: "Auto-integrate @synchronized-studio/response-transformer into any JS/TS project."
979
1025
  },
980
1026
  subCommands: {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z } from 'zod/v3';
2
2
 
3
3
  declare const FrameworkName: z.ZodEnum<["nuxt", "nuxt2", "next", "remix", "astro", "sveltekit", "express", "hono", "fastify", "unknown"]>;
4
4
  type FrameworkName = z.infer<typeof FrameworkName>;
@@ -522,19 +522,19 @@ type PatchPlan = z.infer<typeof PatchPlan>;
522
522
  declare const PatchedFileReport: z.ZodObject<{
523
523
  filePath: z.ZodString;
524
524
  applied: z.ZodBoolean;
525
- method: z.ZodEnum<["ast", "llm", "skipped"]>;
525
+ method: z.ZodEnum<["ast", "llm", "llm-complete", "skipped"]>;
526
526
  reason: z.ZodOptional<z.ZodString>;
527
527
  durationMs: z.ZodNumber;
528
528
  }, "strip", z.ZodTypeAny, {
529
529
  filePath: string;
530
530
  applied: boolean;
531
- method: "llm" | "ast" | "skipped";
531
+ method: "llm" | "ast" | "llm-complete" | "skipped";
532
532
  durationMs: number;
533
533
  reason?: string | undefined;
534
534
  }, {
535
535
  filePath: string;
536
536
  applied: boolean;
537
- method: "llm" | "ast" | "skipped";
537
+ method: "llm" | "ast" | "llm-complete" | "skipped";
538
538
  durationMs: number;
539
539
  reason?: string | undefined;
540
540
  }>;
@@ -550,19 +550,19 @@ declare const ApplyReport: z.ZodObject<{
550
550
  files: z.ZodArray<z.ZodObject<{
551
551
  filePath: z.ZodString;
552
552
  applied: z.ZodBoolean;
553
- method: z.ZodEnum<["ast", "llm", "skipped"]>;
553
+ method: z.ZodEnum<["ast", "llm", "llm-complete", "skipped"]>;
554
554
  reason: z.ZodOptional<z.ZodString>;
555
555
  durationMs: z.ZodNumber;
556
556
  }, "strip", z.ZodTypeAny, {
557
557
  filePath: string;
558
558
  applied: boolean;
559
- method: "llm" | "ast" | "skipped";
559
+ method: "llm" | "ast" | "llm-complete" | "skipped";
560
560
  durationMs: number;
561
561
  reason?: string | undefined;
562
562
  }, {
563
563
  filePath: string;
564
564
  applied: boolean;
565
- method: "llm" | "ast" | "skipped";
565
+ method: "llm" | "ast" | "llm-complete" | "skipped";
566
566
  durationMs: number;
567
567
  reason?: string | undefined;
568
568
  }>, "many">;
@@ -573,7 +573,7 @@ declare const ApplyReport: z.ZodObject<{
573
573
  files: {
574
574
  filePath: string;
575
575
  applied: boolean;
576
- method: "llm" | "ast" | "skipped";
576
+ method: "llm" | "ast" | "llm-complete" | "skipped";
577
577
  durationMs: number;
578
578
  reason?: string | undefined;
579
579
  }[];
@@ -589,7 +589,7 @@ declare const ApplyReport: z.ZodObject<{
589
589
  files: {
590
590
  filePath: string;
591
591
  applied: boolean;
592
- method: "llm" | "ast" | "skipped";
592
+ method: "llm" | "ast" | "llm-complete" | "skipped";
593
593
  durationMs: number;
594
594
  reason?: string | undefined;
595
595
  }[];
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-YZRA5AHC.js";
29
29
  import {
30
30
  aiReviewAll
31
- } from "./chunk-R6XRR66U.js";
32
- import "./chunk-645ASJ55.js";
31
+ } from "./chunk-RALRI2YO.js";
32
+ import "./chunk-OJVHNQQN.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.2",
3
+ "version": "0.2.0",
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",
@@ -54,7 +54,7 @@
54
54
  "fast-glob": "^3.3.3",
55
55
  "picocolors": "^1.1.1",
56
56
  "ts-morph": "^25.0.0",
57
- "zod": "^3.24.0"
57
+ "zod": "^4.3.6"
58
58
  },
59
59
  "optionalDependencies": {
60
60
  "openai": "^4.80.0"