@synchronized-studio/cmsassets-agent 0.2.1 → 0.3.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.
package/dist/cli.js CHANGED
@@ -9,8 +9,8 @@ import {
9
9
  saveReport,
10
10
  scan,
11
11
  verify
12
- } from "./chunk-XHL55FTA.js";
13
- import "./chunk-MW74S44G.js";
12
+ } from "./chunk-Z3PUMVH2.js";
13
+ import "./chunk-SHAT7M2R.js";
14
14
  import "./chunk-E74TGIFQ.js";
15
15
  import "./chunk-QGM4M3NI.js";
16
16
 
@@ -239,10 +239,41 @@ var initCommand = defineCommand({
239
239
  consola2.warn("Package install failed. You can install it manually later.");
240
240
  }
241
241
  }
242
+ const hasAiKey = !!process.env.OPENAI_API_KEY;
243
+ let aiMode = args["ai-verify"] && hasAiKey;
244
+ if (args["ai-verify"] && !hasAiKey) {
245
+ consola2.log(` ${pc.yellow("No OPENAI_API_KEY")} \u2014 using mixed fallback (AST for high/medium, report-only for low)`);
246
+ consola2.log("");
247
+ } else if (aiMode) {
248
+ const { checkAiVerifyReady } = await import("./openaiClient-YGAFYB3X.js");
249
+ let ready = await checkAiVerifyReady(root);
250
+ if (!ready.ok && ready.canInstallInProject) {
251
+ const openaiInstallCmd = getOpenAiInstallCommand(scanResult.packageManager);
252
+ consola2.info(`Installing openai in project: ${openaiInstallCmd}`);
253
+ try {
254
+ const { execSync } = await import("child_process");
255
+ execSync(openaiInstallCmd, { cwd: root, stdio: "inherit" });
256
+ ready = await checkAiVerifyReady(root);
257
+ } catch {
258
+ consola2.warn("Installing openai failed.");
259
+ ready = { ok: false };
260
+ }
261
+ }
262
+ if (!ready.ok) {
263
+ consola2.log(` ${pc.yellow("AI mode unavailable")} \u2014 falling back to AST-only patching`);
264
+ consola2.log("");
265
+ aiMode = false;
266
+ } else {
267
+ consola2.log(` ${pc.cyan("AI mode")} \u2014 AI will patch and verify each file`);
268
+ consola2.log("");
269
+ }
270
+ }
242
271
  consola2.info("Applying patches...");
243
272
  const applyReport = await applyPlan(plan, {
244
273
  dryRun: false,
245
- includeTests: args["include-tests"]
274
+ includeTests: args["include-tests"],
275
+ aiMode,
276
+ aiModel: args["ai-model"] ?? "gpt-4o"
246
277
  });
247
278
  applyReport.installed = installed;
248
279
  let aiReviewReport;
