@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/README.md CHANGED
@@ -1817,7 +1817,7 @@ baker creatives learn [--days <n>] [--dry-run] # what each idea'
1817
1817
  - `brief` returns a verdict, not raw numbers: `account.bottleneck` is `hook`, `after_click`, `none` or `too_little_data`. A part that cannot be read says `unavailable`. `market` says what competitors' ads already say (the followed brands, else the library), how sophisticated the market is, and which awareness stages nobody speaks to.
1818
1818
  - `ideas` is free and local. An idea's `evidence` resolves to `src/content/insights/` entries, or it is an `explore` bet. Numbers must be in the Knowledge or our own customers' quotes (a Reddit, forum or web quote never sources a claim), no two ideas may share an angle and format, and a review or testimonial format needs a quote from our own customer.
1819
1819
  - `learn` pools each built idea's creatives, judges them against the rest of the account's cost per result and writes `status` (`winner`, `failed`, `inconclusive`, `testing`) and a frozen `result` onto the idea. `ideas` then warns when a new idea repeats a failed one.
1820
- - `make` builds one idea. A static searches the idea's container for ads made for our viewer, checks the closest three with `winning-ads fit` and scaffolds from the first that fits. A video idea takes its beats spec. Either way it records the idea on `_definition.md`, sets `prompt.json`'s `message` and syncs the definition. Drafted copy lines claiming a figure the company never wrote come back first in `hints`. When no proven ad fits (or with `--from-idea`), a static starts from the idea itself: `prompt.json` holds the message and placeholders, and `canvas run` refuses to render until the scene and copy are written.
1820
+ - `make` builds one idea. A static searches the idea's container for ads made for our viewer, checks the closest three with `winning-ads fit` and scaffolds from the first that fits. For a new creative it starts scaffolding the best-ranked one while the fits are asked (kept when it fits, removed whole when another is kept), so the reference's describe pass no longer waits for them. A video idea takes its beats spec. Either way it records the idea on `_definition.md`, sets `prompt.json`'s `message` and syncs the definition. Drafted copy lines claiming a figure the company never wrote come back first in `hints`. When no proven ad fits (or with `--from-idea`), a static starts from the idea itself: `prompt.json` holds the message and placeholders, and `canvas run` refuses to render until the scene and copy are written.
1821
1821
 
1822
1822
  ### Competitive Intelligence (`baker research`)
1823
1823
 
