@koda-sl/baker-cli 0.445.0-dev.71ff4e44a → 0.447.0-dev.397af7869

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
@@ -45,6 +45,7 @@ import {
45
45
  SEEDANCE_DURATIONS,
46
46
  SEEDANCE_PROFILE,
47
47
  SOUND_EFFECT_MODEL,
48
+ SPEC_SHAPES_HINT,
48
49
  SPOKEN_CLIP_DURATION_S,
49
50
  SPOKEN_WORDS_PER_SECOND,
50
51
  STATIC_ADAPT_FORMAT_ROLE,
@@ -200,7 +201,7 @@ import {
200
201
  withoutCastName,
201
202
  wordCount,
202
203
  ytDlpBlockSignal
203
- } from "./chunk-CYZ7H4F5.js";
204
+ } from "./chunk-WMAHVZMY.js";
204
205
  import {
205
206
  NAME_CONTAINS_ARG,
206
207
  csvOrJson,
@@ -73604,15 +73605,17 @@ function correctionOf(finding, band) {
73604
73605
  if (misread2) return `Re-letter ${misread2[1]} exactly as written, letter for letter (it now reads ${misread2[2]}).`;
73605
73606
  const missing = what.match(MISSING);
73606
73607
  if (missing) return `Add the line ${missing[1]}, spelled exactly, where it belongs in the layout.`;
73608
+ if (SIZES_FINDING.test(what)) return FOLLOW_PICTURE;
73607
73609
  const described2 = what.replace(CATEGORY, "").replace(/\.$/, "");
73608
73610
  return `Fix this: ${described2.charAt(0).toLowerCase()}${described2.slice(1)}.`;
73609
73611
  }
73610
73612
  function autoFixStep(canvas, review, opts = {}) {
73611
73613
  if ((opts.round ?? 0) >= AUTO_FIX_ROUNDS) return null;
73612
- const blocking = (review ?? []).filter((f) => f.severity === "blocking");
73613
- if (blocking.length === 0) return null;
73614
- if (isNativeCanvas(canvas)) return { kind: "respec", findings: unique(blocking.map((f) => f.what)) };
73614
+ const flagged = (review ?? []).filter((f) => f.severity === "blocking");
73615
+ if (flagged.length === 0) return null;
73616
+ if (isNativeCanvas(canvas)) return { kind: "respec", findings: unique(flagged.map((f) => f.what)) };
73615
73617
  const relaid = relaidSizes(canvas);
73618
+ const blocking = onDerivedSizes(flagged, relaid);
73616
73619
  const unplaceable = new Set((opts.tooFar ?? []).filter((format) => relaid.some((r) => r.format === format)));
73617
73620
  const misplaced = (f) => {
73618
73621
  const what = withoutSize(f.what);
@@ -73656,8 +73659,8 @@ function autoFixStep(canvas, review, opts = {}) {
73656
73659
  pictureFindings.filter((f) => !BRIEF.test(withoutSize(f.what))).flatMap((f) => correctionOf(f.what) ?? [])
73657
73660
  );
73658
73661
  if (changes.length === 0) return sizesOnly();
73659
- const flagged = new Set(blocking.flatMap((f) => sizesOf(f.what)));
73660
- const keep = relaid.map((r) => r.format).filter((format) => !flagged.has(format));
73662
+ const named = new Set(blocking.flatMap((f) => sizesOf(f.what)));
73663
+ const keep = relaid.map((r) => r.format).filter((format) => !named.has(format));
73661
73664
  const remade = every.filter((size) => !keep.includes(size));
73662
73665
  const kept = {
73663
73666
  ...keep.length > 0 ? { keep } : {},
@@ -73670,6 +73673,17 @@ function autoFixStep(canvas, review, opts = {}) {
73670
73673
  return { kind: "fix", instruction, ...Object.keys(edits).length > 0 ? { relay: edits } : {}, ...kept };
73671
73674
  }
73672
73675
  var unique = (lines) => [...new Set(lines)];
73676
+ var SIZES_FINDING = /^SIZES:/i;
73677
+ var FOLLOW_PICTURE = "Show exactly what the finished ad (Image 2) shows: its people, products, panels and their order, and nothing it does not show.";
73678
+ function onDerivedSizes(findings, relaid) {
73679
+ if (relaid.length === 0) return [...findings];
73680
+ return findings.flatMap((f) => {
73681
+ const sizes = sizesOf(f.what);
73682
+ const onPicture = sizes.length > 0 && sizes.every((size) => !relaid.some((r) => r.format === size));
73683
+ if (!onPicture || !SIZES_FINDING.test(withoutSize(f.what))) return [f];
73684
+ return relaid.map((r) => ({ ...f, what: `${r.format}: ${withoutSize(f.what)}` }));
73685
+ });
73686
+ }
73673
73687
  function deliveredSizes(canvas) {
73674
73688
  const nodes = canvas?.nodes;
73675
73689
  const labels = Array.isArray(nodes) ? nodes.find((n) => n.id === "final" && n.type === "collect")?.params?.labels : void 0;
@@ -75278,7 +75292,7 @@ var runCommand = defineCommand139({
75278
75292
  },
75279
75293
  concurrency: {
75280
75294
  type: "string",
75281
- description: "Max nodes per layer in flight at once (default 8; env BAKER_CANVAS_CONCURRENCY)"
75295
+ description: "Max nodes running at once (default 8; env BAKER_CANVAS_CONCURRENCY)"
75282
75296
  },
75283
75297
  parallel: {
75284
75298
  type: "string",
@@ -76062,7 +76076,7 @@ var rerunCommand = defineCommand140({
76062
76076
  },
76063
76077
  fresh: { type: "boolean", default: false, description: "Start a new run id instead of resuming an interrupted one" },
76064
76078
  regenerate: { type: "string", description: "Comma-separated node ids to force fresh this run" },
76065
- concurrency: { type: "string", description: "Max nodes per layer in flight at once" }
76079
+ concurrency: { type: "string", description: "Max nodes running at once" }
76066
76080
  },
76067
76081
  async run({ args: args8 }) {
76068
76082
  process.stderr.write("[deprecated] `baker canvas rerun <slug>` is now `baker canvas run --slug <slug>`.\n");
@@ -81953,7 +81967,7 @@ var learnCommand = defineCommand158({
81953
81967
 
81954
81968
  // src/commands/creatives/make.ts
81955
81969
  import { execFile as execFile3 } from "child_process";
81956
- import { mkdtemp as mkdtemp2, readFile as readFile38, rm as rm7, writeFile as writeFile24 } from "fs/promises";
81970
+ import { mkdtemp as mkdtemp2, readFile as readFile38, rm as rm7, stat as stat7, writeFile as writeFile24 } from "fs/promises";
81957
81971
  import { tmpdir as tmpdir3 } from "os";
81958
81972
  import path46 from "path";
81959
81973
  import { promisify as promisify3 } from "util";
@@ -82051,8 +82065,16 @@ async function findCandidates(searches, deps) {
82051
82065
  }
82052
82066
  return [];
82053
82067
  }
82054
- async function pickReference(root, searches, deps = liveReferenceDeps(root)) {
82068
+ var candidateOf = (c) => ({
82069
+ adId: String(c.ad_id),
82070
+ platform: asPlatform(c.platform),
82071
+ ...c.advertiser_id ? { advertiserId: c.advertiser_id } : {}
82072
+ });
82073
+ async function pickReference(root, searches, deps = liveReferenceDeps(root), prepare) {
82055
82074
  const candidates = (await findCandidates(searches, deps)).slice(0, FITS_TRIED);
82075
+ const first = candidates[0];
82076
+ const building = first && prepare ? prepare(candidateOf(first)) : void 0;
82077
+ void building?.catch(() => void 0);
82056
82078
  const fits = await Promise.all(candidates.map((c) => deps.fit(asPlatform(c.platform), String(c.ad_id))));
82057
82079
  let unchecked = null;
82058
82080
  let checked = 0;
@@ -82064,14 +82086,13 @@ async function pickReference(root, searches, deps = liveReferenceDeps(root)) {
82064
82086
  if (!(fit.ok && fitsIdea(fit.fit))) continue;
82065
82087
  const layers = fit.fit.why_it_wins;
82066
82088
  return {
82067
- adId: String(candidate.ad_id),
82068
- platform: asPlatform(candidate.platform),
82069
- ...candidate.advertiser_id ? { advertiserId: candidate.advertiser_id } : {},
82089
+ ...candidateOf(candidate),
82070
82090
  why: [layers.disguise, layers.trigger, layers.logic].filter(Boolean).join("; "),
82071
- tried: index + 1
82091
+ tried: index + 1,
82092
+ ...building ? index === 0 ? { prepared: building } : { discarded: building } : {}
82072
82093
  };
82073
82094
  }
82074
- return noReference(candidates.length, checked, unchecked);
82095
+ return { ...noReference(candidates.length, checked, unchecked), ...building ? { discarded: building } : {} };
82075
82096
  }
82076
82097
  function noReference(found, checked, unchecked) {
82077
82098
  if (found > 0 && checked === 0 && unchecked) {
@@ -82139,24 +82160,37 @@ async function scaffoldIdea(root, idea, args8, slug, temperature) {
82139
82160
  reference: null
82140
82161
  };
82141
82162
  }
82142
- const reference = args8.reference ? { adId: args8.reference, platform: asPlatform(args8.platform), why: "chosen by hand", tried: 0 } : args8.fromIdea ? { code: "FROM_IDEA", message: "Asked to start from the idea." } : await pickReference(root, referenceSearchesFor(idea, temperature).map(buildSearchBody));
82143
- if ("code" in reference) {
82144
- return { scaffold: await scaffoldFromIdea(idea, slug, viewerFlags), reference: null, fromIdea: reference.message };
82145
- }
82146
- const scaffold = await baker([
82163
+ const onReference = (c) => baker([
82147
82164
  "canvas",
82148
82165
  "scaffold-static-ad",
82149
82166
  "--source-ad-id",
82150
- reference.adId,
82167
+ c.adId,
82151
82168
  "--source-platform",
82152
- reference.platform,
82153
- ...reference.advertiserId ? ["--source-advertiser-id", reference.advertiserId] : [],
82169
+ c.platform,
82170
+ ...c.advertiserId ? ["--source-advertiser-id", c.advertiserId] : [],
82154
82171
  "--slug",
82155
82172
  slug,
82156
82173
  "--title",
82157
82174
  idea.message.slice(0, 120),
82158
82175
  ...viewerFlags
82159
82176
  ]);
82177
+ const dir = path46.join(root, "src", "creatives", slug);
82178
+ const fresh = !await stat7(dir).catch(() => null);
82179
+ const reference = args8.reference ? { adId: args8.reference, platform: asPlatform(args8.platform), why: "chosen by hand", tried: 0 } : args8.fromIdea ? { code: "FROM_IDEA", message: "Asked to start from the idea." } : await pickReference(
82180
+ root,
82181
+ referenceSearchesFor(idea, temperature).map(buildSearchBody),
82182
+ void 0,
82183
+ fresh ? onReference : void 0
82184
+ );
82185
+ if ("discarded" in reference && reference.discarded) {
82186
+ await reference.discarded.catch(() => void 0);
82187
+ await rm7(dir, { recursive: true, force: true });
82188
+ }
82189
+ if ("code" in reference) {
82190
+ return { scaffold: await scaffoldFromIdea(idea, slug, viewerFlags), reference: null, fromIdea: reference.message };
82191
+ }
82192
+ const prepared = "prepared" in reference ? await reference.prepared?.catch(() => null) : null;
82193
+ const scaffold = prepared?.ok === true ? prepared : await onReference(reference);
82160
82194
  return { scaffold, reference };
82161
82195
  }
82162
82196
  async function scaffoldFromIdea(idea, slug, viewerFlags) {
@@ -82253,6 +82287,7 @@ function makeEnvelope(made) {
82253
82287
  `Rewrite before running: ${made.unsourcedCopy.map((l) => JSON.stringify(l)).join(", ")} claim a figure nothing the company wrote holds (the reference's promise, not ours).`
82254
82288
  ] : [],
82255
82289
  `Write the copy lines and the scene in src/creatives/${made.slug}/prompt.json${made.reference ? ": the drafted lines are the reference's, so keep one only if the Knowledge says it (badges, ratings and guarantees too)" : ""}. Say the message in the customer's words${quote ? ` ("${quote.slice(0, 80)}")` : ""}; keep \`message\` as it is.`,
82290
+ SPEC_SHAPES_HINT,
82256
82291
  `Then: baker canvas run ${made.canvasPath} (it validates and asks the viewer itself: nothing to run before it).`,
82257
82292
  // The scaffold's own next steps name a separate validate; the run does it (dev, Oct 2026: five validates before one run).
82258
82293
  ...made.scaffoldHints.filter((h) => !/canvas (?:validate|viewer-check)/.test(h)).slice(0, 4)
@@ -84030,7 +84065,7 @@ import { readdir as readdir19, readFile as readFile42 } from "fs/promises";
84030
84065
  import path48 from "path";
84031
84066
 
84032
84067
  // src/commands/landing/import-graph.ts
84033
- import { readdir as readdir18, readFile as readFile41, stat as stat7 } from "fs/promises";
84068
+ import { readdir as readdir18, readFile as readFile41, stat as stat8 } from "fs/promises";
84034
84069
  import path47 from "path";
84035
84070
  var SOURCE_EXT = /\.(astro|ts|tsx|js|jsx|mjs|cjs|vue|svelte)$/;
84036
84071
  var RESOLVE_CANDIDATES = [
@@ -84050,7 +84085,7 @@ var IMPORT_RE = /(?<![A-Za-z0-9_$])(?:import|export)\s*(?:[\s\S]*?\bfrom\s*)?["'
84050
84085
  var DYNAMIC_IMPORT_RE = /\bimport\s*\(\s*["']([^"']+)["']\s*\)/g;
84051
84086
  async function isFile(p) {
84052
84087
  try {
84053
- return (await stat7(p)).isFile();
84088
+ return (await stat8(p)).isFile();
84054
84089
  } catch {
84055
84090
  return false;
84056
84091
  }
@@ -84182,7 +84217,7 @@ async function readForms(root, slug) {
84182
84217
 
84183
84218
  // src/commands/experiment/fold.ts
84184
84219
  import { statSync } from "fs";
84185
- import { cp as cp3, mkdir as mkdir15, readdir as readdir20, readFile as readFile43, rm as rm8, stat as stat8, writeFile as writeFile25 } from "fs/promises";
84220
+ import { cp as cp3, mkdir as mkdir15, readdir as readdir20, readFile as readFile43, rm as rm8, stat as stat9, writeFile as writeFile25 } from "fs/promises";
84186
84221
  import path50 from "path";
84187
84222
 
84188
84223
  // ../api/src/experiments/variants.ts
@@ -84249,7 +84284,7 @@ function posix2(p) {
84249
84284
  }
84250
84285
  async function isDir(p) {
84251
84286
  try {
84252
- return (await stat8(p)).isDirectory();
84287
+ return (await stat9(p)).isDirectory();
84253
84288
  } catch {
84254
84289
  return false;
84255
84290
  }
@@ -91651,7 +91686,7 @@ function cropSprite(input, region) {
91651
91686
 
91652
91687
  // src/lib/image/io.ts
91653
91688
  import { randomBytes } from "crypto";
91654
- import { glob as fsGlob, readFile as readFile46, rename as rename2, stat as stat9, writeFile as writeFile26 } from "fs/promises";
91689
+ import { glob as fsGlob, readFile as readFile46, rename as rename2, stat as stat10, writeFile as writeFile26 } from "fs/promises";
91655
91690
  import { dirname as dirname2, extname as extname3, join as join5, resolve as resolve4 } from "path";
91656
91691
  var REMOTE_RE = /^https?:\/\//i;
91657
91692
  var GLOB_RE = /[*?[\]{}]/;
@@ -91688,7 +91723,7 @@ async function readImageBuffer(pathOrUrl) {
91688
91723
  }
91689
91724
  async function isDirectory(path68) {
91690
91725
  try {
91691
- const s = await stat9(path68);
91726
+ const s = await stat10(path68);
91692
91727
  return s.isDirectory();
91693
91728
  } catch {
91694
91729
  return false;
@@ -95146,7 +95181,7 @@ Full guide: __tooling__/docs/tools/baker/images.md`
95146
95181
  import { defineCommand as defineCommand226 } from "citty";
95147
95182
 
95148
95183
  // src/commands/landing/critique.ts
95149
- import { readdir as readdir22, readFile as readFile48, stat as stat11 } from "fs/promises";
95184
+ import { readdir as readdir22, readFile as readFile48, stat as stat12 } from "fs/promises";
95150
95185
  import path55 from "path";
95151
95186
  import { defineCommand as defineCommand213 } from "citty";
95152
95187
 
@@ -96357,7 +96392,7 @@ async function writeCritiqueSnapshot(projectRoot, snapshot) {
96357
96392
  }
96358
96393
 
96359
96394
  // src/commands/landing/source-version.ts
96360
- import { readdir as readdir21, readFile as readFile47, stat as stat10 } from "fs/promises";
96395
+ import { readdir as readdir21, readFile as readFile47, stat as stat11 } from "fs/promises";
96361
96396
  import path54 from "path";
96362
96397
  var CRITIQUED_ROOTS = ["src/pages/", "src/components/"];
96363
96398
  async function landingSourceRelPaths(root, slug) {
@@ -96405,7 +96440,7 @@ async function computeLegacyLandingSourceSha(landingDir) {
96405
96440
  }
96406
96441
  async function isFile2(p) {
96407
96442
  try {
96408
- return (await stat10(p)).isFile();
96443
+ return (await stat11(p)).isFile();
96409
96444
  } catch {
96410
96445
  return false;
96411
96446
  }
@@ -96583,7 +96618,7 @@ function present(f) {
96583
96618
  }
96584
96619
  async function isDir2(p) {
96585
96620
  try {
96586
- return (await stat11(p)).isDirectory();
96621
+ return (await stat12(p)).isDirectory();
96587
96622
  } catch {
96588
96623
  return false;
96589
96624
  }
@@ -99901,7 +99936,7 @@ Full guide: __tooling__/docs/tools/baker/landing.md`
99901
99936
 
99902
99937
  // src/commands/landing/variant.ts
99903
99938
  import { randomUUID as randomUUID4 } from "crypto";
99904
- import { mkdir as mkdir20, readdir as readdir23, readFile as readFile49, stat as stat12, writeFile as writeFile32 } from "fs/promises";
99939
+ import { mkdir as mkdir20, readdir as readdir23, readFile as readFile49, stat as stat13, writeFile as writeFile32 } from "fs/promises";
99905
99940
  import path63 from "path";
99906
99941
  import { defineCommand as defineCommand225 } from "citty";
99907
99942
  registerSchema({
@@ -99953,14 +99988,14 @@ function fail11(code, message, fix) {
99953
99988
  }
99954
99989
  async function isDir3(p) {
99955
99990
  try {
99956
- return (await stat12(p)).isDirectory();
99991
+ return (await stat13(p)).isDirectory();
99957
99992
  } catch {
99958
99993
  return false;
99959
99994
  }
99960
99995
  }
99961
99996
  async function exists2(p) {
99962
99997
  try {
99963
- await stat12(p);
99998
+ await stat13(p);
99964
99999
  return true;
99965
100000
  } catch {
99966
100001
  return false;
@@ -108029,7 +108064,7 @@ var groupCommand2 = defineCommand295({
108029
108064
  });
108030
108065
 
108031
108066
  // src/commands/videos/ingest.ts
108032
- import { mkdtemp as mkdtemp4, rm as rm10, stat as stat13 } from "fs/promises";
108067
+ import { mkdtemp as mkdtemp4, rm as rm10, stat as stat14 } from "fs/promises";
108033
108068
  import { tmpdir as tmpdir5 } from "os";
108034
108069
  import path67 from "path";
108035
108070
  import { defineCommand as defineCommand296 } from "citty";
@@ -108302,7 +108337,7 @@ async function downloadThenIngest(args8, country) {
108302
108337
  // we allow to fetch it cannot drift apart.
108303
108338
  timeoutMs: downloadTimeoutMs(durationSeconds(probe.info))
108304
108339
  });
108305
- const stats = await stat13(filePath);
108340
+ const stats = await stat14(filePath);
108306
108341
  if (stats.size > MAX_VIDEO_INGEST_BYTES) {
108307
108342
  throw new ApiError(
108308
108343
  "VALIDATION_ERROR",
@@ -108463,7 +108498,7 @@ var searchCommand6 = defineCommand298({
108463
108498
  var tagsCommand6 = makeTagsCommand("videos", "video", "/api/videos/tags");
108464
108499
 
108465
108500
  // src/commands/videos/upload.ts
108466
- import { stat as stat14 } from "fs/promises";
108501
+ import { stat as stat15 } from "fs/promises";
108467
108502
  import { basename as basename4 } from "path";
108468
108503
  import { defineCommand as defineCommand299 } from "citty";
108469
108504
  registerSchema({
@@ -108531,7 +108566,7 @@ var uploadCommand2 = defineCommand299({
108531
108566
  const contentType = args8["content-type"] || detectVideoContentType(filePath);
108532
108567
  const descriptionContext = args8.context;
108533
108568
  if (args8["dry-run"]) {
108534
- const fileStats = await stat14(filePath);
108569
+ const fileStats = await stat15(filePath);
108535
108570
  const originalFilename = basename4(filePath);
108536
108571
  writeJson({
108537
108572
  ok: true,