@@ -270,7 +301,7 @@ var initCommand = defineCommand({
270
301
  consola2.log(pc.bold(" CMS Assets Agent \u2014 AI Verification"));
271
302
  consola2.log(pc.dim(" \u2500".repeat(25)));
272
303
  consola2.log("");
273
- const { aiReviewAll } = await import("./aiReview-WD5QPIHJ.js");
304
+ const { aiReviewAll } = await import("./aiReview-GDZZWQ3N.js");
274
305
  aiReviewReport = await aiReviewAll(root, appliedPaths, plan, {
275
306
  model: args["ai-model"] ?? "gpt-4o",
276
307
  maxIterations: parseInt(args["ai-max-iterations"] ?? "3", 10)
@@ -296,21 +327,34 @@ var initCommand = defineCommand({
296
327
  const report = createReport({ apply: applyReport, plan, scan: scanResult, aiReview: aiReviewReport });
297
328
  saveReport(root, report);
298
329
  const applied = applyReport.files.filter((f) => f.applied);
299
- const skipped = applyReport.files.filter((f) => !f.applied);
330
+ const manualReview = applyReport.files.filter((f) => f.method === "manual-review");
331
+ const skipped = applyReport.files.filter((f) => !f.applied && f.method === "skipped");
332
+ const s = applyReport.summary;
300
333
  consola2.log("");
301
334
  consola2.log(pc.bold(" CMS Assets Agent \u2014 Init Complete"));
302
335
  consola2.log(pc.dim(" \u2500".repeat(25)));
303
336
  consola2.log("");
304
- consola2.log(` ${pc.green("Applied:")} ${applied.length} files`);
305
- consola2.log(` ${pc.yellow("Skipped:")} ${skipped.length} files`);
337
+ if (s) {
338
+ consola2.log(` ${pc.dim("Candidates:")} ${s.candidatesFound}`);
339
+ if (s.patchedByAi > 0) consola2.log(` ${pc.green("Patched (AI):")} ${s.patchedByAi}`);
340
+ if (s.patchedByAst > 0) consola2.log(` ${pc.green("Patched (AST):")} ${s.patchedByAst}`);
341
+ if (s.manualReviewRequired > 0) consola2.log(` ${pc.yellow("Manual review:")} ${s.manualReviewRequired}`);
342
+ if (s.skipped > 0) consola2.log(` ${pc.dim("Skipped:")} ${s.skipped}`);
343
+ } else {
344
+ consola2.log(` ${pc.green("Applied:")} ${applied.length} files`);
345
+ consola2.log(` ${pc.yellow("Skipped:")} ${skipped.length + manualReview.length} files`);
346
+ }
306
347
  if (installed) consola2.log(` ${pc.green("Installed:")} @synchronized-studio/response-transformer`);
307
348
  if (scriptAdded) consola2.log(` ${pc.green("Script:")} Added "cmsassets:transform" to package.json`);
308
349
  consola2.log("");
309
350
  for (const file of applied) {
310
- consola2.log(` ${pc.green("\u2713")} ${file.filePath} ${pc.dim(`(${file.method}, ${file.durationMs}ms)`)}`);
351
+ consola2.log(` ${pc.green("+")} ${file.filePath} ${pc.dim(`(${file.method}, ${file.durationMs}ms)`)}`);
352
+ }
353
+ for (const file of manualReview) {
354
+ consola2.log(` ${pc.yellow("?")} ${file.filePath} ${pc.dim(`\u2014 ${file.reason}`)}`);
311
355
  }
312
356
  for (const file of skipped) {
313
- consola2.log(` ${pc.yellow("\u25CB")} ${file.filePath} ${pc.dim(`\u2014 ${file.reason}`)}`);
357
+ consola2.log(` ${pc.dim("-")} ${file.filePath} ${pc.dim(`\u2014 ${file.reason}`)}`);
314
358
  }
315
359
  consola2.log("");
316
360
  if (!installed) {
@@ -692,7 +736,7 @@ var applyCommand = defineCommand4({
692
736
  consola5.log(pc4.bold(" CMS Assets Agent \u2014 AI Verification"));
693
737
  consola5.log(pc4.dim(" \u2500".repeat(25)));
694
738
  consola5.log("");
695
- const { aiReviewAll } = await import("./aiReview-WD5QPIHJ.js");
739
+ const { aiReviewAll } = await import("./aiReview-GDZZWQ3N.js");
696
740
  aiReviewReport = await aiReviewAll(root, appliedPaths, plan, {
697
741
  model: args["ai-model"] ?? "gpt-4o",
698
742
  maxIterations: parseInt(args["ai-max-iterations"] ?? "3", 10)
@@ -1020,7 +1064,7 @@ var rollbackCommand = defineCommand7({
1020
1064
  var main = defineCommand8({
1021
1065
  meta: {
1022
1066
  name: "cmsassets-agent",
1023
- version: "0.2.1",
1067
+ version: "0.3.0",
1024
1068
  description: "Auto-integrate @synchronized-studio/response-transformer into any JS/TS project."
1025
1069
  },
1026
1070
  subCommands: {
package/dist/index.d.ts CHANGED
@@ -519,22 +519,24 @@ declare const PatchPlan: z.ZodObject<{
519
519
  };
520
520
  }>;
521
521
  type PatchPlan = z.infer<typeof PatchPlan>;
522
+ declare const PatchMethod: z.ZodEnum<["ast", "llm", "llm-complete", "ai-complete", "skipped", "manual-review"]>;
523
+ type PatchMethod = z.infer<typeof PatchMethod>;
522
524
  declare const PatchedFileReport: z.ZodObject<{
523
525
  filePath: z.ZodString;
524
526
  applied: z.ZodBoolean;
525
- method: z.ZodEnum<["ast", "llm", "llm-complete", "skipped"]>;
527
+ method: z.ZodEnum<["ast", "llm", "llm-complete", "ai-complete", "skipped", "manual-review"]>;
526
528
  reason: z.ZodOptional<z.ZodString>;
527
529
  durationMs: z.ZodNumber;
528
530
  }, "strip", z.ZodTypeAny, {
529
531
  filePath: string;
530
532
  applied: boolean;
531
- method: "llm" | "ast" | "llm-complete" | "skipped";
533
+ method: "llm" | "ast" | "llm-complete" | "ai-complete" | "skipped" | "manual-review";
532
534
  durationMs: number;
533
535
  reason?: string | undefined;
534
536
  }, {
535
537
  filePath: string;
536
538
  applied: boolean;
537
- method: "llm" | "ast" | "llm-complete" | "skipped";
539
+ method: "llm" | "ast" | "llm-complete" | "ai-complete" | "skipped" | "manual-review";
538
540
  durationMs: number;
539
541
  reason?: string | undefined;
540
542
  }>;
@@ -550,22 +552,41 @@ declare const ApplyReport: z.ZodObject<{
550
552
  files: z.ZodArray<z.ZodObject<{
551
553
  filePath: z.ZodString;
552
554
  applied: z.ZodBoolean;
553
- method: z.ZodEnum<["ast", "llm", "llm-complete", "skipped"]>;
555
+ method: z.ZodEnum<["ast", "llm", "llm-complete", "ai-complete", "skipped", "manual-review"]>;
554
556
  reason: z.ZodOptional<z.ZodString>;
555
557
  durationMs: z.ZodNumber;
556
558
  }, "strip", z.ZodTypeAny, {
557
559
  filePath: string;
558
560
  applied: boolean;
559
- method: "llm" | "ast" | "llm-complete" | "skipped";
561
+ method: "llm" | "ast" | "llm-complete" | "ai-complete" | "skipped" | "manual-review";
560
562
  durationMs: number;
561
563
  reason?: string | undefined;
562
564
  }, {
563
565
  filePath: string;
564
566
  applied: boolean;
565
- method: "llm" | "ast" | "llm-complete" | "skipped";
567
+ method: "llm" | "ast" | "llm-complete" | "ai-complete" | "skipped" | "manual-review";
566
568
  durationMs: number;
567
569
  reason?: string | undefined;
568
570
  }>, "many">;
571
+ summary: z.ZodOptional<z.ZodObject<{
572
+ candidatesFound: z.ZodNumber;
573
+ patchedByAi: z.ZodNumber;
574
+ patchedByAst: z.ZodNumber;
575
+ manualReviewRequired: z.ZodNumber;
576
+ skipped: z.ZodNumber;
577
+ }, "strip", z.ZodTypeAny, {
578
+ skipped: number;
579
+ candidatesFound: number;
580
+ patchedByAi: number;
581
+ patchedByAst: number;
582
+ manualReviewRequired: number;
583
+ }, {
584
+ skipped: number;
585
+ candidatesFound: number;
586
+ patchedByAi: number;
587
+ patchedByAst: number;
588
+ manualReviewRequired: number;
589
+ }>>;
569
590
  totalDurationMs: z.ZodNumber;
570
591
  }, "strip", z.ZodTypeAny, {
571
592
  projectRoot: string;
@@ -573,7 +594,7 @@ declare const ApplyReport: z.ZodObject<{
573
594
  files: {
574
595
  filePath: string;
575
596
  applied: boolean;
576
- method: "llm" | "ast" | "llm-complete" | "skipped";
597
+ method: "llm" | "ast" | "llm-complete" | "ai-complete" | "skipped" | "manual-review";
577
598
  durationMs: number;
578
599
  reason?: string | undefined;
579
600
  }[];
@@ -583,13 +604,20 @@ declare const ApplyReport: z.ZodObject<{
583
604
  installed: boolean;
584
605
  envUpdated: boolean;
585
606
  totalDurationMs: number;
607
+ summary?: {
608
+ skipped: number;
609
+ candidatesFound: number;
610
+ patchedByAi: number;
611
+ patchedByAst: number;
612
+ manualReviewRequired: number;
613
+ } | undefined;
586
614
  }, {
587
615
  projectRoot: string;
588
616
  schemaVersion: "1.0";
589
617
  files: {
590
618
  filePath: string;
591
619
  applied: boolean;
592
- method: "llm" | "ast" | "llm-complete" | "skipped";
620
+ method: "llm" | "ast" | "llm-complete" | "ai-complete" | "skipped" | "manual-review";
593
621
  durationMs: number;
594
622
  reason?: string | undefined;
595
623
  }[];
@@ -599,6 +627,13 @@ declare const ApplyReport: z.ZodObject<{
599
627
  installed: boolean;
600
628
  envUpdated: boolean;
601
629
  totalDurationMs: number;
630
+ summary?: {
631
+ skipped: number;
632
+ candidatesFound: number;
633
+ patchedByAi: number;
634
+ patchedByAst: number;
635
+ manualReviewRequired: number;
636
+ } | undefined;
602
637
  }>;
603
638
  type ApplyReport = z.infer<typeof ApplyReport>;
604
639
  declare const VerifyReport: z.ZodObject<{
@@ -726,6 +761,9 @@ interface ApplyOptions {
726
761
  dryRun?: boolean;
727
762
  includeTests?: boolean;
728
763
  maxFiles?: number;
764
+ /** When true, OpenAI key is available and AI-first mode should be used. */
765
+ aiMode?: boolean;
766
+ aiModel?: string;
729
767
  }
730
768
  declare function applyPlan(plan: PatchPlan, opts?: ApplyOptions): Promise<ApplyReport>;
731
769
 
@@ -808,4 +846,4 @@ interface PipelineResult {
808
846
  }
809
847
  declare function runFullPipeline(opts: PipelineOptions): Promise<PipelineResult>;
810
848
 
811
- export { AiFileResult, AiReviewReport, ApplyReport, CmsInfo, CmsType, Confidence, FilePatch, FrameworkInfo, FrameworkName, InjectionCandidate, InjectionType, PackageManager, PatchPlan, PatchedFileReport, type PipelineOptions, type PipelineResult, ScanResult, VerifyProfile, VerifyReport, aiReviewAll, applyPlan, createPlan, createReport, gitOps, loadPlanFile, runFullPipeline, savePlanFile, saveReport, scan, verify };
849
+ export { AiFileResult, AiReviewReport, ApplyReport, CmsInfo, CmsType, Confidence, FilePatch, FrameworkInfo, FrameworkName, InjectionCandidate, InjectionType, PackageManager, PatchMethod, PatchPlan, PatchedFileReport, type PipelineOptions, type PipelineResult, ScanResult, VerifyProfile, VerifyReport, aiReviewAll, applyPlan, createPlan, createReport, gitOps, loadPlanFile, runFullPipeline, savePlanFile, saveReport, scan, verify };
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  InjectionCandidate,
12
12
  InjectionType,
13
13
  PackageManager,
14
+ PatchMethod,
14
15
  PatchPlan,
15
16
  PatchedFileReport,
16
17
  ScanResult,
@@ -25,11 +26,11 @@ import {
25
26
  saveReport,
26
27
  scan,
27
28
  verify
28
- } from "./chunk-XHL55FTA.js";
29
+ } from "./chunk-Z3PUMVH2.js";
29
30
  import {
30
31
  aiReviewAll
31
- } from "./chunk-HYSTWSLW.js";
32
- import "./chunk-MW74S44G.js";
32
+ } from "./chunk-MCKXYHFX.js";
33
+ import "./chunk-SHAT7M2R.js";
33
34
  import "./chunk-E74TGIFQ.js";
34
35
  import "./chunk-QGM4M3NI.js";
35
36
 
@@ -62,10 +63,18 @@ async function runFullPipeline(opts) {
62
63
  previousCommit = gitOps.getHeadCommit(root);
63
64
  gitOps.createBranch(root, `cmsassets-agent/integrate-${Date.now()}`);
64
65
  }
66
+ let aiMode = opts.aiVerify && !!process.env.OPENAI_API_KEY;
67
+ if (aiMode) {
68
+ const { checkAiVerifyReady } = await import("./openaiClient-YGAFYB3X.js");
69
+ const ready = await checkAiVerifyReady(root);
70
+ if (!ready.ok) aiMode = false;
71
+ }
65
72
  const applyReport = await applyPlan(plan, {
66
73
  dryRun: opts.dryRun ?? false,
67
74
  includeTests: opts.includeTests ?? false,
68
- maxFiles: opts.maxFiles
75
+ maxFiles: opts.maxFiles,
76
+ aiMode,
77
+ aiModel: opts.aiModel
69
78
  });
70
79
  if (opts.gitCommit && gitOps.isGitRepo(root) && !opts.dryRun) {
71
80
  gitOps.stageAll(root);
@@ -134,6 +143,7 @@ export {
134
143
  InjectionCandidate,
135
144
  InjectionType,
136
145
  PackageManager,
146
+ PatchMethod,
137
147
  PatchPlan,
138
148
  PatchedFileReport,
139
149
  ScanResult,
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@synchronized-studio/cmsassets-agent",
3
- "version": "0.2.1",
3
+ "version": "0.3.2",
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",
7
7
  "types": "./dist/index.d.ts",
8
8
  "bin": {
9
- "cmsassets-agent": "./dist/cli.js"
9
+ "cmsassets-agent": "dist/cli.js"
10
10
  },
11
11
  "exports": {
12
12
  ".": {