@@ -5879,7 +5879,7 @@ A completed render the review calls ready (`verdict` `ready` or `ready_with_note
5879
5879
 
5880
5880
  **Resuming an interrupted run.** A long `baker canvas run` (multi-clip video) that is killed mid-render — session end, sandbox pause — leaves a marker under the outputs dir. The next `baker canvas run` of the same canvas automatically **resumes** that run: it reuses the run id so still-running billed jobs re-attach instead of being abandoned and re-billed, and completed nodes come from the cache. A live render keeps its marker's heartbeat fresh, so a second `run` of the same canvas is refused while it is alive (checked with `kill(pid, 0)` plus the heartbeat, on Linux and macOS alike). Resume also works from a **different workspace or a fresh sandbox**: when no local marker survives, the run history is consulted for a resumable run of the same source (canvas, `prompt.json`, scenes, compositions and formats), and it is adopted when the backend says it may be: interrupted, stopped at a checkpoint, or a `running` row whose keepalive is older than the backend's staleness threshold. Ctrl-C / SIGTERM aborts gracefully — no new nodes dispatch, a resumable snapshot is flushed, and the marker survives. A clean completion (or a handled failure) clears the marker, so a normal re-run starts a fresh generation. Force a new run with `--fresh`, or pin a specific run with `--run-id <id>` (also the escape hatch to adopt a run that is reported as concurrently live). Independent same-layer nodes (e.g. video clips) fan out in parallel up to `--parallel`/`--concurrency` (default 8; env `BAKER_CANVAS_CONCURRENCY`).
5881
5881
 
5882
- **Static ads: the run corrects a blocking defect itself.** When the review of a static ad finds a blocking defect, `baker canvas run` makes up to 2 more renders (`AUTO_FIX_ROUNDS` in `static-autofix.ts`) before it reports, correcting each defect at the layer that causes it: words or a logo where an interface covers them (Reels, Stories) or the frame cuts them are **placed and extended** (`withExtendedSizes`): a `static_place` node reads where everything sits and shrinks the ad (to 60% at most) into the size's safe area, and a `static_extend_merge` node has the ad's own model paint only the margins that leaves and lays the ad's own pixels back over the painting, so the model is never asked to move anything (a size already inside its area is passed on with nothing painted or billed, and one whose words sit too far out for a shrink to clear is laid out again instead); a defect the spec asked for (a second subject, stars with no named source, a concept that does not read) and any defect of a native screen corrects the spec first (`static-spec-repair.ts`: a model rewrites `prompt.json` for those findings alone, every line of the copy kept word for word), then draws the ad again from it (a native screen redraws free); a picture wrong as a whole or in three places or more is made again from its brief, told what the last one got wrong, but only in a round with another after it unless the brief caused the defect; anything else on the picture is a `--fix` of the chosen picture for its own findings (`correctionOf`: the words to erase, the line to re-letter or add), naming what the last edit was already asked for, while each re-laid size the review flagged follows as an edit of its own last layout (`withSizesFollowingFix`), keeping what an earlier round fixed in it, and a size it found nothing blocking on is delivered as it was (`keep`, nothing in it made again or placed); anything else on a re-laid size alone edits just that size from its own last layout (`withRelayEdit`). A size a round did not touch (its file the same byte for byte) keeps the round before's verdict (`carryUnchanged`) and is not read again: the review reads only the sizes the round changed. Each round is one render (a fix, or one request per re-laid size) and prints `[autofix] round N of 2: …` on stdout; the final JSON's hints start with "Corrected automatically before this result, …" and its review is of the corrected version. Blocking findings left after the rounds keep the hints below. A round that would only repeat the correction that just left its defect in place (a chosen option, `--use-variant`, is only ever corrected) is not run: that version is reported as it is. `--no-autofix` reports after the first render.
5882
+ **Static ads: the run corrects a blocking defect itself.** When the review of a static ad finds a blocking defect, `baker canvas run` makes up to 2 more renders (`AUTO_FIX_ROUNDS` in `static-autofix.ts`) before it reports, correcting each defect at the layer that causes it: words or a logo where an interface covers them (Reels, Stories) or the frame cuts them are **placed and extended** (`withExtendedSizes`): a `static_place` node reads where everything sits and shrinks the ad (to 60% at most) into the size's safe area, and a `static_extend_merge` node has the ad's own model paint only the margins that leaves and lays the ad's own pixels back over the painting, so the model is never asked to move anything (a size already inside its area is passed on with nothing painted or billed, and one whose words sit too far out for a shrink to clear is laid out again instead); a defect the spec asked for (a second subject, stars with no named source, a concept that does not read) and any defect of a native screen corrects the spec first (`static-spec-repair.ts`: a model rewrites `prompt.json` for those findings alone, every line of the copy kept word for word), then draws the ad again from it (a native screen redraws free); a picture wrong as a whole or in three places or more is made again from its brief, told what the last one got wrong, but only in a round with another after it unless the brief caused the defect; anything else on the picture is a `--fix` of the chosen picture for its own findings (`correctionOf`: the words to erase, the line to re-letter or add), naming what the last edit was already asked for, while each re-laid size the review flagged follows as an edit of its own last layout (`withSizesFollowingFix`), keeping what an earlier round fixed in it, and a size it found nothing blocking on is delivered as it was (`keep`, nothing in it made again or placed); anything else on a re-laid size alone edits just that size from its own last layout (`withRelayEdit`); sizes that do not show the same ad (`SIZES:`) are always the re-laid ones' fault, since every size follows the chosen picture, so they are laid out again to show exactly what it shows, never the picture edited to match them. A size a round did not touch (its file the same byte for byte) keeps the round before's verdict (`carryUnchanged`) and is not read again: the review reads only the sizes the round changed. Each round is one render (a fix, or one request per re-laid size) and prints `[autofix] round N of 2: …` on stdout; the final JSON's hints start with "Corrected automatically before this result, …" and its review is of the corrected version. Blocking findings left after the rounds keep the hints below. A round that would only repeat the correction that just left its defect in place (a chosen option, `--use-variant`, is only ever corrected) is not run: that version is reported as it is. `--no-autofix` reports after the first render.
5883
5883
 
5884
5884
  **Static ads: correct a version, or use another of its variants.** Correct a finished version with `--fix "<what to change>"`: one render takes that version (the last one, or `--from <run_id>`) as its first reference and changes only what you said, keeping the picture, the layout and every other word; it replaces the variants and the judge, and every size is made again from the corrected picture. **A `prompt.json` changed only in its words, their positions or its colours** since the version shown is made the same way, as an edit of that version (`[edit]` in the output, the instruction read off the change); three new options are asked for only with `--regenerate static_variants`. A `--fix` whose defect is still blocking afterwards is recorded, and asking for it again with the same words exits 2 with `no_progress`. When every blocking finding is on re-laid-out sizes, the first hint says to lay out those sizes again (`--regenerate adapt_<size>`) before any `--fix`. Every static run's hints say what it cost in credits and what for. There is no render limit per creative. Use another variant with `--use-variant <sha256>` (`--from <run_id>`, default the last render): when the person chose another of a version's variants over the judge's pick, every size is made again from that picture, and the only requests re-lay it out for each other size; `--regenerate adapt_9x16` lays out one size again from the same chosen picture when only that size came out wrong (after a `--fix` or `--use-variant`, from that corrected or chosen picture, so the size never brings back the uncorrected one; `--from <run_id>` names another version); `baker creatives feedback --slug <slug>` prints the choice (`variantChoice`) and the exact command.
5885
5885
 
@@ -3594,23 +3594,6 @@ function resolveConcurrency(...candidates) {
3594
3594
  }
3595
3595
  return DEFAULT_CONCURRENCY;
3596
3596
  }
3597
- async function mapWithConcurrency(items, limit, fn) {
3598
- const results = new Array(items.length);
3599
- let next = 0;
3600
- const worker = async () => {
3601
- while (next < items.length) {
3602
- const index = next++;
3603
- try {
3604
- results[index] = { status: "fulfilled", value: await fn(items[index], index) };
3605
- } catch (reason) {
3606
- results[index] = { status: "rejected", reason };
3607
- }
3608
- }
3609
- };
3610
- const workers = Array.from({ length: Math.min(limit, items.length) }, worker);
3611
- await Promise.all(workers);
3612
- return results;
3613
- }
3614
3597
 
3615
3598
  // src/engine/lib/json-walk.ts
3616
3599
  function isContainerObject(value) {
@@ -6956,8 +6939,9 @@ var FIELD_SHAPES = {
6956
6939
  references: '"references": [{"id": "PRODUCT_1", "role": "product", "what": "the solar panel kit"}]',
6957
6940
  third_party_brands: '"third_party_brands": [{"name": "Trustpilot", "role": "proof", "logo": "BADGE_1"}]',
6958
6941
  mechanism: '"mechanism": [{"device": "a before and after", "why_it_works": "the change is seen, not told"}]',
6959
- viewer: '"viewer": {"who": "homeowners with high energy bills"}'
6942
+ viewer: '"viewer": {"who": "homeowners with high energy bills", "knows": "nothing about us yet"}'
6960
6943
  };
6944
+ var SPEC_SHAPES_HINT = `prompt.json shapes: ${["copy", "colors", "viewer"].map((f) => FIELD_SHAPES[f]).join("; ")}.`;
6961
6945
  function adSpecErrorText(e) {
6962
6946
  if (!(e instanceof z7.ZodError)) return e instanceof Error ? e.message : String(e);
6963
6947
  const items = /* @__PURE__ */ new Map();
@@ -10251,6 +10235,17 @@ function unwrap(schema) {
10251
10235
  }
10252
10236
 
10253
10237
  // src/engine/engine/executor.ts
10238
+ function throwRunOutcome(signal, failures, held) {
10239
+ if (signal?.aborted) throw new RunAbortedError("signal", "run aborted by signal");
10240
+ if (failures.length === 1 && failures[0]) throw failures[0].reason;
10241
+ if (failures.length > 1) throw new LayerExecutionError([...failures]);
10242
+ if (held.length > 0) {
10243
+ throw new RunAbortedError(
10244
+ "checkpoint",
10245
+ `stopped before ${held.join(", ")} \u2014 everything up to here is done and cached, so continuing this run id pays for none of it again`
10246
+ );
10247
+ }
10248
+ }
10254
10249
  function heldByCheckpoint(canvas, layer, kinds) {
10255
10250
  if (!kinds?.size) return [];
10256
10251
  return layer.filter((id) => {
@@ -10339,45 +10334,61 @@ var Engine = class {
10339
10334
  return { run_id: runId, output, outputs_by_node: outputs, stats, outputs_dir: writer.runDir, node_runs: nodeRuns };
10340
10335
  }
10341
10336
  async runLayers(canvas, graph, outputs, runId, writer, opts, counters, nodeRuns, needsBytes) {
10342
- const layers = topologicalLayers(graph);
10337
+ const order = topologicalLayers(graph).flat();
10343
10338
  const limit = resolveConcurrency(opts.concurrency);
10344
- for (const layer of layers) {
10345
- this.assertLayerMayRun(canvas, layer, opts);
10346
- const settled = await mapWithConcurrency(layer, limit, (nodeId) => {
10347
- if (opts.signal?.aborted) {
10348
- return Promise.reject(new RunAbortedError("signal", "run aborted before node dispatch"));
10349
- }
10350
- this.emitProgress(opts, { kind: "node_start", node_id: nodeId });
10351
- return this.executeOne(canvas, nodeId, outputs, runId, writer, opts, needsBytes.has(nodeId)).then((r) => {
10352
- if (r.cached) counters.cachedNodes++;
10353
- counters.totalCredits += r.credits;
10354
- const node = canvas.nodes.find((n) => n.id === nodeId);
10355
- if (node) {
10356
- const run = {
10357
- node_id: nodeId,
10358
- node_type: node.type,
10359
- cached: r.cached,
10360
- duration_ms: r.durationMs,
10361
- credits: r.credits
10362
- };
10363
- nodeRuns.push(run);
10364
- this.emitProgress(opts, { kind: "node_settled", run, outputs: outputs[nodeId] ?? {} });
10365
- }
10366
- });
10367
- });
10368
- const failures = [];
10369
- settled.forEach((result, i) => {
10370
- const nodeId = layer[i];
10371
- if (result.status === "rejected" && nodeId) {
10372
- if (result.reason instanceof RunAbortedError) return;
10373
- failures.push({ nodeId, reason: result.reason });
10374
- this.emitProgress(opts, { kind: "node_failed", node_id: nodeId, error: failureDetail(result.reason) });
10339
+ if (opts.signal?.aborted) throw new RunAbortedError("signal", "run aborted before dispatch");
10340
+ const waitingOn = new Map(order.map((id) => [id, new Set(graph.get(id) ?? [])]));
10341
+ const running = /* @__PURE__ */ new Map();
10342
+ const failures = [];
10343
+ const held = [];
10344
+ const dispatch = (nodeId) => {
10345
+ waitingOn.delete(nodeId);
10346
+ this.emitProgress(opts, { kind: "node_start", node_id: nodeId });
10347
+ const settled = this.executeOne(canvas, nodeId, outputs, runId, writer, opts, needsBytes.has(nodeId)).then(
10348
+ (r) => {
10349
+ this.recordRun(canvas, nodeId, r, counters, nodeRuns, outputs, opts);
10350
+ for (const deps of waitingOn.values()) deps.delete(nodeId);
10351
+ },
10352
+ (reason) => {
10353
+ failures.push({ nodeId, reason });
10354
+ this.emitProgress(opts, { kind: "node_failed", node_id: nodeId, error: failureDetail(reason) });
10375
10355
  }
10376
- });
10377
- if (opts.signal?.aborted) throw new RunAbortedError("signal", "run aborted by signal");
10378
- if (failures.length === 1 && failures[0]) throw failures[0].reason;
10379
- if (failures.length > 1) throw new LayerExecutionError(failures);
10356
+ );
10357
+ running.set(
10358
+ nodeId,
10359
+ settled.finally(() => running.delete(nodeId))
10360
+ );
10361
+ };
10362
+ const isHeld = (nodeId) => heldByCheckpoint(canvas, [nodeId], opts.stop_before_kinds).length > 0;
10363
+ for (; ; ) {
10364
+ const ready = opts.signal?.aborted ? [] : order.filter((id) => waitingOn.get(id)?.size === 0);
10365
+ for (const nodeId of ready) {
10366
+ if (running.size >= limit) break;
10367
+ if (isHeld(nodeId)) {
10368
+ waitingOn.delete(nodeId);
10369
+ held.push(nodeId);
10370
+ } else dispatch(nodeId);
10371
+ }
10372
+ if (running.size === 0) break;
10373
+ await Promise.race(running.values());
10380
10374
  }
10375
+ throwRunOutcome(opts.signal, failures, held);
10376
+ }
10377
+ /** A settled node counted, recorded and announced. */
10378
+ recordRun(canvas, nodeId, r, counters, nodeRuns, outputs, opts) {
10379
+ if (r.cached) counters.cachedNodes++;
10380
+ counters.totalCredits += r.credits;
10381
+ const node = canvas.nodes.find((n) => n.id === nodeId);
10382
+ if (!node) return;
10383
+ const run = {
10384
+ node_id: nodeId,
10385
+ node_type: node.type,
10386
+ cached: r.cached,
10387
+ duration_ms: r.durationMs,
10388
+ credits: r.credits
10389
+ };
10390
+ nodeRuns.push(run);
10391
+ this.emitProgress(opts, { kind: "node_settled", run, outputs: outputs[nodeId] ?? {} });
10381
10392
  }
10382
10393
  /** Progress consumers are observers only — an exception there must never fail the run. */
10383
10394
  emitProgress(opts, event) {
@@ -10469,20 +10480,6 @@ var Engine = class {
10469
10480
  this.logOutputWarnings(node.id, outputsObj);
10470
10481
  return { cached: false, credits, durationMs: elapsed };
10471
10482
  }
10472
- /**
10473
- * Every reason a layer must not dispatch, checked before any of its nodes starts, so a stop
10474
- * never leaves a layer half billed: a signal, the cost cap and a checkpoint.
10475
- */
10476
- assertLayerMayRun(canvas, layer, opts) {
10477
- if (opts.signal?.aborted) throw new RunAbortedError("signal", "run aborted before layer dispatch");
10478
- const held = heldByCheckpoint(canvas, layer, opts.stop_before_kinds);
10479
- if (held.length > 0) {
10480
- throw new RunAbortedError(
10481
- "checkpoint",
10482
- `stopped before ${held.join(", ")} \u2014 everything up to here is done and cached, so continuing this run id pays for none of it again`
10483
- );
10484
- }
10485
- }
10486
10483
  /** A cache hit replayed as this node's result: its outputs written, and free. */
10487
10484
  async replayCached(node, cacheKey, outputs, writer) {
10488
10485
  const cacheT0 = Date.now();
@@ -15752,7 +15749,7 @@ function contextItems(opts) {
15752
15749
  opts.thumbnails ? "7. THUMBNAIL: at thumbnail size the lead line (the largest words) cannot be read. Judge only whether those words can be read, nothing else. That is blocking: most people only ever see the ad that small." : "7. THUMBNAIL: the lead line (the largest words) would be unreadable on a phone feed. That is blocking."
15753
15750
  ],
15754
15751
  sizes: opts.formats.length > 1 ? [
15755
- "12. SIZES: one size loses what the others are built on: the letter sheet, the email or chat window, the post card, the comic's panels and their order, the product the ad is about (blocking). Rearranged for its shape is fine."
15752
+ `12. SIZES: one size loses what the others are built on: the letter sheet, the email or chat window, the post card, the comic's panels and their order, the product the ad is about, or a size that shows something the others do not (blocking; start the finding with "SIZES:" and report it on the size that differs). Rearranged for its shape is fine.`
15756
15753
  ] : []
15757
15754
  };
15758
15755
  }
@@ -18531,6 +18528,7 @@ export {
18531
18528
  conceptProblems,
18532
18529
  unwrittenProblems,
18533
18530
  sceneWordProblems,
18531
+ SPEC_SHAPES_HINT,
18534
18532
  adSpecErrorText,
18535
18533
  readAdSpec,
18536
18534
  withRenderedLettering,
@@ -18619,4 +18617,4 @@ export {
18619
18617
  defaultRegistry,
18620
18618
  createEngineFromEnv
18621
18619
  };
18622
- //# sourceMappingURL=chunk-CYZ7H4F5.js.map
18620
+ //# sourceMappingURL=chunk-WMAHVZMY.js.map