@synchronized-studio/cmsassets-agent 0.3.0 → 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,7 +9,7 @@ import {
9
9
  saveReport,
10
10
  scan,
11
11
  verify
12
- } from "./chunk-O6X5SMT4.js";
12
+ } from "./chunk-Z3PUMVH2.js";
13
13
  import "./chunk-SHAT7M2R.js";
14
14
  import "./chunk-E74TGIFQ.js";
15
15
  import "./chunk-QGM4M3NI.js";
@@ -240,13 +240,33 @@ var initCommand = defineCommand({
240
240
  }
241
241
  }
242
242
  const hasAiKey = !!process.env.OPENAI_API_KEY;
243
- const aiMode = args["ai-verify"] && hasAiKey;
243
+ let aiMode = args["ai-verify"] && hasAiKey;
244
244
  if (args["ai-verify"] && !hasAiKey) {
245
245
  consola2.log(` ${pc.yellow("No OPENAI_API_KEY")} \u2014 using mixed fallback (AST for high/medium, report-only for low)`);
246
246
  consola2.log("");
247
247
  } else if (aiMode) {
248
- consola2.log(` ${pc.cyan("AI mode")} \u2014 AI will patch and verify each file`);
249
- consola2.log("");
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
+ }
250
270
  }
251
271
  consola2.info("Applying patches...");
252
272
  const applyReport = await applyPlan(plan, {
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  saveReport,
27
27
  scan,
28
28
  verify
29
- } from "./chunk-O6X5SMT4.js";
29
+ } from "./chunk-Z3PUMVH2.js";
30
30
  import {
31
31
  aiReviewAll
32
32
  } from "./chunk-MCKXYHFX.js";
@@ -63,7 +63,12 @@ async function runFullPipeline(opts) {
63
63
  previousCommit = gitOps.getHeadCommit(root);
64
64
  gitOps.createBranch(root, `cmsassets-agent/integrate-${Date.now()}`);
65
65
  }
66
- const aiMode = opts.aiVerify && !!process.env.OPENAI_API_KEY;
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
+ }
67
72
  const applyReport = await applyPlan(plan, {
68
73
  dryRun: opts.dryRun ?? false,
69
74
  includeTests: opts.includeTests ?? false,
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@synchronized-studio/cmsassets-agent",
3
- "version": "0.3.0",
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
  ".": {