@koda-sl/baker-cli 0.434.0-dev.3587df0fa → 0.434.0-dev.4dbd56be6

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
@@ -70942,6 +70942,17 @@ function badgeWired(spec, name) {
70942
70942
  return Boolean(ref2 && (ref2.image || ref2.slot));
70943
70943
  }
70944
70944
  var CLAIMED_FIGURE = /([£€$])\s?(\d[\d.,]*)|(\d[\d.,]*)\s?(%|[x×](?![a-z])|(?:min(?:ute)?s?|hours?|hrs?|days?|weeks?|months?|years?|minutos?|horas?|d[ií]as?|semanas?|mes(?:es)?|años?)\b)/giu;
70945
+ var TIME_UNITS = [
70946
+ [/^min/i, "min"],
70947
+ [/^(?:hours?|hrs?|horas?)$/i, "(?:hour|hr|hora)"],
70948
+ [/^d[ií]as?$|^days?$/i, "(?:day|d[i\xED]a)"],
70949
+ [/^(?:weeks?|semanas?)$/i, "(?:week|semana)"],
70950
+ [/^(?:months?|mes(?:es)?)$/i, "(?:month|mes)"],
70951
+ [/^(?:years?|años?)$/i, "(?:year|a\xF1o)"]
70952
+ ];
70953
+ function timeUnitStem(unit) {
70954
+ return TIME_UNITS.find(([matches]) => matches.test(unit))?.[1] ?? unit.slice(0, 3).toLowerCase();
70955
+ }
70945
70956
  function figureSourced(match, knowledge2) {
70946
70957
  const [, currency, price, number = "", unit = ""] = match;
70947
70958
  if (currency && price) return figureForms(price.replace(/[.,]$/, "")).some((form) => knowledge2.includes(form));
@@ -70950,7 +70961,7 @@ function figureSourced(match, knowledge2) {
70950
70961
  const sign = unit === "%" ? "%" : "[x\xD7]";
70951
70962
  return forms.some((form) => new RegExp(`(^|[^\\d])${form}\\s?${sign}`, "iu").test(knowledge2));
70952
70963
  }
70953
- const stem = unit.slice(0, 3).toLowerCase();
70964
+ const stem = timeUnitStem(unit);
70954
70965
  return forms.some((form) => {
70955
70966
  const number2 = `(?:^|[^\\d.,])${form}(?![\\d])`;
70956
70967
  return new RegExp(`${number2}[^.!?\\n]{0,60}?${stem}|${stem}[^.!?\\n]{0,60}?${number2}`, "iu").test(knowledge2);
@@ -80277,6 +80288,7 @@ function isValidScaffoldSlug(slug) {
80277
80288
  // src/commands/canvas/sync-definition.ts
80278
80289
  import { readdir as readdir15, readFile as readFile28, stat as stat5 } from "fs/promises";
80279
80290
  import path36 from "path";
80291
+ import { parseDocument as parseDocument3 } from "yaml";
80280
80292
  import { defineCommand as defineCommand144 } from "citty";
80281
80293
 
80282
80294
  // src/commands/canvas/definition-graph.ts
@@ -80338,6 +80350,17 @@ async function readDefinitionSourceFields(canvasPath) {
80338
80350
  return {};
80339
80351
  }
80340
80352
  }
80353
+ async function readDefinitionTitle(canvasPath) {
80354
+ try {
80355
+ const raw = await readFile28(path36.join(path36.dirname(canvasPath), "_definition.md"), "utf8");
80356
+ const match = raw.match(/^---\r?\n([\s\S]*?\r?\n)?---/);
80357
+ const doc = match ? parseDocument3(match[1] ?? "") : null;
80358
+ const title = doc && doc.errors.length === 0 ? doc.get("title") : void 0;
80359
+ return typeof title === "string" && title.trim() ? title.trim() : void 0;
80360
+ } catch {
80361
+ return void 0;
80362
+ }
80363
+ }
80341
80364
  async function readDefinitionStrategyFields(canvasPath) {
80342
80365
  try {
80343
80366
  return parseDefinitionStrategyFields(await readFile28(path36.join(path36.dirname(canvasPath), "_definition.md"), "utf8"));
@@ -80394,6 +80417,10 @@ var syncDefinitionCommand = defineCommand144({
80394
80417
  type: "positional",
80395
80418
  required: true,
80396
80419
  description: "A path under src/creatives/<slug>/ (the .canvas.json, its prompt.json, or the folder)"
80420
+ },
80421
+ title: {
80422
+ type: "boolean",
80423
+ description: "Also record the title its _definition.md gives. Only for a creative just made from another (a series ad, a translation), never on an edit re-sync."
80397
80424
  }
80398
80425
  },
80399
80426
  async run({ args: args8 }) {
@@ -80412,10 +80439,12 @@ var syncDefinitionCommand = defineCommand144({
80412
80439
  } catch {
80413
80440
  return;
80414
80441
  }
80442
+ const title = args8.title ? await readDefinitionTitle(canvasPath) : void 0;
80415
80443
  await syncCreativeDefinitionBestEffort({
80416
80444
  slug,
80417
80445
  canvas,
80418
80446
  sourceSha,
80447
+ ...title ? { title } : {},
80419
80448
  ...await readDefinitionSourceFields(canvasPath),
80420
80449
  ...await readDefinitionStrategyFields(canvasPath)
80421
80450
  });
@@ -86776,7 +86805,7 @@ function learnFromResults(ideas, creatives, asOf) {
86776
86805
  }
86777
86806
 
86778
86807
  // src/commands/creatives/make-model.ts
86779
- import { parse as parse4, parseDocument as parseDocument3, Scalar, visit } from "yaml";
86808
+ import { parse as parse4, parseDocument as parseDocument4, Scalar, visit } from "yaml";
86780
86809
  var REFERENCE_CANDIDATES = 6;
86781
86810
  function isVideoIdea(idea) {
86782
86811
  return IDEA_VIDEO_FORMATS.includes(idea.format);
@@ -86833,7 +86862,7 @@ function readsAsText11(text4) {
86833
86862
  function setDefinitionFields(raw, fields) {
86834
86863
  const match = raw.match(FRONTMATTER3);
86835
86864
  if (!match) return raw;
86836
- const doc = parseDocument3(match[1] ?? "");
86865
+ const doc = parseDocument4(match[1] ?? "");
86837
86866
  if (doc.errors.length > 0) return raw;
86838
86867
  for (const [key, value2] of Object.entries(fields)) {
86839
86868
  if (value2 === void 0) continue;
@@ -86990,12 +87019,12 @@ import { defineCommand as defineCommand164 } from "citty";
86990
87019
  // src/commands/creatives/make-series.ts
86991
87020
  import { mkdir as mkdir16, readFile as readFile40, writeFile as writeFile26 } from "fs/promises";
86992
87021
  import path50 from "path";
86993
- import { parseDocument as parseDocument4 } from "yaml";
87022
+ import { parseDocument as parseDocument5 } from "yaml";
86994
87023
  var LEAD_ONLY = ["idea", "message", "evidence", "angle", "persona", "awareness", "hypothesis", "series", "title"];
86995
87024
  function withoutFields(raw, keys) {
86996
87025
  const match = raw.match(/^---\r?\n([\s\S]*?\r?\n)?---/);
86997
87026
  if (!match) return raw;
86998
- const doc = parseDocument4(match[1] ?? "");
87027
+ const doc = parseDocument5(match[1] ?? "");
86999
87028
  if (doc.errors.length > 0) return raw;
87000
87029
  for (const key of keys) doc.delete(key);
87001
87030
  return `---
@@ -87421,7 +87450,7 @@ async function makeInSeries(root, idea, slug, lead, evidence) {
87421
87450
  });
87422
87451
  }
87423
87452
  const made = await makeSeriesAd(root, idea, slug, lead, evidence, {
87424
- sync: (dir) => runBaker(["canvas", "sync-definition", dir]),
87453
+ sync: (dir) => runBaker(["canvas", "sync-definition", dir, "--title"]),
87425
87454
  chatId: optionalChatId() ?? null
87426
87455
  });
87427
87456
  if ("code" in made) fail7(made);
@@ -88257,7 +88286,7 @@ var translateCommand = defineCommand167({
88257
88286
  ),
88258
88287
  ...copy !== void 0 ? { copy } : {},
88259
88288
  again: args8.again === true,
88260
- sync: (dir) => runBaker(["canvas", "sync-definition", dir]),
88289
+ sync: (dir) => runBaker(["canvas", "sync-definition", dir, "--title"]),
88261
88290
  chatId: optionalChatId() ?? null
88262
88291
  });
88263
88292
  await holdUnbilledSpend(path53.join(root, "canvas", ".cache"), spent);